otp-sender
v1.4.4
Published
This package provides an OTP (One-Time-Password) authentication system. It can be used to send otp to particular email and verify this otp.
Downloads
2
Readme
otp-sender
This package provides an OTP (One-Time-Password) authentication system. It can be used to send otp to particular email and verify this otp.
Installation
Run the command below in the terminal
npm install otp-sender
Importing the package
import otpSender from 'otp-sender'
Sending otp
Sends otp if email format is correct. Returns an json object that contains succes and token fields. If format is incorrect or another error occures, this exception can be handleded by "catch" keyword.
| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| email
| string
| Required. Email you want to send otp. |
var verification_token
otpSender.sendOtp(<email>).then((res)=>{
token=res.token
}).catch(err=>{console.log(err)})
Verifying otp
Verifies the otp if the paramaters' formats are correct. Returns a json object including declaring success if otp matches. If format is incorrect, otp does not match or another error occures, this exception can be handleded by "catch" keyword.
| Parameter | Type | Description |
| :-------- | :------- | :-------------------------------- |
| email
| string
| Required. Email we want to verify |
| otp
| string
| Required. Otp sent to this email |
| verification_key
| string
| Required. Verification key sent by sendOtp method |
otpSender.verifyOtp({
email:<email>,
otp:<otp>,
verification_key:<verification_key>,
}).then((res)=>{
token=res.token
}).catch(err=>{console.log(err)})