@xaidenlabs/uso 1.1.70 → 1.1.72

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaidenlabs/uso",
3
- "version": "1.1.70",
3
+ "version": "1.1.72",
4
4
  "description": "Universal Solana Development Toolchain. Native or Stealth WSL Mode. Build, test, and deploy without the friction.",
5
5
  "bin": {
6
6
  "uso": "bin/index.js"
@@ -0,0 +1,32 @@
1
+ const shell = require("shelljs");
2
+ const os = require("os");
3
+ const { log } = require("../utils/logger");
4
+ const { isStealthMode } = require("../utils/stealth");
5
+ const { runWsl } = require("../utils/wsl-bridge");
6
+
7
+ const address = async () => {
8
+ const stealth = isStealthMode();
9
+
10
+ try {
11
+ let result;
12
+
13
+ if (stealth.enabled) {
14
+ // Run solana address inside WSL
15
+ result = runWsl("solana address", { distro: stealth.distro });
16
+ } else {
17
+ // Run solana address natively
18
+ result = shell.exec("solana address", { silent: true });
19
+ }
20
+
21
+ if (result.code === 0) {
22
+ log.success(result.stdout.trim());
23
+ } else {
24
+ const errorMsg = result.stderr || result.stdout;
25
+ log.error(errorMsg.trim());
26
+ }
27
+ } catch (e) {
28
+ log.error(`Error getting wallet address: ${e.message}`);
29
+ }
30
+ };
31
+
32
+ module.exports = { address };
@@ -331,6 +331,35 @@ const uninstall = async (component) => {
331
331
  }
332
332
  }
333
333
 
334
+ // 3.5 Remove WSL Distro (if stealth mode is active)
335
+ if (stealth.enabled && os.platform() === "win32") {
336
+ const removeWslDistro = await askQuestion(
337
+ "\n🐧 Remove WSL Ubuntu distro completely? (y/N): ",
338
+ );
339
+ if (removeWslDistro.toLowerCase() === "y") {
340
+ log.warn(
341
+ `āš ļø This will completely remove the ${stealth.distro} distro and all its data.`,
342
+ );
343
+ const confirmWslRemoval = await askQuestion(
344
+ "šŸ’„ Type 'REMOVE WSL' to confirm distro removal: ",
345
+ );
346
+ if (confirmWslRemoval === "REMOVE WSL") {
347
+ log.info(`Unregistering ${stealth.distro} distro...`);
348
+ const unregisterCmd = `wsl --unregister ${stealth.distro}`;
349
+ const result = runOrElevate(
350
+ unregisterCmd,
351
+ `Unregister WSL distro ${stealth.distro}`,
352
+ { enabled: false, distro: stealth.distro },
353
+ );
354
+ if (result) {
355
+ log.success(`āœ… ${stealth.distro} distro removed.`);
356
+ }
357
+ } else {
358
+ log.info("WSL distro removal cancelled.");
359
+ }
360
+ }
361
+ }
362
+
334
363
  // 4. WALLET REMOVAL (DANGER)
335
364
  const walletPath = path.join(os.homedir(), ".config", "solana", "id.json");
336
365
  const wslWalletPath = "$HOME/.config/solana/id.json";
@@ -1,23 +1,34 @@
1
- const os = require('os');
2
- const shell = require('shelljs');
3
- const path = require('path');
4
- const fs = require('fs');
5
- const readline = require('readline');
6
- const { log } = require('./logger');
1
+ const os = require("os");
2
+ const shell = require("shelljs");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+ const readline = require("readline");
6
+ const { log } = require("./logger");
7
+ const { isStealthMode } = require("./stealth");
8
+ const { runWsl } = require("./wsl-bridge");
7
9
 
