
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@fullerstack/ngx-jwt
Advanced tools
A simple JWT library for Angular applications
This library helps with verification and payload extraction of JWT tokens
@fullerstack/ngx-jwt attempts to streamline the jwt operation of your Angular application, while promoting DRY DRY.
npm i @fullerstack/ngx-jwt |OR| yarn add @fullerstack/ngx-jwt
// In your environment{prod,staging}.ts
import { ApplicationConfig } from '@fullerstack/ngx-config';
import { LogLevel } from '@fullerstack/ngx-logger';
export const environment: ApplicationConfig = {
// app name
appName: '@fullerstack/ngx-jwt',
// production, staging or development
production: false,
log: {
// log level (application-wide)
level: LogLevel.debug,
},
jwt: {
// estimate time of http request between client -> server (greater than zero)
networkDelay: 1,
// backend may honor expired request arrive `x` seconds after expiry
expiryLeeway: 5,
},
};
// In your app.module.ts
import { ConfigModule } from '@fullerstack/ngx-config';
import { LoggerModule } from '@fullerstack/ngx-logger';
import { JwtModule } from '@fullerstack/ngx-jwt';
import { environment } from '../environments/environment';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
ConfigModule.forRoot(environment), // make the environment injectable
LoggerModule,
JwtModule,
],
bootstrap: [AppComponent],
})
export class AppModule {}
// In your app.module.ts
import { Component } from '@angular/core';
import { ConfigService } from '@fullerstack/ngx-config';
import { LoggerService } from '@fullerstack/ngx-logger';
import { JwtService } from '@fullerstack/ngx-jwt';
@Component({
selector: 'fullerstack-root',
template: `<h1>Welcome to {{ title }}!</h1>`,
})
export class AppComponent {
title = 'Fullerstack';
options = {};
constructor(
readonly config: ConfigService,
readonly logger: LoggerService,
readonly jwt: JwtService
) {
this.title = this.config.options.appName;
this.logger.info('AppComponent loaded ...');
const someToken = 'some-jwt-token-received-from-server'; // <part-1>.<part-2>.<part-2>
const payload = this.jwt.getPayload(someToken);
const isExpired = this.jwt.isExpired(payload);
if (!isExpired) {
const userId = payload.sub;
const nextRefresh = this.jwt.getRefreshTime(payload);
setTimeout(() => {
// connect to the server to get a new token
}, nextRefresh * 1000);
}
}
}
Released under a (MIT) license.
X.Y.Z Version
`MAJOR` version -- making incompatible API changes
`MINOR` version -- adding functionality in a backwards-compatible manner
`PATCH` version -- making backwards-compatible bug fixes
FAQs
A simple JWT library for Angular applications
The npm package @fullerstack/ngx-jwt receives a total of 2 weekly downloads. As such, @fullerstack/ngx-jwt popularity was classified as not popular.
We found that @fullerstack/ngx-jwt 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.