MCPcopy Index your code
hub / github.com/coder/mux / checkAuth

Function checkAuth

vscode/src/api/connectionCheck.ts:101–118  ·  view source on GitHub ↗
(
  client: ApiClient,
  options?: { timeoutMs?: number }
)

Source from the content-addressed store, hash-verified

99}
100
101export async function checkAuth(
102 client: ApiClient,
103 options?: { timeoutMs?: number }
104): Promise<AuthCheckResult> {
105 const timeoutMs = options?.timeoutMs ?? 1_000;
106
107 try {
108 // Used both as an auth check and a basic liveness check.
109 await promiseWithTimeout(client.general.ping("vscode"), timeoutMs, "API ping");
110 return { status: "ok" };
111 } catch (error) {
112 if (isUnauthorizedError(error)) {
113 return { status: "unauthorized", error: formatError(error) };
114 }
115
116 return { status: "error", error: formatError(error) };
117 }
118}

Callers 3

tryGetApiClientFunction · 0.90
debugConnectionCommandFunction · 0.90

Calls 3

isUnauthorizedErrorFunction · 0.85
promiseWithTimeoutFunction · 0.70
formatErrorFunction · 0.70

Tested by

no test coverage detected