npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vereafy

v1.0.9

Published

A NodeJS Library for Cecula Vereafy Two-Factor Authentication 2FA Service

Downloads

22

Readme

Vereafy

A Node JS package for Cecula Vereafy.

NPM

Build Status Codacy Badge codecov Known Vulnerabilities

Table of Content

  1. Introduction
  2. How to use the library
  3. Installation
  4. How to generate an API Key
  5. Importing Vereafy Library
  6. Initializating 2FA
  7. Resending OTP
  8. Completing 2FA
  9. Getting Balance
  10. Error Responses

Introduction

Vereafy is an SMS based 2-factor authentication service that uses machine learning to understand the causes of OTP delivery failures and resolves them instantly to ensure your login and sign up OTPs deliver.

The Vereafy Nodejs Library Project was created to enable nodejs developers integrate seamlessly with the Vereafy API.

How to use this library

  • Install vereafy from npm or yarn following the instructions in the Installation section or clone from GitHub
  • Login to the Cecula Developers Platform register your app and generate an API KEY
  • Import/Require the library into your script

Installation

Install with NPM:

npm i vereafy

Install with Yarn:

yarn add vereafy

Clone from GitHub

git clone https://github.com/cecula-vereafy/nodejs-library.git

How to generate an API Key

Your API Key is first generated when you register an app. To register an app, Login to the Developers Dashboard, Navigate to Apps > Add, Type the name of your app and click Submit. The app will be registered and a new API Key will be generated. Copy the API key into your project

Importing Vereafy Library

If you installed the library using npm or yarn, import the library into your script using the code below

const vereafy = require("vereafy");
vereafy.apiKey = "<API_KEY>"

Otherwise, if you cloned the library from GitHub, import the library into your script using the code below

const vereafy = require("./path/to/vereafy");
vereafy.apiKey = "<API_KEY>"

Initializing 2FA

The Vereafy 2fa initialization can be as simple as the following lines of code:

    var sendData = {
        "mobile": "23480xxxxxxxx"
    };

    vereafy.init(senData,(res)=>{
        // If status is success show user form to type OTP
    });

The initialization method returns a response that should look like this:

   {
       "status": "success",
       "pinRef": "1293488527"
   }

Resending OTP

In a case where your app users get impatient and hits the retry link on your app form, just call the resend method this way:

   var sendData = {
       "pinRef": "1293488527",
       "mobile": "23480xxxxxxxx"
   };

   vereafy.resend(sendData, (res)=>{
       // If status is success, show user form to type OTP
   });

The resend method returns a response that should look like this:

    {
        "status": "success",
        "pinRef": "1293488527"
    }

Completing 2FA

The Vereafy 2fa completion can be as simple as the following lines of code:

    var sendData = {
        "pinRef": "1293488527",
        "token": "123456"
    }
    vereafy.complete(sendData, (res)=>{
        // Handle failure or success response
    })

The completion method returns a response that should look like this if the parameters are correct:

    {
        "response": "success"
    }

Getting Balance

To get your balance on Vereafy, the getBalance method is used this way: This method requires no parameter:

    vereafy.getBalance((res)=>{
        // Do Something
    })

The get balance method returns a response that should look like:

    {
        "balance": 800
    }

Error Responses

In a case where the request fails due to one reason or another you should get an error response from the requested endpoint that looks like this:

        {
            "error": "Invalid PIN Ref",
            "code": "CE2000"
        }

The table below shows a list of error codes and their descriptions:

| Error Code | Description | |:----------:| :----------------------------------------------:| | CE1001 | Missing Fields | | CE1002 | Empty Fields | | CE1006 | Not a Nigerian Number | | CE2000 | Invalid PIN Ref | | CE2002 | PIN does not reference any verification request | | CE2003 | Mobile number does not match original request | | CE2001 | Invalid PIN | | CE2004 | Request Not Found | | CE7000 | Verification already succeeded | | CE7001 | Verification already failed | | CE6000 | Insufficient Balance | | CE5000 | Invalid Template ID | | CE5001 | Could not find referenced template |