Skip to main content
The server module exports utility functions for working with ID token claims and other authentication-related operations.

filterDefaultIdTokenClaims

Filters out default OIDC claims from an ID token, leaving only custom claims.
Record<string, any>
required
The ID token claims object to filter
Record<string, any>
Object containing only custom claims (default OIDC claims removed)

Example

Use Case

This utility is helpful when you want to extract only the custom claims from an ID token, such as:
  • Application-specific user metadata
  • Custom authorization data (roles, permissions)
  • Business logic data
According to OIDC best practices, custom claims should use namespaced URIs (e.g., https://my-app.com/claim-name) to avoid conflicts with standard claims.

DEFAULT_ID_TOKEN_CLAIMS

An array constant containing the standard OIDC ID token claim names that are filtered by filterDefaultIdTokenClaims.

Default Claims List

The following claims are considered default OIDC claims and will be filtered out:

Example

Usage with beforeSessionSaved Hook

A common use case is to extract custom claims when saving the session:
Then access custom claims from your session:

See Also