# otplib-cli

> CLI tool for managing encrypted OTP vaults

Latest version **13.5.0** (published 2026-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install otplib-cli
pnpm add otplib-cli
yarn add otplib-cli
bun add otplib-cli
```

Provides the commands `otplib`, `otplibx`.

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 13.5.0 |
| Published | 2026-08-21 |
| First published | 2017-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 179.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2296 |
| Author | Gerald Yeo |
| Maintainers | geraldyeo |
| Keywords | otp, totp, hotp, 2fa, cli, vault |

## Links

- npm: https://www.npmjs.com/package/otplib-cli
- Repository: https://github.com/yeojz/otplib
- Homepage: https://github.com/yeojz/otplib#readme
- Issues: https://github.com/yeojz/otplib/issues
- npm.io page: https://npm.io/package/otplib-cli

## Dependencies (3)

- [otplib](https://npm.io/package/otplib.md) 13.5.0
- [commander](https://npm.io/package/commander.md) ^15.0.0
- [@otplib/core](https://npm.io/package/@otplib/core.md) 13.5.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 13.5.0 (latest) — 2026-08-21
- 13.4.1 — 2026-05-30
- 13.4.0 — 2026-03-19
- 2.0.0 — 2026-02-12
- 1.0.1 — 2017-04-15
- 1.0.0 — 2017-04-15

## README

# otplib-cli

A Command Line tool for OTP operations.
It provides stateless, scriptable and storage agnostic tooling.

## Installation

```bash
npm install -g otplib-cli
```

Two commands are available:

- **`otplibx`** - Includes an encrypted `.env` based storage
- **`otplib`** - Stateless CLI for scripting and custom backends

## Quick Start

### otplibx

```bash
# Initialize secrets file
otplibx init

# Add entry from file or clipboard
cat otp-uri.txt | otplibx add
pbpaste | otplibx add

# Generate token
otplibx token A1B2C3D4

# List entries
otplibx list
otplibx list --filter github

# Interactive selection with fzf
npx otplibx token -n "$(npx otplibx list | fzf | cut -f2)" | pbcopy
# OR
npx otplibx list | fzf | cut -f2 | xargs -I {} npx otplibx token -n {} | pbcopy
```

### otplib

For scripting or custom secret backends, use the stateless `otplib` CLI.

```bash
# Encode an otpauth URI into internal format
cat otp-uri.txt | otplib encode
# Output: A1B2C3D4=eyJkYXRhIjp7...}}

# Store the output in a JSON file (storage.json)
# { "A1B2C3D4": "eyJkYXRhIjp7...}}" }

# Generate token
cat storage.json | otplib token A1B2C3D4

# List entries
cat storage.json | otplib list
cat storage.json | otplib list --filter github

# Verify a token
cat storage.json | otplib verify A1B2C3D4 123456
```

## Commands

### otplibx

| Command                        | Description                       |
| ------------------------------ | --------------------------------- |
| `init [file]`                  | Initialize encrypted secrets file |
| `add`                          | Add entry (reads from stdin)      |
| `token [-n] [id]`              | Generate token                    |
| `type [-n] [id]`               | Output entry type                 |
| `hotp update-counter <id> [n]` | Update HOTP counter               |
| `verify <id> <token>`          | Verify token                      |
| `list [--filter <query>]`      | List entries                      |
| `guard update <key> <value>`   | Update guardrail                  |
| `guard rm <key>`               | Remove guardrail                  |
| `guard show`                   | Show guardrails                   |

Options: `-f, --file <path>` (default: `.env.otplibx`)

### otplib

| Command                        | Description                                |
| ------------------------------ | ------------------------------------------ |
| `encode [--save-uid <file>]`   | Encode otpauth URI/JSON to internal format |
| `list [-f, --filter <query>]`  | List entries                               |
| `token [-n] <id>`              | Generate token (auto-detect)               |
| `type [-n] <id>`               | Output entry type                          |
| `hotp update-counter <id> [n]` | Update HOTP counter                        |
| `verify <id> <token>`          | Verify token                               |
| `guard show`                   | Show guardrails                            |

## Documentation

See the [full documentation](https://otplib.yeojz.dev/guide/cli) for detailed usage, architecture, and integration with other secret managers.

## License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/otplib-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
