feat(maps): one shared list of the shipped tile hosts for the CSP and the client

A GL map fetches its style and its tiles, so it can only draw from a host
the server's connect-src names. The raster presets and OpenFreeMap were
written out in the middleware while the client kept its own idea of them,
and nothing held the two together.

The hosts, their reasons and the default OpenFreeMap style now live in
shared/src/maps/map-defaults.ts. The middleware builds those sources from
the list, and the client takes the default style from it, so the renderer
choice the next steps add reads the same hosts the policy allows.

The policy an install sends stays byte for byte the same: a test pins the
whole connect-src in its order.
This commit is contained in:
Maurice
2026-11-30 14:33:05 +01:00
parent b27b3f6563
commit d8a93af2f5
6 changed files with 150 additions and 51 deletions
@@ -305,3 +305,57 @@ describe("connect-src with the operator's own map hosts (MAP_EXTRA_CONNECT_HOSTS
expect(sources).not.toContain("'unsafe-inline'");
});
});
describe('connect-src as shipped', () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it('CSP-SHIPPED-001: lists exactly the shipped sources, in the order they always had', async () => {
// The tile hosts come from the list the client shares (shared/src/maps/map-defaults.ts);
// moving them there must not change one byte of the policy an install sends.
vi.stubEnv('MAP_EXTRA_CONNECT_HOSTS', '');
expect((await connectSrcSources()).join(' ')).toBe(
[
"'self'",
'ws:',
'wss:',
'https://nominatim.openstreetmap.org',
'https://elevation-tiles-prod.s3.amazonaws.com',
'https://overpass-api.de',
'https://places.googleapis.com',
'https://api.openweathermap.org',
'https://en.wikipedia.org',
'https://commons.wikimedia.org',
'https://basemaps.cartocdn.com',
'https://*.basemaps.cartocdn.com',
'https://tile.openstreetmap.org',
'https://*.tile.openstreetmap.org',
'https://tile.openstreetmap.de',
'https://tiles.stadiamaps.com',
'https://tile.opentopomap.org',
'https://*.tile.opentopomap.org',
'https://server.arcgisonline.com',
'https://tiles.openseamap.org',
'https://tiles.opensnowmap.org',
'https://tile.openmaps.fr',
'https://a.tile-cyclosm.openstreetmap.fr',
'https://b.tile-cyclosm.openstreetmap.fr',
'https://c.tile-cyclosm.openstreetmap.fr',
'https://*.is.autonavi.com',
'https://unpkg.com',
'https://open-meteo.com',
'https://api.open-meteo.com',
'https://geocoding-api.open-meteo.com',
'https://api.frankfurter.dev',
'https://router.project-osrm.org/route/v1/',
'https://routing.openstreetmap.de/',
'https://valhalla1.openstreetmap.de',
'https://api.mapbox.com',
'https://*.tiles.mapbox.com',
'https://events.mapbox.com',
'https://tiles.openfreemap.org',
].join(' '),
);
});
});