보안 문맥이 아닌 http + IP 에서는 crypto.randomUUID 가 없어 CAD 개체 만들기에서 멈춤. 앱 본체(A00_Common/main.ts)와 CAD(openwebcad/src/main.tsx) 진입 맨 앞에서 getRandomValues 로 v4 UUID 를 채움 · 이미 있으면 그대로. crypto.subtle(B03 지문) · serviceWorker(B03) 는 이미 없을 때 건너뜀 · navigator.clipboard 는 안 씀. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K7JS47SacjPxZ718QsZKyr
17 lines
845 B
TypeScript
17 lines
845 B
TypeScript
/**
|
|
* http + IP 주소(예: Tailscale)는 보안 문맥이 아니라 `crypto.randomUUID` 가 없음.
|
|
* getRandomValues(보안 문맥 아니어도 됨)로 v4 UUID 를 채움 · 이미 있으면 그대로.
|
|
* `main.ts` 가 맨 먼저 부름. CAD 짝 = `B07_DesignDetail/openwebcad/src/random-uuid-polyfill.ts`.
|
|
*/
|
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID !== "function") {
|
|
crypto.randomUUID = () => {
|
|
const bytes = crypto.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)}` as `${string}-${string}-${string}-${string}-${string}`;
|
|
};
|
|
}
|
|
|
|
export {};
|