| 75 | * Region-only picker used by `mmx auth login --recommend` (no API-key option). |
| 76 | */ |
| 77 | export async function pickOAuthRegion(): Promise<Region> { |
| 78 | const { select, isCancel } = await import('@clack/prompts'); |
| 79 | const value = await select({ |
| 80 | message: 'Select an OAuth region:', |
| 81 | options: [ |
| 82 | { value: 'global', label: `Global → ${stripScheme(REGIONS.global)}` }, |
| 83 | { value: 'cn', label: `China → ${stripScheme(REGIONS.cn)}` }, |
| 84 | ], |
| 85 | }); |
| 86 | if (isCancel(value)) throw new CLIError('Authentication cancelled.', ExitCode.AUTH); |
| 87 | return value as Region; |
| 88 | } |
| 89 | |
| 90 | export async function runOAuthLogin(region: Region): Promise<void> { |
| 91 | const creds = await deviceCodeLogin(region); |