Skip to content
rw3iss Auth

TwoFactorEnrollment

form @rw3iss/auth-client/preact/forms/TwoFactorEnrollment framework-adapters/preact/components/forms/TwoFactorEnrollment.tsx ↗

TOTP enrollment wizard. Two visual steps:

  1. Enroll — calls setupTwoFactor, shows the provisioning URI (rendered as a QR code via a quick external charts service) and the base32 secret as a fallback for users without a QR scanner.

  2. Confirm — collects the first 6-digit code from the authenticator app and calls enableTwoFactor. The server stamps two_factor_confirmed_at only after a valid code, so this step is required (skipping it = “setup but not enforced” state, harmless but useless).

The QR code is generated by Google Chart API as a tiny static URL — no client-side QR library dependency. Swap by passing renderQr.

Usage

import { TwoFactorEnrollment } from '@rw3iss/auth-client/preact/forms';
<TwoFactorEnrollment
onComplete={() => navigate("/login")}
/>

Props

NameTypeDescription
clientAuthClient
renderQr(uri: string) => ComponentChildrenCustom QR renderer; receives the otpauth:// URI.
onComplete() => void
classNamestring