Kind: Type
Source: src/utils/jwt/types.ts
Part of: Utils
JWT Payload
JWTPayload describes the decoded payload data carried by a JSON Web Token. JWT parsing, validation, and authorization code can use this type to pass token claims through the application with a shared shape.
Definition
ts{ [key: string]: unknown exp?: number nbf?: number iat?: number iss?: string aud?: string | string[] }
Diagram
mermaidgraph LR Token[JWT] -->|decode and validate| Payload[JWTPayload] Payload --> Auth[Authorization logic] Payload --> Request[Request context]
Usage
tsimport type { JWTPayload } from './utils/jwt/types';
declare function getVerifiedPayload(request: Request): JWTPayload;
function authorizeRequest(request: Request) {
const payload = getVerifiedPayload(request);
// Read claims declared by JWTPayload before making access decisions.
return payload;
}
AI Coding Instructions
- Import
JWTPayloadwithimport typewhen it is only used for TypeScript checking. - Only create a
JWTPayloadafter the JWT has been decoded and validated. - Keep claim access aligned with the fields declared in
src/utils/jwt/types.ts. - Do not treat decoded payload data as trusted until JWT signature and expiry checks have completed.
Was this page helpful?