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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node_auth_module

v1.2.2

Published

Authentication module

Downloads

54

Readme

node_auth_module

Authentication module using node_db_module

This uses the sequelize framework to provide an authentication frameowork to integrate with your application, using supported SQL OSBDs.

Import the db schema

mysql -u [user] -D [database] -p < sql/schema.sql

Configure credentials

The basic credentials structure is the following. They can be setup as a file in the root that is passed on when instancing the module. You can also send the JSON directly if you are storing the varibles as ENV variables. Ex: (...),password:proccess.env.PASSWORD,(...)

{
  "sql": {
    "host":"127.0.0.1", 
    "database":"yourdatabasename",
    "username":"yourusername",
    "password":"yourpassword",
    "dialect":"mysql",
    "logging":false,
    "timezone":"+00:00"
  },
  "seedDB":false,
  "seedMongoDB":false,
  "seedDBForce":true,
  "db":"sql"
}

Simple example

const Auth =  require('node_auth_module')
const authModule=new Auth(".config_auth.js")
  • .config_auth.js is the JSON file with the credentials this file should be in the root of your app. (Not of this required module) Then run one of the following functions

Authentication

register

  • type: async function
  • parameters: firstName,lastName,email,password,thirdparty
    • firstName (string)
    • lastName (string)
    • email (string)
    • password (sring)
    • thirdparty (boolean) [optional]
  • returns id (int)
    • The primary key (id) of the table User
  • return error
    • if there is some problem
  • Usage:
authModule.auth.register(firstName,lastName,email,password,thirdparty)

activateUser

  • type: async function
  • parameters: id
    • id (int)
  • returns ??
    • db model with update result
  • return error
    • if there is some problem (it should at least)
  • Usage:
authModule.auth.activateUser(id)

inactivateUser

banUser

unbanUser

isBanned

isActive

resetpassword

resetpassword(id)
  • type:asycn function
  • Returns: new password

validateLogin

validateLogin(email,password,callback,req,res)
  • type:async function
  • Returns: What every happens in the callback function. Generally used to set alternative response in case of error in callback. {action,path,payload}

getUserInfo

getUserMetadata

getIdFromEmail

hashPassword

listUsers

validateEmailConfirmationToken

validateEmailConfirmationToken(email,confirmationToken)
  • Validates the confirmation token belongs to the email user
  • parameters: email, confirmationToken
  • Returns: boolean ###setNewConfirmationToken
setNewConfirmationToken(id)

Generates a new confirmation token and stores it for the user.

  • Returns confirmation token

Session

saveSession

  • type: async function
  • parameters: user_id,ipv4,ipv6,platform,valid,city,country
    • user_id (int)
    • ipv4 (string)
    • ipv6 (string)
    • platform (sring)
    • valid (boolean)
    • city (string)
    • country (string)
  • returns id
    • if all goes well
  • return error
    • if there is some problem
  • Usage:
authModule.session.saveSession(user_id,ipv4,ipv6,platform,valid,city,country)

listSessions

  • type: async function
  • parameters: userId
    • userId (int) [Primary key (id) from table Person]
  • returns (array)
    • List of all the session for the userId, the accessToken will not be present in the array
  • Usage:
authModule.session.listSessions(userId)

revokeSession

  • type: async function
  • parameters: id
    • id (int)
  • returns ??
    • update result
  • Usage:
authModule.session.revokeSession(id)

validateSession

  • type: async function
  • parameters: id,accessToken
    • id (int)
    • accessToken (string)
  • returns (boolean)
    • Valid or Not
  • Usage:
authModule.session.validateSession(id,accessToken)