oneie 5.7.5 → 5.8.0

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 (87) hide show
  1. package/README.md +19 -0
  2. package/dist/package.json +5 -2
  3. package/dist/src/balances.d.ts +89 -0
  4. package/dist/src/balances.js +202 -0
  5. package/dist/src/ceiling.d.ts +36 -0
  6. package/dist/src/ceiling.js +189 -0
  7. package/dist/src/check.d.ts +11 -0
  8. package/dist/src/check.js +53 -0
  9. package/dist/src/credits.d.ts +29 -0
  10. package/dist/src/credits.js +88 -0
  11. package/dist/src/hl-run.d.ts +119 -0
  12. package/dist/src/hl-run.js +480 -0
  13. package/dist/src/hl.d.ts +17 -0
  14. package/dist/src/hl.js +148 -0
  15. package/dist/src/index.js +15 -1
  16. package/dist/src/join.js +4 -0
  17. package/dist/src/key-sweep.d.ts +19 -3
  18. package/dist/src/key-sweep.js +70 -20
  19. package/dist/src/lib/check-words.d.ts +57 -0
  20. package/dist/src/lib/check-words.js +144 -0
  21. package/dist/src/lib/hl-core/actions.d.ts +99 -0
  22. package/dist/src/lib/hl-core/actions.js +69 -0
  23. package/dist/src/lib/hl-core/eip712.d.ts +33 -0
  24. package/dist/src/lib/hl-core/eip712.js +107 -0
  25. package/dist/src/lib/hl-core/errors.d.ts +10 -0
  26. package/dist/src/lib/hl-core/errors.js +15 -0
  27. package/dist/src/lib/hl-core/exchange.d.ts +24 -0
  28. package/dist/src/lib/hl-core/exchange.js +47 -0
  29. package/dist/src/lib/hl-core/index.d.ts +13 -0
  30. package/dist/src/lib/hl-core/index.js +14 -0
  31. package/dist/src/lib/hl-core/meta.d.ts +57 -0
  32. package/dist/src/lib/hl-core/meta.js +110 -0
  33. package/dist/src/lib/hl-core/msgpack.d.ts +18 -0
  34. package/dist/src/lib/hl-core/msgpack.js +136 -0
  35. package/dist/src/lib/hl-core/net.d.ts +2 -0
  36. package/dist/src/lib/hl-core/net.js +7 -0
  37. package/dist/src/lib/hl-core/signing.d.ts +103 -0
  38. package/dist/src/lib/hl-core/signing.js +295 -0
  39. package/dist/src/lib/hl-core/wire.d.ts +34 -0
  40. package/dist/src/lib/hl-core/wire.js +81 -0
  41. package/dist/src/lib/journey-words.d.ts +54 -3
  42. package/dist/src/lib/journey-words.js +162 -20
  43. package/dist/src/lib/journey.d.ts +2 -0
  44. package/dist/src/lib/journey.js +21 -2
  45. package/dist/src/lib/key-source.d.ts +9 -0
  46. package/dist/src/lib/key-source.js +33 -0
  47. package/dist/src/lib/net-choice.d.ts +28 -0
  48. package/dist/src/lib/net-choice.js +72 -0
  49. package/dist/src/lib/network.d.ts +22 -0
  50. package/dist/src/lib/network.js +50 -0
  51. package/dist/src/lib/next-words.d.ts +105 -0
  52. package/dist/src/lib/next-words.js +298 -0
  53. package/dist/src/lib/qr.d.ts +21 -0
  54. package/dist/src/lib/qr.js +402 -0
  55. package/dist/src/lib/sale-card.d.ts +117 -0
  56. package/dist/src/lib/sale-card.js +261 -0
  57. package/dist/src/lib/sui-grpc-send.d.ts +90 -0
  58. package/dist/src/lib/sui-grpc-send.js +128 -0
  59. package/dist/src/lib/timed-fetch.d.ts +33 -0
  60. package/dist/src/lib/timed-fetch.js +59 -0
  61. package/dist/src/lib/vaultfile.d.ts +15 -0
  62. package/dist/src/lib/vaultfile.js +28 -1
  63. package/dist/src/lib/wallet-money.d.ts +222 -0
  64. package/dist/src/lib/wallet-money.js +578 -0
  65. package/dist/src/lib/wallet-request.d.ts +50 -0
  66. package/dist/src/lib/wallet-request.js +86 -0
  67. package/dist/src/move.d.ts +36 -0
  68. package/dist/src/move.js +152 -0
  69. package/dist/src/network-cmd.d.ts +17 -0
  70. package/dist/src/network-cmd.js +74 -0
  71. package/dist/src/next.d.ts +12 -0
  72. package/dist/src/next.js +67 -0
  73. package/dist/src/onboard.js +4 -3
  74. package/dist/src/shop-buy.d.ts +16 -0
  75. package/dist/src/shop-buy.js +101 -0
  76. package/dist/src/shop.js +40 -1
  77. package/dist/src/staff.js +10 -0
  78. package/dist/src/start.d.ts +12 -0
  79. package/dist/src/start.js +51 -21
  80. package/dist/src/thread.d.ts +2 -0
  81. package/dist/src/thread.js +52 -0
  82. package/dist/src/wallet-money.d.ts +158 -0
  83. package/dist/src/wallet-money.js +664 -0
  84. package/dist/src/wallet.d.ts +2 -0
  85. package/dist/src/wallet.js +290 -27
  86. package/dist/src/workflow.js +4 -1
  87. package/package.json +5 -2
