4.0.0-alpha.42 • Published 3 months ago

@concepta/nestjs-jwt v4.0.0-alpha.42

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
3 months ago

Rockets NestJS JWT

A flexible JWT utilities module for signing and validating tokens.

This module extends/wraps the @nestjs/jwt module.

Project

NPM Latest NPM Downloads GH Last Commit GH Contrib NestJS Dep

Overview

The module exports three services: JwtSignService, JwtIssueService, and JwtVerifyService.

The JwtSignService maintains two separate JwtService instances from the @nestjs/jwt module, one for managing access tokens and one for managing refresh tokens. Each one can be configured separately at registration time for maximum flexibility.

The JwtIssueService and JwtVerifyService use the JwtSignService internally for generating and validating tokens.

Installation

yarn add @concepta/nestjs-jwt

Configuration

ENV

Configurations available via environment.

VariableTypeDefault
JWT_MODULE_ACCESS_SECRET<string \| Buffer>randomUUID() * see noteAccess token secret
JWT_MODULE_ACCESS_EXPIRES_IN<string \| number>'1h'Access token expiration length
JWT_MODULE_REFRESH_SECRET<string \| Buffer>copied from access secretRefresh token secret
JWT_MODULE_REFRESH_EXPIRES_IN<string \| number>'1y'Refresh token expiration length

* For security reasons, a random UUID will only be generated for the default secret when NODE_ENV !== 'production'.

Advanced

It is possible to override all services at registration time with a custom service that meets their respective interfaces.