otplib-cli 1.0.1 → 2.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/LICENSE +2 -2
- package/README.md +81 -38
- package/dist/index.cjs +644 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/otplibx.cjs +1022 -0
- package/dist/otplibx.cjs.map +1 -0
- package/dist/otplibx.d.cts +2 -0
- package/package.json +32 -36
- package/.npmignore +0 -20
- package/bin/otplib.js +0 -1
- package/src/cli.js +0 -89
- package/src/constants.js +0 -26
- package/src/endec.js +0 -19
- package/src/generate.js +0 -61
- package/src/getConfig.js +0 -45
- package/src/index.js +0 -2
- package/src/initialise.js +0 -74
- package/src/qrcode.js +0 -33
- package/src/verify.js +0 -40
- package/yarn.lock +0 -1116
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,59 +1,102 @@
|
|
|
1
1
|
# otplib-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Command Line tool for OTP operations.
|
|
4
|
+
It provides stateless, scriptable and storage agnostic tooling.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## Installation
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
$ npm install -g otplib-cli
|
|
8
|
+
```bash
|
|
9
|
+
npm install -g otplib-cli
|
|
11
10
|
```
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
Two commands are available:
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
- **`otplibx`** - Includes an encrypted `.env` based storage
|
|
15
|
+
- **`otplib`** - Stateless CLI for scripting and custom backends
|
|
17
16
|
|
|
17
|
+
## Quick Start
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### otplibx
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
qrcode [options] generate a QR Code from configuration
|
|
25
|
-
encrypt [secret] encrypt secret to store in config
|
|
26
|
-
decrypt [secret] decrypt secret from config
|
|
21
|
+
```bash
|
|
22
|
+
# Initialize secrets file
|
|
23
|
+
otplibx init
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
# Add entry from file or clipboard
|
|
26
|
+
cat otp-uri.txt | otplibx add
|
|
27
|
+
pbpaste | otplibx add
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-p, --password [password] password to encrypt/decrypt the secret
|
|
33
|
-
-k, --secret [key] provide a secret key
|
|
34
|
-
-c, --config [path] path to configuration file
|
|
35
|
-
-m, --mode [mode] operation mode. (hotp | totp | authenticator)
|
|
36
|
-
-d, --digits [number] number of digits in token
|
|
37
|
-
-a, --algorithm [type] algorithm to generate for totp (sha1 | sha256 | sha512)
|
|
38
|
-
-s, --step [number] time step (totp / authenticator)
|
|
39
|
-
```
|
|
29
|
+
# Generate token
|
|
30
|
+
otplibx token A1B2C3D4
|
|
40
31
|
|
|
41
|
-
|
|
32
|
+
# List entries
|
|
33
|
+
otplibx list
|
|
34
|
+
otplibx list --filter github
|
|
42
35
|
|
|
36
|
+
# Interactive selection with fzf
|
|
37
|
+
npx otplibx token -n "$(npx otplibx list | fzf | cut -f2)" | pbcopy
|
|
38
|
+
# OR
|
|
39
|
+
npx otplibx list | fzf | cut -f2 | xargs -I {} npx otplibx token -n {} | pbcopy
|
|
43
40
|
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
|
|
42
|
+
### otplib
|
|
43
|
+
|
|
44
|
+
For scripting or custom secret backends, use the stateless `otplib` CLI.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Encode an otpauth URI into internal format
|
|
48
|
+
cat otp-uri.txt | otplib encode
|
|
49
|
+
# Output: A1B2C3D4=eyJkYXRhIjp7...}}
|
|
50
|
+
|
|
51
|
+
# Store the output in a JSON file (storage.json)
|
|
52
|
+
# { "A1B2C3D4": "eyJkYXRhIjp7...}}" }
|
|
53
|
+
|
|
54
|
+
# Generate token
|
|
55
|
+
cat storage.json | otplib token A1B2C3D4
|
|
56
|
+
|
|
57
|
+
# List entries
|
|
58
|
+
cat storage.json | otplib list
|
|
59
|
+
cat storage.json | otplib list --filter github
|
|
60
|
+
|
|
61
|
+
# Verify a token
|
|
62
|
+
cat storage.json | otplib verify A1B2C3D4 123456
|
|
48
63
|
```
|
|
49
64
|
|
|
50
|
-
##
|
|
65
|
+
## Commands
|
|
51
66
|
|
|
52
|
-
|
|
67
|
+
### otplibx
|
|
53
68
|
|
|
54
|
-
|
|
69
|
+
| Command | Description |
|
|
70
|
+
| ------------------------------ | --------------------------------- |
|
|
71
|
+
| `init [file]` | Initialize encrypted secrets file |
|
|
72
|
+
| `add` | Add entry (reads from stdin) |
|
|
73
|
+
| `token [-n] [id]` | Generate token |
|
|
74
|
+
| `type [-n] [id]` | Output entry type |
|
|
75
|
+
| `hotp update-counter <id> [n]` | Update HOTP counter |
|
|
76
|
+
| `verify <id> <token>` | Verify token |
|
|
77
|
+
| `list [--filter <query>]` | List entries |
|
|
78
|
+
| `guard update <key> <value>` | Update guardrail |
|
|
79
|
+
| `guard rm <key>` | Remove guardrail |
|
|
80
|
+
| `guard show` | Show guardrails |
|
|
81
|
+
|
|
82
|
+
Options: `-f, --file <path>` (default: `.env.otplibx`)
|
|
83
|
+
|
|
84
|
+
### otplib
|
|
55
85
|
|
|
56
|
-
|
|
86
|
+
| Command | Description |
|
|
87
|
+
| ------------------------------ | ------------------------------------------ |
|
|
88
|
+
| `encode [--save-uid <file>]` | Encode otpauth URI/JSON to internal format |
|
|
89
|
+
| `list [-f, --filter <query>]` | List entries |
|
|
90
|
+
| `token [-n] <id>` | Generate token (auto-detect) |
|
|
91
|
+
| `type [-n] <id>` | Output entry type |
|
|
92
|
+
| `hotp update-counter <id> [n]` | Update HOTP counter |
|
|
93
|
+
| `verify <id> <token>` | Verify token |
|
|
94
|
+
| `guard show` | Show guardrails |
|
|
95
|
+
|
|
96
|
+
## Documentation
|
|
97
|
+
|
|
98
|
+
See the [full documentation](https://otplib.yeojz.dev/guide/cli) for detailed usage, architecture, and integration with other secret managers.
|
|
99
|
+
|
|
100
|
+
## License
|
|
57
101
|
|
|
58
|
-
[
|
|
59
|
-
[npm-link]: https://www.npmjs.com/package/otplib-cli
|
|
102
|
+
[MIT](./LICENSE)
|