1.1.1 • Published 6 months ago
quickotp v1.1.1
QuickOTP
Simplified, Quickly OTP Generate, Verify on Node.js! OTP, Generated by this module supports Google Authenticator and similar applications.
Support platforms
The quickotp
module works with Node.js v12.x and later version too.
Installation
$ npm install quickotp
or
$ yarn add quickotp
Usage
// 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)