improvement(auth): make Microsoft emailVerified derivation total#5157
Conversation
deriveMicrosoftEmailVerified cast the verified-email claims to string[] and called .includes through optional chaining, which only guards null/undefined. A claim arriving as a non-array, non-string value (e.g. a number) would throw inside getUserInfo and fail the OAuth flow. Array-check the claims with a proper type guard so any claim shape resolves to unverified instead of throwing.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Verified-email claims are no longer cast to Tests in Reviewed by Cursor Bugbot for commit 035b81f. Configure here. |
Greptile SummaryThis PR hardens the
Confidence Score: 5/5Safe to merge — the change is purely defensive and cannot weaken email verification for any well-formed Microsoft token. The only logic that changes is the handling of malformed claim shapes, which previously could throw and now consistently return false. Real Microsoft tokens with proper string[] claims are unaffected. The new tests lock in both the defensive behavior and the important boundary where a plain-string claim equal to the email must not be treated as verified. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "test(auth): lock in unverified for a str..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
Add a boundary case asserting a string verified_primary_email/ verified_secondary_email equal to the email resolves to unverified — the old string[] cast would have returned true via String.includes.
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 035b81f. Configure here.
Summary
deriveMicrosoftEmailVerifiedcast the verified-email claims tostring[]and called.includesvia optional chaining, which only guardsnull/undefined. If a claim ever arrived as a non-array, non-string value (e.g. a number or object),.includeswould throw and fail the OAuthgetUserInfoflow.as string[]cast with properArray.isArrayguards, so any claim shape resolves to unverified instead of throwing. No behavior change for real Microsoft tokens — purely defensive robustness on a security-relevant helper.Type of Change
Testing
microsoft.test.tswith non-array claim shapes (string, number, object, null) asserting no throw + unverified.bunx vitest run lib/oauth/microsoft.test.ts— 11 passing.bunx tsc --noEmit— 0 errors.bun run lint— clean.Checklist