2025-08-25 20:02:40 +02:00
2025-08-23 23:25:25 +02:00
2025-08-23 23:25:25 +02:00
wip
2025-08-21 21:44:44 +02:00
wip
2025-08-21 21:44:44 +02:00
2025-08-20 22:51:37 +02:00
2025-08-25 20:02:40 +02:00
2025-08-25 20:02:40 +02:00
wip
2025-08-21 21:44:44 +02:00
wip
2025-08-21 21:44:44 +02:00

Jwt Generator

A NestJs Library to generate JWTs.

Install

npm i --save @apihub24/jwt-generator

Requirements

Dependency Description
@nestjs/config use the NestJs Config Module to get some keys listed below
@apihub24/session_service used to create new Sessions when a new Token was created
JWT_SECRET NestJs Config Key for Secret used to Sign JWT
JWT_ISSUER NestJs Config Key for the JWT Issuer
JWT_AUDIENCE NestJs Config Key for the JWT Audience

Usage

import {
  JwtGeneratorModule,
  JwtService,
  APIHUB24_TOKEN_SERVICE_INJECTION_KEY,
} from "@apihub24/jwt-generator";
// we use the @apihub24/session_service implementation from the InMemorySessionsModule
import { InMemorySessionsModule } from "@apihub24/in-memory-sessions";
// use the takeExportedProviders function from NestJs Helper Module to select the exported Providers
import { takeExportedProviders } from "@apihub24/nestjs-helper";

// use JwtGeneratorModule
const inMemorySessionsModule = InMemorySessionsModule.forRoot();
const jwtGeneratorModule = JwtGeneratorModule.forRoot([
  ...takeExportedProviders(inMemorySessionsModule),
]);

@Module({
  imports: [jwtGeneratorModule],
})

// now you can inject the service with injection Token
import * as tokenAuthentication from "@apihub24/token-authentication";

export class Test {
  constructor(
    @Inject(APIHUB24_TOKEN_SERVICE_INJECTION_KEY) jwtGenerator: JwtService
  );

  async test(session: tokenAuthentication.ISession) {
    const token = await this.jwtGenerator.generate(session);
  }
}
Description
No description provided
Readme 242 KiB
Languages
TypeScript 100%