Skip to content

Conversation

@ian
Copy link
Owner

@ian ian commented Oct 12, 2025

Summary by cubic

Replaced WorkOS and iron-session with Better Auth to provide a simpler, flexible auth system with email OTP and Google OAuth. This fulfills Startup-90 by removing WorkOS and consolidating server/client APIs around better-auth.

  • New Features

    • createAuth server factory using better-auth + Prisma, email OTP, and Google OAuth
    • createBetterAuthClient, AuthProvider, and useAuth for React apps
    • createServerUtils for SSR access and Next.js route handler
    • New top-level exports via src/index and comprehensive README
  • Migration

    • Removed WorkOS, iron-session, and legacy /api/auth routes
    • Auth base path is now /auth via better-auth Next.js handler
    • Package exports now point to index; routes/config exports removed
    • Dependencies: add better-auth; peer deps bumped to react/react-dom 19
    • Templates updated to use @startupkit/auth provider and client
    • Env vars required: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
    • Breaking: wrap app with AuthProvider and expose GET/POST from toNextJsHandler(auth.handler) in /app/auth/[...all]/route.ts

@linear
Copy link

linear bot commented Oct 12, 2025

@socket-security
Copy link

socket-security bot commented Oct 12, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​radix-ui/​react-toggle@​1.1.9 ⏵ 1.1.10991006794 -1100
Updated@​radix-ui/​react-toggle-group@​1.1.10 ⏵ 1.1.11991007094 -1100
Updated@​radix-ui/​react-checkbox@​1.3.2 ⏵ 1.3.3991007194 -1100
Updated@​radix-ui/​react-scroll-area@​1.2.9 ⏵ 1.2.10991007394 -1100
Updatedbetter-auth@​1.2.5 ⏵ 1.3.2799100 +7587 +196100

View full report

@socket-security
Copy link

socket-security bot commented Oct 12, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 28 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="packages/auth/package.json">

<violation number="1" location="packages/auth/package.json:41">
The migration from WorkOS is incomplete. The `templates/repo/packages/utils` package still includes dependencies on `@workos-inc` packages, contradicting the goal of this PR and leaving legacy dependencies in the codebase. This creates architectural inconsistency.</violation>
</file>

<file name="packages/auth/src/lib/auth.ts">

<violation number="1" location="packages/auth/src/lib/auth.ts:30">
Logging the OTP to console exposes sensitive authentication secrets and lets anyone with log access steal the code; remove the log and require a secure delivery path instead.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

ian and others added 25 commits October 12, 2025 11:49
The inferAdditionalFields function is a type utility, not a runtime client plugin.
Using it in the plugins array was causing TypeScript type errors in the template builds.

This fix removes inferAdditionalFields from:
- templates/repo/packages/auth/src/index.ts
- packages/auth/README.md examples

The auth client now only includes the actual runtime plugins (adminClient, emailOTPClient).
- Remove unused 'import type { auth }' from templates/repo/packages/auth/src/index.ts
- Fix biome formatting to put imports and plugins on single lines
- Change better-auth version from exact '1.2.5' to '^1.2.5' to match packages

These changes fix:
- build-repo-template: lint error (unused import)
- build-next-template: type mismatch (version incompatibility between 1.2.5 and 1.3.27)
- Regenerate templates/repo/pnpm-lock.yaml to align with updated better-auth version range
- This fixes the frozen-lockfile error in CI where package.json specified '^1.2.5' but lockfile had '1.2.5'
- Resolves type incompatibilities between better-auth versions 1.2.5 and 1.3.27

Fixes build-repo-template and build-next-template CI failures
Move better-auth from dependencies to peerDependencies with exact version 1.3.27 in both packages/auth and templates/repo/packages/auth. This ensures version consistency across the workspace and prevents type incompatibilities.

Also add better-auth to devDependencies for development purposes.
Update sendVerificationOtp type parameter from loose 'string' to strict literal union type 'sign-in' | 'forget-password' | 'email-verification' to match better-auth 1.3.27's actual type definitions. This fixes the type compatibility error in CI.
…sponses

Change all method return types from Promise<void> to Promise<any> to accommodate better-auth 1.3.27's actual return types (Promise<Data<...> | Error<...>>). Also add index signature to emailOtp to allow extra properties like checkVerificationOtp that exist in the actual client.
…-auth 1.3.27

Add 'as any' type assertion to adminClient() call to bypass TypeScript type incompatibility where better-auth 1.3.27's adminClient has email as optional in one type but required in another. This is a workaround for a library type bug while maintaining version 1.3.27 everywhere as required.
@ian ian merged commit 4694546 into main Oct 14, 2025
13 checks passed
@ian ian deleted the startup-90-remove-workos-switch-to-better-auth branch October 14, 2025 09:42
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.

2 participants