crypto.getRandomValues, which draws from the operating system’s cryptographically secure source. Nothing here uses Math.random, which is predictable and must never be used for anything security-related.
Picking a length
Security depends on entropy, which is length combined with charset size. As a rough guide:
For a webhook signing secret or an API token, 32 alphanumeric characters is a comfortable default.