sigild 0.0.8 → 0.0.10
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 +77 -22
- package/THREAT_MODEL.md +7 -5
- package/dist/src/bin/sigil-mcp.js +59 -16
- package/dist/src/bin/sigil-mcp.js.map +1 -1
- package/dist/src/cli/index.d.ts +2 -2
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/main.d.ts.map +1 -1
- package/dist/src/cli/main.js +10 -8
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/cli/paths.d.ts +15 -5
- package/dist/src/cli/paths.d.ts.map +1 -1
- package/dist/src/cli/paths.js +11 -1
- package/dist/src/cli/paths.js.map +1 -1
- package/dist/src/cli/portal.d.ts +3 -0
- package/dist/src/cli/portal.d.ts.map +1 -1
- package/dist/src/cli/portal.js +7 -1
- package/dist/src/cli/portal.js.map +1 -1
- package/dist/src/cli/status.d.ts +15 -12
- package/dist/src/cli/status.d.ts.map +1 -1
- package/dist/src/cli/status.js +17 -30
- package/dist/src/cli/status.js.map +1 -1
- package/dist/src/cli/unlock.d.ts +15 -15
- package/dist/src/cli/unlock.d.ts.map +1 -1
- package/dist/src/cli/unlock.js +83 -60
- package/dist/src/cli/unlock.js.map +1 -1
- package/dist/src/confirm/ack-server.d.ts +53 -0
- package/dist/src/confirm/ack-server.d.ts.map +1 -0
- package/dist/src/confirm/ack-server.js +87 -0
- package/dist/src/confirm/ack-server.js.map +1 -0
- package/dist/src/confirm/config.d.ts +56 -0
- package/dist/src/confirm/config.d.ts.map +1 -0
- package/dist/src/confirm/config.js +143 -0
- package/dist/src/confirm/config.js.map +1 -0
- package/dist/src/confirm/gate.d.ts +38 -0
- package/dist/src/confirm/gate.d.ts.map +1 -0
- package/dist/src/confirm/gate.js +66 -0
- package/dist/src/confirm/gate.js.map +1 -0
- package/dist/src/confirm/index.d.ts +6 -0
- package/dist/src/confirm/index.d.ts.map +1 -0
- package/dist/src/confirm/index.js +5 -0
- package/dist/src/confirm/index.js.map +1 -0
- package/dist/src/confirm/ntfy.d.ts +38 -0
- package/dist/src/confirm/ntfy.d.ts.map +1 -0
- package/dist/src/confirm/ntfy.js +47 -0
- package/dist/src/confirm/ntfy.js.map +1 -0
- package/dist/src/confirm/types.d.ts +66 -0
- package/dist/src/confirm/types.d.ts.map +1 -0
- package/dist/src/confirm/types.js +12 -0
- package/dist/src/confirm/types.js.map +1 -0
- package/dist/src/control/broadcast.d.ts +29 -0
- package/dist/src/control/broadcast.d.ts.map +1 -0
- package/dist/src/control/broadcast.js +88 -0
- package/dist/src/control/broadcast.js.map +1 -0
- package/dist/src/control/client.d.ts.map +1 -1
- package/dist/src/control/client.js +4 -1
- package/dist/src/control/client.js.map +1 -1
- package/dist/src/control/index.d.ts +1 -0
- package/dist/src/control/index.d.ts.map +1 -1
- package/dist/src/control/index.js +1 -0
- package/dist/src/control/index.js.map +1 -1
- package/dist/src/control/protocol.d.ts +5 -1
- package/dist/src/control/protocol.d.ts.map +1 -1
- package/dist/src/control/protocol.js +2 -1
- package/dist/src/control/protocol.js.map +1 -1
- package/dist/src/control/server.js +6 -6
- package/dist/src/control/server.js.map +1 -1
- package/dist/src/daemon/handles.d.ts +3 -0
- package/dist/src/daemon/handles.d.ts.map +1 -1
- package/dist/src/daemon/handles.js +3 -1
- package/dist/src/daemon/handles.js.map +1 -1
- package/dist/src/daemon/methods.d.ts +13 -3
- package/dist/src/daemon/methods.d.ts.map +1 -1
- package/dist/src/daemon/methods.js +121 -16
- package/dist/src/daemon/methods.js.map +1 -1
- package/dist/src/mcp/server.d.ts +14 -2
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +28 -14
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools.d.ts +1 -1
- package/dist/src/mcp/tools.d.ts.map +1 -1
- package/dist/src/mcp/tools.js +38 -4
- package/dist/src/mcp/tools.js.map +1 -1
- package/dist/src/policy/evaluate.d.ts +12 -4
- package/dist/src/policy/evaluate.d.ts.map +1 -1
- package/dist/src/policy/evaluate.js +189 -21
- package/dist/src/policy/evaluate.js.map +1 -1
- package/dist/src/policy/loader.d.ts.map +1 -1
- package/dist/src/policy/loader.js +74 -0
- package/dist/src/policy/loader.js.map +1 -1
- package/dist/src/policy/template.d.ts +1 -1
- package/dist/src/policy/template.d.ts.map +1 -1
- package/dist/src/policy/template.js +37 -0
- package/dist/src/policy/template.js.map +1 -1
- package/dist/src/policy/types.d.ts +62 -3
- package/dist/src/policy/types.d.ts.map +1 -1
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/svm/address.d.ts +14 -0
- package/dist/src/svm/address.d.ts.map +1 -0
- package/dist/src/svm/address.js +18 -0
- package/dist/src/svm/address.js.map +1 -0
- package/dist/src/svm/base58.d.ts +15 -0
- package/dist/src/svm/base58.d.ts.map +1 -0
- package/dist/src/svm/base58.js +60 -0
- package/dist/src/svm/base58.js.map +1 -0
- package/dist/src/svm/ed25519.d.ts +19 -0
- package/dist/src/svm/ed25519.d.ts.map +1 -0
- package/dist/src/svm/ed25519.js +32 -0
- package/dist/src/svm/ed25519.js.map +1 -0
- package/dist/src/svm/index.d.ts +5 -0
- package/dist/src/svm/index.d.ts.map +1 -0
- package/dist/src/svm/index.js +5 -0
- package/dist/src/svm/index.js.map +1 -0
- package/dist/src/svm/transaction.d.ts +56 -0
- package/dist/src/svm/transaction.d.ts.map +1 -0
- package/dist/src/svm/transaction.js +182 -0
- package/dist/src/svm/transaction.js.map +1 -0
- package/package.json +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import toml from '@iarna/toml';
|
|
4
|
+
import { base58Decode } from '../svm/index.js';
|
|
4
5
|
import { PolicyLoadError } from './types.js';
|
|
5
6
|
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
6
7
|
const SELECTOR_RE = /^0x[0-9a-fA-F]{8}$/;
|
|
@@ -30,6 +31,10 @@ export function parsePolicy(source) {
|
|
|
30
31
|
if (mode !== 'permissive' && mode !== 'strict') {
|
|
31
32
|
throw new PolicyLoadError(`policy.mode must be "permissive" or "strict" (got ${JSON.stringify(mode)})`);
|
|
32
33
|
}
|
|
34
|
+
// require_confirm_above_wei is mode-independent: it's an opt-in safety net
|
|
35
|
+
// that applies whether or not the rest of the file is strict.
|
|
36
|
+
const requireConfirmAboveWei = parseOptionalWei(raw['require_confirm_above_wei'], 'require_confirm_above_wei');
|
|
37
|
+
const requireConfirmAboveLamports = parseOptionalDec(raw['require_confirm_above_lamports'], 'require_confirm_above_lamports');
|
|
33
38
|
if (mode === 'permissive') {
|
|
34
39
|
return {
|
|
35
40
|
mode: 'permissive',
|
|
@@ -37,8 +42,14 @@ export function parsePolicy(source) {
|
|
|
37
42
|
allowTo: [],
|
|
38
43
|
maxValueWei: 0n,
|
|
39
44
|
allowedSelectors: [],
|
|
45
|
+
allowContractCreation: true,
|
|
40
46
|
allowMessageSigning: true,
|
|
41
47
|
allowTypedData: true,
|
|
48
|
+
allowSvmMessageSigning: true,
|
|
49
|
+
svmAllowTo: [],
|
|
50
|
+
svmMaxLamports: 0n,
|
|
51
|
+
...(requireConfirmAboveWei !== undefined ? { requireConfirmAboveWei } : {}),
|
|
52
|
+
...(requireConfirmAboveLamports !== undefined ? { requireConfirmAboveLamports } : {}),
|
|
42
53
|
};
|
|
43
54
|
}
|
|
44
55
|
// strict mode — every field is consulted; apply defaults for absent ones.
|
|
@@ -63,16 +74,56 @@ export function parsePolicy(source) {
|
|
|
63
74
|
}
|
|
64
75
|
return s.toLowerCase();
|
|
65
76
|
});
|
|
77
|
+
const allowContractCreation = asBool(raw['allow_contract_creation'], 'allow_contract_creation', false);
|
|
66
78
|
const allowMessageSigning = asBool(raw['allow_message_signing'], 'allow_message_signing', false);
|
|
67
79
|
const allowTypedData = asBool(raw['allow_typed_data'], 'allow_typed_data', false);
|
|
80
|
+
const allowSvmMessageSigning = asBool(raw['allow_svm_message_signing'], 'allow_svm_message_signing', false);
|
|
81
|
+
const svmAllowToRaw = asStringArray(raw['svm_allow_to'], 'svm_allow_to');
|
|
82
|
+
const svmAllowTo = svmAllowToRaw.map((s, i) => {
|
|
83
|
+
let decoded;
|
|
84
|
+
try {
|
|
85
|
+
decoded = base58Decode(s);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
throw new PolicyLoadError(`policy.svm_allow_to[${i}] is not valid base58: ${JSON.stringify(s)}`);
|
|
89
|
+
}
|
|
90
|
+
if (decoded.length !== 32) {
|
|
91
|
+
throw new PolicyLoadError(`policy.svm_allow_to[${i}] must decode to a 32-byte address (got ${decoded.length} bytes)`);
|
|
92
|
+
}
|
|
93
|
+
return s;
|
|
94
|
+
});
|
|
95
|
+
const svmMaxLamports = parseOptionalDec(raw['svm_max_lamports'], 'svm_max_lamports') ?? 0n;
|
|
96
|
+
// Catch the misconfiguration where the confirm threshold sits above the
|
|
97
|
+
// hard cap: nothing would ever trigger the confirm path, the deny would
|
|
98
|
+
// fire first. Easier to surface at load time than to wonder why your
|
|
99
|
+
// phone never buzzed.
|
|
100
|
+
if (requireConfirmAboveWei !== undefined &&
|
|
101
|
+
requireConfirmAboveWei >= maxValueWei &&
|
|
102
|
+
maxValueWei !== 0n) {
|
|
103
|
+
throw new PolicyLoadError(`policy.require_confirm_above_wei (${requireConfirmAboveWei}) must be less than ` +
|
|
104
|
+
`max_value_wei (${maxValueWei}) — otherwise the value cap fires first and the ` +
|
|
105
|
+
`confirm gate never triggers`);
|
|
106
|
+
}
|
|
107
|
+
if (requireConfirmAboveLamports !== undefined &&
|
|
108
|
+
requireConfirmAboveLamports >= svmMaxLamports &&
|
|
109
|
+
svmMaxLamports !== 0n) {
|
|
110
|
+
throw new PolicyLoadError(`policy.require_confirm_above_lamports (${requireConfirmAboveLamports}) must be less than ` +
|
|
111
|
+
`svm_max_lamports (${svmMaxLamports}) — otherwise the cap denies first and the confirm never triggers`);
|
|
112
|
+
}
|
|
68
113
|
return {
|
|
69
114
|
mode: 'strict',
|
|
70
115
|
chainIds,
|
|
71
116
|
allowTo,
|
|
72
117
|
maxValueWei,
|
|
73
118
|
allowedSelectors,
|
|
119
|
+
allowContractCreation,
|
|
74
120
|
allowMessageSigning,
|
|
75
121
|
allowTypedData,
|
|
122
|
+
allowSvmMessageSigning,
|
|
123
|
+
svmAllowTo,
|
|
124
|
+
svmMaxLamports,
|
|
125
|
+
...(requireConfirmAboveWei !== undefined ? { requireConfirmAboveWei } : {}),
|
|
126
|
+
...(requireConfirmAboveLamports !== undefined ? { requireConfirmAboveLamports } : {}),
|
|
76
127
|
};
|
|
77
128
|
}
|
|
78
129
|
/**
|
|
@@ -87,8 +138,12 @@ export function permissivePolicyResolver() {
|
|
|
87
138
|
allowTo: [],
|
|
88
139
|
maxValueWei: 0n,
|
|
89
140
|
allowedSelectors: [],
|
|
141
|
+
allowContractCreation: true,
|
|
90
142
|
allowMessageSigning: true,
|
|
91
143
|
allowTypedData: true,
|
|
144
|
+
allowSvmMessageSigning: true,
|
|
145
|
+
svmAllowTo: [],
|
|
146
|
+
svmMaxLamports: 0n,
|
|
92
147
|
};
|
|
93
148
|
return { resolve: () => policy };
|
|
94
149
|
}
|
|
@@ -167,4 +222,23 @@ function parseMaxValue(v) {
|
|
|
167
222
|
}
|
|
168
223
|
return BigInt(v);
|
|
169
224
|
}
|
|
225
|
+
function parseOptionalWei(v, name) {
|
|
226
|
+
return parseOptionalDec(v, name);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Parse an optional non-negative integer supplied as a decimal string (TOML
|
|
230
|
+
* int64 can't hold uint256 wei or, for safety, large lamport totals). Returns
|
|
231
|
+
* undefined when the field is absent.
|
|
232
|
+
*/
|
|
233
|
+
function parseOptionalDec(v, name) {
|
|
234
|
+
if (v === undefined)
|
|
235
|
+
return undefined;
|
|
236
|
+
if (typeof v !== 'string') {
|
|
237
|
+
throw new PolicyLoadError(`policy.${name} must be a decimal string (e.g. "1000000000"); got ${typeof v}`);
|
|
238
|
+
}
|
|
239
|
+
if (!DEC_RE.test(v)) {
|
|
240
|
+
throw new PolicyLoadError(`policy.${name} must be a decimal integer string (got ${JSON.stringify(v)})`);
|
|
241
|
+
}
|
|
242
|
+
return BigInt(v);
|
|
243
|
+
}
|
|
170
244
|
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/policy/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAe,eAAe,EAAuB,MAAM,YAAY,CAAC;AAE/E,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,IAAI,GAAiB,CAAC;IACtB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,eAAe,CAAC,0BAA2B,GAAa,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;IACrF,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/C,MAAM,IAAI,eAAe,CAAC,qDAAqD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1G,CAAC;IAED,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC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AAC;QACpB,MAAM,IAAI,eAAe,CACvB,UAAU,IAAI,0CAA0C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* generally strip those.
|
|
5
5
|
*/
|
|
6
6
|
export declare const PERMISSIVE_TEMPLATE = "# sigil policy file \u2014 permissive mode (default)\n#\n# This portal will sign anything the agent asks for. Your private key is\n# still encrypted at rest and never enters Claude's context, but signing\n# authority is unbounded.\n#\n# To restrict what this portal can sign, run:\n#\n# sigil portal remove <handle>\n# sigil portal add <handle> --key-file <path> --strict\n#\n# ...and edit the resulting policy file. Or just change \"permissive\" below\n# to \"strict\" and add the rules in the commented template at:\n# https://github.com/cdrn/sigil#policy-engine\n\nmode = \"permissive\"\n";
|
|
7
|
-
export declare const STRICT_TEMPLATE = "# sigil policy file \u2014 strict mode\n#\n# Every sign request is checked against the rules below before the key is\n# used. Edit the values to fit your portal. Anything you leave at the\n# default-zero/empty state will deny.\n\nmode = \"strict\"\n\n# Allowed chain IDs (decimal). At least one is required.\n# 1 = ethereum mainnet\n# 8453 = base\n# 42161 = arbitrum one\n# 10 = optimism\n# 11155111 = sepolia testnet\nchain_ids = [1]\n\n# Allowed destination addresses (lowercase 0x-prefixed). Empty = no tx allowed.\n# Example:\n# allow_to = [\"0x000000000000000000000000000000000000dead\"]\nallow_to = []\n\n# Per-tx value cap in wei. Default 0 = no ETH sends allowed at all.\n# 0.1 ether = \"100000000000000000\"\n# 1 ether = \"1000000000000000000\"\n# Quoted because uint256 doesn't fit in a TOML integer.\nmax_value_wei = \"0\"\n\n# 4-byte function selectors that are callable. Empty = pure ETH sends only.\n# Common selectors:\n# \"0xa9059cbb\" ERC-20 transfer(address,uint256)\n# \"0x095ea7b3\" ERC-20 approve(address,uint256)\n# \"0x23b872dd\" ERC-20 transferFrom(address,address,uint256)\nallowed_selectors = []\n\n# EIP-191 personal_sign \u2014 typically safe (used by Sign-In With Ethereum and\n# similar login flows). Set true to permit.\nallow_message_signing = false\n\n# EIP-712 typed data \u2014 CAN authorize off-chain financial actions (Permit,\n# OpenSea orders, gasless approvals). Treat with the same care as signing\n# transactions. Set true to permit.\nallow_typed_data = false\n";
|
|
7
|
+
export declare const STRICT_TEMPLATE = "# sigil policy file \u2014 strict mode\n#\n# Every sign request is checked against the rules below before the key is\n# used. Edit the values to fit your portal. Anything you leave at the\n# default-zero/empty state will deny.\n\nmode = \"strict\"\n\n# Allowed chain IDs (decimal). At least one is required.\n# 1 = ethereum mainnet\n# 8453 = base\n# 42161 = arbitrum one\n# 10 = optimism\n# 11155111 = sepolia testnet\nchain_ids = [1]\n\n# Allowed destination addresses (lowercase 0x-prefixed). Empty = no tx allowed.\n# Example:\n# allow_to = [\"0x000000000000000000000000000000000000dead\"]\nallow_to = []\n\n# Per-tx value cap in wei. Default 0 = no ETH sends allowed at all.\n# 0.1 ether = \"100000000000000000\"\n# 1 ether = \"1000000000000000000\"\n# Quoted because uint256 doesn't fit in a TOML integer.\nmax_value_wei = \"0\"\n\n# 4-byte function selectors that are callable. Empty = pure ETH sends only.\n# Common selectors:\n# \"0xa9059cbb\" ERC-20 transfer(address,uint256)\n# \"0x095ea7b3\" ERC-20 approve(address,uint256)\n# \"0x23b872dd\" ERC-20 transferFrom(address,address,uint256)\nallowed_selectors = []\n\n# Contract creation (deploys, to = null). Initcode is arbitrary code that no\n# allowlist can vet, so even when enabled every deploy still respects\n# max_value_wei and ALWAYS routes to the out-of-band confirm gate \u2014 a\n# [confirm.ntfy] block in ~/.sigil/config.toml is required, otherwise\n# sigil-mcp refuses to start.\nallow_contract_creation = false\n\n# EIP-191 personal_sign \u2014 typically safe (used by Sign-In With Ethereum and\n# similar login flows). Set true to permit.\nallow_message_signing = false\n\n# EIP-712 typed data \u2014 CAN authorize off-chain financial actions (Permit,\n# OpenSea orders, gasless approvals). Treat with the same care as signing\n# transactions. Set true to permit.\nallow_typed_data = false\n\n# Optional: above this wei amount, sigil pushes a notification to your\n# phone and waits for an explicit approve/deny tap before signing. Must be\n# strictly less than max_value_wei. Requires a [confirm.ntfy] block in\n# ~/.sigil/config.toml; without one, sigil-mcp refuses to start.\n# Example: confirm anything above 0.01 ETH.\n# require_confirm_above_wei = \"10000000000000000\"\n\n# --- Solana (SVM) ----------------------------------------------------------\n# The same key also controls a Solana (ed25519) address \u2014 see its base58 in\n# \"sigil portal list\". These rules gate signing with it.\n\n# Sign arbitrary off-chain ed25519 messages (e.g. Sign-In With Solana).\nallow_svm_message_signing = false\n\n# Allowed recipients for native SOL transfers (base58). Empty = none.\n# sigil only decodes System-Program SOL transfers offline; any Solana tx it\n# can't fully decode (SPL tokens, program calls, address-lookup-table\n# accounts) is routed to the confirm gate instead of auto-allowed.\n# Example: svm_allow_to = [\"So11111111111111111111111111111111111111112\"]\nsvm_allow_to = []\n\n# Per-tx cap on total transferred lamports (1 SOL = 1000000000). Default 0 =\n# no SOL transfers allowed. Quoted to stay clear of TOML int limits.\nsvm_max_lamports = \"0\"\n\n# Optional: above this lamport total \u2014 OR for any tx sigil can't fully decode\n# \u2014 push a confirm to your phone. Must be strictly less than svm_max_lamports.\n# Example: confirm anything above 0.1 SOL.\n# require_confirm_above_lamports = \"100000000\"\n";
|
|
8
8
|
export type PolicyMode = 'permissive' | 'strict';
|
|
9
9
|
export declare function policyTemplate(mode: PolicyMode): string;
|
|
10
10
|
//# sourceMappingURL=template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,mBAAmB,wlBAgB/B,CAAC;AAEF,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,mBAAmB,wlBAgB/B,CAAC;AAEF,eAAO,MAAM,eAAe,82GA+E3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEjD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEvD"}
|
|
@@ -54,6 +54,13 @@ max_value_wei = "0"
|
|
|
54
54
|
# "0x23b872dd" ERC-20 transferFrom(address,address,uint256)
|
|
55
55
|
allowed_selectors = []
|
|
56
56
|
|
|
57
|
+
# Contract creation (deploys, to = null). Initcode is arbitrary code that no
|
|
58
|
+
# allowlist can vet, so even when enabled every deploy still respects
|
|
59
|
+
# max_value_wei and ALWAYS routes to the out-of-band confirm gate — a
|
|
60
|
+
# [confirm.ntfy] block in ~/.sigil/config.toml is required, otherwise
|
|
61
|
+
# sigil-mcp refuses to start.
|
|
62
|
+
allow_contract_creation = false
|
|
63
|
+
|
|
57
64
|
# EIP-191 personal_sign — typically safe (used by Sign-In With Ethereum and
|
|
58
65
|
# similar login flows). Set true to permit.
|
|
59
66
|
allow_message_signing = false
|
|
@@ -62,6 +69,36 @@ allow_message_signing = false
|
|
|
62
69
|
# OpenSea orders, gasless approvals). Treat with the same care as signing
|
|
63
70
|
# transactions. Set true to permit.
|
|
64
71
|
allow_typed_data = false
|
|
72
|
+
|
|
73
|
+
# Optional: above this wei amount, sigil pushes a notification to your
|
|
74
|
+
# phone and waits for an explicit approve/deny tap before signing. Must be
|
|
75
|
+
# strictly less than max_value_wei. Requires a [confirm.ntfy] block in
|
|
76
|
+
# ~/.sigil/config.toml; without one, sigil-mcp refuses to start.
|
|
77
|
+
# Example: confirm anything above 0.01 ETH.
|
|
78
|
+
# require_confirm_above_wei = "10000000000000000"
|
|
79
|
+
|
|
80
|
+
# --- Solana (SVM) ----------------------------------------------------------
|
|
81
|
+
# The same key also controls a Solana (ed25519) address — see its base58 in
|
|
82
|
+
# "sigil portal list". These rules gate signing with it.
|
|
83
|
+
|
|
84
|
+
# Sign arbitrary off-chain ed25519 messages (e.g. Sign-In With Solana).
|
|
85
|
+
allow_svm_message_signing = false
|
|
86
|
+
|
|
87
|
+
# Allowed recipients for native SOL transfers (base58). Empty = none.
|
|
88
|
+
# sigil only decodes System-Program SOL transfers offline; any Solana tx it
|
|
89
|
+
# can't fully decode (SPL tokens, program calls, address-lookup-table
|
|
90
|
+
# accounts) is routed to the confirm gate instead of auto-allowed.
|
|
91
|
+
# Example: svm_allow_to = ["So11111111111111111111111111111111111111112"]
|
|
92
|
+
svm_allow_to = []
|
|
93
|
+
|
|
94
|
+
# Per-tx cap on total transferred lamports (1 SOL = 1000000000). Default 0 =
|
|
95
|
+
# no SOL transfers allowed. Quoted to stay clear of TOML int limits.
|
|
96
|
+
svm_max_lamports = "0"
|
|
97
|
+
|
|
98
|
+
# Optional: above this lamport total — OR for any tx sigil can't fully decode
|
|
99
|
+
# — push a confirm to your phone. Must be strictly less than svm_max_lamports.
|
|
100
|
+
# Example: confirm anything above 0.1 SOL.
|
|
101
|
+
# require_confirm_above_lamports = "100000000"
|
|
65
102
|
`;
|
|
66
103
|
export function policyTemplate(mode) {
|
|
67
104
|
return mode === 'permissive' ? PERMISSIVE_TEMPLATE : STRICT_TEMPLATE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;CAgBlC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;CAgBlC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+E9B,CAAC;AAIF,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,OAAO,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,eAAe,CAAC;AACvE,CAAC"}
|
|
@@ -24,8 +24,44 @@ export interface Policy {
|
|
|
24
24
|
maxValueWei: bigint;
|
|
25
25
|
/** 4-byte function selectors, lowercase 0x-prefixed, normalized at load time. */
|
|
26
26
|
allowedSelectors: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* Strict mode: permit contract-creation transactions (to: null). Initcode
|
|
29
|
+
* is arbitrary code that no allowlist can vet, so even when enabled every
|
|
30
|
+
* deploy is routed to the out-of-band confirm gate (a confirm transport
|
|
31
|
+
* must be configured or sigil-mcp refuses to start). Deploys still respect
|
|
32
|
+
* max_value_wei; allow_to and allowed_selectors don't apply to them.
|
|
33
|
+
* Permissive mode ignores this — deploys are already allowed there.
|
|
34
|
+
*/
|
|
35
|
+
allowContractCreation: boolean;
|
|
27
36
|
allowMessageSigning: boolean;
|
|
28
37
|
allowTypedData: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* If set, transactions whose value exceeds this threshold require an
|
|
40
|
+
* out-of-band human confirmation before signing. Independent of mode:
|
|
41
|
+
* applies in both permissive and strict. `undefined` = no confirm gate.
|
|
42
|
+
* A value > maxValueWei in strict mode would never trigger (the deny
|
|
43
|
+
* fires first); validation catches that misconfiguration at load time.
|
|
44
|
+
*/
|
|
45
|
+
requireConfirmAboveWei?: bigint;
|
|
46
|
+
/** Allow signing arbitrary off-chain ed25519 messages with this key. */
|
|
47
|
+
allowSvmMessageSigning: boolean;
|
|
48
|
+
/** base58 recipient allowlist for native SOL transfers (strict). */
|
|
49
|
+
svmAllowTo: readonly string[];
|
|
50
|
+
/** Per-transaction cap on total transferred lamports (strict). 0 = none. */
|
|
51
|
+
svmMaxLamports: bigint;
|
|
52
|
+
/**
|
|
53
|
+
* If set, a Solana tx whose total transferred lamports exceeds this — OR
|
|
54
|
+
* whose instructions can't all be decoded offline — requires an out-of-band
|
|
55
|
+
* confirm. Mode-independent for the value threshold; the undecodable-tx
|
|
56
|
+
* confirm only applies in strict mode (permissive allows them outright).
|
|
57
|
+
*/
|
|
58
|
+
requireConfirmAboveLamports?: bigint;
|
|
59
|
+
}
|
|
60
|
+
/** A native SOL transfer the evaluator was handed, pre-decoded by the caller. */
|
|
61
|
+
export interface SvmTransferView {
|
|
62
|
+
/** base58 recipient. */
|
|
63
|
+
to: string;
|
|
64
|
+
lamports: bigint;
|
|
29
65
|
}
|
|
30
66
|
/** What the evaluator gets asked about. */
|
|
31
67
|
export type PolicyRequest = {
|
|
@@ -37,13 +73,36 @@ export type PolicyRequest = {
|
|
|
37
73
|
} | {
|
|
38
74
|
kind: 'typed_data';
|
|
39
75
|
typedData: TypedData;
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'svm_message';
|
|
78
|
+
messageBytes: Buffer;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'svm_transaction';
|
|
81
|
+
/** Decoded native SOL transfers (may be a subset if allDecoded is false). */
|
|
82
|
+
transfers: readonly SvmTransferView[];
|
|
83
|
+
/** True iff every instruction decoded to a recognized System transfer. */
|
|
84
|
+
allDecoded: boolean;
|
|
85
|
+
/** Total instruction count, for the confirm summary. */
|
|
86
|
+
instructionCount: number;
|
|
40
87
|
};
|
|
41
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Evaluator output. Three arms, discriminated by `kind`:
|
|
90
|
+
* - 'allow': sign without further checks.
|
|
91
|
+
* - 'deny': hard reject with a human-readable, audit-loggable reason.
|
|
92
|
+
* - 'confirm': static checks all passed, but the policy says this request
|
|
93
|
+
* needs an out-of-band human ack before signing. The caller (sign
|
|
94
|
+
* methods) gates on the confirm transport before proceeding. `summary`
|
|
95
|
+
* is the one-line description shown to the user in the push
|
|
96
|
+
* notification — keep it tight ("0.5 ETH → 0xabc…").
|
|
97
|
+
*/
|
|
42
98
|
export type PolicyDecision = {
|
|
43
|
-
|
|
99
|
+
kind: 'allow';
|
|
44
100
|
} | {
|
|
45
|
-
|
|
101
|
+
kind: 'deny';
|
|
46
102
|
reason: string;
|
|
103
|
+
} | {
|
|
104
|
+
kind: 'confirm';
|
|
105
|
+
summary: string;
|
|
47
106
|
};
|
|
48
107
|
/**
|
|
49
108
|
* Resolves a portal handle to its current policy. Wrapped in an interface so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9B,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,gEAAgE;IAChE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9B,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,gEAAgE;IAChE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,iFAA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CAAE,GAChC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"AAoHA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtB,KAAK,CAAW;IAClC,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Solana address controlled by a portal's secret.
|
|
3
|
+
*
|
|
4
|
+
* A Solana address IS the base58 of the 32-byte ed25519 public key. We derive
|
|
5
|
+
* that key from the portal's raw 32-byte secret (the same bytes used as the
|
|
6
|
+
* secp256k1 key for EVM), so one portal controls both an `0x…` EVM address and
|
|
7
|
+
* a base58 Solana address — different strings, same secret.
|
|
8
|
+
*
|
|
9
|
+
* Note: this address will NOT match a Solana account derived from a seed
|
|
10
|
+
* phrase via BIP44 (m/44'/501'/0'/0'); it matches the "import private key"
|
|
11
|
+
* path in Phantom/Solflare, which uses the raw bytes as the ed25519 seed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function svmAddressFromSecret(secret: Buffer | Uint8Array): string;
|
|
14
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/svm/address.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAExE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { base58Encode } from './base58.js';
|
|
2
|
+
import { getPublicKey } from './ed25519.js';
|
|
3
|
+
/**
|
|
4
|
+
* The Solana address controlled by a portal's secret.
|
|
5
|
+
*
|
|
6
|
+
* A Solana address IS the base58 of the 32-byte ed25519 public key. We derive
|
|
7
|
+
* that key from the portal's raw 32-byte secret (the same bytes used as the
|
|
8
|
+
* secp256k1 key for EVM), so one portal controls both an `0x…` EVM address and
|
|
9
|
+
* a base58 Solana address — different strings, same secret.
|
|
10
|
+
*
|
|
11
|
+
* Note: this address will NOT match a Solana account derived from a seed
|
|
12
|
+
* phrase via BIP44 (m/44'/501'/0'/0'); it matches the "import private key"
|
|
13
|
+
* path in Phantom/Solflare, which uses the raw bytes as the ed25519 seed.
|
|
14
|
+
*/
|
|
15
|
+
export function svmAddressFromSecret(secret) {
|
|
16
|
+
return base58Encode(getPublicKey(secret));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/svm/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA2B;IAC9D,OAAO,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base58 (Bitcoin / Solana alphabet) encode + decode.
|
|
3
|
+
*
|
|
4
|
+
* Hand-rolled to keep sigil's dependency surface small (same posture as the
|
|
5
|
+
* hand-rolled keccak / RLP in src/eth). Inputs here are tiny — 32-byte
|
|
6
|
+
* addresses and 64-byte signatures — so the simple BigInt long-division
|
|
7
|
+
* implementation is more than fast enough; we don't need the byte-array
|
|
8
|
+
* division trick.
|
|
9
|
+
*
|
|
10
|
+
* Leading zero bytes map to leading '1' characters (and vice versa), which is
|
|
11
|
+
* what makes the all-zero 32-byte System Program key encode to 32 '1's.
|
|
12
|
+
*/
|
|
13
|
+
export declare function base58Encode(bytes: Uint8Array): string;
|
|
14
|
+
export declare function base58Decode(str: string): Uint8Array;
|
|
15
|
+
//# sourceMappingURL=base58.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../../src/svm/base58.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CActD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAsBpD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base58 (Bitcoin / Solana alphabet) encode + decode.
|
|
3
|
+
*
|
|
4
|
+
* Hand-rolled to keep sigil's dependency surface small (same posture as the
|
|
5
|
+
* hand-rolled keccak / RLP in src/eth). Inputs here are tiny — 32-byte
|
|
6
|
+
* addresses and 64-byte signatures — so the simple BigInt long-division
|
|
7
|
+
* implementation is more than fast enough; we don't need the byte-array
|
|
8
|
+
* division trick.
|
|
9
|
+
*
|
|
10
|
+
* Leading zero bytes map to leading '1' characters (and vice versa), which is
|
|
11
|
+
* what makes the all-zero 32-byte System Program key encode to 32 '1's.
|
|
12
|
+
*/
|
|
13
|
+
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
14
|
+
const BASE = 58n;
|
|
15
|
+
// Reverse lookup: char code -> digit value, -1 for non-alphabet chars.
|
|
16
|
+
const LOOKUP = (() => {
|
|
17
|
+
const t = new Int8Array(128).fill(-1);
|
|
18
|
+
for (let i = 0; i < ALPHABET.length; i++)
|
|
19
|
+
t[ALPHABET.charCodeAt(i)] = i;
|
|
20
|
+
return t;
|
|
21
|
+
})();
|
|
22
|
+
export function base58Encode(bytes) {
|
|
23
|
+
let zeros = 0;
|
|
24
|
+
while (zeros < bytes.length && bytes[zeros] === 0)
|
|
25
|
+
zeros++;
|
|
26
|
+
let num = 0n;
|
|
27
|
+
for (const b of bytes)
|
|
28
|
+
num = (num << 8n) + BigInt(b);
|
|
29
|
+
let out = '';
|
|
30
|
+
while (num > 0n) {
|
|
31
|
+
const rem = Number(num % BASE);
|
|
32
|
+
num /= BASE;
|
|
33
|
+
out = ALPHABET[rem] + out;
|
|
34
|
+
}
|
|
35
|
+
return '1'.repeat(zeros) + out;
|
|
36
|
+
}
|
|
37
|
+
export function base58Decode(str) {
|
|
38
|
+
let num = 0n;
|
|
39
|
+
for (let i = 0; i < str.length; i++) {
|
|
40
|
+
const code = str.charCodeAt(i);
|
|
41
|
+
const v = code < 128 ? LOOKUP[code] : -1;
|
|
42
|
+
if (v < 0)
|
|
43
|
+
throw new Error(`invalid base58 character ${JSON.stringify(str[i])} at index ${i}`);
|
|
44
|
+
num = num * BASE + BigInt(v);
|
|
45
|
+
}
|
|
46
|
+
const rev = [];
|
|
47
|
+
while (num > 0n) {
|
|
48
|
+
rev.push(Number(num & 0xffn));
|
|
49
|
+
num >>= 8n;
|
|
50
|
+
}
|
|
51
|
+
let zeros = 0;
|
|
52
|
+
while (zeros < str.length && str[zeros] === '1')
|
|
53
|
+
zeros++;
|
|
54
|
+
const out = new Uint8Array(zeros + rev.length);
|
|
55
|
+
// rev holds the big-endian body in reverse; copy it back after the zeros.
|
|
56
|
+
for (let i = 0; i < rev.length; i++)
|
|
57
|
+
out[zeros + i] = rev[rev.length - 1 - i];
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=base58.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base58.js","sourceRoot":"","sources":["../../../src/svm/base58.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,QAAQ,GAAG,4DAA4D,CAAC;AAC9E,MAAM,IAAI,GAAG,GAAG,CAAC;AAEjB,uEAAuE;AACvE,MAAM,MAAM,GAAc,CAAC,GAAG,EAAE;IAC9B,MAAM,CAAC,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,CAAC;IAE3D,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAErD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,OAAO,GAAG,GAAG,EAAE,EAAE,CAAC;QAChB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QAC/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IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;IAC/E,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the 32-byte ed25519 public key from a 32-byte seed.
|
|
3
|
+
*
|
|
4
|
+
* The "seed" is the portal's raw secret — the SAME 32 bytes that serve as the
|
|
5
|
+
* secp256k1 private key for EVM. ed25519 hashes the seed (clamped SHA-512) to
|
|
6
|
+
* get its actual signing scalar, so the ed25519 key is independent of the
|
|
7
|
+
* secp256k1 scalar even though both come from one secret. This is exactly the
|
|
8
|
+
* derivation Phantom/Solflare perform on "import private key", so the address
|
|
9
|
+
* this produces is recoverable there.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPublicKey(seed: Buffer | Uint8Array): Buffer;
|
|
12
|
+
/**
|
|
13
|
+
* Sign a message with the ed25519 key derived from `seed`. Returns the 64-byte
|
|
14
|
+
* detached signature (R ‖ S).
|
|
15
|
+
*/
|
|
16
|
+
export declare function sign(message: Buffer | Uint8Array, seed: Buffer | Uint8Array): Buffer;
|
|
17
|
+
/** Verify — used in tests and by callers that want to self-check a signature. */
|
|
18
|
+
export declare function verify(signature: Buffer | Uint8Array, message: Buffer | Uint8Array, publicKey: Buffer | Uint8Array): boolean;
|
|
19
|
+
//# sourceMappingURL=ed25519.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../../../src/svm/ed25519.ts"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAG9D;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAGpF;AAED,iFAAiF;AACjF,wBAAgB,MAAM,CACpB,SAAS,EAAE,MAAM,GAAG,UAAU,EAC9B,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,SAAS,EAAE,MAAM,GAAG,UAAU,GAC7B,OAAO,CAET"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as ed from '@noble/ed25519';
|
|
2
|
+
import { sha512 } from '@noble/hashes/sha2.js';
|
|
3
|
+
ed.hashes.sha512 = sha512;
|
|
4
|
+
/**
|
|
5
|
+
* Derive the 32-byte ed25519 public key from a 32-byte seed.
|
|
6
|
+
*
|
|
7
|
+
* The "seed" is the portal's raw secret — the SAME 32 bytes that serve as the
|
|
8
|
+
* secp256k1 private key for EVM. ed25519 hashes the seed (clamped SHA-512) to
|
|
9
|
+
* get its actual signing scalar, so the ed25519 key is independent of the
|
|
10
|
+
* secp256k1 scalar even though both come from one secret. This is exactly the
|
|
11
|
+
* derivation Phantom/Solflare perform on "import private key", so the address
|
|
12
|
+
* this produces is recoverable there.
|
|
13
|
+
*/
|
|
14
|
+
export function getPublicKey(seed) {
|
|
15
|
+
if (seed.length !== 32)
|
|
16
|
+
throw new Error(`ed25519 seed must be 32 bytes, got ${seed.length}`);
|
|
17
|
+
return Buffer.from(ed.getPublicKey(seed));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sign a message with the ed25519 key derived from `seed`. Returns the 64-byte
|
|
21
|
+
* detached signature (R ‖ S).
|
|
22
|
+
*/
|
|
23
|
+
export function sign(message, seed) {
|
|
24
|
+
if (seed.length !== 32)
|
|
25
|
+
throw new Error(`ed25519 seed must be 32 bytes, got ${seed.length}`);
|
|
26
|
+
return Buffer.from(ed.sign(message, seed));
|
|
27
|
+
}
|
|
28
|
+
/** Verify — used in tests and by callers that want to self-check a signature. */
|
|
29
|
+
export function verify(signature, message, publicKey) {
|
|
30
|
+
return ed.verify(signature, message, publicKey);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ed25519.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../../src/svm/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAS9C,EAAE,CAAC,MAAiB,CAAC,MAAM,GAAG,MAAqC,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,IAAyB;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7F,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,OAA4B,EAAE,IAAyB;IAC1E,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7F,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,MAAM,CACpB,SAA8B,EAC9B,OAA4B,EAC5B,SAA8B;IAE9B,OAAO,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { base58Encode, base58Decode } from './base58.js';
|
|
2
|
+
export { getPublicKey, sign, verify } from './ed25519.js';
|
|
3
|
+
export { svmAddressFromSecret } from './address.js';
|
|
4
|
+
export { type SolInstruction, type SolMessage, type SolTransfer, type DecodedTx, SYSTEM_PROGRAM_ID, parseMessage, decodeTx, } from './transaction.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/svm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,iBAAiB,EACjB,YAAY,EACZ,QAAQ,GACT,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { base58Encode, base58Decode } from './base58.js';
|
|
2
|
+
export { getPublicKey, sign, verify } from './ed25519.js';
|
|
3
|
+
export { svmAddressFromSecret } from './address.js';
|
|
4
|
+
export { SYSTEM_PROGRAM_ID, parseMessage, decodeTx, } from './transaction.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/svm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAKL,iBAAiB,EACjB,YAAY,EACZ,QAAQ,GACT,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Solana transaction-message parser + native-transfer decoder.
|
|
3
|
+
*
|
|
4
|
+
* sigil signs the serialized *message* a caller hands it (ed25519 over the
|
|
5
|
+
* bytes), but to apply policy it first decodes what it can offline. Solana
|
|
6
|
+
* hides most semantics behind account indices and on-chain state, so the only
|
|
7
|
+
* thing reliably decodable without RPC is the **System Program transfer**
|
|
8
|
+
* (native SOL). Everything else — SPL token transfers, arbitrary programs,
|
|
9
|
+
* accounts pulled in via address-lookup-tables — is left as "undecoded", and
|
|
10
|
+
* the policy layer routes those to an out-of-band human confirm.
|
|
11
|
+
*
|
|
12
|
+
* Supports both legacy and v0 (versioned) messages. For v0 we parse the
|
|
13
|
+
* address-table-lookup section to consume the bytes correctly, but any
|
|
14
|
+
* instruction that references an ALT-loaded account (index >= number of static
|
|
15
|
+
* keys) is treated as undecoded, since we can't resolve it offline.
|
|
16
|
+
*/
|
|
17
|
+
/** The System Program id is the all-zero 32-byte key. */
|
|
18
|
+
export declare const SYSTEM_PROGRAM_ID: Uint8Array;
|
|
19
|
+
export interface SolInstruction {
|
|
20
|
+
programIdIndex: number;
|
|
21
|
+
accountIndexes: number[];
|
|
22
|
+
data: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export interface SolMessage {
|
|
25
|
+
version: 'legacy' | 0;
|
|
26
|
+
numRequiredSignatures: number;
|
|
27
|
+
numReadonlySigned: number;
|
|
28
|
+
numReadonlyUnsigned: number;
|
|
29
|
+
/** The static account keys carried in the message (32 bytes each). */
|
|
30
|
+
staticAccountKeys: Uint8Array[];
|
|
31
|
+
recentBlockhash: Uint8Array;
|
|
32
|
+
instructions: SolInstruction[];
|
|
33
|
+
/** Number of address-table lookups (v0 only; 0 for legacy). */
|
|
34
|
+
addressTableLookupCount: number;
|
|
35
|
+
}
|
|
36
|
+
export interface SolTransfer {
|
|
37
|
+
/** base58 sender (the funding account). */
|
|
38
|
+
from: string;
|
|
39
|
+
/** base58 recipient. */
|
|
40
|
+
to: string;
|
|
41
|
+
lamports: bigint;
|
|
42
|
+
}
|
|
43
|
+
export interface DecodedTx {
|
|
44
|
+
message: SolMessage;
|
|
45
|
+
/** Recognized System-Program transfers, in instruction order. */
|
|
46
|
+
transfers: SolTransfer[];
|
|
47
|
+
/**
|
|
48
|
+
* True iff EVERY instruction in the message was decoded as a recognized
|
|
49
|
+
* System transfer over static accounts. When false, the message contains
|
|
50
|
+
* something we can't see offline and policy must route it to confirm.
|
|
51
|
+
*/
|
|
52
|
+
allDecoded: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function parseMessage(bytes: Uint8Array): SolMessage;
|
|
55
|
+
export declare function decodeTx(bytes: Uint8Array): DecodedTx;
|
|
56
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/svm/transaction.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,EAAE,UAA+B,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,QAAQ,GAAG,CAAC,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sEAAsE;IACtE,iBAAiB,EAAE,UAAU,EAAE,CAAC;IAChC,eAAe,EAAE,UAAU,CAAC;IAC5B,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,+DAA+D;IAC/D,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,UAAU,CAAC;IACpB,iEAAiE;IACjE,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAgDD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAgE1D;AAMD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAWrD"}
|