MCPcopy Index your code
hub / github.com/CapSoftware/Cap / checkAuthStartRoute

Function checkAuthStartRoute

apps/chrome-extension/src/shared/api.ts:46–65  ·  view source on GitHub ↗
(
	settings: ExtensionSettings,
	url: URL,
	redirectUri: string,
)

Source from the content-addressed store, hash-verified

44 new URL(path, settings.apiBaseUrl).toString();
45
46const 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

Callers 1

createAuthStartFunction · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected