@moonpay/cli 0.5.1 → 0.6.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/dist/{chunk-PBRXVTTG.js → chunk-DCHEUKV7.js} +529 -528
- package/dist/chunk-DCHEUKV7.js.map +1 -0
- package/dist/{chunk-V7MA7WNX.js → chunk-GSAFAKB7.js} +145 -119
- package/dist/chunk-GSAFAKB7.js.map +1 -0
- package/dist/index.js +174 -31
- package/dist/index.js.map +1 -1
- package/dist/{mcp-TDQN25MO.js → mcp-6IZ4QWFM.js} +3 -3
- package/dist/{store-HCN56E6A.js → store-UAGR3DWU.js} +2 -2
- package/package.json +1 -1
- package/skills/moonpay-block-explorer/SKILL.md +123 -0
- package/skills/moonpay-buy-crypto/SKILL.md +1 -1
- package/skills/moonpay-export-data/SKILL.md +111 -0
- package/skills/moonpay-polymarket-ready/SKILL.md +112 -0
- package/skills/moonpay-price-alerts/SKILL.md +167 -0
- package/skills/moonpay-trading-automation/SKILL.md +276 -0
- package/skills/moonpay-virtual-account/SKILL.md +14 -18
- package/dist/chunk-PBRXVTTG.js.map +0 -1
- package/dist/chunk-V7MA7WNX.js.map +0 -1
- /package/dist/{mcp-TDQN25MO.js.map → mcp-6IZ4QWFM.js.map} +0 -0
- /package/dist/{store-HCN56E6A.js.map → store-UAGR3DWU.js.map} +0 -0
|
@@ -10,16 +10,88 @@ import {
|
|
|
10
10
|
} from "fs";
|
|
11
11
|
import { join } from "path";
|
|
12
12
|
import { homedir } from "os";
|
|
13
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
14
|
+
|
|
15
|
+
// src/tools/wallet/models.ts
|
|
16
|
+
import { z as z2 } from "zod";
|
|
17
|
+
|
|
18
|
+
// src/crypto.ts
|
|
13
19
|
import {
|
|
14
|
-
randomBytes
|
|
20
|
+
randomBytes,
|
|
15
21
|
scryptSync,
|
|
16
22
|
createCipheriv,
|
|
17
23
|
createDecipheriv
|
|
18
24
|
} from "crypto";
|
|
25
|
+
import { z } from "zod";
|
|
26
|
+
var SCRYPT_N = 2 ** 18;
|
|
27
|
+
var SCRYPT_R = 8;
|
|
28
|
+
var SCRYPT_P = 1;
|
|
29
|
+
var KEY_LENGTH = 32;
|
|
30
|
+
var SCRYPT_MAXMEM = 512 * 1024 * 1024;
|
|
31
|
+
var encryptedFileSchema = z.object({
|
|
32
|
+
encryption: z.object({
|
|
33
|
+
cipher: z.literal("aes-256-gcm"),
|
|
34
|
+
kdf: z.literal("scrypt"),
|
|
35
|
+
kdfparams: z.object({
|
|
36
|
+
n: z.number(),
|
|
37
|
+
r: z.number(),
|
|
38
|
+
p: z.number()
|
|
39
|
+
}),
|
|
40
|
+
salt: z.string(),
|
|
41
|
+
iv: z.string(),
|
|
42
|
+
tag: z.string()
|
|
43
|
+
}),
|
|
44
|
+
data: z.string()
|
|
45
|
+
});
|
|
46
|
+
function encrypt(data, encryptionKey) {
|
|
47
|
+
const salt = randomBytes(32);
|
|
48
|
+
const aesKey = scryptSync(encryptionKey, salt, KEY_LENGTH, {
|
|
49
|
+
N: SCRYPT_N,
|
|
50
|
+
r: SCRYPT_R,
|
|
51
|
+
p: SCRYPT_P,
|
|
52
|
+
maxmem: SCRYPT_MAXMEM
|
|
53
|
+
});
|
|
54
|
+
const iv = randomBytes(12);
|
|
55
|
+
const cipher = createCipheriv("aes-256-gcm", aesKey, iv);
|
|
56
|
+
const encrypted = Buffer.concat([
|
|
57
|
+
cipher.update(data, "utf8"),
|
|
58
|
+
cipher.final()
|
|
59
|
+
]);
|
|
60
|
+
return {
|
|
61
|
+
encryption: {
|
|
62
|
+
cipher: "aes-256-gcm",
|
|
63
|
+
kdf: "scrypt",
|
|
64
|
+
kdfparams: { n: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P },
|
|
65
|
+
salt: salt.toString("base64"),
|
|
66
|
+
iv: iv.toString("base64"),
|
|
67
|
+
tag: cipher.getAuthTag().toString("base64")
|
|
68
|
+
},
|
|
69
|
+
data: encrypted.toString("base64")
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function decrypt(file, encryptionKey) {
|
|
73
|
+
const { salt, iv, tag, kdfparams } = file.encryption;
|
|
74
|
+
const aesKey = scryptSync(
|
|
75
|
+
encryptionKey,
|
|
76
|
+
Buffer.from(salt, "base64"),
|
|
77
|
+
KEY_LENGTH,
|
|
78
|
+
{ N: kdfparams.n, r: kdfparams.r, p: kdfparams.p, maxmem: SCRYPT_MAXMEM }
|
|
79
|
+
);
|
|
80
|
+
const decipher = createDecipheriv(
|
|
81
|
+
"aes-256-gcm",
|
|
82
|
+
aesKey,
|
|
83
|
+
Buffer.from(iv, "base64"),
|
|
84
|
+
{ authTagLength: 16 }
|
|
85
|
+
);
|
|
86
|
+
decipher.setAuthTag(Buffer.from(tag, "base64"));
|
|
87
|
+
return Buffer.concat([
|
|
88
|
+
decipher.update(Buffer.from(file.data, "base64")),
|
|
89
|
+
decipher.final()
|
|
90
|
+
]).toString("utf8");
|
|
91
|
+
}
|
|
19
92
|
|
|
20
93
|
// src/tools/wallet/models.ts
|
|
21
|
-
|
|
22
|
-
var chainSchema = z.enum([
|
|
94
|
+
var chainSchema = z2.enum([
|
|
23
95
|
"solana",
|
|
24
96
|
"ethereum",
|
|
25
97
|
"base",
|
|
@@ -31,7 +103,7 @@ var chainSchema = z.enum([
|
|
|
31
103
|
"bitcoin",
|
|
32
104
|
"tron"
|
|
33
105
|
]);
|
|
34
|
-
var keyChainSchema =
|
|
106
|
+
var keyChainSchema = z2.enum(["solana", "ethereum", "bitcoin", "tron"]);
|
|
35
107
|
var KEY_CHAIN_MAP = {
|
|
36
108
|
solana: "solana",
|
|
37
109
|
ethereum: "ethereum",
|
|
@@ -44,88 +116,94 @@ var KEY_CHAIN_MAP = {
|
|
|
44
116
|
bitcoin: "bitcoin",
|
|
45
117
|
tron: "tron"
|
|
46
118
|
};
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
createdAt: z.string()
|
|
119
|
+
var addressesSchema = z2.object({
|
|
120
|
+
solana: z2.string().optional(),
|
|
121
|
+
ethereum: z2.string().optional(),
|
|
122
|
+
bitcoin: z2.string().optional(),
|
|
123
|
+
tron: z2.string().optional()
|
|
53
124
|
});
|
|
54
|
-
var
|
|
55
|
-
name:
|
|
56
|
-
type:
|
|
125
|
+
var hdWalletSchema = z2.object({
|
|
126
|
+
name: z2.string(),
|
|
127
|
+
type: z2.literal("hd"),
|
|
128
|
+
mnemonic: z2.string(),
|
|
129
|
+
addresses: addressesSchema,
|
|
130
|
+
createdAt: z2.string()
|
|
131
|
+
});
|
|
132
|
+
var importedWalletSchema = z2.object({
|
|
133
|
+
name: z2.string(),
|
|
134
|
+
type: z2.literal("imported"),
|
|
57
135
|
chain: keyChainSchema,
|
|
58
|
-
privateKey:
|
|
59
|
-
addresses:
|
|
60
|
-
createdAt:
|
|
136
|
+
privateKey: z2.string(),
|
|
137
|
+
addresses: addressesSchema,
|
|
138
|
+
createdAt: z2.string()
|
|
61
139
|
});
|
|
62
|
-
var walletSchema =
|
|
140
|
+
var walletSchema = z2.discriminatedUnion("type", [
|
|
63
141
|
hdWalletSchema,
|
|
64
142
|
importedWalletSchema
|
|
65
143
|
]);
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
n: z.number(),
|
|
72
|
-
r: z.number(),
|
|
73
|
-
p: z.number()
|
|
74
|
-
}),
|
|
75
|
-
salt: z.string(),
|
|
76
|
-
iv: z.string(),
|
|
77
|
-
tag: z.string()
|
|
78
|
-
}),
|
|
79
|
-
data: z.string()
|
|
80
|
-
});
|
|
81
|
-
var walletInfoSchema = z.object({
|
|
82
|
-
name: z.string(),
|
|
83
|
-
type: z.enum(["hd", "imported"]),
|
|
84
|
-
addresses: z.record(keyChainSchema, z.string()),
|
|
85
|
-
createdAt: z.string()
|
|
144
|
+
var walletInfoSchema = z2.object({
|
|
145
|
+
name: z2.string(),
|
|
146
|
+
type: z2.enum(["hd", "imported"]),
|
|
147
|
+
addresses: addressesSchema,
|
|
148
|
+
createdAt: z2.string()
|
|
86
149
|
});
|
|
87
150
|
|
|
88
151
|
// src/tools/wallet/session.ts
|
|
89
|
-
import { execSync } from "child_process";
|
|
90
|
-
import { randomBytes } from "crypto";
|
|
152
|
+
import { execFileSync, execSync } from "child_process";
|
|
153
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
91
154
|
import { platform } from "os";
|
|
92
155
|
var SERVICE = "moonpay-cli";
|
|
93
156
|
var ACCOUNT = "encryption-key";
|
|
94
157
|
function storeMacOS(value) {
|
|
95
158
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
159
|
+
execFileSync("security", [
|
|
160
|
+
"delete-generic-password",
|
|
161
|
+
"-s",
|
|
162
|
+
SERVICE,
|
|
163
|
+
"-a",
|
|
164
|
+
ACCOUNT
|
|
165
|
+
], { stdio: "ignore" });
|
|
100
166
|
} catch {
|
|
101
167
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
168
|
+
execFileSync("security", [
|
|
169
|
+
"add-generic-password",
|
|
170
|
+
"-s",
|
|
171
|
+
SERVICE,
|
|
172
|
+
"-a",
|
|
173
|
+
ACCOUNT,
|
|
174
|
+
"-w",
|
|
175
|
+
value
|
|
176
|
+
], { stdio: "ignore" });
|
|
106
177
|
}
|
|
107
178
|
function getMacOS() {
|
|
108
179
|
try {
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
180
|
+
return execFileSync("security", [
|
|
181
|
+
"find-generic-password",
|
|
182
|
+
"-s",
|
|
183
|
+
SERVICE,
|
|
184
|
+
"-a",
|
|
185
|
+
ACCOUNT,
|
|
186
|
+
"-w"
|
|
187
|
+
], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
113
188
|
} catch {
|
|
114
189
|
return null;
|
|
115
190
|
}
|
|
116
191
|
}
|
|
117
192
|
function storeLinux(value) {
|
|
118
193
|
execSync(
|
|
119
|
-
`printf '%s'
|
|
120
|
-
{ stdio: "ignore" }
|
|
194
|
+
`printf '%s' | secret-tool store --label="${SERVICE}" service "${SERVICE}" account "${ACCOUNT}"`,
|
|
195
|
+
{ input: value, stdio: ["pipe", "ignore", "ignore"] }
|
|
121
196
|
);
|
|
122
197
|
}
|
|
123
198
|
function getLinux() {
|
|
124
199
|
try {
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
200
|
+
return execFileSync("secret-tool", [
|
|
201
|
+
"lookup",
|
|
202
|
+
"service",
|
|
203
|
+
SERVICE,
|
|
204
|
+
"account",
|
|
205
|
+
ACCOUNT
|
|
206
|
+
], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
129
207
|
} catch {
|
|
130
208
|
return null;
|
|
131
209
|
}
|
|
@@ -150,7 +228,7 @@ function getEncryptionKey() {
|
|
|
150
228
|
function ensureEncryptionKey() {
|
|
151
229
|
const existing = getEncryptionKey();
|
|
152
230
|
if (existing) return existing;
|
|
153
|
-
const key =
|
|
231
|
+
const key = randomBytes2(32).toString("hex");
|
|
154
232
|
storeInKeychain(key);
|
|
155
233
|
return key;
|
|
156
234
|
}
|
|
@@ -283,64 +361,6 @@ var WALLETS_PATH = join(CONFIG_DIR, "wallets.json");
|
|
|
283
361
|
function ensureConfigDir() {
|
|
284
362
|
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
285
363
|
}
|
|
286
|
-
var SCRYPT_N = 2 ** 18;
|
|
287
|
-
var SCRYPT_R = 8;
|
|
288
|
-
var SCRYPT_P = 1;
|
|
289
|
-
var KEY_LENGTH = 32;
|
|
290
|
-
var SCRYPT_MAXMEM = 512 * 1024 * 1024;
|
|
291
|
-
function deriveAesKey(password, salt) {
|
|
292
|
-
return scryptSync(password, salt, KEY_LENGTH, {
|
|
293
|
-
N: SCRYPT_N,
|
|
294
|
-
r: SCRYPT_R,
|
|
295
|
-
p: SCRYPT_P,
|
|
296
|
-
maxmem: SCRYPT_MAXMEM
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
function encrypt(data, encryptionKey) {
|
|
300
|
-
const salt = randomBytes2(32);
|
|
301
|
-
const aesKey = deriveAesKey(encryptionKey, salt);
|
|
302
|
-
const iv = randomBytes2(12);
|
|
303
|
-
const cipher = createCipheriv("aes-256-gcm", aesKey, iv);
|
|
304
|
-
const encrypted = Buffer.concat([
|
|
305
|
-
cipher.update(data, "utf8"),
|
|
306
|
-
cipher.final()
|
|
307
|
-
]);
|
|
308
|
-
return {
|
|
309
|
-
encryption: {
|
|
310
|
-
cipher: "aes-256-gcm",
|
|
311
|
-
kdf: "scrypt",
|
|
312
|
-
kdfparams: { n: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P },
|
|
313
|
-
salt: salt.toString("base64"),
|
|
314
|
-
iv: iv.toString("base64"),
|
|
315
|
-
tag: cipher.getAuthTag().toString("base64")
|
|
316
|
-
},
|
|
317
|
-
data: encrypted.toString("base64")
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
function decrypt(file, encryptionKey) {
|
|
321
|
-
const { salt, iv, tag, kdfparams } = file.encryption;
|
|
322
|
-
const aesKey = scryptSync(
|
|
323
|
-
encryptionKey,
|
|
324
|
-
Buffer.from(salt, "base64"),
|
|
325
|
-
KEY_LENGTH,
|
|
326
|
-
{ N: kdfparams.n, r: kdfparams.r, p: kdfparams.p, maxmem: SCRYPT_MAXMEM }
|
|
327
|
-
);
|
|
328
|
-
const decipher = createDecipheriv(
|
|
329
|
-
"aes-256-gcm",
|
|
330
|
-
aesKey,
|
|
331
|
-
Buffer.from(iv, "base64"),
|
|
332
|
-
{ authTagLength: 16 }
|
|
333
|
-
);
|
|
334
|
-
decipher.setAuthTag(Buffer.from(tag, "base64"));
|
|
335
|
-
try {
|
|
336
|
-
return Buffer.concat([
|
|
337
|
-
decipher.update(Buffer.from(file.data, "base64")),
|
|
338
|
-
decipher.final()
|
|
339
|
-
]).toString("utf8");
|
|
340
|
-
} catch {
|
|
341
|
-
throw new Error("Failed to decrypt wallets. Encryption key may be invalid.");
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
364
|
function loadWallets() {
|
|
345
365
|
if (!existsSync(WALLETS_PATH)) return [];
|
|
346
366
|
const encryptionKey = getEncryptionKey();
|
|
@@ -350,7 +370,7 @@ function loadWallets() {
|
|
|
350
370
|
);
|
|
351
371
|
}
|
|
352
372
|
const raw = JSON.parse(readFileSync(WALLETS_PATH, "utf-8"));
|
|
353
|
-
const file =
|
|
373
|
+
const file = encryptedFileSchema.parse(raw);
|
|
354
374
|
const decrypted = decrypt(file, encryptionKey);
|
|
355
375
|
const parsed = JSON.parse(decrypted);
|
|
356
376
|
return (parsed.wallets ?? []).map((w) => walletSchema.parse(w));
|
|
@@ -360,7 +380,7 @@ function saveWallets(wallets) {
|
|
|
360
380
|
const data = JSON.stringify({ wallets });
|
|
361
381
|
const file = encrypt(data, encryptionKey);
|
|
362
382
|
ensureConfigDir();
|
|
363
|
-
const tmpPath = join(CONFIG_DIR, `.wallets.${
|
|
383
|
+
const tmpPath = join(CONFIG_DIR, `.wallets.${randomBytes3(4).toString("hex")}.tmp`);
|
|
364
384
|
writeFileSync(tmpPath, JSON.stringify(file, null, 2), { mode: 384 });
|
|
365
385
|
renameSync(tmpPath, WALLETS_PATH);
|
|
366
386
|
}
|
|
@@ -424,10 +444,16 @@ function decodePrivateKey(key, chain) {
|
|
|
424
444
|
}
|
|
425
445
|
|
|
426
446
|
export {
|
|
447
|
+
encryptedFileSchema,
|
|
448
|
+
encrypt,
|
|
449
|
+
decrypt,
|
|
450
|
+
getEncryptionKey,
|
|
451
|
+
ensureEncryptionKey,
|
|
427
452
|
deriveAllAddresses,
|
|
428
453
|
chainSchema,
|
|
429
454
|
keyChainSchema,
|
|
430
455
|
KEY_CHAIN_MAP,
|
|
456
|
+
addressesSchema,
|
|
431
457
|
walletInfoSchema,
|
|
432
458
|
loadWallets,
|
|
433
459
|
saveWallets,
|
|
@@ -438,4 +464,4 @@ export {
|
|
|
438
464
|
removeWallet,
|
|
439
465
|
resolveSigningKey
|
|
440
466
|
};
|
|
441
|
-
//# sourceMappingURL=chunk-
|
|
467
|
+
//# sourceMappingURL=chunk-GSAFAKB7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools/wallet/store.ts","../src/tools/wallet/models.ts","../src/crypto.ts","../src/tools/wallet/session.ts","../src/tools/wallet/chains.ts"],"sourcesContent":["import {\n existsSync,\n readFileSync,\n writeFileSync,\n mkdirSync,\n renameSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { randomBytes } from \"node:crypto\";\nimport {\n walletsFileSchema,\n walletSchema,\n type Wallet,\n type Chain,\n type KeyChain,\n KEY_CHAIN_MAP,\n} from \"./models\";\nimport { encrypt, decrypt } from \"../../crypto\";\nimport { getEncryptionKey, ensureEncryptionKey } from \"./session\";\nimport { deriveKeyForChain } from \"./chains\";\nimport bs58 from \"bs58\";\n\n// ── Paths ───────────────────────────────────────────────────\n\nconst CONFIG_DIR = join(homedir(), \".config\", \"moonpay\");\nconst WALLETS_PATH = join(CONFIG_DIR, \"wallets.json\");\n\nfunction ensureConfigDir(): void {\n mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });\n}\n\n// ── Load / Save ─────────────────────────────────────────────\n\nexport function loadWallets(): Wallet[] {\n if (!existsSync(WALLETS_PATH)) return [];\n\n const encryptionKey = getEncryptionKey();\n if (!encryptionKey) {\n throw new Error(\n \"Encryption key not found. Set MOONPAY_ENCRYPTION_KEY or ensure OS keychain is accessible.\",\n );\n }\n\n const raw = JSON.parse(readFileSync(WALLETS_PATH, \"utf-8\"));\n const file = walletsFileSchema.parse(raw);\n const decrypted = decrypt(file, encryptionKey);\n const parsed = JSON.parse(decrypted);\n\n return (parsed.wallets ?? []).map((w: unknown) => walletSchema.parse(w));\n}\n\nexport function saveWallets(wallets: Wallet[]): void {\n const encryptionKey = ensureEncryptionKey();\n const data = JSON.stringify({ wallets });\n const file = encrypt(data, encryptionKey);\n\n ensureConfigDir();\n const tmpPath = join(CONFIG_DIR, `.wallets.${randomBytes(4).toString(\"hex\")}.tmp`);\n writeFileSync(tmpPath, JSON.stringify(file, null, 2), { mode: 0o600 });\n renameSync(tmpPath, WALLETS_PATH);\n}\n\nexport function mutateWallets(fn: (wallets: Wallet[]) => void): void {\n const wallets = loadWallets();\n fn(wallets);\n saveWallets(wallets);\n}\n\n// ── Wallet operations ───────────────────────────────────────\n\nexport function findWallet(nameOrAddress: string): Wallet | null {\n const wallets = loadWallets();\n\n for (const wallet of wallets) {\n if (wallet.name === nameOrAddress) return wallet;\n for (const address of Object.values(wallet.addresses)) {\n if (address === nameOrAddress) return wallet;\n }\n }\n\n return null;\n}\n\nexport function findWalletOrThrow(nameOrAddress: string): Wallet {\n const wallet = findWallet(nameOrAddress);\n if (!wallet) throw new Error(`Wallet \"${nameOrAddress}\" not found`);\n return wallet;\n}\n\nexport function addWallet(wallet: Wallet): void {\n mutateWallets((wallets) => {\n if (wallets.some((w) => w.name === wallet.name)) {\n throw new Error(`Wallet \"${wallet.name}\" already exists`);\n }\n wallets.push(wallet);\n });\n}\n\nexport function removeWallet(name: string): void {\n mutateWallets((wallets) => {\n const idx = wallets.findIndex((w) => w.name === name);\n if (idx === -1) throw new Error(`Wallet \"${name}\" not found`);\n wallets.splice(idx, 1);\n });\n}\n\n// ── Key resolution ──────────────────────────────────────────\n\nexport function resolveSigningKey(\n wallet: Wallet,\n chain: Chain,\n): { privateKey: Uint8Array; address: string } {\n const keyChain = KEY_CHAIN_MAP[chain];\n\n if (wallet.type === \"imported\") {\n if (wallet.chain !== keyChain) {\n throw new Error(\n `Wallet \"${wallet.name}\" was imported for ${wallet.chain}, cannot sign for ${chain}.`,\n );\n }\n return {\n privateKey: decodePrivateKey(wallet.privateKey, keyChain),\n address: wallet.addresses[keyChain]!,\n };\n }\n\n const derived = deriveKeyForChain(wallet.mnemonic, keyChain);\n return { privateKey: derived.privateKey, address: derived.address };\n}\n\nfunction decodePrivateKey(key: string, chain: KeyChain): Uint8Array {\n if (chain === \"solana\") {\n return bs58.decode(key);\n }\n const hex = key.startsWith(\"0x\") ? key.slice(2) : key;\n return Uint8Array.from(Buffer.from(hex, \"hex\"));\n}\n","import { z } from \"zod\";\nimport { encryptedFileSchema, type EncryptedFile } from \"../../crypto\";\n\nexport { encryptedFileSchema as walletsFileSchema };\nexport type WalletsFile = EncryptedFile;\n\n// ── Chain types ─────────────────────────────────────────────\n\nexport const chainSchema = z.enum([\n \"solana\",\n \"ethereum\",\n \"base\",\n \"arbitrum\",\n \"polygon\",\n \"optimism\",\n \"bnb\",\n \"avalanche\",\n \"bitcoin\",\n \"tron\",\n]);\nexport type Chain = z.infer<typeof chainSchema>;\n\nexport const keyChainSchema = z.enum([\"solana\", \"ethereum\", \"bitcoin\", \"tron\"]);\nexport type KeyChain = z.infer<typeof keyChainSchema>;\n\nexport const KEY_CHAIN_MAP: Record<Chain, KeyChain> = {\n solana: \"solana\",\n ethereum: \"ethereum\",\n base: \"ethereum\",\n arbitrum: \"ethereum\",\n polygon: \"ethereum\",\n optimism: \"ethereum\",\n bnb: \"ethereum\",\n avalanche: \"ethereum\",\n bitcoin: \"bitcoin\",\n tron: \"tron\",\n};\n\n// ── Addresses ───────────────────────────────────────────────\n\nexport const addressesSchema = z.object({\n solana: z.string().optional(),\n ethereum: z.string().optional(),\n bitcoin: z.string().optional(),\n tron: z.string().optional(),\n});\nexport type Addresses = z.infer<typeof addressesSchema>;\n\n// ── Wallet types (internal, includes secrets) ───────────────\n\nexport const hdWalletSchema = z.object({\n name: z.string(),\n type: z.literal(\"hd\"),\n mnemonic: z.string(),\n addresses: addressesSchema,\n createdAt: z.string(),\n});\nexport type HdWallet = z.infer<typeof hdWalletSchema>;\n\nexport const importedWalletSchema = z.object({\n name: z.string(),\n type: z.literal(\"imported\"),\n chain: keyChainSchema,\n privateKey: z.string(),\n addresses: addressesSchema,\n createdAt: z.string(),\n});\nexport type ImportedWallet = z.infer<typeof importedWalletSchema>;\n\nexport const walletSchema = z.discriminatedUnion(\"type\", [\n hdWalletSchema,\n importedWalletSchema,\n]);\nexport type Wallet = z.infer<typeof walletSchema>;\n\n// ── Encrypted file format (re-exported from shared crypto) ──\n\n// ── Public wallet info (no secrets) ─────────────────────────\n\nexport const walletInfoSchema = z.object({\n name: z.string(),\n type: z.enum([\"hd\", \"imported\"]),\n addresses: addressesSchema,\n createdAt: z.string(),\n});\nexport type WalletInfo = z.infer<typeof walletInfoSchema>;\n","import {\n randomBytes,\n scryptSync,\n createCipheriv,\n createDecipheriv,\n} from \"node:crypto\";\nimport { z } from \"zod\";\n\nconst SCRYPT_N = 2 ** 18;\nconst SCRYPT_R = 8;\nconst SCRYPT_P = 1;\nconst KEY_LENGTH = 32;\nconst SCRYPT_MAXMEM = 512 * 1024 * 1024;\n\nexport const encryptedFileSchema = z.object({\n encryption: z.object({\n cipher: z.literal(\"aes-256-gcm\"),\n kdf: z.literal(\"scrypt\"),\n kdfparams: z.object({\n n: z.number(),\n r: z.number(),\n p: z.number(),\n }),\n salt: z.string(),\n iv: z.string(),\n tag: z.string(),\n }),\n data: z.string(),\n});\nexport type EncryptedFile = z.infer<typeof encryptedFileSchema>;\n\nexport function encrypt(data: string, encryptionKey: string): EncryptedFile {\n const salt = randomBytes(32);\n const aesKey = scryptSync(encryptionKey, salt, KEY_LENGTH, {\n N: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P, maxmem: SCRYPT_MAXMEM,\n });\n const iv = randomBytes(12);\n const cipher = createCipheriv(\"aes-256-gcm\", aesKey, iv);\n\n const encrypted = Buffer.concat([\n cipher.update(data, \"utf8\"),\n cipher.final(),\n ]);\n\n return {\n encryption: {\n cipher: \"aes-256-gcm\",\n kdf: \"scrypt\",\n kdfparams: { n: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P },\n salt: salt.toString(\"base64\"),\n iv: iv.toString(\"base64\"),\n tag: cipher.getAuthTag().toString(\"base64\"),\n },\n data: encrypted.toString(\"base64\"),\n };\n}\n\nexport function decrypt(file: EncryptedFile, encryptionKey: string): string {\n const { salt, iv, tag, kdfparams } = file.encryption;\n\n const aesKey = scryptSync(\n encryptionKey,\n Buffer.from(salt, \"base64\"),\n KEY_LENGTH,\n { N: kdfparams.n, r: kdfparams.r, p: kdfparams.p, maxmem: SCRYPT_MAXMEM },\n );\n\n const decipher = createDecipheriv(\n \"aes-256-gcm\",\n aesKey,\n Buffer.from(iv, \"base64\"),\n { authTagLength: 16 },\n );\n decipher.setAuthTag(Buffer.from(tag, \"base64\"));\n\n return Buffer.concat([\n decipher.update(Buffer.from(file.data, \"base64\")),\n decipher.final(),\n ]).toString(\"utf8\");\n}\n","import { execFileSync, execSync } from \"node:child_process\";\nimport { randomBytes } from \"node:crypto\";\nimport { platform } from \"node:os\";\n\nconst SERVICE = \"moonpay-cli\";\nconst ACCOUNT = \"encryption-key\";\n\n// ── macOS Keychain ──────────────────────────────────────────\n\nfunction storeMacOS(value: string): void {\n try {\n execFileSync(\"security\", [\n \"delete-generic-password\", \"-s\", SERVICE, \"-a\", ACCOUNT,\n ], { stdio: \"ignore\" });\n } catch {}\n execFileSync(\"security\", [\n \"add-generic-password\", \"-s\", SERVICE, \"-a\", ACCOUNT, \"-w\", value,\n ], { stdio: \"ignore\" });\n}\n\nfunction getMacOS(): string | null {\n try {\n return execFileSync(\"security\", [\n \"find-generic-password\", \"-s\", SERVICE, \"-a\", ACCOUNT, \"-w\",\n ], { encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] }).trim();\n } catch {\n return null;\n }\n}\n\n// ── Linux libsecret ─────────────────────────────────────────\n\nfunction storeLinux(value: string): void {\n execSync(\n `printf '%s' | secret-tool store --label=\"${SERVICE}\" service \"${SERVICE}\" account \"${ACCOUNT}\"`,\n { input: value, stdio: [\"pipe\", \"ignore\", \"ignore\"] },\n );\n}\n\nfunction getLinux(): string | null {\n try {\n return execFileSync(\"secret-tool\", [\n \"lookup\", \"service\", SERVICE, \"account\", ACCOUNT,\n ], { encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] }).trim();\n } catch {\n return null;\n }\n}\n\n// ── Platform dispatch ───────────────────────────────────────\n\nfunction storeInKeychain(value: string): void {\n const os = platform();\n if (os === \"darwin\") return storeMacOS(value);\n if (os === \"linux\") return storeLinux(value);\n throw new Error(\"OS keychain not supported on this platform\");\n}\n\nfunction getFromKeychain(): string | null {\n const os = platform();\n if (os === \"darwin\") return getMacOS();\n if (os === \"linux\") return getLinux();\n return null;\n}\n\n// ── Public API ──────────────────────────────────────────────\n\nexport function getEncryptionKey(): string | null {\n const envKey = process.env.MOONPAY_ENCRYPTION_KEY;\n if (envKey) return envKey;\n return getFromKeychain();\n}\n\nexport function ensureEncryptionKey(): string {\n const existing = getEncryptionKey();\n if (existing) return existing;\n\n const key = randomBytes(32).toString(\"hex\");\n storeInKeychain(key);\n return key;\n}\n","import { createHash } from \"node:crypto\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport { keccak_256 } from \"@noble/hashes/sha3\";\nimport { derivePath } from \"ed25519-hd-key\";\nimport * as bitcoin from \"bitcoinjs-lib\";\nimport ECPairFactory from \"ecpair\";\nimport * as ecc from \"tiny-secp256k1\";\nimport { Keypair } from \"@solana/web3.js\";\nimport bs58 from \"bs58\";\nimport type { KeyChain } from \"./models\";\n\nconst ECPair = ECPairFactory(ecc);\n\n// ── BIP44 derivation paths ──────────────────────────────────\n\nexport function derivationPath(chain: KeyChain, account = 0): string {\n switch (chain) {\n case \"solana\":\n return `m/44'/501'/${account}'/0'`;\n case \"ethereum\":\n return `m/44'/60'/${account}'/0/0`;\n case \"bitcoin\":\n return `m/84'/0'/${account}'/0/0`;\n case \"tron\":\n return `m/44'/195'/${account}'/0/0`;\n }\n}\n\n// ── Key derivation ──────────────────────────────────────────\n\nexport interface DerivedKey {\n privateKey: Uint8Array;\n address: string;\n}\n\nexport function deriveKeyForChain(\n mnemonic: string,\n chain: KeyChain,\n account = 0,\n): DerivedKey {\n switch (chain) {\n case \"solana\":\n return deriveSolana(mnemonic, account);\n case \"ethereum\":\n return deriveEthereum(mnemonic, account);\n case \"bitcoin\":\n return deriveBitcoin(mnemonic, account);\n case \"tron\":\n return deriveTron(mnemonic, account);\n }\n}\n\nexport function deriveAllAddresses(\n mnemonic: string,\n account = 0,\n): Record<KeyChain, string> {\n return {\n solana: deriveKeyForChain(mnemonic, \"solana\", account).address,\n ethereum: deriveKeyForChain(mnemonic, \"ethereum\", account).address,\n bitcoin: deriveKeyForChain(mnemonic, \"bitcoin\", account).address,\n tron: deriveKeyForChain(mnemonic, \"tron\", account).address,\n };\n}\n\n// ── Solana (ed25519 via SLIP-0010) ──────────────────────────\n\nfunction deriveSolana(mnemonic: string, account: number): DerivedKey {\n const seed = mnemonicToSeedSync(mnemonic);\n const path = derivationPath(\"solana\", account);\n const { key } = derivePath(path, Buffer.from(seed).toString(\"hex\"));\n const keypair = Keypair.fromSeed(Uint8Array.from(key));\n return {\n privateKey: keypair.secretKey,\n address: keypair.publicKey.toBase58(),\n };\n}\n\n// ── Ethereum / EVM (secp256k1 via BIP32) ────────────────────\n\nfunction deriveEthereum(mnemonic: string, account: number): DerivedKey {\n const seed = mnemonicToSeedSync(mnemonic);\n const hdkey = HDKey.fromMasterSeed(seed);\n const path = derivationPath(\"ethereum\", account);\n const child = hdkey.derive(path);\n if (!child.privateKey) throw new Error(\"Failed to derive EVM private key\");\n\n const address = publicKeyToEthAddress(child.publicKey!);\n return {\n privateKey: child.privateKey,\n address,\n };\n}\n\nfunction publicKeyToEthAddress(compressedPubKey: Uint8Array): string {\n const uncompressed = ecc.pointCompress(compressedPubKey, false);\n const hash = keccak256(uncompressed.slice(1));\n const addressBytes = hash.slice(-20);\n const address = \"0x\" + Buffer.from(addressBytes).toString(\"hex\");\n return toChecksumAddress(address);\n}\n\nfunction keccak256(data: Uint8Array): Uint8Array {\n return keccak_256(data);\n}\n\nfunction toChecksumAddress(address: string): string {\n const addr = address.toLowerCase().replace(\"0x\", \"\");\n const hash = Buffer.from(keccak_256(Buffer.from(addr, \"utf8\"))).toString(\"hex\");\n let checksummed = \"0x\";\n for (let i = 0; i < addr.length; i++) {\n checksummed += parseInt(hash[i], 16) >= 8 ? addr[i].toUpperCase() : addr[i];\n }\n return checksummed;\n}\n\n// ── Bitcoin (secp256k1 via BIP32, native segwit) ────────────\n\nfunction deriveBitcoin(mnemonic: string, account: number): DerivedKey {\n const seed = mnemonicToSeedSync(mnemonic);\n const hdkey = HDKey.fromMasterSeed(seed);\n const path = derivationPath(\"bitcoin\", account);\n const child = hdkey.derive(path);\n if (!child.privateKey) throw new Error(\"Failed to derive Bitcoin private key\");\n\n const keyPair = ECPair.fromPrivateKey(Buffer.from(child.privateKey));\n const { address } = bitcoin.payments.p2wpkh({\n pubkey: Buffer.from(keyPair.publicKey),\n });\n if (!address) throw new Error(\"Failed to derive Bitcoin address\");\n\n return {\n privateKey: child.privateKey,\n address,\n };\n}\n\n// ── Tron (secp256k1 via BIP32, Base58Check) ─────────────────\n\nfunction deriveTron(mnemonic: string, account: number): DerivedKey {\n const seed = mnemonicToSeedSync(mnemonic);\n const hdkey = HDKey.fromMasterSeed(seed);\n const path = derivationPath(\"tron\", account);\n const child = hdkey.derive(path);\n if (!child.privateKey) throw new Error(\"Failed to derive Tron private key\");\n\n const address = publicKeyToTronAddress(child.publicKey!);\n return { privateKey: child.privateKey, address };\n}\n\nfunction publicKeyToTronAddress(compressedPubKey: Uint8Array): string {\n const uncompressed = ecc.pointCompress(compressedPubKey, false);\n const hash = keccak256(uncompressed.slice(1));\n const addressBytes = hash.slice(-20);\n\n // Tron: 0x41 prefix + 20 address bytes + 4-byte double-SHA256 checksum\n const prefixed = Buffer.concat([Buffer.from([0x41]), Buffer.from(addressBytes)]);\n const hash1 = createHash(\"sha256\").update(prefixed).digest();\n const hash2 = createHash(\"sha256\").update(hash1).digest();\n const raw = Buffer.concat([prefixed, hash2.slice(0, 4)]);\n\n return bs58.encode(raw);\n}\n"],"mappings":";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,eAAAA,oBAAmB;;;ACT5B,SAAS,KAAAC,UAAS;;;ACAlB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAElB,IAAM,WAAW,KAAK;AACtB,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAM,aAAa;AACnB,IAAM,gBAAgB,MAAM,OAAO;AAE5B,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,YAAY,EAAE,OAAO;AAAA,IACnB,QAAQ,EAAE,QAAQ,aAAa;AAAA,IAC/B,KAAK,EAAE,QAAQ,QAAQ;AAAA,IACvB,WAAW,EAAE,OAAO;AAAA,MAClB,GAAG,EAAE,OAAO;AAAA,MACZ,GAAG,EAAE,OAAO;AAAA,MACZ,GAAG,EAAE,OAAO;AAAA,IACd,CAAC;AAAA,IACD,MAAM,EAAE,OAAO;AAAA,IACf,IAAI,EAAE,OAAO;AAAA,IACb,KAAK,EAAE,OAAO;AAAA,EAChB,CAAC;AAAA,EACD,MAAM,EAAE,OAAO;AACjB,CAAC;AAGM,SAAS,QAAQ,MAAc,eAAsC;AAC1E,QAAM,OAAO,YAAY,EAAE;AAC3B,QAAM,SAAS,WAAW,eAAe,MAAM,YAAY;AAAA,IACzD,GAAG;AAAA,IAAU,GAAG;AAAA,IAAU,GAAG;AAAA,IAAU,QAAQ;AAAA,EACjD,CAAC;AACD,QAAM,KAAK,YAAY,EAAE;AACzB,QAAM,SAAS,eAAe,eAAe,QAAQ,EAAE;AAE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