@lynker-desktop/electron-ipc
Version:
electron-ipc
26 lines (23 loc) • 724 B
JavaScript
import md5 from 'md5';
import { v5 } from 'uuid';
const WINDOWL_GLOBAL_KEY = `__ELECTRON_IPC__`;
const getRandomUUID = (key = `${Date.now()}`) => {
let webcrypto;
let randomValue = Math?.random()?.toString()?.replace('0.', '');
try {
if (!webcrypto && !!window && window?.crypto) {
webcrypto = window.crypto;
}
}
catch (error) {
}
try {
const ar = webcrypto.getRandomValues(new Uint8Array(12));
randomValue = `${md5(ar)}` || randomValue;
}
catch (error) { }
const uuid = v5(`${JSON.stringify(key)}_${Date.now()}_${randomValue}`, v5.URL);
return uuid;
};
export { WINDOWL_GLOBAL_KEY, getRandomUUID };
//# sourceMappingURL=index.js.map