feat(auth): Clerk strategy in the shared auth files (from ShipKit) - #107
Merged
Merged
Conversation
Byte-for-byte copies of ShipKit's src/lib/auth/auth-strategy.ts,
session-mapping.ts, use-session.ts and src/server/auth.ts, which now
dispatch to a Clerk facade when AUTH_STRATEGY=clerk, plus:
- src/env.ts: "clerk" joins the AUTH_STRATEGY / NEXT_PUBLIC_AUTH_STRATEGY
enum. Clerk is never picked automatically; Better Auth stays the default.
- src/server/clerk/facade.ts and src/lib/auth/clerk-client.ts: stubs with the
exports the shared files import, no @clerk/nextjs dependency. The clerk
registry item (lacymorrow/shipkit, lac/clerk-item) overwrites both with the
real implementation and adds the provider, proxy and components.
- tests/unit/lib/auth: the strategy and session-mapping unit tests from
ShipKit (both dependency-free).
Verified: pnpm typecheck clean, pnpm test 64 passed, prettier clean on the
changed files. pnpm lint:eslint fails on main already ("next lint" is gone
in Next 16).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
* origin/main: chore(tsconfig): typecheck ui and blocks like ShipKit does fix(seams): @/.source path, static asset types, lucide-react aligned with ShipKit feat(doctor): feature table and doctor report from ShipKit
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Bones' half of the Clerk registry item (ShipKit PR lacymorrow/shipkit#377). The four shared auth files are copied from ShipKit byte for byte so
npx shadcn add @shipkit/clerkskips them silently, and the two modules they now import exist here as stubs.src/lib/auth/auth-strategy.ts:AUTH_STRATEGY=clerkwith both Clerk keys returns"clerk". Unset never picks Clerk (paid, hosted); Better Auth stays the default. Selected but unconfigured falls through to Auth.js or guest, likebetter-authwithout a database.src/lib/auth/session-mapping.ts:mapClerkSession()next tomapBetterAuthSession(), structural so the serverUserand clientUserResourceboth fit, no Clerk import.src/lib/auth/use-session.tsandsrc/server/auth.ts: dispatch to@/lib/auth/clerk-clientand@/server/clerk/facadewhen Clerk is active.src/env.tsand.env.example:"clerk"in theAUTH_STRATEGYenum.src/server/clerk/facade.ts,src/lib/auth/clerk-client.ts: stubs (signed out, redirect to/sign-in). Theclerkitem overwrites them; this is the stub pattern fromdocs/plans/agent-first-install.mdin ShipKit.tests/unit/lib/auth/: strategy and mapping tests from ShipKit.Proof of work
pnpm typecheckpnpm testprettier --checkon changed filespnpm lint:biomepnpm lint:eslintmainalready:next lintwas removed in Next 16 ("Invalid project directory provided, no such directory: .../lint")scripts/registry-smoke.sh clerkagainst a fresh clone of this repo'smainshadcn add @shipkit/clerk,pnpm typecheck)Without this PR the item still typechecks into Bones (the smoke proves it) but
AUTH_STRATEGY=clerkfails env validation at boot, so this needs to land for the item to switch on.