@kaynooo/env-tools 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/README.md +45 -2
- package/dist/ev.js +1542 -0
- package/dist/redact.js +1055 -0
- package/package.json +37 -4
- package/src/dotenv.ts +152 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaynooo <contact@kaynooo.fr>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# env-tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Two CLIs that keep secrets out of a Claude Code transcript: `ev` lists and edits `.env` files with every secret masked, and `redact` masks secrets in any piped output.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bun install -g @kaynooo/env-tools
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## ev
|
|
10
|
+
|
|
11
|
+
| Command | What it does |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `ev list [file]` | every key of the folder's `.env*` files (or one file), secrets masked |
|
|
14
|
+
| `ev get KEY [file]` | one key's masked value, from every file that sets it or from one |
|
|
15
|
+
| `ev grep [-i] <regex> [file...]` | the keys matching the regex (matched against the key, never the value), values masked |
|
|
16
|
+
| `ev show <rev>:<file>` | an env file as a git revision holds it, values masked |
|
|
17
|
+
| `ev set KEY [file]` | sets a key in `.env` (or the file), the value read from stdin or `-F <file>` so it never appears in a command line, `--empty` for an empty value |
|
|
18
|
+
| `ev unset KEY [file]` | removes a key |
|
|
19
|
+
| `ev mv KEY --from <file> --to <file>` | moves a key's line as written, `--force` to replace one the target has |
|
|
20
|
+
| `ev diff <a> <b>` | names the keys set in one file and not the other, exit 1 when they differ |
|
|
21
|
+
| `ev missing [file]` | names the keys of `.env.example` (`--against`) that the file lacks, exit 1 when some are |
|
|
22
|
+
| `ev audit [dir...]` | lists the `.env` files any account can read or git tracks, and the compose files any account can read that write a secret or URL password out, with the fix for each, exit 1 when it finds one |
|
|
23
|
+
| `ev audit --fix [dir...]` | moves each secret a listed compose file writes out into the `.env` beside it as `${KEY}` (a key the `.env` sets to another value stays put), puts it back when `docker compose config` resolves differently, and shuts other accounts out of both files and of every listed `.env`; exit 1 when something is left |
|
|
24
|
+
|
|
25
|
+
A value is masked when its key looks like `TOKEN|SECRET|PASSWORD|KEY|PRIVATE|DSN`, when it is a private key, or in the password part of any URL (`postgres://user:***@host/db`) and any known token format. A masked value keeps a few leading characters and its length (`ghp***(40)`) so two values can be told apart. There is no flag that prints a secret unmasked.
|
|
26
|
+
|
|
27
|
+
Files are parsed and written back preserving comments, order, `export KEY=` prefixes, quoting and multiline values; only the lines a command touches change.
|
|
28
|
+
|
|
29
|
+
## redact
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
some-command 2>&1 | redact
|
|
33
|
+
git diff --cached | redact --check
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`redact` copies stdin to stdout line by line, masking:
|
|
37
|
+
|
|
38
|
+
- known token formats: `ghp_`, `github_pat_`, `glpat-`, `sk-`, `xox?-`, JWTs and the body of PEM private key blocks
|
|
39
|
+
- the password of any URL
|
|
40
|
+
- the values of secret-looking keys in the `.env*` files of the current folder (whole words only, from 6 characters), `--no-env` skips them
|
|
41
|
+
|
|
42
|
+
`redact --check` prints nothing of the input: it lists `<file>:<line>: <kind>` for each secret found and exits 1. On a diff it reads the added lines only and names the new file's line numbers.
|
|
43
|
+
|
|
44
|
+
## The parser and the guard
|
|
45
|
+
|
|
46
|
+
`import { parseDotenv, entries } from '@kaynooo/env-tools/dotenv'` gives the dotenv parser ev reads with: quotes, `export` prefixes, comments and multiline values. `src/guard.ts` holds the env file rules the `guard` bin of `@kaynooo/guard-tools` runs, exported to it as `./guard` within the workspace only.
|