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 'fintegrate-auth';
✗ import AuthModule from 'fintegrate-auth';
Named export, not default. ESM/CJS compatible.
JwtAuthGuard
✓ import { JwtAuthGuard } from 'fintegrate-auth';
✗ const JwtAuthGuard = require('fintegrate-auth');
Named export. Wrong: require returns module object, not the guard class directly.
CurrentUser
✓ import { CurrentUser } from 'fintegrate-auth';
✗ import { CurrentUser } from '@nestjs/common';
Custom decorator, not from NestJS common. Typed with Fintegrate user interface.
AuthService
✓ import { AuthService } from 'fintegrate-auth';
✗ import { AuthService } from './auth/auth.service';
Service is re-exported from the package; do not import from internal paths.
Shows registration of AuthModule with JWKS URI and usage of JwtAuthGuard and CurrentUser decorator in a NestJS controller.
// app.module.ts
import { Module } from '@nestjs/common';
import { AuthModule } from 'fintegrate-auth';
@Module({
imports: [
AuthModule.register({
jwksUri: process.env.JWKS_URI ?? 'https://example.com/.well-known/jwks.json',
audience: process.env.AUDIENCE ?? 'my-api',
issuer: process.env.ISSUER ?? 'https://example.com/',
}),
],
})
export class AppModule {}
// protected.controller.ts
import { Controller, Get, UseGuards } from '@nestjs/common';
import { JwtAuthGuard, CurrentUser } from 'fintegrate-auth';
@Controller('protected')
export class ProtectedController {
@UseGuards(JwtAuthGuard)
@Get('profile')
getProfile(@CurrentUser() user: any) {
return user;
}
}
Debug
Known issues
deprecatedThe 'AuthModule.forRoot()' static method is deprecated, use 'AuthModule.register()' instead.fixReplace 'AuthModule.forRoot({...})' with 'AuthModule.register({...})'. affects: <=1.0.100
breakingIn v1.0.0, the 'CurrentUser' parameter decorator returns the entire JWT payload; previously returned only the sub claim.fixIf you relied on sub-only, change your controller to destructure the user object: 'getProfile(@CurrentUser() { sub }: any)'. affects: >=1.0.0 <1.0.50
gotchaIf you do not configure 'jwksUri', the module throws at runtime: 'JWKS URI is required'. It is not optional.fixAlways provide 'jwksUri' in the configuration object passed to 'AuthModule.register()'.
affects: >=1.0.0
deprecatedThe 'AuthGuard' export (formerly 'AuthGuard') is deprecated, use 'JwtAuthGuard' instead.fixImport 'JwtAuthGuard' instead of 'AuthGuard'.
affects: >=1.0.0 <=1.0.99
gotchaPassing a string audience to 'register()' instead of a string array will cause mismatch if JWT contains audience as array.fixAlways pass audience as an array: audience: ['my-api'].
affects: >=1.0.0
Errors
Common errors & fixes
Error: JWKS URI is required
Missing or undefined jwksUri in AuthModule.register() configuration.
fixProvide jwksUri in the config object, e.g., AuthModule.register({ jwksUri: '...' }). Cannot read properties of undefined (reading 'sub')
The CurrentUser decorator returned undefined because the guard is not applied or the token is invalid.
fixEnsure @UseGuards(JwtAuthGuard) is applied to the route and the JWT is valid.
Error: audience mismatch
The JWT's audience claim does not match the configured audience in AuthModule.
fixCheck that the JWT contains the expected audience and that the audience config matches exactly (string for single, array for multiple).
TypeError: Passport.authenticate is not a function
Missing Passport installation or incorrect import order.
fixEnsure passport and @nestjs/passport are installed and that PassportModule is imported before AuthModule.
Audit
Dependencies
jwks-rsarequiredRS256 JWT verification against JWKS endpoint
passportrequiredCore Passport authentication framework
passport-jwtrequiredJWT strategy for Passport
@nestjs/corerequiredNestJS core module, required for guards and decorators
@nestjs/commonrequiredNestJS common utilities
@nestjs/passportrequiredPassport integration for NestJS