@run402/sdk 4.97.0 → 4.99.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.
- package/README.md +2 -2
- package/core-dist/binding-file.d.ts +14 -0
- package/core-dist/binding-file.js +28 -1
- package/core-dist/wallet.js +3 -3
- package/dist/errors.d.ts +24 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +44 -2
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel.d.ts +34 -0
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +15 -1
- package/dist/kernel.js.map +1 -1
- package/dist/namespaces/admin.d.ts.map +1 -1
- package/dist/namespaces/admin.js +8 -0
- package/dist/namespaces/admin.js.map +1 -1
- package/dist/namespaces/agent.d.ts +2 -2
- package/dist/namespaces/agent.d.ts.map +1 -1
- package/dist/namespaces/agent.js +4 -0
- package/dist/namespaces/agent.js.map +1 -1
- package/dist/namespaces/agent.types.d.ts +5 -0
- package/dist/namespaces/agent.types.d.ts.map +1 -1
- package/dist/namespaces/apps.d.ts.map +1 -1
- package/dist/namespaces/apps.js +2 -0
- package/dist/namespaces/apps.js.map +1 -1
- package/dist/namespaces/auth.d.ts.map +1 -1
- package/dist/namespaces/auth.js +9 -0
- package/dist/namespaces/auth.js.map +1 -1
- package/dist/namespaces/branches.d.ts.map +1 -1
- package/dist/namespaces/branches.js +2 -0
- package/dist/namespaces/branches.js.map +1 -1
- package/dist/namespaces/ci.d.ts.map +1 -1
- package/dist/namespaces/ci.js +2 -0
- package/dist/namespaces/ci.js.map +1 -1
- package/dist/namespaces/credentials.d.ts +0 -23
- package/dist/namespaces/credentials.d.ts.map +1 -1
- package/dist/namespaces/credentials.js +29 -0
- package/dist/namespaces/credentials.js.map +1 -1
- package/dist/namespaces/escalations.d.ts.map +1 -1
- package/dist/namespaces/escalations.js +2 -0
- package/dist/namespaces/escalations.js.map +1 -1
- package/dist/namespaces/grants.d.ts.map +1 -1
- package/dist/namespaces/grants.js +4 -0
- package/dist/namespaces/grants.js.map +1 -1
- package/dist/namespaces/live.d.ts +0 -16
- package/dist/namespaces/live.d.ts.map +1 -1
- package/dist/namespaces/live.js +19 -0
- package/dist/namespaces/live.js.map +1 -1
- package/dist/namespaces/me.d.ts.map +1 -1
- package/dist/namespaces/me.js +3 -0
- package/dist/namespaces/me.js.map +1 -1
- package/dist/namespaces/org.d.ts.map +1 -1
- package/dist/namespaces/org.js +3 -0
- package/dist/namespaces/org.js.map +1 -1
- package/dist/namespaces/projects.d.ts.map +1 -1
- package/dist/namespaces/projects.js +5 -0
- package/dist/namespaces/projects.js.map +1 -1
- package/dist/namespaces/repos.d.ts.map +1 -1
- package/dist/namespaces/repos.js +5 -0
- package/dist/namespaces/repos.js.map +1 -1
- package/dist/namespaces/rooms.d.ts.map +1 -1
- package/dist/namespaces/rooms.js +3 -0
- package/dist/namespaces/rooms.js.map +1 -1
- package/dist/namespaces/session.d.ts.map +1 -1
- package/dist/namespaces/session.js +18 -0
- package/dist/namespaces/session.js.map +1 -1
- package/dist/namespaces/transfers.d.ts.map +1 -1
- package/dist/namespaces/transfers.js +3 -0
- package/dist/namespaces/transfers.js.map +1 -1
- package/dist/namespaces/wallets.d.ts.map +1 -1
- package/dist/namespaces/wallets.js +2 -0
- package/dist/namespaces/wallets.js.map +1 -1
- package/dist/namespaces/write-approval.d.ts.map +1 -1
- package/dist/namespaces/write-approval.js +3 -0
- package/dist/namespaces/write-approval.js.map +1 -1
- package/dist/node/actions-node.d.ts.map +1 -1
- package/dist/node/actions-node.js +3 -0
- package/dist/node/actions-node.js.map +1 -1
- package/dist/node/buzz-doctor-contract.d.ts +155 -0
- package/dist/node/buzz-doctor-contract.d.ts.map +1 -0
- package/dist/node/buzz-doctor-contract.js +385 -0
- package/dist/node/buzz-doctor-contract.js.map +1 -0
- package/dist/node/buzz-doctor.d.ts +155 -0
- package/dist/node/buzz-doctor.d.ts.map +1 -0
- package/dist/node/buzz-doctor.js +810 -0
- package/dist/node/buzz-doctor.js.map +1 -0
- package/dist/node/credentials.d.ts +9 -4
- package/dist/node/credentials.d.ts.map +1 -1
- package/dist/node/credentials.js +1 -1
- package/dist/node/credentials.js.map +1 -1
- package/dist/node/diagnostics.d.ts +45 -0
- package/dist/node/diagnostics.d.ts.map +1 -0
- package/dist/node/diagnostics.js +67 -0
- package/dist/node/diagnostics.js.map +1 -0
- package/dist/node/doctor.d.ts +101 -0
- package/dist/node/doctor.d.ts.map +1 -0
- package/dist/node/doctor.js +618 -0
- package/dist/node/doctor.js.map +1 -0
- package/dist/node/index.d.ts +57 -5
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +36 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/init.d.ts +137 -0
- package/dist/node/init.d.ts.map +1 -0
- package/dist/node/init.js +507 -0
- package/dist/node/init.js.map +1 -0
- package/dist/node/lightning-wallet.d.ts +61 -0
- package/dist/node/lightning-wallet.d.ts.map +1 -0
- package/dist/node/lightning-wallet.js +126 -0
- package/dist/node/lightning-wallet.js.map +1 -0
- package/dist/node/local-actions.d.ts +23 -0
- package/dist/node/local-actions.d.ts.map +1 -0
- package/dist/node/local-actions.js +38 -0
- package/dist/node/local-actions.js.map +1 -0
- package/dist/node/org-context.d.ts +169 -0
- package/dist/node/org-context.d.ts.map +1 -0
- package/dist/node/org-context.js +403 -0
- package/dist/node/org-context.js.map +1 -0
- package/dist/node/status.d.ts +62 -0
- package/dist/node/status.d.ts.map +1 -0
- package/dist/node/status.js +132 -0
- package/dist/node/status.js.map +1 -0
- package/dist/node/vault-target.d.ts +49 -0
- package/dist/node/vault-target.d.ts.map +1 -0
- package/dist/node/vault-target.js +109 -0
- package/dist/node/vault-target.js.map +1 -0
- package/dist/node/wallets.d.ts +242 -0
- package/dist/node/wallets.d.ts.map +1 -0
- package/dist/node/wallets.js +484 -0
- package/dist/node/wallets.js.map +1 -0
- package/dist/secret-gate.d.ts +377 -0
- package/dist/secret-gate.d.ts.map +1 -0
- package/dist/secret-gate.js +273 -0
- package/dist/secret-gate.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named wallets (profiles) and wallet selection, owned by the Node SDK.
|
|
3
|
+
*
|
|
4
|
+
* Each named wallet is a self-contained profile directory under
|
|
5
|
+
* `{config_dir}/profiles/<name>/` with its own key, project keystore, and
|
|
6
|
+
* non-secret `meta.json`; the reserved `default` wallet lives at the
|
|
7
|
+
* config-dir root. This module is the one implementation of:
|
|
8
|
+
*
|
|
9
|
+
* - the SELECTION precedence chain (`resolveWalletSelection`), highest first:
|
|
10
|
+
* 1. an explicit flag value (`--wallet <name>` / `--profile <name>`)
|
|
11
|
+
* 2. `RUN402_WALLET` / `RUN402_PROFILE`
|
|
12
|
+
* 3. the nearest `.run402.local.json` / `.run402.json` binding, walking up
|
|
13
|
+
* 4. the global default recorded by `wallets use` (base `config.json`)
|
|
14
|
+
* 5. `default`
|
|
15
|
+
* An env value that disagrees with a directory binding is a hard error
|
|
16
|
+
* (`WALLET_SELECTION_CONFLICT`) unless the caller is the wallet-management
|
|
17
|
+
* surface itself, which must keep working while selection is ambiguous.
|
|
18
|
+
* - the MANAGEMENT verbs on `r.wallets` (`list`, `current`, `create`, `use`,
|
|
19
|
+
* `rename`, `bind`, `unbind`, `import`, `remove`), which operate on explicit
|
|
20
|
+
* named targets and are independent of the active selection.
|
|
21
|
+
*
|
|
22
|
+
* The CLI (`run402 wallets …`, the `--wallet` pre-resolution in `cli.mjs`) and
|
|
23
|
+
* the MCP server consume these; neither adds a precedence rule of its own.
|
|
24
|
+
*
|
|
25
|
+
* A rejected name is a value we know nothing about — a private key pasted
|
|
26
|
+
* into `RUN402_WALLET` is a demonstrated case — so every refusal routes the
|
|
27
|
+
* value through `describeRejectedValue()`: a short typo shows in full, anything
|
|
28
|
+
* secret-shaped is redacted.
|
|
29
|
+
*/
|
|
30
|
+
import { join } from "node:path";
|
|
31
|
+
import { DEFAULT_PROFILE, getWalletPath, isValidProfileName, } from "../../core-dist/config.js";
|
|
32
|
+
import { ensureProfileDir, getDefaultWallet, listProfileNames, profileDir, profileExists, readMeta, removeProfile, renameProfile, setDefaultWallet, writeMeta, } from "../../core-dist/profiles.js";
|
|
33
|
+
import { readWallet, saveWallet } from "../../core-dist/wallet.js";
|
|
34
|
+
import { describeRejectedValue } from "../../core-dist/redact.js";
|
|
35
|
+
import { findBindingKey, readBindingFile, updateBindingFile } from "../../core-dist/binding-file.js";
|
|
36
|
+
import { LocalError } from "../errors.js";
|
|
37
|
+
import { Wallets } from "../namespaces/wallets.js";
|
|
38
|
+
import { gateSecret } from "../secret-gate.js";
|
|
39
|
+
import { initializeWalletAction } from "./local-actions.js";
|
|
40
|
+
/**
|
|
41
|
+
* The active profile's wallet, or null when there is none. A file that exists
|
|
42
|
+
* but cannot be read as a wallet is `BAD_WALLET_FILE`, naming the file and
|
|
43
|
+
* the way to recreate it, never the parser's own failure.
|
|
44
|
+
*/
|
|
45
|
+
export function readLocalWallet() {
|
|
46
|
+
try {
|
|
47
|
+
return readWallet();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
throw new LocalError(err?.message ?? "wallet.json is malformed", "reading the local wallet", {
|
|
51
|
+
code: "BAD_WALLET_FILE",
|
|
52
|
+
hint: "Back up ~/.config/run402/wallet.json and run 'run402 init' to recreate it.",
|
|
53
|
+
details: { path: getWalletPath() },
|
|
54
|
+
next_actions: [initializeWalletAction()],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const DEFAULT = DEFAULT_PROFILE;
|
|
59
|
+
const PRIVATE_KEY_RE = /^0x[0-9a-fA-F]{64}$/;
|
|
60
|
+
const CONTEXT = "managing local wallets";
|
|
61
|
+
/**
|
|
62
|
+
* A wallet selection refused: bad name, env-vs-binding conflict, or a named
|
|
63
|
+
* wallet that does not exist locally. A {@link LocalError} carrying `code`,
|
|
64
|
+
* `hint`, and `details`, never exiting the process, so a caller mid-protocol
|
|
65
|
+
* (the git remote helper) can report it on its own channel.
|
|
66
|
+
*/
|
|
67
|
+
export class WalletSelectionError extends LocalError {
|
|
68
|
+
constructor({ code, message, hint, details }) {
|
|
69
|
+
super(message, "selecting a wallet", { code, ...(hint !== undefined ? { hint } : {}), ...(details !== undefined ? { details } : {}) });
|
|
70
|
+
this.name = "WalletSelectionError";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function envName(env) {
|
|
74
|
+
const raw = env.RUN402_WALLET ?? env.RUN402_PROFILE;
|
|
75
|
+
return typeof raw === "string" && raw.trim() ? raw.trim() : null;
|
|
76
|
+
}
|
|
77
|
+
function assertValidSelectionName(name, origin) {
|
|
78
|
+
if (name === DEFAULT || isValidProfileName(name))
|
|
79
|
+
return;
|
|
80
|
+
throw new WalletSelectionError({
|
|
81
|
+
code: "BAD_WALLET_NAME",
|
|
82
|
+
message: `Invalid wallet name ${JSON.stringify(describeRejectedValue(name))} (from ${origin}).`,
|
|
83
|
+
hint: "Wallet names must match /^[a-z0-9][a-z0-9_-]{0,63}$/ (lowercase letters, digits, '_' and '-'). If a private key or other secret ended up here, it does not belong in a NAME field — see `run402 wallets import` — and should be treated as compromised.",
|
|
84
|
+
details: { name: describeRejectedValue(name), origin },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Nearest wallet binding walking up from `startDir` to the filesystem root. */
|
|
88
|
+
export function findWalletBinding(startDir) {
|
|
89
|
+
const hit = findBindingKey(startDir, "wallet");
|
|
90
|
+
return hit ? { wallet: hit.value, file: hit.file } : null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The one precedence chain. Pure: reads the environment it is handed, the
|
|
94
|
+
* binding files above `cwd`, and the global default; never prompts, never
|
|
95
|
+
* exits. Throws {@link WalletSelectionError}.
|
|
96
|
+
*/
|
|
97
|
+
export function resolveWalletSelection({ walletFlag, env = process.env, cwd = process.cwd(), allowConflict = false, } = {}) {
|
|
98
|
+
if (walletFlag) {
|
|
99
|
+
if (walletFlag.value === undefined || walletFlag.value === "") {
|
|
100
|
+
throw new WalletSelectionError({ code: "BAD_FLAG", message: `${walletFlag.flag} requires a value`, details: { flag: walletFlag.flag } });
|
|
101
|
+
}
|
|
102
|
+
assertValidSelectionName(walletFlag.value, walletFlag.flag);
|
|
103
|
+
return { name: walletFlag.value, source: "flag", sourceDetail: walletFlag.flag };
|
|
104
|
+
}
|
|
105
|
+
const fromEnv = envName(env);
|
|
106
|
+
const binding = findWalletBinding(cwd);
|
|
107
|
+
if (fromEnv && binding && fromEnv !== binding.wallet && !allowConflict) {
|
|
108
|
+
// Runs BEFORE the name check, so an unvalidated (possibly secret-shaped)
|
|
109
|
+
// env value reaches here whenever a binding exists: redact it the same
|
|
110
|
+
// way. The binding's value comes from a committed file whose writer
|
|
111
|
+
// validated it.
|
|
112
|
+
throw new WalletSelectionError({
|
|
113
|
+
code: "WALLET_SELECTION_CONFLICT",
|
|
114
|
+
message: `Ambiguous wallet: RUN402_WALLET=${describeRejectedValue(fromEnv)} but ${binding.file} selects '${binding.wallet}'.`,
|
|
115
|
+
hint: "Resolve with one of: pass --wallet <name>, unset RUN402_WALLET, or run402 wallets unbind.",
|
|
116
|
+
details: { env_wallet: describeRejectedValue(fromEnv), binding_wallet: binding.wallet, binding_file: binding.file },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (fromEnv) {
|
|
120
|
+
assertValidSelectionName(fromEnv, "RUN402_WALLET");
|
|
121
|
+
return { name: fromEnv, source: "env", sourceDetail: "RUN402_WALLET" };
|
|
122
|
+
}
|
|
123
|
+
if (binding) {
|
|
124
|
+
assertValidSelectionName(binding.wallet, binding.file);
|
|
125
|
+
return { name: binding.wallet, source: "binding", sourceDetail: binding.file };
|
|
126
|
+
}
|
|
127
|
+
const globalDefault = getDefaultWallet();
|
|
128
|
+
if (globalDefault && globalDefault !== DEFAULT)
|
|
129
|
+
return { name: globalDefault, source: "config", sourceDetail: "wallets use" };
|
|
130
|
+
return { name: DEFAULT, source: "default", sourceDetail: null };
|
|
131
|
+
}
|
|
132
|
+
function looksLikeAddress(s) {
|
|
133
|
+
return /^0x[a-fA-F0-9]{40}$/.test(s);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Fail closed when a non-default selection names a wallet that does not exist
|
|
137
|
+
* locally. Throws {@link WalletSelectionError} `WALLET_NOT_FOUND`.
|
|
138
|
+
*/
|
|
139
|
+
export function assertWalletExists({ name, source }) {
|
|
140
|
+
if (name === DEFAULT)
|
|
141
|
+
return;
|
|
142
|
+
if (profileExists(name))
|
|
143
|
+
return;
|
|
144
|
+
// A bare 64-hex private key satisfies the name charset, so this path can
|
|
145
|
+
// still see key material: echo an address (public) or a short plain name,
|
|
146
|
+
// redact anything else.
|
|
147
|
+
const shown = describeRejectedValue(name);
|
|
148
|
+
const hint = looksLikeAddress(name)
|
|
149
|
+
? `'${name}' looks like an address. For billing use: run402 billing ... --wallet-address ${name}`
|
|
150
|
+
: shown === name
|
|
151
|
+
? `Run 'run402 wallets list' to see wallets, or 'run402 wallets new ${name}' to create it.`
|
|
152
|
+
: "Run 'run402 wallets list' to see wallets. This value was not shown because it looks like a secret rather than a wallet name — if a private key or other credential landed here, treat it as compromised.";
|
|
153
|
+
throw new WalletSelectionError({
|
|
154
|
+
code: "WALLET_NOT_FOUND",
|
|
155
|
+
message: `No local wallet named '${shown}'.`,
|
|
156
|
+
hint,
|
|
157
|
+
details: { wallet: shown, source },
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** The environment variable carrying the published selection's provenance. */
|
|
161
|
+
export const ACTIVE_WALLET_CONTEXT_ENV = "RUN402_ACTIVE_WALLET_JSON";
|
|
162
|
+
/**
|
|
163
|
+
* Resolve, fail closed, and PUBLISH the selection to `env` so every core path
|
|
164
|
+
* function resolves under it: `RUN402_WALLET` names the wallet and
|
|
165
|
+
* `RUN402_ACTIVE_WALLET_JSON` carries how it was chosen (read back by
|
|
166
|
+
* `r.wallets.current()`, since the env var alone no longer can say). Call
|
|
167
|
+
* once per process, before any client reads a path.
|
|
168
|
+
*/
|
|
169
|
+
export function selectWallet(opts = {}) {
|
|
170
|
+
const env = (opts.env ?? process.env);
|
|
171
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
172
|
+
const fromEnv = envName(env);
|
|
173
|
+
const binding = findWalletBinding(cwd);
|
|
174
|
+
const resolved = resolveWalletSelection({ ...opts, env, cwd });
|
|
175
|
+
if (!opts.allowMissing)
|
|
176
|
+
assertWalletExists(resolved);
|
|
177
|
+
env.RUN402_WALLET = resolved.name;
|
|
178
|
+
const context = {
|
|
179
|
+
name: resolved.name,
|
|
180
|
+
source: resolved.source,
|
|
181
|
+
sourceDetail: resolved.sourceDetail,
|
|
182
|
+
binding: binding ? { wallet: binding.wallet, file: binding.file } : null,
|
|
183
|
+
envName: fromEnv,
|
|
184
|
+
diverged: !!(fromEnv && binding && fromEnv !== binding.wallet),
|
|
185
|
+
};
|
|
186
|
+
env[ACTIVE_WALLET_CONTEXT_ENV] = JSON.stringify(context);
|
|
187
|
+
return resolved;
|
|
188
|
+
}
|
|
189
|
+
/** The published selection context, or null when no surface published one. */
|
|
190
|
+
export function readActiveWalletContext(env = process.env) {
|
|
191
|
+
try {
|
|
192
|
+
const parsed = JSON.parse(env[ACTIVE_WALLET_CONTEXT_ENV] || "");
|
|
193
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function shortAddr(a) {
|
|
200
|
+
return typeof a === "string" && a.length >= 12 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a ?? null;
|
|
201
|
+
}
|
|
202
|
+
function badUsage(message, hint, details) {
|
|
203
|
+
return new LocalError(message, CONTEXT, { code: "BAD_USAGE", ...(hint !== undefined ? { hint } : {}), ...(details !== undefined ? { details } : {}) });
|
|
204
|
+
}
|
|
205
|
+
function requireName(name, what = "wallet name") {
|
|
206
|
+
if (!name)
|
|
207
|
+
throw badUsage(`Missing ${what}.`, "run402 wallets --help");
|
|
208
|
+
if (name === DEFAULT)
|
|
209
|
+
return name;
|
|
210
|
+
if (!isValidProfileName(name)) {
|
|
211
|
+
throw new LocalError(`Invalid ${what} ${JSON.stringify(describeRejectedValue(name))}.`, CONTEXT, {
|
|
212
|
+
code: "BAD_WALLET_NAME",
|
|
213
|
+
hint: "Names must match /^[a-z0-9][a-z0-9_-]{0,63}$/ (lowercase letters, digits, '_' and '-').",
|
|
214
|
+
details: { name: describeRejectedValue(name) },
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return name;
|
|
218
|
+
}
|
|
219
|
+
function walletNotFound(name) {
|
|
220
|
+
return new LocalError(`No local wallet named '${describeRejectedValue(name)}'.`, CONTEXT, {
|
|
221
|
+
code: "WALLET_NOT_FOUND",
|
|
222
|
+
hint: "run402 wallets list",
|
|
223
|
+
details: { name: describeRejectedValue(name) },
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function profileWalletPath(name) {
|
|
227
|
+
return join(profileDir(name), "wallet.json");
|
|
228
|
+
}
|
|
229
|
+
function walletInfo(name, active) {
|
|
230
|
+
const meta = readMeta(name);
|
|
231
|
+
let address = meta?.address ?? null;
|
|
232
|
+
let rail = meta?.rail ?? null;
|
|
233
|
+
const label = meta?.label ?? null;
|
|
234
|
+
if (!address) {
|
|
235
|
+
try {
|
|
236
|
+
const w = readWallet(profileWalletPath(name));
|
|
237
|
+
address = w?.address ?? null;
|
|
238
|
+
rail = rail ?? w?.rail ?? null;
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
/* best-effort */
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return { local_label: name, server_label: label, address, address_short: shortAddr(address), rail, active: name === active };
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* `r.wallets` on the Node entry: the isomorphic local-wallet and label verbs
|
|
248
|
+
* plus the named-wallet (profile) management verbs.
|
|
249
|
+
*/
|
|
250
|
+
export class NodeWallets extends Wallets {
|
|
251
|
+
#client;
|
|
252
|
+
#clientFor;
|
|
253
|
+
constructor(client, opts = {}) {
|
|
254
|
+
super(client);
|
|
255
|
+
this.#client = client;
|
|
256
|
+
this.#clientFor = opts.clientFor;
|
|
257
|
+
}
|
|
258
|
+
/** The selection in force: the one a surface published, else resolved fresh from the environment and cwd. */
|
|
259
|
+
#selection() {
|
|
260
|
+
const context = readActiveWalletContext();
|
|
261
|
+
if (context)
|
|
262
|
+
return { name: context.name, context, resolved: null };
|
|
263
|
+
const resolved = resolveWalletSelection({ allowConflict: true });
|
|
264
|
+
return { name: resolved.name, context: null, resolved };
|
|
265
|
+
}
|
|
266
|
+
/** Every local wallet, without loading any private key. */
|
|
267
|
+
async list() {
|
|
268
|
+
const active = this.#selection().name;
|
|
269
|
+
return listProfileNames().map((name) => walletInfo(name, active));
|
|
270
|
+
}
|
|
271
|
+
/** The active wallet: its name, how it was selected, and the local wallet file's facts. */
|
|
272
|
+
async current() {
|
|
273
|
+
const { name, context, resolved } = this.#selection();
|
|
274
|
+
const info = walletInfo(name, name);
|
|
275
|
+
const warnings = [];
|
|
276
|
+
const binding = context ? context.binding : findWalletBinding(process.cwd());
|
|
277
|
+
const fromEnv = context ? context.envName : envName(process.env);
|
|
278
|
+
const diverged = context ? context.diverged : !!(fromEnv && binding && fromEnv !== binding.wallet);
|
|
279
|
+
if (diverged && binding) {
|
|
280
|
+
warnings.push({
|
|
281
|
+
code: "WALLET_SELECTION_CONFLICT",
|
|
282
|
+
message: `RUN402_WALLET=${fromEnv} but ${binding.file} selects '${binding.wallet}'.`,
|
|
283
|
+
hint: "Resolve with: --wallet <name>, unset RUN402_WALLET, or run402 wallets unbind.",
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (info.server_label && info.server_label !== name) {
|
|
287
|
+
warnings.push({
|
|
288
|
+
code: "WALLET_LABEL_DRIFT",
|
|
289
|
+
message: `Local label '${name}' differs from the server label '${info.server_label}'.`,
|
|
290
|
+
hint: "Run 'run402 wallets rename' to reconcile.",
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
// `faucet_used` tracks faucet invocation, not pay-readiness.
|
|
294
|
+
const local = await this.status();
|
|
295
|
+
return {
|
|
296
|
+
local_label: name,
|
|
297
|
+
source: context?.source ?? resolved?.source ?? "unknown",
|
|
298
|
+
source_detail: context ? context.sourceDetail ?? null : resolved?.sourceDetail ?? null,
|
|
299
|
+
address: local?.configured ? local.address : info.address,
|
|
300
|
+
server_label: info.server_label,
|
|
301
|
+
configured: !!local?.configured,
|
|
302
|
+
created: local?.created ?? null,
|
|
303
|
+
rail: local?.configured ? local.rail ?? "x402" : info.rail,
|
|
304
|
+
faucet_used: !!local?.faucet_used,
|
|
305
|
+
path: local?.path ?? getWalletPath(),
|
|
306
|
+
...(local?.configured ? {} : { next_actions: [initializeWalletAction()] }),
|
|
307
|
+
warnings,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
async create(name, opts = {}) {
|
|
311
|
+
if (name === undefined)
|
|
312
|
+
return super.create();
|
|
313
|
+
gateSecret(this.#client, "wallets.create", name, opts);
|
|
314
|
+
const label = requireName(name);
|
|
315
|
+
if (profileExists(label)) {
|
|
316
|
+
throw new LocalError(`A wallet named '${label}' already exists.`, CONTEXT, { code: "WALLET_EXISTS", hint: "run402 wallets list", details: { name: label } });
|
|
317
|
+
}
|
|
318
|
+
const requested = opts.rail ?? "x402";
|
|
319
|
+
if (!["x402", "mpp", "lightning"].includes(requested)) {
|
|
320
|
+
throw badUsage("--rail must be x402, mpp, or lightning", undefined, { rail: requested });
|
|
321
|
+
}
|
|
322
|
+
const rail = requested;
|
|
323
|
+
const { generatePrivateKey, privateKeyToAccount } = await import("viem/accounts");
|
|
324
|
+
const privateKey = generatePrivateKey();
|
|
325
|
+
const address = privateKeyToAccount(privateKey).address;
|
|
326
|
+
const created = new Date().toISOString();
|
|
327
|
+
ensureProfileDir(label);
|
|
328
|
+
saveWallet({ address, privateKey, created, funded: false, rail }, profileWalletPath(label));
|
|
329
|
+
// The reserved `default` wallet carries no server label; a named wallet mirrors its name.
|
|
330
|
+
if (label === DEFAULT) {
|
|
331
|
+
writeMeta(label, { name: label, address, rail: rail, created });
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
writeMeta(label, { name: label, address, label, rail: rail, created });
|
|
335
|
+
await this.#pushLabel(label, label, address);
|
|
336
|
+
}
|
|
337
|
+
// requireName constrains names to shell-safe lowercase identifiers.
|
|
338
|
+
const command = rail === "lightning"
|
|
339
|
+
? `run402 --wallet ${label} init lightning`
|
|
340
|
+
: label === DEFAULT ? "run402 wallets fund" : `run402 wallets use ${label}`;
|
|
341
|
+
const why = rail === "lightning"
|
|
342
|
+
? "Initialize this Lightning wallet."
|
|
343
|
+
: label === DEFAULT ? "Fund the wallet you just created from the testnet faucet." : "Select the wallet you just created.";
|
|
344
|
+
return { local_label: label, address, rail, created: true, next: command, next_actions: [{ type: "run_command", command, why }] };
|
|
345
|
+
}
|
|
346
|
+
/** Set the global default wallet (`wallets use`). */
|
|
347
|
+
async use(name) {
|
|
348
|
+
const label = requireName(name);
|
|
349
|
+
if (label !== DEFAULT && !profileExists(label))
|
|
350
|
+
throw walletNotFound(label);
|
|
351
|
+
setDefaultWallet(label);
|
|
352
|
+
return { local_label: label, active: true };
|
|
353
|
+
}
|
|
354
|
+
/** Rename a wallet; renaming `default` moves it under `profiles/`. */
|
|
355
|
+
async rename(oldName, newName) {
|
|
356
|
+
const from = requireName(oldName, "old wallet name");
|
|
357
|
+
const to = requireName(newName, "new wallet name");
|
|
358
|
+
if (to === DEFAULT) {
|
|
359
|
+
throw new LocalError("Cannot rename a wallet to the reserved name 'default'.", CONTEXT, { code: "BAD_WALLET_NAME", details: { name: to } });
|
|
360
|
+
}
|
|
361
|
+
if (!profileExists(from))
|
|
362
|
+
throw walletNotFound(from);
|
|
363
|
+
try {
|
|
364
|
+
renameProfile(from, to);
|
|
365
|
+
}
|
|
366
|
+
catch (e) {
|
|
367
|
+
throw new LocalError(e?.message ?? "rename failed", CONTEXT, { code: "WALLET_RENAME_FAILED", details: { from, to } });
|
|
368
|
+
}
|
|
369
|
+
if (getDefaultWallet() === from)
|
|
370
|
+
setDefaultWallet(to);
|
|
371
|
+
const meta = readMeta(to) ?? { name: to };
|
|
372
|
+
let address = meta.address ?? null;
|
|
373
|
+
if (!address) {
|
|
374
|
+
try {
|
|
375
|
+
address = readWallet(profileWalletPath(to))?.address ?? null;
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
/* best-effort */
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
writeMeta(to, { ...meta, name: to, label: to, ...(address ? { address } : {}) });
|
|
382
|
+
await this.#pushLabel(to, to, address);
|
|
383
|
+
return { from, to, renamed: true };
|
|
384
|
+
}
|
|
385
|
+
/** Bind a directory (default cwd) to a wallet by writing its name into `./.run402.json`. */
|
|
386
|
+
async bind(name, opts = {}) {
|
|
387
|
+
const label = name ? requireName(name) : this.#selection().name;
|
|
388
|
+
// MERGE, never clobber: the same file carries `org`/`room` from `orgs bind`.
|
|
389
|
+
const { contents } = updateBindingFile(opts.cwd ?? process.cwd(), { wallet: label });
|
|
390
|
+
const result = {
|
|
391
|
+
wallet: label,
|
|
392
|
+
file: ".run402.json",
|
|
393
|
+
bound: true,
|
|
394
|
+
safe_to_commit: true,
|
|
395
|
+
note: "Safe to commit — contains no secrets, only the wallet name.",
|
|
396
|
+
binding: contents,
|
|
397
|
+
};
|
|
398
|
+
if (label !== DEFAULT && !profileExists(label)) {
|
|
399
|
+
result.warning = `No local wallet named '${label}' yet — create it with 'run402 wallets new ${label}'.`;
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
/** Remove only the `wallet` key from `./.run402.json`; the file goes when nothing else is left in it. */
|
|
404
|
+
async unbind(opts = {}) {
|
|
405
|
+
const dir = opts.cwd ?? process.cwd();
|
|
406
|
+
const had = readBindingFile(dir).wallet !== undefined;
|
|
407
|
+
const { contents, removed } = updateBindingFile(dir, { wallet: null });
|
|
408
|
+
return { file: ".run402.json", unbound: had, removed, binding: contents };
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Adopt an existing private key as a new named wallet. `privateKey` may be a
|
|
412
|
+
* function, called only after the name checks pass, so a caller reading the
|
|
413
|
+
* key from a file or stdin reads nothing for a refused name. Refused on the
|
|
414
|
+
* sandbox surface: its input is a private key.
|
|
415
|
+
*/
|
|
416
|
+
async import(name, privateKey) {
|
|
417
|
+
gateSecret(this.#client, "wallets.import", name);
|
|
418
|
+
const label = requireName(name);
|
|
419
|
+
if (label === DEFAULT) {
|
|
420
|
+
throw new LocalError("'default' is reserved.", CONTEXT, { code: "BAD_WALLET_NAME", details: { name: label } });
|
|
421
|
+
}
|
|
422
|
+
if (profileExists(label)) {
|
|
423
|
+
throw new LocalError(`A wallet named '${label}' already exists.`, CONTEXT, { code: "WALLET_EXISTS", details: { name: label } });
|
|
424
|
+
}
|
|
425
|
+
const key = (typeof privateKey === "function" ? privateKey() : privateKey).trim();
|
|
426
|
+
if (!PRIVATE_KEY_RE.test(key)) {
|
|
427
|
+
throw new LocalError("Key must be a 0x-prefixed 64-hex secp256k1 private key.", CONTEXT, { code: "BAD_PRIVATE_KEY", details: { name: label } });
|
|
428
|
+
}
|
|
429
|
+
const { privateKeyToAccount } = await import("viem/accounts");
|
|
430
|
+
let address;
|
|
431
|
+
try {
|
|
432
|
+
address = privateKeyToAccount(key).address;
|
|
433
|
+
}
|
|
434
|
+
catch (e) {
|
|
435
|
+
throw new LocalError(`Invalid private key: ${e?.message}`, CONTEXT, { code: "BAD_PRIVATE_KEY", details: { name: label } });
|
|
436
|
+
}
|
|
437
|
+
const created = new Date().toISOString();
|
|
438
|
+
ensureProfileDir(label);
|
|
439
|
+
saveWallet({ address, privateKey: key, created, funded: false, rail: "x402" }, profileWalletPath(label));
|
|
440
|
+
writeMeta(label, { name: label, address, label, rail: "x402", created });
|
|
441
|
+
await this.#pushLabel(label, label, address);
|
|
442
|
+
return { local_label: label, address, imported: true };
|
|
443
|
+
}
|
|
444
|
+
/** Delete a named wallet and its keys. Requires `{ confirm: true }`; `default` is protected. */
|
|
445
|
+
async remove(name, opts = {}) {
|
|
446
|
+
const label = requireName(name);
|
|
447
|
+
if (label === DEFAULT) {
|
|
448
|
+
throw new LocalError("Refusing to remove the reserved 'default' wallet.", CONTEXT, { code: "WALLET_PROTECTED", details: { name: label } });
|
|
449
|
+
}
|
|
450
|
+
if (!profileExists(label))
|
|
451
|
+
throw walletNotFound(label);
|
|
452
|
+
if (opts.confirm !== true) {
|
|
453
|
+
throw new LocalError(`Removing wallet '${label}' deletes its private key and project keystore. This cannot be undone.`, CONTEXT, {
|
|
454
|
+
code: "CONFIRMATION_REQUIRED",
|
|
455
|
+
hint: `Re-run with --yes to confirm: run402 wallets rm ${label} --yes`,
|
|
456
|
+
details: { name: label },
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
removeProfile(label);
|
|
460
|
+
if (getDefaultWallet() === label)
|
|
461
|
+
setDefaultWallet(DEFAULT);
|
|
462
|
+
return { local_label: label, removed: true };
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Best-effort server-side label push, signed with the TARGET wallet's key
|
|
466
|
+
* so a just-created or renamed wallet can set its own label. On by default;
|
|
467
|
+
* `RUN402_WALLET_LABEL_SYNC=0` disables it. Never throws: the local folder
|
|
468
|
+
* name is the source of truth and the server label only mirrors it.
|
|
469
|
+
*/
|
|
470
|
+
async #pushLabel(name, label, address) {
|
|
471
|
+
if (process.env.RUN402_WALLET_LABEL_SYNC === "0")
|
|
472
|
+
return;
|
|
473
|
+
if (!address || !this.#clientFor)
|
|
474
|
+
return;
|
|
475
|
+
try {
|
|
476
|
+
const sibling = this.#clientFor({ walletPath: profileWalletPath(name), keystorePath: join(profileDir(name), "projects.json") });
|
|
477
|
+
await sibling.wallet(address).setLabel(label);
|
|
478
|
+
}
|
|
479
|
+
catch {
|
|
480
|
+
/* best-effort — never block the local operation */
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
//# sourceMappingURL=wallets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallets.js","sourceRoot":"","sources":["../../src/node/wallets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,QAAQ,EACR,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,SAAS,GACV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,OAAO,EAA2B,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,UAAU,CAAE,GA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