initial commit

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-03-23 08:46:51 +01:00
commit 4608494a3f
130 changed files with 40361 additions and 0 deletions

20
src/utils/totp.ts Normal file
View File

@@ -0,0 +1,20 @@
import * as OTPAuthLib from 'otpauth';
import { decrypt } from './encryption';
export const OTPAuth = {
verify(encryptedSecret: string, code: string): boolean {
try {
const secret = decrypt(encryptedSecret);
const totp = new OTPAuthLib.TOTP({
secret: OTPAuthLib.Secret.fromBase32(secret),
algorithm: 'SHA1',
digits: 6,
period: 30,
});
const delta = totp.validate({ token: code, window: 1 });
return delta !== null;
} catch {
return false;
}
},
};