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

nvbm

v1.0.1

Published

Verification of the number with the code, banning the user and managing repeat requests

Downloads

71

Readme

nvbm - number verification & Ban Management ⚔️

npm version license downloads Logo

Table of Contents 📕

Introduction 💡

nvbm is a powerful and flexible Node.js package for verifying numbers with codes, managing repeated requests, and banning users based on their device ID. Whether you're building a web or mobile application, nvbm helps you secure your app with authentication mechanisms and rate-limiting strategies.

Features 🚀

  • ✅ Verify user phone numbers with custom codes
  • 🚫 Ban users based on device ID
  • 📦 Integration with Sequelize and MySQL
  • ✔ Simple API with async/await support

Installation 📥

You can install the package via npm:

npm install nvbm --save

API ⭐

createDB

  • args: dbName, username, password, hostname
  • First, create a database and then send its values ​​mentioned above to nvbm.createDB()

useSequelize

  • args: sequelize
  • If you use Sequelize, it is better to use this method and give it only one instance of Sequelize as input.

checkBanDevice

  • args: device_id
  • Before you want to send a confirmation code, check whether the user with a certain device_id is prohibited from receiving SMS or not.

addRequest

  • args: number, code, device_id, checkBanDevice
  • If the user with her specific device_id was not restricted, we can confirm the request to receive the code and after receiving the code, we will call the addRequest() method (pay attention that you must also give the response checkBanDevice() to its input)

codeExist

  • args: number, code, device_id
  • In the last step, when the user wants to send the received code for authentication, we call this method

Example 📌

Pay attention to explanations:

  • banTimeList: Each time it is requested by a device_id, according to the value provided each time, it takes n time for the user to unblock (if it reaches the end of the list, it starts from the beginning) -> ( custom )
  • verifyTimer: Once the code is submitted, you have n seconds to submit the code for verification -> ( custom )
  • exampleCode: The amount of the code you received from anywhere (for example, SMS panel)
  • exampleDeviceID: You should get a unique ID from the client
import NVBM from 'nvbm'

const banTimeList = [60, 120, 180, 500, 3600] // array sec: 
const verifyTimer = 120 // sec ( 2 min )

const nvbm = new NVBM(banTimeList, verifyTimer)
await nvbm.useSequelize(sequelize) // or: await nvbm.createDB('dbName', 'root', '', 'localhost')
// first check ban list
const checkBanDeviceRes = await nvbm.checkBanDevice("exampleDeviceID") // you can log 'checkBanDeviceRes' ( maybe user is ban ( device_id ) )
if(!checkBanDeviceRes.isBan) {
  // call for send code to your number
  console.log(await nvbm.addRequest("exampleNumber", "exampleCode", "exampleDeviceID", checkBanDeviceRes)) 
}

// call for check & verify your number with Code
console.log(await nvbm.codeExist("exampleNumber", "exampleCode", "exampleDeviceID")) // if verifyed: true, else: false

License ⚖️

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.