( settings: ExtensionSettings, url: URL, redirectUri: string, )
| 44 | new URL(path, settings.apiBaseUrl).toString(); |
| 45 | |
| 46 | const checkAuthStartRoute = async ( |
| 47 | settings: ExtensionSettings, |
| 48 | url: URL, |
| 49 | redirectUri: string, |
| 50 | ) => { |
| 51 | try { |
| 52 | const response = await fetch(url, { |
| 53 | redirect: "manual", |
| 54 | signal: AbortSignal.timeout(AUTH_CHECK_TIMEOUT_MS), |
| 55 | }); |
| 56 | if (response.type === "opaqueredirect" || response.status === 302) return; |
| 57 | if (response.ok) return; |
| 58 | throw new Error(`${response.status} ${await response.text()}`); |
| 59 | } catch (error) { |
| 60 | const message = error instanceof Error ? error.message : String(error); |
| 61 | throw new Error( |
| 62 | `Could not reach Cap extension auth at ${url.origin}. Start the local web server with pnpm dev:extension and make sure the extension Options Cap URL is ${settings.apiBaseUrl}. Redirect URI: ${redirectUri}. ${message}`, |
| 63 | ); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | // Carries the HTTP status so callers can tell a definitive server answer |
| 68 | // (the request was processed and rejected) from a failure where the request |
no test coverage detected