Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Shridhad
left a comment
There was a problem hiding this comment.
🖍️ redline (automated reviewer)
self-review: 0 blockers / 0 should-fixes / 5 questions / 5 nits inline
context (not on a changed line):
packages/auth/src/server/client-factory.test.ts:123—lastCall()readsmock.calls[0], which is the first call. fine today since these tests make one fetch, but a test that also mints a cookie does a second get-session fetch and this helper will silently check the wrong request. name doesn't match behavior.packages/auth/src/server/client-factory.test.ts:170— table covers path, POST and exact body for all five endpoints, and the cookie tests use real Set-Cookie plus get-session so that part is solid. but eachsuffixis copied by hand fromendpoints.ts, so it's circular: a wrong path likephone-number/request-password-resetvs an olderforget-passwordreturns 404 in prod and every case here stays green. nothing compares against the real better-auth 1.7.6 plugin routes.packages/auth/src/server/client-factory.test.ts:176—endsWith(suffix)just echoes theendpoints.tsliteral back, so a wrong path can't fail it. asserting the full/api/auth/phone-number/...pathname, or anchoring to the better-auth route, would actually catch something.packages/auth/src/server/client-factory.test.ts:213— good that the no-Set-Cookie case asserts a single fetch and nosetCookie. but the test never sendsdisableSession, body is just{ phoneNumber, code }. it only hits the genericsetCookieHeaders.length > 0gate atclient-factory.ts:242, shared by every endpoint, so the name overstates what it checks for phone verify.packages/auth/src/server/types.ts:46—NeonAuthServerpicks the client's wholephoneNumbertype, but the proxy returnsundefinedfor any key missing fromAPI_ENDPOINTS.phoneNumber(client-factory.ts:408). doesphoneNumberClient()in 1.7.6 expose any method beyond the four mapped here? if so it type-checks and throwsnot a functionat runtime.
|
Review summary items, addressed in 0da1979:
|
Shridhad
left a comment
There was a problem hiding this comment.
🖍️ redline (automated reviewer)
self-review: 3 questions / 2 nits inline
Adds signIn.phoneNumber and phoneNumber.{sendOtp,verify,requestPasswordReset,resetPassword}
to the server endpoint tree. Paths match better-auth 1.7.6 plugins/phone-number/routes.mjs.
Session cookies already flow through the existing fetchWithAuth minting path.
Co-authored-by: Isaac <no-reply@databricks.com>
- rename lastCall to firstCall and assert a single fetch before inspecting it - compare the exact request pathname instead of endsWith - send disableSession in the verify test and assert it is forwarded Co-authored-by: Isaac <no-reply@databricks.com>
- Pin phone number request bodies to Better Auth's own zod schemas - Add phoneNumber to the mocked session user - Cover signIn.phoneNumber with no session cookie on the two-factor path Co-authored-by: Isaac <no-reply@databricks.com>
0da1979 to
795a4e7
Compare
Shridhad
left a comment
There was a problem hiding this comment.
🖍️ redline (automated reviewer)
self-review: 1 question / 2 nits inline
context (not on a changed line):
- [question]
packages/auth/src/server/client-factory.test.ts:149— doesphoneNumber.resetPasswordset session cookies on success?signIn.phoneNumberhas a test that cookies are forwarded, and this case has none.
Co-authored-by: Isaac <no-reply@databricks.com>
|
Summary question from the last round: |
Shridhad
left a comment
There was a problem hiding this comment.
🖍️ redline (automated reviewer)
self-review: 1 question / 2 nits inline
|
|
||
| // Phone Number | ||
| phoneNumber: { | ||
| sendOtp: { path: 'phone-number/send-otp', method: 'POST' }, |
There was a problem hiding this comment.
🖍️ redline (automated reviewer)
[question]
🤔 fetchWithAuth forwards only Cookie, Origin and the proxy header, no X-Forwarded-For or User-Agent. so every sendOtp from a server action hits neon auth from the app's egress IP. does phone-number/send-otp rate-limit by phone number or by IP? if by IP, all users share one SMS budget and abuse can't be traced to a client, and sms costs money per message.
There was a problem hiding this comment.
Good question. better-auth 1.7.6 rate-limits by client IP plus path (createRateLimitKey(ip, path)), and the phone-number plugin allows 10 requests per 60 seconds on /phone-number/*. Server methods send only Cookie, Origin and the proxy header, so calls from server actions all count against the app's egress IP. This applies to every createNeonAuth() server method (for example signIn.email), not just phone numbers. Fixing it means forwarding the client IP and the Neon Auth server trusting it, which is a separate change. Leaving this open for the maintainer to decide.
Co-authored-by: Isaac <no-reply@databricks.com>
Shridhad
left a comment
There was a problem hiding this comment.
🖍️ redline (automated reviewer)
self-review: nothing blocking — no findings
The phone number plugin already works on the client, but the server auth object had no methods for it. This adds
signIn.phoneNumber()plusphoneNumber.sendOtp(),verify(),requestPasswordReset()andresetPassword(), using the Better Auth 1.7.6 phone-number routes.signIn.phoneNumber()andverify()set the session cookies the same waysignIn.email()does.The project needs the phone number plugin enabled in Neon Auth.
Test plan: one fetchMock test per method checks the path, method and body. Further tests check that
signIn.phoneNumberandverifycreate thesession_datacookie, and thatverifywithdisableSessionsets no cookie. Auth tests (271) pass and typecheck and lint are clean.This pull request and its description were written by Isaac.