import { useState } from 'react' // Renders a freshly generated batch of recovery codes ONCE, with copy + download. // The backend never returns these again, so the copy stresses saving them now. export default function RecoveryCodesDisplay({ codes, onDone }) { const [copied, setCopied] = useState(false) const text = (codes || []).join('\n') async function copy() { try { await navigator.clipboard.writeText(text) setCopied(true) setTimeout(() => setCopied(false), 2000) } catch { /* clipboard blocked — the codes are visible to copy manually */ } } function download() { const blob = new Blob([`${text}\n`], { type: 'text/plain' }) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = 'recovery-codes.txt' a.click() URL.revokeObjectURL(url) } return (

Save these recovery codes somewhere safe. Each can be used once to sign in if you lose your authenticator. They will not be shown again.

{(codes || []).map((c) => (
{c}
))}
{onDone && ( )}
) }