const readline = require('readline'); const { execSync } = require('child_process'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); console.log("=== Proxy Bridge Keyring Setup ==="); rl.question('Enter your corporate username: ', (user) => { rl.question('Enter your corporate password: ', (pass) => { try { // Securely store the password in the Ubuntu Keyring using secret-tool // We use standard input to pass the password so it doesn't appear in process lists execSync(`secret-tool store --label="Proxy Bridge Credentials" service proxy-bridge account ${user}`, { input: pass }); // Store the username in a local config just so the bridge knows WHICH account to look up require('fs').writeFileSync('/opt/proxy-bridge/user.json', JSON.stringify({ username: user })); console.log("\n✅ Credentials successfully stored in the system keyring."); } catch (error) { console.error("\n❌ Failed to store credentials in keyring:", error.message); } rl.close(); }); // Hide typing for password (basic implementation) rl._writeToOutput = function _writeToOutput(stringToWrite) { if (rl.history.length === 0) rl.output.write("*"); }; });