fix(server): obfuscated deployment id in build id (#1168)

Co-authored-by: John Pope <88814278+innovatedev-john-pope@users.noreply.github.com>

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
This commit is contained in:
Luca Casonato
2023-05-13 11:09:21 +02:00
committed by GitHub
co-authored by John Pope Yoshiya Hinosawa
parent abe12a12f8
commit 6feac0d2d8
2 changed files with 10 additions and 2 deletions
+9 -2
View File
@@ -1,12 +1,19 @@
import { INTERNAL_PREFIX } from "../runtime/utils.ts";
import { toHashString } from "./deps.ts";
export const REFRESH_JS_URL = `${INTERNAL_PREFIX}/refresh.js`;
export const ALIVE_URL = `${INTERNAL_PREFIX}/alive`;
export const BUILD_ID = Deno.env.get("DENO_DEPLOYMENT_ID") ||
crypto.randomUUID();
export const JS_PREFIX = `/js`;
export const DEBUG = !Deno.env.get("DENO_DEPLOYMENT_ID");
const deploymentId = Deno.env.get("DENO_DEPLOYMENT_ID") ||
crypto.randomUUID();
const buildIdHash = await crypto.subtle.digest(
"SHA-1",
new TextEncoder().encode(deploymentId),
);
export const BUILD_ID = toHashString(buildIdHash, "hex");
export function bundleAssetUrl(path: string) {
return `${INTERNAL_PREFIX}${JS_PREFIX}/${BUILD_ID}${path}`;
}