@fedify/relay 2.3.16-dev.2841 → 2.3.16

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-BOutl7lc.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-Ek6iDzG8.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-BOutl7lc.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-Ek6iDzG8.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";
@@ -6,7 +6,7 @@ import { getLogger } from "@logtape/logtape";
6
6
  import dns from "node:dns/promises";
7
7
  import { isIP } from "node:net";
8
8
  import process$1 from "node:process";
9
- //#region ../vocab-runtime/dist/public-fetch-Dfmc_Kfy.js
9
+ //#region ../vocab-runtime/dist/crypto-key-BR2FO0pB.js
10
10
  const grants = /* @__PURE__ */ new WeakMap();
11
11
  /**
12
12
  * Issues a grant for the given URL's origin and addresses. This does not
@@ -80,6 +80,81 @@ function lookupAllAddresses(hostname) {
80
80
  return dns.lookup(hostname, { all: true });
81
81
  }
82
82
  /**
83
+ * Limits concurrent lookups started by the returned function. A pending
84
+ * caller can abort before its lookup starts. Once `dns.lookup()` has started,
85
+ * it cannot be cancelled, so its slot remains occupied until the underlying
86
+ * lookup settles, even if its caller aborts. This bounds the number of
87
+ * outstanding getaddrinfo calls made by users of this function.
88
+ * @internal
89
+ */
90
+ function createBoundedLookup(lookup, maxConcurrent = 1) {
91
+ if (!Number.isInteger(maxConcurrent) || maxConcurrent < 1) throw new RangeError("maxConcurrent must be a positive integer");
92
+ let active = 0;
93
+ const waiting = /* @__PURE__ */ new Set();
94
+ function release() {
95
+ active--;
96
+ while (waiting.size > 0) {
97
+ const next = waiting.values().next().value;
98
+ waiting.delete(next);
99
+ next.signal?.removeEventListener("abort", next.onAbort);
100
+ if (next.signal?.aborted) {
101
+ next.reject(next.signal.reason);
102
+ continue;
103
+ }
104
+ active++;
105
+ next.resolve();
106
+ break;
107
+ }
108
+ }
109
+ function acquire(signal) {
110
+ signal?.throwIfAborted();
111
+ if (active < maxConcurrent) {
112
+ active++;
113
+ return Promise.resolve();
114
+ }
115
+ return new Promise((resolve, reject) => {
116
+ const entry = {
117
+ signal,
118
+ resolve,
119
+ reject,
120
+ onAbort() {
121
+ if (!waiting.delete(entry)) return;
122
+ signal?.removeEventListener("abort", entry.onAbort);
123
+ reject(signal?.reason);
124
+ }
125
+ };
126
+ waiting.add(entry);
127
+ signal?.addEventListener("abort", entry.onAbort, { once: true });
128
+ if (signal?.aborted) entry.onAbort();
129
+ });
130
+ }
131
+ return async (hostname, signal) => {
132
+ await acquire(signal);
133
+ let started = false;
134
+ try {
135
+ signal?.throwIfAborted();
136
+ const pending = lookup(hostname);
137
+ started = true;
138
+ pending.then(release, release);
139
+ if (signal == null) return await pending;
140
+ let onAbort;
141
+ const aborted = new Promise((_, reject) => {
142
+ onAbort = () => reject(signal.reason);
143
+ signal.addEventListener("abort", onAbort, { once: true });
144
+ if (signal.aborted) onAbort();
145
+ });
146
+ try {
147
+ return await Promise.race([pending, aborted]);
148
+ } finally {
149
+ if (onAbort != null) signal.removeEventListener("abort", onAbort);
150
+ }
151
+ } finally {
152
+ if (!started) release();
153
+ }
154
+ };
155
+ }
156
+ createBoundedLookup(lookupAllAddresses, 2);
157
+ /**
83
158
  * Checks the parts of a URL that can be validated without resolving it:
84
159
  * the protocol, the `localhost` hostname, and IP literal hostnames.
85
160
  * @throws {UrlError} If the URL is not allowed.
@@ -731,6 +806,17 @@ function logUnpinned(url) {
731
806
  protocol: url.protocol
732
807
  });
733
808
  }
809
+ /**
810
+ * Narrows a {@link CryptoKeyLike} to the ambient `CryptoKey` type, for passing
811
+ * it to `crypto.subtle` or to APIs that still declare the ambient type.
812
+ *
813
+ * This is internal to Fedify and is not exported from the package entry point.
814
+ * @param key The key to narrow.
815
+ * @returns The same key, typed as the ambient `CryptoKey`.
816
+ */
817
+ function asCryptoKey(key) {
818
+ return key;
819
+ }
734
820
  //#endregion
735
821
  //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/version.js
736
822
  const VERSION = "1.9.1";
@@ -26545,7 +26631,7 @@ const preloadedContexts = {
26545
26631
  } }
26546
26632
  };
26547
26633
  var name = "@fedify/vocab-runtime";
26548
- var version = "2.3.16-dev.2841+a3847aa4";
26634
+ var version = "2.3.16";
26549
26635
  /**
26550
26636
  * Error thrown when fetching a JSON-LD document failed.
26551
26637
  */
@@ -27374,7 +27460,7 @@ constants.reduce((prev, tupple) => {
27374
27460
  */
27375
27461
  async function exportSpki(key) {
27376
27462
  validateCryptoKey(key);
27377
- let pem = a(await crypto.subtle.exportKey("spki", key));
27463
+ let pem = a(await crypto.subtle.exportKey("spki", asCryptoKey(key)));
27378
27464
  pem = (pem.match(/.{1,64}/g) || []).join("\n");
27379
27465
  return `-----BEGIN PUBLIC KEY-----\n${pem}\n-----END PUBLIC KEY-----\n`;
27380
27466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/relay",
3
- "version": "2.3.16-dev.2841+a3847aa4",
3
+ "version": "2.3.16",
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/vocab": "2.3.16-dev.2841+a3847aa4",
54
- "@fedify/fedify": "^2.3.16-dev.2841+a3847aa4"
53
+ "@fedify/fedify": "^2.3.16",
54
+ "@fedify/vocab": "2.3.16"
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.16-dev.2841+a3847aa4"
60
+ "@fedify/vocab-runtime": "^2.3.16"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",