@chriscode/hush 2.9.1 → 3.0.0
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/README.md +0 -1
- package/dist/cli.js +0 -17
- package/dist/commands/edit.js +1 -1
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +1 -16
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/types.d.ts +0 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/commands/decrypt.d.ts +0 -3
- package/dist/commands/decrypt.d.ts.map +0 -1
- package/dist/commands/decrypt.js +0 -71
package/README.md
CHANGED
|
@@ -193,7 +193,6 @@ targets:
|
|
|
193
193
|
| `hush skill` | Install AI skill | ✅ |
|
|
194
194
|
| `hush check` | Verify encryption sync | ✅ |
|
|
195
195
|
| `hush list` | List variables (shows values!) | ⚠️ |
|
|
196
|
-
| `hush decrypt` | Write secrets to disk (deprecated) | ⚠️ |
|
|
197
196
|
|
|
198
197
|
## AI-Native Design
|
|
199
198
|
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
|
-
import { decryptCommand } from './commands/decrypt.js';
|
|
5
4
|
import { encryptCommand } from './commands/encrypt.js';
|
|
6
5
|
import { editCommand } from './commands/edit.js';
|
|
7
6
|
import { setCommand } from './commands/set.js';
|
|
@@ -46,9 +45,6 @@ ${pc.bold('Commands:')}
|
|
|
46
45
|
${pc.bold('Debugging Commands:')}
|
|
47
46
|
resolve <target> Show what variables a target receives (AI-safe)
|
|
48
47
|
trace <key> Trace a variable through sources and targets (AI-safe)
|
|
49
|
-
|
|
50
|
-
${pc.bold('Deprecated Commands:')}
|
|
51
|
-
decrypt Write secrets to disk (unsafe - use 'run' instead)
|
|
52
48
|
|
|
53
49
|
${pc.bold('Options:')}
|
|
54
50
|
-e, --env <env> Environment: development or production (default: development)
|
|
@@ -304,19 +300,6 @@ async function main() {
|
|
|
304
300
|
case 'encrypt':
|
|
305
301
|
await encryptCommand({ root });
|
|
306
302
|
break;
|
|
307
|
-
case 'decrypt':
|
|
308
|
-
console.warn(pc.yellow('⚠️ Warning: "hush decrypt" is deprecated and writes unencrypted secrets to disk.'));
|
|
309
|
-
console.warn(pc.yellow(' Use "hush run -- <command>" instead for better security.'));
|
|
310
|
-
console.warn(pc.dim(' To suppress this warning, use "hush unsafe:decrypt"'));
|
|
311
|
-
console.warn('');
|
|
312
|
-
await decryptCommand({ root, env });
|
|
313
|
-
break;
|
|
314
|
-
case 'unsafe:decrypt':
|
|
315
|
-
console.warn(pc.red('⚠️ UNSAFE MODE: Writing unencrypted secrets to disk.'));
|
|
316
|
-
console.warn(pc.red(' These files will be readable by AI assistants and other tools.'));
|
|
317
|
-
console.warn('');
|
|
318
|
-
await decryptCommand({ root, env });
|
|
319
|
-
break;
|
|
320
303
|
case 'run':
|
|
321
304
|
await runCommand({ root, env, target, command: cmdArgs });
|
|
322
305
|
break;
|
package/dist/commands/edit.js
CHANGED
|
@@ -18,5 +18,5 @@ export async function editCommand(options) {
|
|
|
18
18
|
console.log(pc.dim('Changes will be encrypted on save'));
|
|
19
19
|
sopsEdit(encryptedPath);
|
|
20
20
|
console.log(pc.green('\nEdit complete'));
|
|
21
|
-
console.log(pc.dim('Run "hush
|
|
21
|
+
console.log(pc.dim('Run "hush run -- <command>" to use updated secrets'));
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/commands/skill.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/commands/skill.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmpChD,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CvE"}
|
package/dist/commands/skill.js
CHANGED
|
@@ -100,8 +100,8 @@ npx hush run -e production -- npm build # Production
|
|
|
100
100
|
| \`npx hush keys setup\` | Set up encryption keys | New team member |
|
|
101
101
|
|
|
102
102
|
### Commands to AVOID:
|
|
103
|
-
- \`hush decrypt\` - Writes plaintext to disk (security risk!)
|
|
104
103
|
- \`cat .env\` - Never read plaintext .env files directly
|
|
104
|
+
- \`hush list\` - Shows actual secret values (use \`hush inspect\` instead)
|
|
105
105
|
|
|
106
106
|
---
|
|
107
107
|
|
|
@@ -634,21 +634,6 @@ hush trace STRIPE_SECRET_KEY # Trace another variable
|
|
|
634
634
|
|
|
635
635
|
---
|
|
636
636
|
|
|
637
|
-
## Deprecated Commands (Avoid)
|
|
638
|
-
|
|
639
|
-
### hush decrypt / hush unsafe:decrypt ⚠️
|
|
640
|
-
|
|
641
|
-
**DEPRECATED:** Writes unencrypted secrets to disk, defeating the "encrypted at rest" model.
|
|
642
|
-
|
|
643
|
-
\`\`\`bash
|
|
644
|
-
hush decrypt # Writes plaintext .env files (avoid!)
|
|
645
|
-
hush unsafe:decrypt # Same, explicit unsafe mode
|
|
646
|
-
\`\`\`
|
|
647
|
-
|
|
648
|
-
Use \`hush run -- <command>\` instead.
|
|
649
|
-
|
|
650
|
-
---
|
|
651
|
-
|
|
652
637
|
## Quick Reference
|
|
653
638
|
|
|
654
639
|
| Command | Purpose |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { OutputFormat, Environment, Target, SourceFiles, HushConfig, EnvVar,
|
|
1
|
+
export type { OutputFormat, Environment, Target, SourceFiles, HushConfig, EnvVar, EncryptOptions, EditOptions, PushOptions, StatusOptions, InitOptions, ListOptions, } from './types.js';
|
|
2
2
|
export { DEFAULT_SOURCES, FORMAT_OUTPUT_FILES } from './types.js';
|
|
3
3
|
export { loadConfig, findConfigPath, validateConfig } from './config/loader.js';
|
|
4
4
|
export { parseEnvContent, parseEnvFile, varsToRecord, recordToVars } from './core/parse.js';
|
|
@@ -9,7 +9,6 @@ export { decrypt, encrypt, edit, isSopsInstalled, isAgeKeyConfigured } from './c
|
|
|
9
9
|
export { maskValue, maskVars, formatMaskedVar } from './core/mask.js';
|
|
10
10
|
export type { MaskedVar } from './core/mask.js';
|
|
11
11
|
export { formatVars, formatDotenv, formatWrangler, formatJson, formatShell } from './formats/index.js';
|
|
12
|
-
export { decryptCommand } from './commands/decrypt.js';
|
|
13
12
|
export { encryptCommand } from './commands/encrypt.js';
|
|
14
13
|
export { editCommand } from './commands/edit.js';
|
|
15
14
|
export { statusCommand } from './commands/status.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChH,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,6 @@ export { mergeVars } from './core/merge.js';
|
|
|
7
7
|
export { decrypt, encrypt, edit, isSopsInstalled, isAgeKeyConfigured } from './core/sops.js';
|
|
8
8
|
export { maskValue, maskVars, formatMaskedVar } from './core/mask.js';
|
|
9
9
|
export { formatVars, formatDotenv, formatWrangler, formatJson, formatShell } from './formats/index.js';
|
|
10
|
-
export { decryptCommand } from './commands/decrypt.js';
|
|
11
10
|
export { encryptCommand } from './commands/encrypt.js';
|
|
12
11
|
export { editCommand } from './commands/edit.js';
|
|
13
12
|
export { statusCommand } from './commands/status.js';
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAC7E,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,YAAY,CAAC;AAEvD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAC7E,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,YAAY,C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,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,WAAW,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,eAAe,EAAE,WAK7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAqBjF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decrypt.d.ts","sourceRoot":"","sources":["../../src/commands/decrypt.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAU,MAAM,aAAa,CAAC;AAO1D,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA2E3E"}
|
package/dist/commands/decrypt.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import pc from 'picocolors';
|
|
4
|
-
import { loadConfig } from '../config/loader.js';
|
|
5
|
-
import { filterVarsForTarget } from '../core/filter.js';
|
|
6
|
-
import { interpolateVars, getUnresolvedVars } from '../core/interpolate.js';
|
|
7
|
-
import { mergeVars } from '../core/merge.js';
|
|
8
|
-
import { parseEnvContent, parseEnvFile } from '../core/parse.js';
|
|
9
|
-
import { decrypt as sopsDecrypt } from '../core/sops.js';
|
|
10
|
-
import { formatVars } from '../formats/index.js';
|
|
11
|
-
import { FORMAT_OUTPUT_FILES } from '../types.js';
|
|
12
|
-
function getEncryptedPath(sourcePath) {
|
|
13
|
-
return sourcePath + '.encrypted';
|
|
14
|
-
}
|
|
15
|
-
export async function decryptCommand(options) {
|
|
16
|
-
const { root, env } = options;
|
|
17
|
-
const config = loadConfig(root);
|
|
18
|
-
console.log(pc.blue(`Decrypting for ${env}...`));
|
|
19
|
-
const sharedEncrypted = join(root, getEncryptedPath(config.sources.shared));
|
|
20
|
-
const envEncrypted = join(root, getEncryptedPath(config.sources[env]));
|
|
21
|
-
const localPath = join(root, '.env.local');
|
|
22
|
-
const varSources = [];
|
|
23
|
-
if (existsSync(sharedEncrypted)) {
|
|
24
|
-
const content = sopsDecrypt(sharedEncrypted);
|
|
25
|
-
const vars = parseEnvContent(content);
|
|
26
|
-
varSources.push(vars);
|
|
27
|
-
console.log(pc.dim(` ${config.sources.shared}.encrypted: ${vars.length} vars`));
|
|
28
|
-
}
|
|
29
|
-
if (existsSync(envEncrypted)) {
|
|
30
|
-
const content = sopsDecrypt(envEncrypted);
|
|
31
|
-
const vars = parseEnvContent(content);
|
|
32
|
-
varSources.push(vars);
|
|
33
|
-
console.log(pc.dim(` ${config.sources[env]}.encrypted: ${vars.length} vars`));
|
|
34
|
-
}
|
|
35
|
-
if (existsSync(localPath)) {
|
|
36
|
-
const vars = parseEnvFile(localPath);
|
|
37
|
-
varSources.push(vars);
|
|
38
|
-
console.log(pc.dim(` .env.local: ${vars.length} vars (overrides)`));
|
|
39
|
-
}
|
|
40
|
-
if (varSources.length === 0) {
|
|
41
|
-
console.error(pc.red('No encrypted files found'));
|
|
42
|
-
console.error(pc.dim(`Expected: ${sharedEncrypted}`));
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
const merged = mergeVars(...varSources);
|
|
46
|
-
const interpolated = interpolateVars(merged);
|
|
47
|
-
const unresolved = getUnresolvedVars(interpolated);
|
|
48
|
-
if (unresolved.length > 0) {
|
|
49
|
-
console.warn(pc.yellow(` Warning: ${unresolved.length} vars have unresolved references`));
|
|
50
|
-
}
|
|
51
|
-
console.log(pc.blue(`\nWriting to ${config.targets.length} targets:`));
|
|
52
|
-
for (const target of config.targets) {
|
|
53
|
-
const targetDir = join(root, target.path);
|
|
54
|
-
const filtered = filterVarsForTarget(interpolated, target);
|
|
55
|
-
if (filtered.length === 0) {
|
|
56
|
-
console.log(pc.dim(` ${target.path}/ - no matching vars, skipped`));
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const outputFilename = FORMAT_OUTPUT_FILES[target.format][env];
|
|
60
|
-
const outputPath = join(targetDir, outputFilename);
|
|
61
|
-
if (!existsSync(targetDir)) {
|
|
62
|
-
mkdirSync(targetDir, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
const content = formatVars(filtered, target.format);
|
|
65
|
-
writeFileSync(outputPath, content, 'utf-8');
|
|
66
|
-
const relativePath = target.path === '.' ? outputFilename : `${target.path}/${outputFilename}`;
|
|
67
|
-
console.log(pc.green(` ${relativePath}`) +
|
|
68
|
-
pc.dim(` (${target.format}, ${filtered.length} vars)`));
|
|
69
|
-
}
|
|
70
|
-
console.log(pc.green('\nDecryption complete'));
|
|
71
|
-
}
|