JwtService

Client-side JWT decode and inspection utilities. Explicitly NON-verifying — signature validation must happen server-side. Use for reading expiration, extracting claims for UX, or detecting expired tokens to redirect to login.

TypeScriptexample.ts
import { JwtService } from '@angular-helpers/security'

# Methods

MethodSignatureReturnsDescription
decodedecode(token: string): TTDecodes the payload segment of a JWT and returns it typed.
isExpiredisExpired(token: string, leewaySeconds: any): booleanbooleanReturns `true` when the token is expired relative to `Date.now()`. Missing or non-numeric `exp` counts as expired (fail-secure).
expiresInexpiresIn(token: string): numbernumberReturns milliseconds until the token expires. Negative when already expired. `0` when `exp` is missing.
claimclaim(token: string, name: string): T | nullT | nullExtracts a single claim from the payload. Returns `null` when the claim is absent or the token is malformed.
LCP N/A
CLS N/A
INP N/A