@toon-protocol/client 5.0.0 → 5.0.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toon-protocol/client",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "TOON client: pay for HTTP requests per request over ILP, with EVM and Solana payment channels",
5
5
  "license": "MIT",
6
6
  "author": "Jonathan Green",
@@ -1,230 +0,0 @@
1
- // src/cli/anon-daemon.ts
2
- import { createRequire } from "module";
3
- var nodeRequire = createRequire(import.meta.url);
4
- var ANON_VERSION = "v0.4.10.2";
5
- var RELEASE_BASE = `https://github.com/anyone-protocol/ator-protocol/releases/download/${ANON_VERSION}`;
6
- var ANON_ASSETS = {
7
- "linux-x64": {
8
- assetName: "anon-live-linux-amd64.zip",
9
- sha256: "9c6498b8d27de54d78842a1b854979a605f9c140ccc34f2b4c267bf094eaeb17"
10
- },
11
- "linux-arm64": {
12
- assetName: "anon-live-linux-arm64.zip",
13
- sha256: "daa3ed15f321d83f22b9c03fad2c0f908e60e3e156d143774bd38194244ebec9"
14
- },
15
- "darwin-x64": {
16
- assetName: "anon-live-macos-amd64.zip",
17
- sha256: "38b5b7ce1ed847e791e56697385365918fbcf81d08def0d389abd8e31e58b975"
18
- },
19
- "darwin-arm64": {
20
- assetName: "anon-live-macos-arm64.zip",
21
- sha256: "8f662cc5ecba27b5ec07dbed897894bd6f0e6c5ff33ca01f3a1d19544ac67866"
22
- },
23
- "win32-x64": {
24
- assetName: "anon-live-windows-signed-amd64.zip",
25
- sha256: "e7352c4436e2043cfe505a35f1f412e01c72a5aa671cb85af2dcf97da83df4ab"
26
- }
27
- };
28
- function selectAnonAsset(platform, arch) {
29
- const asset = ANON_ASSETS[`${platform}-${arch}`];
30
- if (!asset) {
31
- throw new Error(
32
- `No pinned anon binary for ${platform}-${arch}. Supported: ${Object.keys(ANON_ASSETS).join(", ")}. Run your own daemon and pass --socks instead.`
33
- );
34
- }
35
- return asset;
36
- }
37
- function defaultCacheDir() {
38
- const os = nodeRequire("node:os");
39
- const path = nodeRequire("node:path");
40
- const xdg = process.env["XDG_CACHE_HOME"];
41
- return xdg ? path.join(xdg, "toon", "anon", ANON_VERSION) : path.join(os.homedir(), ".toon", "anon", ANON_VERSION);
42
- }
43
- function renderTorrc(cacheDir, socksPort) {
44
- const path = nodeRequire("node:path");
45
- return [
46
- "AgreeToTerms 1",
47
- `DataDirectory ${path.join(cacheDir, "data")}`,
48
- `SOCKSPort 127.0.0.1:${socksPort}`,
49
- "SOCKSPolicy accept *",
50
- `GeoIPFile ${path.join(cacheDir, "geoip")}`,
51
- `GeoIPv6File ${path.join(cacheDir, "geoip6")}`,
52
- "Log notice stdout",
53
- "RunAsDaemon 0",
54
- ""
55
- ].join("\n");
56
- }
57
- async function startManagedAnon(options = {}) {
58
- const fs = nodeRequire("node:fs");
59
- const path = nodeRequire("node:path");
60
- const cp = nodeRequire("node:child_process");
61
- const log = options.log ?? (() => void 0);
62
- const cacheDir = options.cacheDir ?? defaultCacheDir();
63
- const anonPath = await ensureAnonBinary(cacheDir, log);
64
- const port = await freePort();
65
- fs.mkdirSync(path.join(cacheDir, "data"), { recursive: true, mode: 448 });
66
- const torrcPath = path.join(cacheDir, "torrc");
67
- fs.writeFileSync(torrcPath, renderTorrc(cacheDir, port), { mode: 384 });
68
- log(`starting anon ${ANON_VERSION} on 127.0.0.1:${port} (${anonPath})`);
69
- const child = cp.spawn(anonPath, ["-f", torrcPath], { stdio: ["ignore", "pipe", "pipe"] });
70
- let exited = false;
71
- let lastLine = "";
72
- child.on("exit", () => {
73
- exited = true;
74
- });
75
- child.stdout?.on("data", (data) => {
76
- lastLine = data.toString().trim().split("\n").pop() ?? lastLine;
77
- });
78
- child.stderr?.on("data", (data) => {
79
- lastLine = data.toString().trim().split("\n").pop() ?? lastLine;
80
- });
81
- const stop = () => {
82
- if (!exited) child.kill("SIGTERM");
83
- };
84
- try {
85
- await waitForSocksPort(port, options.bootstrapTimeoutMs ?? 9e4, () => exited, () => lastLine);
86
- } catch (error) {
87
- stop();
88
- throw error;
89
- }
90
- log(`anon is listening; building circuits on demand`);
91
- return { socksProxy: `socks5h://127.0.0.1:${port}`, port, stop };
92
- }
93
- async function ensureAnonBinary(cacheDir, log = () => void 0) {
94
- const fs = nodeRequire("node:fs");
95
- const path = nodeRequire("node:path");
96
- const os = nodeRequire("node:os");
97
- const exe = os.platform() === "win32" ? "anon.exe" : "anon";
98
- const anonPath = path.join(cacheDir, exe);
99
- if (fs.existsSync(anonPath)) return anonPath;
100
- const asset = selectAnonAsset(os.platform(), os.arch());
101
- if (asset.sha256 === null) {
102
- throw new Error(
103
- `The anon asset ${asset.assetName} has no pinned checksum, so it will not be downloaded. Run your own daemon and pass --socks.`
104
- );
105
- }
106
- fs.mkdirSync(cacheDir, { recursive: true });
107
- const zipPath = path.join(cacheDir, asset.assetName);
108
- const url = `${RELEASE_BASE}/${asset.assetName}`;
109
- log(`downloading ${asset.assetName} (${ANON_VERSION})\u2026`);
110
- await downloadToFile(url, zipPath);
111
- const actual = await sha256File(zipPath);
112
- if (actual !== asset.sha256) {
113
- fs.rmSync(zipPath, { force: true });
114
- throw new Error(
115
- `Checksum mismatch for ${asset.assetName}: expected ${asset.sha256}, got ${actual}. The download was discarded.`
116
- );
117
- }
118
- log("verified; extracting");
119
- await extractZip(zipPath, cacheDir);
120
- fs.rmSync(zipPath, { force: true });
121
- if (os.platform() !== "win32") fs.chmodSync(anonPath, 493);
122
- return anonPath;
123
- }
124
- async function sha256File(filePath) {
125
- const fs = nodeRequire("node:fs");
126
- const crypto = nodeRequire("node:crypto");
127
- const hash = crypto.createHash("sha256");
128
- await new Promise((resolve, reject) => {
129
- const stream = fs.createReadStream(filePath);
130
- stream.on("data", (chunk) => hash.update(chunk));
131
- stream.on("error", reject);
132
- stream.on("end", () => resolve());
133
- });
134
- return hash.digest("hex");
135
- }
136
- async function downloadToFile(url, destPath) {
137
- const fs = nodeRequire("node:fs");
138
- const https = nodeRequire("node:https");
139
- const once = (target, redirectsLeft) => new Promise((resolve, reject) => {
140
- const req = https.get(target, (res) => {
141
- const status = res.statusCode ?? 0;
142
- if (status >= 300 && status < 400 && res.headers.location) {
143
- res.resume();
144
- if (redirectsLeft <= 0) return reject(new Error(`Too many redirects downloading ${url}`));
145
- return resolve(once(res.headers.location, redirectsLeft - 1));
146
- }
147
- if (status !== 200) {
148
- res.resume();
149
- return reject(new Error(`Download failed (HTTP ${status}) for ${target}`));
150
- }
151
- const out = fs.createWriteStream(destPath);
152
- res.pipe(out);
153
- out.on("error", reject);
154
- out.on("finish", () => out.close(() => resolve()));
155
- });
156
- req.on("error", reject);
157
- req.setTimeout(12e4, () => req.destroy(new Error(`Download timeout for ${target}`)));
158
- });
159
- await once(url, 5);
160
- }
161
- async function extractZip(zipPath, destDir) {
162
- const cp = nodeRequire("node:child_process");
163
- const os = nodeRequire("node:os");
164
- const [command, args] = os.platform() === "win32" ? [
165
- "powershell",
166
- ["-NoProfile", "-Command", `Expand-Archive -Force -Path "${zipPath}" -DestinationPath "${destDir}"`]
167
- ] : ["unzip", ["-o", zipPath, "-d", destDir]];
168
- await new Promise((resolve, reject) => {
169
- const child = cp.spawn(command, [...args], { stdio: ["ignore", "ignore", "pipe"] });
170
- let stderr = "";
171
- child.stderr?.on("data", (d) => stderr += d.toString());
172
- child.on(
173
- "error",
174
- (err) => reject(new Error(`Could not run ${command} to extract ${zipPath} (is it installed?): ${err.message}`))
175
- );
176
- child.on(
177
- "exit",
178
- (code) => code === 0 ? resolve() : reject(new Error(`${command} exited ${code} extracting ${zipPath}: ${stderr}`))
179
- );
180
- });
181
- }
182
- async function freePort() {
183
- const net = nodeRequire("node:net");
184
- return new Promise((resolve, reject) => {
185
- const server = net.createServer();
186
- server.on("error", reject);
187
- server.listen(0, "127.0.0.1", () => {
188
- const port = server.address().port;
189
- server.close(() => resolve(port));
190
- });
191
- });
192
- }
193
- async function waitForSocksPort(port, timeoutMs, exited, lastLine) {
194
- const net = nodeRequire("node:net");
195
- const deadline = Date.now() + timeoutMs;
196
- const probe = () => new Promise((resolve) => {
197
- const socket = net.createConnection({ host: "127.0.0.1", port }, () => {
198
- socket.destroy();
199
- resolve(true);
200
- });
201
- socket.setTimeout(1e3, () => {
202
- socket.destroy();
203
- resolve(false);
204
- });
205
- socket.on("error", () => {
206
- socket.destroy();
207
- resolve(false);
208
- });
209
- });
210
- while (Date.now() < deadline) {
211
- if (exited()) {
212
- throw new Error(`anon exited before opening its SOCKS port. Last log line: ${lastLine()}`);
213
- }
214
- if (await probe()) return;
215
- await new Promise((resolve) => setTimeout(resolve, 250));
216
- }
217
- throw new Error(
218
- `anon did not open a SOCKS port on 127.0.0.1:${port} within ${timeoutMs}ms. Last log line: ${lastLine()}`
219
- );
220
- }
221
- export {
222
- ANON_ASSETS,
223
- ANON_VERSION,
224
- defaultCacheDir,
225
- ensureAnonBinary,
226
- renderTorrc,
227
- selectAnonAsset,
228
- startManagedAnon
229
- };
230
- //# sourceMappingURL=anon-daemon-5PIPY36T.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/anon-daemon.ts"],"sourcesContent":["/**\n * The managed `anon` daemon — the CLI's, and only the CLI's (ADR 0001).\n *\n * Reaching a hidden-service connector takes a running Anyone Protocol daemon and\n * a SOCKS port. `@toon-protocol/client` never provides one: a library that an\n * application embeds must not download and execute a binary at runtime. The\n * `toon-client` command may, because running it is already a decision to run our\n * executable — so this module lives under `src/cli/`, which is a separate build\n * entry that a library consumer never loads.\n *\n * The release is pinned and checksummed, and the gate fails **closed**: an asset\n * whose hash is unknown is not downloaded at all, rather than downloaded and\n * trusted. A platform we have no pinned hash for is a platform this command\n * cannot serve.\n */\nimport { createRequire } from 'node:module';\nimport type childProcessModule from 'node:child_process';\nimport type cryptoModule from 'node:crypto';\nimport type fsModule from 'node:fs';\nimport type httpsModule from 'node:https';\nimport type netModule from 'node:net';\nimport type osModule from 'node:os';\nimport type pathModule from 'node:path';\n\nconst nodeRequire = createRequire(import.meta.url);\n\n/**\n * The pinned `anon` release.\n *\n * `live` is the stable channel. There are newer `-beta` tags, and a payer should\n * not be shipped a beta daemon by default. The channel slug is embedded in every\n * asset name (`anon-live-linux-amd64.zip`), which is why it moves with the\n * version rather than being a separate knob.\n */\nexport const ANON_VERSION = 'v0.4.10.2';\n\nconst RELEASE_BASE = `https://github.com/anyone-protocol/ator-protocol/releases/download/${ANON_VERSION}`;\n\n/** One platform's release asset, and the hash it must have. */\nexport interface AnonAsset {\n assetName: string;\n /** sha256 of the zip, or `null` when unpinned — which refuses the download. */\n sha256: string | null;\n}\n\n/**\n * Platform → asset, keyed by `${os.platform()}-${os.arch()}`.\n *\n * Windows is here now: earlier versions of this map excluded it because no\n * Windows asset existed, and `v0.4.10.2` ships a signed one.\n */\nexport const ANON_ASSETS: Record<string, AnonAsset> = {\n 'linux-x64': {\n assetName: 'anon-live-linux-amd64.zip',\n sha256: '9c6498b8d27de54d78842a1b854979a605f9c140ccc34f2b4c267bf094eaeb17',\n },\n 'linux-arm64': {\n assetName: 'anon-live-linux-arm64.zip',\n sha256: 'daa3ed15f321d83f22b9c03fad2c0f908e60e3e156d143774bd38194244ebec9',\n },\n 'darwin-x64': {\n assetName: 'anon-live-macos-amd64.zip',\n sha256: '38b5b7ce1ed847e791e56697385365918fbcf81d08def0d389abd8e31e58b975',\n },\n 'darwin-arm64': {\n assetName: 'anon-live-macos-arm64.zip',\n sha256: '8f662cc5ecba27b5ec07dbed897894bd6f0e6c5ff33ca01f3a1d19544ac67866',\n },\n 'win32-x64': {\n assetName: 'anon-live-windows-signed-amd64.zip',\n sha256: 'e7352c4436e2043cfe505a35f1f412e01c72a5aa671cb85af2dcf97da83df4ab',\n },\n};\n\n/** The asset for a platform/arch pair, or an error naming what is supported. */\nexport function selectAnonAsset(platform: string, arch: string): AnonAsset {\n const asset = ANON_ASSETS[`${platform}-${arch}`];\n if (!asset) {\n throw new Error(\n `No pinned anon binary for ${platform}-${arch}. Supported: ` +\n `${Object.keys(ANON_ASSETS).join(', ')}. Run your own daemon and pass --socks instead.`\n );\n }\n return asset;\n}\n\n/** Where the binary and its data live between runs. */\nexport function defaultCacheDir(): string {\n const os = nodeRequire('node:os') as typeof osModule;\n const path = nodeRequire('node:path') as typeof pathModule;\n const xdg = process.env['XDG_CACHE_HOME'];\n return xdg\n ? path.join(xdg, 'toon', 'anon', ANON_VERSION)\n : path.join(os.homedir(), '.toon', 'anon', ANON_VERSION);\n}\n\n/**\n * A SOCKS-only torrc.\n *\n * `AgreeToTerms 1` is REQUIRED: without it `anon` exits immediately, and the\n * failure reads as \"the daemon died\" rather than \"you did not accept the terms\".\n */\nexport function renderTorrc(cacheDir: string, socksPort: number): string {\n const path = nodeRequire('node:path') as typeof pathModule;\n return [\n 'AgreeToTerms 1',\n `DataDirectory ${path.join(cacheDir, 'data')}`,\n `SOCKSPort 127.0.0.1:${socksPort}`,\n 'SOCKSPolicy accept *',\n `GeoIPFile ${path.join(cacheDir, 'geoip')}`,\n `GeoIPv6File ${path.join(cacheDir, 'geoip6')}`,\n 'Log notice stdout',\n 'RunAsDaemon 0',\n '',\n ].join('\\n');\n}\n\n/** A running daemon, and the way to stop it. */\nexport interface ManagedAnon {\n /** `socks5h://127.0.0.1:<port>` — what to configure a client with. */\n socksProxy: string;\n port: number;\n stop(): void;\n}\n\nexport interface StartManagedAnonOptions {\n cacheDir?: string;\n /** Where progress goes. The CLI passes something that prints. */\n log?: (message: string) => void;\n /** How long to wait for the SOCKS port to open. Default 90s. */\n bootstrapTimeoutMs?: number;\n}\n\n/**\n * Downloads (once), verifies, spawns and waits for `anon`.\n *\n * Announced, not silent: a first run downloads ~15MB and then waits for the\n * daemon to bootstrap, and an unexplained thirty-second pause reads as a hang.\n */\nexport async function startManagedAnon(options: StartManagedAnonOptions = {}): Promise<ManagedAnon> {\n const fs = nodeRequire('node:fs') as typeof fsModule;\n const path = nodeRequire('node:path') as typeof pathModule;\n const cp = nodeRequire('node:child_process') as typeof childProcessModule;\n\n const log = options.log ?? ((): void => undefined);\n const cacheDir = options.cacheDir ?? defaultCacheDir();\n const anonPath = await ensureAnonBinary(cacheDir, log);\n const port = await freePort();\n\n fs.mkdirSync(path.join(cacheDir, 'data'), { recursive: true, mode: 0o700 });\n const torrcPath = path.join(cacheDir, 'torrc');\n fs.writeFileSync(torrcPath, renderTorrc(cacheDir, port), { mode: 0o600 });\n\n log(`starting anon ${ANON_VERSION} on 127.0.0.1:${port} (${anonPath})`);\n const child = cp.spawn(anonPath, ['-f', torrcPath], { stdio: ['ignore', 'pipe', 'pipe'] });\n\n let exited = false;\n let lastLine = '';\n child.on('exit', () => {\n exited = true;\n });\n child.stdout?.on('data', (data: Buffer) => {\n lastLine = data.toString().trim().split('\\n').pop() ?? lastLine;\n });\n child.stderr?.on('data', (data: Buffer) => {\n lastLine = data.toString().trim().split('\\n').pop() ?? lastLine;\n });\n\n const stop = (): void => {\n if (!exited) child.kill('SIGTERM');\n };\n\n try {\n await waitForSocksPort(port, options.bootstrapTimeoutMs ?? 90_000, () => exited, () => lastLine);\n } catch (error) {\n stop();\n throw error;\n }\n\n log(`anon is listening; building circuits on demand`);\n return { socksProxy: `socks5h://127.0.0.1:${port}`, port, stop };\n}\n\n/** The binary's path, downloading and verifying it if this is the first run. */\nexport async function ensureAnonBinary(\n cacheDir: string,\n log: (message: string) => void = () => undefined\n): Promise<string> {\n const fs = nodeRequire('node:fs') as typeof fsModule;\n const path = nodeRequire('node:path') as typeof pathModule;\n const os = nodeRequire('node:os') as typeof osModule;\n\n const exe = os.platform() === 'win32' ? 'anon.exe' : 'anon';\n const anonPath = path.join(cacheDir, exe);\n if (fs.existsSync(anonPath)) return anonPath;\n\n const asset = selectAnonAsset(os.platform(), os.arch());\n if (asset.sha256 === null) {\n // Fail closed. An unpinned asset is one nobody has verified, and silently\n // skipping the check would make the gate decorative.\n throw new Error(\n `The anon asset ${asset.assetName} has no pinned checksum, so it will not be ` +\n 'downloaded. Run your own daemon and pass --socks.'\n );\n }\n\n fs.mkdirSync(cacheDir, { recursive: true });\n const zipPath = path.join(cacheDir, asset.assetName);\n const url = `${RELEASE_BASE}/${asset.assetName}`;\n log(`downloading ${asset.assetName} (${ANON_VERSION})…`);\n await downloadToFile(url, zipPath);\n\n const actual = await sha256File(zipPath);\n if (actual !== asset.sha256) {\n fs.rmSync(zipPath, { force: true });\n throw new Error(\n `Checksum mismatch for ${asset.assetName}: expected ${asset.sha256}, got ${actual}. ` +\n 'The download was discarded.'\n );\n }\n\n log('verified; extracting');\n await extractZip(zipPath, cacheDir);\n fs.rmSync(zipPath, { force: true });\n if (os.platform() !== 'win32') fs.chmodSync(anonPath, 0o755);\n return anonPath;\n}\n\n/** sha256 of a file, streamed — these zips are ~15MB. */\nasync function sha256File(filePath: string): Promise<string> {\n const fs = nodeRequire('node:fs') as typeof fsModule;\n const crypto = nodeRequire('node:crypto') as typeof cryptoModule;\n const hash = crypto.createHash('sha256');\n await new Promise<void>((resolve, reject) => {\n const stream = fs.createReadStream(filePath);\n stream.on('data', (chunk) => hash.update(chunk));\n stream.on('error', reject);\n stream.on('end', () => resolve());\n });\n return hash.digest('hex');\n}\n\n/** GitHub release assets redirect to a signed URL, so follow a few. */\nasync function downloadToFile(url: string, destPath: string): Promise<void> {\n const fs = nodeRequire('node:fs') as typeof fsModule;\n const https = nodeRequire('node:https') as typeof httpsModule;\n\n const once = (target: string, redirectsLeft: number): Promise<void> =>\n new Promise<void>((resolve, reject) => {\n const req = https.get(target, (res) => {\n const status = res.statusCode ?? 0;\n if (status >= 300 && status < 400 && res.headers.location) {\n res.resume();\n if (redirectsLeft <= 0) return reject(new Error(`Too many redirects downloading ${url}`));\n return resolve(once(res.headers.location, redirectsLeft - 1));\n }\n if (status !== 200) {\n res.resume();\n return reject(new Error(`Download failed (HTTP ${status}) for ${target}`));\n }\n const out = fs.createWriteStream(destPath);\n res.pipe(out);\n out.on('error', reject);\n out.on('finish', () => out.close(() => resolve()));\n });\n req.on('error', reject);\n req.setTimeout(120_000, () => req.destroy(new Error(`Download timeout for ${target}`)));\n });\n\n await once(url, 5);\n}\n\n/** No zip reader in Node, so borrow the platform's. */\nasync function extractZip(zipPath: string, destDir: string): Promise<void> {\n const cp = nodeRequire('node:child_process') as typeof childProcessModule;\n const os = nodeRequire('node:os') as typeof osModule;\n\n const [command, args] =\n os.platform() === 'win32'\n ? ([\n 'powershell',\n ['-NoProfile', '-Command', `Expand-Archive -Force -Path \"${zipPath}\" -DestinationPath \"${destDir}\"`],\n ] as const)\n : (['unzip', ['-o', zipPath, '-d', destDir]] as const);\n\n await new Promise<void>((resolve, reject) => {\n const child = cp.spawn(command, [...args], { stdio: ['ignore', 'ignore', 'pipe'] });\n let stderr = '';\n child.stderr?.on('data', (d: Buffer) => (stderr += d.toString()));\n child.on('error', (err: Error) =>\n reject(new Error(`Could not run ${command} to extract ${zipPath} (is it installed?): ${err.message}`))\n );\n child.on('exit', (code) =>\n code === 0 ? resolve() : reject(new Error(`${command} exited ${code} extracting ${zipPath}: ${stderr}`))\n );\n });\n}\n\n/** An unused loopback port, chosen by the OS. */\nasync function freePort(): Promise<number> {\n const net = nodeRequire('node:net') as typeof netModule;\n return new Promise<number>((resolve, reject) => {\n const server = net.createServer();\n server.on('error', reject);\n server.listen(0, '127.0.0.1', () => {\n const port = (server.address() as netModule.AddressInfo).port;\n server.close(() => resolve(port));\n });\n });\n}\n\n/**\n * Waits for the daemon to open its SOCKS port, and gives up early if it dies.\n *\n * A dead child is reported with its last log line, because \"anon exited\" alone\n * sends the reader looking in the wrong place — the actual reason is almost\n * always in that line.\n */\nasync function waitForSocksPort(\n port: number,\n timeoutMs: number,\n exited: () => boolean,\n lastLine: () => string\n): Promise<void> {\n const net = nodeRequire('node:net') as typeof netModule;\n const deadline = Date.now() + timeoutMs;\n\n const probe = (): Promise<boolean> =>\n new Promise((resolve) => {\n const socket = net.createConnection({ host: '127.0.0.1', port }, () => {\n socket.destroy();\n resolve(true);\n });\n socket.setTimeout(1000, () => {\n socket.destroy();\n resolve(false);\n });\n socket.on('error', () => {\n socket.destroy();\n resolve(false);\n });\n });\n\n while (Date.now() < deadline) {\n if (exited()) {\n throw new Error(`anon exited before opening its SOCKS port. Last log line: ${lastLine()}`);\n }\n if (await probe()) return;\n await new Promise((resolve) => setTimeout(resolve, 250));\n }\n throw new Error(\n `anon did not open a SOCKS port on 127.0.0.1:${port} within ${timeoutMs}ms. ` +\n `Last log line: ${lastLine()}`\n );\n}\n"],"mappings":";AAeA,SAAS,qBAAqB;AAS9B,IAAM,cAAc,cAAc,YAAY,GAAG;AAU1C,IAAM,eAAe;AAE5B,IAAM,eAAe,sEAAsE,YAAY;AAehG,IAAM,cAAyC;AAAA,EACpD,aAAa;AAAA,IACX,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AAAA,EACA,eAAe;AAAA,IACb,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AAAA,EACA,cAAc;AAAA,IACZ,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AAAA,EACA,gBAAgB;AAAA,IACd,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AAAA,EACA,aAAa;AAAA,IACX,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AACF;AAGO,SAAS,gBAAgB,UAAkB,MAAyB;AACzE,QAAM,QAAQ,YAAY,GAAG,QAAQ,IAAI,IAAI,EAAE;AAC/C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR,6BAA6B,QAAQ,IAAI,IAAI,gBACxC,OAAO,KAAK,WAAW,EAAE,KAAK,IAAI,CAAC;AAAA,IAC1C;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,kBAA0B;AACxC,QAAM,KAAK,YAAY,SAAS;AAChC,QAAM,OAAO,YAAY,WAAW;AACpC,QAAM,MAAM,QAAQ,IAAI,gBAAgB;AACxC,SAAO,MACH,KAAK,KAAK,KAAK,QAAQ,QAAQ,YAAY,IAC3C,KAAK,KAA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