()
| 80 | * @returns User object or null if not found/authenticated |
| 81 | */ |
| 82 | export 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 | |
| 105 | export type AuthTokenSource = 'credentials' | 'environment' | null |
| 106 |
no test coverage detected