Novices Performing Miracles

    @petercraftsmn/auth-util

    2.2.0 • Public • Published

    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)

    Install

    npm i @petercraftsmn/auth-util

    DownloadsWeekly Downloads

    33

    Version

    2.2.0

    License

    ISC

    Unpacked Size

    58.8 kB

    Total Files

    17

    Last publish

    Collaborators

    • petercraftsmn