Improve privacy on the buildinfo file that might be served

This commit is contained in:
Joseph Garrone
2024-02-12 00:32:18 +01:00
parent 2790487fc7
commit 5b563d8e9b

View File

@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
import { downloadKeycloakStaticResources, type BuildOptionsLike } from "./keycloakify/generateTheme/downloadKeycloakStaticResources"; import { downloadKeycloakStaticResources, type BuildOptionsLike } from "./keycloakify/generateTheme/downloadKeycloakStaticResources";
import { join as pathJoin } from "path"; import { join as pathJoin, relative as pathRelative } from "path";
import { readBuildOptions } from "./keycloakify/buildOptions"; import { readBuildOptions } from "./keycloakify/buildOptions";
import { themeTypes, keycloak_resources, lastKeycloakVersionWithAccountV1 } from "./constants"; import { themeTypes, keycloak_resources, lastKeycloakVersionWithAccountV1 } from "./constants";
import { readThisNpmProjectVersion } from "./tools/readThisNpmProjectVersion"; import { readThisNpmProjectVersion } from "./tools/readThisNpmProjectVersion";
@ -19,6 +19,7 @@ export async function copyKeycloakResourcesToPublic(params: { processArgv: strin
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo"); const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
const { keycloakifyBuildinfoRaw } = generateKeycloakifyBuildinfoRaw({ const { keycloakifyBuildinfoRaw } = generateKeycloakifyBuildinfoRaw({
destDirPath,
"keycloakifyVersion": readThisNpmProjectVersion(), "keycloakifyVersion": readThisNpmProjectVersion(),
buildOptions buildOptions
}); });
@ -72,12 +73,13 @@ export async function copyKeycloakResourcesToPublic(params: { processArgv: strin
} }
export function generateKeycloakifyBuildinfoRaw(params: { export function generateKeycloakifyBuildinfoRaw(params: {
destDirPath: string;
keycloakifyVersion: string; keycloakifyVersion: string;
buildOptions: BuildOptionsLike & { buildOptions: BuildOptionsLike & {
loginThemeResourcesFromKeycloakVersion: string; loginThemeResourcesFromKeycloakVersion: string;
}; };
}) { }) {
const { keycloakifyVersion, buildOptions } = params; const { destDirPath, keycloakifyVersion, buildOptions } = params;
const { cacheDirPath, npmWorkspaceRootDirPath, loginThemeResourcesFromKeycloakVersion, ...rest } = buildOptions; const { cacheDirPath, npmWorkspaceRootDirPath, loginThemeResourcesFromKeycloakVersion, ...rest } = buildOptions;
@ -88,8 +90,8 @@ export function generateKeycloakifyBuildinfoRaw(params: {
keycloakifyVersion, keycloakifyVersion,
"buildOptions": { "buildOptions": {
loginThemeResourcesFromKeycloakVersion, loginThemeResourcesFromKeycloakVersion,
cacheDirPath, "cacheDirPath": pathRelative(destDirPath, cacheDirPath),
npmWorkspaceRootDirPath "npmWorkspaceRootDirPath": pathRelative(destDirPath, npmWorkspaceRootDirPath)
} }
}, },
null, null,