@toon-protocol/client 2.1.1 → 2.2.0
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/dist/anon-daemon-ZFBL6EYA.js +230 -0
- package/dist/anon-daemon-ZFBL6EYA.js.map +1 -0
- package/dist/chunk-32MD3CXE.js +27 -0
- package/dist/chunk-32MD3CXE.js.map +1 -0
- package/dist/{chunk-DD7TJKP6.js → chunk-4I3JQ7KA.js} +2 -2
- package/dist/{chunk-J6JVCKNV.js → chunk-7MPONJW5.js} +39 -1
- package/dist/chunk-7MPONJW5.js.map +1 -0
- package/dist/{chunk-ENNSPYP4.js → chunk-A3JKQOWQ.js} +197 -43
- package/dist/chunk-A3JKQOWQ.js.map +1 -0
- package/dist/chunk-GOLBDUNV.js +143 -0
- package/dist/chunk-GOLBDUNV.js.map +1 -0
- package/dist/cli/main.js +63 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/{client-ACUZCR5A.js → client-VA4727SQ.js} +4 -3
- package/dist/index.d.ts +194 -2
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/socks-CCMHMB35.js +15 -0
- package/dist/socks-CCMHMB35.js.map +1 -0
- package/dist/transport/hidden-service.d.ts +116 -0
- package/dist/transport/hidden-service.js +15 -0
- package/dist/transport/hidden-service.js.map +1 -0
- package/package.json +7 -1
- package/dist/chunk-ENNSPYP4.js.map +0 -1
- package/dist/chunk-J6JVCKNV.js.map +0 -1
- /package/dist/{chunk-DD7TJKP6.js.map → chunk-4I3JQ7KA.js.map} +0 -0
- /package/dist/{client-ACUZCR5A.js.map → client-VA4727SQ.js.map} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
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-ZFBL6EYA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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` 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,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WAAW,SAAS,GAAG,CAAC;AAAA,EACzD;AACA,QAAM,IAAI;AAAA,IACR,+CAA+C,IAAI,WAAW,SAAS,sBACnD,SAAS,CAAC;AAAA,EAChC;AACF;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/transport/socks-url.ts
|
|
2
|
+
function validateSocks5hUrl(socksProxy) {
|
|
3
|
+
if (typeof socksProxy !== "string" || !socksProxy.startsWith("socks5h://")) {
|
|
4
|
+
const got = typeof socksProxy === "string" ? socksProxy.split("://")[0] + "://" : typeof socksProxy;
|
|
5
|
+
throw new Error(
|
|
6
|
+
`SOCKS5 proxy URL must use the socks5h:// scheme (got ${JSON.stringify(got)}). The "h" makes the proxy resolve the hostname, so a .anyone address never leaks into a local DNS query.`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
let parsed;
|
|
10
|
+
try {
|
|
11
|
+
parsed = new URL(socksProxy.replace(/^socks5h:\/\//, "http://"));
|
|
12
|
+
} catch {
|
|
13
|
+
throw new Error(`Malformed SOCKS5 proxy URL: ${JSON.stringify(socksProxy)}`);
|
|
14
|
+
}
|
|
15
|
+
const host = parsed.hostname;
|
|
16
|
+
const port = parsed.port ? Number.parseInt(parsed.port, 10) : 1080;
|
|
17
|
+
if (!host) throw new Error(`SOCKS5 proxy URL missing host: ${JSON.stringify(socksProxy)}`);
|
|
18
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
19
|
+
throw new Error(`SOCKS5 proxy port out of range (1\u201365535): ${parsed.port}`);
|
|
20
|
+
}
|
|
21
|
+
return { host, port };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
validateSocks5hUrl
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-32MD3CXE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transport/socks-url.ts"],"sourcesContent":["/**\n * `socks5h://` URL parsing, kept apart from the transport that uses it.\n *\n * Config validation has to reject a bad proxy URL, and config validation runs\n * everywhere — including in a browser, where `./socks.js` must never be loaded\n * (it reaches for `node:module` on the first line). This module is pure.\n */\n\n/**\n * Parses and validates a `socks5h://` URL.\n *\n * Enforces the `socks5h://` scheme, not `socks5://`: the trailing `h` means the\n * *proxy* resolves the hostname. Under plain `socks5://` the client resolves it\n * locally first, which for a `.anyone` address means shipping the hidden service\n * you are about to talk to into a plaintext DNS query — the exact fact the\n * hidden service exists to withhold. Mirrors the connector's `transport/socks-url.ts`.\n */\nexport function validateSocks5hUrl(socksProxy: string): { host: string; port: number } {\n if (typeof socksProxy !== 'string' || !socksProxy.startsWith('socks5h://')) {\n const got = typeof socksProxy === 'string' ? socksProxy.split('://')[0] + '://' : typeof socksProxy;\n throw new Error(\n `SOCKS5 proxy URL must use the socks5h:// scheme (got ${JSON.stringify(got)}). ` +\n 'The \"h\" makes the proxy resolve the hostname, so a .anyone address never ' +\n 'leaks into a local DNS query.'\n );\n }\n\n // Parse by swapping in a scheme `URL` understands; `socks5h:` is not special-cased.\n let parsed: URL;\n try {\n parsed = new URL(socksProxy.replace(/^socks5h:\\/\\//, 'http://'));\n } catch {\n throw new Error(`Malformed SOCKS5 proxy URL: ${JSON.stringify(socksProxy)}`);\n }\n\n const host = parsed.hostname;\n const port = parsed.port ? Number.parseInt(parsed.port, 10) : 1080;\n\n if (!host) throw new Error(`SOCKS5 proxy URL missing host: ${JSON.stringify(socksProxy)}`);\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(`SOCKS5 proxy port out of range (1–65535): ${parsed.port}`);\n }\n\n return { host, port };\n}\n"],"mappings":";AAiBO,SAAS,mBAAmB,YAAoD;AACrF,MAAI,OAAO,eAAe,YAAY,CAAC,WAAW,WAAW,YAAY,GAAG;AAC1E,UAAM,MAAM,OAAO,eAAe,WAAW,WAAW,MAAM,KAAK,EAAE,CAAC,IAAI,QAAQ,OAAO;AACzF,UAAM,IAAI;AAAA,MACR,wDAAwD,KAAK,UAAU,GAAG,CAAC;AAAA,IAG7E;AAAA,EACF;AAGA,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,WAAW,QAAQ,iBAAiB,SAAS,CAAC;AAAA,EACjE,QAAQ;AACN,UAAM,IAAI,MAAM,+BAA+B,KAAK,UAAU,UAAU,CAAC,EAAE;AAAA,EAC7E;AAEA,QAAM,OAAO,OAAO;AACpB,QAAM,OAAO,OAAO,OAAO,OAAO,SAAS,OAAO,MAAM,EAAE,IAAI;AAE9D,MAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kCAAkC,KAAK,UAAU,UAAU,CAAC,EAAE;AACzF,MAAI,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,OAAO,OAAO;AACvD,UAAM,IAAI,MAAM,kDAA6C,OAAO,IAAI,EAAE;AAAA,EAC5E;AAEA,SAAO,EAAE,MAAM,KAAK;AACtB;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateMnemonic,
|
|
3
3
|
validateMnemonic
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7MPONJW5.js";
|
|
5
5
|
|
|
6
6
|
// src/keys/keystore-node.ts
|
|
7
7
|
import {
|
|
@@ -163,4 +163,4 @@ export {
|
|
|
163
163
|
loadKeystore,
|
|
164
164
|
writeKeystoreFile
|
|
165
165
|
};
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
166
|
+
//# sourceMappingURL=chunk-4I3JQ7KA.js.map
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
// src/transport/hs-hostname.ts
|
|
2
|
+
var HS_HOSTNAME_REGEX = /^[a-z2-7]+\.anyone$/;
|
|
3
|
+
var HS_HOSTNAME_MAX_LENGTH = 80;
|
|
4
|
+
function isRoutableHsHostname(s) {
|
|
5
|
+
return typeof s === "string" && s.length <= HS_HOSTNAME_MAX_LENGTH && HS_HOSTNAME_REGEX.test(s);
|
|
6
|
+
}
|
|
7
|
+
function isHiddenServiceUrl(url) {
|
|
8
|
+
if (typeof url !== "string") return false;
|
|
9
|
+
try {
|
|
10
|
+
return isRoutableHsHostname(new URL(url).hostname);
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function assertRoutableHsHostname(hostname) {
|
|
16
|
+
if (typeof hostname === "string" && /\.anon$/.test(hostname)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`"${hostname}" is not a routable hidden-service address; use the .anyone TLD (e.g. "${hostname.replace(/\.anon$/, ".anyone")}"). The anon daemon only resolves hidden services under .anyone \u2014 a .anon name is treated as a clearnet address and fails (HostUnreachable).`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (typeof hostname === "string" && /\.onion$/.test(hostname)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`"${hostname}" is a Tor hidden service, which this client does not dial. Packets are routed through the Anyone Protocol \`anon\` daemon, whose hidden services live under the .anyone TLD.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
if (!isRoutableHsHostname(hostname)) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Invalid hidden-service hostname: ${JSON.stringify(hostname)}. Expected a base32 .anyone address matching ${HS_HOSTNAME_REGEX}.`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return hostname;
|
|
32
|
+
}
|
|
33
|
+
|
|
1
34
|
// src/keys/KeyDerivation.ts
|
|
2
35
|
import { privateKeyToAccount } from "viem/accounts";
|
|
3
36
|
import { toHex } from "viem";
|
|
@@ -187,6 +220,11 @@ function defaultRpcUrl(chain) {
|
|
|
187
220
|
}
|
|
188
221
|
|
|
189
222
|
export {
|
|
223
|
+
HS_HOSTNAME_REGEX,
|
|
224
|
+
HS_HOSTNAME_MAX_LENGTH,
|
|
225
|
+
isRoutableHsHostname,
|
|
226
|
+
isHiddenServiceUrl,
|
|
227
|
+
assertRoutableHsHostname,
|
|
190
228
|
base58Encode,
|
|
191
229
|
base58Decode,
|
|
192
230
|
generateMnemonic,
|
|
@@ -198,4 +236,4 @@ export {
|
|
|
198
236
|
DEVNET,
|
|
199
237
|
defaultRpcUrl
|
|
200
238
|
};
|
|
201
|
-
//# sourceMappingURL=chunk-
|
|
239
|
+
//# sourceMappingURL=chunk-7MPONJW5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transport/hs-hostname.ts","../src/keys/KeyDerivation.ts","../src/utils/base58.ts","../src/presets.ts"],"sourcesContent":["/**\n * Hidden-service hostname validation for the Anyone Protocol network.\n *\n * The `anon` binary routes hidden-service hostnames under the **`.anyone`** TLD\n * ONLY. A `<host>.anon` name is NOT recognized as a hidden service — anon treats\n * it as a clearnet name and tries to exit-resolve it, which fails\n * (`resolve failed` / `HostUnreachable`). Only `<host>.anyone` triggers anon's\n * `parse_extended_hostname: Anyone dns address lookup` and is validated.\n *\n * Historically this client accepted BOTH `.anon` and `.anyone`, so a `.anon`\n * address was silently accepted and then failed deep in the transport with an\n * opaque error. This module makes `.anyone` the single accepted HS TLD and\n * rejects the near-misses up front with an actionable message.\n *\n * `.onion` is a near-miss too, and a more tempting one: it is a real hidden\n * service, just on a network this client does not dial. We route through `anon`,\n * not `tor`, so accepting a `.onion` address would repeat the exact mistake\n * `.anon` taught us — an address we cannot reach, failing late and cryptically.\n *\n * This is a pure, browser-safe helper (no Node built-ins) so it can be imported\n * from any path, including config validation.\n */\n\n/**\n * A `<host>.anyone` hidden-service hostname. The label is base32 (`a-z2-7`),\n * matching the on-wire onion-style address alphabet anon uses.\n */\nexport const HS_HOSTNAME_REGEX = /^[a-z2-7]+\\.anyone$/;\n\n/** Max length of an HS hostname (defensive bound against pathological input). */\nexport const HS_HOSTNAME_MAX_LENGTH = 80;\n\n/**\n * Returns true iff `s` is a routable `.anyone` hidden-service hostname.\n * Does NOT accept `.anon` or `.onion` (see {@link assertRoutableHsHostname}).\n */\nexport function isRoutableHsHostname(s: unknown): s is string {\n return (\n typeof s === 'string' &&\n s.length <= HS_HOSTNAME_MAX_LENGTH &&\n HS_HOSTNAME_REGEX.test(s)\n );\n}\n\n/**\n * Returns true iff `url` addresses a hidden service — i.e. its host is a\n * routable `.anyone` address.\n *\n * Takes a URL string rather than a hostname because that is what a caller\n * actually holds: a `connector` config value, an `httpEndpoint` off a\n * self-description. A string that is not a URL at all is not a hidden service.\n */\nexport function isHiddenServiceUrl(url: unknown): boolean {\n if (typeof url !== 'string') return false;\n try {\n return isRoutableHsHostname(new URL(url).hostname);\n } catch {\n return false;\n }\n}\n\n/**\n * Validates that `hostname` is a routable `.anyone` hidden-service address.\n *\n * - `<host>.anyone` → returns the hostname unchanged.\n * - `<host>.anon` → throws, pointing at `.anyone` (anon does NOT route\n * `.anon`; it is treated as a clearnet address and fails `HostUnreachable`).\n * - `<host>.onion` → throws, naming the network mismatch: that is Tor, and\n * this client dials the Anyone Protocol.\n * - anything else → throws a generic format error.\n *\n * @throws {Error} if the hostname is not a routable `.anyone` HS address.\n */\nexport function assertRoutableHsHostname(hostname: unknown): string {\n if (typeof hostname === 'string' && /\\.anon$/.test(hostname)) {\n throw new Error(\n `\"${hostname}\" is not a routable hidden-service address; use the .anyone TLD ` +\n `(e.g. \"${hostname.replace(/\\.anon$/, '.anyone')}\"). ` +\n 'The anon daemon only resolves hidden services under .anyone — a .anon ' +\n 'name is treated as a clearnet address and fails (HostUnreachable).'\n );\n }\n if (typeof hostname === 'string' && /\\.onion$/.test(hostname)) {\n throw new Error(\n `\"${hostname}\" is a Tor hidden service, which this client does not dial. ` +\n 'Packets are routed through the Anyone Protocol `anon` daemon, whose ' +\n 'hidden services live under the .anyone TLD.'\n );\n }\n if (!isRoutableHsHostname(hostname)) {\n throw new Error(\n `Invalid hidden-service hostname: ${JSON.stringify(hostname)}. ` +\n `Expected a base32 .anyone address matching ${HS_HOSTNAME_REGEX}.`\n );\n }\n return hostname;\n}\n","/**\n * One BIP-39 phrase → an EVM key and a Solana key.\n *\n * ## Which path an EVM key comes from\n *\n * There are two, and the difference is historical rather than cryptographic.\n *\n * - **`standard`** — `m/44'/60'/0'/0/{accountIndex}`, BIP-44's registered coin\n * type for Ethereum. This is what every wallet derives, so the same phrase\n * typed into MetaMask or a hardware wallet produces the same address: the\n * channel wallet can be inspected, topped up or swept without this package.\n * New keystores use it.\n *\n * - **`legacy`** — `m/44'/1237'/0'/0/{accountIndex}`, Nostr's coin type. Before\n * 1.0 this client derived one secp256k1 key and used it for both a Nostr\n * identity and an EVM account, so the EVM key sat on Nostr's path. The Nostr\n * half is gone, but the addresses are not: they hold channels with real\n * collateral. A keystore written before 1.0 records no scheme and is read as\n * `legacy`, so nothing moves under an existing deployment.\n *\n * Solana is unaffected — `m/44'/501'/{accountIndex}'/0'`, SLIP-0010, all\n * hardened, which is what Phantom and the Solana CLI derive.\n */\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { toHex } from 'viem';\nimport {\n generateMnemonic as _genMnemonic,\n validateMnemonic as _validateMnemonic,\n mnemonicToSeedSync,\n} from '@scure/bip39';\nimport { wordlist as english } from '@scure/bip39/wordlists/english';\nimport { HDKey } from '@scure/bip32';\nimport { hmac } from '@noble/hashes/hmac';\nimport { sha512 } from '@noble/hashes/sha512';\nimport { ed25519 } from '@noble/curves/ed25519.js';\nimport { secp256k1 } from '@noble/curves/secp256k1.js';\nimport { base58Encode } from '../utils/base58.js';\nimport type { DerivedIdentity } from './types.js';\n\n/** How a mnemonic becomes an EVM key. See this module's own docs. */\nexport type KeyDerivationScheme = 'standard' | 'legacy';\n\n/** BIP-44 coin type 60: Ethereum, and every EVM chain by convention. */\nconst EVM_COIN_TYPE_STANDARD = 60;\n/** BIP-44 coin type 1237: Nostr. What this client used before 1.0. */\nconst EVM_COIN_TYPE_LEGACY = 1237;\n\n/** Generate a new 12-word BIP-39 mnemonic. */\nexport function generateMnemonic(): string {\n return _genMnemonic(english, 128);\n}\n\n/** Is this a well-formed BIP-39 phrase with a valid checksum? */\nexport function validateMnemonic(mnemonic: string): boolean {\n return _validateMnemonic(mnemonic, english);\n}\n\n/** Maximum valid BIP-32 non-hardened child index (2^31 − 1). */\nconst MAX_BIP32_INDEX = 0x7fffffff;\n\nfunction assertValidAccountIndex(accountIndex: number): void {\n if (\n !Number.isInteger(accountIndex) ||\n accountIndex < 0 ||\n accountIndex > MAX_BIP32_INDEX\n ) {\n throw new Error(\n `accountIndex must be an integer in [0, ${MAX_BIP32_INDEX}]; got ${String(accountIndex)}`\n );\n }\n}\n\n/** The BIP-44 path an EVM key is derived at, under a given scheme. */\nexport function evmDerivationPath(\n scheme: KeyDerivationScheme,\n accountIndex = 0\n): string {\n const coinType =\n scheme === 'legacy' ? EVM_COIN_TYPE_LEGACY : EVM_COIN_TYPE_STANDARD;\n return `m/44'/${String(coinType)}'/0'/0/${String(accountIndex)}`;\n}\n\nfunction deriveEvmKey(\n seed: Uint8Array,\n scheme: KeyDerivationScheme,\n accountIndex: number\n): DerivedIdentity['evm'] {\n const child = HDKey.fromMasterSeed(seed).derive(\n evmDerivationPath(scheme, accountIndex)\n );\n if (!child.privateKey) {\n throw new Error('Failed to derive an EVM private key from the seed');\n }\n return evmIdentityFromKey(new Uint8Array(child.privateKey));\n}\n\n/** The account an existing secp256k1 secret belongs to. */\nexport function evmIdentityFromKey(\n privateKey: Uint8Array\n): DerivedIdentity['evm'] {\n const account = privateKeyToAccount(toHex(privateKey));\n return { privateKey, address: account.address };\n}\n\n/**\n * SLIP-0010 Ed25519 derivation at `m/44'/501'/{accountIndex}'/0'`.\n *\n * Ed25519 has no non-hardened derivation, so every level is hardened and the\n * chain code is carried by hand rather than through `HDKey` (which implements\n * BIP-32 for secp256k1).\n */\nfunction deriveSolanaKey(\n seed: Uint8Array,\n accountIndex: number\n): DerivedIdentity['solana'] {\n const encoder = new TextEncoder();\n let I = hmac(sha512, encoder.encode('ed25519 seed'), seed);\n let key = I.slice(0, 32);\n let chainCode = I.slice(32);\n\n const indices = [\n 0x8000002c, // 44'\n 0x800001f5, // 501'\n (0x80000000 + accountIndex) >>> 0, // {accountIndex}'\n 0x80000000, // 0'\n ];\n\n for (const index of indices) {\n const data = new Uint8Array(37);\n data[0] = 0x00;\n data.set(key, 1);\n data[33] = (index >>> 24) & 0xff;\n data[34] = (index >>> 16) & 0xff;\n data[35] = (index >>> 8) & 0xff;\n data[36] = index & 0xff;\n\n I = hmac(sha512, chainCode, data);\n key = I.slice(0, 32);\n chainCode = I.slice(32);\n }\n\n const publicKeyBytes = ed25519.getPublicKey(key);\n // A Solana secret key is the 32-byte seed followed by its public key.\n const keypair = new Uint8Array(64);\n keypair.set(key, 0);\n keypair.set(publicKeyBytes, 32);\n\n return { secretKey: keypair, publicKey: base58Encode(publicKeyBytes) };\n}\n\nexport interface DeriveIdentityOptions {\n accountIndex?: number;\n /** Default `'standard'`. */\n scheme?: KeyDerivationScheme;\n}\n\n/**\n * Derive both chain keys from a mnemonic.\n *\n * The seed is zeroed before returning; the derived keys are not, because they\n * are the return value.\n */\nexport function deriveFullIdentity(\n mnemonic: string,\n options: DeriveIdentityOptions | number = {}\n): DerivedIdentity {\n // `deriveFullIdentity(mnemonic, 3)` used to mean account index 3.\n const opts: DeriveIdentityOptions =\n typeof options === 'number' ? { accountIndex: options } : options;\n const accountIndex = opts.accountIndex ?? 0;\n const scheme = opts.scheme ?? 'standard';\n assertValidAccountIndex(accountIndex);\n\n const seed = mnemonicToSeedSync(mnemonic);\n try {\n return {\n evm: deriveEvmKey(seed, scheme, accountIndex),\n solana: deriveSolanaKey(seed, accountIndex),\n };\n } finally {\n seed.fill(0);\n }\n}\n\n/**\n * A random identity, for tests and ephemeral use. The keys are unrelated to\n * each other and to any mnemonic, so nothing here can be recovered from a\n * phrase — generate a mnemonic instead if the keys need to outlive the process.\n */\nexport function generateRandomIdentity(): DerivedIdentity {\n const evmKey = secp256k1.utils.randomSecretKey();\n const solanaSeed = ed25519.utils.randomSecretKey();\n const solanaPublic = ed25519.getPublicKey(solanaSeed);\n const keypair = new Uint8Array(64);\n keypair.set(solanaSeed, 0);\n keypair.set(solanaPublic, 32);\n return {\n evm: evmIdentityFromKey(evmKey),\n solana: { secretKey: keypair, publicKey: base58Encode(solanaPublic) },\n };\n}\n","/**\n * Base58 (Bitcoin alphabet) — the encoding every Solana address, program id,\n * mint and signature-free pubkey arrives in.\n *\n * A thin wrapper over `@scure/base` rather than a hand-rolled implementation:\n * the same audited primitive already sits under `@scure/bip32`, so this adds no\n * install weight, and base58 decoding is exactly the kind of loop where a\n * hand-rolled version is wrong only for inputs you did not test.\n *\n * Replaces `@toon-protocol/core`'s `base58Encode`/`base58Decode`.\n */\nimport { base58 } from '@scure/base';\n\n/** Encode raw bytes as base58. */\nexport function base58Encode(bytes: Uint8Array): string {\n return base58.encode(bytes);\n}\n\n/**\n * Decode base58 text to raw bytes.\n *\n * Throws on any character outside the alphabet — a Solana pubkey that fails to\n * decode is a caller error worth surfacing, never something to coerce.\n */\nexport function base58Decode(text: string): Uint8Array {\n return base58.decode(text);\n}\n","/**\n * Well-known values for the public TOON devnet.\n *\n * **These are conveniences, never authorities.** Every settlement fact a client\n * actually pays against — the chain, the counterparty address, the token\n * network, the mint, the decimals — comes from the connector's own `GET /ilp`,\n * because the connector proved each of them against a live chain when it booted\n * (`self-description-spec.md` ND-07). Two declarations of one fact is how a\n * mainnet node comes to be described as devnet, so nothing here is ever\n * consulted in preference to the document a node answers with.\n *\n * What they are good for: a default RPC endpoint, a default faucet, and a URL to\n * put in an example so it can be run rather than adapted.\n *\n * Everything below is a **testnet**. Base Sepolia and Solana devnet carry no\n * real value, and the USDC is a mock mint anyone can draw from the faucet.\n */\n\n/** A connector on the public devnet. */\nexport interface DevnetNode {\n /** Client-edge base URL — `GET /ilp` here returns everything else. */\n url: string;\n /** The route this node terminates. */\n route: string;\n /** That route's base price, in base units of the settlement asset (USDC, 6dp). */\n price: bigint;\n /**\n * Added per kibibyte of sealed payload, on a route that meters by size. A\n * packet on such a route always costs strictly more than `price`.\n */\n pricePerKib?: bigint;\n /** Set when the route accepts only one carriage. */\n requiredTransport?: 'http' | 'btp';\n}\n\nexport const DEVNET = {\n /**\n * The store node: an Arweave-backed object store behind `g.toon.store`, and\n * the one route here that METERS — 1000 base units (0.001 USDC) plus 10 per\n * kibibyte of sealed payload, so no packet on it costs only `price`.\n */\n store: {\n url: 'https://proxy.ario.devnet.toonprotocol.dev',\n route: 'g.toon.store',\n price: 1000n,\n pricePerKib: 10n,\n } satisfies DevnetNode,\n\n /**\n * The gas station behind `g.toon.gas`, priced flat at 1000 base units.\n * Reachable directly, or through the relay at `g.toon.relay.gas`.\n */\n gas: {\n url: 'https://proxy.gas.devnet.toonprotocol.dev',\n route: 'g.toon.gas',\n price: 1000n,\n } satisfies DevnetNode,\n\n /**\n * The relay node behind `g.toon.relay`, priced at 1 base unit. Its route is\n * pinned to **BTP**: an HTTP one-shot to it is refused with the same terms\n * document an unpaid request gets, carrying `extra.requiredTransport`.\n */\n relay: {\n url: 'https://proxy.relay.devnet.toonprotocol.dev',\n route: 'g.toon.relay',\n price: 1n,\n requiredTransport: 'btp',\n } satisfies DevnetNode,\n\n /**\n * The relay's ephemeral lane, priced at **zero** — the one route on the devnet\n * that exercises the whole wire while holding no funds and no channel. Not\n * carriage-pinned, unlike `g.toon.relay` beside it.\n */\n ephemeral: {\n url: 'https://proxy.relay.devnet.toonprotocol.dev',\n route: 'g.toon.relay.ephemeral',\n price: 0n,\n } satisfies DevnetNode,\n\n /** Test funds. `POST /api/base-sepolia/request` and `/api/solana/usdc-request`. */\n faucet: 'https://faucet.devnet.toonprotocol.dev',\n\n /** Base Sepolia. The registry is the stable address; the token network is resolved from it. */\n evm: {\n chainId: 84532,\n rpcUrl: 'https://sepolia.base.org',\n tokenNetworkRegistry: '0x0c41D9D424d6B075A3cEa1068a694f7847a8CCa5',\n tokenNetwork: '0xe9E05dfecfe165266C88d73e61D483612651952a',\n /** Mock USDC, 6 decimals, ungated `mint()`. */\n tokenAddress: '0x49beE1Bca5d15Fb0963117923403F9498119a9Ce',\n decimals: 6,\n },\n\n /** Solana devnet — the public cluster, not a local validator. */\n solana: {\n rpcUrl: 'https://api.devnet.solana.com',\n /** The deployed `payment-channel` program. Bound into every claim (ADR 0053). */\n programId: '2aEVJ8koKD8LTZrLRSGtAtU7LBt4e7QjjCgf1kzQ7Rip',\n /** Mock USDC SPL mint, 6 decimals. */\n tokenAddress: '34eSxY7qxQ4GzyhDJ8GpUcTz1WWzruGbJbR8q6TtxfQU',\n decimals: 6,\n },\n} as const;\n\n/** The default RPC URL for a chain when a caller configures none. */\nexport function defaultRpcUrl(chain: 'evm' | 'solana'): string {\n return chain === 'evm' ? DEVNET.evm.rpcUrl : DEVNET.solana.rpcUrl;\n}\n"],"mappings":";AA2BO,IAAM,oBAAoB;AAG1B,IAAM,yBAAyB;AAM/B,SAAS,qBAAqB,GAAyB;AAC5D,SACE,OAAO,MAAM,YACb,EAAE,UAAU,0BACZ,kBAAkB,KAAK,CAAC;AAE5B;AAUO,SAAS,mBAAmB,KAAuB;AACxD,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,MAAI;AACF,WAAO,qBAAqB,IAAI,IAAI,GAAG,EAAE,QAAQ;AAAA,EACnD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAcO,SAAS,yBAAyB,UAA2B;AAClE,MAAI,OAAO,aAAa,YAAY,UAAU,KAAK,QAAQ,GAAG;AAC5D,UAAM,IAAI;AAAA,MACR,IAAI,QAAQ,0EACA,SAAS,QAAQ,WAAW,SAAS,CAAC;AAAA,IAGpD;AAAA,EACF;AACA,MAAI,OAAO,aAAa,YAAY,WAAW,KAAK,QAAQ,GAAG;AAC7D,UAAM,IAAI;AAAA,MACR,IAAI,QAAQ;AAAA,IAGd;AAAA,EACF;AACA,MAAI,CAAC,qBAAqB,QAAQ,GAAG;AACnC,UAAM,IAAI;AAAA,MACR,oCAAoC,KAAK,UAAU,QAAQ,CAAC,gDACZ,iBAAiB;AAAA,IACnE;AAAA,EACF;AACA,SAAO;AACT;;;ACzEA,SAAS,2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