(info: StoredUserInfo, path = credentialPath())
| 71 | * than fail the login. |
| 72 | */ |
| 73 | export async function saveUserInfo(info: StoredUserInfo, path = credentialPath()): Promise<void> { |
| 74 | if (isUserInfoEmpty(info)) return; |
| 75 | // readStore preserves co-located api_key / oauth blocks and any |
| 76 | // unknown/foreign keys (captured on a hidden slot), so writing back |
| 77 | // only attaches the user block. A legacy single-line plaintext file |
| 78 | // parses into { api_key }, so this upgrades it to JSON in passing. |
| 79 | const { credentials } = await readStore(path); |
| 80 | credentials.user = { ...info }; |
| 81 | await writeStore(credentials, path); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Read the friendly-display block. Returns `null` when the file is absent |
no test coverage detected