* Use full keyspace for email verification codes
Email verification codes were generated with randomInt(100000, 1000000),
which can never produce a value below 100000. That excluded every code
with a leading zero — shrinking the keyspace from 1,000,000 to 900,000
and letting an attacker assume the first digit is never zero. It also
made the existing padStart(6, "0") dead code.
Draw uniformly from the full 0–999999 range and rely on padStart to
render leading zeros, restoring the full six-digit keyspace. Add tests
covering the six-digit invariant across many samples and the presence of
leading-zero codes.
* Simplify verification code jsdoc and drop leading-zero test
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EWfLg5uQdYFuzj1UBEo1og
---------
Co-authored-by: Claude <noreply@anthropic.com>
* fix: Ensure OTP is bound to teamId
* fix: Address review feedback on OTP tenant scoping
- Trim whitespace in VerificationCode Redis keys to match DB lookup
normalization.
- Redirect with invalid-code (rather than leaking a backend error)
when no user exists for the email in the resolved team.
- Correct retrieve() JSDoc to state undefined instead of null.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>