oneie 5.7.6 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +19 -1
  2. package/dist/package.json +7 -8
  3. package/dist/src/age-yefbe8pe.js +1 -0
  4. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  5. package/dist/src/hl-run-tgrkrk69.js +1 -0
  6. package/dist/src/index-0rj9wdk9.js +4 -0
  7. package/dist/src/index-91y484c2.js +2052 -0
  8. package/dist/src/index-940y3rnv.js +12 -0
  9. package/dist/src/index.js +1047 -121
  10. package/dist/src/message-key-db1xjdkw.js +1 -0
  11. package/dist/src/message-lock-5vr8079x.js +5 -0
  12. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  13. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  14. package/package.json +7 -8
  15. package/dist/src/agent.d.ts +0 -75
  16. package/dist/src/agent.js +0 -1334
  17. package/dist/src/agentverse.d.ts +0 -26
  18. package/dist/src/agentverse.js +0 -171
  19. package/dist/src/args.d.ts +0 -9
  20. package/dist/src/args.js +0 -61
  21. package/dist/src/auth.d.ts +0 -6
  22. package/dist/src/auth.js +0 -121
  23. package/dist/src/balances.d.ts +0 -89
  24. package/dist/src/balances.js +0 -202
  25. package/dist/src/banner.d.ts +0 -1
  26. package/dist/src/banner.js +0 -17
  27. package/dist/src/broadcast.d.ts +0 -8
  28. package/dist/src/broadcast.js +0 -175
  29. package/dist/src/catalog.d.ts +0 -12
  30. package/dist/src/catalog.js +0 -76
  31. package/dist/src/chat.d.ts +0 -2
  32. package/dist/src/chat.js +0 -92
  33. package/dist/src/client.d.ts +0 -5
  34. package/dist/src/client.js +0 -157
  35. package/dist/src/compiler.d.ts +0 -36
  36. package/dist/src/compiler.js +0 -366
  37. package/dist/src/config.d.ts +0 -24
  38. package/dist/src/config.js +0 -70
  39. package/dist/src/connect.d.ts +0 -2
  40. package/dist/src/connect.js +0 -64
  41. package/dist/src/coordinate.d.ts +0 -3
  42. package/dist/src/coordinate.js +0 -58
  43. package/dist/src/create.d.ts +0 -2
  44. package/dist/src/create.js +0 -113
  45. package/dist/src/deploy.d.ts +0 -2
  46. package/dist/src/deploy.js +0 -19
  47. package/dist/src/dev.d.ts +0 -2
  48. package/dist/src/dev.js +0 -75
  49. package/dist/src/device-flow.d.ts +0 -57
  50. package/dist/src/device-flow.js +0 -173
  51. package/dist/src/doctor.d.ts +0 -26
  52. package/dist/src/doctor.js +0 -146
  53. package/dist/src/draw.d.ts +0 -18
  54. package/dist/src/draw.js +0 -156
  55. package/dist/src/endpoint.d.ts +0 -2
  56. package/dist/src/endpoint.js +0 -250
  57. package/dist/src/env.d.ts +0 -3
  58. package/dist/src/env.js +0 -37
  59. package/dist/src/eval.d.ts +0 -2
  60. package/dist/src/eval.js +0 -43
  61. package/dist/src/fn.d.ts +0 -2
  62. package/dist/src/fn.js +0 -70
  63. package/dist/src/group.d.ts +0 -2
  64. package/dist/src/group.js +0 -117
  65. package/dist/src/hl-run.d.ts +0 -119
  66. package/dist/src/hl-run.js +0 -480
  67. package/dist/src/hl.d.ts +0 -17
  68. package/dist/src/hl.js +0 -148
  69. package/dist/src/index.d.ts +0 -2
  70. package/dist/src/init.d.ts +0 -76
  71. package/dist/src/init.js +0 -278
  72. package/dist/src/join.d.ts +0 -11
  73. package/dist/src/join.js +0 -293
  74. package/dist/src/key-publish.d.ts +0 -40
  75. package/dist/src/key-publish.js +0 -232
  76. package/dist/src/key-seal.d.ts +0 -21
  77. package/dist/src/key-seal.js +0 -142
  78. package/dist/src/key-sweep.d.ts +0 -93
  79. package/dist/src/key-sweep.js +0 -263
  80. package/dist/src/key.d.ts +0 -26
  81. package/dist/src/key.js +0 -338
  82. package/dist/src/lib/age-plugin.d.ts +0 -51
  83. package/dist/src/lib/age-plugin.js +0 -130
  84. package/dist/src/lib/agent-env.d.ts +0 -12
  85. package/dist/src/lib/agent-env.js +0 -48
  86. package/dist/src/lib/api-path.d.ts +0 -2
  87. package/dist/src/lib/api-path.js +0 -40
  88. package/dist/src/lib/asker.d.ts +0 -34
  89. package/dist/src/lib/asker.js +0 -126
  90. package/dist/src/lib/client.d.ts +0 -20
  91. package/dist/src/lib/client.js +0 -71
  92. package/dist/src/lib/env-sealed.d.ts +0 -53
  93. package/dist/src/lib/env-sealed.js +0 -184
  94. package/dist/src/lib/flow-tag.d.ts +0 -86
  95. package/dist/src/lib/flow-tag.js +0 -230
  96. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  97. package/dist/src/lib/hl-core/actions.js +0 -69
  98. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  99. package/dist/src/lib/hl-core/eip712.js +0 -107
  100. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  101. package/dist/src/lib/hl-core/errors.js +0 -15
  102. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  103. package/dist/src/lib/hl-core/exchange.js +0 -47
  104. package/dist/src/lib/hl-core/index.d.ts +0 -13
  105. package/dist/src/lib/hl-core/index.js +0 -14
  106. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  107. package/dist/src/lib/hl-core/meta.js +0 -110
  108. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  109. package/dist/src/lib/hl-core/msgpack.js +0 -136
  110. package/dist/src/lib/hl-core/net.d.ts +0 -2
  111. package/dist/src/lib/hl-core/net.js +0 -7
  112. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  113. package/dist/src/lib/hl-core/signing.js +0 -295
  114. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  115. package/dist/src/lib/hl-core/wire.js +0 -81
  116. package/dist/src/lib/invoked-as.d.ts +0 -2
  117. package/dist/src/lib/invoked-as.js +0 -24
  118. package/dist/src/lib/journey-words.d.ts +0 -84
  119. package/dist/src/lib/journey-words.js +0 -360
  120. package/dist/src/lib/journey.d.ts +0 -148
  121. package/dist/src/lib/journey.js +0 -245
  122. package/dist/src/lib/key-receipt.d.ts +0 -48
  123. package/dist/src/lib/key-receipt.js +0 -116
  124. package/dist/src/lib/key-source.d.ts +0 -9
  125. package/dist/src/lib/key-source.js +0 -33
  126. package/dist/src/lib/keyfile.d.ts +0 -136
  127. package/dist/src/lib/keyfile.js +0 -397
  128. package/dist/src/lib/launch-claude.d.ts +0 -5
  129. package/dist/src/lib/launch-claude.js +0 -45
  130. package/dist/src/lib/lock-lookup.d.ts +0 -40
  131. package/dist/src/lib/lock-lookup.js +0 -92
  132. package/dist/src/lib/message-seal.d.ts +0 -63
  133. package/dist/src/lib/message-seal.js +0 -150
  134. package/dist/src/lib/network.d.ts +0 -15
  135. package/dist/src/lib/network.js +0 -41
  136. package/dist/src/lib/paths.d.ts +0 -41
  137. package/dist/src/lib/paths.js +0 -91
  138. package/dist/src/lib/plan-draw.d.ts +0 -56
  139. package/dist/src/lib/plan-draw.js +0 -219
  140. package/dist/src/lib/plan-live.d.ts +0 -20
  141. package/dist/src/lib/plan-live.js +0 -192
  142. package/dist/src/lib/qr.d.ts +0 -21
  143. package/dist/src/lib/qr.js +0 -402
  144. package/dist/src/lib/roster.d.ts +0 -20
  145. package/dist/src/lib/roster.js +0 -79
  146. package/dist/src/lib/sale-card.d.ts +0 -117
  147. package/dist/src/lib/sale-card.js +0 -261
  148. package/dist/src/lib/shop-init.d.ts +0 -62
  149. package/dist/src/lib/shop-init.js +0 -63
  150. package/dist/src/lib/sui-grpc-send.d.ts +0 -50
  151. package/dist/src/lib/sui-grpc-send.js +0 -89
  152. package/dist/src/lib/swap-core.d.ts +0 -163
  153. package/dist/src/lib/swap-core.js +0 -405
  154. package/dist/src/lib/tasks-digest.d.ts +0 -66
  155. package/dist/src/lib/tasks-digest.js +0 -200
  156. package/dist/src/lib/tasks-graph.d.ts +0 -79
  157. package/dist/src/lib/tasks-graph.js +0 -463
  158. package/dist/src/lib/tasks-lens.d.ts +0 -31
  159. package/dist/src/lib/tasks-lens.js +0 -47
  160. package/dist/src/lib/tasks-next.d.ts +0 -25
  161. package/dist/src/lib/tasks-next.js +0 -103
  162. package/dist/src/lib/tasks-prove.d.ts +0 -15
  163. package/dist/src/lib/tasks-prove.js +0 -68
  164. package/dist/src/lib/tasks-route.d.ts +0 -29
  165. package/dist/src/lib/tasks-route.js +0 -151
  166. package/dist/src/lib/tasks-score.d.ts +0 -36
  167. package/dist/src/lib/tasks-score.js +0 -152
  168. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  169. package/dist/src/lib/tasks-workspace.js +0 -73
  170. package/dist/src/lib/vault-read.d.ts +0 -24
  171. package/dist/src/lib/vault-read.js +0 -77
  172. package/dist/src/lib/vaultfile.d.ts +0 -88
  173. package/dist/src/lib/vaultfile.js +0 -222
  174. package/dist/src/lib/wallet-money.d.ts +0 -222
  175. package/dist/src/lib/wallet-money.js +0 -578
  176. package/dist/src/lib/wallet-request.d.ts +0 -50
  177. package/dist/src/lib/wallet-request.js +0 -86
  178. package/dist/src/links.d.ts +0 -5
  179. package/dist/src/links.js +0 -45
  180. package/dist/src/media.d.ts +0 -29
  181. package/dist/src/media.js +0 -487
  182. package/dist/src/message-receipt.d.ts +0 -25
  183. package/dist/src/message-receipt.js +0 -71
  184. package/dist/src/message.d.ts +0 -13
  185. package/dist/src/message.js +0 -92
  186. package/dist/src/onboard.d.ts +0 -16
  187. package/dist/src/onboard.js +0 -149
  188. package/dist/src/plugin.d.ts +0 -2
  189. package/dist/src/plugin.js +0 -193
  190. package/dist/src/push.d.ts +0 -2
  191. package/dist/src/push.js +0 -115
  192. package/dist/src/render.d.ts +0 -21
  193. package/dist/src/render.js +0 -32
  194. package/dist/src/secrets-device.d.ts +0 -32
  195. package/dist/src/secrets-device.js +0 -127
  196. package/dist/src/secrets-give.d.ts +0 -125
  197. package/dist/src/secrets-give.js +0 -236
  198. package/dist/src/secrets-list.d.ts +0 -27
  199. package/dist/src/secrets-list.js +0 -84
  200. package/dist/src/secrets-run.d.ts +0 -31
  201. package/dist/src/secrets-run.js +0 -182
  202. package/dist/src/secrets.d.ts +0 -33
  203. package/dist/src/secrets.js +0 -200
  204. package/dist/src/setup.d.ts +0 -6
  205. package/dist/src/setup.js +0 -127
  206. package/dist/src/ship.d.ts +0 -2
  207. package/dist/src/ship.js +0 -18
  208. package/dist/src/shop.d.ts +0 -10
  209. package/dist/src/shop.js +0 -110
  210. package/dist/src/skill-parser.d.ts +0 -14
  211. package/dist/src/skill-parser.js +0 -113
  212. package/dist/src/skill.d.ts +0 -2
  213. package/dist/src/skill.js +0 -493
  214. package/dist/src/slug.d.ts +0 -2
  215. package/dist/src/slug.js +0 -6
  216. package/dist/src/social.d.ts +0 -2
  217. package/dist/src/social.js +0 -106
  218. package/dist/src/staff.d.ts +0 -2
  219. package/dist/src/staff.js +0 -104
  220. package/dist/src/start.d.ts +0 -15
  221. package/dist/src/start.js +0 -203
  222. package/dist/src/status.d.ts +0 -2
  223. package/dist/src/status.js +0 -52
  224. package/dist/src/substrate.d.ts +0 -2
  225. package/dist/src/substrate.js +0 -258
  226. package/dist/src/swap.d.ts +0 -93
  227. package/dist/src/swap.js +0 -622
  228. package/dist/src/tasks.d.ts +0 -2
  229. package/dist/src/tasks.js +0 -743
  230. package/dist/src/templates.d.ts +0 -1
  231. package/dist/src/templates.js +0 -213
  232. package/dist/src/trade.d.ts +0 -2
  233. package/dist/src/trade.js +0 -91
  234. package/dist/src/trail.d.ts +0 -2
  235. package/dist/src/trail.js +0 -41
  236. package/dist/src/validate.d.ts +0 -13
  237. package/dist/src/validate.js +0 -35
  238. package/dist/src/wallet-money.d.ts +0 -152
  239. package/dist/src/wallet-money.js +0 -564
  240. package/dist/src/wallet.d.ts +0 -167
  241. package/dist/src/wallet.js +0 -855
  242. package/dist/src/workflow.d.ts +0 -2
  243. package/dist/src/workflow.js +0 -166
  244. package/dist/src/write.d.ts +0 -43
  245. package/dist/src/write.js +0 -180
