# totp

A code from an authenticator app (RFC 6238) as a second factor, with
recovery codes, and a QR code writer. The whole of it is
[docs/second-factor.md](../../docs/second-factor.md).

```text
use "pkg:totp/totp.mote"
```

Settings: `TOTP_KEY` (a secret: the apps' secrets are sealed with it),
`TOTP_ISSUER` (optional).

| File | |
|---|---|
| `totp.mote` | `TotpSecret`, `TotpRecovery`; `totpBegin`, `totpConfirm`, `totpCheck`, `totpNewRecovery`, `totpOff`, `totpState`; `totpHotp`, `totpAt`. |
| `qr.mote` | `qrGrid`, `qrSvg`, `qrUrl`, `TotpQr`: QR codes of versions 1 to 10, level M. |
| `tests.mote` | Its tests (RFC 4226 and RFC 6238's examples among them). |

Left out: codes by text message (see [twilio](../twilio/README.md)'s
Verify), HOTP counters on a device, codes of eight digits or 60 seconds
(the `totpHotp` and `totpAt` fns take any). Tested with `tests/all.sh
real_totp`; the QR codes were read back in Chrome, not by a phone.
