UNPKG

uncsrf

Version:

Single API for CSRF functions, working in Node.js, Browsers and other runtimes

25 lines (22 loc) 1.09 kB
import { CipherCCMTypes, CipherOCBTypes, CipherGCMTypes } from 'node:crypto'; type EncryptAlgorithm = CipherCCMTypes | CipherOCBTypes | CipherGCMTypes | string; type EncryptSecret = Buffer; 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 };