workos-auth/docs-tests: Document WorkOS auth and add readUserId tests#53
workos-auth/docs-tests: Document WorkOS auth and add readUserId tests#53x0ba wants to merge 1 commit into
Conversation
Update README and .env.example for WorkOS env vars and API tokens, rename redirect param test wording, and cover cookie vs bearer readUserId resolution.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Greptile SummaryThis PR completes the WorkOS AuthKit migration by updating
Confidence Score: 5/5Safe to merge — changes are documentation updates and additive unit tests with no production code modifications. All three test assertions correctly reflect the actual ??-chain in readUserId, the env var and README updates are accurate, and no existing logic is touched. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant SvelteKit as SvelteKit Hooks
participant Auth as auth.ts
participant WorkOS as WorkOS API
Note over Client,WorkOS: Cookie session (dashboard)
Client->>SvelteKit: Request with session cookie
SvelteKit->>Auth: readUserId(event)
Auth-->>SvelteKit: event.locals.auth.user.id
Note over Client,WorkOS: Bearer token (SDK / API)
Client->>SvelteKit: Request with Authorization: Bearer token
SvelteKit->>Auth: authenticateBearer(event)
Auth->>WorkOS: jwtVerify(token, JWKS)
WorkOS-->>Auth: payload.sub
Auth-->>SvelteKit: event.locals.bearerUserId
SvelteKit->>Auth: readUserId(event)
Auth-->>SvelteKit: bearerUserId (cookie absent → fallback)
Note over Client,WorkOS: Unauthenticated
Client->>SvelteKit: Request (no auth)
SvelteKit->>Auth: readUserId(event)
Auth-->>SvelteKit: undefined
SvelteKit-->>Client: 401 / redirect /sign-in
Reviews (1): Last reviewed commit: "Document WorkOS auth setup and add readU..." | Re-trigger Greptile |

Stack Context
This 3-PR stack migrates FlightLog from Clerk to WorkOS AuthKit while preserving cookie sessions for the dashboard and Bearer tokens for the SDK/API.
Stack:
workos-auth/core(#51) →workos-auth/ui-shell(#52) →workos-auth/docs-testsWhy?
Env var names and API token docs need to match the new WorkOS auth model before merge. Unit tests for
readUserIdlock in cookie-vs-bearer precedence without requiring live JWT verification in CI.What?
.env.exampleand README for WorkOS env vars andWORKOS_ACCESS_TOKENreadUserIdunit tests for session vs bearer precedenceTest plan
bun run checkbun run lint(src/ + README)bunx vitest run src/lib/server/auth.test.ts src/lib/auth-redirect.test.tsbun run db:up)