@@ -130,6 +130,8 @@ export interface UnlockIO {
130
130
  value?: string;
131
131
  error?: string;
132
132
  };
133
+ /** Open the passphrase sealed to the Secure Enclave — the chip asks for the finger here. */
134
+ openSe?: (sealedPath: string, identityPath: string) => string;
133
135
  }
134
136
  /**
135
137
  * Open the folder's vault, asking Keychain or the human depending on how it was
@@ -6,11 +6,18 @@ import { generateWallet, recoverWallet, readDerivation } from '@oneie/sdk/wallet
6
6
  import { sealVault, openVault, mintKeychainSecret } from '@oneie/sdk/vault-file';
7
7
  import { proveAddresses } from '@oneie/sdk/address-proof';
8
8
  import { askPath } from './lib/api-path.js';
9
+ import { balancesCmd } from './balances.js';
9
10
  import { workspaceFor } from './lib/keyfile.js';
10
11
  import { resolveKey } from './lib/client.js';
11
- import { wordsStdoutRefusal } from './lib/agent-env.js';
12
+ import { keySourceOf } from './lib/key-source.js';
13
+ import { readMachineKey } from './lib/paths.js';
14
+ import { wordsStdoutRefusal, agentType } from './lib/agent-env.js';
12
15
  import { cliPrefix } from './lib/invoked-as.js';
13
- import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, } from './lib/vaultfile.js';
16
+ import { writeVaultFolder, readVaultFolder, vaultPath, paperSheet, keychainStore, keychainRead, keychainAvailable, keychainDelete, seSealPath, seIdentityPath, } from './lib/vaultfile.js';
17
+ import { keygen, openWithAge, recipientOf, sealWithAge } from './lib/age-plugin.js';
18
+ import { receiveCmd, requestCmd, sendCmd, upgradeBalances } from './wallet-money.js';
19
+ import { ceilingCmd } from './ceiling.js';
20
+ import { savedNet } from './lib/net-choice.js';
14
21
  const DEFAULT_API = process.env.ONEIE_BASE_URL ?? process.env.ONE_API_URL ?? 'https://api.one.ie';
15
22
  // Re-exported for existing callers/tests — canonical implementation now lives
16
23
  // in ./lib/api-path.ts so trade.ts/client.ts/coordinate.ts/catalog.ts can share
@@ -28,11 +35,19 @@ export function refusalMessage(receiver, envelope) {
28
35
  const hint = typeof r.hint === 'string' ? ` — ${r.hint}` : '';
29
36
  return `${receiver} → ${envelope.outcome}${why.length ? `: ${why.join(' · ')}` : ''}${hint}`;
30
37
  }
38
+ /** A wallet receiver that has not answered in this long is not going to: say so, never wait forever (lib/timed-fetch.ts). */
39
+ const WALLET_ASK_TIMEOUT_MS = 60_000;
31
40
  async function ask(base, key, receiver, data) {
41
+ const signal = AbortSignal.timeout(WALLET_ASK_TIMEOUT_MS);
32
42
  const res = await fetch(askPath(base, receiver), {
33
43
  method: 'POST',
34
44
  headers: { 'Content-Type': 'application/json', ...(key ? { Authorization: `Bearer ${key}` } : {}) },
35
45
  body: JSON.stringify({ data }),
46
+ signal,
47
+ }).catch((e) => {
48
+ if (signal.aborted)
49
+ throw new Error(`${receiver} did not answer in ${WALLET_ASK_TIMEOUT_MS / 1000} s`);
50
+ throw e;
36
51
  });
37
52
  if (!res.ok) {
38
53
  const body = await res.text().catch(() => '');
@@ -134,17 +149,42 @@ export function okWrap(result) {
134
149
  export function walletCmd() {
135
150
  const cmd = new Command('wallet').description('Read balances, provision a wallet row, fund from testnet, send crypto — wallet:* receivers + pay.one.ie');
136
151
  cmd.command('get')
137
- .description('Credits, spend ceiling, wallet rows, live chain balances, delegated wallets')
152
+ .description('Credits, spend ceiling, wallet rows, live chain balances (sui · evm · solana · btc · hyperliquid), delegated wallets')
138
153
  .option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
139
154
  .option('--actor <id>', 'Actor within the workspace (defaults to workspace)')
155
+ .option('--net <network>', 'mainnet | testnet — the one network every balance is read on (default: ONE_NETWORK, then `one network`, then the deploy\'s)')
140
156
  .option('--api <url>', 'API base URL', DEFAULT_API)
141
157
  .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
142
158
  .action(async (opts) => {
159
+ // The server already defaults to its own deploy; send a network only when one is NAMED here.
160
+ if (!opts.net)
161
+ opts.net = process.env.ONE_NETWORK?.trim() || savedNet() || undefined;
162
+ if (opts.net && opts.net !== 'mainnet' && opts.net !== 'testnet') {
163
+ out(cmd, { ok: false, error: '--net must be mainnet or testnet' });
164
+ process.exitCode = 1;
165
+ return;
166
+ }
143
167
  const { base, key } = resolveAuth(opts);
144
168
  const workspace = resolveWorkspace(opts.workspace);
145
- const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
169
+ const result = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor, ...(opts.net ? { net: opts.net } : {}) });
146
170
  out(cmd, okWrap(result));
147
171
  });
172
+ // ceiling — the agent's on-chain spend ceiling (src/ceiling.ts): owner-signed create/set, show, register with pay.
173
+ cmd.addCommand(ceilingCmd());
174
+ // balances — the REAL mainnet balances of the loaded wallet, read from the chains (src/balances.ts).
175
+ // `get` above is ONE's own ledger and shows test money for most chains.
176
+ cmd.addCommand(balancesCmd({
177
+ fetch: (url, init) => fetch(url, init),
178
+ addresses: async (opts) => {
179
+ const { base, key } = resolveAuth(opts);
180
+ const workspace = resolveWorkspace(opts.workspace);
181
+ const w = await ask(base, key, 'wallet:get', { workspace, actor: opts.actor });
182
+ const rows = Array.isArray(w['addresses']) ? w['addresses'] : [];
183
+ const who = opts.actor ?? workspace;
184
+ const mine = (chain) => rows.find((x) => x.chain === chain && x.actor === who && typeof x.address === 'string')?.address;
185
+ return { evm: mine('evm'), sui: mine('sui') };
186
+ },
187
+ }, DEFAULT_API));
148
188
  // list — every wallet in the workspace with the words it wears (treasury · agent · person ·
149
189
  // limit · paused · no-limit · sweep · vault · no-address). The tags are wallet:get's own,
150
190
  // derived on the server from the rows, the caps and the signed sweep rules.
@@ -227,27 +267,46 @@ export function walletCmd() {
227
267
  const results = (data.results ?? []);
228
268
  out(cmd, { ok: faucetOk(results), results, manualFaucets: data.manualFaucets });
229
269
  });
230
- cmd.command('send <to>')
231
- .description('Send crypto via pay.one.ie payment links, incl. Bitcoin — sign the transfer yourself first, pass the tx hash')
232
- .requiredOption('--chain <chain>', 'SUI | EVM | SOL | BTC | BASE | ARB | OPT')
233
- .requiredOption('--amount <n>', 'Amount to send')
234
- .requiredOption('--payment-tx <hash>', 'The transaction hash from signing & broadcasting client-side — this command never signs')
235
- .option('--workspace <slug>', 'Source workspace (defaults to AGENCY_SLUG)')
236
- .option('--unit <unit>', 'usd | token', 'usd')
237
- .option('--currency <currency>', 'NATIVE | USDC', 'NATIVE')
238
- .option('--user-address <address>', 'Sender address (defaults to --to)')
239
- .option('--memo <text>', 'Payment memo')
240
- .option('--api <url>', 'API base URL', DEFAULT_API)
241
- .option('--key <key>', 'API key (overrides ONEIE_API_KEY env)')
242
- .action(async (to, opts) => {
243
- const { base, key } = resolveAuth(opts);
244
- const workspace = resolveWorkspace(opts.workspace);
245
- const result = await ask(base, key, 'wallet:send', {
246
- workspace, to, chain: opts.chain, amount: Number(opts.amount), paymentTx: opts.paymentTx,
247
- unit: opts.unit, currency: opts.currency, userAddress: opts.userAddress, memo: opts.memo,
248
- });
249
- out(cmd, okWrap(result));
250
- });
270
+ // receive · send · request, and --net on balances — the loaded wallet's money (src/wallet-money.ts).
271
+ // `send <amount> <asset>[@chain] <to>` signs with the sealed vault on --live; the older
272
+ // `send <to> --chain --amount --payment-tx` form still records a transfer signed elsewhere.
273
+ const money = {
274
+ ask: (o, receiver, data) => { const { base, key } = resolveAuth(o); return ask(base, key, receiver, data); },
275
+ workspace: resolveWorkspace,
276
+ // Who the key acts as and where it came from — wallet:challenge names the actor; the key itself is never printed.
277
+ identity: async (o, which) => {
278
+ const src = keySourceOf(o);
279
+ if (which === 'machine' && !src.local)
280
+ return null;
281
+ const { base, key } = resolveAuth(o);
282
+ const useKey = which === 'machine' ? readMachineKey() : key;
283
+ const from = which === 'machine' ? keySourceOf({}, '/nonexistent-folder', {}).label : src.label;
284
+ let actor;
285
+ try {
286
+ actor = String((await ask(base, useKey, 'wallet:challenge', {}))['actor'] ?? '') || undefined;
287
+ }
288
+ catch { /* unread: the header says so */ }
289
+ return { actor, from, local: which === 'machine' ? false : src.local };
290
+ },
291
+ unlock: (dir) => unlock(dir),
292
+ defaultApi: DEFAULT_API,
293
+ relay: async (_c, to, o) => {
294
+ const opts = o;
295
+ const { base, key } = resolveAuth(opts);
296
+ const workspace = resolveWorkspace(opts.workspace);
297
+ const result = await ask(base, key, 'wallet:send', {
298
+ workspace, to, chain: opts.chain, amount: Number(opts.amount), paymentTx: opts.paymentTx,
299
+ unit: opts.unit, currency: opts.currency, userAddress: opts.userAddress, memo: opts.memo,
300
+ });
301
+ out(cmd, okWrap(result));
302
+ },
303
+ };
304
+ const balances = cmd.commands.find((c) => c.name() === 'balances');
305
+ if (balances)
306
+ upgradeBalances(balances, money);
307
+ cmd.addCommand(receiveCmd(money));
308
+ cmd.addCommand(sendCmd(money));
309
+ cmd.addCommand(requestCmd(money));
251
310
  cmd.command('register')
252
311
  .description('Register a keygen output\'s PUBLIC receiving addresses with a workspace — sends addresses only, never a key or a mnemonic. With --kind agent the keys in --from (or the sealed wallet in --dir) sign a server challenge locally, and only the signatures are sent. First write wins per chain and is permanent')
253
312
  .option('--from <file>', 'A `wallet keygen --out` file (or any JSON with `addresses` / `keys`) — only the address fields are read')
@@ -478,6 +537,193 @@ export function walletCmd() {
478
537
  const k = keychainStore(String(blob.authPub ?? ''), pass);
479
538
  out(cmd, k.ok ? { ok: true, note: 'Touch ID now opens this wallet' } : { ok: false, error: k.error });
480
539
  });
