0.2.6 • Published 3 years ago

otp-cache v0.2.6

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

otp-cache

npm install

npm install otp-cache

example

npm run otp_example1
npm run otp_example2

How To Use ?

Generate OTP ( Promise )

 // example promise
  const {OtpGenerate}=require("otp-cache");
    OtpGenerate({digits:6,type_code:"numeric",time:60,secret:"no-secret",payload:{"user":"john doe"}).then((OTP)=>{
        console.log("OTP Code Generated Successfully ",OTP);
    }).catch((err)=>{
      console.error("Generate OTP : "+err.message);
    });

  // example async await
  (async()=>{
    const {OtpGenerate}=require("otp-cache");
    try {
        let OTP=await OtpGenerate({});
        console.log(OTP);
    } catch (error) {
        console.error("Generate OTP : ",error);
    }
})();

Noted

If you want to include a payload, you must include a secret key to ensure the security of your payload.

OTP GENERATE OPTIONS (object)

OptionsType dataDefault
digitsint4
type_codestringdynamic -> alphanumeric, numeric or alpha
timeint30 seconds
secretstringundefined
payloadobject,string,numberrecommended object form

Verify OTP (Promise) -

 // example promise
   const {OtpVerify}=require("otp-cache");
   OtpVerify({ otp_code: "ST0DK1",secret:"no-secret" }).then(()=>{
      console.log("OTP Verified");
   }).catch((err)=>{
     console.error("Verify OTP : "+err.message);
   });

 // example async await
 (async()=>{
   const {OtpVerify}=require("otp-cache");
   try {
        let OTP=OtpVerify({ otp_code: "ST0DK1" });
     if(OTP){
       console.log("OTP Verified");
     }
   } catch (error) {
       console.error("Verify OTP : ",error);
   }
})();
 

Notes

The Secret Key is used to decrypt the payload you include.

OTP VERIFY OPTIONS (object)

OptionsType dataDefault
otp_codestring""
secretstringyour secret key
0.2.6

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.1.2

3 years ago

1.0.3

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

1.0.1

3 years ago