MCPcopy Create free account
hub / github.com/garrytan/gstack / loadAuthToken

Function loadAuthToken

extension/background.js:35–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33// ─── Auth Token Bootstrap ─────────────────────────────────────
34
35async function loadAuthToken() {
36 if (authToken) return;
37 // Get token from browse server /health endpoint (localhost-only, safe).
38 // Previously read from .auth.json in extension dir, but that breaks
39 // read-only .app bundles and codesigning.
40 const base = getBaseUrl();
41 if (!base) return;
42 try {
43 const resp = await fetch(`${base}/health`, { signal: AbortSignal.timeout(3000) });
44 if (resp.ok) {
45 const data = await resp.json();
46 if (data.token) authToken = data.token;
47 }
48 } catch (err) {
49 console.error('[gstack bg] Failed to load auth token:', err.message);
50 }
51}
52
53// ─── Health Polling ────────────────────────────────────────────
54

Callers 2

checkHealthFunction · 0.85
background.jsFile · 0.85

Calls 2

getBaseUrlFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected