Constants§
- BACKUP_
CODE_ COUNT - Number of one-time backup codes generated at enable time.
Functions§
- check_
code - True when
codeis the valid current TOTP for this secret/account. - consume_
backup_ code - If
codematches one of the stored (JSON array) hashes, consume it and return the remaining hashes as JSON. ReturnsNonewhen nothing matched. - generate_
backup_ codes - Generate
BACKUP_CODE_COUNThuman-friendly one-time codes (shown once, in plain text). Format:1234-5678. - generate_
secret - Generate a fresh base32 TOTP secret to persist on the user row.
- hash_
backup_ codes - Hash backup codes for storage. Returns a JSON array of bcrypt hashes.
- provisioning_
url otpauth://URL to encode into the setup QR code.- qr_svg
- Render arbitrary data (an otpauth URL) as an inline SVG QR code. SVG keeps the dependency light — no raster/image encoders.