540
+ cmd.command('secure')
541
+ .description("Put this wallet behind the Secure Enclave: its passphrase is sealed to a chip key that only the CURRENT fingerprint opens, so no process can sign without Touch ID. wallet.json is not rewritten. Then --drop-keychain, after one Touch ID open proves it, deletes the Keychain copy")
542
+ .option('--dir <path>', 'Project directory', '.')
543
+ .option('--drop-keychain', 'Open once through the Secure Enclave (Touch ID), prove it opens the vault, then delete the Keychain copy')
544
+ .option('--access <rule>', 'age-plugin-se access control', 'current-biometry')
545
+ .action(async (opts) => {
546
+ const t0 = Date.now();
547
+ const blob = readVaultFolder(opts.dir);
548
+ if (!blob) {
549
+ out(cmd, { ok: false, error: `no wallet at ${vaultPath(opts.dir)}` });
550
+ return;
551
+ }
552
+ if (blob.wrap !== 'keychain') {
553
+ out(cmd, { ok: false, error: 'not_a_keychain_wallet', detail: 'only a Keychain-wrapped wallet moves to the Secure Enclave' });
554
+ return;
555
+ }
556
+ const authPub = String(blob.authPub ?? '');
557
+ const sealed = seSealPath(opts.dir), identity = seIdentityPath(opts.dir);
558
+ if (!existsSync(sealed)) {
559
+ const k = keychainRead(authPub);
560
+ if (!k.ok || !k.value) {
561
+ out(cmd, { ok: false, error: 'keychain_unreadable', detail: k.ok ? 'empty' : k.error });
562
+ return;
563
+ }
564
+ // Prove the Keychain copy opens THIS vault before sealing it anywhere.
565
+ try {
566
+ await openVault(blob, k.value);
567
+ }
568
+ catch {
569
+ out(cmd, { ok: false, error: 'keychain_copy_does_not_open_vault' });
570
+ return;
571
+ }
572
+ const made = keygen(identity, opts.access);
573
+ if (made !== true) {
574
+ out(cmd, { ok: false, error: typeof made === 'string' ? made : 'se_keygen_failed' });
575
+ return;
576
+ }
577
+ chmodSync(identity, 0o600);
578
+ const lock = recipientOf(identity);
579
+ if (!lock) {
580
+ rmSync(identity, { force: true });
581
+ out(cmd, { ok: false, error: 'se_lock_unreadable' });
582
+ return;
583
+ }
584
+ try {
585
+ writeFileSync(sealed, sealWithAge(new TextEncoder().encode(k.value), [lock]), { mode: 0o600 });
586
+ }
587
+ catch {
588
+ rmSync(identity, { force: true });
589
+ out(cmd, { ok: false, error: 'se_seal_failed' });
590
+ return;
591
+ }
592
+ if (!opts.dropKeychain) {
593
+ out(cmd, { ok: true, sealed: true, lock, access: opts.access, keychain: 'kept until proven', next: `${cliPrefix()} wallet secure --dir ${opts.dir} --drop-keychain (Touch ID once, then the Keychain copy is deleted)`, ms: Date.now() - t0 });
594
+ return;
595
+ }
596
+ }
597
+ if (!opts.dropKeychain) {
598
+ out(cmd, { ok: true, sealed: true, note: 'already behind the Secure Enclave', next: `${cliPrefix()} wallet secure --dir ${opts.dir} --drop-keychain` });
599
+ return;
600
+ }
601
+ // The proof: open through the chip (this is where Touch ID asks), and the result must open the vault.
602
+ let pass;
603
+ try {
604
+ pass = openSeDefault(sealed, identity);
605
+ }
606
+ catch {
607
+ out(cmd, { ok: false, error: 'touch_id_not_given', detail: 'the Secure Enclave did not open — the Keychain copy is KEPT, nothing was deleted' });
608
+ return;
609
+ }
610
+ try {
611
+ await openVault(blob, pass);
612
+ }
613
+ catch {
614
+ out(cmd, { ok: false, error: 'se_copy_does_not_open_vault', detail: 'the Keychain copy is KEPT' });
615
+ return;
616
+ }
617
+ const d = keychainDelete(authPub);
618
+ if (!d.ok) {
619
+ out(cmd, { ok: false, error: 'keychain_delete_failed', detail: d.error });
620
+ return;
621
+ }
622
+ const after = keychainRead(authPub);
623
+ out(cmd, { ok: !after.ok || !after.value, provedWithTouchId: true, keychainCopy: after.ok && after.value ? 'STILL PRESENT' : 'deleted', ms: Date.now() - t0 });
624
+ });
625
+ // The browser's /w/restore "Key file" door opens a vault sealed with a TYPED
626
+ // passphrase — it cannot read this machine's Keychain. This writes that copy:
627
+ // the same 24 words, the same derivation, a passphrase the person types twice.
628
+ // Nothing secret reaches stdout; the file is useless without the passphrase.
629
+ cmd.command('file')
630
+ .description('Write a browser copy of this wallet — the same key re-sealed with a passphrase you type, for the Key file door on /w/restore (drag and drop). Prints only the path and the addresses')
631
+ .option('--dir <path>', 'Project directory', '.')
632
+ .option('--out <path>', 'Where to write it', '')
633
+ .action(async (opts) => {
634
+ if (!process.stdin.isTTY) {
635
+ out(cmd, { ok: false, error: 'a passphrase is typed at a terminal, never piped — run this yourself' });
636
+ process.exitCode = 1;
637
+ return;
638
+ }
639
+ const agentHere = agentType(process.env);
640
+ if (agentHere) {
641
+ out(cmd, { ok: false, error: `refusing: this shell is driven by ${agentHere}. Run it yourself in a terminal no agent drives` });
642
+ process.exitCode = 1;
643
+ return;
644
+ }
645
+ const r = await unlock(opts.dir);
646
+ if ('error' in r) {
647
+ out(cmd, { ok: false, error: r.error });
648
+ return;
649
+ }
650
+ const p1 = await promptSecret('Passphrase for the browser copy (12+ characters): ');
651
+ if (p1.length < 12) {
652
+ out(cmd, { ok: false, error: 'too short — nothing written' });
653
+ return;
654
+ }
655
+ const p2 = await promptSecret('Again: ');
656
+ if (p1 !== p2) {
657
+ out(cmd, { ok: false, error: 'they differ — nothing written' });
658
+ return;
659
+ }
660
+ const blob = await sealVault(r.mnemonic, p1, { wrap: 'passphrase', derivation: r.blob.derivation });
661
+ const target = opts.out || `${opts.dir.replace(/\/$/, '')}/wallet-file.json`;
662
+ writeFileSync(target, JSON.stringify(blob, null, 1) + '\n');
663
+ chmodSync(target, 0o600);
664
+ out(cmd, { ok: true, out: target, addresses: r.addresses, next: 'drop it on /w/restore → Key file, type the passphrase; delete the copy once the browser holds the key' });
665
+ });
666
+ // One chain's private key, to the CLIPBOARD and nowhere else — for MetaMask,
667
+ // Phantom, Slush, Sparrow. Never stdout: a terminal scrollback, a CI log or an
668
+ // agent transcript would keep it. The key is derived on demand and dropped.
669
+ cmd.command('key')
670
+ .description('Copy one chain\'s private key to the clipboard for another wallet app (MetaMask, Phantom, Slush, Sparrow). Clipboard only — it is never printed. Prints the address it belongs to')
671
+ .option('--dir <path>', 'Project directory', '.')
672
+ .option('--chain <chain>', 'evm | sui | sol | btc | asi', 'evm')
673
+ .option('--clipboard', 'Required: the only destination this command has')
674
+ .action(async (opts) => {
675
+ if (!opts.clipboard) {
676
+ out(cmd, { ok: false, error: 'add --clipboard — the key goes to the clipboard, never to the screen' });
677
+ process.exitCode = 1;
678
+ return;
679
+ }
680
+ // The same gate as `paper`, BEFORE unlock: a shell an agent drives must not
681
+ // move a private key anywhere — a clipboard is one paste from a transcript.
682
+ // And a terminal, so the hand on the keyboard is a person's.
683
+ const agent = agentType(process.env);
684
+ if (agent) {
685
+ out(cmd, { ok: false, error: `refusing: this shell is driven by ${agent}. Run it yourself in a terminal no agent drives` });
686
+ process.exitCode = 1;
687
+ return;
688
+ }
689
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
690
+ out(cmd, { ok: false, error: 'refusing: not a terminal (a pipe, a file or a log)' });
691
+ process.exitCode = 1;
692
+ return;
693
+ }
694
+ const want = opts.chain.toLowerCase();
695
+ const r = await unlock(opts.dir);
696
+ if ('error' in r) {
697
+ out(cmd, { ok: false, error: r.error });
698
+ return;
699
+ }
700
+ const k = r.keys.find((x) => String(x.chain).toLowerCase() === want || (want === 'evm' && ['eth', 'ethereum'].includes(String(x.chain).toLowerCase())) || (want === 'sol' && String(x.chain).toLowerCase() === 'solana'));
701
+ if (!k) {
702
+ out(cmd, { ok: false, error: `no ${want} key in this wallet` });
703
+ return;
704
+ }
705
+ const { spawnSync, spawn } = await import('node:child_process');
706
+ // Fixed system paths only — never a PATH or cwd lookup, which a project-local
707
+ // `pbcopy` could shadow and read the key.
708
+ const copier = process.platform === 'darwin' ? ['/usr/bin/pbcopy']
709
+ : process.platform === 'win32' ? [`${process.env.SystemRoot ?? 'C:\\Windows'}\\System32\\clip.exe`]
710
+ : existsSync('/usr/bin/wl-copy') ? ['/usr/bin/wl-copy'] : ['/usr/bin/xclip', '-selection', 'clipboard'];
711
+ if (!existsSync(copier[0])) {
712
+ out(cmd, { ok: false, error: `no clipboard tool at ${copier[0]} — nothing was printed` });
713
+ return;
714
+ }
715
+ const p = spawnSync(copier[0], copier.slice(1), { input: k.privateKeyHex.replace(/^0x/, '') });
716
+ if (p.status !== 0) {
717
+ out(cmd, { ok: false, error: `clipboard tool ${copier[0]} failed — nothing was printed` });
718
+ return;
719
+ }
720
+ // Clear it after the paste window: the key must not sit on the clipboard.
721
+ // --clear-after defaults to 60 s; the clear is a second spawn of the same tool.
722
+ const seconds = 60;
723
+ const sweeper = spawn(process.execPath, ['-e', `setTimeout(()=>{require('child_process').spawnSync(${JSON.stringify(copier[0])},${JSON.stringify(copier.slice(1))},{input:'cleared'})},${seconds * 1000})`], { detached: true, stdio: 'ignore' });
724
+ sweeper.unref();
725
+ out(cmd, { ok: true, chain: want, address: k.address, note: `private key on the clipboard for ${seconds} s — paste it into the wallet app now; it clears itself after` });
726
+ });
481
727
  return cmd;
