2fa-hotp-totp
Version:
Zero dependency HOTP/TOTP 2FA
17 lines (16 loc) • 893 B
TypeScript
/**
* @param key unique secret key for user
* @param algorithm custom algorithm for crypto.createHmac. Default: sha1
* @param time time-step in seconds (default recomended). Default: 30
* @return 6 digit code as a string
*/
export declare const generate:({key,time}:{key:string;algorithm?:string;time?:number;})=>string;
/**
* @param token code, provided by user
* @param key unique secret key for user
* @param algorithm custom algorithm for crypto.createHmac. Default: sha1
* @param window counter values window. Default: 1
* @param time time-step in seconds (default is recomended). Default: 30
* @return null if nothing found or number between -window to +window if same code in steps found
*/
export declare const validate:({token,key,algorithm,window,time,}:{token:string;key:string;algorithm?:string;window?:number;time?:number;})=>number|null;