How to use jwt-simple.default:
GitHub: nhttp/nhttp
80 81 82 83 84 85 86 87 88 89
} const prop = opts.propertyName ?? "auth"; rev[prop] = {}; let decode; try { decode = import_jwt_simple.default.decode(token, secret, opts.noVerify, opts.algorithm); rev[prop] = decode; } catch (err) { const e = new UnauthorizedError(err.message ?? "Invalid token"); if (typeof opts.onExpired === "function" && err.message.includes("expired")) {
How to use jwt-simple.decode:
GitHub: naturalcrit/homebrewery
50 51 52 53 54 55 56 57 58 59 60
//Account Middleware app.use((req, res, next)=>{ if(req.cookies && req.cookies.nc_session){ try { req.account = jwt.decode(req.cookies.nc_session, config.get('secret')); //console.log("Just loaded up JWT from cookie:"); //console.log(req.account); } catch (e){} }
297
862
36
See more examples
How to use jwt-simple.encode:
GitHub: naturalcrit/homebrewery
405 406 407 408 409 410 411 412 413 414 415
// Login app.post('/local/login', (req, res)=>{ const username = req.body.username; if(!username) return; const payload = jwt.encode({ username: username, issued: new Date }, config.get('secret')); return res.json(payload); }); }
297
862
36
See more examples