@envsave/cli 1.0.38 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +41 -19
  2. 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,
@@ -514,7 +515,7 @@ function initVault(password, options) {
514
515
  const hmacSeed = randomBytes2(32).toString("hex");
515
516
  const sshKeyContent = options?.sshKeyPath ? readFileSync3(options.sshKeyPath, "utf8") : undefined;
516
517
  const vault = {
517
- version: 4,
518
+ version: 5,
518
519
  hmacSeed,
519
520
  sshKeyPath: options?.sshKeyPath,
520
521
  secrets: {},
@@ -544,7 +545,8 @@ function setSecret(key, value, password) {
544
545
  const vault = readMainVault(password);
545
546
  const sshKeyContent = loadSshKey(vault);
546
547
  const opaque = computeOpaqueName(vault.hmacSeed, key, sshKeyContent);
547
- if (!(opaque in vault.secrets) && !hasValidLicense()) {
548
+ const updated = opaque in vault.secrets;
549
+ if (!updated && !hasValidLicense()) {
548
550
  if (vault.registry.length >= FREE_TIER_MAX_SECRETS) {
549
551
  throw new Error(`Free tier limit: max ${FREE_TIER_MAX_SECRETS} secrets. Run 'envsave activate <token>' to unlock unlimited secrets.
550
552
  Get your license at https://api.envsave.com`);
@@ -556,7 +558,7 @@ Get your license at https://api.envsave.com`);
556
558
  }
557
559
  writeMainVault(vault, password);
558
560
  writeSessionCache(vault.secrets, vault.registry);
559
- return opaque;
561
+ return { opaque, updated };
560
562
  }
561
563
  function showSecret(cleanName, password) {
562
564
  const vault = readMainVault(password);
@@ -572,6 +574,22 @@ function revealKey(cleanName, password) {
572
574
  const opaque = computeOpaqueName(vault.hmacSeed, cleanName, sshKeyContent);
573
575
  return opaque in vault.secrets ? opaque : undefined;
574
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
+ }
575
593
  function getSecretFromCache(opaqueKey) {
576
594
  checkRateLimit();
577
595
  const cache = readSessionCache();
@@ -892,7 +910,7 @@ Usage:
892
910
  envsave set <key> <value> Add/update a secret (outputs opaque key)
893
911
  envsave get <opaque_key> Retrieve a value (no password needed)
894
912
  envsave show <key> Show real value by key name (password required)
895
- envsave reveal <key> [key2] [key3]... Show opaque key name(s) (password required)
913
+ envsave reveal <keyword> [keyword2]... Show opaque key(s) for any name matching keyword (password required)
896
914
  envsave delete <key> Remove a secret (password required)
897
915
  envsave search <keyword> Search keys matching keyword (no password)
898
916
  envsave scan [dir] Scan project for env variable usage
@@ -1041,9 +1059,9 @@ Use 'envsave reveal <KEY>' to get the opaque key for each secret.`);
1041
1059
  process.exit(1);
1042
1060
  }
1043
1061
  const password = await requirePassword();
1044
- const opaque = setSecret(key, value, password);
1062
+ const { opaque, updated } = setSecret(key, value, password);
1045
1063
  console.log(`
1046
- ${key} → ${opaque}
1064
+ ${updated ? "Updated" : "Added"}: ${key} → ${opaque}
1047
1065
  `);
1048
1066
  console.log(` Use this in your code to access ${key}:`);
1049
1067
  console.log(` envsave.get("${opaque}")
@@ -1051,27 +1069,31 @@ Use 'envsave reveal <KEY>' to get the opaque key for each secret.`);
1051
1069
  break;
1052
1070
  }
1053
1071
  case "reveal": {
1054
- const keys = args.slice(1);
1055
- if (keys.length === 0) {
1056
- console.error("Usage: envsave reveal <key> [key2] [key3]...");
1072
+ const patterns = args.slice(1);
1073
+ if (patterns.length === 0) {
1074
+ console.error("Usage: envsave reveal <keyword> [keyword2]...");
1057
1075
  process.exit(1);
1058
1076
  }
1059
1077
  const password = await requirePassword();
1060
- let notFound = 0;
1061
- for (const key of keys) {
1062
- const opaque = revealKey(key, password);
1063
- if (opaque) {
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) {
1064
1088
  console.log(`
1065
- ${key} → ${opaque}`);
1089
+ ${name} → ${opaque}`);
1066
1090
  console.log(` envsave.get("${opaque}")`);
1067
- } else {
1068
- console.error(`Secret '${key}' not found.`);
1069
- notFound++;
1091
+ totalMatches++;
1070
1092
  }
1071
1093
  }
1072
- if (keys.length > 1 && notFound === 0)
1094
+ if (totalMatches > 0)
1073
1095
  console.log();
1074
- if (notFound > 0 && notFound === keys.length)
1096
+ if (notFoundPatterns === patterns.length)
1075
1097
  process.exit(1);
1076
1098
  break;
1077
1099
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envsave/cli",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Local secret vault for LLM-safe environments — encrypted secrets that agents can't bulk-discover",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",