/** * InvalidHmacError is thrown when HMACs don't match * @source https://rclayton.silvrback.com/custom-errors-in-node-js */ export declare class InvalidHmacError extends Error { constructor(message?: any); } /** * Generate a new TWT from a payload and signature * @param payload - Payload * @param secret - Secret * @example * // returns "hello5112055c05f944f85755efc5cd8970e194e9f45b" * sign("hello", "secret"); */ export declare const sign: (payload: string, secret: string, length?: number, algorithm?: string) => string; /** * Verify a TWT using its secret * @param twt - TWT * @param secret - Secret * @example * // returns "hello" * verify("hello5112055c05f944f85755efc5cd8970e194e9f45b", "secret"); * @example * // Throws an InvalidHmacError * verify("hello-this-is-not-the-correct-hmac", "secret"); * @example * // Throws an InvalidHmacError * verify("hello5112055c05f944f85755efc5cd8970e194e9f45b", "incorrect-secret"); */ export declare const verify: (twt: string, secret: string, length?: number, algorithm?: string) => string; /** * Decode a TWT **without** verifying it (not recommended) * @param twt - TWT * @example * // returns "hello" * decode("hello5112055c05f944f85755efc5cd8970e194e9f45b"); * @example * // returns "hello" * decode("hellothis-is-not-the-correct-hmac"); */ export declare const decode: (twt: string, length?: number) => string; /** * Validate a TWT **without** verifying it * @param twt - TWT * @example * // returns true * decode("hello5112055c05f944f85755efc5cd8970e194e9f45b"); * @example * // returns false * decode("hellothis-is-not-32-characters"); * // returns true * decode("hellothis-is-32-characters-abcdefghijklmnopqr"); */ export declare const validate: (twt: string, length?: number) => boolean;