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

Function getUserCredentials

cli/src/utils/auth.ts:82–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 * @returns User object or null if not found/authenticated
81 */
82export const getUserCredentials = (): User | null => {
83 const credentialsPath = getCredentialsPath()
84
85 // Read user credentials directly from file
86 if (!fs.existsSync(credentialsPath)) {
87 return null
88 }
89
90 try {
91 const credentialsFile = fs.readFileSync(credentialsPath, 'utf8')
92 const user = userFromJson(credentialsFile)
93 return user || null
94 } catch (error) {
95 logger.error(
96 {
97 error: error instanceof Error ? error.message : String(error),
98 },
99 'Error reading credentials',
100 )
101 return null
102 }
103}
104
105export type AuthTokenSource = 'credentials' | 'environment' | null
106

Callers 7

handlePublishFunction · 0.90
useAuthQueryFunction · 0.90
useAuthStateFunction · 0.90
getAuthTokenDetailsFunction · 0.70
logoutUserFunction · 0.70

Calls 2

getCredentialsPathFunction · 0.70
userFromJsonFunction · 0.70

Tested by

no test coverage detected