@@ -25,19 +25,21 @@ const userSchema = z.object({
2525export type User = z . infer < typeof userSchema >
2626
2727// Claude OAuth credentials schema (for passthrough, not strict validation here)
28- const claudeOAuthSchema = z . object ( {
29- accessToken : z . string ( ) ,
30- refreshToken : z . string ( ) ,
31- expiresAt : z . number ( ) ,
32- connectedAt : z . number ( ) ,
33- } ) . optional ( )
28+ const claudeOAuthSchema = z
29+ . object ( {
30+ accessToken : z . string ( ) ,
31+ refreshToken : z . string ( ) ,
32+ expiresAt : z . number ( ) ,
33+ connectedAt : z . number ( ) ,
34+ } )
35+ . optional ( )
3436
3537const credentialsSchema = z
3638 . object ( {
3739 default : userSchema ,
3840 claudeOAuth : claudeOAuthSchema ,
3941 } )
40- . catchall ( userSchema )
42+ . catchall ( z . unknown ( ) )
4143
4244// Get the config directory path
4345export const getConfigDir = ( ) : string => {
@@ -67,7 +69,9 @@ const userFromJson = (
6769 try {
6870 const allCredentials = credentialsSchema . parse ( JSON . parse ( json ) )
6971 const profile = allCredentials [ profileName ]
70- return profile
72+ // Validate that the profile matches the user schema
73+ const parsed = userSchema . safeParse ( profile )
74+ return parsed . success ? parsed . data : undefined
7175 } catch ( error ) {
7276 logger . error (
7377 {
0 commit comments