mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
fix(studio): correct save failure telemetry (#3499)
This commit is contained in:
@@ -48,8 +48,18 @@ export async function studioExpectedFileVersion(
|
||||
return versions.get(path);
|
||||
}
|
||||
|
||||
function createStudioWriteToken(): string {
|
||||
return globalThis.crypto.randomUUID();
|
||||
export function createStudioWriteToken(): string {
|
||||
const webCrypto = globalThis.crypto;
|
||||
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
|
||||
if (typeof webCrypto?.getRandomValues !== "function") {
|
||||
throw new Error("Web Crypto getRandomValues is required for Studio write identity");
|
||||
}
|
||||
|
||||
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user