Nocturnal Pumpkin Maelstrom

    skutil-express-jwt

    1.1.0 • Public • Published

    express-jwt together with a jwtSign method attached to request.

    Install

    yarn add skutil-express-jwt

    Usage

    const jwtUtil = require('skutil-express-jwt')
    jwtUtil.init({
        secret: 'some string',
        algorithms: ['HS256', ...],
        sign: { ... },
        verify: { ... }
    })
    
    const token = jwtUtil.sign({ ... })
    
    app.get('/some/uri', jwtUtil.midware, (req, res, next) => {
        const auth = req.auth
        ...
    })
    

    Api

    jwtUtil.init(options)

    options:

    • secret: String
    • algorithms: String[] the algorithms supported in sign and verify
    • sign: jwt.SignOptions all the options of jwt.sign
    • verify: expressjwt.Params all the options of expressjwt

    jwtUtil.sign(data, signOptions)

    signOptions: all the options of jwt.sign

    • the algorithm is used in the order of signOptions.algorithm > options.sign.algorithm > options.algorithms[0]

    Install

    npm i skutil-express-jwt

    DownloadsWeekly Downloads

    1

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    2.33 kB

    Total Files

    4

    Last publish

    Collaborators

    • stayknight