2.0.4 • Published 3 years ago

email-verification-code v2.0.4

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

Email Verification Code - V2 (V1 is just below)

What has changed?

We added 2 other functions to make the verification more secure and more intense. Now you can confirm with a Token that is generated at the beginning, or confirm with the code and the token at the same time!

How the changes can be helpful?

With the Token Code, you can easily verify the email with a link redirection without restraint!

Installation

This is a Node.js module available through the npm registry.

Installation is done using the npm install command:

npm install email-verification-code --save

Usage

const {
  sendCode,
  verifyCode,
  verifyToken,
  verifyBoth,
} = require("email-verification-code");

// Send the code to the User Email.

const data = {
  smtpInfo: {
    host: "0.0.0.0",
    port: 587,
    user: "test@example.com",
    pass: 23454,
  },
  company: {
    name: "FahDev.",
    email: "FahDev@gmail.com",
  },
  mailInfo: {
    emailReceiver: "FahDev1@gmail.com",
    subject: "Code Confirmation",
    text(code, token) {
      return `The Confirmation Code is: ${code} or click in this link: www.test.com/?token=${token}`;
    },
    html(code, token) {
      return `<p>The Confirmation Code is: ${code} or click in this link: www.test.com/?token=${token}</p>`;
    },
  },
};

sendCode(data);

// To verify the code validity

const response = verifyCode("example@email.com", 3429921);

// To verify with the Token code

const response = verifyToken("CunedqBnbxT85jbXLrApHh");

// To verify with both codes

const codes = {
  code: 3429921,
  token: "CunedqBnbxT85jbXLrApHh",
};

const response = verifyBoth(codes);

console.log(response);

smtpInfo

OptionTypeDefaultDescriptionRequired
hostStringnullSMTP HOST, required to Connect to Your SMTP & Send the mailTrue
portNumber587SMTP PORT, required to Connect to Your SMTP & Send the mailTrue
userStringnullSMTP User, required to Connect to Your SMTP & Send the mailTrue
passStringnullSMTP Password, required to Connect to Your SMTP & Send the mailTrue

company

OptionTypeDefaultDescriptionRequired
nameStringnullYour company Name, sent in the FROM tagfalse, One of the two is Required.
emailStringnullYour company email, sent in the from tagfalse, One of the two is Required.

mailInfo

OptionTypeDefaultDescriptionRequired
emailReceiverStringnullUser or Receiver EmailTrue
subjectStringnullThe mail SubjectFalse
textFunction''The mail content.NB: This function must have two parameters which corresponds to the Code & the TokenFalse, One of the two is Required.
htmlFunction''The mail content.NB: This function must have two parameters which corresponds to the Code & the TokenFalse, One of the two is Required.

How it Work!

The script generates a 6-digit & a token codes with 1 hour validity and saves it locally (For security reasons, please call the backend functions) and then sends an email with the message you had inserted previously.

To check the code, all you need to do is have the email address and the code. The script will look for the code in the local database, compare it, delete it if the code is correct, and give you a response to do so.

Email Verification Code - V1

With this package, you are able to send email verification codes and confirm them with using only 2 functions!

Installation

This is a Node.js module available through the npm registry.

Installation is done using the npm install command:

npm install email-verification-code --save

Usage

const { sendCode, verifyCode } = require("email-verification-code");

// Send the code to the User Email.

const data = {
  smtpInfo: {
    host: "0.0.0.0",
    port: 587,
    user: "test@example.com",
    pass: 23454,
  },
  company: {
    name: "FahDev.",
    email: "FahDev@gmail.com",
  },
  mailInfo: {
    emailReceiver: "FahDev1@gmail.com",
    subject: "Code Confirmation",
    text(code) {
      return `The Confirmation Code is: ${code}`;
    },
    html(code) {
      return `<p>The Confirmation Code is: ${code}</p>`;
    },
  },
};

sendCode(data);

// To verify the code validity

const response = verifyCode("example@email.com", 3429921);

console.log(response);

smtpInfo

OptionTypeDefaultDescriptionRequired
hostStringnullSMTP HOST, required to Connect to Your SMTP & Send the mailTrue
portNumber587SMTP PORT, required to Connect to Your SMTP & Send the mailTrue
userStringnullSMTP User, required to Connect to Your SMTP & Send the mailTrue
passStringnullSMTP Password, required to Connect to Your SMTP & Send the mailTrue

company

OptionTypeDefaultDescriptionRequired
nameStringnullYour company Name, sent in the FROM tagfalse, One of the two is Required.
emailStringnullYour company email, sent in the from tagfalse, One of the two is Required.

mailInfo

OptionTypeDefaultDescriptionRequired
emailReceiverStringnullUser or Receiver EmailTrue
subjectStringnullThe mail SubjectFalse
textFunction''The mail content. NB: This function must have only one parameter which corresponds to the CodeFalse, One of the two is Required.
htmlFunction''The mail content. NB: This function must have only one parameter which corresponds to the CodeFalse, One of the two is Required.

How it Work!

The script generates a 6-digit code with 1 hour validity and saves it locally (For security reasons, please call the backend functions) and then sends an email with the message you had inserted previously.

To check the code, all you need to do is have the email address and the code. The script will look for the code in the local database, compare it, delete it if the code is correct, and give you a response to do so.

License

MIT

2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago