UNPKG

@lynker-desktop/electron-ipc

Version:

electron-ipc

27 lines (24 loc) 788 B
const md5 = require('md5'); const uuid = require('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$1 = uuid.v5(`${JSON.stringify(key)}_${Date.now()}_${randomValue}`, uuid.v5.URL); return uuid$1; }; exports.WINDOWL_GLOBAL_KEY = WINDOWL_GLOBAL_KEY; exports.getRandomUUID = getRandomUUID; //# sourceMappingURL=index.js.map