(region: Region)
| 88 | } |
| 89 | |
| 90 | export async function runOAuthLogin(region: Region): Promise<void> { |
| 91 | const creds = await deviceCodeLogin(region); |
| 92 | // OAuth and api_key are mutually exclusive — drop any stale api_key |
| 93 | // so `mmx auth status` and the resolver see a single source of truth. |
| 94 | const existing = readConfigFile() as Record<string, unknown>; |
| 95 | delete existing.api_key; |
| 96 | existing.oauth = creds; |
| 97 | existing.region = region; |
| 98 | await writeConfigFile(existing); |
| 99 | process.stderr.write('Logged in successfully.\n'); |
| 100 | process.stderr.write('Credentials saved to ~/.mmx/config.json\n'); |
| 101 | } |
| 102 | |
| 103 | async function persistApiKey(config: Config, key: string): Promise<void> { |
| 104 | const data = { ...(readConfigFile() as Record<string, unknown>), api_key: key }; |
no test coverage detected