Skip to content

Commit 0fcbae0

Browse files
authored
Fix KitCN Better Auth client types (#293)
1 parent 91bc99a commit 0fcbae0

16 files changed

Lines changed: 550 additions & 128 deletions

File tree

.changeset/quiet-auth-clients.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"kitcn": patch
3+
---
4+
5+
## Patches
6+
7+
- Fix Better Auth client type compatibility for auth providers and organization-heavy auth clients.
8+
- Support Better Auth 1.6.18 across generated auth apps.

bun.lock

Lines changed: 98 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/plans/195-fix-cross-domain-client-types.md

Lines changed: 299 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# kitcn better auth client type pressure
2+
3+
Objective:
4+
Validate and fix KitCN Better Auth client type pressure on the latest supported Better Auth release.
5+
6+
Goal plan:
7+
docs/plans/2026-06-15-kitcn-better-auth-client-type-oom.md
8+
9+
Task source:
10+
- type: user-reported package compatibility investigation
11+
- id / link: Better Auth OOM discussion plus KitCN auth client type failure from chat
12+
- title: KitCN auth client types collapse under Better Auth 1.6.18 organization-heavy clients
13+
- acceptance criteria: patch KitCN if the failure happens in this repo, verify latest Better Auth no longer fails the repo-owned type path, and check the OOM claim with a stress repro.
14+
15+
Completion threshold:
16+
- Latest Better Auth is installed through KitCN-owned pins where generated auth apps use Better Auth.
17+
- KitCN exported auth client/provider types no longer collapse `useSession().data` to `never` for organization-heavy Better Auth clients.
18+
- A freshly packed local KitCN tarball passes a direct Better Auth 1.6.18 repro and a 250-import TypeScript stress run under a 512 MB heap.
19+
- Package build, fixture/scenario gates, `bun check`, changeset, autoreview, commit, push, and PR path are complete or final-response recorded.
20+
21+
Verification surface:
22+
- `bun tooling/dependency-pins.ts sync`
23+
- `bun test packages/kitcn/src/auth-client/convex-auth-provider.types.test.ts`
24+
- `bun test ./packages/kitcn/src/solid/convex-auth-provider.types.vitest.ts`
25+
- `bun --cwd packages/kitcn build`
26+
- `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck`
27+
- `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck:512`
28+
- `bun lint:fix`
29+
- `bun check`
30+
- `.agents/skills/autoreview/scripts/autoreview --mode local`
31+
32+
Constraints:
33+
- Preserve concrete user-created `createAuthClient(...)` inference; only make KitCN's exported catch-all type stop asking Better Auth to infer impossible arbitrary server-plugin endpoints.
34+
- Keep the fix in KitCN because the failing `AuthClient` alias and generated auth app pins are repo-owned.
35+
- Include a patch changeset for the published package type/pin change.
36+
- PR uses the whole current checkout as required by repo policy.
37+
38+
Boundaries:
39+
- Source of truth: KitCN source, generated fixture output, Better Auth 1.6.18 declarations, and tarball repro output.
40+
- Allowed edit scope: `packages/kitcn` auth client/solid type aliases, Better Auth pin owner files, generated auth fixture package manifests, root/example manifests/lockfile, changeset, and plan files already in the checkout.
41+
- Browser surface: N/A, this is compile-time package behavior and CLI scenario verification.
42+
- Tracker sync: N/A, no public KitCN issue was opened for this chat task.
43+
- Non-goals: Do not claim Better Auth's upstream type system cannot OOM in every possible app; do not patch `@convex-dev/better-auth` in this repo.
44+
45+
Output budget strategy:
46+
- Use focused search and capped command output; rely on command summaries for long fixture/scenario output. Large `bun check` output was polled in chunks because it owns the PR gate.
47+
48+
Blocked condition:
49+
- Block only if latest repro stayed failing after KitCN-owned type/pin fixes, package gates failed with a real product regression, or GitHub push/PR permissions failed.
50+
51+
Start Gates:
52+
| Gate | Applies | Evidence |
53+
|------|---------|----------|
54+
| Skill analysis before edits | yes | Used `task`, `autogoal`, `tdd`, `changeset`, and `autoreview` instructions. |
55+
| Active goal checked or created | yes | Active goal created and checked for this plan path. |
56+
| Source of truth read before edits | yes | Inspected KitCN auth type source, Better Auth declarations, dependency pin tooling, and existing solution note. |
57+
| Reproduction verdict before implementation | yes | Local packed KitCN repro failed before final type patch with `AuthClient.useSession().data` as `never`. |
58+
| TDD decision before behavior change | yes | Existing type tests already covered the intended type path; focused tests were run directly after patching. |
59+
| Release artifact decision | yes | Added `.changeset/quiet-auth-clients.md` as a patch changeset. |
60+
| Commit / PR expectation decision | yes | Code-changing package task requires commit, push, and PR. |
61+
62+
Work Checklist:
63+
- [x] Objective, threshold, verification, constraints, boundaries, and blocked condition recorded.
64+
- [x] Task source classified and challenged before implementation.
65+
- [x] Reproduced the repo-owned type failure before the final type-boundary patch.
66+
- [x] Fixed the ownership boundary in KitCN auth client and Solid auth client type aliases.
67+
- [x] Updated Better Auth support pins to 1.6.18 and kept generated auth fixture package manifests in sync.
68+
- [x] Added the required patch changeset.
69+
- [x] Ran focused type tests, package build, dependency pin sync, tarball repro, stress repro, lint, full check, and autoreview.
70+
- [x] Recorded that browser proof is not applicable for this compile-time package issue.
71+
- [x] Commit and PR path handled after final staging; URL is recorded in final response.
72+
73+
Completion Gates:
74+
| Gate | Applies | Required action | Evidence |
75+
|------|---------|-----------------|----------|
76+
| Named verification threshold | yes | Run all named checks | All verification commands listed above passed. |
77+
| Bug reproduced before fix | yes | Capture failing repro | Pre-final tarball repro failed with `TS2322` and `useSession().data` expected as `never`. |
78+
| Targeted behavior verification | yes | Run tarball type repro | `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck` passed after patch: 174427 instantiations, 227531K memory, 0.78s. |
79+
| OOM stress verification | yes | Run 250-import 512 MB heap stress | `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck:512` passed: 174427 instantiations, 247145K memory, 0.66s. |
80+
| TypeScript changed | yes | Run relevant type tests and typecheck | React and Solid auth provider type tests passed; `bun check` package typecheck passed uncached for KitCN. |
81+
| Package exports changed | yes | Run package build | `bun --cwd packages/kitcn build` passed; `bun check` also rebuilt packaged output. |
82+
| Package manifests changed | yes | Run install/pin and repo checks | `bun tooling/dependency-pins.ts sync` and `bun check` passed. |
83+
| Scaffold or fixture output changed | yes | Run fixture sync/check | `bun tooling/dependency-pins.ts sync` ran fixture sync/check; `bun check` reran `fixtures:check`. |
84+
| Package behavior or public API changed | yes | Add changeset | `.changeset/quiet-auth-clients.md` added. |
85+
| Browser surface changed | no | N/A | Compile-time package surface; scenario dev/runtime checks covered generated apps. |
86+
| Autoreview | yes | Run helper | `.agents/skills/autoreview/scripts/autoreview --mode local` exited clean with no accepted/actionable findings. |
87+
| Final lint | yes | Run formatter/lint fix | `bun lint:fix` passed and formatted touched files. |
88+
| PR path | yes | Commit, push, open PR | Final response records branch and PR URL after the GitHub step. |
89+
90+
Phase / pass table:
91+
| Phase | Status | Evidence | Next |
92+
|-------|--------|----------|------|
93+
| Repro | done | Packed local KitCN repro failed before final patch with `AuthClient` `never` session data | implementation |
94+
| Implementation | done | Patched React/Solid type aliases and Better Auth 1.6.18 pins | verification |
95+
| Verification | done | Pin sync, focused tests, package build, tarball repro, stress repro, lint, `bun check` | publish |
96+
| Review | done | Autoreview clean | commit |
97+
| Publish | done | Commit and PR recorded in final response | close |
98+
99+
Verification evidence:
100+
- `bun tooling/dependency-pins.ts sync` passed after aligning Better Auth, Expo auth, example, lockfile, and fixture pins to 1.6.18.
101+
- `bun test packages/kitcn/src/auth-client/convex-auth-provider.types.test.ts` passed.
102+
- `bun test ./packages/kitcn/src/solid/convex-auth-provider.types.vitest.ts` passed.
103+
- `bun --cwd packages/kitcn build` passed.
104+
- Fresh tarball repro in `/tmp/kitcn-ba-oom-C3qmoU` passed `npm run typecheck`.
105+
- Fresh tarball stress in `/tmp/kitcn-ba-oom-C3qmoU` passed `NODE_OPTIONS=--max-old-space-size=512 tsc --noEmit --extendedDiagnostics` with 247145K reported memory.
106+
- `bun lint:fix` passed.
107+
- `bun check` passed, including uncached KitCN typecheck, package tests, fixture checks, and runtime scenarios.
108+
- Autoreview clean: no accepted/actionable findings.
109+
110+
Reboot status:
111+
- Resume from this file if interrupted. Next concrete action after this record is branch/commit/push/PR if not already done.
112+
113+
Open risks:
114+
- Low residual risk: Better Auth can still be type-heavy in other arbitrary plugin compositions. This patch fixes KitCN's exported catch-all type and generated latest pins; it is not a universal Better Auth type-system fix.

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"typecheck:watch": "tsc --noEmit --watch"
3232
},
3333
"dependencies": {
34-
"@better-auth/stripe": "1.6.15",
34+
"@better-auth/stripe": "1.6.18",
3535
"@convex-dev/react-query": "0.1.0",
3636
"@hookform/resolvers": "5.2.2",
3737
"@kitcn/resend": "workspace:*",
@@ -40,7 +40,7 @@
4040
"@react-email/render": "2.0.4",
4141
"@t3-oss/env-nextjs": "0.13.10",
4242
"@tanstack/react-query": "5.95.2",
43-
"better-auth": "1.6.15",
43+
"better-auth": "1.6.18",
4444
"class-variance-authority": "0.7.1",
4545
"clsx": "2.1.1",
4646
"cmdk": "1.1.1",

fixtures/expo-auth/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"dependencies": {
3-
"@better-auth/expo": "1.6.15",
3+
"@better-auth/expo": "1.6.18",
44
"@opentelemetry/api": "1.9.0",
55
"@react-navigation/bottom-tabs": "^7.15.5",
66
"@react-navigation/elements": "^2.9.10",
77
"@react-navigation/native": "^7.1.33",
88
"@tanstack/react-query": "5.95.2",
9-
"better-auth": "1.6.15",
9+
"better-auth": "1.6.18",
1010
"convex": "1.38.0",
1111
"expo": "~55.0.26",
1212
"expo-constants": "~55.0.16",

fixtures/next-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"@base-ui/react": "^1.5.0",
44
"@opentelemetry/api": "1.9.0",
55
"@tanstack/react-query": "5.95.2",
6-
"better-auth": "1.6.15",
6+
"better-auth": "1.6.18",
77
"class-variance-authority": "^0.7.1",
88
"clsx": "^2.1.1",
99
"convex": "1.38.0",

fixtures/start-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@tanstack/react-router-ssr-query": "latest",
1212
"@tanstack/react-start": "latest",
1313
"@tanstack/router-plugin": "latest",
14-
"better-auth": "1.6.15",
14+
"better-auth": "1.6.18",
1515
"class-variance-authority": "^0.7.1",
1616
"clsx": "^2.1.1",
1717
"convex": "1.38.0",

fixtures/vite-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"@opentelemetry/api": "1.9.0",
66
"@tailwindcss/vite": "^4",
77
"@tanstack/react-query": "5.95.2",
8-
"better-auth": "1.6.15",
8+
"better-auth": "1.6.18",
99
"class-variance-authority": "^0.7.1",
1010
"clsx": "^2.1.1",
1111
"convex": "1.38.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"@typescript-eslint/parser": "8.56.1",
9292
"@typescript/native-preview": "^7.0.0-dev.20260225.1",
9393
"@vitest/coverage-v8": "^4.0.18",
94-
"better-auth": "1.6.15",
94+
"better-auth": "1.6.18",
9595
"bun-types": "^1.3.9",
9696
"concurrently": "^9.2.1",
9797
"convex-test": "^0.0.41",

0 commit comments

Comments
 (0)