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
+19
View File
@@ -0,0 +1,19 @@
import { isMapConnectHost } from './map-connect-hosts';
import { OPENFREEMAP_DEFAULT_STYLE, OPENFREEMAP_HOST, RASTER_TILE_HOSTS } from './map-defaults';
import { describe, expect, it } from 'vitest';
describe('map defaults', () => {
it('MAP-DEFAULTS-001: every shipped host reads in the grammar the operator list uses', () => {
for (const host of [...RASTER_TILE_HOSTS, OPENFREEMAP_HOST]) expect(isMapConnectHost(host), host).toBe(true);
});
it('MAP-DEFAULTS-002: lists each raster host once', () => {
expect(new Set(RASTER_TILE_HOSTS).size).toBe(RASTER_TILE_HOSTS.length);
});
it('MAP-DEFAULTS-003: the default style is OpenFreeMap Liberty on the shared host', () => {
expect(OPENFREEMAP_DEFAULT_STYLE).toBe('https://tiles.openfreemap.org/styles/liberty');
expect(new URL(OPENFREEMAP_DEFAULT_STYLE).host).toBe(OPENFREEMAP_HOST);
});
});