()
| 33 | // ─── Auth Token Bootstrap ───────────────────────────────────── |
| 34 | |
| 35 | async 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 |
no test coverage detected