import type { Dict, Strict } from 'worktop/utils'; export declare namespace JWT { // Custom token claims export type Claims = Dict; export type Header = { /** algorithm */ alg?: string; /** type */ typ?: string; /** key id */ kid?: string; // others? } & Strict; export type Payload = { /** issuer */ iss?: string; /** subject */ sub?: string; /** audience */ aud?: string; /** jwt ID */ jti?: string; /** not before */ nbf?: number; /** expires */ exp?: number; /** issued at */ iat?: number; } & Strict; } export interface Factory { sign(payload: JWT.Payload

): Promise; verify(input: string): Promise>; } export namespace Options { type Common = JWT.Payload & Omit & { /** custom header claims, if any */ header?: H; /** token lifetime, in seconds */ expires?: number; // TODO: ttl? }; export type HMAC = Common & { key: string; }; export type RSA = Common & { privkey: string; pubkey: string; }; export type ECDSA = Common & { privkey: string; pubkey: string; }; } export function decode(input: string): { header: JWT.Header; payload: JWT.Payload

; signature: string; }; // HMAC + SHA-256|384|512 export function HS256(options: Options.HMAC): Factory; export function HS384(options: Options.HMAC): Factory; export function HS512(options: Options.HMAC): Factory; // RSASSA-PKCS1-v1_5 + SHA-256|384|512 export function RS256(options: Options.RSA): Factory; export function RS384(options: Options.RSA): Factory; export function RS512(options: Options.RSA): Factory; // // RSASSA-PSS + SHA-256|384|512 // export function PS256(options: any): Factory; // export function PS384(options: any): Factory; // export function PS512(options: any): Factory; // ECDSA + P-256|384|512 curve export function ES256(options: Options.ECDSA): Factory; export function ES384(options: Options.ECDSA): Factory; export function ES512(options: Options.ECDSA): Factory;