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

auth-setup

v1.0.6

Published

A npm package to setup two-step-auth package localy for custom emails and servers, you are in control of your data.

Downloads

2

Readme

npm i --save auth-setup

  • A node file with prebuilt server functions for setting up two-step-auth locally for custom Mail ID's and server.

prerequisites

  • You need PYTHON for the successful execution of the package

  • Download PYTHON.

Need for the package

  • As per the suggestions, people need the package to be available locally, and also have them easily set for hosting,
  • Privacy concerns , Even though we never share any email ID's that was sent using the package two-step-auth, and neither do we use it for our purposes, people wanted their own server so this was created on top of that, You have control on your data.
    • You have control on your data

    • Own Mail ID

    • Host on your favorite servers / Micro servers

    • Greater speeds of sending mails

Usage (server side configuration)

  • Create a config file inside the project and add the following variables to the ENV file
    • File Name : (test.env) for example.
loginEmailID = "[email protected]"
loginPassword = "samplePassword"
  • In your index.js / server.js
  • Initialise your express server.
const express = require('express')
const app = express();
  • Import the authSetupFiles object from the package.
const {authSetupFiles} = require('auth-setup')
  • Declare your config file path.
authSetupFiles.filePath = "test.env"
  • Delcare your session name / Company Name (optional)
authSetupFiles.sessionName = "Sample"
  • Declare your favorite route to use with the package and point it using the app.use() method.
app.use("/email", authSetupFiles.emailRouter)
  • You are all done for the backend setup 👍

Usage (accessing the routes from Frontend)

  • Check if credentials pass initial test.

  • I am using localhost:5000 as the parent route here, it is applicable for all other routes.
  • To check if the package is able to login to the Mail ID provided, performa get request so the script will login to your Email ID and then give you a call back in JSON stating if it was success. Pass the route you specified in the previous step. ... app.use('/email', ...)
GET http://localhost:5000/email
  • Success Response on login:
{
  "success": true,
  "message": "Successfully logged in"
}
  • Failure Response on login:
{
  "success": false,
  "message": "credentials mis-match"
}
  • Sending an OTP to the reciever Email

  • All you need to do is to send a POST Request to the same route that you specified with the query containing the Paramaters : [email protected]
POST http://localhost:5000/[email protected]
  • This will yield you an OTP and the JSON will look as follows.
    • Gives an OTP.
    • Gives a reference mail to work with.
{
  "success": true,
  "OTP": 121568,
  "mail" : "[email protected]",
  "message": "OTP sent successfully"
}
  • Complete Example :

const express = require('express')
const app = express();

const {authSetupFiles} = require('auth-setup')
authSetupFiles.filePath = "config/test.env"
authSetupFiles.sessionName = "Sample"

app.use("/email", authSetupFiles.emailRouter)

app.listen(5000, async(req, res)=>{
    console.log("server started")
})

Preparing your NODE server for HOSTING:

  • HEROKU
    • node test.js --setup=heroku
    • node .js --setup=heroku
    • Execute the following command in the command line,
    • This will create a ProcFile and a requirements.txt file in helping with hosting in Heroku.
    • If you have already created a ProcFile for Heroku, then kindly ignore, Just add the requirements.txt file if you have missed it

    • (Adding Requirements.txt) in your Command Promt follow the snippet below.

    pip freeze > requirements.txt

Feel free to raise PR for issues :)

Thankyou ❤️