Description
otplib is a one time password library for TypeScript, for Node.js and the browser. It implements HOTP, the counter based one time password defined in RFC 4226, and TOTP, the time based version in RFC 6238 that authenticator apps use. The library is written in TypeScript with complete type definitions, and its API is async first, with synchronous alternatives. It has a pluggable architecture, so you can swap the crypto and Base32 implementations through plugins, using Web Crypto, Node crypto or your own. The project says it is compatible with common authenticator apps, including Google, Microsoft and Authy. The site has an interactive demo. For TOTP, tokens refresh every 30 seconds, and for HOTP, a counter increments with each use. The server side check accepts a token from the current counter up to a window ahead, which allows for resynchronization. Documentation is split into a guide, an API reference and a CLI. The library is released under the MIT License, and its source is on GitHub under yeojz.…
Highlights
- HOTP and TOTP per RFC 4226 and RFC 6238
- TypeScript types with an async first API
- Pluggable crypto and Base32 implementations
- Works with Google, Microsoft and Authy authenticator apps
- Interactive demo, guide, API reference and CLI
Ratings & Reviews
No ratings yet
Be the first to rate Otplib.
People also visit
Otplib FAQ
What is otplib?
A TypeScript library for one time passwords and two factor authentication, for Node.js and the browser.
Which standards does it follow?
HOTP from RFC 4226 and TOTP from RFC 6238, which the README describes as the standard for authenticator apps.
Which authenticator apps work with it?
The site says it is compatible with Google, Microsoft, Authy and many more.
Can it run in the browser?
Yes. It supports Node.js and the browser, and can use Web Crypto.
How does server side verification work?
The server accepts tokens from the current counter up to a window ahead, to allow for resynchronization.
Is it free?
Yes. It is released under the MIT License and the source is on GitHub.
What are the best Otplib alternatives?
Popular alternatives to Otplib include Otpauth, Otp.NET and Totp RS. See all Otplib alternatives



