[HYPER-545] suggest corrections for mistyped email domains - #231
Conversation
🦋 Changeset detectedLatest commit: fe3b15c The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds common email-domain typo detection with accessible correction prompts. Integrates the guard into OAuth and account login pages. Adds unit and end-to-end coverage for accepting, dismissing, and blocking typo corrections before OTP requests. ChangesEmail Typo Guard
Sequence Diagram(s)sequenceDiagram
participant User
participant LoginForm
participant EmailTypoGuard
participant AuthService
participant OTPForm
User->>LoginForm: enter mistyped email
LoginForm->>EmailTypoGuard: submit email
EmailTypoGuard->>LoginForm: show correction and block submission
User->>EmailTypoGuard: accept or dismiss suggestion
EmailTypoGuard->>LoginForm: update or retain email
LoginForm->>AuthService: request OTP
AuthService->>OTPForm: display code form
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🚅 Deployed to the ePDS-pr-231 environment in ePDS
|
Coverage Report for CI Build 30666552997Coverage increased (+0.4%) to 57.672%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
4311a18 to
71c1472
Compare
71c1472 to
4e6f846
Compare
4e6f846 to
d7b593b
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/auth-service/src/lib/email-typo-guard.ts (1)
104-236: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce drift risk between the TS algorithm and its embedded JS duplicate.
suggestEmailAddress(lines 57-74) and the embedded script'seditDistance/suggest(lines 127-177) implement the identical algorithm twice.suggestEmailAddressis unit-tested, but browsers only ever run the string-embedded copy. A future edit to one without the other changes production behavior while the test suite still passes.Consider deriving the embedded script from the tested function, or add a regression test that evaluates the embedded script (for example via Node's
vmmodule) against the same fixtures asemail-typo-guard.test.tsto guarantee parity.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/auth-service/src/lib/email-typo-guard.ts` around lines 104 - 236, Eliminate algorithm drift between the tested suggestEmailAddress implementation and the embedded editDistance/suggest functions in renderEmailTypoGuardScript. Either generate the browser script from the shared tested implementation or add a regression test that evaluates the embedded script and compares it with the existing email-typo fixtures, ensuring both paths remain behaviorally identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/auth-service/src/lib/email-typo-guard.ts`:
- Around line 104-236: Eliminate algorithm drift between the tested
suggestEmailAddress implementation and the embedded editDistance/suggest
functions in renderEmailTypoGuardScript. Either generate the browser script from
the shared tested implementation or add a regression test that evaluates the
embedded script and compares it with the existing email-typo fixtures, ensuring
both paths remain behaviorally identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 07c92fa6-bcb8-4145-aa89-db6fda7ccf61
📒 Files selected for processing (8)
.changeset/suggest-mistyped-email-domains.mde2e/step-definitions/email-typo-guard.steps.tse2e/support/world.tsfeatures/email-typo-guard.featurepackages/auth-service/src/__tests__/email-typo-guard.test.tspackages/auth-service/src/lib/email-typo-guard.tspackages/auth-service/src/routes/account-login.tspackages/auth-service/src/routes/login-page.ts
d7b593b to
2a9a77f
Compare
Without this change, addresses such as gmial.com and hotmal.com proceed directly to code delivery and leave users unable to receive their sign-in code. Add a conservative one-edit domain check for common providers. Both email entry points now pause before sending, offer the corrected address, and still allow the original address explicitly. Behavioral tests cover corrected and original sends. Refs HYPER-545. Co-authored-by: OpenAI Codex <noreply@openai.com>
2a9a77f to
fe3b15c
Compare
|



Summary
Prevent obvious email-domain typos from silently sending sign-in codes to unreachable addresses. Before either the OAuth login form or account-settings login sends a code, ePDS now offers a conservative, non-blocking correction for near-misses of Gmail, Hotmail, Outlook, Yahoo, and iCloud.
Changes
gmial.com--email-typo-*CSS variablesTesting
pnpm format:checkpnpm lintpnpm typecheckpnpm buildpnpm test— 1,084 tests passpnpm test:coverage— thresholds pass; the new helper has 100% statement/branch/function/line coveragefe3b15cin run 30666552929Before and after
The screenshots are embedded in this PR description only; no screenshot binaries are committed to the repository.
Before
Submitting the plain email form immediately attempted to send a code, even for an obvious provider-domain typo.
After
The prompt appears immediately when the typed domain matches, shows only the corrected address, offers one compact Yes, fix it mini button, and provides a subtle × to dismiss it and keep the original input. Either action hides the prompt and re-enables Continue without submitting.
Notes
Summary by CodeRabbit
New Features
Bug Fixes