( relayId: string, )
| 222 | } |
| 223 | |
| 224 | export async function pollOauthCallbackRelay( |
| 225 | relayId: string, |
| 226 | ): Promise<string | null> { |
| 227 | try { |
| 228 | const response = await axios.post<{ |
| 229 | authorization_code?: string |
| 230 | pending?: boolean |
| 231 | }>( |
| 232 | getOauthCallbackRelayEndpoint('/oauth/callback-relay/poll'), |
| 233 | { relay_id: relayId }, |
| 234 | { |
| 235 | headers: { 'Content-Type': 'application/json' }, |
| 236 | timeout: 10000, |
| 237 | validateStatus: status => |
| 238 | status === 200 || status === 202 || status === 204 || status === 404, |
| 239 | }, |
| 240 | ) |
| 241 | if (response.status === 202 || response.status === 204 || response.status === 404) { |
| 242 | return null |
| 243 | } |
| 244 | return response.data.authorization_code ?? null |
| 245 | } catch (error) { |
| 246 | logForDebugging( |
| 247 | `OAuth callback relay poll failed: ${error instanceof Error ? error.message : String(error)}`, |
| 248 | ) |
| 249 | throw error |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | export async function exchangeCodeForTokens( |
| 254 | authorizationCode: string, |
nothing calls this directly
no test coverage detected