MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / userFromJson

Function userFromJson

cli/src/utils/auth.ts:55–76  ·  view source on GitHub ↗
(
  json: string,
  profileName: string = 'default',
)

Source from the content-addressed store, hash-verified

53 * Parse user from JSON string
54 */
55const userFromJson = (
56 json: string,
57 profileName: string = 'default',
58): User | undefined => {
59 try {
60 const allCredentials = credentialsSchema.parse(JSON.parse(json))
61 const profile = allCredentials[profileName]
62 // Validate that the profile matches the user schema
63 const parsed = userSchema.safeParse(profile)
64 return parsed.success ? parsed.data : undefined
65 } catch (error) {
66 logger.error(
67 {
68 errorMessage: error instanceof Error ? error.message : String(error),
69 errorStack: error instanceof Error ? error.stack : undefined,
70 profileName,
71 },
72 'Error parsing user JSON',
73 )
74 return
75 }
76}
77
78/**
79 * Get user credentials from file system

Callers 1

getUserCredentialsFunction · 0.70

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected