Skip to content

AuthHost

Defined in: core/src/auth/oauth.ts:8

What the host app supplies. Opening a browser and catching a redirect are the two things a fetch-only package can’t do.

appName: string;

Defined in: core/src/auth/oauth.ts:11

Names the app on the wire: Copilot’s Editor-Version, xAI’s referrer. Use name/version, like TabRunner/1.4.0.


optional fetchImpl?: (input, init?) => Promise<Response>;

Defined in: core/src/auth/oauth.ts:27

Replaces fetch, for tests.

MDN Reference

Parameter Type
input RequestInfo | URL
init? RequestInit

Promise<Response>


optional timeoutMs?: number;

Defined in: core/src/auth/oauth.ts:29

How long one request to a sign-in server may take, in ms. Default 30 s.

captureRedirect(request): Promise<string>;

Defined in: core/src/auth/oauth.ts:20

Opens authorizeUrl, waits for the browser to land on redirectUri, and returns the code from that URL. Reject with a SignInError when the user denies (denied), closes the page (cancelled) or takes too long (expired). Check state against the one in the URL when it is set.

Parameter Type
request { authorizeUrl: string; redirectUri: string; signal: AbortSignal; state?: string; }
request.authorizeUrl string
request.redirectUri string
request.signal AbortSignal
request.state? string

Promise<string>


openUrl(url): void | Promise<void>;

Defined in: core/src/auth/oauth.ts:13

Opens a page for the user. Device-code flows call it with the approval page.

Parameter Type
url string

void | Promise<void>