NestJS Profiler
Packages

nest-profiler-auth

Capture the authenticated user, roles and JWT claims in the Security panel.

@eleven-labs/nest-profiler-auth

@eleven-labs/nest-profiler-auth captures the authentication context (Passport user, JWT claims, roles) of the current execution and displays it in a Security panel.

Security panel — authenticated user, roles and decoded JWT claims with sensitive fields masked

Installation

pnpm add @eleven-labs/nest-profiler-auth@alpha

There is no stable release yet — install every @eleven-labs/nest-profiler* package with the @alpha dist-tag (@latest resolves to nothing).

No additional peer dependencies beyond nestjs-cls (already required by @eleven-labs/nest-profiler).

Setup

auth.module.ts
import { ConditionalModule } from '@nestjs/config';
import { AuthCollectorModule } from '@eleven-labs/nest-profiler-auth';

const isProfilerEnabled = (env: NodeJS.ProcessEnv) => env['PROFILER_ENABLED'] === 'true';

@Module({
  imports: [
    ConditionalModule.registerWhen(
      AuthCollectorModule.forRoot({ maskUserFields: ['password', 'refreshToken'] }),
      isProfilerEnabled,
    ),
  ],
})
export class AppModule {}

Enabling / disabling — gate the collector with ConditionalModule.registerWhen(..., isProfilerEnabled) as shown, so it loads only when PROFILER_ENABLED is on. Wire the core ProfilerModule once at the root — the recommended setup bundles the root-level profiler modules into a single ProfilingModule behind a ConditionalModule gate (see Enabling and disabling the profiler and the example app). A top-level enabled option is also supported as an alternative.

What it collects

FieldDescription
isAuthenticatedtrue when request.user is populated (Passport)
userThe request.user object (with sensitive fields masked)
rolesuser.roles or user.role (normalized to array)
jwtClaimsDecoded JWT payload from Authorization: Bearer …

Automatic masking: Fields matching password|secret|key|token|credential are replaced with ***. Additional fields can be specified via maskUserFields.

Note: The JWT is decoded without verification (display only). Never rely on this data for security decisions.

Toolbar badge

The authenticated user's identifier (username, email, sub, or id) or anon for unauthenticated requests.

How it works

The collector reads request.user and the Authorization header from the current CLS context (set by the profiler middleware). It decodes the JWT payload using Buffer.from(payload, 'base64url') without any cryptographic verification.

Powered & maintained by

On this page