@@ -1,88 +0,0 @@
1
- /**
2
- * The sealed envelope, as far as THIS module is concerned.
3
- *
4
- * Deliberately a local structural type rather than an import of
5
- * `@oneie/sdk/vault-file`'s `VaultBlob`. Nothing here seals or opens anything —
6
- * it moves an opaque JSON object on and off disk and reads exactly three fields
7
- * of it. Importing the crypto module to borrow a type would drag Argon2id into
8
- * the dependency graph of a file that never derives a key, and would couple the
9
- * CLI's two-runtime-dep budget to a subpath that has to be linked before it
10
- * resolves. The full type lives with the code that actually uses it.
11
- */
12
- export interface SealedVault {
13
- v: 1;
14
- wrap: 'passphrase' | 'keychain';
15
- authPub?: string;
16
- [k: string]: unknown;
17
- }
18
- export declare const VAULT_FILE_NAME = "wallet.json";
19
- export interface VaultWriteResult {
20
- ok: boolean;
21
- path?: string;
22
- error?: string;
23
- }
24
- /** Where a project's vault lives. */
25
- export declare function vaultPath(dir: string): string;
26
- /**
27
- * Write the sealed vault. Ignore entry FIRST — same order, same reason as the
28
- * API key: a secret written before it is ignored is exposed for the width of the
29
- * gap, and the gap is where `git add -A` lives. Refuses rather than writing an
30
- * unignorable credential.
31
- */
32
- export declare function writeVaultFolder(dir: string, blob: SealedVault): VaultWriteResult;
33
- /** Read a sealed vault, or null when the folder has none. Never throws. */
34
- export declare function readVaultFolder(dir: string): SealedVault | null;
35
- /**
36
- * The Keychain service name a vault's wrapping secret is stored under.
37
- *
38
- * Scoped by the vault's public identity rather than a constant, so two projects
39
- * on one machine do not fight over one entry — and so deleting one wallet's
40
- * secret cannot silently unlock another's.
41
- */
42
- export declare function keychainService(authPub: string): string;
43
- export type KeychainResult = {
44
- ok: true;
45
- value?: string;
46
- } | {
47
- ok: false;
48
- error: string;
49
- };
50
- /** macOS only — every other platform gets a clear refusal, never a silent no-op. */
51
- export declare function keychainAvailable(): boolean;
52
- /**
53
- * Store the wrapping secret in Apple Keychain, gated by the user's login
54
- * keychain ACL.
55
- *
56
- * `-w` takes the secret on argv, which is normally the thing to avoid — argv is
57
- * world-readable in `ps`. It is accepted HERE because `security` offers no stdin
58
- * form for add-generic-password, and the exposure is a race against a local
59
- * process that could read the unlocked vault anyway. The mnemonic itself never
60
- * appears on argv; only this random wrapper does, and it is useless without the
61
- * file.
62
- */
63
- export declare function keychainStore(authPub: string, secret: string): KeychainResult;
64
- /** Read the wrapping secret back. This is the call that prompts for Touch ID. */
65
- export declare function keychainRead(authPub: string): KeychainResult;
66
- /**
67
- * The 24 words laid out for transcription, numbered.
68
- *
69
- * Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
70
- * words is trivially copied out of sequence — a wallet that restores to the
71
- * wrong addresses with no error. Pure, so it is testable without a wallet.
72
- *
73
- * The derivation is printed, and named in the restore command, because the words
74
- * carry no marker of their own: `wallet new --recover` with no `--derivation`
75
- * recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
76
- * `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
77
- * different, empty wallet with no error. The paper alone must carry what restore
78
- * needs, so the derivation is required here, not defaulted.
79
- *
80
- * `cli` is how the restore command is spelled (`one` or `npx oneie`, see
81
- * invoked-as.ts) so the line runs as printed. The restore line itself is a bare
82
- * command — nothing trailing — so it can be copied, and parsed by the test that
83
- * follows it back to the same addresses (tests/paper-restore.test.ts).
84
- */
85
- export declare function paperSheet(mnemonic: string, addresses: Record<string, string>, restore: {
86
- derivation: 'v1' | 'v2';
87
- cli: string;
88
- }): string;
@@ -1,222 +0,0 @@
1
- /**
2
- * vaultfile.ts — the encrypted wallet folder, and the three ways out of it.
3
- *
4
- * `.one/wallet.json` is a sealed 24-word mnemonic. From it `recoverWallet()`
5
- * derives all four chain keys offline, so the file IS the wallet: lose it and
6
- * the phrase and the money is gone; copy it and the copy is equally the wallet.
7
- * That is the property the three export paths below exist to serve.
8
- *
9
- * THE KEYS NEVER LEAVE THIS MACHINE unless the human deliberately moves them,
10
- * and there are exactly three doors:
11
- * · PAPER — the 24 words, printed once, offline forever.
12
- * · KEYCHAIN — Apple Keychain (or any OS keystore) holds the WRAPPING secret,
13
- * released by biometrics. The vault stays on disk.
14
- * · ADDRESSES — public only. `wallet register` uploads these to be paid at;
15
- * they are not key material and never were.
16
- * Nothing else is an export. In particular nothing here ever posts a mnemonic,
17
- * a private key, or a passphrase to a server — there is no code path for it.
18
- *
19
- * WHAT THE SECURE ENCLAVE ACTUALLY DOES, because the difference matters and is
20
- * easy to oversell: the SE holds NIST P-256 keys ONLY. It cannot hold the
21
- * ed25519 (Sui, Solana) or secp256k1 (EVM, BTC) keys this wallet is made of. So
22
- * "open and close it with your biometrics" is TRUE — Touch ID releases the
23
- * wrapping secret that decrypts the vault — while "your keys live in the Secure
24
- * Enclave" is FALSE. Once unlocked, the chain keys are in this process's memory
25
- * like any other program's. That is a real and useful boundary; it is not a
26
- * hardware signer, and the code says so where a reader will meet it.
27
- *
28
- * The write ceremony is `keyfile.ts`'s, reused rather than re-derived: ignore
29
- * entry before the file, 0700 directory, O_NOFOLLOW writes, symlink refusal.
30
- * A second implementation of that is a second thing to get wrong.
31
- */
32
- import { existsSync, readFileSync, lstatSync } from 'node:fs';
33
- import { join } from 'node:path';
34
- import { spawnSync } from 'node:child_process';
35
- import { ensureIgnored, KEY_DIR_NAME, LEGACY_KEY_DIR_NAME, writeSecret, canonicalDir } from './keyfile.js';
36
- export const VAULT_FILE_NAME = 'wallet.json';
37
- /** Where a project's vault lives. */
38
- export function vaultPath(dir) {
39
- const root = canonicalDir(dir);
40
- const current = join(root, KEY_DIR_NAME, VAULT_FILE_NAME);
41
- if (existsSync(current))
42
- return current;
43
- const legacy = join(root, LEGACY_KEY_DIR_NAME, VAULT_FILE_NAME);
44
- // A vault minted before the rename still opens. New ones are always written
45
- // to the current directory — vaultPath is used for BOTH, so the fallback only
46
- // wins when a legacy file is actually there.
47
- return existsSync(legacy) ? legacy : current;
48
- }
49
- /**
50
- * Write the sealed vault. Ignore entry FIRST — same order, same reason as the
51
- * API key: a secret written before it is ignored is exposed for the width of the
52
- * gap, and the gap is where `git add -A` lives. Refuses rather than writing an
53
- * unignorable credential.
54
- */
55
- export function writeVaultFolder(dir, blob) {
56
- const root = canonicalDir(dir);
57
- if (!existsSync(root))
58
- return { ok: false, error: `no such directory: ${root}` };
59
- if (!ensureIgnored(root)) {
60
- return { ok: false, error: 'could not write .gitignore — refusing to write a wallet git can see' };
61
- }
62
- const path = vaultPath(root);
63
- if (existsSync(path)) {
64
- // Overwriting a vault destroys a wallet. There is no undo and no backup,
65
- // so this refuses and makes the operator move the old one by hand.
66
- return { ok: false, error: `${path} already exists — move it aside first; overwriting destroys the wallet it holds` };
67
- }
68
- try {
69
- writeSecret(path, JSON.stringify(blob, null, 2) + '\n');
70
- return { ok: true, path };
71
- }
72
- catch (err) {
73
- return { ok: false, error: `write failed: ${err.message}` };
74
- }
75
- }
76
- /** Read a sealed vault, or null when the folder has none. Never throws. */
77
- export function readVaultFolder(dir) {
78
- const path = vaultPath(dir);
79
- if (!existsSync(path))
80
- return null;
81
- try {
82
- // lstat, not stat: a symlinked vault is refused rather than followed to a
83
- // file whose mode looks fine.
84
- const st = lstatSync(path);
85
- if (st.isSymbolicLink())
86
- return null;
87
- if ((st.mode & 0o077) !== 0)
88
- return null;
89
- const blob = JSON.parse(readFileSync(path, 'utf8'));
90
- return blob?.v === 1 ? blob : null;
91
- }
92
- catch {
93
- return null;
94
- }
95
- }
96
- // ─── Keychain ────────────────────────────────────────────────────────────────
97
- /**
98
- * The Keychain service name a vault's wrapping secret is stored under.
99
- *
100
- * Scoped by the vault's public identity rather than a constant, so two projects
101
- * on one machine do not fight over one entry — and so deleting one wallet's
102
- * secret cannot silently unlock another's.
103
- */
104
- export function keychainService(authPub) {
105
- return `one.ie.wallet.${authPub}`;
106
- }
107
- /** macOS only — every other platform gets a clear refusal, never a silent no-op. */
108
- export function keychainAvailable() {
109
- return process.platform === 'darwin' && spawnSync('which', ['security']).status === 0;
110
- }
111
- /**
112
- * Store the wrapping secret in Apple Keychain, gated by the user's login
113
- * keychain ACL.
114
- *
115
- * `-w` takes the secret on argv, which is normally the thing to avoid — argv is
116
- * world-readable in `ps`. It is accepted HERE because `security` offers no stdin
117
- * form for add-generic-password, and the exposure is a race against a local
118
- * process that could read the unlocked vault anyway. The mnemonic itself never
119
- * appears on argv; only this random wrapper does, and it is useless without the
120
- * file.
121
- */
122
- export function keychainStore(authPub, secret) {
123
- if (!keychainAvailable())
124
- return { ok: false, error: 'Keychain is macOS-only' };
125
- const r = spawnSync('security', [
126
- 'add-generic-password',
127
- '-a', process.env.USER ?? 'one',
128
- '-s', keychainService(authPub),
129
- '-w', secret,
130
- '-U',
131
- '-T', '', // no app is pre-trusted: every read prompts, which is the biometric gate
132
- ]);
133
- if (r.status !== 0) {
134
- return { ok: false, error: (r.stderr?.toString() || 'security add-generic-password failed').trim() };
135
- }
136
- return { ok: true };
137
- }
138
- /** Read the wrapping secret back. This is the call that prompts for Touch ID. */
139
- export function keychainRead(authPub) {
140
- if (!keychainAvailable())
141
- return { ok: false, error: 'Keychain is macOS-only' };
142
- const r = spawnSync('security', [
143
- 'find-generic-password',
144
- '-a', process.env.USER ?? 'one',
145
- '-s', keychainService(authPub),
146
- '-w',
147
- ]);
148
- if (r.status !== 0) {
149
- return { ok: false, error: 'no Keychain entry for this wallet (or access was denied)' };
150
- }
151
- return { ok: true, value: r.stdout.toString().trim() };
152
- }
153
- // ─── Paper ───────────────────────────────────────────────────────────────────
154
- /**
155
- * Where else the words open. Only v2 is BIP-39 at the standard paths, so only a v2
156
- * sheet may name other wallets — v1 is ONE's own scheme and opens an empty account
157
- * anywhere else. The wallet list is pinned against independent derivations at those
158
- * paths in one.ie/web/tests/unit/wallet/sheet-other-wallets.test.ts.
159
- */
160
- function otherWallets(restore) {
161
- if (restore.derivation === 'v2') {
162
- return [
163
- 'These words also open in: MetaMask (Ethereum), Phantom (Solana), Sui Wallet / Slush (Sui),',
164
- ' Sparrow or BlueWallet (Bitcoin, native SegWit), ASI Alliance Wallet (ASI).',
165
- ' The first account in each is the address above.',
166
- ];
167
- }
168
- return [
169
- `These words recover only with ONE tools (\`${restore.cli} wallet new --recover --derivation v1\``,
170
- ' or `npx @oneie/recover --derivation v1`) — not in other wallets.',
171
- ];
172
- }
173
- /**
174
- * The 24 words laid out for transcription, numbered.
175
- *
176
- * Numbered because BIP-39 order is load-bearing and an unnumbered column of 24
177
- * words is trivially copied out of sequence — a wallet that restores to the
178
- * wrong addresses with no error. Pure, so it is testable without a wallet.
179
- *
180
- * The derivation is printed, and named in the restore command, because the words
181
- * carry no marker of their own: `wallet new --recover` with no `--derivation`
182
- * recovers v1 (it must — a v1 key recovers its v1 addresses forever), while
183
- * `oneie init` mints v2. A sheet that omits it restores a v2 holder to a
184
- * different, empty wallet with no error. The paper alone must carry what restore
185
- * needs, so the derivation is required here, not defaulted.
186
- *
187
- * `cli` is how the restore command is spelled (`one` or `npx oneie`, see
188
- * invoked-as.ts) so the line runs as printed. The restore line itself is a bare
189
- * command — nothing trailing — so it can be copied, and parsed by the test that
190
- * follows it back to the same addresses (tests/paper-restore.test.ts).
191
- */
192
- export function paperSheet(mnemonic, addresses, restore) {
193
- const words = mnemonic.trim().split(/\s+/);
194
- const rows = [];
195
- const half = Math.ceil(words.length / 2);
196
- for (let i = 0; i < half; i++) {
197
- const l = `${String(i + 1).padStart(2, ' ')}. ${(words[i] ?? '').padEnd(10)}`;
198
- const j = i + half;
199
- const r = j < words.length ? `${String(j + 1).padStart(2, ' ')}. ${words[j]}` : '';
200
- rows.push(` ${l} ${r}`.trimEnd());
201
- }
202
- return [
203
- 'ONE — wallet recovery sheet',
204
- '',
205
- 'These 24 words ARE the wallet. Anyone who reads them owns it.',
206
- 'Write them down in this order. Store the paper offline.',
207
- '',
208
- ...rows,
209
- '',
210
- 'Receiving addresses (public — safe to share, this is how you get paid):',
211
- ...Object.entries(addresses).map(([chain, addr]) => ` ${chain.padEnd(5)} ${addr}`),
212
- '',
213
- `Derivation: ${restore.derivation} (restore MUST name it — without it the same words open a different, empty wallet)`,
214
- ...otherWallets(restore),
215
- '',
216
- `Restore with: ${restore.cli} wallet new --recover --derivation ${restore.derivation}`,
217
- ' The words go in ONE_WALLET_MNEMONIC, set without echo first:',
218
- ' read -rs ONE_WALLET_MNEMONIC && export ONE_WALLET_MNEMONIC',
219
- ' Never on the command line — argv lands in shell history and in `ps`.',
220
- `Offline, no ONE server: npx @oneie/recover --derivation ${restore.derivation}`,
221
- ].join('\n');
222
- }
@@ -1,222 +0,0 @@
1
- /**
2
- * wallet-money.ts — the pure half of `one wallet balances | receive | send | request`:
3
- * the chain table, the words a person types, the reads, which chain a bare `USDC`
4
- * means, the plan a send would sign, and the client check (R16) run before it does.
5
- *
6
- * Every chain read takes `Fetch` as an argument (tests hand in a fake; the command
7
- * hands in a fetch with a deadline). A read that fails is null, never 0.
8
- * Nothing here opens a vault or holds a key.
9
- */
10
- import { type BalanceRow, type Fetch, type HlRead } from '../balances.js';
11
- export type Net = 'mainnet' | 'testnet';
12
- export type EvmChain = 'ethereum' | 'base' | 'arbitrum';
13
- export type SendChain = EvmChain | 'sui';
14
- export type SendAsset = 'ETH' | 'USDC' | 'SUI';
15
- export type Obj = Record<string, unknown>;
16
- export interface EvmNet {
17
- chainId: number;
18
- rpc: string;
19
- usdc: string;
20
- explorer: string;
21
- label: string;
22
- }
23
- /** The three EVM chains on each network. Testnet USDC contracts read back `symbol() = USDC` (2026-11-09). */
24
- export declare const EVM: Record<EvmChain, Record<Net, EvmNet>>;
25
- export declare const EVM_CHAIN_NAMES: readonly EvmChain[];
26
- /** Sui's public JSON-RPC answers "deprecated" on mainnet and testnet (measured 2026-11-09); GraphQL is the public read. */
27
- export declare const SUI: Record<Net, {
28
- graphql: string;
29
- usdc: string;
30
- explorer: string;
31
- label: string;
32
- }>;
33
- export declare const SUI_NATIVE = "0x2::sui::SUI";
34
- export declare const DECIMALS: Record<SendAsset, number>;
35
- export declare function parseNet(v: unknown): Net | null;
36
- /** "0.5" → base units; anything that is not a plain positive decimal within `decimals` places → null. */
37
- export declare function parseAmount(input: string, decimals: number): bigint | null;
38
- export type AssetWord = {
39
- ok: true;
40
- asset: SendAsset;
41
- chain?: SendChain;
42
- } | {
43
- ok: false;
44
- error: string;
45
- message: string;
46
- };
47
- /** `ETH` · `USDC@base` · `SUI` — the asset and, when named, the chain. */
48
- export declare function parseAssetWord(word: string): AssetWord;
49
- /** The chains a bare asset could mean, in a fixed order. */
50
- export declare function candidateChains(asset: SendAsset): SendChain[];
51
- export declare const familyOf: (chain: SendChain) => "evm" | "sui";
52
- export declare const chainLabel: (chain: SendChain, net: Net) => string;
53
- export declare function addressShape(addr: string): 'evm' | 'sui' | null;
54
- export declare function evmRpc(f: Fetch, rpc: string, method: string, params: unknown[]): Promise<string>;
55
- export declare function readEvmAsset(f: Fetch, chain: EvmChain, net: Net, asset: 'ETH' | 'USDC', address: string): Promise<bigint | null>;
56
- /** A coin balance on Sui via GraphQL; an address that never held the coin answers a null balance — a real zero. */
57
- export declare function readSuiCoin(f: Fetch, net: Net, address: string, coinType: string): Promise<bigint | null>;
58
- export declare function readAsset(f: Fetch, asset: SendAsset, chain: SendChain, net: Net, address: string): Promise<bigint | null>;
59
- /** SOL in lamports from a public Solana node (testnet = devnet, where ONE's test money lives). */
60
- export declare const SOL_RPC: Record<Net, string>;
61
- export declare function readSol(f: Fetch, net: Net, address: string): Promise<bigint | null>;
62
- /** BTC in satoshis from mempool.space: confirmed + unconfirmed, funded minus spent. */
63
- export declare const BTC_API: Record<Net, string>;
64
- export declare function readBtc(f: Fetch, net: Net, address: string): Promise<bigint | null>;
65
- export interface Addresses {
66
- evm?: string;
67
- sui?: string;
68
- solana?: string;
69
- btc?: string;
70
- }
71
- export type MoneyRow = BalanceRow & {
72
- source: 'wallet:get' | 'chain';
73
- };
74
- export interface MoneyBalances {
75
- ok: true;
76
- network: Net;
77
- addresses: Addresses;
78
- rows: MoneyRow[];
79
- hyperliquid?: HlRead;
80
- note: string;
81
- }
82
- /** What a server-given address must look like before it is used, printed or pasted anywhere. */
83
- export declare const ADDRESS_SHAPE: Record<'evm' | 'sui' | 'solana' | 'btc', RegExp>;
84
- /** wallet:get's rows for one actor → the addresses it holds. A row whose address is not its chain's shape is dropped. */
85
- export declare function addressesFor(walletGet: Obj, actor: string): Addresses;
86
- /**
87
- * Every balance of one actor on ONE network. A wallet:get row is used only when it says
88
- * it was read on the network asked (a server that ignores `net` answers the deploy's —
89
- * production's is testnet — and such a row is dropped, never shown under the wrong label).
90
- * What wallet:get does not read — USDC everywhere, ETH on Base and Arbitrum, USDT on
91
- * mainnet, and SOL/BTC when the server gave no row — is read from the chains here.
92
- */
93
- export declare function moneyBalances(args: {
94
- walletGet: Obj | null;
95
- actor: string;
96
- addresses: Addresses;
97
- net: Net;
98
- }, f: Fetch, hlRead?: (address: string) => Promise<HlRead>): Promise<MoneyBalances>;
99
- export declare function moneyLines(r: MoneyBalances): string[];
100
- export type ReceiveChain = EvmChain | 'sui' | 'solana' | 'bitcoin';
101
- export type ReceivePlan = {
102
- ok: true;
103
- chain: ReceiveChain;
104
- network: Net;
105
- address: string;
106
- uri: string;
107
- label: string;
108
- accepts: string;
109
- warning: string;
110
- } | {
111
- ok: false;
112
- error: string;
113
- message: string;
114
- options?: string[];
115
- };
116
- /** Which chains these addresses can receive on — the list a refusal names. */
117
- export declare function receivableChains(a: Addresses): ReceiveChain[];
118
- /** One chain, one address, one QR payload. No chain = refused: one 0x address is three chains. */
119
- export declare function receivePlan(chainWord: string | undefined, a: Addresses, net: Net): ReceivePlan;
120
- /** wallet:invoice takes cents: USD or USDC, at most 2 decimals. Anything else is refused by name. */
121
- export declare function invoiceCents(amount: string, asset: string): {
122
- ok: true;
123
- cents: number;
124
- } | {
125
- ok: false;
126
- error: string;
127
- message: string;
128
- };
129
- export interface EvmTxFields {
130
- chainId: number;
131
- nonce: bigint;
132
- maxPriorityFeePerGas: bigint;
133
- maxFeePerGas: bigint;
134
- gasLimit: bigint;
135
- to: string;
136
- value: bigint;
137
- data: string;
138
- }
139
- export interface SendPlan {
140
- network: Net;
141
- chain: SendChain;
142
- chainLabel: string;
143
- asset: SendAsset;
144
- amount: string;
145
- amountUnits: bigint;
146
- from: string;
147
- to: string;
148
- /** How `to` was found: typed (an address in argv), or resolved from a name. */
149
- toSource: 'typed' | 'wallet:get' | 'identity:address';
150
- /** Why this chain — named, or the only one holding it. */
151
- choice: string;
152
- balanceUnits: bigint;
153
- /** EVM: the transaction exactly as it would be signed. */
154
- tx?: EvmTxFields;
155
- /** EVM: gasLimit × maxFeePerGas — the most the fee can be, in wei. */
156
- feeMaxUnits?: bigint;
157
- /** Sui: the coin type moved. */
158
- coinType?: string;
159
- explorer: string;
160
- }
161
- export interface PlanDeps {
162
- fetch: Fetch;
163
- /** The sender's registered addresses (wallet:get), read once. */
164
- from: Addresses;
165
- /** Resolves a name (slug or agent id) to an address of `family`; null = none. */
166
- resolve: (name: string, family: 'evm' | 'sui') => Promise<{
167
- address: string;
168
- source: 'wallet:get' | 'identity:address';
169
- } | null>;
170
- }
171
- export type PlanResult = {
172
- ok: true;
173
- plan: SendPlan;
174
- } | {
175
- ok: false;
176
- error: string;
177
- message: string;
178
- options?: Obj[];
179
- };
180
- /** A bare asset → the one chain that holds it. Two → refused with the list; a failed read → refused (it might be a second). */
181
- export declare function pickChain(asset: SendAsset, from: Addresses, net: Net, f: Fetch): Promise<{
182
- ok: true;
183
- chain: SendChain;
184
- choice: string;
185
- } | {
186
- ok: false;
187
- error: string;
188
- message: string;
189
- options: Obj[];
190
- }>;
191
- /** Everything a send would sign, read and checked — nothing signed, nothing sent. */
192
- export declare function planSend(intent: {
193
- amount: string;
194
- asset: string;
195
- to: string;
196
- net: Net;
197
- }, deps: PlanDeps): Promise<PlanResult>;
198
- /** ERC-20 transfer(address,uint256) — the same bytes as @oneie/sdk/evm-tx encodeErc20Transfer, kept here so a dry run needs no SDK upgrade. */
199
- export declare function erc20TransferData(to: string, amount: bigint): string;
200
- /**
201
- * R16 — before a key signs, rebuild what the transaction MUST be from the person's own inputs
202
- * (argv, and the address they confirmed), never from a server answer or the plan's echo, and
203
- * compare. Any difference refuses.
204
- */
205
- export declare function clientCheck(plan: SendPlan, own: {
206
- amount: string;
207
- asset: SendAsset;
208
- chain: SendChain;
209
- to: string;
210
- net: Net;
211
- }): {
212
- ok: true;
213
- } | {
214
- ok: false;
215
- field: string;
216
- };
217
- /** What a person reads before anything is signed. */
218
- export declare function planLines(p: SendPlan): string[];
219
- /** A plan as JSON-safe values (bigints as decimal strings). */
220
- export declare function planJson(p: SendPlan): Obj;
221
- /** The `wallet send … --payment-tx` line that records a broadcast transfer in ONE's ledger. */
222
- export declare function recordLine(p: SendPlan, hash: string, cli: string): string;