Registry / auth-security / clhq-auth-module

clhq-auth-module

JSON →
library1.1.0-alpha.189jsnpmunverified

A reusable authentication module for NestJS v11 applications, currently in early alpha (v1.1.0-alpha.189). It provides guards, decorators, and services for JWT-based auth with role-based access control. Differentiators: minimal configuration, full TypeScript support, and designed for monorepo workflows. Requires @nestjs/core >=11.0.0 and @nestjs/common >=11.0.0. Active development with frequent breaking changes before stable.

npm install clhq-auth-module
INSTALL
IMPORT
SIG · CLHQ-AUTH-MODULE
C
clhq-auth-module
auth-securityjavascriptv1.1.0-alpha.189
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthModule
import { AuthModule } from 'clhq-auth-module'
const AuthModule = require('clhq-auth-module')
ESM-only package; CommonJS require will fail.
JwtAuthGuard
import { JwtAuthGuard } from 'clhq-auth-module'
import { JWTGuard } from 'clhq-auth-module'
Guard name is case-sensitive and includes 'Auth'.
Roles
import { Roles } from 'clhq-auth-module'
import { Roles } from '@nestjs/passport'
Custom Roles decorator provided by this module, not from passport.
CurrentUser
import { CurrentUser } from 'clhq-auth-module'
import { Req } from '@nestjs/common'
Use this decorator to access the authenticated user in route handlers.

Shows how to import and configure AuthModule with a JWT secret in a NestJS application.

import { Module } from '@nestjs/common'; import { AuthModule } from 'clhq-auth-module'; import { AppController } from './app.controller'; @Module({ imports: [ AuthModule.forRoot({ jwtSecret: process.env.JWT_SECRET ?? '', expiry: '1h', }), ], controllers: [AppController], }) export class AppModule {}
Debug
Known issues
breakingThe module API is unstable in alpha versions; forRoot() options may change without notice.
fix
Pin to a specific alpha version and monitor release notes.
affects: <1.0.0
deprecatedUsage of 'AuthModule.forRootAsync()' with factory provider is deprecated in favor of synchronous forRoot().
fix
Pass configuration directly to forRoot().
affects: >=1.1.0-alpha.150
gotchaJwtAuthGuard must be applied to controllers or routes; it does not automatically protect all endpoints.
fix
Add @UseGuards(JwtAuthGuard) to controller class or individual routes.
affects: >=1.0.0
breakingThe 'Roles' decorator previously accepted an array of strings; now requires an array of enums.
fix
Define an enum for roles and pass an array of enum values.
affects: >=1.1.0-alpha.170
Errors
Common errors & fixes
Cannot find module 'clhq-auth-module' or its corresponding type declarations.
Missing npm install or TypeScript not configured to resolve the module.
fix
Run 'npm install clhq-auth-module' and ensure 'moduleResolution' is 'node' or 'node16' in tsconfig.json.
Error: Forbidden resource
Request lacks valid JWT token or token is expired.
fix
Provide a valid JWT token in the Authorization header: 'Bearer <token>'.
Nest can't resolve dependencies of the AuthModule (JwtAuthGuard, ...)
AuthModule.forRoot() not called or missing peer dependencies.
fix
Ensure @nestjs/core and @nestjs/common are installed and AuthModule.forRoot() is added to the imports array.
Upgrade
Version history
1.1.0-alpha.189latest on npm
Audit
Dependencies
@nestjs/corerequiredPeer dependency for NestJS integration
@nestjs/commonrequiredPeer dependency for NestJS integration
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
clhq-auth-module — npm install clhq-auth-module · libregistry