Interface IServerSideOtpStore
B3: server-side OTP store — issues and consumes SMS/Email one-time codes so that the
plaintext OTP lives only in transient memory (generator → delivery channel) and never
appears in the encrypted mfa_state blob, URL query strings, access logs, or
Referer headers.
The resulting model is classic OTP-issuance: each challenge writes a single row
containing the hash of the code, an absolute MaxAge TTL, and a
single-use flag. Verify loads the row under LockForUpdate, checks the hash in
constant time, flips the flag, commits — so a second verify with the same code hits a
already-consumed row and fails regardless of correctness.
public interface IServerSideOtpStore
Methods
IssueAsync(long, string, string, TimeSpan, CancellationToken)
Issues a new OTP. Generates a CSPRNG 6-digit code, persists its SHA-256 hash, and
Task<OtpIssueResult> IssueAsync(long userId, string method, string destinationMasked, TimeSpan ttl, CancellationToken ct = default)
VerifyAndConsumeAsync(Guid, long, string, CancellationToken)
Verifies and atomically consumes an OTP keyed by jti. On success
Task<OtpVerifyResult> VerifyAndConsumeAsync(Guid jti, long userId, string code, CancellationToken ct = default)