1.2.20 • Published 4 years ago

brewery-auth-test v1.2.20

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

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.

1.2.16

4 years ago

1.2.17

4 years ago

1.2.18

4 years ago

1.2.19

4 years ago

1.2.20

4 years ago

1.2.12

4 years ago

1.2.13

4 years ago

1.2.10

4 years ago

1.2.11

4 years ago

1.2.14

4 years ago

1.2.15

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.21

4 years ago

1.1.12

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.20

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago