import { SingleResult } from "toyhauler-common/contracts"; import { AuthSettings } from "./AuthSettings"; import { ITokenConstraint } from "./ITokenConstraint"; import { Token } from "./Token"; export declare class JwtFactory { private readonly constraints; /** Factory for reading, writing, and signing JWTs */ constructor(settings: AuthSettings, constraints: ITokenConstraint[]); /** The shared secret used to sign JWTs */ private readonly secret; private readonly requireTokenExpiration; private readonly builtInPayloadMapper; /** Generates a signature for the given token. * Uses the default secret for this instance if one is not passed in. * (Encodes the header and the payload together, using the encoding algorithm declared in the token header with the given or default secret). */ sign(token: Token, secret?: string): Token; generateSignature(token: Token, secret?: string): string; /** serializes and encodes the jwt to its standard, transmission-ready string representation. * (ie: `${EncodedHeader}.${EncodedPayload}.${Signature}") */ encode(token: Token): string; /** Parses the given string jwt into readable constituents. * Returns undefined when token has an invalid format. * Throws any encountered exceptions. */ tryDecode(jwt: string): Token | undefined; private encodeToUtf8; private fromUtf8; private encodeToBase64; private fromBase64; /** Ensures only that the signature is genuine and that token is not expired */ validate(jwt: string): SingleResult; /** Returns undefined if jwt string is improperly formatted or otherwise unreadable. Throws any encountered exceptions. */ tryExtend(jwt: string, durationInMinutes: number): Token | undefined; extend(jwt: Token, durationInMinutes: number): Token; /** Assembles a string of printable characters for use as a shared secret, * using Gibson Research's cryptographic-quality pseudo-random number generator (PRNG) */ static generateSecret(length?: number): string; }