()
| 305 | } |
| 306 | |
| 307 | export async function login(): Promise<void> { |
| 308 | const userCodeResponse = await requestUserCode() |
| 309 | printDeviceCodePrompt(userCodeResponse.userCode, userCodeResponse.verificationUri) |
| 310 | |
| 311 | const tokens = await pollForToken(userCodeResponse.deviceAuthId, userCodeResponse.userCode, userCodeResponse.interval) |
| 312 | const idTokenInfo = parseIdToken(tokens.id_token) |
| 313 | const expiresIn = tokens.expires_in ?? 3600 |
| 314 | |
| 315 | await Auth.set("codex", { |
| 316 | type: "codex", |
| 317 | accessToken: tokens.access_token, |
| 318 | refreshToken: tokens.refresh_token, |
| 319 | idToken: tokens.id_token, |
| 320 | accountId: idTokenInfo?.chatgpt_account_id, |
| 321 | expiresAt: Date.now() + expiresIn * 1000, |
| 322 | email: idTokenInfo?.email, |
| 323 | planType: idTokenInfo?.chatgpt_plan_type, |
| 324 | }) |
| 325 | } |
| 326 | |
| 327 | export async function refresh(refreshToken: string): Promise<TokenResponse> { |
| 328 | const url = `${Config.issuerBaseUrl}/oauth/token` |
nothing calls this directly
no test coverage detected