import * as jwt from "jsonwebtoken"; import type { StringValue } from "ms"; import { GarmrOptions } from "../garmr.options"; /** * Service for issuing and managing JSON Web Tokens. * * @example * ```typescript * const { token } = tokenService.issue({ sub: user.id, aud: "session" }) * ``` */ export declare class TokenService { private readonly options; constructor(options: GarmrOptions); /** * Issues a signed JWT with the given payload. * * @param payload - The claims to include in the token * @param options - Optional signing options * @param options.expiresIn - Override the default expiration time * @returns Object containing the signed token and decoded payload */ issue(payload: Record, options?: { expiresIn?: StringValue | number; }): { token: string; payload: jwt.JwtPayload; }; /** * Verifies a JWT and returns the payload. * * @param token - The JWT string to verify * @returns The verified JWT payload * * @example * ```typescript * const payload = tokenService.verify(token) * const user = await userRepo.findOne({ where: { id: payload.sub } }) * ``` */ verify(token: string): jwt.JwtPayload; /** * Decodes a JWT without verifying its signature. * * @param token - The JWT string to decode * @returns The decoded JWT payload * * @example * ```typescript * const payload = tokenService.decode(token) * ``` */ decode(token: string): jwt.JwtPayload; }