1.0.7 • Published 8 years ago

quickotp v1.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

QuickOTP

Build Status NPM NPM Downloads License Donate

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 v4.x and later version too.

Notice

This module dependency to the qr module. qr module, the operating system-specific additional installation you may need So, please check this link.

This module use Promise If you want to use previous callback method, please install previous version as 1.0.6

Installation

$ npm install quickotp

Usage

// If you want to use the TOTP...
const totp = require('quickotp').TOTP;
// If you want to use the HOTP...
const hotp = require('quickotp').HOTP;

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...)
let qrcode = totp.qrcode(uri).then(
    (data) => { 
        // data.uri is return a URL that has been encoded QRCode in Base64. (Content-Type: image/png)
        // data.raw is raw png data
        console.log(data.uri)  
    },
    (err) => { console.error(err) }
);

// Second Way (using HOTP...)
let qrcode = hotp.qrcode(uri).then(
    (data) => { 
        // data.uri is return a URL that has been encoded QRCode in Base64. (Content-Type: image/png)
        // data.raw is raw png data
        console.log(data.uri)  
    },
    (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)

Author: DONGIN LEE

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

0.0.1

9 years ago

1.0.0

9 years ago