import { InvalidJWTVerification, JwtPayloadCreation, ValidJWTVerification } from '../../docs/docs'; import ConfigManager from '../config/config'; declare class JWTManager { #private; constructor(configManager: ConfigManager); /** * Generates a JWT (JSON Web Token) from a given payload. * * This method creates a JWT token by encoding the header and payload using base64 encoding, * and then creating a signature with a secret key. The token is assembled in the format: * `{header}.{payload}.{signature}`. * * @example * const token = authCrypto.jwt.generate({ * iss: 'auth.nasriya.net', * exp: Math.floor(Date.now() / 1000) + 60 * 60 * 24 // 24 hours from now in seconds * }) * @param payload The payload to include in the JWT. This must be an object that can be serialized to JSON. * @returns {string} The generated JWT token. * @throws {TypeError} If payload is not an object or is null. * @throws {Error} If the payload contains invalid or unexpected data. */ generate(payload: JwtPayloadCreation): string; /** * Verifies the validity of a given JWT token. * * This method checks if the token's signature is valid and if the token has expired. * It returns an object indicating whether the token is valid or not, along with an * optional message and the decoded payload if valid. * * @param token - The JWT token to verify. It must be in the format: `JWT.{header}.{payload}.{signature}`. * @returns {ValidJWTVerification | InvalidJWTVerification} An object indicating the result * of the verification: * - `valid` (boolean): `true` if the token is valid, `false` otherwise. * - `payload` (optional): The decoded payload if the token is valid. * - `message` (optional): A description of why the token is invalid, if applicable. */ verify(token: string): ValidJWTVerification | InvalidJWTVerification; } export default JWTManager;