Yes, a package named sendotp exists. This is solely used to deliver OTP through SMS.
You may discover a variety of examples in npmjs to help you complete your assignment.
However, I believe that implementing your own approach for transmitting and confirming OTP is preferable. Because utilising packages may result in the addition of methods that you do not require or the absence of functionality that you require.
For email verification, you may use Nodemailer, and for SMS verification, you can utilise Twiiolio. Create a random string and send it to the user through SMS or email. If you use MongoDB, you can check when the otp is formed and from there see how much time has elapsed since it was delivered.
You can use the msg91 for sending the otp to users.
Login to msg91 and get your template_id and api_key.
using msg91 api with the axios.
const axios = require('axios');
async function sendOtpTOUser(phone) {
const template = "template _id";
const apiKey = "api_key";
const sendotp = "https://api.msg91.com/api/v5/otp?template_id="+template+"&mobile="+phone+"&authkey="+apiKey;
let request_options1 = {
method: 'get',
url: sendotp
};
let otpResponse = await axios(request_options1);
console.log(otpResponse.data)
return otpResponse.data;
}
it will return the object as
{ request_id: '3166686e7867313634383535', type: 'success' }