import { HttpRequest, HttpResponse } from '@deepkit/http';
import { Algorithm, Bufferable, createDecoder, SignerPayload, SignerSync, VerifierSync } from 'fast-jwt';
type JwtExtras = Record<string, any>;
interface BaseJwtOptions {
    issuer?: string;
    audience?: string;
}
export interface JwtCookieOptions {
    secure?: boolean;
    sameSite?: 'Strict' | 'Lax' | 'None';
    domain?: string;
}
interface JwtGenerationOptions<T extends JwtExtras = object> extends BaseJwtOptions {
    id?: string;
    subject: string;
    expiresAt?: Date | number;
    expiryMins?: number;
    payload?: T;
}
interface VerifierOptions extends BaseJwtOptions {
    key: string | Buffer;
    algorithm: Algorithm;
}
export declare class ParsedJwt<T extends JwtExtras = object> {
    readonly isValid = true;
    id?: string;
    issuer: string;
    audience?: string;
    subject: string;
    issuedAtMs: number;
    get issuedAt(): Date;
    expiresAtMs: number;
    get expiresAt(): Date;
    payload: T;
    rawPayload: Record<string, any>;
}
export interface InvalidJwtValidationResult {
    isValid: false;
    isDecodable: boolean;
    isSignatureValid?: boolean;
    isPayloadValid?: boolean;
    isNotExpired?: boolean;
}
export type JwtValidationResult<T extends JwtExtras = object> = ParsedJwt<T> | InvalidJwtValidationResult;
interface JWTState {
    shouldVerify: boolean;
    issuerName: string;
    validityMins: number;
    cookieName: string;
    cookieRe: RegExp;
    signer: typeof SignerSync<SignerPayload>;
    verifier: typeof VerifierSync<Bufferable>;
    decoder: ReturnType<typeof createDecoder>;
}
export declare class JWT {
    private static _state?;
    private static get state();
    private static deriveEdPublicKey;
    static generate<T extends JwtExtras>(options: JwtGenerationOptions<T>): Promise<string>;
    static generateCookie<T extends JwtExtras>(options: JwtGenerationOptions<T>, response: HttpResponse, cookieOptions?: JwtCookieOptions): Promise<void>;
    static clearCookie(response: HttpResponse, cookieOptions?: JwtCookieOptions): Promise<void>;
    private static buildCookieAttributes;
    static createVerifier<T extends JwtExtras = object>(options: VerifierOptions): (token: string) => Promise<JwtValidationResult<T>>;
    static verify<T extends JwtExtras = object>(token: string, verifier?: JWTState['verifier']): Promise<JwtValidationResult<T>>;
    static decode<T extends JwtExtras = object>(token: string): Promise<JwtValidationResult<T>>;
    private static formatJwtResult;
    private static formatJwtError;
    static process(token: string): Promise<JwtValidationResult<object>>;
    static processWithRequest(request: HttpRequest): Promise<JwtValidationResult | null>;
    private static getExpirationTs;
}
export {};
export declare type __ΩJwtCookieOptions = any[];
export declare type __ΩInvalidJwtValidationResult = any[];
export declare type __ΩJwtValidationResult = any[];
//# sourceMappingURL=jwt.d.ts.map