()
| 188 | * Only removes the 'default' field, preserving other credentials. |
| 189 | */ |
| 190 | export const clearUserCredentials = (): void => { |
| 191 | const credentialsPath = getCredentialsPath() |
| 192 | |
| 193 | try { |
| 194 | if (!fs.existsSync(credentialsPath)) return |
| 195 | |
| 196 | const { default: _, ...rest } = readCredentialsFile() |
| 197 | |
| 198 | if (Object.keys(rest).length === 0) { |
| 199 | fs.unlinkSync(credentialsPath) |
| 200 | } else { |
| 201 | fs.writeFileSync(credentialsPath, JSON.stringify(rest, null, 2)) |
| 202 | } |
| 203 | } catch (error) { |
| 204 | logger.error( |
| 205 | { |
| 206 | error: error instanceof Error ? error.message : String(error), |
| 207 | }, |
| 208 | 'Error clearing credentials', |
| 209 | ) |
| 210 | throw error |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | export async function logoutUser(): Promise<boolean> { |
| 215 | try { |
no test coverage detected