@secretstash/cli 0.1.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 ADDED
@@ -0,0 +1,321 @@
1
+ # SecretStash CLI
2
+
3
+ Command-line interface for SecretStash - secure team secrets management.
4
+
5
+ ## Installation
6
+
7
+ ### npm (recommended)
8
+
9
+ ```bash
10
+ npm install -g @secretstash/cli
11
+ ```
12
+
13
+ ### Docker
14
+
15
+ Pull the official Docker image:
16
+
17
+ ```bash
18
+ # From Docker Hub
19
+ docker pull secretstash/cli:latest
20
+
21
+ # From GitHub Container Registry
22
+ docker pull ghcr.io/secretstash/secretstash-cli:latest
23
+ ```
24
+
25
+ ### Homebrew (macOS/Linux)
26
+
27
+ ```bash
28
+ brew install secretstash/tap/sstash
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ### Authentication
34
+
35
+ ```bash
36
+ # Login to SecretStash
37
+ sstash auth login
38
+
39
+ # Login with service token (for CI/CD)
40
+ export SECRETSTASH_TOKEN=your-service-token
41
+ sstash auth status
42
+ ```
43
+
44
+ ### Working with Secrets
45
+
46
+ ```bash
47
+ # Pull secrets to .env file
48
+ sstash pull --env production --output .env
49
+
50
+ # Push secrets from .env file
51
+ sstash push --env development --input .env
52
+
53
+ # List all secrets in an environment
54
+ sstash list --env production
55
+
56
+ # Set a single secret
57
+ sstash set API_KEY=your-api-key --env production
58
+
59
+ # Get a single secret
60
+ sstash get API_KEY --env production
61
+
62
+ # Run a command with secrets injected
63
+ sstash run --env production -- npm start
64
+ ```
65
+
66
+ ### Projects and Environments
67
+
68
+ ```bash
69
+ # List projects
70
+ sstash projects list
71
+
72
+ # Switch project context
73
+ sstash projects use my-project
74
+
75
+ # List environments
76
+ sstash environments list
77
+
78
+ # Create a new environment
79
+ sstash environments create staging
80
+ ```
81
+
82
+ ## Docker Usage
83
+
84
+ ### Basic Usage
85
+
86
+ Run commands directly with Docker:
87
+
88
+ ```bash
89
+ # Show help
90
+ docker run --rm secretstash/cli:latest --help
91
+
92
+ # Pull secrets (using service token)
93
+ docker run --rm \
94
+ -e SECRETSTASH_TOKEN=your-token \
95
+ secretstash/cli:latest \
96
+ pull --env production
97
+
98
+ # Pull secrets to a file
99
+ docker run --rm \
100
+ -e SECRETSTASH_TOKEN=your-token \
101
+ -v $(pwd):/workspace \
102
+ -w /workspace \
103
+ secretstash/cli:latest \
104
+ pull --env production --output .env
105
+ ```
106
+
107
+ ### Docker Compose
108
+
109
+ Create a `docker-compose.yml`:
110
+
111
+ ```yaml
112
+ version: '3.8'
113
+ services:
114
+ secretstash:
115
+ image: secretstash/cli:latest
116
+ environment:
117
+ - SECRETSTASH_TOKEN=${SECRETSTASH_TOKEN}
118
+ command: pull --env production
119
+ ```
120
+
121
+ Run with:
122
+
123
+ ```bash
124
+ export SECRETSTASH_TOKEN=your-token
125
+ docker-compose run --rm secretstash
126
+ ```
127
+
128
+ ### CI/CD Integration
129
+
130
+ #### GitHub Actions
131
+
132
+ ```yaml
133
+ jobs:
134
+ deploy:
135
+ runs-on: ubuntu-latest
136
+ steps:
137
+ - uses: actions/checkout@v4
138
+
139
+ - name: Pull secrets
140
+ run: |
141
+ docker run --rm \
142
+ -e SECRETSTASH_TOKEN=${{ secrets.SECRETSTASH_TOKEN }} \
143
+ -v ${{ github.workspace }}:/workspace \
144
+ -w /workspace \
145
+ secretstash/cli:latest \
146
+ pull --env production --output .env
147
+
148
+ - name: Deploy with secrets
149
+ run: |
150
+ source .env
151
+ # Your deployment commands here
152
+ ```
153
+
154
+ #### GitLab CI
155
+
156
+ ```yaml
157
+ stages:
158
+ - prepare
159
+ - deploy
160
+
161
+ pull_secrets:
162
+ stage: prepare
163
+ image: secretstash/cli:latest
164
+ script:
165
+ - sstash pull --env $CI_ENVIRONMENT_NAME --output .env
166
+ artifacts:
167
+ paths:
168
+ - .env
169
+ expire_in: 1 hour
170
+
171
+ deploy:
172
+ stage: deploy
173
+ needs: [pull_secrets]
174
+ script:
175
+ - source .env
176
+ - ./deploy.sh
177
+ ```
178
+
179
+ #### CircleCI
180
+
181
+ ```yaml
182
+ version: 2.1
183
+ jobs:
184
+ deploy:
185
+ docker:
186
+ - image: cimg/node:20.0
187
+ steps:
188
+ - checkout
189
+ - run:
190
+ name: Pull secrets
191
+ command: |
192
+ docker run --rm \
193
+ -e SECRETSTASH_TOKEN=$SECRETSTASH_TOKEN \
194
+ -v $(pwd):/workspace \
195
+ -w /workspace \
196
+ secretstash/cli:latest \
197
+ pull --env production --output .env
198
+ - run:
199
+ name: Deploy
200
+ command: |
201
+ source .env
202
+ npm run deploy
203
+ ```
204
+
205
+ #### Jenkins
206
+
207
+ ```groovy
208
+ pipeline {
209
+ agent any
210
+ environment {
211
+ SECRETSTASH_TOKEN = credentials('secretstash-token')
212
+ }
213
+ stages {
214
+ stage('Pull Secrets') {
215
+ steps {
216
+ sh '''
217
+ docker run --rm \
218
+ -e SECRETSTASH_TOKEN=$SECRETSTASH_TOKEN \
219
+ -v $WORKSPACE:/workspace \
220
+ -w /workspace \
221
+ secretstash/cli:latest \
222
+ pull --env production --output .env
223
+ '''
224
+ }
225
+ }
226
+ stage('Deploy') {
227
+ steps {
228
+ sh '''
229
+ source .env
230
+ ./deploy.sh
231
+ '''
232
+ }
233
+ }
234
+ }
235
+ }
236
+ ```
237
+
238
+ ### Multi-Architecture Support
239
+
240
+ The Docker image supports multiple architectures:
241
+
242
+ - `linux/amd64` (Intel/AMD 64-bit)
243
+ - `linux/arm64` (ARM 64-bit, including Apple Silicon Macs and AWS Graviton)
244
+
245
+ Docker will automatically pull the correct architecture for your platform.
246
+
247
+ ### Available Tags
248
+
249
+ | Tag | Description |
250
+ |-----|-------------|
251
+ | `latest` | Latest stable release |
252
+ | `x.y.z` | Specific version (e.g., `1.2.3`) |
253
+ | `x.y` | Latest patch for minor version (e.g., `1.2`) |
254
+ | `x` | Latest minor/patch for major version (e.g., `1`) |
255
+
256
+ ### Environment Variables
257
+
258
+ | Variable | Description | Default |
259
+ |----------|-------------|---------|
260
+ | `SECRETSTASH_TOKEN` | Service token for authentication | - |
261
+ | `SECRETSTASH_API_URL` | API endpoint URL | `https://api.secretstash.io` |
262
+ | `SECRETSTASH_CONFIG_DIR` | Configuration directory | `~/.config/secretstash` |
263
+
264
+ ## Configuration
265
+
266
+ ### Config File
267
+
268
+ The CLI stores configuration in `~/.config/secretstash/config.json`:
269
+
270
+ ```json
271
+ {
272
+ "apiUrl": "https://api.secretstash.io",
273
+ "currentProject": "my-project",
274
+ "currentTeam": "my-team"
275
+ }
276
+ ```
277
+
278
+ ### Service Tokens
279
+
280
+ For CI/CD and automated workflows, use service tokens instead of user credentials:
281
+
282
+ 1. Generate a token in the web dashboard under Settings > Service Tokens
283
+ 2. Set the `SECRETSTASH_TOKEN` environment variable
284
+ 3. Optionally scope tokens to specific environments for security
285
+
286
+ ## Commands Reference
287
+
288
+ | Command | Description |
289
+ |---------|-------------|
290
+ | `sstash auth login` | Authenticate with SecretStash |
291
+ | `sstash auth logout` | Clear authentication |
292
+ | `sstash auth status` | Show authentication status |
293
+ | `sstash pull` | Pull secrets from SecretStash |
294
+ | `sstash push` | Push secrets to SecretStash |
295
+ | `sstash list` | List secrets in an environment |
296
+ | `sstash get <key>` | Get a specific secret |
297
+ | `sstash set <key>=<value>` | Set a specific secret |
298
+ | `sstash delete <key>` | Delete a specific secret |
299
+ | `sstash run` | Run a command with secrets injected |
300
+ | `sstash diff` | Compare local and remote secrets |
301
+ | `sstash projects list` | List available projects |
302
+ | `sstash projects use <name>` | Switch project context |
303
+ | `sstash environments list` | List environments |
304
+ | `sstash environments create <name>` | Create a new environment |
305
+ | `sstash teams list` | List teams |
306
+ | `sstash teams switch <name>` | Switch team context |
307
+
308
+ Use `sstash --help` or `sstash <command> --help` for detailed usage information.
309
+
310
+ ## Security
311
+
312
+ - All secrets are encrypted in transit (TLS 1.3) and at rest (AES-256-GCM)
313
+ - Service tokens can be scoped to specific environments
314
+ - Audit logs track all secret access and modifications
315
+ - The CLI never stores secrets on disk (except when explicitly writing to .env files)
316
+
317
+ For security best practices, see [SECURITY.md](./SECURITY.md).
318
+
319
+ ## License
320
+
321
+ MIT
package/bin/vault.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../dist/index.js';
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node