8
10
  const resolveSolanaKeygen = () => {
9
- // 1. Try PATH first
10
- if (shell.which('solana-keygen')) return 'solana-keygen';
11
-
12
- // 2. Try default Windows path
13
- if (os.platform() === 'win32') {
14
- const home = os.homedir();
15
- const defaultPath = path.join(home, '.local', 'share', 'solana', 'install', 'active_release', 'bin', 'solana-keygen.exe');
16
- if (fs.existsSync(defaultPath)) return `"${defaultPath}"`;
17
- }
11
+ // 1. Try PATH first
12
+ if (shell.which("solana-keygen")) return "solana-keygen";
13
+
14
+ // 2. Try default Windows path
15
+ if (os.platform() === "win32") {
16
+ const home = os.homedir();
17
+ const defaultPath = path.join(
18
+ home,
19
+ ".local",
20
+ "share",
21
+ "solana",
22
+ "install",
23
+ "active_release",
24
+ "bin",
25
+ "solana-keygen.exe",
26
+ );
27
+ if (fs.existsSync(defaultPath)) return `"${defaultPath}"`;
28
+ }
18
29
 
19
- // Fallback
20
- return 'solana-keygen';
30
+ // Fallback
31
+ return "solana-keygen";
21
32
  };
22
33
 
23
34
  /**
@@ -25,62 +36,118 @@ const resolveSolanaKeygen = () => {
25
36
  * Returns true if wallet exists (or was created), false if user declined.
26
37
  */
