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.

Installation
pnpm add @eleven-labs/nest-profiler-auth@alphaThere is no stable release yet — install every
@eleven-labs/nest-profiler*package with the@alphadist-tag (@latestresolves to nothing).
No additional peer dependencies beyond nestjs-cls (already required by @eleven-labs/nest-profiler).
Setup
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 whenPROFILER_ENABLEDis on. Wire the coreProfilerModuleonce at the root — the recommended setup bundles the root-level profiler modules into a singleProfilingModulebehind aConditionalModulegate (see Enabling and disabling the profiler and the example app). A top-levelenabledoption is also supported as an alternative.
What it collects
| Field | Description |
|---|---|
isAuthenticated | true when request.user is populated (Passport) |
user | The request.user object (with sensitive fields masked) |
roles | user.roles or user.role (normalized to array) |
jwtClaims | Decoded 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.