
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
ngx-jwt-handler
Advanced tools
`ngx-jwt-handler` is an Angular library that provides services for managing JSON Web Tokens (JWT) and handling sessions in Angular applications. It includes a JWT handler service for decoding and managing JWT tokens, a session handler service for managing
ngx-jwt-handler
is an Angular library that provides services for managing JSON Web Tokens (JWT) and handling sessions in Angular applications. It includes a JWT handler service for decoding and managing JWT tokens, a session handler service for managing browser sessions, and an interceptor for adding JWT tokens to HTTP requests.
You can install ngx-jwt-handler
via npm:
npm install ngx-jwt-handler
JWT Handler Service The JWT handler service allows you to decode JWT tokens and check their expiration.
import { JwtHandlerService } from 'ngx-jwt-handler';
// Inject JwtHandlerService in your component or service
constructor(private jwtHandlerService: JwtHandlerService) {}
// Decode a JWT token
const decodedToken = this.jwtHandlerService.decodeToken(token);
// Check if a token is expired
const isTokenExpired = this.jwtHandlerService.isTokenExpired(token);
// Check if a token audience is valid
const isTokenAudienceValid = this.jwtHandlerService.isTokenAudienceValid(token, audience);
// Check if token claims are present
const hasRequiredClaims = this.jwtHandlerService.hasRequiredClaims(token, claims[]);
Session Handler Service The session handler service provides methods for managing browser sessions.
import { SessionHandlerService } from 'ngx-jwt-handler';
// Inject SessionService in your component or service
constructor(private sessionService: SessionHandlerService) {}
this.sessionService.add('accessToken', 'token');
this.sessionService.remove('accessToken');
this.sessionService.get('accessToken');
this.sessionService.has('accessToken');
this.sessionService.clear();
JWT Interceptor The JWT interceptor automatically adds JWT tokens to HTTP requests.
import { TokenInterceptor } from 'ngx-jwt-handler';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
// Include TokenInterceptor in your providers array
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptor,
multi: true
}
]
Contributions are welcome! Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
`ngx-jwt-handler` is an Angular library that provides services for managing JSON Web Tokens (JWT) and handling sessions in Angular applications. It includes a JWT handler service for decoding and managing JWT tokens, a session handler service for managing
The npm package ngx-jwt-handler receives a total of 3 weekly downloads. As such, ngx-jwt-handler popularity was classified as not popular.
We found that ngx-jwt-handler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.