3.0.21 • Published 2 years ago
@chatpta/auth-util v3.0.21
Auth utilities class
Main Functionality
This is a collection of utility functions for use in authentication
Main functions
const { jwtUtilAuth, pwdUtilAuth } = require( '@chatpta/auth-util' );
Create jwt
const headerObject = {
alg: "SHA256", // Mendatory acceptable algorithm
...
};
const payloadObject = {
...
};
const jwt = jwtUtilAuth.createSignedJwtFromObject( headerObject, payloadObject, privateKey );
Verify jwt signature returns true
or false
const isVerified = jwtUtilAuth.verifyJwtSignature( jwt, publicKey );
Get header and payload object from jwt.
const { header, payload } = jwtUtilAuth.getHeaderPayloadFromJwt( jwt );
Create password hash to save in database
const hash = pwdUtilAuth.createPasswordHashWithRandomSalt( password, secret, algorithm );
Create another password hash based on saved hash to compare.
const hashForLogin = pwdUtilAuth.createPasswordHashBasedOnSavedAlgorithmSalt( passwordForLogin, savedPasswordHash, secret );
3.0.21
2 years ago
3.0.2
2 years ago
3.0.20
2 years ago
3.0.1
3 years ago
3.0.0
3 years ago
2.1.1
4 years ago
2.1.3
4 years ago
2.1.7
3 years ago
2.1.0
4 years ago
2.0.11
4 years ago
2.0.10
4 years ago
2.0.9
4 years ago
2.0.8
4 years ago
2.0.7
4 years ago
2.0.6
4 years ago
2.0.5
4 years ago
2.0.4
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