Summary
The auth plugin (src/plugins/auth.ts) trusts Clerk's API response without runtime validation. Fields are extracted via TypeScript as casts, which provide no runtime safety.
If Clerk changes their API shape, we get silent undefined propagation instead of a clear error.
Proposed changes
- Define a Zod schema for the Clerk user fields we use (emailAddresses, externalAccounts, publicMetadata, etc.)
- Parse the
clerkClient.users.getUser() response through it
- Remove unsafe
as unknown as Record<string, unknown> casts
- Applies to both
apps/registry/src/plugins/auth.ts and apps/registryDemo/src/plugins/auth.ts
Rationale
Best practice: validate at system boundaries. Clerk is an external service — its responses are untrusted input.
🤖 Generated with Claude Code