argonvault 1.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 +158 -0
- package/bun.lock +767 -0
- package/eslint.config.js +12 -0
- package/package.json +32 -0
- package/secrets.js +29 -0
- package/secrets.json +11 -0
- package/src/commands/decrypt.js +67 -0
- package/src/commands/encrypt.js +253 -0
- package/src/crypto.js +64 -0
- package/src/index.js +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# _argonvault – Secret Encryption CLI Tool_
|
|
2
|
+
|
|
3
|
+
_argonvault (**C**rypto **a**s **a** **B**) is a Node.js CLI tool for encrypting key/value secrets using Argon2id and AES-256-GCM, and generating both an encrypted JSON bundle and a JavaScript decryption module for use in your applications._
|
|
4
|
+
|
|
5
|
+
## _Features_
|
|
6
|
+
|
|
7
|
+
- **\*Interactive secret encryption**: Securely enter a passphrase and multiple key/value pairs.\*
|
|
8
|
+
- **\*Strong key derivation**: Uses Argon2id with high memory and time parameters.\*
|
|
9
|
+
- **\*Authenticated encryption**: Encrypts values with AES-256-GCM (per-secret IV and auth tag).\*
|
|
10
|
+
- **\*Bundled output**:\*
|
|
11
|
+
- `secrets.json` _– encrypted secrets and metadata._
|
|
12
|
+
- `secrets.js` _– JS helpers for decrypting each secret in your app._
|
|
13
|
+
- **\*Decrypt/verify mode**: Decrypt and verify stored secrets to confirm correctness.\*
|
|
14
|
+
|
|
15
|
+
## _Installation_
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Assuming you have Node.js and npm/bun installed
|
|
19
|
+
npm install -g argonvault
|
|
20
|
+
# or
|
|
21
|
+
bun install -g argonvault
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
_(If you’re working from source, clone this repo and install dependencies, then use_ `npm link` _or_ `bun link` _to expose the_ `argonvault` _CLI globally.)_
|
|
25
|
+
|
|
26
|
+
## _Usage_
|
|
27
|
+
|
|
28
|
+
### _1. Encrypt secrets (default mode)_
|
|
29
|
+
|
|
30
|
+
_Run the CLI to interactively enter your passphrase and secrets:_
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
argonvault encrypt
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
_You will be prompted to:_
|
|
37
|
+
|
|
38
|
+
1. **\*Enter a passphrase** (hidden/secure input).\*
|
|
39
|
+
2. **\*Enter multiple key/value pairs** (argonvault loops so you can add as many as you like).\*
|
|
40
|
+
|
|
41
|
+
_On success, argonvault generates:_
|
|
42
|
+
|
|
43
|
+
- `secrets.json` _– encrypted blobs and metadata._
|
|
44
|
+
- `secrets.js` _– decryption helpers._
|
|
45
|
+
|
|
46
|
+
### _2. Decrypt and verify secrets_
|
|
47
|
+
|
|
48
|
+
_Use decrypt mode to verify that your secrets were correctly encrypted:_
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
argonvault decrypt --secrets secrets.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
_You will be prompted for your passphrase. argonvault will:_
|
|
55
|
+
|
|
56
|
+
- _Derive the key with Argon2id._
|
|
57
|
+
- _Attempt to decrypt each stored secret._
|
|
58
|
+
- _Print decrypted key/value pairs on success._
|
|
59
|
+
- _Show an error if the passphrase is incorrect._
|
|
60
|
+
|
|
61
|
+
### _3. Help_
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
argonvault --help
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
_Displays available commands, options, and usage examples._
|
|
68
|
+
|
|
69
|
+
## _Output Files_
|
|
70
|
+
|
|
71
|
+
### `secrets.json`
|
|
72
|
+
|
|
73
|
+
_Structured encrypted secrets bundle:_
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"version": 1,
|
|
78
|
+
"secrets": {
|
|
79
|
+
"API_KEY": {
|
|
80
|
+
"salt": "base64...",
|
|
81
|
+
"iv": "base64...",
|
|
82
|
+
"authTag": "base64...",
|
|
83
|
+
"data": "base64..."
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- **\*version**: Schema version (for future upgrades).\*
|
|
90
|
+
- **\*secrets**: Map of secret names to their encrypted payloads and parameters.\*
|
|
91
|
+
|
|
92
|
+
### `secrets.js`
|
|
93
|
+
|
|
94
|
+
_Generated JavaScript decryption helpers:_
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
const CRYPTO_CONFIG = { time: 12, mem: 262144, hashLen: 32, parallelism: 1 };
|
|
98
|
+
|
|
99
|
+
export async function decryptAPI_KEY(passphrase) {
|
|
100
|
+
// argon2 derive key + aes-256-gcm decrypt
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function decryptDB_PASSWORD(passphrase) {
|
|
104
|
+
// argon2 derive key + aes-256-gcm decrypt
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- _One function per secret key (_`decrypt<KEY>`_)._
|
|
109
|
+
- _Each function:_
|
|
110
|
+
- _Accepts a_ `passphrase` _string._
|
|
111
|
+
- _Uses the same Argon2id + AES-256-GCM settings as the CLI._
|
|
112
|
+
- _Returns the decrypted value (or throws on error)._
|
|
113
|
+
|
|
114
|
+
## _Cryptography Details_
|
|
115
|
+
|
|
116
|
+
### _Key Derivation – Argon2id_
|
|
117
|
+
|
|
118
|
+
- **\*Type**: Argon2id\*
|
|
119
|
+
- **\*Memory**: 256 MB (262,144 KB)\*
|
|
120
|
+
- **\*Time**: 12 iterations\*
|
|
121
|
+
- **\*Parallelism**: 1\*
|
|
122
|
+
- **\*Hash length**: 32 bytes\*
|
|
123
|
+
|
|
124
|
+
_Each secret uses its **own random salt** (16 bytes), ensuring unique keys even with the same passphrase._
|
|
125
|
+
|
|
126
|
+
### _Encryption – AES-256-GCM_
|
|
127
|
+
|
|
128
|
+
- **\*Algorithm**: AES-256-GCM\*
|
|
129
|
+
- **\*IV**: 12 bytes random per secret\*
|
|
130
|
+
- **\*Salt**: 16 bytes random per secret\*
|
|
131
|
+
- **\*Auth tag**: Stored alongside the ciphertext and IV\*
|
|
132
|
+
|
|
133
|
+
_These parameters are encoded as Base64 in_ `secrets.json`_._
|
|
134
|
+
|
|
135
|
+
## _Example Project Structure_
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
my-secrets/
|
|
139
|
+
├── secrets.json # Encrypted data
|
|
140
|
+
└── secrets.js # Decryption functions
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
_You can import the functions from_ `secrets.js` _in your frontend or backend code and pass in the user’s passphrase to decrypt values at runtime._
|
|
144
|
+
|
|
145
|
+
## _Dependencies_
|
|
146
|
+
|
|
147
|
+
_argonvault relies on:_
|
|
148
|
+
|
|
149
|
+
- `argon2` _– Node.js bindings for Argon2id key derivation._
|
|
150
|
+
- `commander` _– CLI framework for command parsing and help output._
|
|
151
|
+
- `readline` _– For interactive prompts (passphrase and key/value input)._
|
|
152
|
+
|
|
153
|
+
## _Security Notes_
|
|
154
|
+
|
|
155
|
+
- _Use a **strong, unique passphrase** and avoid reusing passphrases from other systems._
|
|
156
|
+
- _Treat_ `secrets.json` _and_ `secrets.js` _as sensitive artifacts; they contain encrypted data but still need protection._
|
|
157
|
+
- _Never commit real production passphrases to source control._
|
|
158
|
+
- _When you enter a passphrase during_ `argonvault encrypt`_, argonvault prints an **estimated brute-force cost** (based on passphrase length/character set and an offline attacker with ~50k Argon2id guesses per second) **before you confirm it**. This is only a rough heuristic—always prefer long, random passphrases._
|