import { createSignal, onCleanup } from "solid-js"; import { generateTOTP } from "../../crypto/totp"; interface TOTPProps { secret: string; } export function TOTPDisplay(props: TOTPProps) { const [totp, setTotp] = createSignal(generateTOTP(props.secret)); const interval = setInterval(() => { setTotp(generateTOTP(props.secret)); }, 1000); onCleanup(() => clearInterval(interval)); return (
{totp().code.slice(0, 3)} {totp().code.slice(3)}