Developer's note

This package is for generating OTP with the provider handling the validity and storage of the OTP. This is developed as for a study with the use of QR code with OTPs for improved security. For any questions and suggestions feel free to send an email to alidejandoandrada@gmail.com.

Getting Started
Installation
NPM or yarn
npm install paperstack or yarn add paperstack
Usage
Importing package
const paperstack = require('paperstack')
Initialization

Avoid storing your credentials directly in variable. We recommend storing them in the ENV and access them through process.ENV.variable_name

Create a separate file to for the package initialization and call init().

const paperstack = require('paperstack') const client = new paperstack(email, password, clientSecret, clientID) client.init() module.exports = client
Schema 1

A simple OTP schema with the OTP in QR option.

Generate raw OTP in QR
ParameterTypeRequiredDefault ValueDescription
uniqueIdstringtrueA unique ID which will be used later as reference for verification of OTP

This will return an object containing the OTP and a base64 string that can be rendered to an image which contains the raw OTP.

client.upsertUser(uniqueID)
OTP verification
ParameterTypeRequiredDefault ValueDescription
idstringtrueA unique ID for a valid generator
OTPstringtrueOTP user input

OTP verification. Returns a bool. This can be used with either of the 2 schemas

client.verifyOTP(id, otp)
Schema 2

OTP schema where the user can generate OTP for himself/herself when logging in. Generator is valid for a limited amount of time generation can only be allowed by the developer(Ideally called upon login attempt).

Create OTP Generator
ParameterTypeRequiredDefault ValueDescription
idstringtrueA unique ID which will be used later as reference for verification of OTP
expirynumbertrueDuration of the OTP generator validity in seconds(Roughly 86400 seconds a day).

Creates an OTP generator. Returns a link that is valid within the Expiry's duration. It is advised for the user to save the QR code instead of the link.

client.createOTPGenerator(id, expiry)
Allow OTP generation of valid generator
ParameterTypeRequiredDefault ValueDescription
idstringtrueA unique ID for a valid generator

Allows the valid generator to generate OTPs using the generator link. Valid for only 5 minutes

client.allowGenerateOTP(id)
Check user status using ID
ParameterTypeRequiredDefault ValueDescription
idstringtrueA unique ID used earlier to generate and OTP or create a Generator

Returns an object contaning the current status and details linked to an ID.

client.checkUserStatus(id)