export interface DecodedJwt { header: unknown; payload: Record; /** From the `iat`, `nbf` and `exp` claims, when the token carries them. */ times: { claim: string; label: string; at: Date; }[]; } /** A JWT's header and payload, which travel as base64url; `null` when the token does not parse. Reads a token without verifying it. */ export declare function decodeJwt(token: string): DecodedJwt | null; /** What most JWT libraries take when signing, e.g. jsonwebtoken's `sign` options. */ export interface JwtSignOptions { /** Seconds, or a duration string such as `'1h'`. */ expiresIn?: string | number; algorithm?: string; [option: string]: unknown; } /** The JWT library calls the builder wraps, e.g. `{ generate: jwt.sign, verify: jwt.verify }`. */ export interface JwtLibrary { generate: (payload: Payload, secret: string, options?: SignOptions) => string; verify: (token: string, secret: string) => unknown; } export type JwtVerification = { ok: true; payload: Payload; } | { ok: false; reason: 'expired' | 'malformed' | 'invalid'; error: unknown; }; export declare class JWTBuilder { jwt: JwtLibrary; secret: string; /** Sign options every `generate` starts from, e.g. `{ expiresIn: '1h' }`. */ defaults?: NoInfer | undefined; constructor(jwt: JwtLibrary, secret: string, /** Sign options every `generate` starts from, e.g. `{ expiresIn: '1h' }`. */ defaults?: NoInfer | undefined); /** Signs `payload`; `options` win over the builder's defaults. */ generate(payload: Payload, options?: SignOptions): string; /** The payload, or `undefined` for any failure; `validate` says which. */ verify(token: string): Payload | undefined; /** The payload, or why the token was refused: `expired`, `malformed` (not a JWT at all) or `invalid` (bad signature, wrong audience...). */ validate(token: string): JwtVerification; } //# sourceMappingURL=jwt.d.ts.map