Skip to content

[flags] Encrypt FlagValues with the public key of Vercel without FLAGS_SECRET - #586

Draft
luismeyer wants to merge 1 commit into
mainfrom
luismeyer/flag-values-platform-encryption
Draft

luismeyer wants to merge 1 commit into
mainfrom
luismeyer/flag-values-platform-encryption

Conversation

@luismeyer

Copy link
Copy Markdown
Member

Why

  • encryptFlagValues throws without FLAGS_SECRET, so a project needs a secret just to keep its flag values confidential.
  • The Flags Explorer can now decrypt values encrypted with the public key of Vercel through the API (vercel/api#103736, vercel/next-live-mode#3893 behind flags-explorer-api-decrypt).
  • This brings the platform encryption of the standard branch ([flags] FlagValues: projectIds in the protected header, flags-keys JWKS #575) to main, without the rest of that branch.

What

  • Without FLAGS_SECRET, encryptFlagValues encrypts with the public key from https://keys.vercel-flags.com/.well-known/jwks.json (ECDH-ES, A256GCM, projectIds and kid in the protected header, pur: flag-values, ver: 1, aud: vercel:flag-values). This is the format that @api/flag-values decrypts.
  • With FLAGS_SECRET nothing changes. { method: 'platform' } uses the public key anyway.
  • The second argument can now be the secret, as before, or EncryptFlagValuesOptions (method, secret, expirationTime, projectIds, jwksUrl, fetch).
  • The project ID comes from VERCEL_PROJECT_ID, the VERCEL_OIDC_TOKEN of vercel env pull, or .vercel/project.json.
  • The key set is cached for 5 minutes. Concurrent loads share one request, and after a failed load there is a 30 s cooldown.
  • SvelteKit's createHandle still requires a secret and isn't changed.

Validation

  • New tests in flag-values-platform.test.ts cover the token format, finding the project ID, validating projectIds, key caching and rotation, the error cooldown, HTTPS-only key URLs, and the positional arguments still working.
  • vitest (169 tests), tsc --noEmit, biome and the package build all pass.

🤖 Generated with Claude Code

…S_SECRET

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flags-playground Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-dev Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-flagsmith Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-growthbook Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-launchdarkly Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-openfeature Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-posthog Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-reflag Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-snippets Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-statsig Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
shirt-shop Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC
shirt-shop-api Ready Ready Preview, v0 Nov 2, 2026 5:05pm UTC

This branch was successfully deployed

14 active deployments
Preview – flags-sdk-dev — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-openfeature — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-growthbook — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-launchdarkly — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – shirt-shop — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-statsig — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-vercel — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-playground — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-flagsmith — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-posthog — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – flags-sdk-reflag — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
Preview – shirt-shop-api — 165c09cf Deployed Nov 2, 2026 by vercel[bot]
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.

1 participant