import * as OTPAuth from 'otpauth'; /** * Generate a TOTP code from a secret * @param secret - The base32 encoded secret * @returns The 6-digit OTP code */ export function generateOTP(secret: string): string { const totp = new OTPAuth.TOTP({ issuer: 'Truck Wash', label: 'User', algorithm: 'SHA1', digits: 6, period: 30, secret: secret, }); return totp.generate(); }