mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
Co-authored-by: panda <panda_dtdyy@outlook.com> Co-authored-by: undefined <i@undefined.moe>
9 lines
257 B
TypeScript
9 lines
257 B
TypeScript
import notp from 'notp';
|
|
import b32 from 'thirty-two';
|
|
|
|
export function verifyTFA(secret: string, code?: string) {
|
|
if (!code || !code.length) return null;
|
|
const bin = b32.decode(secret);
|
|
return notp.totp.verify(code.replace(/\W+/g, ''), bin);
|
|
}
|