-
Notifications
You must be signed in to change notification settings - Fork 1
fix username/password auth #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e5e8d9c to
51287c9
Compare
@proofkit/better-auth
@proofkit/cli
create-proofkit
@proofkit/fmdapi
@proofkit/fmodata
@proofkit/typegen
@proofkit/webviewer
commit: |
| "username" in envNames.auth | ||
| ) { | ||
| addTypeGuardStatements(sourceFile, { | ||
| envVarName: envNames.auth?.username ?? defaultEnvNames.username, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Generated code requires all auth env vars unnecessarily
The type guard generation now adds throw statements for apiKey, username, AND password environment variables whenever envNames.auth is an object. Previously, it only added guards for the specific auth method being used. Now, if a user configures only API key authentication, the generated client will throw errors for missing FM_USERNAME and FM_PASSWORD env vars that aren't actually needed, making the generated code unusable.
9045be0 to
7d472d4
Compare
|
Cursor Agent can help with this pull request. Just |
d180094 to
6f5e5f6
Compare
6f5e5f6 to
a5a36be
Compare
| envVarName: envNames.server ?? defaultEnvNames.server, | ||
| }); | ||
| if (typeof envNames.auth === "object" && "apiKey" in envNames.auth) { | ||
| if (typeof envNames.auth === "object") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong adapter selected due to property existence check
The condition "apiKey" in envNames.auth checks for property existence, not truthiness. With the changes in typegen.ts, the envNames.auth object now always includes apiKey as a property (even when set to undefined for username/password auth). Since "apiKey" in { apiKey: undefined, username: "X" } returns true, the OttoAdapter branch is incorrectly selected for username/password authentication. The generated code would reference process.env.undefined, completely breaking username/password auth. The check needs to verify the value is truthy (e.g., envNames.auth.apiKey) rather than just checking property existence.
Note
server,db, and bothauthmethods (apiKey, username/password) acrossgetEnvValues,createDataApiClient, and client generation; updates type guards and schema building to always check relevant vars.buildLayoutClientnow adds guards forauth.apiKey,auth.username, andauth.passwordas applicable; adapter selection simplified (Otto for apiKey, Fetch for username/password).envNames.authschema unified to include optionalapiKey,username,passwordsimultaneously; sample config updated.zfromzod.MetadataFieldsDialogandMetadataTablesEditor(sticky headers, scroll areas, bulk include/exclude); minor copy tweak inConnectionWarning; newdata-grid/sticky-header.tsxdemo.Written by Cursor Bugbot for commit a5a36be. This will update automatically on new commits. Configure here.