(auth: Auth.Info, providerID: string)
| 807 | const TOKEN_REFRESH_BUFFER_MS = 60 * 1000 |
| 808 | |
| 809 | async function resolveCodexCredentials(auth: Auth.Info, providerID: string): Promise<{ accessToken: string; accountId: string }> { |
| 810 | if (auth.type === "codex") { |
| 811 | const accessToken = await CodexClient.ensureValidTokenFor(providerID, auth) |
| 812 | const accountId = resolveAccountId(auth.accountId, auth.idToken ?? accessToken) |
| 813 | return { accessToken, accountId } |
| 814 | } |
| 815 | |
| 816 | if (auth.type === "oauth") { |
| 817 | const accessToken = await ensureOauthAccessToken(auth, providerID) |
| 818 | const accountId = resolveAccountId(undefined, accessToken) |
| 819 | return { accessToken, accountId } |
| 820 | } |
| 821 | |
| 822 | throw new Error("Codex authentication is required. Run `arctic auth codex` to connect your account.") |
| 823 | } |
| 824 | |
| 825 | async function ensureOauthAccessToken(auth: Extract<Auth.Info, { type: "oauth" }>, providerID: string): Promise<string> { |
| 826 | let token = auth.access |
no test coverage detected