lsh-framework 0.6.0 → 0.8.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 +493 -245
- package/dist/cli.js +191 -45
- package/dist/commands/self.js +59 -3
- package/dist/commands/theme.js +2 -1
- package/dist/lib/base-job-manager.js +2 -1
- package/dist/lib/job-manager.js +55 -7
- package/dist/lib/lshrc-init.js +3 -1
- package/dist/lib/secrets-manager.js +161 -11
- package/dist/services/lib/lib.js +3 -1
- package/dist/services/secrets/secrets.js +155 -4
- package/package.json +26 -22
package/README.md
CHANGED
|
@@ -1,190 +1,452 @@
|
|
|
1
|
-
# LSH -
|
|
1
|
+
# LSH - Encrypted Secrets Manager with Automated Rotation
|
|
2
2
|
|
|
3
|
-
`lsh` is
|
|
3
|
+
`lsh` is a powerful **encrypted secrets manager** that syncs your `.env` files across all development environments with AES-256 encryption. Built on a robust shell framework with daemon scheduling, it enables **automatic secret rotation**, team collaboration, and seamless multi-environment management.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Never copy .env files again.** Push once, pull anywhere, rotate automatically.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **POSIX Shell Compatibility** - Standard shell syntax and builtins
|
|
9
|
-
- **ZSH-Compatible Features** - Extended globbing, parameter expansion, associative arrays
|
|
10
|
-
- **Interactive Terminal UI** - Built with React/Ink for rich terminal experiences
|
|
11
|
-
- **Command History** - Persistent history with search and replay
|
|
12
|
-
- **Tab Completion** - Intelligent completion system
|
|
7
|
+
## Why LSH?
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
- **Persistent Job Daemon** - Background daemon for reliable job execution
|
|
16
|
-
- **Cron-Style Scheduling** - Schedule jobs with cron expressions
|
|
17
|
-
- **Job Control** - Start, stop, monitor, and manage background jobs
|
|
18
|
-
- **Job Registry** - Centralized job tracking and persistence
|
|
9
|
+
Traditional secret management tools are either too complex, too expensive, or require vendor lock-in. LSH gives you:
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
11
|
+
- **Encrypted sync** across all your machines using Supabase/PostgreSQL
|
|
12
|
+
- **Automatic rotation** with built-in daemon scheduling
|
|
13
|
+
- **Team collaboration** with shared encryption keys
|
|
14
|
+
- **Multi-environment** support (dev/staging/prod)
|
|
15
|
+
- **Self-hosted** - your data, your infrastructure
|
|
16
|
+
- **Free & Open Source** - no per-seat pricing
|
|
17
|
+
|
|
18
|
+
**Plus, you get a complete shell automation platform as a bonus.**
|
|
19
|
+
|
|
20
|
+
## Quick Start (30 seconds)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 1. Install
|
|
24
|
+
npm install -g gwicho38-lsh
|
|
25
|
+
|
|
26
|
+
# 2. Generate encryption key
|
|
27
|
+
lsh lib secrets key
|
|
28
|
+
# Add the output to your .env:
|
|
29
|
+
# LSH_SECRETS_KEY=<your-key>
|
|
30
|
+
|
|
31
|
+
# 3. Configure Supabase (free tier works!)
|
|
32
|
+
# Add to .env:
|
|
33
|
+
# SUPABASE_URL=https://your-project.supabase.co
|
|
34
|
+
# SUPABASE_ANON_KEY=<your-anon-key>
|
|
35
|
+
|
|
36
|
+
# 4. Push your secrets
|
|
37
|
+
lsh lib secrets push
|
|
38
|
+
|
|
39
|
+
# 5. Pull on any other machine
|
|
40
|
+
lsh lib secrets pull
|
|
25
41
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
# Done! Your secrets are synced.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Core Features
|
|
46
|
+
|
|
47
|
+
### 🔐 Secrets Management
|
|
48
|
+
|
|
49
|
+
- **AES-256 Encryption** - Military-grade encryption for all secrets
|
|
50
|
+
- **Multi-Environment** - Separate configs for dev, staging, and production
|
|
51
|
+
- **Team Sync** - Share encryption keys securely with your team
|
|
52
|
+
- **Masked Viewing** - View secrets safely without exposing full values
|
|
53
|
+
- **Automatic Backup** - Never lose your `.env` files
|
|
54
|
+
- **Version Control** - Track changes to your secrets over time
|
|
55
|
+
|
|
56
|
+
### 🔄 Automatic Rotation (Unique Feature!)
|
|
57
|
+
|
|
58
|
+
Use the built-in daemon to automatically rotate secrets on a schedule:
|
|
31
59
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
60
|
+
```bash
|
|
61
|
+
# Schedule API key rotation every 30 days
|
|
62
|
+
lsh lib cron add \
|
|
63
|
+
--name "rotate-api-keys" \
|
|
64
|
+
--schedule "0 0 1 * *" \
|
|
65
|
+
--command "./scripts/rotate-keys.sh && lsh lib secrets push"
|
|
66
|
+
|
|
67
|
+
# Or use interval-based scheduling
|
|
68
|
+
lsh lib cron add \
|
|
69
|
+
--name "sync-secrets" \
|
|
70
|
+
--interval 3600 \
|
|
71
|
+
--command "lsh lib secrets pull && ./scripts/reload-app.sh"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**No other secrets manager has this built-in!** Most require complex integrations with cron or external tools.
|
|
75
|
+
|
|
76
|
+
### 👥 Team Collaboration
|
|
77
|
+
|
|
78
|
+
**Setup (One Time):**
|
|
79
|
+
```bash
|
|
80
|
+
# Project lead:
|
|
81
|
+
lsh lib secrets key # Generate shared key
|
|
82
|
+
lsh lib secrets push --env prod # Push team secrets
|
|
83
|
+
# Share LSH_SECRETS_KEY via 1Password
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Team members:**
|
|
87
|
+
```bash
|
|
88
|
+
# 1. Get key from 1Password
|
|
89
|
+
# 2. Add to .env
|
|
90
|
+
echo "LSH_SECRETS_KEY=<shared-key>" > .env
|
|
91
|
+
|
|
92
|
+
# 3. Pull secrets
|
|
93
|
+
lsh lib secrets pull --env prod
|
|
94
|
+
|
|
95
|
+
# 4. Start coding!
|
|
96
|
+
npm start
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 🌍 Multi-Environment Workflow
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Development
|
|
103
|
+
lsh lib secrets push --env dev
|
|
104
|
+
|
|
105
|
+
# Staging (different values)
|
|
106
|
+
lsh lib secrets push --file .env.staging --env staging
|
|
107
|
+
|
|
108
|
+
# Production (super secret)
|
|
109
|
+
lsh lib secrets push --file .env.production --env prod
|
|
110
|
+
|
|
111
|
+
# Pull whatever you need
|
|
112
|
+
lsh lib secrets pull --env dev # for local dev
|
|
113
|
+
lsh lib secrets pull --env staging # for testing
|
|
114
|
+
lsh lib secrets pull --env prod # for production debugging
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Secrets Commands
|
|
118
|
+
|
|
119
|
+
| Command | Description |
|
|
120
|
+
|---------|-------------|
|
|
121
|
+
| `lsh lib secrets push` | Upload .env to encrypted cloud storage |
|
|
122
|
+
| `lsh lib secrets pull` | Download .env from cloud storage |
|
|
123
|
+
| `lsh lib secrets list` | List all stored environments |
|
|
124
|
+
| `lsh lib secrets show` | View secrets (masked) |
|
|
125
|
+
| `lsh lib secrets key` | Generate encryption key |
|
|
126
|
+
| `lsh lib secrets create` | Create new .env file |
|
|
127
|
+
| `lsh lib secrets delete` | Delete .env file (with confirmation) |
|
|
128
|
+
|
|
129
|
+
See the complete guide: [SECRETS_GUIDE.md](SECRETS_GUIDE.md)
|
|
37
130
|
|
|
38
131
|
## Installation
|
|
39
132
|
|
|
40
133
|
### Prerequisites
|
|
41
|
-
- Node.js 18.0
|
|
42
|
-
- npm
|
|
43
|
-
-
|
|
44
|
-
- Redis (optional, for caching)
|
|
45
|
-
|
|
46
|
-
### Quick Start
|
|
134
|
+
- Node.js 20.18.0 or higher
|
|
135
|
+
- npm 10.0.0 or higher
|
|
136
|
+
- Supabase account (free tier works) OR PostgreSQL database
|
|
47
137
|
|
|
48
|
-
|
|
138
|
+
### Install from npm
|
|
49
139
|
|
|
50
140
|
```bash
|
|
51
141
|
npm install -g gwicho38-lsh
|
|
52
142
|
```
|
|
53
143
|
|
|
54
|
-
|
|
144
|
+
### Verify installation
|
|
55
145
|
|
|
56
146
|
```bash
|
|
57
147
|
lsh --version
|
|
58
148
|
lsh self version
|
|
59
149
|
```
|
|
60
150
|
|
|
61
|
-
|
|
151
|
+
### Initial Setup
|
|
62
152
|
|
|
63
|
-
|
|
153
|
+
```bash
|
|
154
|
+
# 1. Generate encryption key
|
|
155
|
+
lsh lib secrets key
|
|
156
|
+
|
|
157
|
+
# 2. Create .env file
|
|
158
|
+
cat > .env <<EOF
|
|
159
|
+
# Supabase (for encrypted storage)
|
|
160
|
+
SUPABASE_URL=https://your-project.supabase.co
|
|
161
|
+
SUPABASE_ANON_KEY=your-anon-key
|
|
162
|
+
|
|
163
|
+
# Encryption key (generated above)
|
|
164
|
+
LSH_SECRETS_KEY=your-key-here
|
|
165
|
+
|
|
166
|
+
# Your application secrets
|
|
167
|
+
DATABASE_URL=postgresql://localhost/mydb
|
|
168
|
+
API_KEY=your-api-key
|
|
169
|
+
EOF
|
|
170
|
+
|
|
171
|
+
# 3. Push to cloud
|
|
172
|
+
lsh lib secrets push --env dev
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Advanced Features (Bonus!)
|
|
176
|
+
|
|
177
|
+
Because LSH is built on a complete shell framework, you also get powerful automation capabilities:
|
|
178
|
+
|
|
179
|
+
### Persistent Daemon
|
|
180
|
+
|
|
181
|
+
Run jobs reliably in the background:
|
|
64
182
|
|
|
65
183
|
```bash
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
cd lsh
|
|
184
|
+
# Start daemon
|
|
185
|
+
lsh lib daemon start
|
|
69
186
|
|
|
70
|
-
#
|
|
71
|
-
|
|
187
|
+
# Check status
|
|
188
|
+
lsh lib daemon status
|
|
72
189
|
|
|
73
|
-
#
|
|
74
|
-
|
|
190
|
+
# Stop daemon
|
|
191
|
+
lsh lib daemon stop
|
|
192
|
+
```
|
|
75
193
|
|
|
76
|
-
|
|
77
|
-
|
|
194
|
+
### Cron-Style Scheduling
|
|
195
|
+
|
|
196
|
+
Schedule any task with cron expressions:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Daily backup at midnight
|
|
200
|
+
lsh lib cron add --name "backup" \
|
|
201
|
+
--schedule "0 0 * * *" \
|
|
202
|
+
--command "./backup.sh"
|
|
203
|
+
|
|
204
|
+
# Every 6 hours
|
|
205
|
+
lsh lib cron add --name "sync" \
|
|
206
|
+
--schedule "0 */6 * * *" \
|
|
207
|
+
--command "lsh lib secrets pull && ./reload.sh"
|
|
208
|
+
|
|
209
|
+
# List all jobs
|
|
210
|
+
lsh lib cron list
|
|
78
211
|
|
|
79
|
-
#
|
|
80
|
-
lsh
|
|
212
|
+
# Trigger manually
|
|
213
|
+
lsh lib cron trigger backup
|
|
81
214
|
```
|
|
82
215
|
|
|
83
|
-
|
|
216
|
+
### RESTful API
|
|
84
217
|
|
|
85
|
-
|
|
218
|
+
Control everything via HTTP API:
|
|
86
219
|
|
|
87
220
|
```bash
|
|
88
|
-
# Start
|
|
89
|
-
lsh
|
|
221
|
+
# Start API server
|
|
222
|
+
LSH_API_KEY=your-key lsh lib api start --port 3030
|
|
223
|
+
|
|
224
|
+
# Use the API
|
|
225
|
+
curl -H "X-API-Key: your-key" http://localhost:3030/api/jobs
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### CI/CD Integration
|
|
229
|
+
|
|
230
|
+
- **Webhook Receiver** - GitHub, GitLab, Jenkins webhook support
|
|
231
|
+
- **Build Analytics** - Track build metrics and performance
|
|
232
|
+
- **Pipeline Orchestration** - Workflow engine for complex pipelines
|
|
233
|
+
|
|
234
|
+
### POSIX Shell Features
|
|
235
|
+
|
|
236
|
+
LSH is also a full POSIX-compatible shell with ZSH enhancements:
|
|
237
|
+
|
|
238
|
+
- Extended globbing patterns
|
|
239
|
+
- Parameter expansion
|
|
240
|
+
- Associative arrays
|
|
241
|
+
- Command history and tab completion
|
|
242
|
+
- Interactive mode
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Use as interactive shell
|
|
246
|
+
lsh -i
|
|
90
247
|
|
|
91
248
|
# Execute commands
|
|
92
|
-
lsh
|
|
93
|
-
|
|
94
|
-
|
|
249
|
+
lsh -c "echo 'Hello World'"
|
|
250
|
+
|
|
251
|
+
# Run scripts
|
|
252
|
+
lsh -s script.sh
|
|
95
253
|
```
|
|
96
254
|
|
|
97
|
-
|
|
255
|
+
## Security
|
|
256
|
+
|
|
257
|
+
### Encryption
|
|
258
|
+
|
|
259
|
+
- **Algorithm**: AES-256-CBC
|
|
260
|
+
- **Key Management**: User-controlled encryption keys
|
|
261
|
+
- **Storage**: Encrypted at rest in Supabase/PostgreSQL
|
|
262
|
+
- **Transport**: HTTPS for all API calls
|
|
263
|
+
|
|
264
|
+
### Best Practices
|
|
98
265
|
|
|
266
|
+
**✅ DO:**
|
|
267
|
+
- Generate unique keys per project
|
|
268
|
+
- Share keys via 1Password/LastPass
|
|
269
|
+
- Use different keys for personal vs team projects
|
|
270
|
+
- Rotate keys periodically
|
|
271
|
+
- Keep backups of your .env files
|
|
272
|
+
|
|
273
|
+
**❌ DON'T:**
|
|
274
|
+
- Commit `LSH_SECRETS_KEY` to git
|
|
275
|
+
- Share keys in plain text (Slack, email, etc.)
|
|
276
|
+
- Reuse keys across projects
|
|
277
|
+
- Store production secrets in dev environment
|
|
278
|
+
|
|
279
|
+
### Command Validation
|
|
280
|
+
|
|
281
|
+
All commands are validated to prevent injection attacks:
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import { validateCommand } from './lib/command-validator.js';
|
|
285
|
+
|
|
286
|
+
// Automatically validates and sanitizes
|
|
287
|
+
const result = await validateCommand(userInput);
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Environment Validation
|
|
291
|
+
|
|
292
|
+
LSH validates all environment variables at startup and fails fast if:
|
|
293
|
+
- Required secrets are missing or too short
|
|
294
|
+
- Invalid URL formats
|
|
295
|
+
- Dangerous commands enabled in production
|
|
296
|
+
|
|
297
|
+
## Use Cases
|
|
298
|
+
|
|
299
|
+
### 1. Multi-Machine Development
|
|
300
|
+
|
|
301
|
+
**Problem:** You develop on a laptop, desktop, and cloud server. Copying .env files manually is tedious.
|
|
302
|
+
|
|
303
|
+
**Solution:**
|
|
99
304
|
```bash
|
|
100
|
-
#
|
|
101
|
-
lsh
|
|
305
|
+
# Laptop
|
|
306
|
+
lsh lib secrets push --env dev
|
|
307
|
+
|
|
308
|
+
# Desktop
|
|
309
|
+
lsh lib secrets pull --env dev
|
|
102
310
|
|
|
103
|
-
#
|
|
104
|
-
lsh
|
|
311
|
+
# Cloud server
|
|
312
|
+
lsh lib secrets pull --env dev
|
|
105
313
|
|
|
106
|
-
#
|
|
107
|
-
lsh daemon stop
|
|
314
|
+
# All synced!
|
|
108
315
|
```
|
|
109
316
|
|
|
110
|
-
###
|
|
317
|
+
### 2. Team Onboarding
|
|
318
|
+
|
|
319
|
+
**Problem:** New team member needs to set up 5 microservices with different env vars.
|
|
111
320
|
|
|
321
|
+
**Solution:**
|
|
112
322
|
```bash
|
|
113
|
-
#
|
|
114
|
-
|
|
323
|
+
# New team member (after getting LSH_SECRETS_KEY from 1Password)
|
|
324
|
+
cd ~/projects/service-1 && lsh lib secrets pull --env dev
|
|
325
|
+
cd ~/projects/service-2 && lsh lib secrets pull --env dev
|
|
326
|
+
cd ~/projects/service-3 && lsh lib secrets pull --env dev
|
|
327
|
+
cd ~/projects/service-4 && lsh lib secrets pull --env dev
|
|
328
|
+
cd ~/projects/service-5 && lsh lib secrets pull --env dev
|
|
329
|
+
|
|
330
|
+
# Done in 30 seconds instead of 30 minutes
|
|
331
|
+
```
|
|
115
332
|
|
|
116
|
-
|
|
117
|
-
lsh cron list
|
|
333
|
+
### 3. Automated Secret Rotation
|
|
118
334
|
|
|
119
|
-
|
|
120
|
-
lsh cron trigger daily-backup
|
|
335
|
+
**Problem:** Security policy requires API keys to be rotated every 30 days.
|
|
121
336
|
|
|
122
|
-
|
|
123
|
-
|
|
337
|
+
**Solution:**
|
|
338
|
+
```bash
|
|
339
|
+
# Create rotation script
|
|
340
|
+
cat > rotate-keys.sh <<'EOF'
|
|
341
|
+
#!/bin/bash
|
|
342
|
+
# Generate new API key from provider
|
|
343
|
+
NEW_KEY=$(curl -X POST https://api.provider.com/keys/rotate)
|
|
344
|
+
|
|
345
|
+
# Update .env
|
|
346
|
+
sed -i "s/API_KEY=.*/API_KEY=$NEW_KEY/" .env
|
|
347
|
+
|
|
348
|
+
# Push to cloud
|
|
349
|
+
lsh lib secrets push --env prod
|
|
350
|
+
|
|
351
|
+
# Notify team
|
|
352
|
+
echo "API keys rotated at $(date)" | mail -s "Key Rotation" team@company.com
|
|
353
|
+
EOF
|
|
354
|
+
|
|
355
|
+
# Schedule it
|
|
356
|
+
lsh lib cron add --name "rotate-keys" \
|
|
357
|
+
--schedule "0 0 1 * *" \
|
|
358
|
+
--command "./rotate-keys.sh"
|
|
124
359
|
```
|
|
125
360
|
|
|
126
|
-
###
|
|
361
|
+
### 4. Multi-Environment Deployment
|
|
127
362
|
|
|
363
|
+
**Problem:** Managing different configs for dev, staging, and production.
|
|
364
|
+
|
|
365
|
+
**Solution:**
|
|
128
366
|
```bash
|
|
129
|
-
#
|
|
130
|
-
lsh
|
|
367
|
+
# Push from local dev
|
|
368
|
+
lsh lib secrets push --file .env.development --env dev
|
|
369
|
+
|
|
370
|
+
# Push staging config
|
|
371
|
+
lsh lib secrets push --file .env.staging --env staging
|
|
131
372
|
|
|
132
|
-
#
|
|
133
|
-
|
|
373
|
+
# Push production config (from secure machine only)
|
|
374
|
+
lsh lib secrets push --file .env.production --env prod
|
|
375
|
+
|
|
376
|
+
# CI/CD pulls the right one
|
|
377
|
+
# In .github/workflows/deploy.yml:
|
|
378
|
+
- name: Get secrets
|
|
379
|
+
run: lsh lib secrets pull --env ${{ github.ref == 'refs/heads/main' && 'prod' || 'staging' }}
|
|
134
380
|
```
|
|
135
381
|
|
|
382
|
+
## Comparison with Other Tools
|
|
383
|
+
|
|
384
|
+
| Feature | LSH | dotenv-vault | 1Password | Doppler | HashiCorp Vault |
|
|
385
|
+
|---------|-----|--------------|-----------|---------|-----------------|
|
|
386
|
+
| **Cost** | Free | Free tier | $3-8/mo/user | $5-10/user | Free (complex) |
|
|
387
|
+
| **Encryption** | AES-256 | ✓ | ✓ | ✓ | ✓ |
|
|
388
|
+
| **Self-Hosted** | ✓ (Supabase) | ✗ | ✗ | ✗ | ✓ (complex) |
|
|
389
|
+
| **Auto Rotation** | ✓ Built-in | ✗ | Manual | ✗ | ✓ (complex) |
|
|
390
|
+
| **Team Sync** | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
391
|
+
| **CLI Native** | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
392
|
+
| **Setup Time** | 2 min | 5 min | 10 min | 10 min | 30+ min |
|
|
393
|
+
| **Daemon/Cron** | ✓ Built-in | ✗ | ✗ | ✗ | ✗ |
|
|
394
|
+
| **Learning Curve** | Easy | Easy | Medium | Medium | Hard |
|
|
395
|
+
|
|
396
|
+
**LSH is the only tool that combines:**
|
|
397
|
+
- Simple, fast setup
|
|
398
|
+
- Built-in scheduling for rotation
|
|
399
|
+
- Self-hosted option (no vendor lock-in)
|
|
400
|
+
- Completely free
|
|
401
|
+
|
|
136
402
|
## Configuration
|
|
137
403
|
|
|
138
404
|
### Environment Variables
|
|
139
405
|
|
|
140
|
-
Copy `.env.example` to `.env
|
|
406
|
+
Copy `.env.example` to `.env`:
|
|
141
407
|
|
|
142
408
|
```bash
|
|
143
|
-
#
|
|
144
|
-
NODE_ENV=development # Environment mode
|
|
145
|
-
LSH_API_ENABLED=true # Enable API server
|
|
146
|
-
LSH_API_PORT=3030 # API server port
|
|
147
|
-
|
|
148
|
-
# Security (REQUIRED in production)
|
|
149
|
-
LSH_API_KEY=<generate-32-char-key> # API authentication key
|
|
150
|
-
LSH_JWT_SECRET=<generate-32-char-secret> # JWT signing secret
|
|
151
|
-
LSH_ALLOW_DANGEROUS_COMMANDS=false # Allow risky commands (use with caution)
|
|
152
|
-
|
|
153
|
-
# Webhooks
|
|
154
|
-
LSH_ENABLE_WEBHOOKS=true # Enable webhook receiver
|
|
155
|
-
WEBHOOK_PORT=3033 # Webhook receiver port
|
|
156
|
-
GITHUB_WEBHOOK_SECRET=<your-secret> # GitHub webhook secret
|
|
157
|
-
GITLAB_WEBHOOK_SECRET=<your-secret> # GitLab webhook secret
|
|
158
|
-
JENKINS_WEBHOOK_SECRET=<your-secret> # Jenkins webhook secret
|
|
159
|
-
|
|
160
|
-
# Database (Optional)
|
|
161
|
-
DATABASE_URL=postgresql://localhost:5432/cicd
|
|
409
|
+
# Secrets Management (Required)
|
|
162
410
|
SUPABASE_URL=https://your-project.supabase.co
|
|
163
411
|
SUPABASE_ANON_KEY=<your-anon-key>
|
|
412
|
+
LSH_SECRETS_KEY=<generate-with-lsh-lib-secrets-key>
|
|
413
|
+
|
|
414
|
+
# Optional: Advanced Features
|
|
415
|
+
|
|
416
|
+
# API Server
|
|
417
|
+
LSH_API_ENABLED=true
|
|
418
|
+
LSH_API_PORT=3030
|
|
419
|
+
LSH_API_KEY=<generate-32-char-key>
|
|
420
|
+
LSH_JWT_SECRET=<generate-32-char-secret>
|
|
421
|
+
|
|
422
|
+
# Webhooks (for CI/CD integration)
|
|
423
|
+
LSH_ENABLE_WEBHOOKS=true
|
|
424
|
+
WEBHOOK_PORT=3033
|
|
425
|
+
GITHUB_WEBHOOK_SECRET=<your-secret>
|
|
426
|
+
GITLAB_WEBHOOK_SECRET=<your-secret>
|
|
427
|
+
|
|
428
|
+
# Database (alternative to Supabase)
|
|
429
|
+
DATABASE_URL=postgresql://localhost:5432/lsh
|
|
164
430
|
|
|
165
|
-
# Caching
|
|
431
|
+
# Caching
|
|
166
432
|
REDIS_URL=redis://localhost:6379
|
|
167
433
|
|
|
168
|
-
#
|
|
169
|
-
|
|
434
|
+
# Security
|
|
435
|
+
LSH_ALLOW_DANGEROUS_COMMANDS=false # Keep false in production
|
|
170
436
|
```
|
|
171
437
|
|
|
172
|
-
###
|
|
438
|
+
### Generate Secrets
|
|
173
439
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
2. **Generate strong keys** - Use `openssl rand -hex 32` for secrets
|
|
178
|
-
3. **Enable webhook verification** - Set webhook secrets when using webhooks
|
|
179
|
-
4. **Review dangerous commands** - Keep `LSH_ALLOW_DANGEROUS_COMMANDS=false`
|
|
180
|
-
5. **Use environment variables** - Never commit `.env` to version control
|
|
440
|
+
```bash
|
|
441
|
+
# Encryption key for secrets
|
|
442
|
+
lsh lib secrets key
|
|
181
443
|
|
|
182
|
-
|
|
444
|
+
# API key for HTTP API
|
|
445
|
+
openssl rand -hex 32
|
|
183
446
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
- Dangerous commands enabled in production
|
|
447
|
+
# JWT secret
|
|
448
|
+
openssl rand -hex 32
|
|
449
|
+
```
|
|
188
450
|
|
|
189
451
|
## Development
|
|
190
452
|
|
|
@@ -194,206 +456,192 @@ LSH validates environment variables at startup and fails fast in production if:
|
|
|
194
456
|
# Build TypeScript
|
|
195
457
|
npm run build
|
|
196
458
|
|
|
197
|
-
# Watch mode
|
|
459
|
+
# Watch mode
|
|
198
460
|
npm run watch
|
|
199
461
|
|
|
200
|
-
# Type checking
|
|
462
|
+
# Type checking
|
|
201
463
|
npm run typecheck
|
|
202
464
|
```
|
|
203
465
|
|
|
204
466
|
### Testing
|
|
205
467
|
|
|
206
468
|
```bash
|
|
207
|
-
# Run
|
|
469
|
+
# Run tests
|
|
208
470
|
npm test
|
|
209
471
|
|
|
210
|
-
#
|
|
472
|
+
# With coverage
|
|
211
473
|
npm run test:coverage
|
|
212
474
|
|
|
213
|
-
#
|
|
214
|
-
npm run test:integration
|
|
215
|
-
|
|
216
|
-
# Lint code
|
|
475
|
+
# Lint
|
|
217
476
|
npm run lint
|
|
218
477
|
|
|
219
|
-
# Auto-fix
|
|
478
|
+
# Auto-fix
|
|
220
479
|
npm run lint:fix
|
|
221
480
|
```
|
|
222
481
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
**Well-tested modules:**
|
|
226
|
-
- `command-validator.ts` - 100% coverage
|
|
227
|
-
- `env-validator.ts` - 74% coverage
|
|
228
|
-
|
|
229
|
-
### Electron App
|
|
482
|
+
### From Source
|
|
230
483
|
|
|
231
484
|
```bash
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
npm
|
|
237
|
-
|
|
238
|
-
# Access dashboards
|
|
239
|
-
npm run dashboard
|
|
485
|
+
git clone https://github.com/gwicho38/lsh.git
|
|
486
|
+
cd lsh
|
|
487
|
+
npm install
|
|
488
|
+
npm run build
|
|
489
|
+
npm link
|
|
490
|
+
lsh --version
|
|
240
491
|
```
|
|
241
492
|
|
|
242
|
-
##
|
|
243
|
-
|
|
244
|
-
### Core Components
|
|
493
|
+
## Troubleshooting
|
|
245
494
|
|
|
246
|
-
|
|
247
|
-
- **`src/lib/job-manager.ts`** - Job lifecycle management
|
|
248
|
-
- **`src/daemon/lshd.ts`** - Persistent background daemon
|
|
249
|
-
- **`src/daemon/api-server.ts`** - RESTful API server
|
|
250
|
-
- **`src/cicd/webhook-receiver.ts`** - CI/CD webhook integration
|
|
495
|
+
### "No secrets found"
|
|
251
496
|
|
|
252
|
-
|
|
497
|
+
```bash
|
|
498
|
+
# Check stored environments
|
|
499
|
+
lsh lib secrets list
|
|
253
500
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
↓
|
|
257
|
-
Job Manager
|
|
258
|
-
↓
|
|
259
|
-
Daemon (persistent)
|
|
260
|
-
↓
|
|
261
|
-
Database/Redis
|
|
501
|
+
# Push if missing
|
|
502
|
+
lsh lib secrets push --env dev
|
|
262
503
|
```
|
|
263
504
|
|
|
264
|
-
###
|
|
505
|
+
### "Decryption failed"
|
|
265
506
|
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
Daemon Startup → Env Validation → Fail Fast if Invalid
|
|
270
|
-
```
|
|
507
|
+
```bash
|
|
508
|
+
# Wrong encryption key!
|
|
509
|
+
# Make sure LSH_SECRETS_KEY matches the one used to encrypt
|
|
271
510
|
|
|
272
|
-
|
|
511
|
+
# Generate new key and re-push
|
|
512
|
+
lsh lib secrets key
|
|
513
|
+
lsh lib secrets push
|
|
514
|
+
```
|
|
273
515
|
|
|
274
|
-
###
|
|
516
|
+
### "Supabase not configured"
|
|
275
517
|
|
|
276
518
|
```bash
|
|
277
|
-
#
|
|
278
|
-
|
|
519
|
+
# Add to .env:
|
|
520
|
+
SUPABASE_URL=https://your-project.supabase.co
|
|
521
|
+
SUPABASE_ANON_KEY=your-anon-key
|
|
279
522
|
```
|
|
280
523
|
|
|
281
|
-
###
|
|
282
|
-
|
|
283
|
-
**Job Management:**
|
|
284
|
-
- `GET /api/jobs` - List all jobs
|
|
285
|
-
- `POST /api/jobs` - Create a new job
|
|
286
|
-
- `GET /api/jobs/:id` - Get job details
|
|
287
|
-
- `POST /api/jobs/:id/trigger` - Trigger job execution
|
|
288
|
-
- `DELETE /api/jobs/:id` - Remove a job
|
|
289
|
-
|
|
290
|
-
**Daemon Control:**
|
|
291
|
-
- `GET /api/status` - Daemon status
|
|
292
|
-
- `GET /api/metrics` - System metrics
|
|
293
|
-
|
|
294
|
-
**Webhooks:**
|
|
295
|
-
- `POST /webhooks/github` - GitHub webhook endpoint
|
|
296
|
-
- `POST /webhooks/gitlab` - GitLab webhook endpoint
|
|
297
|
-
- `POST /webhooks/jenkins` - Jenkins webhook endpoint
|
|
298
|
-
|
|
299
|
-
## Troubleshooting
|
|
300
|
-
|
|
301
|
-
### Common Issues
|
|
524
|
+
### Daemon won't start
|
|
302
525
|
|
|
303
|
-
**Daemon won't start:**
|
|
304
526
|
```bash
|
|
305
527
|
# Check if already running
|
|
306
528
|
ps aux | grep lshd
|
|
307
529
|
|
|
308
|
-
# Check PID file
|
|
309
|
-
cat /tmp/lsh-job-daemon-$USER.pid
|
|
310
|
-
|
|
311
530
|
# Remove stale PID file
|
|
312
531
|
rm /tmp/lsh-job-daemon-$USER.pid
|
|
532
|
+
|
|
533
|
+
# Restart
|
|
534
|
+
lsh lib daemon start
|
|
313
535
|
```
|
|
314
536
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
537
|
+
## Documentation
|
|
538
|
+
|
|
539
|
+
- **[SECRETS_GUIDE.md](SECRETS_GUIDE.md)** - Complete secrets management guide
|
|
540
|
+
- **[SECRETS_QUICK_REFERENCE.md](SECRETS_QUICK_REFERENCE.md)** - Quick reference for daily use
|
|
541
|
+
- **[SECRETS_CHEATSHEET.txt](SECRETS_CHEATSHEET.txt)** - Command cheatsheet
|
|
542
|
+
- **[INSTALL.md](INSTALL.md)** - Detailed installation instructions
|
|
543
|
+
- **[CLAUDE.md](CLAUDE.md)** - Developer guide for contributors
|
|
544
|
+
|
|
545
|
+
## Architecture
|
|
319
546
|
|
|
320
|
-
|
|
321
|
-
|
|
547
|
+
### Secrets Flow
|
|
548
|
+
|
|
549
|
+
```
|
|
550
|
+
Local .env → Encrypt (AES-256) → Supabase/PostgreSQL
|
|
551
|
+
↓
|
|
552
|
+
Pull on any machine
|
|
553
|
+
↓
|
|
554
|
+
Decrypt → Local .env
|
|
322
555
|
```
|
|
323
556
|
|
|
324
|
-
|
|
325
|
-
```bash
|
|
326
|
-
# Check your .env file matches .env.example
|
|
327
|
-
cp .env.example .env
|
|
328
|
-
# Edit .env with your values
|
|
557
|
+
### Rotation Flow
|
|
329
558
|
|
|
330
|
-
|
|
331
|
-
|
|
559
|
+
```
|
|
560
|
+
Cron Schedule → Daemon → Rotation Script → Update .env → Push to cloud
|
|
561
|
+
↓
|
|
562
|
+
Notify team/reload apps
|
|
332
563
|
```
|
|
333
564
|
|
|
334
|
-
|
|
335
|
-
```bash
|
|
336
|
-
# Auto-fix what's possible
|
|
337
|
-
npm run lint:fix
|
|
565
|
+
### Security Architecture
|
|
338
566
|
|
|
339
|
-
|
|
340
|
-
|
|
567
|
+
```
|
|
568
|
+
API Request → JWT Validation → Command Validation → Execution
|
|
569
|
+
Webhook → HMAC Verification → Event Processing → Job Trigger
|
|
570
|
+
Daemon Startup → Env Validation → Fail Fast if Invalid
|
|
571
|
+
Secrets → AES-256 Encryption → Encrypted Storage
|
|
341
572
|
```
|
|
342
573
|
|
|
343
|
-
##
|
|
574
|
+
## API Reference
|
|
344
575
|
|
|
345
|
-
|
|
576
|
+
### Secrets API
|
|
346
577
|
|
|
347
|
-
|
|
348
|
-
2. **Create a feature branch** - `git checkout -b feature/your-feature`
|
|
349
|
-
3. **Make your changes**
|
|
350
|
-
4. **Add tests** - Ensure tests pass with `npm test`
|
|
351
|
-
5. **Lint your code** - Run `npm run lint:fix`
|
|
352
|
-
6. **Commit your changes** - Follow conventional commit format
|
|
353
|
-
7. **Push to your fork** - `git push origin feature/your-feature`
|
|
354
|
-
8. **Create a Pull Request**
|
|
578
|
+
All secrets commands are available programmatically:
|
|
355
579
|
|
|
356
|
-
|
|
580
|
+
```typescript
|
|
581
|
+
import SecretsManager from 'lsh-framework/dist/lib/secrets-manager.js';
|
|
357
582
|
|
|
358
|
-
|
|
359
|
-
- Prefix unused variables with `_` (e.g., `_unusedVar`)
|
|
360
|
-
- Add tests for new features
|
|
361
|
-
- Follow existing code structure
|
|
362
|
-
- Update documentation for user-facing changes
|
|
583
|
+
const manager = new SecretsManager();
|
|
363
584
|
|
|
364
|
-
|
|
585
|
+
// Push secrets
|
|
586
|
+
await manager.push('.env', 'production');
|
|
365
587
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
npm run watch
|
|
588
|
+
// Pull secrets
|
|
589
|
+
await manager.pull('.env', 'production');
|
|
369
590
|
|
|
370
|
-
|
|
371
|
-
|
|
591
|
+
// List environments
|
|
592
|
+
const envs = await manager.listEnvironments();
|
|
372
593
|
|
|
373
|
-
|
|
374
|
-
|
|
594
|
+
// Show secrets (masked)
|
|
595
|
+
await manager.show('production');
|
|
375
596
|
```
|
|
376
597
|
|
|
377
|
-
|
|
598
|
+
### REST API
|
|
378
599
|
|
|
379
|
-
|
|
600
|
+
See API endpoints documentation in the Advanced Features section.
|
|
380
601
|
|
|
381
|
-
##
|
|
602
|
+
## Roadmap
|
|
382
603
|
|
|
383
|
-
|
|
604
|
+
- [ ] CLI command shortcuts (`lsh push` instead of `lsh lib secrets push`)
|
|
605
|
+
- [ ] Built-in secret rotation templates (AWS, GCP, Azure)
|
|
606
|
+
- [ ] Web dashboard for team secret management
|
|
607
|
+
- [ ] Audit logging for secret access
|
|
608
|
+
- [ ] Integration with cloud secret managers (AWS Secrets Manager, etc.)
|
|
609
|
+
- [ ] Automatic secret expiration warnings
|
|
610
|
+
- [ ] Git hooks for secret validation
|
|
384
611
|
|
|
385
|
-
|
|
386
|
-
- Improving test coverage (target: 70%)
|
|
387
|
-
- Reducing lint errors
|
|
388
|
-
- Adding comprehensive documentation
|
|
389
|
-
- Refactoring large modules
|
|
612
|
+
## Contributing
|
|
390
613
|
|
|
391
|
-
|
|
614
|
+
Contributions welcome! Please:
|
|
615
|
+
|
|
616
|
+
1. Fork the repository
|
|
617
|
+
2. Create a feature branch: `git checkout -b feature/your-feature`
|
|
618
|
+
3. Make your changes
|
|
619
|
+
4. Add tests: `npm test`
|
|
620
|
+
5. Lint: `npm run lint:fix`
|
|
621
|
+
6. Commit and push
|
|
622
|
+
7. Create a Pull Request
|
|
392
623
|
|
|
393
|
-
|
|
624
|
+
## License
|
|
625
|
+
|
|
626
|
+
MIT
|
|
394
627
|
|
|
395
628
|
## Support
|
|
396
629
|
|
|
397
|
-
For issues, questions, or contributions:
|
|
398
630
|
- **Issues**: https://github.com/gwicho38/lsh/issues
|
|
399
631
|
- **Discussions**: https://github.com/gwicho38/lsh/discussions
|
|
632
|
+
- **Documentation**: See docs/ folder
|
|
633
|
+
|
|
634
|
+
## Credits
|
|
635
|
+
|
|
636
|
+
Built with:
|
|
637
|
+
- TypeScript for type safety
|
|
638
|
+
- Supabase for encrypted storage
|
|
639
|
+
- Node.js crypto for AES-256 encryption
|
|
640
|
+
- Commander.js for CLI framework
|
|
641
|
+
- React/Ink for terminal UI
|
|
642
|
+
|
|
643
|
+
---
|
|
644
|
+
|
|
645
|
+
**Made with ❤️ for developers tired of copying .env files**
|
|
646
|
+
|
|
647
|
+
**Stop copying. Start syncing. Automate rotation.**
|