()
| 265 | }; |
| 266 | |
| 267 | const poll = async () => { |
| 268 | if (settled) return; |
| 269 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: fetch can reject for transient network errors during polling |
| 270 | try { |
| 271 | // The await poll is now gated like the rest of /api — carry the bearer |
| 272 | // (standalone web). On desktop the connection has no client-side auth and |
| 273 | // the main process injects the header instead. |
| 274 | const authorization = getExecutorServerAuthorizationHeader(); |
| 275 | const response = await fetch(`/api/oauth/await/${encodeURIComponent(input.sessionId)}`, { |
| 276 | signal: controller.signal, |
| 277 | cache: "no-store", |
| 278 | ...(authorization ? { headers: { authorization } } : {}), |
| 279 | }); |
| 280 | if (!response.ok) return; |
| 281 | const body = (await response.json()) as unknown; |
| 282 | if (body === null || settled) return; |
| 283 | if (!isOAuthPopupResult<TAuth>(body)) return; |
| 284 | settle(); |
| 285 | input.onResult(body); |
| 286 | } catch { |
| 287 | // Transient — next tick will retry. AbortError after settle is also caught here. |
| 288 | } |
| 289 | }; |
| 290 | |
| 291 | void (async () => { |
| 292 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: openExternal is host-provided IPC, no Effect runtime in this browser-only helper |
no test coverage detected