@toon-protocol/client 5.0.2 → 5.1.1
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 +4 -4
- 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-GNPJRJ6U.js} +62 -18
- package/dist/chunk-GNPJRJ6U.js.map +1 -0
- package/dist/{chunk-2DGVNDKA.js → chunk-VHP6XLM3.js} +2 -2
- package/dist/cli/main.js +17 -8
- package/dist/cli/main.js.map +1 -1
- package/dist/{client-WCAXMQWM.js → client-RO3VITXU.js} +5 -3
- package/dist/index.d.ts +52 -21
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-PCPG4CIS.js.map +0 -1
- /package/dist/{chunk-2DGVNDKA.js.map → chunk-VHP6XLM3.js.map} +0 -0
- /package/dist/{client-WCAXMQWM.js.map → client-RO3VITXU.js.map} +0 -0
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm install @toon-protocol/client
|
|
|
15
15
|
devnet store. No ETH needed.
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
export TOON_CONNECTOR=https://
|
|
18
|
+
export TOON_CONNECTOR=https://toonprotocol.dev
|
|
19
19
|
npx toon-client init # an encrypted keystore at ~/.toon/keystore.json
|
|
20
20
|
npx toon-client faucet # devnet USDC for that address
|
|
21
21
|
npx toon-client channel open --deposit 100000 # 100000 base units (0.10 USDC), no gas
|
|
@@ -25,7 +25,7 @@ npx toon-client channel open --deposit 100000 # 100000 base units (0.10 USDC),
|
|
|
25
25
|
1010 base units, the same as a `200`.
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
npx toon-client send --body 'hello'
|
|
28
|
+
npx toon-client send g.toon.store --body 'hello'
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
The same from the library:
|
|
@@ -34,14 +34,14 @@ The same from the library:
|
|
|
34
34
|
import { ToonClient } from '@toon-protocol/client';
|
|
35
35
|
|
|
36
36
|
const client = await ToonClient.create({
|
|
37
|
-
connector: 'https://
|
|
37
|
+
connector: 'https://toonprotocol.dev',
|
|
38
38
|
mnemonic: process.env.TOON_MNEMONIC,
|
|
39
39
|
channelStore: `${process.env.HOME}/.toon/channels.json`,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
await client.channel.open({ deposit: 100_000n }); // 100000 base units (0.10 USDC)
|
|
43
43
|
|
|
44
|
-
const answer = await client.send({ body: 'hello' });
|
|
44
|
+
const answer = await client.send('g.toon.store', { body: 'hello' });
|
|
45
45
|
if (answer.fulfilled) {
|
|
46
46
|
console.log(answer.status, answer.text()); // the app's own HTTP response
|
|
47
47
|
console.log(answer.claim.amount); // 1010n base units: 1000 + 10 per KiB
|
|
@@ -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
|
|
@@ -1 +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 `requiredTransport` in\n * `extensions.toon.info`.\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 /**\n * The Onboarder (toon-protocol/infra#23): a stock x402 facilitator on Base\n * Sepolia that submits a channel deposit and pays its gas, so a wallet\n * holding devnet USDC and no ETH can open a channel.\n */\n facilitator: 'https://onboard.devnet.toonprotocol.dev',\n\n /** Base Sepolia. */\n evm: {\n chainId: 84532,\n network: 'eip155:84532',\n rpcUrl: 'https://sepolia.base.org',\n /** Devnet USDC: Circle FiatToken v2.2 (ERC-3009, EIP-2612), 6 decimals, minter-gated — fund via the faucet (connector#1337). */\n tokenAddress: '0x0C996d7c934c79a6255254875607Fe69df25C0E1',\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 network: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\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\n/**\n * The facilitator a Base deposit goes through when a caller names none: the\n * devnet's own on Base Sepolia, and nothing elsewhere — a mainnet deposit\n * through a devnet service would be refused anyway, and silently picking a\n * third party to relay real money is not this package's decision to make.\n */\nexport function defaultFacilitatorFor(network: string): string | undefined {\n return network === DEVNET.evm.network ? DEVNET.facilitator : undefined;\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,2BAA2B;AACpC,SAAS,aAAa;AACtB;AAAA,EACE,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB;AAAA,OACK;AACP,SAAS,YAAY,eAAe;AACpC,SAAS,aAAa;AACtB,SA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,SAAO,YAAY,OAAO,IAAI,UAAU,OAAO,cAAc;AAC/D;","names":[]}
|
|
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\n/**\n * The devnet's one connector (consolidated 2026-10-16). Every route below\n * terminates here, one channel with it pays for all of them, and every payload\n * is sealed to its key — no route on the devnet is forwarded to another node.\n */\nconst DEVNET_CONNECTOR = 'https://toonprotocol.dev';\n\nexport const DEVNET = {\n /** The devnet's single connector. `DEVNET.store.url` and the rest all equal it. */\n connector: DEVNET_CONNECTOR,\n\n /**\n * The store: an Arweave-backed object store behind `g.toon.store`, and a\n * route that METERS — 1000 base units (0.001 USDC) plus 10 per kibibyte of\n * sealed payload, so no packet on it costs only `price`.\n */\n store: {\n url: DEVNET_CONNECTOR,\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. Also\n * addressable as `g.toon.relay.gas` at the same price, on the same connector.\n */\n gas: {\n url: DEVNET_CONNECTOR,\n route: 'g.toon.gas',\n price: 1000n,\n } satisfies DevnetNode,\n\n /**\n * The relay 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 `requiredTransport` in\n * `extensions.toon.info`.\n */\n relay: {\n url: DEVNET_CONNECTOR,\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: DEVNET_CONNECTOR,\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 /**\n * The Onboarder (toon-protocol/infra#23): a stock x402 facilitator on Base\n * Sepolia that submits a channel deposit and pays its gas, so a wallet\n * holding devnet USDC and no ETH can open a channel.\n */\n facilitator: 'https://onboard.devnet.toonprotocol.dev',\n\n /** Base Sepolia. */\n evm: {\n chainId: 84532,\n network: 'eip155:84532',\n rpcUrl: 'https://sepolia.base.org',\n /** Devnet USDC: Circle FiatToken v2.2 (ERC-3009, EIP-2612), 6 decimals, minter-gated — fund via the faucet (connector#1337). */\n tokenAddress: '0x0C996d7c934c79a6255254875607Fe69df25C0E1',\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 network: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\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\n/**\n * The facilitator a Base deposit goes through when a caller names none: the\n * devnet's own on Base Sepolia, and nothing elsewhere — a mainnet deposit\n * through a devnet service would be refused anyway, and silently picking a\n * third party to relay real money is not this package's decision to make.\n */\nexport function defaultFacilitatorFor(network: string): string | undefined {\n return network === DEVNET.evm.network ? DEVNET.facilitator : undefined;\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,Q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AAAA;AAAA,EAGA,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOR,aAAa;AAAA;AAAA,EAGb,KAAK;AAAA,IACH,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA;AAAA,IAER,cAAc;AAAA,IACd,UAAU;AAAA,EACZ;AAAA;AAAA,EAGA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,SAAS;AAAA;AAAA,IAET,cAAc;AAAA,IACd,UAAU;AAAA,EACZ;AACF;AAGO,SAAS,cAAc,OAAiC;AAC7D,SAAO,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO,OAAO;AAC7D;AAQO,SAAS,sBAAsB,SAAqC;AACzE,SAAO,YAAY,OAAO,IAAI,UAAU,OAAO,cAAc;AAC/D;","names":[]}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
deriveFullIdentity,
|
|
9
9
|
evmIdentityFromKey,
|
|
10
10
|
isHiddenServiceUrl
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6O5OXJVR.js";
|
|
12
12
|
import {
|
|
13
13
|
validateSocks5hUrl
|
|
14
14
|
} from "./chunk-32MD3CXE.js";
|
|
@@ -23,11 +23,17 @@ var ToonClientError = class extends Error {
|
|
|
23
23
|
code;
|
|
24
24
|
};
|
|
25
25
|
var NetworkError = class extends ToonClientError {
|
|
26
|
-
|
|
26
|
+
/** The URL that could not be reached, when the failure was reaching one. */
|
|
27
|
+
endpoint;
|
|
28
|
+
constructor(message, cause, endpoint) {
|
|
27
29
|
super(message, "NETWORK_ERROR", cause);
|
|
28
30
|
this.name = "NetworkError";
|
|
31
|
+
if (endpoint !== void 0) this.endpoint = endpoint;
|
|
29
32
|
}
|
|
30
33
|
};
|
|
34
|
+
function describeEndpoint(url, source) {
|
|
35
|
+
return source === "published" ? `${url} (the endpoint the connector published in its self-description)` : url;
|
|
36
|
+
}
|
|
31
37
|
var ConnectorError = class extends ToonClientError {
|
|
32
38
|
constructor(message, cause) {
|
|
33
39
|
super(message, "CONNECTOR_ERROR", cause);
|
|
@@ -1725,6 +1731,7 @@ function headerReader(headers) {
|
|
|
1725
1731
|
}
|
|
1726
1732
|
var HttpIlpClient = class {
|
|
1727
1733
|
httpEndpoint;
|
|
1734
|
+
endpointSource;
|
|
1728
1735
|
peerId;
|
|
1729
1736
|
authToken;
|
|
1730
1737
|
timeout;
|
|
@@ -1733,6 +1740,7 @@ var HttpIlpClient = class {
|
|
|
1733
1740
|
createWebSocket;
|
|
1734
1741
|
constructor(config) {
|
|
1735
1742
|
this.httpEndpoint = config.httpEndpoint;
|
|
1743
|
+
this.endpointSource = config.endpointSource;
|
|
1736
1744
|
this.peerId = config.peerId;
|
|
1737
1745
|
this.authToken = config.authToken;
|
|
1738
1746
|
this.timeout = config.timeout ?? 3e4;
|
|
@@ -1961,14 +1969,16 @@ var HttpIlpClient = class {
|
|
|
1961
1969
|
}
|
|
1962
1970
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1963
1971
|
return new NetworkError(
|
|
1964
|
-
`Request timeout after ${requestTimeout}ms`,
|
|
1965
|
-
error
|
|
1972
|
+
`Request timeout after ${requestTimeout}ms reaching ${describeEndpoint(this.httpEndpoint, this.endpointSource)}`,
|
|
1973
|
+
error,
|
|
1974
|
+
this.httpEndpoint
|
|
1966
1975
|
);
|
|
1967
1976
|
}
|
|
1968
1977
|
if (error instanceof TypeError && (error.message.includes("fetch failed") || error.message.includes("ECONNREFUSED") || error.message.includes("ECONNRESET") || error.message.includes("ETIMEDOUT") || error.message.includes("network"))) {
|
|
1969
1978
|
return new NetworkError(
|
|
1970
|
-
`Network connection failed: ${error.message}`,
|
|
1971
|
-
error
|
|
1979
|
+
`Network connection failed reaching ${describeEndpoint(this.httpEndpoint, this.endpointSource)}: ${error.message}`,
|
|
1980
|
+
error,
|
|
1981
|
+
this.httpEndpoint
|
|
1972
1982
|
);
|
|
1973
1983
|
}
|
|
1974
1984
|
return new ConnectorError(
|
|
@@ -2384,7 +2394,8 @@ var ConnectorEdgeClient = class {
|
|
|
2384
2394
|
} catch (error) {
|
|
2385
2395
|
throw new NetworkError(
|
|
2386
2396
|
`could not reach the connector client edge at ${url}`,
|
|
2387
|
-
error instanceof Error ? error : void 0
|
|
2397
|
+
error instanceof Error ? error : void 0,
|
|
2398
|
+
url
|
|
2388
2399
|
);
|
|
2389
2400
|
} finally {
|
|
2390
2401
|
clearTimeout(timer);
|
|
@@ -2420,8 +2431,8 @@ var ConnectorEdgeClient = class {
|
|
|
2420
2431
|
* a transport failure throws {@link NetworkError} instead, so a caller can
|
|
2421
2432
|
* always tell "not mine" from "could not ask".
|
|
2422
2433
|
*
|
|
2423
|
-
* Fetched once per (endpoint, destination) and reused. ADR 0020
|
|
2424
|
-
*
|
|
2434
|
+
* Fetched once per (endpoint, destination) and reused. ADR 0020 gives a
|
|
2435
|
+
* handler one set of terms, which do not vary with the packet — a route
|
|
2425
2436
|
* being repriced is an operator event, and {@link invalidateRoutePrice} is
|
|
2426
2437
|
* how a caller reacts to one.
|
|
2427
2438
|
*
|
|
@@ -2489,7 +2500,8 @@ var ConnectorEdgeClient = class {
|
|
|
2489
2500
|
} catch (error) {
|
|
2490
2501
|
throw new NetworkError(
|
|
2491
2502
|
`could not reach the connector client edge at ${base}/ilp`,
|
|
2492
|
-
error instanceof Error ? error : void 0
|
|
2503
|
+
error instanceof Error ? error : void 0,
|
|
2504
|
+
`${base}/ilp`
|
|
2493
2505
|
);
|
|
2494
2506
|
} finally {
|
|
2495
2507
|
clearTimeout(timer);
|
|
@@ -2543,7 +2555,8 @@ var ConnectorEdgeClient = class {
|
|
|
2543
2555
|
} catch (error) {
|
|
2544
2556
|
throw new NetworkError(
|
|
2545
2557
|
`could not reach the connector client edge at ${url}`,
|
|
2546
|
-
error instanceof Error ? error : void 0
|
|
2558
|
+
error instanceof Error ? error : void 0,
|
|
2559
|
+
url
|
|
2547
2560
|
);
|
|
2548
2561
|
} finally {
|
|
2549
2562
|
clearTimeout(timer);
|
|
@@ -2657,7 +2670,8 @@ var ConnectorEdgeClient = class {
|
|
|
2657
2670
|
} catch (error) {
|
|
2658
2671
|
throw new NetworkError(
|
|
2659
2672
|
`could not reach the connector client edge at ${url}`,
|
|
2660
|
-
error instanceof Error ? error : void 0
|
|
2673
|
+
error instanceof Error ? error : void 0,
|
|
2674
|
+
url
|
|
2661
2675
|
);
|
|
2662
2676
|
} finally {
|
|
2663
2677
|
clearTimeout(timer);
|
|
@@ -2744,6 +2758,8 @@ function sleep(ms) {
|
|
|
2744
2758
|
var BtpPaidWriteTransport = class {
|
|
2745
2759
|
session;
|
|
2746
2760
|
fallback;
|
|
2761
|
+
url;
|
|
2762
|
+
endpointSource;
|
|
2747
2763
|
maxReconnectAttempts;
|
|
2748
2764
|
reconnectDelay;
|
|
2749
2765
|
/**
|
|
@@ -2756,6 +2772,8 @@ var BtpPaidWriteTransport = class {
|
|
|
2756
2772
|
constructor(config) {
|
|
2757
2773
|
this.session = config.session;
|
|
2758
2774
|
this.fallback = config.fallback;
|
|
2775
|
+
this.url = config.url;
|
|
2776
|
+
this.endpointSource = config.endpointSource;
|
|
2759
2777
|
this.maxReconnectAttempts = config.maxReconnectAttempts ?? 1;
|
|
2760
2778
|
this.reconnectDelay = config.reconnectDelay ?? 250;
|
|
2761
2779
|
}
|
|
@@ -2802,8 +2820,26 @@ var BtpPaidWriteTransport = class {
|
|
|
2802
2820
|
}
|
|
2803
2821
|
/** Connect if need be, then send once. No claim, so nothing to re-spend. */
|
|
2804
2822
|
async dispatchUnpaid(params) {
|
|
2805
|
-
|
|
2806
|
-
|
|
2823
|
+
try {
|
|
2824
|
+
if (!this.session.isConnected) await this.session.connect();
|
|
2825
|
+
return await this.session.sendIlpPacket(params);
|
|
2826
|
+
} catch (error) {
|
|
2827
|
+
throw this.nameEndpoint(error);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
/**
|
|
2831
|
+
* A connection-level failure becomes a {@link NetworkError} naming the BTP
|
|
2832
|
+
* URL, with the original kept as `cause`. Anything else passes through.
|
|
2833
|
+
*/
|
|
2834
|
+
nameEndpoint(error) {
|
|
2835
|
+
if (this.url === void 0 || error instanceof NetworkError) return error;
|
|
2836
|
+
if (!isConnectionError2(error)) return error;
|
|
2837
|
+
const cause = error instanceof Error ? error : void 0;
|
|
2838
|
+
return new NetworkError(
|
|
2839
|
+
`BTP connection failed reaching ${describeEndpoint(this.url, this.endpointSource)}: ${cause?.message ?? String(error)}`,
|
|
2840
|
+
cause,
|
|
2841
|
+
this.url
|
|
2842
|
+
);
|
|
2807
2843
|
}
|
|
2808
2844
|
/**
|
|
2809
2845
|
* One write's worth of connect/send/reconnect/fallback policy. Runs
|
|
@@ -2837,8 +2873,12 @@ var BtpPaidWriteTransport = class {
|
|
|
2837
2873
|
if (this.fallback) {
|
|
2838
2874
|
return this.fallback.sendIlpPacketWithClaim(params, claim);
|
|
2839
2875
|
}
|
|
2840
|
-
|
|
2841
|
-
|
|
2876
|
+
const named = this.nameEndpoint(lastError);
|
|
2877
|
+
if (named instanceof Error) throw named;
|
|
2878
|
+
throw new NetworkError(
|
|
2879
|
+
`BTP paid-write transport exhausted its reconnect budget${this.url !== void 0 ? ` reaching ${describeEndpoint(this.url, this.endpointSource)}` : ""} and no HTTP fallback is configured`,
|
|
2880
|
+
void 0,
|
|
2881
|
+
this.url
|
|
2842
2882
|
);
|
|
2843
2883
|
}
|
|
2844
2884
|
};
|
|
@@ -3656,7 +3696,7 @@ function addressFor(identity, chain) {
|
|
|
3656
3696
|
function resolveConnector(connector) {
|
|
3657
3697
|
if (typeof connector !== "string" || connector.trim().length === 0) {
|
|
3658
3698
|
throw new ConfigError(
|
|
3659
|
-
`connector is required: the client-edge URL of the node to pay, e.g. '${DEVNET.
|
|
3699
|
+
`connector is required: the client-edge URL of the node to pay, e.g. '${DEVNET.connector}'. One free GET on it returns every other fact needed to transact (self-description-spec.md, connector ADR 0050).`
|
|
3660
3700
|
);
|
|
3661
3701
|
}
|
|
3662
3702
|
let base;
|
|
@@ -8396,6 +8436,7 @@ var ToonClient = class _ToonClient {
|
|
|
8396
8436
|
this.assertEndpointReachable(httpEndpoint);
|
|
8397
8437
|
const http2 = new HttpIlpClient({
|
|
8398
8438
|
httpEndpoint,
|
|
8439
|
+
...description.httpEndpoint !== void 0 ? { endpointSource: "published" } : {},
|
|
8399
8440
|
timeout: this.config.timeoutMs,
|
|
8400
8441
|
httpClient: this.config.fetch,
|
|
8401
8442
|
...this.config.createWebSocket ? { createWebSocket: this.config.createWebSocket } : {}
|
|
@@ -8422,6 +8463,8 @@ var ToonClient = class _ToonClient {
|
|
|
8422
8463
|
kind: "btp",
|
|
8423
8464
|
transport: new BtpPaidWriteTransport({
|
|
8424
8465
|
session,
|
|
8466
|
+
url: choice.url,
|
|
8467
|
+
endpointSource: "published",
|
|
8425
8468
|
// HTTP fallback only where the node did not REQUIRE btp *for this
|
|
8426
8469
|
// destination*: falling back onto a carriage the route refuses would
|
|
8427
8470
|
// turn a recoverable socket outage into a `402` per request. Read
|
|
@@ -8536,6 +8579,7 @@ function lazyEvmReader(config) {
|
|
|
8536
8579
|
export {
|
|
8537
8580
|
ToonClientError,
|
|
8538
8581
|
NetworkError,
|
|
8582
|
+
describeEndpoint,
|
|
8539
8583
|
ConnectorError,
|
|
8540
8584
|
ValidationError,
|
|
8541
8585
|
ConfigError,
|
|
@@ -8748,4 +8792,4 @@ export {
|
|
|
8748
8792
|
toEnvelopeRequest,
|
|
8749
8793
|
ToonClient
|
|
8750
8794
|
};
|
|
8751
|
-
//# sourceMappingURL=chunk-
|
|
8795
|
+
//# sourceMappingURL=chunk-GNPJRJ6U.js.map
|