How UUID v4 Generation Works
UUID v4 is just 122 random bits plus 6 bits of versioning/variant metadata, formatted as 32 hex characters in five hyphen-separated groups: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where the third group always starts with 4 (the version) and the fourth group starts with 8, 9, a, or b (the variant). The randomness comes from crypto.getRandomValues(), which on every modern browser/OS uses a CSPRNG seeded from hardware sources (RDRAND, /dev/urandom, etc.). This is exactly the same entropy source used for TLS session keys and password hashing.