UNPKG

malibu

Version:

Framework-agnostic CSRF middleware

30 lines (29 loc) 1.08 kB
/** * Generate a secure type safe UID with specified length. * Rewrite of https://github.com/crypto-utils/uid-safe * @param {Number} length UID length * @returns {String} Type safe UID */ export declare function typeSafeUID(length: number): string; /** * Generate a (not secure) quick salt with specified length. * Rewrite of https://github.com/crypto-utils/rndm * @param {Number} length Salt length * @returns {String} Salt */ export declare function randomBase62(length: number): string; /** * Create a SHA1 hash from specified string * Rewrite of a function from https://github.com/pillarjs/csrf * @param {String} str Dirty string * @returns {String} Hashed string */ export declare function hash(str: string): string; /** * Compare two keys, to check if they have the same creation duration. * Rewrite of https://github.com/suryagh/tsscmp * @param {String} a Key #1 * @param {String} b Key #2 * @returns {Boolean} Whether both keys matches or not */ export declare function timeSafeCompare(a: string, b: string): boolean;