@toon-protocol/client 5.0.1 → 5.1.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/README.md +39 -14
- package/dist/anon-daemon-XW7VJFKL.js +355 -0
- package/dist/anon-daemon-XW7VJFKL.js.map +1 -0
- package/dist/{chunk-WJKJ6Y4N.js → chunk-6O5OXJVR.js} +14 -11
- package/dist/{chunk-WJKJ6Y4N.js.map → chunk-6O5OXJVR.js.map} +1 -1
- package/dist/{chunk-PCPG4CIS.js → chunk-BHGJXLS7.js} +3 -3
- package/dist/{chunk-PCPG4CIS.js.map → chunk-BHGJXLS7.js.map} +1 -1
- package/dist/{chunk-2DGVNDKA.js → chunk-VHP6XLM3.js} +2 -2
- package/dist/cli/main.js +6 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/{client-WCAXMQWM.js → client-DF3LZVLC.js} +3 -3
- package/dist/index.d.ts +14 -11
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/anon-daemon-5PIPY36T.js +0 -230
- package/dist/anon-daemon-5PIPY36T.js.map +0 -1
- /package/dist/{chunk-2DGVNDKA.js.map → chunk-VHP6XLM3.js.map} +0 -0
- /package/dist/{client-WCAXMQWM.js.map → client-DF3LZVLC.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,32 +1,50 @@
|
|
|
1
1
|
# @toon-protocol/client
|
|
2
2
|
|
|
3
|
-
Pay for an HTTP request, per request, in stablecoin
|
|
4
|
-
|
|
5
|
-
that was already paid for. This package is the payer, as a library and as the `toon-client` CLI.
|
|
3
|
+
Pay for an HTTP request, per request, in stablecoin, from code or a terminal. No account, no
|
|
4
|
+
API key, and no gas to open a channel or to pay.
|
|
6
5
|
|
|
7
|
-
##
|
|
6
|
+
## Three steps to a paid request
|
|
7
|
+
|
|
8
|
+
**1. Install.** One package gives you the library and the `toon-client` CLI.
|
|
8
9
|
|
|
9
10
|
```bash
|
|
10
11
|
npm install @toon-protocol/client
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
**2. Open one channel.** A wallet, devnet USDC from the faucet, then a 0.10 USDC deposit at the
|
|
15
|
+
devnet store. No ETH needed.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
export TOON_CONNECTOR=https://toonprotocol.dev
|
|
19
|
+
npx toon-client init # an encrypted keystore at ~/.toon/keystore.json
|
|
20
|
+
npx toon-client faucet # devnet USDC for that address
|
|
21
|
+
npx toon-client channel open --deposit 100000 # 100000 base units (0.10 USDC), no gas
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**3. Send one request.** The devnet store answers a plain body with its own `422`. That cost
|
|
25
|
+
1010 base units, the same as a `200`.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx toon-client send g.toon.store --body 'hello'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The same from the library:
|
|
14
32
|
|
|
15
33
|
```ts
|
|
16
34
|
import { ToonClient } from '@toon-protocol/client';
|
|
17
35
|
|
|
18
36
|
const client = await ToonClient.create({
|
|
19
|
-
connector: 'https://
|
|
37
|
+
connector: 'https://toonprotocol.dev',
|
|
20
38
|
mnemonic: process.env.TOON_MNEMONIC,
|
|
21
39
|
channelStore: `${process.env.HOME}/.toon/channels.json`,
|
|
22
40
|
});
|
|
23
41
|
|
|
24
42
|
await client.channel.open({ deposit: 100_000n }); // 100000 base units (0.10 USDC)
|
|
25
43
|
|
|
26
|
-
const answer = await client.send({ body: 'hello' });
|
|
44
|
+
const answer = await client.send('g.toon.store', { body: 'hello' });
|
|
27
45
|
if (answer.fulfilled) {
|
|
28
46
|
console.log(answer.status, answer.text()); // the app's own HTTP response
|
|
29
|
-
console.log(answer.claim.amount); //
|
|
47
|
+
console.log(answer.claim.amount); // 1010n base units: 1000 + 10 per KiB
|
|
30
48
|
} else {
|
|
31
49
|
console.log(answer.code, answer.message); // a refusal, not an exception
|
|
32
50
|
}
|
|
@@ -34,6 +52,19 @@ if (answer.fulfilled) {
|
|
|
34
52
|
await client.close();
|
|
35
53
|
```
|
|
36
54
|
|
|
55
|
+
## What you can count on
|
|
56
|
+
|
|
57
|
+
- A request costs a signature, not a transaction. At the devnet store that is 1000 base units
|
|
58
|
+
(0.001 USDC), plus 10 per kibibyte.
|
|
59
|
+
- A refusal is returned as a value with a code, never thrown.
|
|
60
|
+
- An x402 batch-settlement channel on Base or Solana, opened once. Your deposit minus what you
|
|
61
|
+
signed for is yours to take back; only leaving costs gas.
|
|
62
|
+
- The wire is defined by [the connector's](https://github.com/toon-protocol/connector) committed
|
|
63
|
+
vectors, which this package replays as its conformance suite.
|
|
64
|
+
- MIT.
|
|
65
|
+
|
|
66
|
+
Everything else is under [Documentation](#documentation) below.
|
|
67
|
+
|
|
37
68
|
## Documentation
|
|
38
69
|
|
|
39
70
|
| Document | What is in it |
|
|
@@ -46,9 +77,3 @@ await client.close();
|
|
|
46
77
|
| [Devnet reference](https://github.com/toon-protocol/toon-client/blob/main/docs/devnet.md) | Endpoints, routes, prices, contract addresses, faucet |
|
|
47
78
|
| [Errors and reject codes](https://github.com/toon-protocol/toon-client/blob/main/docs/errors.md) | What each code means and what to do about it |
|
|
48
79
|
| [Troubleshooting](https://github.com/toon-protocol/toon-client/blob/main/docs/troubleshooting.md) | Symptom, cause, fix |
|
|
49
|
-
|
|
50
|
-
The wire is defined by the Rust connector, not by this package:
|
|
51
|
-
[toon-protocol/connector](https://github.com/toon-protocol/connector) and its committed wire
|
|
52
|
-
vectors are the authority, and this client replays them as its own conformance suite.
|
|
53
|
-
|
|
54
|
-
MIT.
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
// src/cli/anon-daemon.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
|
|
4
|
+
// src/cli/zip-extract.ts
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import zlib from "zlib";
|
|
8
|
+
var EOCD_SIG = 101010256;
|
|
9
|
+
var ZIP64_LOCATOR_SIG = 117853008;
|
|
10
|
+
var CENTRAL_SIG = 33639248;
|
|
11
|
+
var LOCAL_SIG = 67324752;
|
|
12
|
+
var CRC_TABLE = (() => {
|
|
13
|
+
const table = new Uint32Array(256);
|
|
14
|
+
for (let n = 0; n < 256; n++) {
|
|
15
|
+
let c = n;
|
|
16
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
17
|
+
table[n] = c >>> 0;
|
|
18
|
+
}
|
|
19
|
+
return table;
|
|
20
|
+
})();
|
|
21
|
+
function crc32(data) {
|
|
22
|
+
let c = 4294967295;
|
|
23
|
+
for (const b of data) c = (CRC_TABLE[(c ^ b) & 255] ?? 0) ^ c >>> 8;
|
|
24
|
+
return (c ^ 4294967295) >>> 0;
|
|
25
|
+
}
|
|
26
|
+
function fail(zipPath, why) {
|
|
27
|
+
throw new Error(`Cannot extract ${zipPath}: ${why}`);
|
|
28
|
+
}
|
|
29
|
+
function containedPath(destDir, name) {
|
|
30
|
+
if (name.includes("\0") || name.includes("\\") || name.startsWith("/") || /^[A-Za-z]:/.test(name)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (name.split("/").includes("..")) return null;
|
|
34
|
+
const root = path.resolve(destDir);
|
|
35
|
+
const target = path.resolve(root, name);
|
|
36
|
+
const rel = path.relative(root, target);
|
|
37
|
+
if (rel === "" || rel.startsWith("..") || path.isAbsolute(rel)) return null;
|
|
38
|
+
return target;
|
|
39
|
+
}
|
|
40
|
+
function readEntries(zipPath, buf) {
|
|
41
|
+
let eocd = -1;
|
|
42
|
+
for (let i = buf.length - 22; i >= Math.max(0, buf.length - 22 - 65535); i--) {
|
|
43
|
+
if (buf.readUInt32LE(i) === EOCD_SIG) {
|
|
44
|
+
eocd = i;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (eocd < 0) fail(zipPath, "no end-of-central-directory record (not a zip file?)");
|
|
49
|
+
if (eocd >= 20 && buf.readUInt32LE(eocd - 20) === ZIP64_LOCATOR_SIG) {
|
|
50
|
+
fail(zipPath, "zip64 archives are not supported");
|
|
51
|
+
}
|
|
52
|
+
const count = buf.readUInt16LE(eocd + 10);
|
|
53
|
+
const cdSize = buf.readUInt32LE(eocd + 12);
|
|
54
|
+
const cdOffset = buf.readUInt32LE(eocd + 16);
|
|
55
|
+
if (count === 65535 || cdSize === 4294967295 || cdOffset === 4294967295) {
|
|
56
|
+
fail(zipPath, "zip64 archives are not supported");
|
|
57
|
+
}
|
|
58
|
+
if (buf.readUInt16LE(eocd + 4) !== 0 || buf.readUInt16LE(eocd + 6) !== 0) {
|
|
59
|
+
fail(zipPath, "multi-disk archives are not supported");
|
|
60
|
+
}
|
|
61
|
+
const entries = [];
|
|
62
|
+
let p = cdOffset;
|
|
63
|
+
for (let i = 0; i < count; i++) {
|
|
64
|
+
if (p + 46 > buf.length || buf.readUInt32LE(p) !== CENTRAL_SIG) {
|
|
65
|
+
fail(zipPath, "corrupt central directory");
|
|
66
|
+
}
|
|
67
|
+
const madeBy = buf.readUInt16LE(p + 4);
|
|
68
|
+
const flags = buf.readUInt16LE(p + 8);
|
|
69
|
+
const method = buf.readUInt16LE(p + 10);
|
|
70
|
+
const crc = buf.readUInt32LE(p + 16);
|
|
71
|
+
const compressedSize = buf.readUInt32LE(p + 20);
|
|
72
|
+
const size = buf.readUInt32LE(p + 24);
|
|
73
|
+
const nameLen = buf.readUInt16LE(p + 28);
|
|
74
|
+
const extraLen = buf.readUInt16LE(p + 30);
|
|
75
|
+
const commentLen = buf.readUInt16LE(p + 32);
|
|
76
|
+
const externalAttrs = buf.readUInt32LE(p + 38);
|
|
77
|
+
const localOffset = buf.readUInt32LE(p + 42);
|
|
78
|
+
const name = buf.toString("utf8", p + 46, p + 46 + nameLen);
|
|
79
|
+
p += 46 + nameLen + extraLen + commentLen;
|
|
80
|
+
if (compressedSize === 4294967295 || size === 4294967295 || localOffset === 4294967295) {
|
|
81
|
+
fail(zipPath, `zip64 entry "${name}" is not supported`);
|
|
82
|
+
}
|
|
83
|
+
if (flags & 1 || flags & 64) fail(zipPath, `entry "${name}" is encrypted`);
|
|
84
|
+
const isDirectory = name.endsWith("/");
|
|
85
|
+
if (!isDirectory && method !== 0 && method !== 8) {
|
|
86
|
+
fail(zipPath, `entry "${name}" uses unsupported compression method ${method}`);
|
|
87
|
+
}
|
|
88
|
+
if (madeBy >> 8 === 3 && (externalAttrs >>> 16 & 61440) === 40960) {
|
|
89
|
+
fail(zipPath, `entry "${name}" is a symbolic link`);
|
|
90
|
+
}
|
|
91
|
+
entries.push({ name, method, crc, compressedSize, size, localOffset, isDirectory });
|
|
92
|
+
}
|
|
93
|
+
return entries;
|
|
94
|
+
}
|
|
95
|
+
function readData(zipPath, buf, e) {
|
|
96
|
+
const p = e.localOffset;
|
|
97
|
+
if (p + 30 > buf.length || buf.readUInt32LE(p) !== LOCAL_SIG) {
|
|
98
|
+
fail(zipPath, `corrupt local header for "${e.name}"`);
|
|
99
|
+
}
|
|
100
|
+
const start = p + 30 + buf.readUInt16LE(p + 26) + buf.readUInt16LE(p + 28);
|
|
101
|
+
if (start + e.compressedSize > buf.length) fail(zipPath, `entry "${e.name}" is truncated`);
|
|
102
|
+
const raw = buf.subarray(start, start + e.compressedSize);
|
|
103
|
+
let data;
|
|
104
|
+
if (e.method === 0) {
|
|
105
|
+
data = raw;
|
|
106
|
+
} else {
|
|
107
|
+
try {
|
|
108
|
+
data = zlib.inflateRawSync(raw);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
return fail(zipPath, `entry "${e.name}" does not inflate: ${err.message}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (data.length !== e.size) {
|
|
114
|
+
fail(zipPath, `size mismatch for "${e.name}": expected ${e.size}, got ${data.length}`);
|
|
115
|
+
}
|
|
116
|
+
if (crc32(data) !== e.crc) fail(zipPath, `CRC-32 mismatch for "${e.name}"`);
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
function extractZip(zipPath, destDir) {
|
|
120
|
+
const buf = fs.readFileSync(zipPath);
|
|
121
|
+
const entries = readEntries(zipPath, buf);
|
|
122
|
+
const planned = entries.map((e) => {
|
|
123
|
+
const target = containedPath(destDir, e.name);
|
|
124
|
+
if (target === null) fail(zipPath, `entry "${e.name}" escapes the destination directory`);
|
|
125
|
+
return { e, target, data: e.isDirectory ? null : readData(zipPath, buf, e) };
|
|
126
|
+
});
|
|
127
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
128
|
+
for (const { e, target, data } of planned) {
|
|
129
|
+
if (e.isDirectory || data === null) {
|
|
130
|
+
fs.mkdirSync(target, { recursive: true });
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
134
|
+
const partial = `${target}.partial`;
|
|
135
|
+
try {
|
|
136
|
+
fs.writeFileSync(partial, data);
|
|
137
|
+
fs.renameSync(partial, target);
|
|
138
|
+
} catch (err) {
|
|
139
|
+
fs.rmSync(partial, { force: true });
|
|
140
|
+
throw err;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/cli/anon-daemon.ts
|
|
146
|
+
var nodeRequire = createRequire(import.meta.url);
|
|
147
|
+
var ANON_VERSION = "v0.4.10.2";
|
|
148
|
+
var RELEASE_BASE = `https://github.com/anyone-protocol/ator-protocol/releases/download/${ANON_VERSION}`;
|
|
149
|
+
var ANON_ASSETS = {
|
|
150
|
+
"linux-x64": {
|
|
151
|
+
assetName: "anon-live-linux-amd64.zip",
|
|
152
|
+
sha256: "9c6498b8d27de54d78842a1b854979a605f9c140ccc34f2b4c267bf094eaeb17"
|
|
153
|
+
},
|
|
154
|
+
"linux-arm64": {
|
|
155
|
+
assetName: "anon-live-linux-arm64.zip",
|
|
156
|
+
sha256: "daa3ed15f321d83f22b9c03fad2c0f908e60e3e156d143774bd38194244ebec9"
|
|
157
|
+
},
|
|
158
|
+
"darwin-x64": {
|
|
159
|
+
assetName: "anon-live-macos-amd64.zip",
|
|
160
|
+
sha256: "38b5b7ce1ed847e791e56697385365918fbcf81d08def0d389abd8e31e58b975"
|
|
161
|
+
},
|
|
162
|
+
"darwin-arm64": {
|
|
163
|
+
assetName: "anon-live-macos-arm64.zip",
|
|
164
|
+
sha256: "8f662cc5ecba27b5ec07dbed897894bd6f0e6c5ff33ca01f3a1d19544ac67866"
|
|
165
|
+
},
|
|
166
|
+
"win32-x64": {
|
|
167
|
+
assetName: "anon-live-windows-signed-amd64.zip",
|
|
168
|
+
sha256: "e7352c4436e2043cfe505a35f1f412e01c72a5aa671cb85af2dcf97da83df4ab"
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
function selectAnonAsset(platform, arch) {
|
|
172
|
+
const asset = ANON_ASSETS[`${platform}-${arch}`];
|
|
173
|
+
if (!asset) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`No pinned anon binary for ${platform}-${arch}. Supported: ${Object.keys(ANON_ASSETS).join(", ")}. Run your own daemon and pass --socks instead.`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return asset;
|
|
179
|
+
}
|
|
180
|
+
function defaultCacheDir() {
|
|
181
|
+
const os = nodeRequire("node:os");
|
|
182
|
+
const path2 = nodeRequire("node:path");
|
|
183
|
+
const xdg = process.env["XDG_CACHE_HOME"];
|
|
184
|
+
return xdg ? path2.join(xdg, "toon", "anon", ANON_VERSION) : path2.join(os.homedir(), ".toon", "anon", ANON_VERSION);
|
|
185
|
+
}
|
|
186
|
+
function renderTorrc(cacheDir, socksPort) {
|
|
187
|
+
const path2 = nodeRequire("node:path");
|
|
188
|
+
return [
|
|
189
|
+
"AgreeToTerms 1",
|
|
190
|
+
`DataDirectory ${path2.join(cacheDir, "data")}`,
|
|
191
|
+
`SOCKSPort 127.0.0.1:${socksPort}`,
|
|
192
|
+
"SOCKSPolicy accept *",
|
|
193
|
+
`GeoIPFile ${path2.join(cacheDir, "geoip")}`,
|
|
194
|
+
`GeoIPv6File ${path2.join(cacheDir, "geoip6")}`,
|
|
195
|
+
"Log notice stdout",
|
|
196
|
+
"RunAsDaemon 0",
|
|
197
|
+
""
|
|
198
|
+
].join("\n");
|
|
199
|
+
}
|
|
200
|
+
async function startManagedAnon(options = {}) {
|
|
201
|
+
const fs2 = nodeRequire("node:fs");
|
|
202
|
+
const path2 = nodeRequire("node:path");
|
|
203
|
+
const cp = nodeRequire("node:child_process");
|
|
204
|
+
const log = options.log ?? (() => void 0);
|
|
205
|
+
const cacheDir = options.cacheDir ?? defaultCacheDir();
|
|
206
|
+
const anonPath = await ensureAnonBinary(cacheDir, log);
|
|
207
|
+
const port = await freePort();
|
|
208
|
+
fs2.mkdirSync(path2.join(cacheDir, "data"), { recursive: true, mode: 448 });
|
|
209
|
+
const torrcPath = path2.join(cacheDir, "torrc");
|
|
210
|
+
fs2.writeFileSync(torrcPath, renderTorrc(cacheDir, port), { mode: 384 });
|
|
211
|
+
log(`starting anon ${ANON_VERSION} on 127.0.0.1:${port} (${anonPath})`);
|
|
212
|
+
const child = cp.spawn(anonPath, ["-f", torrcPath], { stdio: ["ignore", "pipe", "pipe"] });
|
|
213
|
+
let exited = false;
|
|
214
|
+
let lastLine = "";
|
|
215
|
+
child.on("exit", () => {
|
|
216
|
+
exited = true;
|
|
217
|
+
});
|
|
218
|
+
child.stdout?.on("data", (data) => {
|
|
219
|
+
lastLine = data.toString().trim().split("\n").pop() ?? lastLine;
|
|
220
|
+
});
|
|
221
|
+
child.stderr?.on("data", (data) => {
|
|
222
|
+
lastLine = data.toString().trim().split("\n").pop() ?? lastLine;
|
|
223
|
+
});
|
|
224
|
+
const stop = () => {
|
|
225
|
+
if (!exited) child.kill("SIGTERM");
|
|
226
|
+
};
|
|
227
|
+
try {
|
|
228
|
+
await waitForSocksPort(port, options.bootstrapTimeoutMs ?? 9e4, () => exited, () => lastLine);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
stop();
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
log(`anon is listening; building circuits on demand`);
|
|
234
|
+
return { socksProxy: `socks5h://127.0.0.1:${port}`, port, stop };
|
|
235
|
+
}
|
|
236
|
+
async function ensureAnonBinary(cacheDir, log = () => void 0) {
|
|
237
|
+
const fs2 = nodeRequire("node:fs");
|
|
238
|
+
const path2 = nodeRequire("node:path");
|
|
239
|
+
const os = nodeRequire("node:os");
|
|
240
|
+
const exe = os.platform() === "win32" ? "anon.exe" : "anon";
|
|
241
|
+
const anonPath = path2.join(cacheDir, exe);
|
|
242
|
+
if (fs2.existsSync(anonPath)) return anonPath;
|
|
243
|
+
const asset = selectAnonAsset(os.platform(), os.arch());
|
|
244
|
+
if (asset.sha256 === null) {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`The anon asset ${asset.assetName} has no pinned checksum, so it will not be downloaded. Run your own daemon and pass --socks.`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
fs2.mkdirSync(cacheDir, { recursive: true });
|
|
250
|
+
const zipPath = path2.join(cacheDir, asset.assetName);
|
|
251
|
+
const url = `${RELEASE_BASE}/${asset.assetName}`;
|
|
252
|
+
log(`downloading ${asset.assetName} (${ANON_VERSION})\u2026`);
|
|
253
|
+
await downloadToFile(url, zipPath);
|
|
254
|
+
const actual = await sha256File(zipPath);
|
|
255
|
+
if (actual !== asset.sha256) {
|
|
256
|
+
fs2.rmSync(zipPath, { force: true });
|
|
257
|
+
throw new Error(
|
|
258
|
+
`Checksum mismatch for ${asset.assetName}: expected ${asset.sha256}, got ${actual}. The download was discarded.`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
log("verified; extracting");
|
|
262
|
+
try {
|
|
263
|
+
extractZip(zipPath, cacheDir);
|
|
264
|
+
} finally {
|
|
265
|
+
fs2.rmSync(zipPath, { force: true });
|
|
266
|
+
}
|
|
267
|
+
if (os.platform() !== "win32") fs2.chmodSync(anonPath, 493);
|
|
268
|
+
return anonPath;
|
|
269
|
+
}
|
|
270
|
+
async function sha256File(filePath) {
|
|
271
|
+
const fs2 = nodeRequire("node:fs");
|
|
272
|
+
const crypto = nodeRequire("node:crypto");
|
|
273
|
+
const hash = crypto.createHash("sha256");
|
|
274
|
+
await new Promise((resolve, reject) => {
|
|
275
|
+
const stream = fs2.createReadStream(filePath);
|
|
276
|
+
stream.on("data", (chunk) => hash.update(chunk));
|
|
277
|
+
stream.on("error", reject);
|
|
278
|
+
stream.on("end", () => resolve());
|
|
279
|
+
});
|
|
280
|
+
return hash.digest("hex");
|
|
281
|
+
}
|
|
282
|
+
async function downloadToFile(url, destPath) {
|
|
283
|
+
const fs2 = nodeRequire("node:fs");
|
|
284
|
+
const https = nodeRequire("node:https");
|
|
285
|
+
const once = (target, redirectsLeft) => new Promise((resolve, reject) => {
|
|
286
|
+
const req = https.get(target, (res) => {
|
|
287
|
+
const status = res.statusCode ?? 0;
|
|
288
|
+
if (status >= 300 && status < 400 && res.headers.location) {
|
|
289
|
+
res.resume();
|
|
290
|
+
if (redirectsLeft <= 0) return reject(new Error(`Too many redirects downloading ${url}`));
|
|
291
|
+
return resolve(once(res.headers.location, redirectsLeft - 1));
|
|
292
|
+
}
|
|
293
|
+
if (status !== 200) {
|
|
294
|
+
res.resume();
|
|
295
|
+
return reject(new Error(`Download failed (HTTP ${status}) for ${target}`));
|
|
296
|
+
}
|
|
297
|
+
const out = fs2.createWriteStream(destPath);
|
|
298
|
+
res.pipe(out);
|
|
299
|
+
out.on("error", reject);
|
|
300
|
+
out.on("finish", () => out.close(() => resolve()));
|
|
301
|
+
});
|
|
302
|
+
req.on("error", reject);
|
|
303
|
+
req.setTimeout(12e4, () => req.destroy(new Error(`Download timeout for ${target}`)));
|
|
304
|
+
});
|
|
305
|
+
await once(url, 5);
|
|
306
|
+
}
|
|
307
|
+
async function freePort() {
|
|
308
|
+
const net = nodeRequire("node:net");
|
|
309
|
+
return new Promise((resolve, reject) => {
|
|
310
|
+
const server = net.createServer();
|
|
311
|
+
server.on("error", reject);
|
|
312
|
+
server.listen(0, "127.0.0.1", () => {
|
|
313
|
+
const port = server.address().port;
|
|
314
|
+
server.close(() => resolve(port));
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async function waitForSocksPort(port, timeoutMs, exited, lastLine) {
|
|
319
|
+
const net = nodeRequire("node:net");
|
|
320
|
+
const deadline = Date.now() + timeoutMs;
|
|
321
|
+
const probe = () => new Promise((resolve) => {
|
|
322
|
+
const socket = net.createConnection({ host: "127.0.0.1", port }, () => {
|
|
323
|
+
socket.destroy();
|
|
324
|
+
resolve(true);
|
|
325
|
+
});
|
|
326
|
+
socket.setTimeout(1e3, () => {
|
|
327
|
+
socket.destroy();
|
|
328
|
+
resolve(false);
|
|
329
|
+
});
|
|
330
|
+
socket.on("error", () => {
|
|
331
|
+
socket.destroy();
|
|
332
|
+
resolve(false);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
while (Date.now() < deadline) {
|
|
336
|
+
if (exited()) {
|
|
337
|
+
throw new Error(`anon exited before opening its SOCKS port. Last log line: ${lastLine()}`);
|
|
338
|
+
}
|
|
339
|
+
if (await probe()) return;
|
|
340
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
341
|
+
}
|
|
342
|
+
throw new Error(
|
|
343
|
+
`anon did not open a SOCKS port on 127.0.0.1:${port} within ${timeoutMs}ms. Last log line: ${lastLine()}`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
export {
|
|
347
|
+
ANON_ASSETS,
|
|
348
|
+
ANON_VERSION,
|
|
349
|
+
defaultCacheDir,
|
|
350
|
+
ensureAnonBinary,
|
|
351
|
+
renderTorrc,
|
|
352
|
+
selectAnonAsset,
|
|
353
|
+
startManagedAnon
|
|
354
|
+
};
|
|
355
|
+
//# sourceMappingURL=anon-daemon-XW7VJFKL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/anon-daemon.ts","../src/cli/zip-extract.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\nimport { extractZip } from './zip-extract.js';\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 try {\n extractZip(zipPath, cacheDir);\n } finally {\n fs.rmSync(zipPath, { force: true });\n }\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/** 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","/**\n * An in-process zip extractor for the pinned `anon` release — the CLI's, and only the CLI's\n * (ADR 0001). Node has no zip reader and the platform's own tool is not always installed, so\n * this reads exactly what the release assets use and refuses everything else.\n *\n * Supported: the end-of-central-directory record and the central directory; stored (0) and\n * deflated (8) entries; directory entries. Refused, loudly: zip64, encryption, other methods,\n * symlinks, a CRC-32 or size mismatch, and any entry whose path leaves the destination.\n *\n * Every entry is inflated and verified in memory before the first byte is written, so a bad\n * archive leaves nothing behind that could pass for a cached binary.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nconst EOCD_SIG = 0x06054b50;\nconst ZIP64_LOCATOR_SIG = 0x07064b50;\nconst CENTRAL_SIG = 0x02014b50;\nconst LOCAL_SIG = 0x04034b50;\n\nconst CRC_TABLE = (() => {\n const table = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n table[n] = c >>> 0;\n }\n return table;\n})();\n\nfunction crc32(data: Uint8Array): number {\n let c = 0xffffffff;\n for (const b of data) c = (CRC_TABLE[(c ^ b) & 0xff] ?? 0) ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n\ninterface Entry {\n name: string;\n method: number;\n crc: number;\n compressedSize: number;\n size: number;\n localOffset: number;\n isDirectory: boolean;\n}\n\nfunction fail(zipPath: string, why: string): never {\n throw new Error(`Cannot extract ${zipPath}: ${why}`);\n}\n\n/** The destination path for an entry, or null when it would escape `destDir`. */\nfunction containedPath(destDir: string, name: string): string | null {\n if (name.includes('\\0') || name.includes('\\\\') || name.startsWith('/') || /^[A-Za-z]:/.test(name)) {\n return null;\n }\n if (name.split('/').includes('..')) return null;\n const root = path.resolve(destDir);\n const target = path.resolve(root, name);\n const rel = path.relative(root, target);\n if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) return null;\n return target;\n}\n\nfunction readEntries(zipPath: string, buf: Buffer): Entry[] {\n let eocd = -1;\n for (let i = buf.length - 22; i >= Math.max(0, buf.length - 22 - 0xffff); i--) {\n if (buf.readUInt32LE(i) === EOCD_SIG) {\n eocd = i;\n break;\n }\n }\n if (eocd < 0) fail(zipPath, 'no end-of-central-directory record (not a zip file?)');\n\n if (eocd >= 20 && buf.readUInt32LE(eocd - 20) === ZIP64_LOCATOR_SIG) {\n fail(zipPath, 'zip64 archives are not supported');\n }\n const count = buf.readUInt16LE(eocd + 10);\n const cdSize = buf.readUInt32LE(eocd + 12);\n const cdOffset = buf.readUInt32LE(eocd + 16);\n if (count === 0xffff || cdSize === 0xffffffff || cdOffset === 0xffffffff) {\n fail(zipPath, 'zip64 archives are not supported');\n }\n if (buf.readUInt16LE(eocd + 4) !== 0 || buf.readUInt16LE(eocd + 6) !== 0) {\n fail(zipPath, 'multi-disk archives are not supported');\n }\n\n const entries: Entry[] = [];\n let p = cdOffset;\n for (let i = 0; i < count; i++) {\n if (p + 46 > buf.length || buf.readUInt32LE(p) !== CENTRAL_SIG) {\n fail(zipPath, 'corrupt central directory');\n }\n const madeBy = buf.readUInt16LE(p + 4);\n const flags = buf.readUInt16LE(p + 8);\n const method = buf.readUInt16LE(p + 10);\n const crc = buf.readUInt32LE(p + 16);\n const compressedSize = buf.readUInt32LE(p + 20);\n const size = buf.readUInt32LE(p + 24);\n const nameLen = buf.readUInt16LE(p + 28);\n const extraLen = buf.readUInt16LE(p + 30);\n const commentLen = buf.readUInt16LE(p + 32);\n const externalAttrs = buf.readUInt32LE(p + 38);\n const localOffset = buf.readUInt32LE(p + 42);\n const name = buf.toString('utf8', p + 46, p + 46 + nameLen);\n p += 46 + nameLen + extraLen + commentLen;\n\n if (compressedSize === 0xffffffff || size === 0xffffffff || localOffset === 0xffffffff) {\n fail(zipPath, `zip64 entry \"${name}\" is not supported`);\n }\n if (flags & 0x1 || flags & 0x40) fail(zipPath, `entry \"${name}\" is encrypted`);\n const isDirectory = name.endsWith('/');\n if (!isDirectory && method !== 0 && method !== 8) {\n fail(zipPath, `entry \"${name}\" uses unsupported compression method ${method}`);\n }\n // Unix host (3): the high half of the external attributes is st_mode.\n if (madeBy >> 8 === 3 && ((externalAttrs >>> 16) & 0xf000) === 0xa000) {\n fail(zipPath, `entry \"${name}\" is a symbolic link`);\n }\n entries.push({ name, method, crc, compressedSize, size, localOffset, isDirectory });\n }\n return entries;\n}\n\nfunction readData(zipPath: string, buf: Buffer, e: Entry): Buffer {\n const p = e.localOffset;\n if (p + 30 > buf.length || buf.readUInt32LE(p) !== LOCAL_SIG) {\n fail(zipPath, `corrupt local header for \"${e.name}\"`);\n }\n const start = p + 30 + buf.readUInt16LE(p + 26) + buf.readUInt16LE(p + 28);\n if (start + e.compressedSize > buf.length) fail(zipPath, `entry \"${e.name}\" is truncated`);\n const raw = buf.subarray(start, start + e.compressedSize);\n\n let data: Buffer;\n if (e.method === 0) {\n data = raw;\n } else {\n try {\n data = zlib.inflateRawSync(raw);\n } catch (err) {\n return fail(zipPath, `entry \"${e.name}\" does not inflate: ${(err as Error).message}`);\n }\n }\n if (data.length !== e.size) {\n fail(zipPath, `size mismatch for \"${e.name}\": expected ${e.size}, got ${data.length}`);\n }\n if (crc32(data) !== e.crc) fail(zipPath, `CRC-32 mismatch for \"${e.name}\"`);\n return data;\n}\n\n/** Extract `zipPath` into `destDir`. Throws before writing anything if the archive is unacceptable. */\nexport function extractZip(zipPath: string, destDir: string): void {\n const buf = fs.readFileSync(zipPath);\n const entries = readEntries(zipPath, buf);\n\n const planned = entries.map((e) => {\n const target = containedPath(destDir, e.name);\n if (target === null) fail(zipPath, `entry \"${e.name}\" escapes the destination directory`);\n return { e, target, data: e.isDirectory ? null : readData(zipPath, buf, e) };\n });\n\n fs.mkdirSync(destDir, { recursive: true });\n for (const { e, target, data } of planned) {\n if (e.isDirectory || data === null) {\n fs.mkdirSync(target, { recursive: true });\n continue;\n }\n fs.mkdirSync(path.dirname(target), { recursive: true });\n // Write beside the target and rename, so the final name only ever holds a whole file.\n const partial = `${target}.partial`;\n try {\n fs.writeFileSync(partial, data);\n fs.renameSync(partial, target);\n } catch (err) {\n fs.rmSync(partial, { force: true });\n throw err;\n }\n }\n}\n"],"mappings":";AAeA,SAAS,qBAAqB;;;ACH9B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,UAAU;AAEjB,IAAM,WAAW;AACjB,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AACpB,IAAM,YAAY;AAElB,IAAM,aAAa,MAAM;AACvB,QAAM,QAAQ,IAAI,YAAY,GAAG;AACjC,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,QAAI,IAAI;AACR,aAAS,IAAI,GAAG,IAAI,GAAG,IAAK,KAAI,IAAI,IAAI,aAAc,MAAM,IAAK,MAAM;AACvE,UAAM,CAAC,IAAI,MAAM;AAAA,EACnB;AACA,SAAO;AACT,GAAG;AAEH,SAAS,MAAM,MAA0B;AACvC,MAAI,IAAI;AACR,aAAW,KAAK,KAAM,MAAK,WAAW,IAAI,KAAK,GAAI,KAAK,KAAM,MAAM;AACpE,UAAQ,IAAI,gBAAgB;AAC9B;AAYA,SAAS,KAAK,SAAiB,KAAoB;AACjD,QAAM,IAAI,MAAM,kBAAkB,OAAO,KAAK,GAAG,EAAE;AACrD;AAGA,SAAS,cAAc,SAAiB,MAA6B;AACnE,MAAI,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,GAAG,KAAK,aAAa,KAAK,IAAI,GAAG;AAC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AQ,KAAK;AAAA,IACf,CAAC;AAAA,EACH,CAAC;AAEH,SAAO,KAAK,IAAI,IAAI,UAAU;AAC5B,QAAI,OAAO,GAAG;AACZ,YAAM,IAAI,MAAM,6DAA6D,SAAS,CAAC,EAAE;AAAA,IAC3F;AACA,QAAI,MAAM,MAAM,EAAG;AACnB,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG,CAAC;AAAA,EACzD;AACA,QAAM,IAAI;AAAA,IACR,+CAA+C,IAAI,WAAW,SAAS,sBACnD,SAAS,CAAC;AAAA,EAChC;AACF;","names":["path","fs"]}
|
|
@@ -151,35 +151,38 @@ function generateRandomIdentity() {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// src/presets.ts
|
|
154
|
+
var DEVNET_CONNECTOR = "https://toonprotocol.dev";
|
|
154
155
|
var DEVNET = {
|
|
156
|
+
/** The devnet's single connector. `DEVNET.store.url` and the rest all equal it. */
|
|
157
|
+
connector: DEVNET_CONNECTOR,
|
|
155
158
|
/**
|
|
156
|
-
* The store
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
+
* The store: an Arweave-backed object store behind `g.toon.store`, and a
|
|
160
|
+
* route that METERS — 1000 base units (0.001 USDC) plus 10 per kibibyte of
|
|
161
|
+
* sealed payload, so no packet on it costs only `price`.
|
|
159
162
|
*/
|
|
160
163
|
store: {
|
|
161
|
-
url:
|
|
164
|
+
url: DEVNET_CONNECTOR,
|
|
162
165
|
route: "g.toon.store",
|
|
163
166
|
price: 1000n,
|
|
164
167
|
pricePerKib: 10n
|
|
165
168
|
},
|
|
166
169
|
/**
|
|
167
|
-
* The gas station behind `g.toon.gas`, priced flat at 1000 base units.
|
|
168
|
-
*
|
|
170
|
+
* The gas station behind `g.toon.gas`, priced flat at 1000 base units. Also
|
|
171
|
+
* addressable as `g.toon.relay.gas` at the same price, on the same connector.
|
|
169
172
|
*/
|
|
170
173
|
gas: {
|
|
171
|
-
url:
|
|
174
|
+
url: DEVNET_CONNECTOR,
|
|
172
175
|
route: "g.toon.gas",
|
|
173
176
|
price: 1000n
|
|
174
177
|
},
|
|
175
178
|
/**
|
|
176
|
-
* The relay
|
|
179
|
+
* The relay behind `g.toon.relay`, priced at 1 base unit. Its route is
|
|
177
180
|
* pinned to **BTP**: an HTTP one-shot to it is refused with the same terms
|
|
178
181
|
* document an unpaid request gets, carrying `requiredTransport` in
|
|
179
182
|
* `extensions.toon.info`.
|
|
180
183
|
*/
|
|
181
184
|
relay: {
|
|
182
|
-
url:
|
|
185
|
+
url: DEVNET_CONNECTOR,
|
|
183
186
|
route: "g.toon.relay",
|
|
184
187
|
price: 1n,
|
|
185
188
|
requiredTransport: "btp"
|
|
@@ -190,7 +193,7 @@ var DEVNET = {
|
|
|
190
193
|
* carriage-pinned, unlike `g.toon.relay` beside it.
|
|
191
194
|
*/
|
|
192
195
|
ephemeral: {
|
|
193
|
-
url:
|
|
196
|
+
url: DEVNET_CONNECTOR,
|
|
194
197
|
route: "g.toon.relay.ephemeral",
|
|
195
198
|
price: 0n
|
|
196
199
|
},
|
|
@@ -245,4 +248,4 @@ export {
|
|
|
245
248
|
defaultRpcUrl,
|
|
246
249
|
defaultFacilitatorFor
|
|
247
250
|
};
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
251
|
+
//# sourceMappingURL=chunk-6O5OXJVR.js.map
|