sigild 0.0.10 → 0.0.11
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 +34 -0
- package/THREAT_MODEL.md +11 -0
- package/dist/src/bin/sigil-mcp.js +62 -6
- package/dist/src/bin/sigil-mcp.js.map +1 -1
- package/dist/src/confirm/config.d.ts +29 -2
- package/dist/src/confirm/config.d.ts.map +1 -1
- package/dist/src/confirm/config.js +52 -0
- package/dist/src/confirm/config.js.map +1 -1
- package/dist/src/confirm/index.d.ts +1 -1
- package/dist/src/confirm/index.d.ts.map +1 -1
- package/dist/src/confirm/index.js +1 -1
- package/dist/src/confirm/index.js.map +1 -1
- package/dist/src/mcp/server.d.ts +8 -0
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +8 -1
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/rpc/fill.d.ts +16 -0
- package/dist/src/rpc/fill.d.ts.map +1 -0
- package/dist/src/rpc/fill.js +202 -0
- package/dist/src/rpc/fill.js.map +1 -0
- package/dist/src/rpc/index.d.ts +4 -0
- package/dist/src/rpc/index.d.ts.map +1 -0
- package/dist/src/rpc/index.js +4 -0
- package/dist/src/rpc/index.js.map +1 -0
- package/dist/src/rpc/server.d.ts +63 -0
- package/dist/src/rpc/server.d.ts.map +1 -0
- package/dist/src/rpc/server.js +301 -0
- package/dist/src/rpc/server.js.map +1 -0
- package/dist/src/rpc/upstream.d.ts +48 -0
- package/dist/src/rpc/upstream.d.ts.map +1 -0
- package/dist/src/rpc/upstream.js +74 -0
- package/dist/src/rpc/upstream.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,6 +196,40 @@ Install the ntfy app on your phone, subscribe to that topic, and you'll get a pu
|
|
|
196
196
|
|
|
197
197
|
If any policy file sets `require_confirm_above_wei` but no transport is configured, `sigil-mcp` refuses to start with a clear error rather than silently degrading every confirm-gated sign to a deny.
|
|
198
198
|
|
|
199
|
+
## JSON-RPC signing proxy (Foundry / Hardhat / any web3 tool)
|
|
200
|
+
|
|
201
|
+
sigil can expose a local JSON-RPC endpoint that makes any portal a drop-in signer for tooling that expects an unlocked node account — the same pattern Clef and web3signer use. Contract bytecode goes from `forge` straight into sigil; it never transits the agent's context or an MCP tool parameter.
|
|
202
|
+
|
|
203
|
+
Enable it in `~/.sigil/config.toml`:
|
|
204
|
+
|
|
205
|
+
```toml
|
|
206
|
+
[rpc]
|
|
207
|
+
portal = "evm:bot" # which portal signs
|
|
208
|
+
upstream = "https://sepolia.example/v3/KEY" # real node for everything else
|
|
209
|
+
token = "<openssl rand -hex 24>" # required — guards the endpoint
|
|
210
|
+
# port = 8547 # default 8547 (clear of anvil's 8545)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Then point any tool at it, with the token as the Basic-auth password:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
forge script script/Deploy.s.sol \
|
|
217
|
+
--rpc-url "http://sigil:<token>@127.0.0.1:8547" \
|
|
218
|
+
--unlocked --sender 0xYourPortalAddress --broadcast
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The proxy serves three things with the portal key and forwards everything else (`eth_call`, `eth_estimateGas`, `eth_getTransactionReceipt`, …) to the upstream:
|
|
222
|
+
|
|
223
|
+
- `eth_accounts` → the portal address (empty while locked)
|
|
224
|
+
- `eth_signTransaction` → fills nonce/gas/fees if missing, signs, returns the raw tx
|
|
225
|
+
- `eth_sendTransaction` → same, then broadcasts via the upstream and returns the hash
|
|
226
|
+
|
|
227
|
+
**Security properties.** The listener binds `127.0.0.1` only; every request must present the config token (constant-time compared) and a loopback `Host` header (DNS-rebinding defence). Signing runs through the *identical* daemon pipeline as the MCP tools — policy checks, the out-of-band confirm gate, and the hash-chained audit log all apply, so this surface adds a transport, not a privilege. The filled transaction carries the **upstream's** chain id, so a strict policy's `chain_ids` allowlist binds the proxy to the network you configured. Message/typed-data methods (`eth_sign`, `personal_sign`, `eth_signTypedData*`) are rejected on this surface — use the MCP tools, which have their own policy toggles. A strict policy with `allow_contract_creation = true` gives you confirm-gated `forge script` deploys: forge submits, your phone buzzes, the tx signs when you tap approve.
|
|
228
|
+
|
|
229
|
+
With multiple Claude windows open, each `sigil-mcp` tries to bind the port; the first wins and the rest log and continue — any one session's proxy serves the machine.
|
|
230
|
+
|
|
231
|
+
When the proxy is enabled, sigil-mcp advertises the endpoint — including the authenticated URL — in the `sigil_eth_sign_transaction` tool description, so the agent discovers it on its own and reaches for `forge --unlocked` instead of transcribing bytecode through the MCP tool. This is deliberate: the token gates other local software, not your agent (see THREAT_MODEL.md).
|
|
232
|
+
|
|
199
233
|
## Solana (SVM)
|
|
200
234
|
|
|
201
235
|
Every portal also controls a **Solana address**, derived from the *same secret*. EVM uses secp256k1; Solana uses ed25519 — different curves, so you can't share a public key. But the portal's raw 32-byte secret doubles as an ed25519 seed, yielding one secret → two addresses:
|
package/THREAT_MODEL.md
CHANGED
|
@@ -31,6 +31,17 @@ The unlock path:
|
|
|
31
31
|
|
|
32
32
|
This shape was chosen so the agent has no path to trigger unlock — only a human at the local TTY can. `sigil lock` zeroizes the in-memory table without killing the process; subsequent signs return `DAEMON_LOCKED` again until the next `sigil unlock`.
|
|
33
33
|
|
|
34
|
+
### The JSON-RPC signing proxy surface
|
|
35
|
+
|
|
36
|
+
With a `[rpc]` block in `~/.sigil/config.toml`, `sigil-mcp` additionally listens on `127.0.0.1:<port>` and serves `eth_accounts` / `eth_signTransaction` / `eth_sendTransaction` with the configured portal's key (proxying every other method to the configured upstream node). This is a deliberate second way to reach a key, added so Foundry/Hardhat-class tooling can sign without transaction payloads transiting the agent's context. Its containment:
|
|
37
|
+
|
|
38
|
+
- **Same pipeline, no proxy privilege.** Proxy signs are dispatched through the identical daemon path as the MCP tools — policy evaluation, the out-of-band confirm gate, and the hash-chained audit log all apply. There is no signing branch unique to the proxy.
|
|
39
|
+
- **Mandatory shared token.** Every request must present the config token (min 16 chars, constant-time compared) as a Bearer credential or the Basic-auth password. Without it, any local process could ask a permissive-mode portal to sign arbitrary transactions. The token lives in `~/.sigil/config.toml` (0700 home dir) — it gates *other software on the machine*, not the user's own agent: when the proxy is enabled, sigil-mcp deliberately advertises the authenticated URL in the `sigil_eth_sign_transaction` tool description so the agent can drive forge/hardhat against it (the ward hooks block it from reading the config file directly). The token therefore appears in agent context and transcripts; that is accepted — it is useless without local code execution, at which point the attacker already has the config file.
|
|
40
|
+
- **Loopback binding + Host allowlist.** The listener binds 127.0.0.1 only and rejects any request whose `Host` header is not a loopback name, which closes DNS-rebinding attacks from a browser tab even if the token leaks into a page-visible URL.
|
|
41
|
+
- **Chain binding.** The proxy fills transactions with the *upstream's* `eth_chainId`; a strict policy's `chain_ids` allowlist therefore pins the proxy to the intended network, and a client-supplied `chainId` that disagrees with the upstream is rejected outright.
|
|
42
|
+
- **Fail-closed inheritance.** Locked handle table, policy deny, confirm deny/timeout, missing confirm transport — each surfaces as a JSON-RPC error and no signature is produced. `eth_sign`/`personal_sign`/`eth_signTypedData*` are rejected on this surface entirely.
|
|
43
|
+
- **Residual risk, stated plainly:** with a **permissive** portal and the token, anything that can POST to loopback signs at will — same authority the MCP tools already grant the agent, now reachable by any tool the user (or agent) runs. Use a strict policy on any proxy-exposed portal that holds real value, and a confirm threshold for the rest. The upstream node also becomes an availability and privacy dependency: it sees every proxied call and the broadcast of every signed tx.
|
|
44
|
+
|
|
34
45
|
## In scope
|
|
35
46
|
|
|
36
47
|
### 1. Preventing key ingestion by the agent
|
|
@@ -7,6 +7,7 @@ import { startControlServer } from '../control/index.js';
|
|
|
7
7
|
import { HandleTable } from '../daemon/handles.js';
|
|
8
8
|
import { runMcpStdio } from '../mcp/server.js';
|
|
9
9
|
import { FileSystemPolicyResolver } from '../policy/index.js';
|
|
10
|
+
import { DEFAULT_RPC_PORT, startRpcServer } from '../rpc/index.js';
|
|
10
11
|
/**
|
|
11
12
|
* sigil-mcp: single-process MCP server for sigil. Spawned by Claude Code per
|
|
12
13
|
* session via the .claude/settings.json mcpServers entry.
|
|
@@ -67,6 +68,60 @@ async function main() {
|
|
|
67
68
|
const handles = new HandleTable();
|
|
68
69
|
const audit = new AuditWriter(paths.auditLog);
|
|
69
70
|
const policy = new FileSystemPolicyResolver(paths.policyDir);
|
|
71
|
+
const context = {
|
|
72
|
+
handles,
|
|
73
|
+
audit,
|
|
74
|
+
policy,
|
|
75
|
+
...(confirmGate ? { confirm: confirmGate } : {}),
|
|
76
|
+
};
|
|
77
|
+
// Local JSON-RPC signing proxy (forge/hardhat/cast integration). Shares
|
|
78
|
+
// `context` with the MCP loop, so its signs run the identical policy →
|
|
79
|
+
// confirm → audit pipeline. Multiple Claude windows each spawn a
|
|
80
|
+
// sigil-mcp; only the first binds the port — the others log and carry on,
|
|
81
|
+
// since any one session's proxy serves the machine.
|
|
82
|
+
let rpcServer;
|
|
83
|
+
let rpcProxyPort;
|
|
84
|
+
if (config.rpc) {
|
|
85
|
+
try {
|
|
86
|
+
rpcServer = await startRpcServer({
|
|
87
|
+
config: config.rpc,
|
|
88
|
+
ctx: context,
|
|
89
|
+
onLog: (e) => process.stderr.write(`rpc: ${JSON.stringify(e)}\n`),
|
|
90
|
+
});
|
|
91
|
+
rpcProxyPort = rpcServer.port;
|
|
92
|
+
const upstreamOrigin = new URL(config.rpc.upstream).origin;
|
|
93
|
+
process.stderr.write(`sigil-mcp: json-rpc signing proxy on ${rpcServer.url} ` +
|
|
94
|
+
`(portal "${config.rpc.portal}", upstream ${upstreamOrigin})\n`);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
if (err.code === 'EADDRINUSE') {
|
|
98
|
+
// Another session already serves the proxy on the configured port —
|
|
99
|
+
// still advertise it to the model below; it's the same config.
|
|
100
|
+
rpcProxyPort = config.rpc.port ?? DEFAULT_RPC_PORT;
|
|
101
|
+
process.stderr.write(`sigil-mcp: rpc port busy — another sigil-mcp session already serves the proxy\n`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Tell the model the proxy exists — tool descriptions are its only
|
|
109
|
+
// discovery channel. The authenticated URL is included on purpose: the
|
|
110
|
+
// token gates other local software, not the agent (which is the intended
|
|
111
|
+
// client and cannot read the config file past the ward hooks).
|
|
112
|
+
let toolNotes;
|
|
113
|
+
if (config.rpc && rpcProxyPort !== undefined) {
|
|
114
|
+
const authedUrl = `http://sigil:${config.rpc.token}@127.0.0.1:${rpcProxyPort}`;
|
|
115
|
+
toolNotes = {
|
|
116
|
+
sigil_eth_sign_transaction: `NOTE: sigil also serves a local JSON-RPC signing proxy for portal ` +
|
|
117
|
+
`"${config.rpc.portal}" at ${authedUrl} (chain per its configured upstream). ` +
|
|
118
|
+
`For Foundry/Hardhat/web3-tool workflows — especially contract deployments — ` +
|
|
119
|
+
`prefer that endpoint over transcribing calldata into this tool: e.g. ` +
|
|
120
|
+
`forge script <Script> --rpc-url '${authedUrl}' --unlocked --sender <portal address> --broadcast. ` +
|
|
121
|
+
`Its eth_sendTransaction fills nonce/gas/fees automatically, broadcasts via the ` +
|
|
122
|
+
`upstream, and runs the same policy, confirm, and audit pipeline as this tool.`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
70
125
|
let controlClosed = false;
|
|
71
126
|
let control = null;
|
|
72
127
|
try {
|
|
@@ -102,17 +157,16 @@ async function main() {
|
|
|
102
157
|
if (ackServer) {
|
|
103
158
|
ackServer.close().catch(() => { });
|
|
104
159
|
}
|
|
160
|
+
if (rpcServer) {
|
|
161
|
+
rpcServer.close().catch(() => { });
|
|
162
|
+
}
|
|
105
163
|
};
|
|
106
164
|
process.on('exit', shutdown);
|
|
107
165
|
process.on('SIGINT', () => process.exit(0));
|
|
108
166
|
process.on('SIGTERM', () => process.exit(0));
|
|
109
167
|
await runMcpStdio({
|
|
110
|
-
context
|
|
111
|
-
|
|
112
|
-
audit,
|
|
113
|
-
policy,
|
|
114
|
-
...(confirmGate ? { confirm: confirmGate } : {}),
|
|
115
|
-
},
|
|
168
|
+
context,
|
|
169
|
+
...(toolNotes ? { toolNotes } : {}),
|
|
116
170
|
stdin: process.stdin,
|
|
117
171
|
stdout: process.stdout,
|
|
118
172
|
onLog: (e) => process.stderr.write(JSON.stringify(e) + '\n'),
|
|
@@ -125,6 +179,8 @@ async function main() {
|
|
|
125
179
|
}
|
|
126
180
|
if (ackServer)
|
|
127
181
|
await ackServer.close();
|
|
182
|
+
if (rpcServer)
|
|
183
|
+
await rpcServer.close();
|
|
128
184
|
process.exit(0);
|
|
129
185
|
}
|
|
130
186
|
main().catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sigil-mcp.js","sourceRoot":"","sources":["../../../src/bin/sigil-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,UAAU,EACV,aAAa,EACb,cAAc,GAGf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sigil-mcp.js","sourceRoot":"","sources":["../../../src/bin/sigil-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,UAAU,EACV,aAAa,EACb,cAAc,GAGf,MAAM,qBA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CAAC,KAAK,EAAE,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* sigil config at ~/.sigil/config.toml.
|
|
3
|
-
*
|
|
2
|
+
* sigil config at ~/.sigil/config.toml. Carries the OOB confirm transport
|
|
3
|
+
* block and the optional local JSON-RPC signing proxy block.
|
|
4
4
|
*
|
|
5
5
|
* [confirm.ntfy]
|
|
6
6
|
* topic = "an-unguessable-string"
|
|
7
7
|
* server = "https://ntfy.sh" # optional, default https://ntfy.sh
|
|
8
8
|
*
|
|
9
|
+
* [rpc]
|
|
10
|
+
* portal = "evm:bot"
|
|
11
|
+
* upstream = "https://sepolia.example/v3/KEY"
|
|
12
|
+
* token = "an-unguessable-string-16+chars"
|
|
13
|
+
* port = 8547 # optional
|
|
14
|
+
*
|
|
9
15
|
* Missing file → SigilConfig with no transport configured. That's fine on
|
|
10
16
|
* its own; we only fail closed at startup if some policy actually depends
|
|
11
17
|
* on a transport (see `enforceConfirmTransportPresence`).
|
|
12
18
|
*/
|
|
13
19
|
export interface SigilConfig {
|
|
14
20
|
confirm?: ConfirmConfig;
|
|
21
|
+
rpc?: RpcConfigToml;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Local JSON-RPC signing proxy (`[rpc]` block). All of portal/upstream/token
|
|
25
|
+
* are required — the proxy never starts without an auth token, and a token
|
|
26
|
+
* under 16 chars is rejected at parse time rather than silently weakening
|
|
27
|
+
* the only thing standing between "any local process" and "signs with the
|
|
28
|
+
* portal key".
|
|
29
|
+
*/
|
|
30
|
+
export interface RpcConfigToml {
|
|
31
|
+
/** Portal handle whose key answers eth_accounts / signs eth_sendTransaction. */
|
|
32
|
+
portal: string;
|
|
33
|
+
/** Upstream JSON-RPC node everything else is proxied to. http(s) only. */
|
|
34
|
+
upstream: string;
|
|
35
|
+
/** Shared secret every request must present (Bearer or Basic password). */
|
|
36
|
+
token: string;
|
|
37
|
+
/** Listen port on 127.0.0.1. Default 8547 (clear of anvil's 8545). */
|
|
38
|
+
port?: number;
|
|
15
39
|
}
|
|
16
40
|
export interface ConfirmConfig {
|
|
17
41
|
/** Default timeout for any OOB confirm round-trip, in milliseconds.
|
|
@@ -32,6 +56,9 @@ export declare class SigilConfigError extends Error {
|
|
|
32
56
|
* file-not-found case is handled uniformly.
|
|
33
57
|
*/
|
|
34
58
|
export declare function parseConfig(source: string): SigilConfig;
|
|
59
|
+
/** Minimum length for the [rpc] auth token. Below this, brute force from a
|
|
60
|
+
* rebound browser page or a local process stops being fanciful. */
|
|
61
|
+
export declare const RPC_TOKEN_MIN_LENGTH = 16;
|
|
35
62
|
/**
|
|
36
63
|
* Load + parse the file at ~/.sigil/config.toml. Returns an empty config if
|
|
37
64
|
* the file is absent. Throws SigilConfigError on parse/schema errors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/confirm/config.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/confirm/config.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B;+DAC2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CA6CvD;AAED;oEACoE;AACpE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAqDvC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CASpD;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CA4BnE;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,GAChB,IAAI,CAWN"}
|
|
@@ -24,6 +24,9 @@ export function parseConfig(source) {
|
|
|
24
24
|
throw new SigilConfigError(`config: invalid TOML — ${err.message}`);
|
|
25
25
|
}
|
|
26
26
|
const out = {};
|
|
27
|
+
const rpc = parseRpcBlock(raw['rpc']);
|
|
28
|
+
if (rpc)
|
|
29
|
+
out.rpc = rpc;
|
|
27
30
|
const confirmRaw = raw['confirm'];
|
|
28
31
|
if (confirmRaw === undefined)
|
|
29
32
|
return out;
|
|
@@ -58,6 +61,55 @@ export function parseConfig(source) {
|
|
|
58
61
|
}
|
|
59
62
|
return out;
|
|
60
63
|
}
|
|
64
|
+
/** Minimum length for the [rpc] auth token. Below this, brute force from a
|
|
65
|
+
* rebound browser page or a local process stops being fanciful. */
|
|
66
|
+
export const RPC_TOKEN_MIN_LENGTH = 16;
|
|
67
|
+
function parseRpcBlock(rpcRaw) {
|
|
68
|
+
if (rpcRaw === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
if (!isObject(rpcRaw)) {
|
|
71
|
+
throw new SigilConfigError(`config.rpc must be a table`);
|
|
72
|
+
}
|
|
73
|
+
const portal = rpcRaw['portal'];
|
|
74
|
+
if (typeof portal !== 'string' || portal.length === 0) {
|
|
75
|
+
throw new SigilConfigError(`config.rpc.portal is required and must be a portal handle`);
|
|
76
|
+
}
|
|
77
|
+
const upstream = rpcRaw['upstream'];
|
|
78
|
+
if (typeof upstream !== 'string' || upstream.length === 0) {
|
|
79
|
+
throw new SigilConfigError(`config.rpc.upstream is required and must be a JSON-RPC URL`);
|
|
80
|
+
}
|
|
81
|
+
let upstreamUrl;
|
|
82
|
+
try {
|
|
83
|
+
upstreamUrl = new URL(upstream);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
throw new SigilConfigError(`config.rpc.upstream is not a valid URL`);
|
|
87
|
+
}
|
|
88
|
+
if (upstreamUrl.protocol !== 'http:' && upstreamUrl.protocol !== 'https:') {
|
|
89
|
+
throw new SigilConfigError(`config.rpc.upstream must be http(s), got ${upstreamUrl.protocol.replace(/:$/, '')}`);
|
|
90
|
+
}
|
|
91
|
+
const token = rpcRaw['token'];
|
|
92
|
+
if (typeof token !== 'string' || token.length === 0) {
|
|
93
|
+
throw new SigilConfigError(`config.rpc.token is required — generate one with: openssl rand -hex 24`);
|
|
94
|
+
}
|
|
95
|
+
if (token.length < RPC_TOKEN_MIN_LENGTH) {
|
|
96
|
+
throw new SigilConfigError(`config.rpc.token must be at least ${RPC_TOKEN_MIN_LENGTH} characters — ` +
|
|
97
|
+
`it is the only credential guarding the signing endpoint. ` +
|
|
98
|
+
`Generate one with: openssl rand -hex 24`);
|
|
99
|
+
}
|
|
100
|
+
const port = rpcRaw['port'];
|
|
101
|
+
if (port !== undefined) {
|
|
102
|
+
if (typeof port !== 'number' || !Number.isInteger(port) || port < 1 || port > 65535) {
|
|
103
|
+
throw new SigilConfigError(`config.rpc.port must be an integer in 1..65535`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
portal,
|
|
108
|
+
upstream,
|
|
109
|
+
token,
|
|
110
|
+
...(port !== undefined ? { port: port } : {}),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
61
113
|
/**
|
|
62
114
|
* Load + parse the file at ~/.sigil/config.toml. Returns an empty config if
|
|
63
115
|
* the file is absent. Throws SigilConfigError on parse/schema errors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/confirm/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/confirm/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAuDlE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAA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,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;YAC9B,IAAI,CAAC,CAAC,sBAAsB,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YACxD,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,qBAAqB;gBAAE,OAAO,IAAI,CAAC;QAClE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mEAAmE;YACnE,wDAAwD;YACxD,IAAI,GAAG,YAAY,eAAe;gBAAE,SAAS;YAC7C,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC7C,MAAmB,EACnB,SAAiB;IAEjB,MAAM,cAAc,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAC3D,IAAI,CAAC,cAAc;QAAE,OAAO;IAC5B,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC;IACzD,IAAI,aAAa;QAAE,OAAO;IAC1B,MAAM,IAAI,gBAAgB,CACxB,iCAAiC,SAAS,mCAAmC;QAC7E,8CAA8C;QAC9C,mEAAmE;QACnE,qEAAqE,CACtE,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -2,5 +2,5 @@ export { type ConfirmRequest, type ConfirmDecision, type ConfirmTransport, } fro
|
|
|
2
2
|
export { NtfyTransport, type NtfyConfig, type FetchLike } from './ntfy.js';
|
|
3
3
|
export { startAckServer, type AckServer, type AckOutcome, } from './ack-server.js';
|
|
4
4
|
export { ConfirmGate, type ConfirmGateOpts } from './gate.js';
|
|
5
|
-
export { type SigilConfig, type ConfirmConfig, type NtfyConfigToml, SigilConfigError, parseConfig, loadConfig, anyPolicyRequiresConfirm, enforceConfirmTransportPresence, } from './config.js';
|
|
5
|
+
export { type SigilConfig, type ConfirmConfig, type NtfyConfigToml, type RpcConfigToml, RPC_TOKEN_MIN_LENGTH, SigilConfigError, parseConfig, loadConfig, anyPolicyRequiresConfirm, enforceConfirmTransportPresence, } from './config.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/confirm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/confirm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { NtfyTransport } from './ntfy.js';
|
|
2
2
|
export { startAckServer, } from './ack-server.js';
|
|
3
3
|
export { ConfirmGate } from './gate.js';
|
|
4
|
-
export { SigilConfigError, parseConfig, loadConfig, anyPolicyRequiresConfirm, enforceConfirmTransportPresence, } from './config.js';
|
|
4
|
+
export { RPC_TOKEN_MIN_LENGTH, SigilConfigError, parseConfig, loadConfig, anyPolicyRequiresConfirm, enforceConfirmTransportPresence, } from './config.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/confirm/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAmC,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAwB,MAAM,WAAW,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/confirm/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAmC,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAwB,MAAM,WAAW,CAAC;AAC9D,OAAO,EAKL,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,aAAa,CAAC"}
|
package/dist/src/mcp/server.d.ts
CHANGED
|
@@ -6,6 +6,14 @@ export interface McpServerOpts {
|
|
|
6
6
|
* sign methods directly against this — no cross-process IPC.
|
|
7
7
|
*/
|
|
8
8
|
context: MethodContext;
|
|
9
|
+
/**
|
|
10
|
+
* Extra text appended to a tool's description at tools/list time, keyed by
|
|
11
|
+
* tool name. Tool descriptions are the only channel through which the
|
|
12
|
+
* model discovers capabilities, and the static definitions can't know
|
|
13
|
+
* runtime config — this is how sigil-mcp advertises the JSON-RPC signing
|
|
14
|
+
* proxy endpoint when the [rpc] block is enabled.
|
|
15
|
+
*/
|
|
16
|
+
toolNotes?: Readonly<Record<string, string>>;
|
|
9
17
|
/**
|
|
10
18
|
* Optional log sink for protocol-level events. Defaults to a no-op.
|
|
11
19
|
* The default binary entrypoint writes log events to stderr so they don't
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAWL,KAAK,KAAK,EAEX,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,OAAO,EAAE,aAAa,CAAC;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,KAAK,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAA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CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B7D"}
|
package/dist/src/mcp/server.js
CHANGED
|
@@ -52,7 +52,14 @@ async function dispatch(req, opts) {
|
|
|
52
52
|
serverInfo: SERVER_INFO,
|
|
53
53
|
};
|
|
54
54
|
case 'tools/list':
|
|
55
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
tools: TOOLS.map((t) => {
|
|
57
|
+
const note = opts.toolNotes?.[t.definition.name];
|
|
58
|
+
return note === undefined
|
|
59
|
+
? t.definition
|
|
60
|
+
: { ...t.definition, description: `${t.definition.description}\n\n${note}` };
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
56
63
|
case 'tools/call':
|
|
57
64
|
return await invokeTool(req.params, opts);
|
|
58
65
|
case 'ping':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EACL,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,WAAW,GAGZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EACL,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,WAAW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B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;oBAAE,SAAS;gBAChC,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;oBACtC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBAC1C,IAAI,IAAI,KAAK,IAAI;wBAAE,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACnB,oEAAoE;YACpE,wDAAwD;YACxD,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type JsonRpcUpstream } from './upstream.js';
|
|
2
|
+
/** Invalid client input. The proxy maps this to JSON-RPC -32602. */
|
|
3
|
+
export declare class FillParamsError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export interface FillContext {
|
|
7
|
+
/** The portal's EVM address, lowercase. `from` must match it. */
|
|
8
|
+
portalAddress: string;
|
|
9
|
+
/** Chain ID reported by the upstream node (eth_chainId). */
|
|
10
|
+
chainId: bigint;
|
|
11
|
+
upstream: JsonRpcUpstream;
|
|
12
|
+
}
|
|
13
|
+
/** The daemon `tx` param shape (decimal strings; see daemon/methods.ts asTx). */
|
|
14
|
+
export type FilledTx = Record<string, unknown>;
|
|
15
|
+
export declare function fillTransaction(raw: Record<string, unknown>, fill: FillContext): Promise<FilledTx>;
|
|
16
|
+
//# sourceMappingURL=fill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../../src/rpc/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAkBvE,oEAAoE;AACpE,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,iFAAiF;AACjF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAW/C,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,QAAQ,CAAC,CAsHnB"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { UpstreamRpcError } from './upstream.js';
|
|
2
|
+
/**
|
|
3
|
+
* Turn an eth_sendTransaction/eth_signTransaction params object (JSON-RPC
|
|
4
|
+
* hex quantities, missing fields allowed) into the fully-specified tx shape
|
|
5
|
+
* sigil's daemon dispatch expects (decimal-string quantities, every field
|
|
6
|
+
* present). Missing nonce/gas/fees are filled from the upstream node.
|
|
7
|
+
*
|
|
8
|
+
* This runs BEFORE policy — it only shapes the request; every security
|
|
9
|
+
* decision (chain allowlist, destination allowlist, value cap, contract
|
|
10
|
+
* creation, confirm) happens inside the daemon sign path the result is
|
|
11
|
+
* dispatched to.
|
|
12
|
+
*/
|
|
13
|
+
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
14
|
+
const QTY_RE = /^0x[0-9a-fA-F]+$/;
|
|
15
|
+
const DATA_RE = /^0x[0-9a-fA-F]*$/;
|
|
16
|
+
/** Invalid client input. The proxy maps this to JSON-RPC -32602. */
|
|
17
|
+
export class FillParamsError extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'FillParamsError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Fallback priority fee when the node doesn't serve eth_maxPriorityFeePerGas. */
|
|
24
|
+
const DEFAULT_TIP_WEI = 1000000000n; // 1 gwei
|
|
25
|
+
/** Headroom multiplier applied to eth_estimateGas (×1.2). Estimates are the
|
|
26
|
+
* simulated minimum; state moving between estimate and inclusion makes the
|
|
27
|
+
* exact value flaky, and unused gas is refunded. */
|
|
28
|
+
const GAS_HEADROOM_NUM = 12n;
|
|
29
|
+
const GAS_HEADROOM_DEN = 10n;
|
|
30
|
+
export async function fillTransaction(raw, fill) {
|
|
31
|
+
// --- from: required, must be the portal's own address -------------------
|
|
32
|
+
const from = raw['from'];
|
|
33
|
+
if (typeof from !== 'string' || !ADDR_RE.test(from)) {
|
|
34
|
+
throw new FillParamsError('tx.from is required and must be a 0x address');
|
|
35
|
+
}
|
|
36
|
+
if (from.toLowerCase() !== fill.portalAddress) {
|
|
37
|
+
throw new FillParamsError(`unknown account ${from} — this endpoint signs only for ${fill.portalAddress}`);
|
|
38
|
+
}
|
|
39
|
+
// --- chainId: optional, but must match the upstream if given ------------
|
|
40
|
+
if (raw['chainId'] !== undefined) {
|
|
41
|
+
const chainId = qty(raw['chainId'], 'chainId');
|
|
42
|
+
if (chainId !== fill.chainId) {
|
|
43
|
+
throw new FillParamsError(`tx.chainId ${chainId} does not match upstream chain ${fill.chainId}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// --- to: absent/null = contract creation --------------------------------
|
|
47
|
+
const toRaw = raw['to'];
|
|
48
|
+
let to;
|
|
49
|
+
if (toRaw === undefined || toRaw === null) {
|
|
50
|
+
to = null;
|
|
51
|
+
}
|
|
52
|
+
else if (typeof toRaw === 'string' && ADDR_RE.test(toRaw)) {
|
|
53
|
+
to = toRaw;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new FillParamsError('tx.to must be a 0x address, null, or omitted');
|
|
57
|
+
}
|
|
58
|
+
// --- data / input: spec-standard alias pair -----------------------------
|
|
59
|
+
const data = pickData(raw);
|
|
60
|
+
const value = raw['value'] === undefined ? 0n : qty(raw['value'], 'value');
|
|
61
|
+
// --- nonce ---------------------------------------------------------------
|
|
62
|
+
const nonce = raw['nonce'] !== undefined
|
|
63
|
+
? qty(raw['nonce'], 'nonce')
|
|
64
|
+
: qtyResult(await fill.upstream.call('eth_getTransactionCount', [from, 'pending']), 'eth_getTransactionCount');
|
|
65
|
+
// --- gas limit ------------------------------------------------------------
|
|
66
|
+
let gasLimit;
|
|
67
|
+
if (raw['gas'] !== undefined) {
|
|
68
|
+
gasLimit = qty(raw['gas'], 'gas');
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const estimateParams = {
|
|
72
|
+
from,
|
|
73
|
+
data,
|
|
74
|
+
value: toQtyHex(value),
|
|
75
|
+
...(to !== null ? { to } : {}),
|
|
76
|
+
};
|
|
77
|
+
const estimated = qtyResult(await fill.upstream.call('eth_estimateGas', [estimateParams]), 'eth_estimateGas');
|
|
78
|
+
gasLimit = (estimated * GAS_HEADROOM_NUM) / GAS_HEADROOM_DEN;
|
|
79
|
+
}
|
|
80
|
+
const common = {
|
|
81
|
+
chainId: fill.chainId.toString(),
|
|
82
|
+
nonce: nonce.toString(),
|
|
83
|
+
gasLimit: gasLimit.toString(),
|
|
84
|
+
to,
|
|
85
|
+
value: value.toString(),
|
|
86
|
+
data,
|
|
87
|
+
};
|
|
88
|
+
// --- fees -----------------------------------------------------------------
|
|
89
|
+
const hasGasPrice = raw['gasPrice'] !== undefined;
|
|
90
|
+
const hasMaxFee = raw['maxFeePerGas'] !== undefined;
|
|
91
|
+
const hasTip = raw['maxPriorityFeePerGas'] !== undefined;
|
|
92
|
+
if (hasGasPrice && (hasMaxFee || hasTip)) {
|
|
93
|
+
throw new FillParamsError('tx mixes gasPrice with maxFeePerGas/maxPriorityFeePerGas');
|
|
94
|
+
}
|
|
95
|
+
if (hasGasPrice) {
|
|
96
|
+
return { ...common, type: 'legacy', gasPrice: qty(raw['gasPrice'], 'gasPrice').toString() };
|
|
97
|
+
}
|
|
98
|
+
// EIP-1559 by default; fall back to legacy on a pre-London chain (no
|
|
99
|
+
// baseFeePerGas in the latest block).
|
|
100
|
+
let maxFeePerGas = hasMaxFee ? qty(raw['maxFeePerGas'], 'maxFeePerGas') : undefined;
|
|
101
|
+
let tip = hasTip ? qty(raw['maxPriorityFeePerGas'], 'maxPriorityFeePerGas') : undefined;
|
|
102
|
+
if (maxFeePerGas === undefined || tip === undefined) {
|
|
103
|
+
const baseFee = await fetchBaseFee(fill.upstream);
|
|
104
|
+
if (baseFee === undefined) {
|
|
105
|
+
// Pre-London chain: no 1559 fields exist to fill; sign legacy instead.
|
|
106
|
+
const gasPrice = qtyResult(await fill.upstream.call('eth_gasPrice', []), 'eth_gasPrice');
|
|
107
|
+
return { ...common, type: 'legacy', gasPrice: gasPrice.toString() };
|
|
108
|
+
}
|
|
109
|
+
if (tip === undefined) {
|
|
110
|
+
tip = await fetchTip(fill.upstream);
|
|
111
|
+
// A filled tip must never exceed a caller-provided fee cap.
|
|
112
|
+
if (maxFeePerGas !== undefined && tip > maxFeePerGas)
|
|
113
|
+
tip = maxFeePerGas;
|
|
114
|
+
}
|
|
115
|
+
if (maxFeePerGas === undefined) {
|
|
116
|
+
// 2× base fee absorbs six consecutive max-increase blocks before the
|
|
117
|
+
// cap binds — the standard wallet heuristic.
|
|
118
|
+
maxFeePerGas = baseFee * 2n + tip;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (maxFeePerGas < tip) {
|
|
122
|
+
throw new FillParamsError('tx.maxFeePerGas is less than maxPriorityFeePerGas');
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
...common,
|
|
126
|
+
type: 'eip1559',
|
|
127
|
+
maxFeePerGas: maxFeePerGas.toString(),
|
|
128
|
+
maxPriorityFeePerGas: tip.toString(),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** Extract calldata, honouring the data/input alias pair: either alone is
|
|
132
|
+
* fine, both must agree (viem and recent forge send both). */
|
|
133
|
+
function pickData(raw) {
|
|
134
|
+
const data = raw['data'];
|
|
135
|
+
const input = raw['input'];
|
|
136
|
+
const check = (v, name) => {
|
|
137
|
+
if (typeof v !== 'string' || !DATA_RE.test(v)) {
|
|
138
|
+
throw new FillParamsError(`tx.${name} must be 0x-prefixed hex`);
|
|
139
|
+
}
|
|
140
|
+
return v;
|
|
141
|
+
};
|
|
142
|
+
if (data !== undefined && input !== undefined) {
|
|
143
|
+
const d = check(data, 'data');
|
|
144
|
+
const i = check(input, 'input');
|
|
145
|
+
if (d.toLowerCase() !== i.toLowerCase()) {
|
|
146
|
+
throw new FillParamsError('tx.data and tx.input are both set and disagree');
|
|
147
|
+
}
|
|
148
|
+
return d;
|
|
149
|
+
}
|
|
150
|
+
if (data !== undefined)
|
|
151
|
+
return check(data, 'data');
|
|
152
|
+
if (input !== undefined)
|
|
153
|
+
return check(input, 'input');
|
|
154
|
+
return '0x';
|
|
155
|
+
}
|
|
156
|
+
async function fetchBaseFee(upstream) {
|
|
157
|
+
const block = await upstream.call('eth_getBlockByNumber', ['latest', false]);
|
|
158
|
+
if (typeof block !== 'object' || block === null) {
|
|
159
|
+
throw new FillParamsError('upstream eth_getBlockByNumber returned no block');
|
|
160
|
+
}
|
|
161
|
+
const baseFee = block['baseFeePerGas'];
|
|
162
|
+
if (baseFee === undefined || baseFee === null)
|
|
163
|
+
return undefined;
|
|
164
|
+
return qtyResult(baseFee, 'baseFeePerGas');
|
|
165
|
+
}
|
|
166
|
+
async function fetchTip(upstream) {
|
|
167
|
+
try {
|
|
168
|
+
return qtyResult(await upstream.call('eth_maxPriorityFeePerGas', []), 'eth_maxPriorityFeePerGas');
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
// Method not on every node; a sane constant beats failing the sign.
|
|
172
|
+
if (err instanceof UpstreamRpcError)
|
|
173
|
+
return DEFAULT_TIP_WEI;
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** Parse a client-supplied JSON-RPC quantity (0x hex string, or a plain
|
|
178
|
+
* number some loose clients send). */
|
|
179
|
+
function qty(v, name) {
|
|
180
|
+
if (typeof v === 'string') {
|
|
181
|
+
if (!QTY_RE.test(v)) {
|
|
182
|
+
throw new FillParamsError(`tx.${name} must be a 0x-prefixed hex quantity`);
|
|
183
|
+
}
|
|
184
|
+
return BigInt(v);
|
|
185
|
+
}
|
|
186
|
+
if (typeof v === 'number' && Number.isSafeInteger(v) && v >= 0) {
|
|
187
|
+
return BigInt(v);
|
|
188
|
+
}
|
|
189
|
+
throw new FillParamsError(`tx.${name} must be a 0x-prefixed hex quantity`);
|
|
190
|
+
}
|
|
191
|
+
/** Parse a quantity out of an upstream RESPONSE — failures here are the
|
|
192
|
+
* node's fault, not the client's, so the error names the source method. */
|
|
193
|
+
function qtyResult(v, source) {
|
|
194
|
+
if (typeof v !== 'string' || !QTY_RE.test(v)) {
|
|
195
|
+
throw new FillParamsError(`upstream ${source} returned a malformed quantity`);
|
|
196
|
+
}
|
|
197
|
+
return BigInt(v);
|
|
198
|
+
}
|
|
199
|
+
function toQtyHex(v) {
|
|
200
|
+
return '0x' + v.toString(16);
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/rpc/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,eAAe,CAAC;AAEvE;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAClC,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC,oEAAoE;AACp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7C,MAAM,IAAI,eAAe,CAAC,YAAY,MAAM,gCAAgC,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DEFAULT_RPC_PORT, startRpcServer, type RpcProxyServer, type RpcServerConfig, type StartRpcServerOpts, } from './server.js';
|
|
2
|
+
export { fillTransaction, FillParamsError, type FillContext, type FilledTx } from './fill.js';
|
|
3
|
+
export { HttpUpstream, UpstreamRpcError, UpstreamTransportError, type HttpUpstreamOpts, type JsonRpcUpstream, type RpcFetchLike, } from './upstream.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9F,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,GAIf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAmC,MAAM,WAAW,CAAC;AAC9F,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,GAIvB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type MethodContext } from '../daemon/index.js';
|
|
2
|
+
import { type JsonRpcUpstream } from './upstream.js';
|
|
3
|
+
/**
|
|
4
|
+
* Local JSON-RPC signing proxy — the endpoint `forge script --unlocked`,
|
|
5
|
+
* hardhat, cast, or any web3 tool points at. Serves three account methods
|
|
6
|
+
* with the portal key and transparently proxies everything else to the
|
|
7
|
+
* configured upstream node:
|
|
8
|
+
*
|
|
9
|
+
* eth_accounts / eth_requestAccounts → [portal address]
|
|
10
|
+
* eth_signTransaction → fill nonce/gas/fees, sign, return raw tx hex
|
|
11
|
+
* eth_sendTransaction → same, then broadcast via upstream
|
|
12
|
+
* eth_sendRawTransaction, return the tx hash
|
|
13
|
+
* everything else → proxied verbatim to the upstream
|
|
14
|
+
*
|
|
15
|
+
* Security model — this is a NEW way to reach the portal key, so:
|
|
16
|
+
*
|
|
17
|
+
* - Signing goes through the daemon's `dispatch()` — the byte-identical
|
|
18
|
+
* path the MCP tools use. Policy evaluation, the out-of-band confirm
|
|
19
|
+
* gate, and the hash-chained audit log apply to every request from this
|
|
20
|
+
* surface; there is no proxy-only signing branch that could drift.
|
|
21
|
+
* - The listener binds 127.0.0.1 only, and every request must carry the
|
|
22
|
+
* shared token from config (`Authorization: Bearer <token>`, or the
|
|
23
|
+
* password half of HTTP Basic — i.e. an rpc URL of the form
|
|
24
|
+
* http://sigil:<token>@127.0.0.1:8547 works out of the box with forge).
|
|
25
|
+
* Tokens are compared in constant time. Without the token, any local
|
|
26
|
+
* process could ask a permissive-mode portal to sign a drain.
|
|
27
|
+
* - The Host header must be a loopback name. A DNS-rebinding page makes
|
|
28
|
+
* the victim browser send its own hostname there; rejecting non-loopback
|
|
29
|
+
* Hosts kills that class even if the token somehow leaked into a URL.
|
|
30
|
+
* - Message-signing methods (eth_sign, personal_sign, eth_signTypedData*)
|
|
31
|
+
* are rejected, not proxied — they'd silently fail upstream, and sigil's
|
|
32
|
+
* MCP tools already cover them with their own policy toggles.
|
|
33
|
+
* - Fail-closed inheritance: locked table, policy deny, confirm deny or
|
|
34
|
+
* timeout, missing confirm transport — every one surfaces as a JSON-RPC
|
|
35
|
+
* error to the client and never yields a signature.
|
|
36
|
+
*
|
|
37
|
+
* No TLS: loopback-only, same rationale as the ack server.
|
|
38
|
+
*/
|
|
39
|
+
export interface RpcServerConfig {
|
|
40
|
+
portal: string;
|
|
41
|
+
upstream: string;
|
|
42
|
+
token: string;
|
|
43
|
+
port?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface StartRpcServerOpts {
|
|
46
|
+
config: RpcServerConfig;
|
|
47
|
+
/** The SAME MethodContext the MCP loop uses — shared handles/audit/policy/confirm. */
|
|
48
|
+
ctx: MethodContext;
|
|
49
|
+
/** Injectable upstream for tests. Default: HttpUpstream(config.upstream). */
|
|
50
|
+
upstream?: JsonRpcUpstream;
|
|
51
|
+
/** Port override for tests (0 = kernel-assigned). Default: config.port ?? 8547. */
|
|
52
|
+
port?: number;
|
|
53
|
+
onLog?: (event: Record<string, unknown>) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface RpcProxyServer {
|
|
56
|
+
/** e.g. "http://127.0.0.1:8547" — no credentials embedded. */
|
|
57
|
+
readonly url: string;
|
|
58
|
+
readonly port: number;
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare const DEFAULT_RPC_PORT = 8547;
|
|
62
|
+
export declare function startRpcServer(opts: StartRpcServerOpts): Promise<RpcProxyServer>;
|
|
63
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/rpc/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAElF,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,eAAe,CAAC;IACxB,sFAAsF;IACtF,GAAG,EAAE,aAAa,CAAC;IACnB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAarC,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAqLhF"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import { dispatch, RpcMethodError } from '../daemon/index.js';
|
|
4
|
+
import { fillTransaction, FillParamsError } from './fill.js';
|
|
5
|
+
import { HttpUpstream, UpstreamRpcError, UpstreamTransportError, } from './upstream.js';
|
|
6
|
+
export const DEFAULT_RPC_PORT = 8547;
|
|
7
|
+
/** Cap request bodies at 8 MiB — far above any deploy tx, far below a DoS. */
|
|
8
|
+
const MAX_BODY_BYTES = 8 * 1024 * 1024;
|
|
9
|
+
const SIGNING_METHODS_NOT_SUPPORTED = new Set([
|
|
10
|
+
'eth_sign',
|
|
11
|
+
'personal_sign',
|
|
12
|
+
'eth_signTypedData',
|
|
13
|
+
'eth_signTypedData_v3',
|
|
14
|
+
'eth_signTypedData_v4',
|
|
15
|
+
]);
|
|
16
|
+
export function startRpcServer(opts) {
|
|
17
|
+
const { config, ctx } = opts;
|
|
18
|
+
const upstream = opts.upstream ?? new HttpUpstream(config.upstream);
|
|
19
|
+
const log = opts.onLog ?? (() => { });
|
|
20
|
+
const tokenDigest = sha256(config.token);
|
|
21
|
+
// Upstream chain id, fetched once on first use. A node doesn't change
|
|
22
|
+
// chains mid-life; if yours does, restart sigil-mcp.
|
|
23
|
+
let chainIdPromise;
|
|
24
|
+
const getChainId = () => {
|
|
25
|
+
chainIdPromise ??= (async () => {
|
|
26
|
+
const raw = await upstream.call('eth_chainId', []);
|
|
27
|
+
if (typeof raw !== 'string' || !/^0x[0-9a-fA-F]+$/.test(raw)) {
|
|
28
|
+
chainIdPromise = undefined; // retry on next request
|
|
29
|
+
throw new UpstreamTransportError('upstream eth_chainId returned a malformed quantity');
|
|
30
|
+
}
|
|
31
|
+
return BigInt(raw);
|
|
32
|
+
})();
|
|
33
|
+
chainIdPromise.catch(() => { chainIdPromise = undefined; });
|
|
34
|
+
return chainIdPromise;
|
|
35
|
+
};
|
|
36
|
+
const handleOne = async (req) => {
|
|
37
|
+
if (typeof req !== 'object' || req === null || Array.isArray(req)) {
|
|
38
|
+
return errorResponse(null, -32600, 'invalid request: not an object');
|
|
39
|
+
}
|
|
40
|
+
const r = req;
|
|
41
|
+
const id = idOf(r);
|
|
42
|
+
const method = r['method'];
|
|
43
|
+
if (typeof method !== 'string') {
|
|
44
|
+
return errorResponse(id, -32600, 'invalid request: method must be a string');
|
|
45
|
+
}
|
|
46
|
+
const params = r['params'] === undefined ? [] : r['params'];
|
|
47
|
+
if (!Array.isArray(params)) {
|
|
48
|
+
return errorResponse(id, -32602, `${method}: params must be an array`);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const result = await route(method, params);
|
|
52
|
+
return { jsonrpc: '2.0', id, result };
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
return errorResponse(id, ...asJsonRpcError(err));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const route = async (method, params) => {
|
|
59
|
+
switch (method) {
|
|
60
|
+
case 'eth_accounts':
|
|
61
|
+
case 'eth_requestAccounts': {
|
|
62
|
+
// Locked table or missing portal → empty list, not an error: tools
|
|
63
|
+
// poll this to display state, and an empty list is the truthful
|
|
64
|
+
// answer to "which accounts can you sign for right now?".
|
|
65
|
+
const portal = ctx.handles.isUnlocked()
|
|
66
|
+
? ctx.handles.list().find((p) => p.handle === config.portal)
|
|
67
|
+
: undefined;
|
|
68
|
+
return portal ? [portal.address] : [];
|
|
69
|
+
}
|
|
70
|
+
case 'eth_signTransaction':
|
|
71
|
+
case 'eth_sendTransaction': {
|
|
72
|
+
const raw = params[0];
|
|
73
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
74
|
+
throw new FillParamsError(`${method}: params[0] must be a transaction object`);
|
|
75
|
+
}
|
|
76
|
+
const signed = await fillAndSign(raw);
|
|
77
|
+
if (method === 'eth_signTransaction')
|
|
78
|
+
return signed;
|
|
79
|
+
return await upstream.call('eth_sendRawTransaction', [signed]);
|
|
80
|
+
}
|
|
81
|
+
default: {
|
|
82
|
+
if (SIGNING_METHODS_NOT_SUPPORTED.has(method)) {
|
|
83
|
+
throw new RpcMethodError(-32601, `${method} is not served by the sigil rpc proxy — message/typed-data ` +
|
|
84
|
+
`signing is available through sigil's MCP tools with their own policy toggles`);
|
|
85
|
+
}
|
|
86
|
+
// Transparent pass-through. Re-issued as a fresh request built from
|
|
87
|
+
// {method, params} only — nothing else from the client survives.
|
|
88
|
+
return await upstream.call(method, params);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const fillAndSign = async (raw) => {
|
|
93
|
+
// Surface locked/missing-portal before any upstream round-trips.
|
|
94
|
+
if (!ctx.handles.isUnlocked()) {
|
|
95
|
+
throw new RpcMethodError(-32003, 'sigil is locked — run "sigil unlock" in a terminal to load keys');
|
|
96
|
+
}
|
|
97
|
+
const portal = ctx.handles.list().find((p) => p.handle === config.portal);
|
|
98
|
+
if (!portal) {
|
|
99
|
+
throw new RpcMethodError(-32000, `portal "${config.portal}" not found`);
|
|
100
|
+
}
|
|
101
|
+
const chainId = await getChainId();
|
|
102
|
+
const tx = await fillTransaction(raw, {
|
|
103
|
+
portalAddress: portal.address.toLowerCase(),
|
|
104
|
+
chainId,
|
|
105
|
+
upstream,
|
|
106
|
+
});
|
|
107
|
+
// The whole point: same dispatch as the MCP tools → same policy checks,
|
|
108
|
+
// same confirm gate, same audit entries. This surface adds no privilege.
|
|
109
|
+
const result = await dispatch('sigil_eth_sign_transaction', { portal: config.portal, tx }, ctx);
|
|
110
|
+
return result.signed;
|
|
111
|
+
};
|
|
112
|
+
const handler = (req, res) => {
|
|
113
|
+
void handleHttp(req, res).catch((err) => {
|
|
114
|
+
log({ event: 'rpc_internal_error', message: err.message });
|
|
115
|
+
if (!res.headersSent) {
|
|
116
|
+
replyJson(res, 500, errorResponse(null, -32603, 'internal error'));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
res.end();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
const handleHttp = async (req, res) => {
|
|
124
|
+
if (req.method !== 'POST') {
|
|
125
|
+
replyText(res, 405, 'method not allowed — POST JSON-RPC 2.0 only\n');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (!isLoopbackHost(req.headers.host)) {
|
|
129
|
+
log({ event: 'rpc_rejected', reason: 'non-loopback host header' });
|
|
130
|
+
replyText(res, 403, 'forbidden\n');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!isAuthorized(req.headers.authorization, tokenDigest)) {
|
|
134
|
+
log({ event: 'rpc_rejected', reason: 'missing or invalid token' });
|
|
135
|
+
replyText(res, 401, 'unauthorized — supply the [rpc] token via Bearer or Basic auth\n');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
let body;
|
|
139
|
+
try {
|
|
140
|
+
body = await readBody(req, MAX_BODY_BYTES);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
replyText(res, 413, 'payload too large\n');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let parsed;
|
|
147
|
+
try {
|
|
148
|
+
parsed = JSON.parse(body.toString('utf8'));
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
replyJson(res, 200, errorResponse(null, -32700, 'parse error: body is not valid JSON'));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(parsed)) {
|
|
155
|
+
if (parsed.length === 0) {
|
|
156
|
+
replyJson(res, 200, errorResponse(null, -32600, 'invalid request: empty batch'));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const responses = await Promise.all(parsed.map(handleOne));
|
|
160
|
+
replyJson(res, 200, responses.filter((r) => r !== null));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const response = await handleOne(parsed);
|
|
164
|
+
replyJson(res, 200, response);
|
|
165
|
+
};
|
|
166
|
+
const server = createServer(handler);
|
|
167
|
+
const port = opts.port ?? config.port ?? DEFAULT_RPC_PORT;
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
server.once('error', reject);
|
|
170
|
+
server.listen(port, '127.0.0.1', () => {
|
|
171
|
+
server.removeListener('error', reject);
|
|
172
|
+
const addr = server.address();
|
|
173
|
+
const url = `http://127.0.0.1:${addr.port}`;
|
|
174
|
+
log({ event: 'rpc_listening', url, portal: config.portal });
|
|
175
|
+
resolve({
|
|
176
|
+
url,
|
|
177
|
+
port: addr.port,
|
|
178
|
+
close: () => new Promise((res2, rej2) => {
|
|
179
|
+
server.close((err) => (err ? rej2(err) : res2()));
|
|
180
|
+
}),
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
// ---------------------------------------------------------------------------
|
|
186
|
+
// Auth
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
function sha256(s) {
|
|
189
|
+
return createHash('sha256').update(s, 'utf8').digest();
|
|
190
|
+
}
|
|
191
|
+
/** Constant-time token check against the config token's digest. Hashing both
|
|
192
|
+
* sides makes timingSafeEqual applicable to attacker-chosen lengths. */
|
|
193
|
+
function tokenMatches(candidate, tokenDigest) {
|
|
194
|
+
return timingSafeEqual(sha256(candidate), tokenDigest);
|
|
195
|
+
}
|
|
196
|
+
function isAuthorized(header, tokenDigest) {
|
|
197
|
+
if (typeof header !== 'string')
|
|
198
|
+
return false;
|
|
199
|
+
const space = header.indexOf(' ');
|
|
200
|
+
if (space < 0)
|
|
201
|
+
return false;
|
|
202
|
+
const scheme = header.slice(0, space).toLowerCase();
|
|
203
|
+
const rest = header.slice(space + 1).trim();
|
|
204
|
+
if (scheme === 'bearer') {
|
|
205
|
+
return tokenMatches(rest, tokenDigest);
|
|
206
|
+
}
|
|
207
|
+
if (scheme === 'basic') {
|
|
208
|
+
let decoded;
|
|
209
|
+
try {
|
|
210
|
+
decoded = Buffer.from(rest, 'base64').toString('utf8');
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
// The password half carries the token; the username is ignored, so both
|
|
216
|
+
// http://sigil:TOKEN@… and http://:TOKEN@… work.
|
|
217
|
+
const colon = decoded.indexOf(':');
|
|
218
|
+
if (colon < 0)
|
|
219
|
+
return false;
|
|
220
|
+
return tokenMatches(decoded.slice(colon + 1), tokenDigest);
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
// DNS-rebinding defence
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
function isLoopbackHost(host) {
|
|
228
|
+
if (typeof host !== 'string' || host.length === 0)
|
|
229
|
+
return false;
|
|
230
|
+
let hostname;
|
|
231
|
+
try {
|
|
232
|
+
hostname = new URL(`http://${host}`).hostname;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
// WHATWG URL keeps the brackets on IPv6 hostnames ("[::1]"); strip them
|
|
238
|
+
// so the comparison sees the bare address.
|
|
239
|
+
const h = hostname.replace(/^\[|\]$/g, '').toLowerCase();
|
|
240
|
+
return h === '127.0.0.1' || h === 'localhost' || h === '::1';
|
|
241
|
+
}
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
// Plumbing
|
|
244
|
+
// ---------------------------------------------------------------------------
|
|
245
|
+
function readBody(req, maxBytes) {
|
|
246
|
+
return new Promise((resolve, reject) => {
|
|
247
|
+
const chunks = [];
|
|
248
|
+
let total = 0;
|
|
249
|
+
req.on('data', (chunk) => {
|
|
250
|
+
total += chunk.length;
|
|
251
|
+
if (total > maxBytes) {
|
|
252
|
+
req.destroy();
|
|
253
|
+
reject(new Error('body too large'));
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
chunks.push(chunk);
|
|
257
|
+
});
|
|
258
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
259
|
+
req.on('error', reject);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function idOf(r) {
|
|
263
|
+
const id = r['id'];
|
|
264
|
+
if (typeof id === 'string' || typeof id === 'number')
|
|
265
|
+
return id;
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
function errorResponse(id, code, message, data) {
|
|
269
|
+
return {
|
|
270
|
+
jsonrpc: '2.0',
|
|
271
|
+
id,
|
|
272
|
+
error: { code, message, ...(data !== undefined ? { data } : {}) },
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/** Map every failure class onto a JSON-RPC error tuple. */
|
|
276
|
+
function asJsonRpcError(err) {
|
|
277
|
+
if (err instanceof RpcMethodError) {
|
|
278
|
+
// Sigil's daemon codes are already JSON-RPC-shaped (-32xxx); policy
|
|
279
|
+
// denials, locked-daemon, invalid params all pass through unchanged.
|
|
280
|
+
return err.data !== undefined ? [err.code, err.message, err.data] : [err.code, err.message];
|
|
281
|
+
}
|
|
282
|
+
if (err instanceof FillParamsError) {
|
|
283
|
+
return [-32602, err.message];
|
|
284
|
+
}
|
|
285
|
+
if (err instanceof UpstreamRpcError) {
|
|
286
|
+
return err.data !== undefined ? [err.code, err.message, err.data] : [err.code, err.message];
|
|
287
|
+
}
|
|
288
|
+
if (err instanceof UpstreamTransportError) {
|
|
289
|
+
return [-32603, err.message];
|
|
290
|
+
}
|
|
291
|
+
return [-32603, `internal error: ${err.message}`];
|
|
292
|
+
}
|
|
293
|
+
function replyText(res, status, body) {
|
|
294
|
+
res.writeHead(status, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
295
|
+
res.end(body);
|
|
296
|
+
}
|
|
297
|
+
function replyJson(res, status, body) {
|
|
298
|
+
res.writeHead(status, { 'Content-Type': 'application/json' });
|
|
299
|
+
res.end(JSON.stringify(body));
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/rpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AAEjG,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,GAEvB,MAAM,eAAe,CAAC;AA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,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,CAAC,CAAC,KAAK,EAAE,mBAAoB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,SAAS,CAAC,GAAmB,EAAE,MAAc,EAAE,IAAY;IAClE,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,2BAA2B,EAAE,CAAC,CAAC;IACvE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,GAAmB,EAAE,MAAc,EAAE,IAAa;IACnE,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC9D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Just enough of fetch for a JSON-RPC POST. Injectable for tests. */
|
|
2
|
+
export type RpcFetchLike = (url: string, init: {
|
|
3
|
+
method: 'POST';
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
body: string;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
ok: boolean;
|
|
9
|
+
status: number;
|
|
10
|
+
json(): Promise<unknown>;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Minimal JSON-RPC 2.0 client for the upstream node the signing proxy
|
|
14
|
+
* forwards to. Deliberately tiny: one method, no batching, no subscriptions —
|
|
15
|
+
* the proxy re-issues each client request individually so nothing but a
|
|
16
|
+
* `{method, params}` pair we constructed ourselves ever reaches the upstream
|
|
17
|
+
* (no header or field smuggling from the proxy's clients).
|
|
18
|
+
*/
|
|
19
|
+
export interface JsonRpcUpstream {
|
|
20
|
+
call(method: string, params: readonly unknown[]): Promise<unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The upstream node answered with a JSON-RPC error object. Carries the
|
|
24
|
+
* node's code/message/data so the proxy can hand them back to its own client
|
|
25
|
+
* verbatim (forge's revert decoding depends on `data` surviving the trip).
|
|
26
|
+
*/
|
|
27
|
+
export declare class UpstreamRpcError extends Error {
|
|
28
|
+
readonly code: number;
|
|
29
|
+
readonly data: unknown;
|
|
30
|
+
constructor(code: number, message: string, data?: unknown);
|
|
31
|
+
}
|
|
32
|
+
/** Transport-level failure: unreachable, HTTP non-200, timeout, bad JSON. */
|
|
33
|
+
export declare class UpstreamTransportError extends Error {
|
|
34
|
+
readonly cause?: unknown;
|
|
35
|
+
constructor(message: string, cause?: unknown);
|
|
36
|
+
}
|
|
37
|
+
export interface HttpUpstreamOpts {
|
|
38
|
+
/** Per-call timeout. Default 30s — covers slow public RPC endpoints. */
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
/** Injectable for tests. Default: global fetch. */
|
|
41
|
+
fetchImpl?: RpcFetchLike;
|
|
42
|
+
}
|
|
43
|
+
export declare class HttpUpstream implements JsonRpcUpstream {
|
|
44
|
+
#private;
|
|
45
|
+
constructor(url: string, opts?: HttpUpstreamOpts);
|
|
46
|
+
call(method: string, params: readonly unknown[]): Promise<unknown>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=upstream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../../../src/rpc/upstream.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KACE,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpE;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBACX,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAM1D;AAED,6EAA6E;AAC7E,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK7C;AAED,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,qBAAa,YAAa,YAAW,eAAe;;gBAMtC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB;IAM9C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CA0CzE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The upstream node answered with a JSON-RPC error object. Carries the
|
|
3
|
+
* node's code/message/data so the proxy can hand them back to its own client
|
|
4
|
+
* verbatim (forge's revert decoding depends on `data` surviving the trip).
|
|
5
|
+
*/
|
|
6
|
+
export class UpstreamRpcError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
data;
|
|
9
|
+
constructor(code, message, data) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'UpstreamRpcError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.data = data;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Transport-level failure: unreachable, HTTP non-200, timeout, bad JSON. */
|
|
17
|
+
export class UpstreamTransportError extends Error {
|
|
18
|
+
cause;
|
|
19
|
+
constructor(message, cause) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'UpstreamTransportError';
|
|
22
|
+
if (cause !== undefined)
|
|
23
|
+
this.cause = cause;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class HttpUpstream {
|
|
27
|
+
#url;
|
|
28
|
+
#timeoutMs;
|
|
29
|
+
#fetch;
|
|
30
|
+
#nextId = 1;
|
|
31
|
+
constructor(url, opts = {}) {
|
|
32
|
+
this.#url = url;
|
|
33
|
+
this.#timeoutMs = opts.timeoutMs ?? 30_000;
|
|
34
|
+
this.#fetch = opts.fetchImpl ?? globalThis.fetch;
|
|
35
|
+
}
|
|
36
|
+
async call(method, params) {
|
|
37
|
+
let res;
|
|
38
|
+
try {
|
|
39
|
+
res = await this.#fetch(this.#url, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: { 'content-type': 'application/json' },
|
|
42
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: this.#nextId++, method, params }),
|
|
43
|
+
signal: AbortSignal.timeout(this.#timeoutMs),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
throw new UpstreamTransportError(`upstream RPC unreachable: ${err.message}`, err);
|
|
48
|
+
}
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
throw new UpstreamTransportError(`upstream RPC returned HTTP ${res.status}`);
|
|
51
|
+
}
|
|
52
|
+
let body;
|
|
53
|
+
try {
|
|
54
|
+
body = await res.json();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
throw new UpstreamTransportError('upstream RPC returned invalid JSON', err);
|
|
58
|
+
}
|
|
59
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
60
|
+
throw new UpstreamTransportError('upstream RPC returned a non-object response');
|
|
61
|
+
}
|
|
62
|
+
const obj = body;
|
|
63
|
+
const errObj = obj['error'];
|
|
64
|
+
if (errObj !== undefined && errObj !== null) {
|
|
65
|
+
if (typeof errObj === 'object' && !Array.isArray(errObj)) {
|
|
66
|
+
const e = errObj;
|
|
67
|
+
throw new UpstreamRpcError(typeof e['code'] === 'number' ? e['code'] : -32603, typeof e['message'] === 'string' ? e['message'] : 'upstream error', e['data']);
|
|
68
|
+
}
|
|
69
|
+
throw new UpstreamTransportError('upstream RPC returned a malformed error object');
|
|
70
|
+
}
|
|
71
|
+
return obj['result'];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=upstream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream.js","sourceRoot":"","sources":["../../../src/rpc/upstream.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAS;IACb,IAAI,CAAU;IACvB,YAAY,IAAY,EAAE,OAAe,EAAE,IAAc;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,6EAA6E;AAC7E,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7B,KAAK,CAAW;IAClC,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KA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