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

email-otp-verify

v1.1.1

Published

a package witch utility functions to send OTP to emails and verifies them using emailauth-api

Downloads

3

Readme

Introduction

This is a Node.js module that provides a simple interface for sending and verifying OTP (One-Time Password) codes via an API. The API is hosted at https://emailauth-api.onrender.com. Installation

This module can be installed using npm:

npm install email-otp-verify

Usage

To use the module, import the sendOTP, verifyOTP, and resendOTP functions:

import { sendOTP, verifyOTP, resendOTP } from "email-otp-verify";

sendOTP(data)

This function sends an OTP code to the email address provided in the data object. The data object must have an email property that contains the email address. The function returns a Promise that resolves with the response including a token which will be required further when verifying OTP and resending OTP.

Optionally, you can also set the expiration time for the OTP by including a min property in the data object. The min property must be a number that represents the number of minutes before the OTP expires. If the min property is included, the function will modify the data object to include the expiresIn property instead, with the value set to the number of seconds until expiration.

const data = {
	email: "[email protected]",
	min: 5, // optional, sets the OTP expiration time to 5 minutes
};

sendOTP(data)
	.then((response) => {
		console.log(response);
	})
	.catch((error) => {
		console.error(error);
	});

verifyOTP(data)

This function verifies an OTP code that was sent to an email address. The data object must have a token property that contains the token received from the sendOTP function, and an otp property that contains the OTP code entered by the user. The function returns a Promise that resolves with the response from the API.

const data = {
	token: "example-token",
	otp: "123456",
};

verifyOTP(data)
	.then((response) => {
		console.log(response);
	})
	.catch((error) => {
		console.error(error);
	});

resendOTP(data)

This function resends an OTP code to the email address associated with the given token. The data object must have a token property that contains the token received from the sendOTP function. The function returns a Promise that resolves with the response from the API.

const data = {
	token: "example-token",
};

resendOTP(data)
	.then((response) => {
		console.log(response);
	})
	.catch((error) => {
		console.error(error);
	});

Error Handling

The module throws an error if the data object passed to any of the functions is missing a required property. Specifically, the sendOTP function requires an email property, the verifyOTP function requires token and otp properties, and the resendOTP function requires a token property.