From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method