Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
jwt-auth-utility
Advanced tools
**jwt-auth-utility** is a lightweight and easy-to-use utility package for handling JSON Web Tokens (JWT) in Node.js applications. It simplifies the process of generating, signing, verifying, and refreshing access and refresh tokens, making it ideal for im
jwt-auth-utility is a lightweight and easy-to-use utility package for handling JSON Web Tokens (JWT) in Node.js applications. It simplifies the process of generating, signing, verifying, and refreshing access and refresh tokens, making it ideal for implementing JWT-based authentication in your project.
Install the package via npm:
npm i jwt-auth-utility
To start using jwtauthutil, first import and initialize the JWT utility by providing your secrets:
import JWT from 'jwt-auth-utility';
const jwtUtil = new JWT('your_access_secret', 'your_refresh_secret',
{
accessTokenLife: '1d', // Optional, defaults to '1d'
refreshTokenLife: '7d' // Optional, defaults to '7d'
});
You can generate both access and refresh tokens by passing a payload:
const payload=
{
userId: 123,
email: "exapmle@mail.com",
role: "admin"
}
const { accessToken, refreshToken } = jwtUtil.generateTokens(payload);
To verify an access token:
const decodedAccessToken = jwtUtil.verifyAccessToken(accessToken);
To verify a refresh token:
const decodedRefreshToken = jwtUtil.verifyRefreshToken(refreshToken);
To generate a new access token using a refresh token:
const newAccessToken = jwtUtil.refreshAccessToken(refreshToken);
You can decode tokens without verifying their validity:
const payload = jwtUtil.decodeToken(accessToken);
FAQs
**jwt-auth-utility** is a lightweight and easy-to-use utility package for handling JSON Web Tokens (JWT) in Node.js applications. It simplifies the process of generating, signing, verifying, and refreshing access and refresh tokens, making it ideal for im
We found that jwt-auth-utility demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.