Skip to content

Commit e7936c4

Browse files
committed
Fix schema parsing error
1 parent d1f8780 commit e7936c4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cli/src/utils/auth.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ const userSchema = z.object({
2525
export 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

3537
const 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
4345
export 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

Comments
 (0)