(code: string)
| 190 | } |
| 191 | |
| 192 | export async function handleChatGptAuthCode(code: string): Promise<{ |
| 193 | success: boolean |
| 194 | message: string |
| 195 | }> { |
| 196 | try { |
| 197 | await exchangeChatGptCodeForTokens(code) |
| 198 | stopChatGptOAuthServer() |
| 199 | return { |
| 200 | success: true, |
| 201 | message: |
| 202 | 'Successfully connected your ChatGPT subscription! Codebuff will use it for supported OpenAI streaming requests.', |
| 203 | } |
| 204 | } catch (err) { |
| 205 | return { |
| 206 | success: false, |
| 207 | message: |
| 208 | err instanceof Error |
| 209 | ? err.message |
| 210 | : 'Failed to exchange ChatGPT authorization code', |
| 211 | } |
| 212 | } |
| 213 | } |
no test coverage detected