{{random-uuid}} currently uses {{Math/random}} via {{rand-int}} to generate random numbers for v4 UUIDs. This patch aims to use a cryptographically strong PRNG (pseudo random number generator) instead, if available.
The functions used are:
{{window.crypto.getRandomValues}} in most browsers
{{window.msCrypto.getRandomValues}} in IE11
* {{Math/random}} in browsers not supporting the former or if the crypto module is not made available on Node.js
Currently not used:
* {{crypto.randomBytes}} on Node.js
Google Closure doesn't seem to provide feature detection or wrappers for the crypto-APIs, so the attached patch proposal implements a shim based on feature detection.
One open question is how the Node.js {{crypto}} module can be made available, since ClojureScripts {{core.cljs}} doesn't seem to have conditional {{require}} of Node.js-modules and maybe it should be kept this way.