From 431402983f7cc484184d61df9c42982f11834f63 Mon Sep 17 00:00:00 2001 From: David Dada Date: Sat, 14 Nov 2026 00:57:02 +0100 Subject: [PATCH] fix: pass the records flag through the production release build The release build defines each VITE flag explicitly; VITE_RECORDS_ENABLED was missing, so production never included the harbor records even with the flag set. It now follows the sealed note: production only, with a Privy app, and only when exactly true. --- scripts/build-release.test.ts | 11 +++++++---- scripts/build-release.ts | 7 ++++--- scripts/package-tidebound-review.ts | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/build-release.test.ts b/scripts/build-release.test.ts index 10078d9..641de6d 100644 --- a/scripts/build-release.test.ts +++ b/scripts/build-release.test.ts @@ -6,12 +6,15 @@ import { releaseSettings } from "./build-release"; import { buildAccountFunction,currentRouting,HTTP_PATHS } from "./package-tidebound-review"; test("only production builds receive explicitly allowlisted public account settings",()=>{ - expect(releaseSettings({})).toEqual({appId:"",clientId:"",sealedNote:false}); - expect(releaseSettings({VERCEL_ENV:"preview",PRIVY_APP_ID:"prod-app",VITE_PRIVY_CLIENT_ID:"prod-client",VITE_SEALED_NOTE_ENABLED:"true"})).toEqual({appId:"",clientId:"",sealedNote:false}); - expect(releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:"existing-app"})).toEqual({appId:"existing-app",clientId:"",sealedNote:false}); + expect(releaseSettings({})).toEqual({appId:"",clientId:"",sealedNote:false,records:false}); + expect(releaseSettings({VERCEL_ENV:"preview",PRIVY_APP_ID:"prod-app",VITE_PRIVY_CLIENT_ID:"prod-client",VITE_SEALED_NOTE_ENABLED:"true"})).toEqual({appId:"",clientId:"",sealedNote:false,records:false}); + expect(releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:"existing-app"})).toEqual({appId:"existing-app",clientId:"",sealedNote:false,records:false}); expect(releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:"existing-app",VITE_SEALED_NOTE_ENABLED:"1"}).sealedNote).toBe(false); expect(releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:"existing-app",VITE_SEALED_NOTE_ENABLED:"true"}).sealedNote).toBe(true); - expect(releaseSettings({VERCEL_ENV:"production",VITE_PRIVY_APP_ID:"public-app",PRIVY_APP_ID:"fallback",VITE_PRIVY_CLIENT_ID:"public-client"})).toEqual({appId:"public-app",clientId:"public-client",sealedNote:false}); + expect(releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:"existing-app",VITE_RECORDS_ENABLED:"true"}).records).toBe(true); + expect(releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:"existing-app",VITE_RECORDS_ENABLED:"yes"}).records).toBe(false); + expect(releaseSettings({VERCEL_ENV:"preview",PRIVY_APP_ID:"existing-app",VITE_RECORDS_ENABLED:"true"}).records).toBe(false); + expect(releaseSettings({VERCEL_ENV:"production",VITE_PRIVY_APP_ID:"public-app",PRIVY_APP_ID:"fallback",VITE_PRIVY_CLIENT_ID:"public-client"})).toEqual({appId:"public-app",clientId:"public-client",sealedNote:false,records:false}); for(const id of ["","invalid id", "a".repeat(129)]) expect(()=>releaseSettings({VERCEL_ENV:"production",PRIVY_APP_ID:id})).toThrow(); expect(()=>releaseSettings({VERCEL_ENV:"production",PRIVY_APP_SECRET:"never-an-app-id"})).toThrow(); diff --git a/scripts/build-release.ts b/scripts/build-release.ts index 3d9501d..1f01bf8 100644 --- a/scripts/build-release.ts +++ b/scripts/build-release.ts @@ -3,12 +3,13 @@ import { join,resolve } from "node:path"; import { buildAccountFunction,buildGameSite,currentRouting } from "./package-tidebound-review"; export function releaseSettings(env:Record){ - if(env.VERCEL_ENV!=="production")return {appId:"",clientId:"",sealedNote:false}; + if(env.VERCEL_ENV!=="production")return {appId:"",clientId:"",sealedNote:false,records:false}; const appId=env.VITE_PRIVY_APP_ID??env.PRIVY_APP_ID??"",clientId=env.VITE_PRIVY_CLIENT_ID??""; const id=/^[A-Za-z0-9_-]{1,128}$/; if(!id.test(appId)||(clientId&&!id.test(clientId)))throw Error("Production requires a valid public Privy app ID and, if supplied, a valid public client ID."); // Mochi's sealed note needs the account endpoints, so it is off unless production explicitly opts in. - return {appId,clientId,sealedNote:env.VITE_SEALED_NOTE_ENABLED==="true"}; + // Harbor records read public chain state for a signed-in player; also explicit opt-in. + return {appId,clientId,sealedNote:env.VITE_SEALED_NOTE_ENABLED==="true",records:env.VITE_RECORDS_ENABLED==="true"}; } export async function buildRelease(source:string,settings:ReturnType){ @@ -19,7 +20,7 @@ export async function buildRelease(source:string,settings:ReturnTypeid.includes("/phaser/")?"phaser":undefined}}}}); const staticReport=await copyGameStatic(overlay,site); const runtimeAssets=await copyRuntimeAssets(join(source,"web/public"),site);