Repository navigation
Minor Changes
-
#586
3cc264bThanks @luismeyer! -encryptFlagValuesencrypts with the public key of Vercel when there is noFLAGS_SECRET, instead of throwing. In SvelteKit,createHandleandencryptFlagValueswork withoutFLAGS_SECRETtoo: the flag values of a page are encrypted with the public key.This fallback is silent. Before, a secret which is
undefinedor empty (e.g.encryptFlagValues(values, process.env.TYPO)) threw an error. Now the values are encrypted with the public key, anddecryptFlagValuescan not read them, because only Vercel can decrypt them: it logs a warning and returnsundefined.decryptFlagValues,encryptFlagDefinitionsanddecryptFlagDefinitionskeep working only with aFLAGS_SECRET.The project of the host is also read from the OIDC token of the request (
x-vercel-oidc-token), so a deployment which does not expose the system environment variables works too. -
#589
e248a06Thanks @luismeyer! -verifyAccessaccepts short-lived tokens which Vercel signs with Vercel KMS, so the Flags Discovery Endpoint (/.well-known/vercel/flags) works on Vercel without aFLAGS_SECRET. These tokens are signed by a separate Vercel KMS issuer, not the issuer of signed overrides.Proofs encrypted with the
FLAGS_SECRETkeep working exactly as before. Without a secret,verifyAccessnow returnsfalsefor such a proof instead of throwing.When there is no secret and the host can not verify signed tokens (a self-hosted app, local development without
vercel env pull, or a project which does not expose the system environment variables),verifyAccesslogs a warning which names the fix. -
#587
3b5d8ecThanks @luismeyer! - Accept flag overrides which the Vercel Toolbar signs with Vercel KMS, so overrides work on Vercel without aFLAGS_SECRET.On Vercel, or locally after
vercel env pull, the SDK verifies signed override tokens with the public keys of Vercel, which it keeps in memory.decryptOverridesaccepts them too, for apps which read the cookie themselves. Tokens encrypted with theFLAGS_SECRETkeep working exactly as before. The cookie is stillvercel-flag-overrides.The host must know that it runs for a Vercel project. On Vercel, it reads the project from the system environment variables (
VERCEL,VERCEL_PROJECT_ID), or from the OIDC token of the request (x-vercel-oidc-token). With that token, a deployment also checks the team of a signed token. Locally,vercel env pullsupplies theVERCEL_OIDC_TOKEN. SvelteKit also reads it from$envduringvite dev.A signed token which the host can not use is ignored, with a warning which names the cause: the host can not verify signed tokens, the public keys do not load, or the token is for a different project or environment.
Without a
FLAGS_SECRET, a Next.js flag now ignores an overrides cookie which the host can not read (e.g. an encrypted cookie from before the secret was removed). Before, it threwflags: Missing FLAGS_SECRET.Add
signOverrides, which asks Vercel to sign flag overrides for the project and the environment of the host, e.g. for end-to-end tests of a project without aFLAGS_SECRET. It uses the OIDC token of the host: of the request on a deployment, or theVERCEL_OIDC_TOKENofvercel env pull. -
#597
0d8720fThanks @luismeyer! - Precompute works on Vercel without aFLAGS_SECRET. When there is no secret,precompute,serialize,deserialize,getPrecomputedandgeneratePermutations(Next.js and SvelteKit) sign the code with a key derived fromVERCEL_DEPLOYMENT_KEY, which Vercel sets for the build and for the runtime of a deployment.Each deployment has its own key, so a code is only valid inside the deployment which created it. Set
FLAGS_SECRETorFLAGS_PRECOMPUTE_SECRET, or pass a secret, if a code must be valid in another deployment or project.The new variable
FLAGS_PRECOMPUTE_SECRETsets a secret for precompute only. It is only used when there is noFLAGS_SECRET. The order is: a secret passed to the function,FLAGS_SECRET,FLAGS_PRECOMPUTE_SECRET, the key of the deployment, the public secret outside of Vercel. In SvelteKit, pass the same secret tocreateHandle,precomputeandgeneratePermutations, or none to all of them.In the local development of a Vercel project (e.g.
next devor a localnext build && next startaftervercel env pull, which writes aVERCEL_OIDC_TOKENfor the environmentdevelopment), these functions use a fixed, public secret when there is no other one. Anyone can create a code with it, so they warn one time whenNODE_ENVis notdevelopment. Without such a token, e.g. on a custom host, they throw without a secret, as before.In a Turborepo task, a cache hit replays codes of another deployment, because
VERCEL_DEPLOYMENT_KEYis not part of the hash of the task. AddVERCEL_DEPLOYMENT_KEYto theenvof the task inturbo.json, or setFLAGS_PRECOMPUTE_SECRET.On Vercel without a secret and without
VERCEL_DEPLOYMENT_KEY(a project which does not expose the system environment variables, or a build withvercel buildwhich is deployed withvercel deploy --prebuilt), these functions throw as before.
Patch Changes
-
#586
3cc264bThanks @luismeyer! - Without aFLAGS_SECRET,encryptFlagValuesno longer throws when the public key of Vercel does not load (e.g. the key host is down, or a request times out). It logs a warning, at most one time in 30 seconds, and returns an empty string, so the build or the render does not fail. The flag values are only for the Vercel Toolbar: the page has none until it renders again.FlagValuesofflags/reactrenders nothing for an empty string. If you render thescripttag withdata-flag-valuesyourself, leave it out when the value is empty. In SvelteKit,createHandlealready rendered the page without the flag values;encryptFlagValuesofflags/sveltekitnow returns an empty string too.encryptFlagValuesstill throws when there is neither a secret nor a project ID, when the project ID is too long, and when the secret is not valid. With a secret nothing changes.