27
38
  const ensureWalletInteractive = async () => {
28
- const walletDir = path.join(os.homedir(), '.config', 'solana');
29
- const walletPath = path.join(walletDir, 'id.json');
39
+ const stealth = isStealthMode();
30
40
 
41
+ // When in stealth mode, wallet is in WSL home
42
+ let walletDir, walletPath;
43
+ if (stealth.enabled) {
44
+ walletDir = "$HOME/.config/solana";
45
+ walletPath = "$HOME/.config/solana/id.json";
46
+ } else {
47
+ walletDir = path.join(os.homedir(), ".config", "solana");
48
+ walletPath = path.join(walletDir, "id.json");
49
+ }
50
+
51
+ // Check if wallet exists
52
+ if (stealth.enabled) {
53
+ // Check inside WSL
54
+ const checkWallet = runWsl(
55
+ 'test -f $HOME/.config/solana/id.json && echo "exists"',
56
+ { distro: stealth.distro },
57
+ );
58
+ if (checkWallet.code === 0 && checkWallet.stdout.includes("exists")) {
59
+ log.info("šŸ”‘ Wallet found (in WSL).");
60
+ return true;
61
+ }
62
+ } else {
31
63
  if (fs.existsSync(walletPath)) {
32
- log.info("šŸ”‘ Wallet found.");
33
- return true;
64
+ log.info("šŸ”‘ Wallet found.");
65
+ return true;
34
66
  }
67
+ }
68
+
69
+ const rl = readline.createInterface({
70
+ input: process.stdin,
71
+ output: process.stdout,
72
+ });
73
+
74
+ return new Promise((resolve) => {
75
+ log.info("");
76
+ log.warn("āš ļø No Solana wallet found.");
77
+ rl.question(
78
+ "šŸ‘‰ Do you want to generate a new Solana wallet? [y/N] ",
79
+ (answer) => {
80
+ rl.close();
81
+ if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") {
82
+ log.info("šŸ”‘ Generating wallet...");
83
+
84
+ try {
85
+ if (stealth.enabled) {
86
+ // Create wallet inside WSL
87
+ const mkdirCmd = "mkdir -p $HOME/.config/solana";
88
+ runWsl(mkdirCmd, { distro: stealth.distro });
35
89
 
36
- const rl = readline.createInterface({
37
- input: process.stdin,
38
- output: process.stdout
39
- });
40
-
41
- return new Promise((resolve) => {
42
- log.info("");
43
- log.warn("āš ļø No Solana wallet found.");
44
- rl.question("šŸ‘‰ Do you want to generate a new Solana wallet? [y/N] ", (answer) => {
45
- rl.close();
46
- if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
47
- log.info("šŸ”‘ Generating wallet...");
48
- if (!fs.existsSync(walletDir)) fs.mkdirSync(walletDir, { recursive: true });
49
-
50
- const keygenCmd = resolveSolanaKeygen();
51
-
52
- // Use spawnSync to allow interactive input (passphrase)
53
- const { spawnSync } = require('child_process');
54
-
55
- // We need to strip quotes for spawn
56
- let cmd = keygenCmd;
57
- if (cmd.startsWith('"') && cmd.endsWith('"')) cmd = cmd.slice(1, -1);
58
-
59
- try {
60
- // We use 'new' command which might prompt for passphrase
61
- spawnSync(cmd, ['new', '--outfile', walletPath], { stdio: 'inherit', shell: true });
62
-
63
- if (fs.existsSync(walletPath)) {
64
- log.success("āœ… Wallet generated.");
65
- resolve(true);
66
- } else {
67
- // User might have cancelled via Ctrl+C in the subprocess
68
- log.warn("āŒ Creation cancelled or failed.");
69
- resolve(false);
70
- }
71
- } catch (e) {
72
- log.error("āŒ Failed to generate wallet: " + e.message);
73
- resolve(false);
74
- }
90
+ // Run solana-keygen inside WSL with interactive mode
91
+ const { spawnSync } = require("child_process");
92
+ const wslCmd = `mkdir -p "$HOME/.config/solana" && solana-keygen new --outfile "$HOME/.config/solana/id.json"`;
93
+ const result = spawnSync("wsl", ["-d", stealth.distro, "-e", "bash", "-c", wslCmd], { stdio: "inherit" });
94
+
95
+ // Verify wallet was created in WSL
96
+ const verifyCmd = runWsl(
97
+ 'test -f $HOME/.config/solana/id.json && echo "exists"',
98
+ { distro: stealth.distro },
99
+ );
100
+ if (verifyCmd.code === 0 && verifyCmd.stdout.includes("exists")) {
101
+ log.success("āœ… Wallet generated (in WSL).");
102
+ resolve(true);
103
+ } else {
104
+ log.warn("āŒ Creation cancelled or failed.");
105
+ resolve(false);
106
+ }
75
107
  } else {
76
- log.info(" Skipping wallet generation.");
108
+ // Create wallet natively on Windows
109
+ if (!fs.existsSync(walletDir))
110
+ fs.mkdirSync(walletDir, { recursive: true });
111
+
112
+ const keygenCmd = resolveSolanaKeygen();
113
+
114
+ // Use spawnSync to allow interactive input (passphrase)
115
+ const { spawnSync } = require("child_process");
116
+
117
+ // We need to strip quotes for spawn
118
+ let cmd = keygenCmd;
119
+ if (cmd.startsWith('"') && cmd.endsWith('"'))
120
+ cmd = cmd.slice(1, -1);
121
+
122
+ // We use 'new' command which might prompt for passphrase
123
+ spawnSync(cmd, ["new", "--outfile", walletPath], {
124
+ stdio: "inherit",
125
+ shell: true,
126
+ });
127
+
128
+ if (fs.existsSync(walletPath)) {
129
+ log.success("āœ… Wallet generated.");
130
+ resolve(true);
131
+ } else {
132
+ // User might have cancelled via Ctrl+C in the subprocess
133
+ log.warn("āŒ Creation cancelled or failed.");
77
134
  resolve(false);
135
+ }
78
136
  }
79
- });
80
- });
137
+ } catch (e) {
138
+ log.error("āŒ Failed to generate wallet: " + e.message);
139
+ resolve(false);
140
+ }
141
+ } else {
142
+ log.info(" Skipping wallet generation.");
143
+ resolve(false);
144
+ }
145
+ },
146
+ );
147
+ });
81
148
  };
82
149
 
83
150
  module.exports = {
84
- resolveSolanaKeygen,
85
- ensureWalletInteractive
151
+ resolveSolanaKeygen,
152
+ ensureWalletInteractive,
86
153
  };