quickotp
Version:
Simplified, Quickly OTP Generate, Verify
54 lines (41 loc) • 1.8 kB
Markdown
//img.shields.io/npm/v/quickotp.svg)](https://npmjs.org/package/quickotp)
[](https://npmjs.org/package/quickotp)
[](https://github.com/donginl/quickotp/blob/master/LICENSE)
Simplified, Quickly OTP Generate, Verify on Node.js!
OTP, Generated by this module supports Google Authenticator and similar applications.
The `quickotp` module works with Node.js v12.x and later version too.
```
$ npm install quickotp
```
or
```
$ yarn add quickotp
```
```js
// If you want to use the TOTP...
import { TOTP } from 'quickotp';
// If you want to use the HOTP...
import { HOTP } from 'quickotp';
let uri = TOTP.create('key', 'label'); // Create TOTP! (May return the URL with "otpauth" schema)
let uri = HOTP.create('key', 'label'); // or Create HOTP! (May return the URL with "otpauth" schema)
// Create OTPAuth URL QRCode (have two ways, but both are the same way.)
// First Way (using TOTP...)
try {
let qrcode = await TOTP.qrcode(uri); // return a URL that has been encoded QRCode in Base64. (Content-Type: image/png)
} catch(err) {
console.error(err);
}
// Second Way (using HOTP...)
try {
let qrocde = await HOTP.qrcode(uri); // return a URL that has been encoded QRCode in Base64. (Content-Type: image/png)
} catch(err) {
console.error(err);
}
let verify = TOTP.verify('key', 'token'); // TOTP Token (OTP Number) Valid check (If valid : return to 'true', invalid : return to false)
let verify = HOTP.verify('key', 'token', 'counter') // HOTP Token (OTP Number) Valid check (If valid : return to 'true', invalid : return to false)
```
[![NPM](https: