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 CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2017 Gerald Yeo
3
+ Copyright (c) 2026 Gerald Yeo
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,59 +1,102 @@
1
1
  # otplib-cli
2
2
 
3
- > Command-line tool for OTP token generation and verification
3
+ A Command Line tool for OTP operations.
4
+ It provides stateless, scriptable and storage agnostic tooling.
4
5
 
5
- [![npm][npm-badge]][npm-link]
6
+ ## Installation
6
7
 
7
- ## Install
8
-
9
- ```
10
- $ npm install -g otplib-cli
8
+ ```bash
9
+ npm install -g otplib-cli
11
10
  ```
12
11
 
13
- ## Usage
12
+ Two commands are available:
14
13
 
15
- ```
16
- Usage: otplib [options] [command]
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
- Commands:
19
+ ### otplibx
20
20
 
21
- init [options] initialise a new configuration
22
- generate [options] generate new tokens
23
- verify [options] [token] validate a token against the setting or configuration
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
- Options:
25
+ # Add entry from file or clipboard
26
+ cat otp-uri.txt | otplibx add
27
+ pbpaste | otplibx add
29
28
 
30
- -h, --help output usage information
31
- -V, --version output the version number
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
- For individual command options, you can run `-h` for each of them. i.e.
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
- $ otplib init -h
45
- $ otplib generate -h
46
- $ otplib verify -h
47
- $ otplib qrcode -h
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
- ## Related
65
+ ## Commands
51
66
 
52
- - [otplib](https://github.com/yeojz/otplib) - API for this module
67
+ ### otplibx
53
68
 
54
- ## License
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
- `otplib-cli` is [MIT licensed](./LICENSE)
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
- [npm-badge]: https://img.shields.io/npm/v/otplib-cli.svg?style=flat-square
59
- [npm-link]: https://www.npmjs.com/package/otplib-cli
102
+ [MIT](./LICENSE)