2.2.0 • Published 4 years ago

@petercraftsmn/auth-util v2.2.0

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

Auth utilities class

Main Functionality

This is a collection of utility functions for use in authentication

Main functions

####Constructor takes default values object

const defaultValues = {
    defaultAlgorithm: 'sha512',
    defaultSecret: 'dev-secret',
    defaultOutputType: 'base64'
};

const authUtil = new AuthUtil(defaultValues);

####Creates hash of password -> returns string

  • this string contains $algorithm.hash.salt
createPasswordHash(password, secretKey, algorithm, outputType)

####Verify hash -> returns true or false

  • Password: user password
  • passwordHash: hash stored in the database as it is -> created by createPasswordHash() function
  • secretKey: optional key, if different then the key used at initialization
verifyPasswordHash(password, passwordHash, secretKey)

####Create JWT -> returns url safe jwt string

  • This string follows jwt specification
createJWT(header, payload, key)

verify JWT signatures -> returns true or false

  • Returns true or false
verifySignatureJWT(jwt, key)

####read JWT -> return object containing header, payload, signature

  • Returns object containing { header: {}, payload: {} }
readJWT(jwt)
2.2.0

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.5

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.5

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago