@zzznpm/clavis 1.2.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 +198 -0
- package/bunfig.toml +1 -0
- package/dist/index.js +2097 -0
- package/dist/tui.js +1568 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Clavis - Secret Management System
|
|
2
|
+
|
|
3
|
+
A command-line interface (CLI) tool for managing secrets with support for hierarchical key organization and fuzzy search.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Secret Management**: Create, read, update, and delete secrets
|
|
8
|
+
- **Hierarchical Keys**: Support for dot-separated keys (e.g., `foo.bar.baz`)
|
|
9
|
+
- **Fuzzy Search**: Search secrets by key patterns
|
|
10
|
+
- **Tag System**: Categorize secrets with tags
|
|
11
|
+
- **Expiration Tracking**: Optional expiration dates with visual indicators
|
|
12
|
+
- **Data Persistence**: Secrets stored in JSON format
|
|
13
|
+
- **Validation**: Comprehensive input validation
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Clone the repository
|
|
19
|
+
git clone <repository-url>
|
|
20
|
+
cd clavis
|
|
21
|
+
|
|
22
|
+
# Install dependencies
|
|
23
|
+
npm install
|
|
24
|
+
|
|
25
|
+
# Make CLI globally available (optional)
|
|
26
|
+
npm link
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Create a new secret
|
|
32
|
+
```bash
|
|
33
|
+
clavis create --key "api.github.production" --token "ghp_abc123" --tag "github" --comment "Production API token"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### List all secrets
|
|
37
|
+
```bash
|
|
38
|
+
clavis list
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Search secrets by key pattern
|
|
42
|
+
```bash
|
|
43
|
+
clavis list --search "github"
|
|
44
|
+
clavis list --search "api"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Filter secrets by tag
|
|
48
|
+
```bash
|
|
49
|
+
clavis list --tag "github"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Show secret details
|
|
53
|
+
```bash
|
|
54
|
+
clavis show "api.github.production"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Update a secret
|
|
58
|
+
```bash
|
|
59
|
+
clavis update "api.github.production" --token "ghp_newtoken123" --expiration "2024-12-31"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Delete a secret
|
|
63
|
+
```bash
|
|
64
|
+
clavis delete "api.github.production"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Clear all secrets (with confirmation)
|
|
68
|
+
```bash
|
|
69
|
+
clavis clear
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Secret Structure
|
|
73
|
+
|
|
74
|
+
Each secret record contains:
|
|
75
|
+
- **key** (required): Hierarchical identifier (e.g., `service.environment.scope`)
|
|
76
|
+
- **token** (required): The actual API token value
|
|
77
|
+
- **expiration** (optional): Expiration date in YYYY-MM-DD format
|
|
78
|
+
- **tag** (optional): Categorization tag
|
|
79
|
+
- **comment** (optional): Description or notes
|
|
80
|
+
- **createdAt**: Automatic timestamp
|
|
81
|
+
- **updatedAt**: Automatic timestamp
|
|
82
|
+
|
|
83
|
+
## Key Format Rules
|
|
84
|
+
|
|
85
|
+
- Must be non-empty string
|
|
86
|
+
- Can contain letters, numbers, underscores, and hyphens
|
|
87
|
+
- Parts separated by dots (`.`)
|
|
88
|
+
- Cannot start or end with dots
|
|
89
|
+
- Cannot contain consecutive dots
|
|
90
|
+
- Examples: `api.github`, `aws.production.s3`, `database.staging.readonly`
|
|
91
|
+
|
|
92
|
+
## Security Architecture
|
|
93
|
+
|
|
94
|
+
Clavis protects token values with a two-layer security model:
|
|
95
|
+
|
|
96
|
+
### 1. Master Password & Key Derivation
|
|
97
|
+
|
|
98
|
+
Before using Clavis for the first time, set a master password:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
clavis add pwd
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The password is **never stored in plain text**. Instead:
|
|
105
|
+
- It is hashed with **Argon2** (memory-hard key derivation function)
|
|
106
|
+
- The resulting Argon2 hash string is stored in the **OS keychain / credentials manager** (via `cross-keychain`), under service `clavis`, account `master`
|
|
107
|
+
|
|
108
|
+
To update the password, the current password must be verified first (via `argon2.verify`) before the new one is accepted.
|
|
109
|
+
|
|
110
|
+
### 2. Token Field Encryption
|
|
111
|
+
|
|
112
|
+
When token records are written to disk, the `token` field is encrypted with **AES-256-GCM**:
|
|
113
|
+
|
|
114
|
+
1. At write time, `CryptoService` reads the Argon2 hash from the keychain
|
|
115
|
+
2. The raw hash output (last `$`-delimited segment, base64-decoded) is used as the 32-byte AES key
|
|
116
|
+
3. Each token value is encrypted with a random 12-byte IV and the resulting ciphertext is stored as:
|
|
117
|
+
```
|
|
118
|
+
enc:<base64(iv[12 bytes] + authTag[16 bytes] + ciphertext)>
|
|
119
|
+
```
|
|
120
|
+
4. At load time, the process is reversed — tokens are decrypted in memory before use
|
|
121
|
+
5. Values not prefixed with `enc:` are returned as-is for backward compatibility
|
|
122
|
+
|
|
123
|
+
The AES key is derived from the Argon2 hash, so:
|
|
124
|
+
- The key is never stored directly on disk
|
|
125
|
+
- Without the correct master password in the keychain, token values cannot be decrypted
|
|
126
|
+
- GCM authentication tags provide integrity verification (tampered ciphertext is rejected)
|
|
127
|
+
|
|
128
|
+
### Key files
|
|
129
|
+
|
|
130
|
+
| File | Role |
|
|
131
|
+
|------|------|
|
|
132
|
+
| `src/services/CryptoService.js` | AES-256-GCM encrypt/decrypt, key derivation from keychain |
|
|
133
|
+
| `src/index.js` (`add pwd` / `get pwd`) | Argon2 hashing, keychain read/write |
|
|
134
|
+
|
|
135
|
+
## Data Storage
|
|
136
|
+
|
|
137
|
+
Secrets are stored in `data/tokens.json` in the project directory. The file is automatically created and managed by the application. Token values in this file are always AES-256-GCM encrypted (see Security Architecture above).
|
|
138
|
+
|
|
139
|
+
## TUI Interface
|
|
140
|
+
|
|
141
|
+
Clavis includes a Terminal User Interface (TUI) for interactive token management:
|
|
142
|
+
|
|
143
|
+
OpenTUI uses Bun's native FFI runtime. Install Bun first if it is not already available:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
curl -fsSL https://bun.sh/install | bash
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Then build and start the TUI:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm run go
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### TUI Components
|
|
156
|
+
The TUI uses Solid.js components rendered by OpenTUI. See [COMPONENTS.md](COMPONENTS.md) for detailed documentation on:
|
|
157
|
+
- **ConfirmDialog**: Interactive confirmation dialogs for dangerous operations
|
|
158
|
+
- **Warning**: Notification components for feedback and error messages
|
|
159
|
+
- Other TUI components and their usage
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
### Project Structure
|
|
164
|
+
```
|
|
165
|
+
src/
|
|
166
|
+
├── index.js # CLI entry point
|
|
167
|
+
├── tui/ # Terminal User Interface
|
|
168
|
+
│ ├── index.js # TUI entry point
|
|
169
|
+
│ ├── components/ # Solid.js/OpenTUI components
|
|
170
|
+
│ │ ├── App.jsx
|
|
171
|
+
│ │ ├── ConfirmDialog.jsx
|
|
172
|
+
│ │ ├── Warning.jsx
|
|
173
|
+
│ │ └── ...
|
|
174
|
+
│ ├── theme.js # Shared terminal color tokens
|
|
175
|
+
│ └── utils/ # TUI utilities
|
|
176
|
+
├── models/
|
|
177
|
+
│ └── Secret.js # Secret data model
|
|
178
|
+
├── services/
|
|
179
|
+
│ └── SecretStorage.js # Storage and business logic
|
|
180
|
+
└── utils/
|
|
181
|
+
└── validators.js # Input validation
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### TUI Testing
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Run all tests, including the Bun/OpenTUI smoke test
|
|
188
|
+
npm test
|
|
189
|
+
|
|
190
|
+
# Run only the TUI smoke test
|
|
191
|
+
npm run test:tui
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The TUI smoke test verifies that the interface mounts and its create and quit shortcuts work.
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
ISC
|
package/bunfig.toml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
preload = ["@opentui/solid/preload"]
|