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

brewery-auth-test

v1.2.20

Published

brewery-auth-test-bed

Downloads

5

Readme

brewery-auth-test

Authentication package using PassportJs

Table of Contents

Requirements

Install

npm i brewery-auth-test

Usage

Example usage in AmberJs Framework:


const BreweryAuth = require('brewery-auth');


class LoginUser extends Operation {
  constructor({ UserRepository }) {
    super();
    this.UserRepository = UserRepository;
  }

  async execute(data) {
    const { SUCCESS, VALIDATION_ERROR } = this.events;

    const { clientId, clientSecret } = data;


    const config = {
    dbConfig: {
        databaseName: process.env.DB_NAME,
        username: process.env.DB_USERNAME,
        password: process.env.DB_PASSWORD,
        dialect: process.env.DB_DIALECT,
        host: process.env.DB_HOST,

    },
    salt: process.env.SALT,
    tokenSecret: process.env.ACCESS_TOKEN_SECRET,
    refreshSecret: process.env.REFRESH_TOKEN_SECRET,
    nexmoSecret: process.env.NEXMO_API_SECRET,
    nexmoKey: process.env.NEXMO_API_KEY,
    sendgridKey: process.env.SENDGRID_API_KEY,
    senderEmail: process.env.SENDER_EMAIL,
    senderSms: process.env.SENDER_SMS 
  };

    try {
      const tokens = new BreweryAuth(config).login({ clientId, clientSecret });
      
      tokens.then(result=> {
        return this.emit(SUCCESS, result);
      });

    } catch(error) {
      this.emit(VALIDATION_ERROR, {
        type: 'VALIDATION ERROR',
        details: error.message
      });
    }
  }
}

LoginUser.setEvents(['SUCCESS', 'ERROR', 'VALIDATION_ERROR', 'NOT_FOUND']);

module.exports = LoginUser;

API

First you need to pass the needed parameters for this library like so:

BreweryAuth({
    dbConfig: {
        databaseName: ,
        username: ,
        password: ,
        dialect: ,
        host: 

    },
    salt: ,
    tokenSecret: ,
    refreshSecret: ,
    nexmoSecret: ,
    nexmoKey: ,
    sendgridKey: ,
    senderEmail: ,
    senderSms: 
})

For logging in a Client you need to pass a Client Id and Password and it will return a Access Token and Refresh Token.

.login({ clientId: '', clientSecret: '' })

If a Client does not exist yet, you can signup first by using this api and passing the fields needed.

.signup({ email: '', password: '', username: '', phone: '', MFA: '' })

If you have an existing user and just need to register a client just use this api and pass the following fields.

.register({ email: '', password: '', username: '', phone: '' })

After you use the signup api, you can execute this api after so can recieve a confirmation code and an email.

.signupConfirm({ clientId: '' , confirmationCode: '' }, { subject: '' , text: '' })

If you somehow did not recieved a confirmation code, you can use this api to resend the request by just passing the Client Id used.

.signupResend({ clientId: '' })

If you enabled the MFA upon signup, you have to use this api and pass the confirmation code in it

.loginMfa({ clientId: '', confirmationCode: '' })

If you change your password that was given by default upon registration you have to use this api to change it

.loginNewPasswordRequired({ clientId: '', newPassword: '' })

If you forgot your password, use this send a to request. A confirmation code will be sent to your phone number

.passwordForgot({ clientId: '' })

Once confirmation code from passwordForgot is sent, use this to set new password

.passwordReset({ clientId: '', confirmationCode: '', newPassword: '' })

Change user password. Used when user knows the old password, and wants to change it.

.passwordChange({ oldPassword: '', newPassword: '' })

View user profile

.profile({ clientId: '' })

Update user profile

.profileEdit({ clientId: '', body })

Update user multifactor authentication setting

.setMfa({ clientId: '', mfa: '' })

View current user multifactor-authentication setting

.getMfa({ clientId: '' })

Delete user information

.deleteUser({ clientId: '', clientSecret: '' })

For your resources that needed protection or authentication you can attach this api and use it on your routes first.

.initialize()

Then, Including this above your resources that needed authentication first

.JWTauthenticate()

Contributors

  • Jerico Estanislao
  • Jorelle Agustin

License

ISC © Stratpoint Technologies Inc.