cloakx
Version:
Cloakx is a secure, lightweight CLI tool to manage your development secrets locally — no cloud, no hassle. Store, retrieve, and manage secrets across projects with encryption and ease. 🔐 Perfect for solo devs, indie hackers, and teams who value speed, si
39 lines (38 loc) • 1.43 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCommand = getCommand;
// commands/get.ts
const commander_1 = require("commander");
const fs_1 = __importDefault(require("fs"));
const crypto_1 = require("../utils/crypto");
const session_1 = require("../utils/session");
const paths_1 = require("../config/paths");
function getCommand() {
const cmd = new commander_1.Command('get');
cmd.argument('<key>', 'Key to retrieve')
.description('Retrieve a decrypted value from the vault')
.action((key) => {
try {
const password = (0, session_1.getSessionPassword)();
if (!fs_1.default.existsSync(paths_1.vaultPath)) {
console.log('🔐 Vault is empty.');
return;
}
const data = JSON.parse(fs_1.default.readFileSync(paths_1.vaultPath, 'utf-8'));
const encrypted = data[key];
if (!encrypted) {
console.log(`❌ No such key: ${key}`);
return;
}
const decrypted = (0, crypto_1.decrypt)(encrypted, password);
console.log(`${key}: ${decrypted}`);
}
catch (err) {
console.error(`❌ ${err.message}`);
}
});
return cmd;
}