diff --git a/lib/utils.js b/lib/utils.js index a17afff790..2ed6fb43cf 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -369,6 +369,11 @@ const utils = { * https://stackoverflow.com/a/2117523 */ uuid4: () => { + // available in: v14.17.x+ + if (crypto.randomUUID) { + return crypto.randomUUID(); + } + // legacy behavior if native UUIDs aren't available return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { const r = (Math.random() * 16) | 0; const v = c === 'x' ? r : (r & 0x3) | 0x8;