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:
co-authored by
John Pope
Yoshiya Hinosawa
parent
abe12a12f8
commit
6feac0d2d8
@@ -1,12 +1,19 @@
|
|||||||
import { INTERNAL_PREFIX } from "../runtime/utils.ts";
|
import { INTERNAL_PREFIX } from "../runtime/utils.ts";
|
||||||
|
import { toHashString } from "./deps.ts";
|
||||||
|
|
||||||
export const REFRESH_JS_URL = `${INTERNAL_PREFIX}/refresh.js`;
|
export const REFRESH_JS_URL = `${INTERNAL_PREFIX}/refresh.js`;
|
||||||
export const ALIVE_URL = `${INTERNAL_PREFIX}/alive`;
|
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 JS_PREFIX = `/js`;
|
||||||
export const DEBUG = !Deno.env.get("DENO_DEPLOYMENT_ID");
|
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) {
|
export function bundleAssetUrl(path: string) {
|
||||||
return `${INTERNAL_PREFIX}${JS_PREFIX}/${BUILD_ID}${path}`;
|
return `${INTERNAL_PREFIX}${JS_PREFIX}/${BUILD_ID}${path}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export { Status } from "https://deno.land/std@0.178.0/http/http_status.ts";
|
|||||||
export {
|
export {
|
||||||
typeByExtension,
|
typeByExtension,
|
||||||
} from "https://deno.land/std@0.178.0/media_types/mod.ts";
|
} from "https://deno.land/std@0.178.0/media_types/mod.ts";
|
||||||
|
export { toHashString } from "https://deno.land/std@0.178.0/crypto/to_hash_string.ts";
|
||||||
|
|
||||||
// -- esbuild --
|
// -- esbuild --
|
||||||
// @deno-types="https://deno.land/x/esbuild@v0.17.11/mod.d.ts"
|
// @deno-types="https://deno.land/x/esbuild@v0.17.11/mod.d.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user