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.
Properties
Section titled “Properties”appName
Section titled “appName”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.
fetchImpl?
Section titled “fetchImpl?”optional fetchImpl?: (input, init?) => Promise<Response>;Defined in: core/src/auth/oauth.ts:27
Replaces fetch, for tests.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
RequestInfo | URL |
init? |
RequestInit |
Returns
Section titled “Returns”Promise<Response>
timeoutMs?
Section titled “timeoutMs?”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.
Methods
Section titled “Methods”captureRedirect()
Section titled “captureRedirect()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
{ authorizeUrl: string; redirectUri: string; signal: AbortSignal; state?: string; } |
request.authorizeUrl |
string |
request.redirectUri |
string |
request.signal |
AbortSignal |
request.state? |
string |
Returns
Section titled “Returns”Promise<string>
openUrl()
Section titled “openUrl()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
url |
string |
Returns
Section titled “Returns”void | Promise<void>