A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
Merge branch 'main' into fix/tomtom-cross-site-gate
Sameh Khamis53bb05abed38
diff --cc SECURITY.mdindex fdb10b877,cc3f27cfe..e53883548--- a/SECURITY.md+++ b/SECURITY.md@@@ -73,7 -73,10 +73,10 @@@ The data proxies under `server/provider- **Sanitized errors** — internal error details are not echoed back to clients.- **Coalesced OAuth refresh** and cached successful responses only (OpenSky).- **Redacted debug logging.** The voice debug log (`.gev-logs/`, gitignored) strips API keys, bearer tokens, client secrets, and image data URLs before writing.-- **Cross-site gate on cost/log endpoints.** The cost-bearing (`/api/realtime/token`, `/api/openai/hud-summary`, `/api/google/nearby-places`, `/api/google/text-search`), quota-bearing (`/api/mapillary/*`, with a per-IP limit on tiles) and log (`/api/realtime/debug-log`) endpoints refuse cross-site browser requests: a foreign or opaque `Origin`, a `Sec-Fetch-Site` other than `same-origin`/`none` (this is what blocks an `<img>`/navigation that carries no `Origin`), or any reverse-proxy/CDN forwarding header returns `403`. Non-browser loopback tools (the repo QA harnesses POST the token endpoint with no `Origin`) and the explicit `HOST=0.0.0.0` LAN opt-in keep working — the gate deliberately does not require a loopback remote address; that stricter requirement belongs only to the credential panel (`admitKeySetupRequest`). The Host check (`allowedHosts`, applied by `hostCheckPlugin` ahead of every route, since Vite's own check runs only after plugin middleware) rejects a rebinding `Host` before any handler runs, in every mode, and the gate is defense in depth behind it: the LAN opt-in keeps that check and accepts only IP addresses, `localhost` and names listed in `GEV_ALLOWED_HOSTS`. **Limit:** a name you list there is trusted like the app's own address, so list only names you control.+- **Cross-site gate on cost/log endpoints.** The cost-bearing (`/api/realtime/token`, `/api/openai/hud-summary`, `/api/google/nearby-places`, `/api/google/text-search`), quota-bearing (`/api/mapillary/*`, with a per-IP limit on tiles, and `/api/tomtom/*`, backed by its persistent daily tile budget) and log (`/api/realtime/debug-log`) endpoints refuse cross-site browser requests: a foreign or opaque `Origin`, a `Sec-Fetch-Site` other than `same-origin`/`none` (this is what blocks an `<img>`/navigation that carries no `Origin`), or any reverse-proxy/CDN forwarding header returns `403`. Non-browser loopback tools (the repo QA harnesses POST the token endpoint with no `Origin`) and the explicit `HOST=0.0.0.0` LAN opt-in keep working — the gate deliberately does not require a loopback remote address; that stricter requirement belongs only to the credential panel (`admitKeySetupRequest`). The Host check (`allowedHosts`, applied by `hostCheckPlugin` ahead of every route, since Vite's own check runs only after plugin middleware) rejects a rebinding `Host` before any handler runs, in every mode, and the gate is defense in depth behind it: the LAN opt-in keeps that check and accepts only IP addresses, `localhost` and names listed in `GEV_ALLOWED_HOSTS`. **Limit:** a name you list there is trusted like the app's own address, so list only names you control.+ - **Full Content-Security-Policy.** The dev and preview servers send a real CSP (`script-src 'self' 'unsafe-eval' blob:` plus the YouTube, Facebook and X scripts the Nepal event's embedded media loads and the Maps JavaScript API that Street View runs on, with a matching `frame-src` for their players and posts: no inline script and no other script origin; `blob:` covers the object URLs Cesium's bundled workers bootstrap through in the built app), alongside the existing `X-Frame-Options: DENY` and `frame-ancestors 'none'`. `'unsafe-eval'` stays because Knockout, bundled inside Cesium's widgets package, resolves the global object with `eval` at load time and the globe does not initialize without it; styles permit `'unsafe-inline'` and Google Fonts because Vite's dev client injects `<style>` elements.++ Allowing `maps.googleapis.com` in `script-src` also trusts its JSONP endpoints, which can bypass the script allowlist if an HTML-injection bug exists; this is an accepted limitation of loading the Maps JavaScript API, alongside the existing `'unsafe-eval'` allowance.- **Full Content-Security-Policy.** The dev and preview servers send a real CSP (`script-src 'self' 'unsafe-eval' blob:` plus the YouTube, Facebook and X scripts the Nepal event's embedded media loads, with a matching `frame-src` for their players and posts: no inline script and no other script origin; `blob:` covers the object URLs Cesium's bundled workers bootstrap through in the built app), alongside the existing `X-Frame-Options: DENY` and `frame-ancestors 'none'`. `'unsafe-eval'` stays because Knockout, bundled inside Cesium's widgets package, resolves the global object with `eval` at load time and the globe does not initialize without it; styles permit `'unsafe-inline'` and Google Fonts because Vite's dev client injects `<style>` elements.- **ChatGPT OAuth voice reuses the local Codex sign-in.** `/api/realtime/oauth-status`, `/api/realtime/oauth-login` and `/api/realtime/token?auth=oauth` answer only loopback connections, behind the same cross-site gate as the token endpoint; the login route also refuses a foreign `Origin`. None of them returns the access token. The login route runs `codex login` (or the executable named by `CODEX_BIN`) with an allowlisted environment that leaves out GEV's provider keys, keeps one attempt pending at a time and cancels it after two minutes or when the server stops. **Limits:** any program on this machine that can reach the server can mint Realtime sessions on the signed-in ChatGPT account, as it can with the API key; a local reverse proxy that hides the client's address defeats the loopback check; and OpenAI has not documented this use of Codex credentials for Realtime, so it may stop working or fall outside the account's terms.diff --cc docs/CURRENT-STATE.mdindex f7c1056ed,34ad95e6b..5671f41ec--- a/docs/CURRENT-STATE.md+++ b/docs/CURRENT-STATE.md@@@ -1103,10 -1392,10 +1392,13 @@@ plugin order, server-key selection, valand stale/error responses remain unchanged. Each has a Node-only package entryunder `gods-eye-view/server/providers/`. Portable terrain mechanics, traffic tilemath and GBFS source rules are available under `gods-eye-view/sources/`.-The browser layers and their rendering remain in their existing modules.+The TomTom `/api/tomtom/*` routes run the shared same-site admission gate before+status, cache or upstream work, refusing cross-site browser requests while+preserving same-origin app requests and non-browser local callers. The browser+layers and their rendering remain in their existing modules.+ GBFS null or empty availability counts retain an unknown value through station+ parsing and rendering; they use the neutral station color rather than reporting+ an empty dock. Explicit zero and caller-supplied numeric fallbacks remain valid.## Terrain height cache bounddiff --cc scripts/package-boundaries.jsonindex 1c8939f16,75ed60f18..40090ba19--- a/scripts/package-boundaries.json+++ b/scripts/package-boundaries.json@@@ -125,9 -128,10 +128,12 @@@"exports": ["./server/providers/traffic"],"modules": ["server/providers/traffic.js",+ "server/providers/common/http.js",+ "src/sources/httpBody.js",+ "src/i18n/marker.js",- "src/data/tomtomTiles.js"+ "src/data/tomtomTiles.js",+ "server/providers/common/same-site.js",+ "src/localRequestGate.mjs"],"external": []},diff --cc src/tooling/environmentProviders.test.mjsindex 36889f6dc,63795c16d..b6faeb34c--- a/src/tooling/environmentProviders.test.mjs+++ b/src/tooling/environmentProviders.test.mjs@@@ -176,64 -191,29 +199,87 @@@ test('traffic middleware preserves keylassert.equal(calls, 2);});+test('traffic refuses cross-site requests in dev and preview before spending the TomTom budget', async (t) => {+ isolate(t, { TOMTOM_API_KEY: 'fixture-key', TOMTOM_DAILY_TILE_BUDGET: '3' });+ let calls = 0;+ t.mock.method(globalThis, 'fetch', async () => {+ calls++;+ return new Response(new Uint8Array([1, 2, 3]));+ });+ const host = 'localhost:5173';+ const refused = [+ { host, 'sec-fetch-site': 'cross-site' }, // <img src> from any web page+ { host, 'sec-fetch-site': 'same-site' },+ { host, origin: 'https://evil.example' }, // fetch from another page+ { host, origin: 'null' }, // sandboxed frame+ { host, 'x-forwarded-for': '203.0.113.9' }, // through a proxy+ ];+ for (const [mode, hook] of [+ ['dev', 'configureServer'],+ ['preview', 'configurePreviewServer'],+ ]) {+ const request = install(tomtomProxy(), hook);+ // Each refused shape asks for distinct uncached tiles: without the gate+ // every one would be a billed attempt counted against the daily budget.+ let x = 0;+ for (const headers of refused)+ for (let i = 0; i < 2; i++) {+ const res = await request(`/flow/16/${x++}/0.pbf`, 'GET', headers);+ assert.equal(res.status, 403, `${mode}: ${JSON.stringify(headers)}`);+ }+ assert.equal(+ (await request('/status', 'GET', refused[0])).status,+ 403,+ `${mode}: status is gated too`,+ );+ assert.equal(+ calls,+ mode === 'dev' ? 0 : 2,+ `${mode}: no refused upstream work`,+ );+ const app = { host, 'sec-fetch-site': 'same-origin' };+ assert.equal(json(await request('/status', 'GET', app)).dailyCount, 0);+ // The app itself and loopback tools (no browser headers) still get tiles.+ const tile = await request('/flow/8/1/1.pbf', 'GET', app);+ assert.equal(tile.status, 200);+ assert.equal(tile.headers['x-tomtom-cache'], 'MISS');+ assert.equal((await request('/flow/8/2/1.pbf')).status, 200);+ assert.equal(+ (+ await request('/flow/8/1/1.pbf', 'GET', {+ host,+ origin: `http://${host}`,+ })+ ).headers['x-tomtom-cache'],+ 'HIT',+ );+ assert.equal(calls, mode === 'dev' ? 2 : 4);+ }+});++ test('traffic middleware answers 502 to an oversized tile without caching it', async (t) => {+ isolate(t, { TOMTOM_API_KEY: 'fixture-key', TOMTOM_DAILY_TILE_BUDGET: '' });+ const bodies = [];+ t.mock.method(globalThis, 'fetch', async () => {+ const oversized = oversizedResponse('\x01');+ bodies.push(oversized.state);+ return oversized.response;+ });+ const request = install(tomtomProxy());+ const first = await request('/flow/8/1/1.pbf');+ assert.equal(first.status, 502);+ assert.equal(bodies[0].cancelled, true);+ assert.ok(bodies[0].pulled <= 9, 'reading stops at the 8 MiB cap');+ assert.ok(+ !fsp.writeFile.mock.calls.some(({ arguments: [file] }) =>+ String(file).endsWith('.pbf'),+ ),+ 'no tile reached the disk cache',+ );+ assert.equal((await request('/flow/8/1/1.pbf')).status, 502);+ assert.equal(bodies.length, 2, 'nothing was cached in memory');+ });+test('FIRMS retains a large successful source during partial failure and filters stale data at serve time', async (t) => {isolate(t, { FIRMS_MAP_KEY: '' });let now = Date.UTC(2026, 8, 12, 12);