
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
jwt-in-cookie
Advanced tools
Wrapper around the functionality of jsonwebtoken to easily set and validate JWT tokens in express requests/responses
Wrapper around the functionality of jsonwebtoken to easily set and validate JWT tokens in express requests/responses
const jwtInCookie = require("jwt-in-cookie");
jwtInCookie.configure({secret: 'MY_SECRET'});
function (req, res) {
jwtInCookie.setJwtToken(res, data);
...
}
function (req, res) {
jwtInCookie.validateJwtToken(req);
...
}
function (req, res) {
jwtInCookie.clearToken(res);
...
}
config object literal
Configures the instance of jwt-in-cookie
Return: void
secret: string (required), secret to be used to sign the JWT
Eg:
abcdefghijklmnopqrstuvwxyz1234567890
timeoutDuration: string, length of time before signed data expires
Eg:
"2 hours","1d","20h",60
Adds payload as a token in the response cookie using configured secret & options
Return: string, token of payload
payload object
cookieOptions object, options that set in the cookie
httpOnly: boolean, javascript can't access the cookieexpires: number, time until the cookie expires (if 0, will expire at end of session)Clears the jwt token from the response
Return: void
Returns decoded token if request contains a valid JWT in its cookie (must be preceded by jwtInCookie.configure)
Return: object
Encodes payload using configured secret & options
Return: encoded payload
payload object
Retrieves decoded token from the input request's cookie (must be preceded by jwtInCookie.configure)
Return: decoded token
FAQs
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.