@theredhead — Frontend Library - v1.0.0
    Preparing search index...
    • Decode a compact-serialisation JWT string into its constituent parts: header, payload, and raw signature.

      This function does NOT verify the token's signature. Signature verification requires access to the signing key or a JWKS endpoint and is the responsibility of the consumer's backend or auth library.

      Type Parameters

      Parameters

      • token: string

        A JWT in compact serialisation (header.payload.signature).

      Returns JwtToken<TPayload>

      A JwtToken with decoded header and payload.

      If the token structure is malformed or the JSON is invalid.

      import { decodeJwt } from '@theredhead/lucid-foundation';

      const jwt = decodeJwt(rawTokenString);
      console.log(jwt.payload.sub); // "user-123"
      console.log(jwt.payload.exp); // 1742601600