sigild 0.0.7 → 0.0.9
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 +80 -27
- package/THREAT_MODEL.md +6 -4
- package/dist/src/audit/log.d.ts +1 -1
- package/dist/src/audit/log.js +1 -1
- package/dist/src/bin/sigil-mcp.js +60 -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 +35 -9
- 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 +14 -1
- package/dist/src/cli/portal.d.ts.map +1 -1
- package/dist/src/cli/portal.js +31 -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 +54 -0
- package/dist/src/confirm/config.d.ts.map +1 -0
- package/dist/src/confirm/config.js +139 -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 +6 -2
- 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.d.ts +10 -0
- package/dist/src/control/server.d.ts.map +1 -1
- package/dist/src/control/server.js +60 -7
- package/dist/src/control/server.js.map +1 -1
- package/dist/src/daemon/handles.d.ts +5 -2
- package/dist/src/daemon/handles.d.ts.map +1 -1
- package/dist/src/daemon/handles.js +11 -3
- 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/eth/secp.d.ts.map +1 -1
- package/dist/src/eth/secp.js +6 -2
- package/dist/src/eth/secp.js.map +1 -1
- package/dist/src/hooks/command-scanner.d.ts.map +1 -1
- package/dist/src/hooks/command-scanner.js +57 -13
- package/dist/src/hooks/command-scanner.js.map +1 -1
- package/dist/src/hooks/glob.js +1 -1
- package/dist/src/hooks/glob.js.map +1 -1
- package/dist/src/hooks/path-blocker.d.ts.map +1 -1
- package/dist/src/hooks/path-blocker.js +1 -8
- package/dist/src/hooks/path-blocker.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 +10 -4
- package/dist/src/policy/evaluate.d.ts.map +1 -1
- package/dist/src/policy/evaluate.js +161 -20
- 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 +70 -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 +30 -0
- package/dist/src/policy/template.js.map +1 -1
- package/dist/src/policy/types.d.ts +53 -3
- package/dist/src/policy/types.d.ts.map +1 -1
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/qr/encode.d.ts +36 -0
- package/dist/src/qr/encode.d.ts.map +1 -0
- package/dist/src/qr/encode.js +44 -0
- package/dist/src/qr/encode.js.map +1 -0
- package/dist/src/qr/index.d.ts +3 -0
- package/dist/src/qr/index.d.ts.map +1 -0
- package/dist/src/qr/index.js +3 -0
- package/dist/src/qr/index.js.map +1 -0
- package/dist/src/qr/render.d.ts +34 -0
- package/dist/src/qr/render.d.ts.map +1 -0
- package/dist/src/qr/render.js +43 -0
- package/dist/src/qr/render.js.map +1 -0
- 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 +4 -2
|
@@ -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,MAA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,CAC/E,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;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# 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,ogGAwE3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEjD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEvD"}
|
|
@@ -62,6 +62,36 @@ allow_message_signing = false
|
|
|
62
62
|
# OpenSea orders, gasless approvals). Treat with the same care as signing
|
|
63
63
|
# transactions. Set true to permit.
|
|
64
64
|
allow_typed_data = false
|
|
65
|
+
|
|
66
|
+
# Optional: above this wei amount, sigil pushes a notification to your
|
|
67
|
+
# phone and waits for an explicit approve/deny tap before signing. Must be
|
|
68
|
+
# strictly less than max_value_wei. Requires a [confirm.ntfy] block in
|
|
69
|
+
# ~/.sigil/config.toml; without one, sigil-mcp refuses to start.
|
|
70
|
+
# Example: confirm anything above 0.01 ETH.
|
|
71
|
+
# require_confirm_above_wei = "10000000000000000"
|
|
72
|
+
|
|
73
|
+
# --- Solana (SVM) ----------------------------------------------------------
|
|
74
|
+
# The same key also controls a Solana (ed25519) address — see its base58 in
|
|
75
|
+
# "sigil portal list". These rules gate signing with it.
|
|
76
|
+
|
|
77
|
+
# Sign arbitrary off-chain ed25519 messages (e.g. Sign-In With Solana).
|
|
78
|
+
allow_svm_message_signing = false
|
|
79
|
+
|
|
80
|
+
# Allowed recipients for native SOL transfers (base58). Empty = none.
|
|
81
|
+
# sigil only decodes System-Program SOL transfers offline; any Solana tx it
|
|
82
|
+
# can't fully decode (SPL tokens, program calls, address-lookup-table
|
|
83
|
+
# accounts) is routed to the confirm gate instead of auto-allowed.
|
|
84
|
+
# Example: svm_allow_to = ["So11111111111111111111111111111111111111112"]
|
|
85
|
+
svm_allow_to = []
|
|
86
|
+
|
|
87
|
+
# Per-tx cap on total transferred lamports (1 SOL = 1000000000). Default 0 =
|
|
88
|
+
# no SOL transfers allowed. Quoted to stay clear of TOML int limits.
|
|
89
|
+
svm_max_lamports = "0"
|
|
90
|
+
|
|
91
|
+
# Optional: above this lamport total — OR for any tx sigil can't fully decode
|
|
92
|
+
# — push a confirm to your phone. Must be strictly less than svm_max_lamports.
|
|
93
|
+
# Example: confirm anything above 0.1 SOL.
|
|
94
|
+
# require_confirm_above_lamports = "100000000"
|
|
65
95
|
`;
|
|
66
96
|
export function policyTemplate(mode) {
|
|
67
97
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwE9B,CAAC;AAIF,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,OAAO,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,eAAe,CAAC;AACvE,CAAC"}
|
|
@@ -26,6 +26,33 @@ export interface Policy {
|
|
|
26
26
|
allowedSelectors: readonly string[];
|
|
27
27
|
allowMessageSigning: boolean;
|
|
28
28
|
allowTypedData: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If set, transactions whose value exceeds this threshold require an
|
|
31
|
+
* out-of-band human confirmation before signing. Independent of mode:
|
|
32
|
+
* applies in both permissive and strict. `undefined` = no confirm gate.
|
|
33
|
+
* A value > maxValueWei in strict mode would never trigger (the deny
|
|
34
|
+
* fires first); validation catches that misconfiguration at load time.
|
|
35
|
+
*/
|
|
36
|
+
requireConfirmAboveWei?: bigint;
|
|
37
|
+
/** Allow signing arbitrary off-chain ed25519 messages with this key. */
|
|
38
|
+
allowSvmMessageSigning: boolean;
|
|
39
|
+
/** base58 recipient allowlist for native SOL transfers (strict). */
|
|
40
|
+
svmAllowTo: readonly string[];
|
|
41
|
+
/** Per-transaction cap on total transferred lamports (strict). 0 = none. */
|
|
42
|
+
svmMaxLamports: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* If set, a Solana tx whose total transferred lamports exceeds this — OR
|
|
45
|
+
* whose instructions can't all be decoded offline — requires an out-of-band
|
|
46
|
+
* confirm. Mode-independent for the value threshold; the undecodable-tx
|
|
47
|
+
* confirm only applies in strict mode (permissive allows them outright).
|
|
48
|
+
*/
|
|
49
|
+
requireConfirmAboveLamports?: bigint;
|
|
50
|
+
}
|
|
51
|
+
/** A native SOL transfer the evaluator was handed, pre-decoded by the caller. */
|
|
52
|
+
export interface SvmTransferView {
|
|
53
|
+
/** base58 recipient. */
|
|
54
|
+
to: string;
|
|
55
|
+
lamports: bigint;
|
|
29
56
|
}
|
|
30
57
|
/** What the evaluator gets asked about. */
|
|
31
58
|
export type PolicyRequest = {
|
|
@@ -37,13 +64,36 @@ export type PolicyRequest = {
|
|
|
37
64
|
} | {
|
|
38
65
|
kind: 'typed_data';
|
|
39
66
|
typedData: TypedData;
|
|
67
|
+
} | {
|
|
68
|
+
kind: 'svm_message';
|
|
69
|
+
messageBytes: Buffer;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'svm_transaction';
|
|
72
|
+
/** Decoded native SOL transfers (may be a subset if allDecoded is false). */
|
|
73
|
+
transfers: readonly SvmTransferView[];
|
|
74
|
+
/** True iff every instruction decoded to a recognized System transfer. */
|
|
75
|
+
allDecoded: boolean;
|
|
76
|
+
/** Total instruction count, for the confirm summary. */
|
|
77
|
+
instructionCount: number;
|
|
40
78
|
};
|
|
41
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Evaluator output. Three arms, discriminated by `kind`:
|
|
81
|
+
* - 'allow': sign without further checks.
|
|
82
|
+
* - 'deny': hard reject with a human-readable, audit-loggable reason.
|
|
83
|
+
* - 'confirm': static checks all passed, but the policy says this request
|
|
84
|
+
* needs an out-of-band human ack before signing. The caller (sign
|
|
85
|
+
* methods) gates on the confirm transport before proceeding. `summary`
|
|
86
|
+
* is the one-line description shown to the user in the push
|
|
87
|
+
* notification — keep it tight ("0.5 ETH → 0xabc…").
|
|
88
|
+
*/
|
|
42
89
|
export type PolicyDecision = {
|
|
43
|
-
|
|
90
|
+
kind: 'allow';
|
|
44
91
|
} | {
|
|
45
|
-
|
|
92
|
+
kind: 'deny';
|
|
46
93
|
reason: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'confirm';
|
|
96
|
+
summary: string;
|
|
47
97
|
};
|
|
48
98
|
/**
|
|
49
99
|
* 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;;;;;;;;;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AgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;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":"AA2GA,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,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code encoder — thin adapter over `qrcode-generator` (Kazuhiko Arase's
|
|
3
|
+
* reference implementation, pinned at exact version, zero transitive deps).
|
|
4
|
+
*
|
|
5
|
+
* Defaults to byte mode so the input string is preserved verbatim,
|
|
6
|
+
* including case. The earlier alphanumeric-mode-only API uppercased
|
|
7
|
+
* everything, which broke wallets that validate ETH addresses against
|
|
8
|
+
* EIP-55 (lowercase `0x` prefix; mixed-case checksum).
|
|
9
|
+
*
|
|
10
|
+
* For pure-uppercase / pure-numeric payloads, alphanumeric mode is
|
|
11
|
+
* denser; opt in via the `mode` option.
|
|
12
|
+
*/
|
|
13
|
+
export type QrMode = 'Byte' | 'Alphanumeric';
|
|
14
|
+
export interface QrEncodeOpts {
|
|
15
|
+
/**
|
|
16
|
+
* Force a specific version (1–40). If omitted, the library picks the
|
|
17
|
+
* smallest fitting version for the input.
|
|
18
|
+
*/
|
|
19
|
+
version?: number;
|
|
20
|
+
/**
|
|
21
|
+
* QR encoding mode. Defaults to `'Byte'` (case-preserving, works for
|
|
22
|
+
* any UTF-8 string). `'Alphanumeric'` is denser but only supports
|
|
23
|
+
* digits, uppercase A–Z, space, and `$%*+-./:`.
|
|
24
|
+
*/
|
|
25
|
+
mode?: QrMode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Encode a string into a QR bit matrix at error-correction level L.
|
|
29
|
+
*
|
|
30
|
+
* In byte mode (the default) any input is accepted as-is. In alphanumeric
|
|
31
|
+
* mode we validate up front rather than letting the library silently
|
|
32
|
+
* fall back to byte mode, so callers who asked for the denser encoding
|
|
33
|
+
* get a clear error if their input doesn't qualify.
|
|
34
|
+
*/
|
|
35
|
+
export declare function encode(input: string, opts?: QrEncodeOpts): boolean[][];
|
|
36
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/qr/encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,cAAc,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,EAAE,EAAE,CAiB1E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code encoder — thin adapter over `qrcode-generator` (Kazuhiko Arase's
|
|
3
|
+
* reference implementation, pinned at exact version, zero transitive deps).
|
|
4
|
+
*
|
|
5
|
+
* Defaults to byte mode so the input string is preserved verbatim,
|
|
6
|
+
* including case. The earlier alphanumeric-mode-only API uppercased
|
|
7
|
+
* everything, which broke wallets that validate ETH addresses against
|
|
8
|
+
* EIP-55 (lowercase `0x` prefix; mixed-case checksum).
|
|
9
|
+
*
|
|
10
|
+
* For pure-uppercase / pure-numeric payloads, alphanumeric mode is
|
|
11
|
+
* denser; opt in via the `mode` option.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire as _createRequire } from "module";
|
|
14
|
+
const __require = _createRequire(import.meta.url);
|
|
15
|
+
const qrcode = __require("qrcode-generator");
|
|
16
|
+
const ALPHANUMERIC_RE = /^[0-9A-Z $%*+\-./:]*$/;
|
|
17
|
+
/**
|
|
18
|
+
* Encode a string into a QR bit matrix at error-correction level L.
|
|
19
|
+
*
|
|
20
|
+
* In byte mode (the default) any input is accepted as-is. In alphanumeric
|
|
21
|
+
* mode we validate up front rather than letting the library silently
|
|
22
|
+
* fall back to byte mode, so callers who asked for the denser encoding
|
|
23
|
+
* get a clear error if their input doesn't qualify.
|
|
24
|
+
*/
|
|
25
|
+
export function encode(input, opts = {}) {
|
|
26
|
+
const mode = opts.mode ?? 'Byte';
|
|
27
|
+
if (mode === 'Alphanumeric' && !ALPHANUMERIC_RE.test(input)) {
|
|
28
|
+
throw new Error(`qr: input contains chars outside the alphanumeric set: ${JSON.stringify(input)}`);
|
|
29
|
+
}
|
|
30
|
+
const typeNumber = (opts.version ?? 0);
|
|
31
|
+
const qr = qrcode(typeNumber, 'L');
|
|
32
|
+
qr.addData(input, mode);
|
|
33
|
+
qr.make();
|
|
34
|
+
const size = qr.getModuleCount();
|
|
35
|
+
const matrix = [];
|
|
36
|
+
for (let r = 0; r < size; r++) {
|
|
37
|
+
const row = [];
|
|
38
|
+
for (let c = 0; c < size; c++)
|
|
39
|
+
row.push(qr.isDark(r, c));
|
|
40
|
+
matrix.push(row);
|
|
41
|
+
}
|
|
42
|
+
return matrix;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=encode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../../../src/qr/encode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;AAEH,6CAA4C;AAE5C,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAkBhD;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,OAAqB,EAAE;IAC3D,MAAM,IAAI,GAAW,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC;IACzC,IAAI,IAAI,KAAK,cAAc,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,0DAA0D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAiC,CAAC;IACvE,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACnC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxB,EAAE,CAAC,IAAI,EAAE,CAAC;IACV,MAAM,IAAI,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAc,EAAE,CAAC;QAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/qr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/qr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkC,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a QR bit matrix as terminal text.
|
|
3
|
+
*
|
|
4
|
+
* Each QR module becomes `██` (two full-block chars wide × one line tall).
|
|
5
|
+
* Monospace terminal cells are ~1:2 (width:height), so 2 chars wide × 1
|
|
6
|
+
* line tall lands at roughly square — the shape a phone camera expects.
|
|
7
|
+
*
|
|
8
|
+
* We deliberately avoid the half-block trick (`▀ ▄ █`) because it requires
|
|
9
|
+
* the terminal to render line spacing such that `▀` aligns flush with the
|
|
10
|
+
* `▄` below — Warp, iTerm with custom fonts, and tmux all add sub-pixel
|
|
11
|
+
* gaps that produce non-square modules and break scanner lock.
|
|
12
|
+
*
|
|
13
|
+
* We also deliberately avoid ANSI background colours: themed terminals
|
|
14
|
+
* (Warp's default theme, low-contrast iTerm themes) render `[40m` /
|
|
15
|
+
* `[47m` at insufficient contrast for a phone camera. Plain block chars
|
|
16
|
+
* inherit the terminal's natural fg/bg contrast.
|
|
17
|
+
*
|
|
18
|
+
* On a dark-theme terminal this renders as light-on-dark (inverted
|
|
19
|
+
* polarity); on a light theme, dark-on-light. Phone scanners accept
|
|
20
|
+
* either polarity. A 4-module quiet zone (ISO/IEC 18004 §6.3) is added
|
|
21
|
+
* so scanners reliably locate the finder patterns.
|
|
22
|
+
*/
|
|
23
|
+
export interface RenderOpts {
|
|
24
|
+
/** Modules of light padding around the matrix (default 4 — the QR spec minimum). */
|
|
25
|
+
quietZone?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function renderTerminal(matrix: boolean[][], opts?: RenderOpts): string;
|
|
28
|
+
/**
|
|
29
|
+
* Alias for {@link renderTerminal}. Kept for callers that imported the
|
|
30
|
+
* old name; renderTerminal is now also pure ASCII / Unicode block chars
|
|
31
|
+
* with no ANSI dependency.
|
|
32
|
+
*/
|
|
33
|
+
export declare const renderAscii: typeof renderTerminal;
|
|
34
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/qr/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,UAAU;IACzB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,GAAE,UAAe,GAAG,MAAM,CAajF;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,uBAAiB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a QR bit matrix as terminal text.
|
|
3
|
+
*
|
|
4
|
+
* Each QR module becomes `██` (two full-block chars wide × one line tall).
|
|
5
|
+
* Monospace terminal cells are ~1:2 (width:height), so 2 chars wide × 1
|
|
6
|
+
* line tall lands at roughly square — the shape a phone camera expects.
|
|
7
|
+
*
|
|
8
|
+
* We deliberately avoid the half-block trick (`▀ ▄ █`) because it requires
|
|
9
|
+
* the terminal to render line spacing such that `▀` aligns flush with the
|
|
10
|
+
* `▄` below — Warp, iTerm with custom fonts, and tmux all add sub-pixel
|
|
11
|
+
* gaps that produce non-square modules and break scanner lock.
|
|
12
|
+
*
|
|
13
|
+
* We also deliberately avoid ANSI background colours: themed terminals
|
|
14
|
+
* (Warp's default theme, low-contrast iTerm themes) render `[40m` /
|
|
15
|
+
* `[47m` at insufficient contrast for a phone camera. Plain block chars
|
|
16
|
+
* inherit the terminal's natural fg/bg contrast.
|
|
17
|
+
*
|
|
18
|
+
* On a dark-theme terminal this renders as light-on-dark (inverted
|
|
19
|
+
* polarity); on a light theme, dark-on-light. Phone scanners accept
|
|
20
|
+
* either polarity. A 4-module quiet zone (ISO/IEC 18004 §6.3) is added
|
|
21
|
+
* so scanners reliably locate the finder patterns.
|
|
22
|
+
*/
|
|
23
|
+
export function renderTerminal(matrix, opts = {}) {
|
|
24
|
+
const quiet = opts.quietZone ?? 4;
|
|
25
|
+
const size = matrix.length;
|
|
26
|
+
const out = [];
|
|
27
|
+
for (let r = -quiet; r < size + quiet; r++) {
|
|
28
|
+
let line = '';
|
|
29
|
+
for (let c = -quiet; c < size + quiet; c++) {
|
|
30
|
+
const dark = r >= 0 && r < size && c >= 0 && c < size && matrix[r][c];
|
|
31
|
+
line += dark ? '██' : ' ';
|
|
32
|
+
}
|
|
33
|
+
out.push(line);
|
|
34
|
+
}
|
|
35
|
+
return out.join('\n') + '\n';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Alias for {@link renderTerminal}. Kept for callers that imported the
|
|
39
|
+
* old name; renderTerminal is now also pure ASCII / Unicode block chars
|
|
40
|
+
* with no ANSI dependency.
|
|
41
|
+
*/
|
|
42
|
+
export const renderAscii = renderTerminal;
|
|
43
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/qr/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,OAAmB,EAAE;IACvE,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAC;YACxE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7B,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC"}
|
|
@@ -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,KA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AC,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;QAC9B,GAAG,KAAK,EAAE,CAAC;IACb,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG;QAAE,KAAK,EAAE,CAAC;IAEzD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/C,0EAA0E;IAC1E,KAAK,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"}
|