Skip to content

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

Open
luismeyer wants to merge 7 commits into
mainfrom
luismeyer/flag-values-platform-encryption
Open

luismeyer wants to merge 7 commits into
mainfrom
luismeyer/flag-values-platform-encryption

Conversation

@luismeyer

@luismeyer luismeyer commented Nov 2, 2026 •

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, with the signature of encryptFlagValues unchanged.

What

  • With a secret (argument or FLAGS_SECRET), nothing changes.
  • Without one, 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.
  • The project ID comes from VERCEL_PROJECT_ID, the VERCEL_OIDC_TOKEN of vercel env pull, or .vercel/project.json.
  • In SvelteKit, createHandle and encryptFlagValues no longer require a secret. Without one, the data-flag-values of a page use the public key, the overrides cookie is ignored, /.well-known/vercel/flags responds with 401, and precompute still requires a secret.
  • The key set is cached for 5 minutes. Concurrent loads share one request, and after a failed load there is a 30 s cooldown.

Validation

  • New tests in flag-values-platform.test.ts cover the token format, finding the project ID, key caching and rotation, the error cooldown, and that a set FLAGS_SECRET is still used. without-secret.test.ts covers SvelteKit's createHandle and encryptFlagValues without a secret.

🤖 Generated with Claude Code

@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 11, 2026 11:38am UTC
flags-sdk-dev Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-flagsmith Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-growthbook Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-launchdarkly Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-openfeature Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-posthog Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-reflag Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-snippets Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-statsig Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
shirt-shop Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC
shirt-shop-api Ready Ready Preview, v0 Nov 11, 2026 11:38am UTC

luismeyer and others added 4 commits November 10, 2026 16:33
…S_SECRET

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut new options

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rcel-platform

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

@chriswdmr chriswdmr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Three things to fix before merge:

  • SvelteKit without a secret: a failure to load the key must not break the page render
  • Add a timeout to the key set fetch
  • Next.js middleware: remove the two new Edge Runtime build warnings

The other comments are suggestions and nits.

Comment thread packages/flags/src/sveltekit/index.ts Resolved
Comment thread packages/flags/src/lib/crypto.ts Resolved
Comment thread packages/flags/src/sveltekit/index.ts Resolved
luismeyer and others added 3 commits November 11, 2026 11:05
- Read env vars without a process global and from SvelteKit's $env
- Memoize the OIDC decode and the .vercel/project.json read
- No Edge Runtime warnings for process.getBuiltinModule / process.cwd
- Load the key set with a 5s timeout
- Rethrow framework control-flow errors instead of wrapping them
- SvelteKit: render the page without flag values when encryption fails
- Document that the fallback without a secret is silent

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
…an decrypt

Note that decryptFlagValues, encryptFlagDefinitions and
decryptFlagDefinitions work only with a FLAGS_SECRET.

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch was successfully deployed

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

2 participants