482
728
  }
483
729
  /**
@@ -638,8 +884,9 @@ export async function paperFor(dir, io = terminalIO(), cli = cliPrefix()) {
638
884
  // absent marker is v1 — so the sheet names the derivation those addresses are.
639
885
  return { sheet: paperSheet(r.mnemonic, r.addresses, { derivation: readDerivation(r.blob.derivation), cli }) };
640
886
  }
887
+ const openSeDefault = (sealedPath, identityPath) => new TextDecoder().decode(openWithAge(new Uint8Array(readFileSync(sealedPath)), identityPath));
641
888
  const terminalIO = () => ({
642
- interactive: Boolean(process.stdin.isTTY), readPassphrase: promptSecret, readKeychain: keychainRead,
889
+ interactive: Boolean(process.stdin.isTTY), readPassphrase: promptSecret, readKeychain: keychainRead, openSe: openSeDefault,
643
890
  });
644
891
  /**
645
892
  * Open the folder's vault, asking Keychain or the human depending on how it was
@@ -657,7 +904,23 @@ export async function unlock(dir, io = terminalIO()) {
657
904
  return { error: `no wallet at ${vaultPath(dir)} — run \`${cliPrefix()} wallet new\`` };
658
905
  const blob = raw;
659
906
  let passphrase;
660
- if (blob.wrap === 'keychain') {
907
+ if (existsSync(seSealPath(dir))) {
908
+ // Sealed to the Secure Enclave (`wallet secure`): the chip opens it with the current
909
+ // finger, or nothing does. Keychain is never consulted, even if a copy is still there.
910
+ // The moment a person meets their key. Said on the terminal only (stderr, a TTY), never in --json.
911
+ const say = (line) => { if (process.stderr.isTTY)
912
+ process.stderr.write(line + '\n'); };
913
+ say('\n ◉ Touch ID — your finger is the key. It never leaves this Mac.');
914
+ try {
915
+ passphrase = (io.openSe ?? openSeDefault)(seSealPath(dir), seIdentityPath(dir));
916
+ say(' ✓ That was you. Opened, and signing now.\n');
917
+ }
918
+ catch {
919
+ say(' · Not opened — nothing was signed, nothing moved. Run it again when you are ready.\n');
920
+ return { error: 'touch_id_required: this wallet opens only with Touch ID on this Mac, and the Secure Enclave did not open it (no finger, cancelled, or a fingerprint changed). Recover from the 24 words if this Mac is gone' };
921
+ }
922
+ }
923
+ else if (blob.wrap === 'keychain') {
661
924
  const k = io.readKeychain(String(blob.authPub ?? ''));
662
925
  if (!k.ok || !k.value)
663
926
  return { error: k.ok ? 'Keychain returned nothing' : String(k.error) };
@@ -55,7 +55,10 @@ export function workflowCmd() {
55
55
  .requiredOption('--slug <slug>', 'Workspace slug')
56
56
  .option('--api <url>', 'API base URL', DEFAULT_API)
57
57
  .action(async (opts) => {
58
- const r = await call(opts.api, opts.slug, 'workflow:list', {});
58
+ // The receiver lists `data.slug` when the key controls it, else the KEY's own
59
+ // workspace. Sending {} dropped --slug, so a key minted for another workspace
60
+ // printed 0 for `--slug one` while workflow:list answered 22 for one.
61
+ const r = await call(opts.api, opts.slug, 'workflow:list', { slug: opts.slug });
59
62
  out(cmd, { ok: !r.error, ...r });
60
63
  });
61
64
  cmd.command('pull <id>')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.7.5",
3
+ "version": "5.8.0",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,10 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "commander": "^12.0.0",
23
- "@oneie/sdk": "^0.17.6"
23
+ "@oneie/sdk": "^0.17.6",
24
+ "@noble/curves": "^2.2.0",
25
+ "@noble/hashes": "^2.2.0",
26
+ "@mysten/sui": "^2.20.0"
24
27
  },
25
28
  "devDependencies": {
26
29
  "@oneie/evals": "^0.2.0",