2.0.0 • Published 5 years ago

porichoy v2.0.0

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

Porichoy · NID Verification Gateway of Bangladesh · GitHub license npm version

const porichoy = require('porichoy');

const person = {nid: "1456782945", dob: "1999-11-29", name: "Asik Ahmed"};

const createAccount = async () => {
  if(await porichoy.valid(person)) {
    //Your code for creating account.
  }
}

Intro

This package will make it very easy to use Porichoy API in your NodeJS project. It is zero dependency package so you will get faster perfermance than using other aproaches like 'request' module. This package is now ready to use in production. Although more new features are on the way. Feel free to provide feedback, I will highly appreciate it.

  • Visit the official website of Porichoy API to get your API Key.
  • For Porichoy API documentation visit this website.
  • This npm package is still under mass development. This package is not managed by the officals of Porichoy API.

Installation

npm i porichoy;

Configaration

Setting API Key.

porichoy.setApiKey(<api_key>);

or set env variable PORICHOY_API_KEY = <api_key>

Setting mode.

Information about mode is here.

porichoy.setModeToTest(); // It is the default mode.
porichoy.setModeToProduction();
porichoy.setModeToTestPass();
porichoy.setModeToTestFail();

or

porichoy.setMode(<mode_name>);

or set env variable NODE_ENV = <mode_name>

####Getting mode.

porichoy.getMode();

####Getting API Key.

porichoy.getApiKey();

Example Usage

####The promise based approach

const porichoy = require("porichoy");

porichoy.setApiKey(<api_key>);

const person = {nid: "1456782945", dob: "1999-11-29", name: "Asik Ahmed"};

(async () => console.log((await porichoy.valid(person))? 'Valid NID':'Invalid NID'))();

####The callback approach

const porichoy = require("porichoy");

porichoy.setApiKey(<api_key>);

// The information to be verified
const person = {nid: "1456782945", dob: "1999-11-29", name: "Asik Ahmed"};

porichoy.verify(person, s => {
  //s will return true if the verification succeed.
  if (s) {
    console.log("The person's NID is real");
  } else {
    console.log("The person's NID is fake");
  }
});

Person Object Schema

KeyData TypeDescription
nidString10 or 17 digits. If 13 digits, add the 4 digit year to the front of the ID
dobDateDate of Birth YYYY-MM-DD Example 1980-03-28
nameStringPerson's full name, will match alphabetic characters only Mr. will convert to Mr ( exactly as in NID card)

Example

const person = {
  nid: "1234567890",
  dob: "1999-11-28",
  name: "Rejaul Kabir"
  };

Modes

The default mode is 'test'
NameDescriptionMethod to Set
'test'In this mode if you send data from this sample valid data then your verification will succeed otherwise it will fail. More infoporichoy.setModeToTes(); or porichoy.setMode('test');
'testPass'In this mode every of your verification request will succeed, mimicking the provided information as a real NID.porichoy.setModeToTestPass(); or porichoy.setMode('testPass');
'testFail' (N/A)In this mode every of your verification request will fail, mimicking the provided information as a fake NID.porichoy.setModeToTestFail(); or porichoy.setMode('testFail');
'production'In this mode every of your verification request will be verified with the real database. Note you must need to subscribe for production API Key in order to use this mode.porichoy.setModeToProduction(); or porichoy.setMode('production');

Methods

NameDescription
porichoy.valid(<Object>)This functions is promise based and it will return true if verification is success otherwise it will return false
<!--porichoy.verify(<Object>, callback).....-->
2.0.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

1.0.0

5 years ago