lsh-framework 0.5.6 → 0.5.7

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.
@@ -45,14 +45,30 @@ export class SecretsManager {
45
45
  * Decrypt a value
46
46
  */
47
47
  decrypt(text) {
48
- const parts = text.split(':');
49
- const iv = Buffer.from(parts[0], 'hex');
50
- const encryptedText = parts[1];
51
- const key = Buffer.from(this.encryptionKey, 'hex');
52
- const decipher = crypto.createDecipheriv('aes-256-cbc', key.slice(0, 32), iv);
53
- let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
54
- decrypted += decipher.final('utf8');
55
- return decrypted;
48
+ try {
49
+ const parts = text.split(':');
50
+ if (parts.length !== 2) {
51
+ throw new Error('Invalid encrypted format');
52
+ }
53
+ const iv = Buffer.from(parts[0], 'hex');
54
+ const encryptedText = parts[1];
55
+ const key = Buffer.from(this.encryptionKey, 'hex');
56
+ const decipher = crypto.createDecipheriv('aes-256-cbc', key.slice(0, 32), iv);
57
+ let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
58
+ decrypted += decipher.final('utf8');
59
+ return decrypted;
60
+ }
61
+ catch (error) {
62
+ if (error.message.includes('bad decrypt') || error.message.includes('wrong final block length')) {
63
+ throw new Error('Decryption failed. This usually means:\n' +
64
+ ' 1. You need to set LSH_SECRETS_KEY environment variable\n' +
65
+ ' 2. The key must match the one used during encryption\n' +
66
+ ' 3. Generate a shared key with: lsh secrets key\n' +
67
+ ' 4. Add it to your .env: LSH_SECRETS_KEY=<key>\n' +
68
+ '\nOriginal error: ' + error.message);
69
+ }
70
+ throw error;
71
+ }
56
72
  }
57
73
  /**
58
74
  * Parse .env file into key-value pairs
@@ -100,6 +116,13 @@ export class SecretsManager {
100
116
  if (!fs.existsSync(envFilePath)) {
101
117
  throw new Error(`File not found: ${envFilePath}`);
102
118
  }
119
+ // Warn if using default key
120
+ if (!process.env.LSH_SECRETS_KEY) {
121
+ logger.warn('⚠️ Warning: No LSH_SECRETS_KEY set. Using machine-specific key.');
122
+ logger.warn(' To share secrets across machines, generate a key with: lsh secrets key');
123
+ logger.warn(' Then add LSH_SECRETS_KEY=<key> to your .env on all machines');
124
+ console.log();
125
+ }
103
126
  logger.info(`Pushing ${envFilePath} to Supabase (${environment})...`);
104
127
  const content = fs.readFileSync(envFilePath, 'utf8');
105
128
  const env = this.parseEnvFile(content);
@@ -41,12 +41,18 @@ export async function init_secrets(program) {
41
41
  });
42
42
  // List environments
43
43
  secretsCmd
44
- .command('list')
44
+ .command('list [environment]')
45
45
  .alias('ls')
46
- .description('List all stored environments')
47
- .action(async () => {
46
+ .description('List all stored environments or show secrets for specific environment')
47
+ .action(async (environment) => {
48
48
  try {
49
49
  const manager = new SecretsManager();
50
+ // If environment specified, show secrets for that environment
51
+ if (environment) {
52
+ await manager.show(environment);
53
+ return;
54
+ }
55
+ // Otherwise, list all environments
50
56
  const envs = await manager.listEnvironments();
51
57
  if (envs.length === 0) {
52
58
  console.log('No environments found. Push your first .env with: lsh secrets push');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "A powerful, extensible shell with advanced job management, database persistence, and modern CLI features",
5
5
  "main": "dist/app.js",
6
6
  "bin": {