UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

22 lines (21 loc) • 861 B
//#region packages/normalization-core/src/uuid.ts let warnedWeakCrypto = false; function generateUUID(e = globalThis.crypto) { if (e && typeof e.randomUUID === "function") return e.randomUUID(); if (e && typeof e.getRandomValues === "function") { const t = /* @__PURE__ */ new Uint8Array(16); e.getRandomValues(t); const n = new DataView(t.buffer); n.setUint8(6, n.getUint8(6) & 15 | 64); n.setUint8(8, n.getUint8(8) & 63 | 128); const r = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join(""); return `${r.slice(0, 8)}-${r.slice(8, 12)}-${r.slice(12, 16)}-${r.slice(16, 20)}-${r.slice(20)}`; } if (!warnedWeakCrypto) { warnedWeakCrypto = true; console.warn("[uuid] crypto API missing; refusing insecure UUID generation"); } throw new Error("Web Crypto is required for UUID generation"); } //#endregion export { generateUUID };