uncsrf
Version:
Single API for CSRF functions, working in Node.js, Browsers and other runtimes
23 lines (21 loc) • 962 B
TypeScript
type EncryptAlgorithm = "AES-CBC";
type EncryptSecret = CryptoKey;
declare const defaultEncryptAlgorithm: EncryptAlgorithm;
declare const importEncryptSecret: (secret?: string, encryptAlgorithm?: EncryptAlgorithm | "") => Promise<EncryptSecret>;
/**
* Create a new CSRF token
*/
declare const create: (secret: string, encryptSecret: EncryptSecret, encryptAlgorithm?: EncryptAlgorithm | "") => Promise<string>;
/**
* Check csrf token
*/
declare const verify: (secret: string, token: string, encryptSecret: EncryptSecret, encryptAlgorithm?: EncryptAlgorithm | "") => Promise<boolean>;
/**
* Create cryptographic random value
*/
declare const randomSecret: () => `${string}-${string}-${string}-${string}-${string}`;
/**
* Create a random encrypt secret
*/
declare const randomEncryptSecret: () => string;
export { type EncryptAlgorithm, type EncryptSecret, create, defaultEncryptAlgorithm, importEncryptSecret, randomEncryptSecret, randomSecret, verify };