chore: JWT unification (jose everywhere) + logout cache clear - #20
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Two tech-debt items deferred from Week 3 AC 2 review. Unifies JWT signing and verification under a single library (
jose), removesjsonwebtoken, and clears TanStack cache on logout to prevent stale data flash when switching accounts.Changes
Code
dashboard/server/auth.ts—issueJWTported tonew SignJWT(...).sign()fromjosedashboard/server/jwt.ts—requireUsermade async, now delegates to existingverifyJwt(jose); removedjsonwebtokenimportdashboard/app/api/v1/**(10 route handlers) — addedawaitbeforerequireUser(req)callsdashboard/app/dashboard/logout-button.tsx— addedqueryClient.clear()beforerouter.replace("/login")Tooling / config
dashboard/package.json— removedjsonwebtokenand@types/jsonwebtoken(10 packages, 91 lines from lock file)Docs / plan
plans/week4/jwt-unification-and-logout-cache.md— moved from backlog, decomposed into commitsplans/backlog/email-password-auth.md— deleted, out of scope for Week 4Design decisions
joseonly, no dual-library —jsonwebtokenhad two call sites (issueJWT+requireUser); now everything goes throughverifyJwt/SignJWTfromjose. Single place to update if algorithm or rotation logic changesJWT_SECRETis base64 (ASCII only), soTextEncoder().encode()produces identical bytes. Existing tokens in extension remain validrequireUserasync — breaking change within the codebase only; all callers were alreadyasync, only neededawaitaddedqueryClient.clear()before redirect — ensures zero stale cache before the new user's data arrives; one line, zero riskVerification
npx tsc --noEmit(dashboard) — cleannpm run lint(dashboard) — cleanPOST /api/v1/eventswith extension JWT →201✓/dashboardloads with data →200on all API calls ✓Out of scope (future PRs)
josefor middleware (already usedjosethere before this PR — no change needed)Closes
plans/week4/jwt-unification-and-logout-cache.md)