@envsave/cli 1.0.39 → 1.0.40
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/cli.js +35 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -259,6 +259,7 @@ __export(exports_vault, {
|
|
|
259
259
|
showSecret: () => showSecret,
|
|
260
260
|
setSecret: () => setSecret,
|
|
261
261
|
searchKeys: () => searchKeys,
|
|
262
|
+
revealKeysByPattern: () => revealKeysByPattern,
|
|
262
263
|
revealKey: () => revealKey,
|
|
263
264
|
listKeys: () => listKeys,
|
|
264
265
|
initVault: () => initVault,
|
|
@@ -573,6 +574,22 @@ function revealKey(cleanName, password) {
|
|
|
573
574
|
const opaque = computeOpaqueName(vault.hmacSeed, cleanName, sshKeyContent);
|
|
574
575
|
return opaque in vault.secrets ? opaque : undefined;
|
|
575
576
|
}
|
|
577
|
+
function revealKeysByPattern(patterns, password) {
|
|
578
|
+
const vault = readMainVault(password);
|
|
579
|
+
const sshKeyContent = loadSshKey(vault);
|
|
580
|
+
writeSessionCache(vault.secrets, vault.registry);
|
|
581
|
+
return patterns.map((pattern) => {
|
|
582
|
+
const lower = pattern.toLowerCase();
|
|
583
|
+
const matchingNames = vault.registry.filter((k) => k.toLowerCase().includes(lower));
|
|
584
|
+
return {
|
|
585
|
+
pattern,
|
|
586
|
+
matches: matchingNames.map((name) => ({
|
|
587
|
+
name,
|
|
588
|
+
opaque: computeOpaqueName(vault.hmacSeed, name, sshKeyContent)
|
|
589
|
+
}))
|
|
590
|
+
};
|
|
591
|
+
});
|
|
592
|
+
}
|
|
576
593
|
function getSecretFromCache(opaqueKey) {
|
|
577
594
|
checkRateLimit();
|
|
578
595
|
const cache = readSessionCache();
|
|
@@ -893,7 +910,7 @@ Usage:
|
|
|
893
910
|
envsave set <key> <value> Add/update a secret (outputs opaque key)
|
|
894
911
|
envsave get <opaque_key> Retrieve a value (no password needed)
|
|
895
912
|
envsave show <key> Show real value by key name (password required)
|
|
896
|
-
envsave reveal <
|
|
913
|
+
envsave reveal <keyword> [keyword2]... Show opaque key(s) for any name matching keyword (password required)
|
|
897
914
|
envsave delete <key> Remove a secret (password required)
|
|
898
915
|
envsave search <keyword> Search keys matching keyword (no password)
|
|
899
916
|
envsave scan [dir] Scan project for env variable usage
|
|
@@ -1052,27 +1069,31 @@ Use 'envsave reveal <KEY>' to get the opaque key for each secret.`);
|
|
|
1052
1069
|
break;
|
|
1053
1070
|
}
|
|
1054
1071
|
case "reveal": {
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
console.error("Usage: envsave reveal <
|
|
1072
|
+
const patterns = args.slice(1);
|
|
1073
|
+
if (patterns.length === 0) {
|
|
1074
|
+
console.error("Usage: envsave reveal <keyword> [keyword2]...");
|
|
1058
1075
|
process.exit(1);
|
|
1059
1076
|
}
|
|
1060
1077
|
const password = await requirePassword();
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1078
|
+
const results = revealKeysByPattern(patterns, password);
|
|
1079
|
+
let totalMatches = 0;
|
|
1080
|
+
let notFoundPatterns = 0;
|
|
1081
|
+
for (const { pattern, matches } of results) {
|
|
1082
|
+
if (matches.length === 0) {
|
|
1083
|
+
console.error(`No keys matching '${pattern}'.`);
|
|
1084
|
+
notFoundPatterns++;
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
for (const { name, opaque } of matches) {
|
|
1065
1088
|
console.log(`
|
|
1066
|
-
${
|
|
1089
|
+
${name} → ${opaque}`);
|
|
1067
1090
|
console.log(` envsave.get("${opaque}")`);
|
|
1068
|
-
|
|
1069
|
-
console.error(`Secret '${key}' not found.`);
|
|
1070
|
-
notFound++;
|
|
1091
|
+
totalMatches++;
|
|
1071
1092
|
}
|
|
1072
1093
|
}
|
|
1073
|
-
if (
|
|
1094
|
+
if (totalMatches > 0)
|
|
1074
1095
|
console.log();
|
|
1075
|
-
if (
|
|
1096
|
+
if (notFoundPatterns === patterns.length)
|
|
1076
1097
|
process.exit(1);
|
|
1077
1098
|
break;
|
|
1078
1099
|
}
|