Show OTP code validity in every frontend #63

Closed
opened 2026-08-10 11:28:45 +00:00 by hugo · 1 comment
Owner

Problem

OTP code presentation must tell the user how many seconds the current code remains valid. The CLI currently presents the code without its remaining validity. The TUI has storage-provided validity countdown and automatic boundary refresh from issue #27; that behavior must remain covered and must not regress. Future frontends need the same storage-owned presentation contract.

Required behavior

  • Storage remains the source of the TOTP validity boundary and remaining duration; frontends must not duplicate OTP timing or calculation.
  • CLI OTP code presentation includes a clear remaining-validity value without leaking the underlying URI or secret. Clipboard-only output must retain its secret-safe channel behavior while giving non-secret timeout feedback separately.
  • TUI shows the remaining seconds beside the focused code, repaints without counting as user activity, and automatically replaces the code at the validity boundary.
  • HOTP is identified as counter-based rather than claiming a time validity.
  • Document the reusable frontend presentation contract for later desktop and Apple implementations.

Acceptance criteria

  • Deterministic tests cover CLI terminal and clipboard presentation, TUI countdown and boundary refresh, and HOTP output.
  • No frontend calculates OTP codes, periods, or validity boundaries.
  • Formatting, warnings-as-errors check, Clippy, and workspace tests pass.
## Problem OTP code presentation must tell the user how many seconds the current code remains valid. The CLI currently presents the code without its remaining validity. The TUI has storage-provided validity countdown and automatic boundary refresh from issue #27; that behavior must remain covered and must not regress. Future frontends need the same storage-owned presentation contract. ## Required behavior - Storage remains the source of the TOTP validity boundary and remaining duration; frontends must not duplicate OTP timing or calculation. - CLI OTP code presentation includes a clear remaining-validity value without leaking the underlying URI or secret. Clipboard-only output must retain its secret-safe channel behavior while giving non-secret timeout feedback separately. - TUI shows the remaining seconds beside the focused code, repaints without counting as user activity, and automatically replaces the code at the validity boundary. - HOTP is identified as counter-based rather than claiming a time validity. - Document the reusable frontend presentation contract for later desktop and Apple implementations. ## Acceptance criteria - Deterministic tests cover CLI terminal and clipboard presentation, TUI countdown and boundary refresh, and HOTP output. - No frontend calculates OTP codes, periods, or validity boundaries. - Formatting, warnings-as-errors check, Clippy, and workspace tests pass.
hugo added this to the 02 - Mutt-style terminal UI milestone 2026-08-10 11:28:45 +00:00
hugo added the bug label 2026-08-10 11:28:45 +00:00
Author
Owner

Implemented and pushed in commit d3427f3.

Implementation:

  • Added storage-owned OtpCodeValidity with explicit Timed and CounterBased variants.
  • Kept TOTP boundary and remaining-time arithmetic in crates/storage through remaining_at.
  • CLI terminal and clipboard paths report the current validity on stderr without leaking the code or changing pass-compatible code-only stdout.
  • HOTP output explicitly reports the committed counter as counter-based with no time expiry.
  • TUI repainting now observes the real system time and asks the storage validity object for remaining seconds instead of decrementing an assumed four-ticks-per-second counter.
  • Boundary expiry schedules an asynchronous replacement without being treated as user activity or extending the authentication lease.
  • Added a deterministic TUI test that reaches zero and replaces the old code with the next code and reset duration.
  • Documented the reusable contract for desktop and Apple-family frontends in docs/otp.md.

Review confirmed that no frontend derives an OTP period, code, or validity boundary. Code-only stdout compatibility and clipboard secret isolation are preserved.

Required gates passed:

  • cargo fmt --all -- --check
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Focused storage OTP, CLI terminal/clipboard/HOTP, and TUI boundary tests also pass.

Implemented and pushed in commit d3427f3. Implementation: - Added storage-owned OtpCodeValidity with explicit Timed and CounterBased variants. - Kept TOTP boundary and remaining-time arithmetic in crates/storage through remaining_at. - CLI terminal and clipboard paths report the current validity on stderr without leaking the code or changing pass-compatible code-only stdout. - HOTP output explicitly reports the committed counter as counter-based with no time expiry. - TUI repainting now observes the real system time and asks the storage validity object for remaining seconds instead of decrementing an assumed four-ticks-per-second counter. - Boundary expiry schedules an asynchronous replacement without being treated as user activity or extending the authentication lease. - Added a deterministic TUI test that reaches zero and replaces the old code with the next code and reset duration. - Documented the reusable contract for desktop and Apple-family frontends in docs/otp.md. Review confirmed that no frontend derives an OTP period, code, or validity boundary. Code-only stdout compatibility and clipboard secret isolation are preserved. Required gates passed: - cargo fmt --all -- --check - RUSTFLAGS="-D warnings" cargo check --workspace --all-targets - cargo clippy --workspace --all-targets -- -D warnings - cargo test --workspace Focused storage OTP, CLI terminal/clipboard/HOTP, and TUI boundary tests also pass.
hugo closed this issue 2026-08-10 11:59:54 +00:00
Sign in to join this conversation.