Skip to content

feat(auth): infer AuthUser and AuthSession from auth.ts - #622

Open
0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:cursor/infer-auth-user-session-types-ed4f
Open

0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:cursor/infer-auth-user-session-types-ed4f

Conversation

@0froq

@0froq 0froq commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #567

Summary

AuthUser and AuthSession were always Better Auth's base shapes. Fields from plugins and user.additionalFields exist at runtime but were missing from c.get('user'), getUser(), requireAuth(), and the session helpers.

Changes

  • Make AuthUser and AuthSession mergeable interfaces
  • Generate .void/auth.d.ts from the app auth.ts (same pattern as .void/env.d.ts)
  • Wire generation into prepare and the routing plugin; remove the file when auth is off
  • List auth.d.ts in .void/tsconfig.json only after the file exists
  • Note inferred fields in the auth API docs

Testing

  • Unit tests for codegen and for when auth.d.ts is listed in tsconfig
  • prepareProject write/delete lifecycle test
  • Integration tsc with admin() and additionalFields on c.get, getUser, getSession, and requireAuth

🐸

Fixes voidzero-dev#567

## Summary

`AuthUser` and `AuthSession` were always Better Auth's base shapes. Fields from plugins and `user.additionalFields` exist at runtime but were missing from `c.get('user')`, `getUser()`, `requireAuth()`, and the session helpers.

## Changes

- Make `AuthUser` and `AuthSession` mergeable interfaces
- Generate `.void/auth.d.ts` from the app `auth.ts` (same pattern as `.void/env.d.ts`)
- Wire generation into prepare and the routing plugin; remove the file when auth is off
- List `auth.d.ts` in `.void/tsconfig.json` only after the file exists
- Note inferred fields in the auth API docs

## Testing

- Unit tests for codegen and for when `auth.d.ts` is listed in tsconfig
- `prepareProject` write/delete lifecycle test
- Integration `tsc` with `admin()` and `additionalFields` on `c.get`, `getUser`, `getSession`, and `requireAuth`
@cpojer
cpojer requested a review from Brooooooklyn October 27, 2026 15:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infer AuthUser / AuthSession from auth.ts: plugin and additionalFields columns are missing from c.get('user'), getUser() and requireAuth()

1 participant