Skip to content

Mint GeoJSON preview token per request instead of caching#118

Merged
zmofei merged 3 commits into
mainfrom
geojson-preview-token-per-request
Jun 10, 2026
Merged

Mint GeoJSON preview token per request instead of caching#118
zmofei merged 3 commits into
mainfrom
geojson-preview-token-per-request

Conversation

@zmofei

@zmofei zmofei commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

The GeoJSON Preview UI resource (ui://mapbox/geojson-preview/index.html) reused a process-wide cached Mapbox GL token across requests. This change mints a short-lived token per request and verifies the minted token belongs to the requesting account before embedding it in the returned HTML.

Changes

  • Remove the module-global token cache; mint the token per request (request-scoped).
  • Assert the minted token's account matches the caller before embedding it; otherwise render without a token.
  • Add a test suite for the resource (per-request minting, pk pass-through, graceful degradation when minting fails, no-token case).

Testing

  • npm test — new test/resources/ui-apps/GeojsonPreviewUIResource.test.ts (6 cases), full suite green
  • npm run build, npm run lint

zmofei added 2 commits June 10, 2026 13:21
The GeoJSON Preview UI resource reused a process-wide cached Mapbox GL token across requests. Mint a short-lived token per request and verify it belongs to the requesting account before embedding it. Adds tests for the resource.
@zmofei zmofei force-pushed the geojson-preview-token-per-request branch 2 times, most recently from e9d1aea to c118e6d Compare June 10, 2026 11:20
@zmofei zmofei marked this pull request as ready for review June 10, 2026 11:21
@zmofei zmofei requested a review from a team as a code owner June 10, 2026 11:21
Valiunia
Valiunia previously approved these changes Jun 10, 2026
@zmofei zmofei merged commit 9932e54 into main Jun 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants