@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
30 lines (29 loc) • 996 B
JavaScript
const L = {
oe: function () {
if ("undefined" != typeof window && window.crypto) {
if ("function" == typeof window.crypto.randomUUID)
return window.crypto.randomUUID();
if ("function" == typeof window.crypto.getRandomValues)
try {
const n = new Uint8Array(16);
window.crypto.getRandomValues(n),
(n[6] = (15 & n[6]) | 64),
(n[8] = (63 & n[8]) | 128);
const t = Array.from(n, (n) => ("0" + n.toString(16)).slice(-2));
return [
t.slice(0, 4).join(""),
t.slice(4, 6).join(""),
t.slice(6, 8).join(""),
t.slice(8, 10).join(""),
t.slice(10, 16).join(""),
].join("-");
} catch (n) {}
}
const n = (n = !1) => {
const t = (Math.random().toString(16) + "000000000").substr(2, 8);
return n ? "-" + t.substr(0, 4) + "-" + t.substr(4, 4) : t;
};
return n() + n(!0) + n(!0) + n();
},
};
export default L;