(win)
| 320 | * @return {string} |
| 321 | */ |
| 322 | export function getRandom(win) { |
| 323 | let rand; |
| 324 | if (win.crypto && win.crypto.getRandomValues) { |
| 325 | // By default use 2 32 bit integers. |
| 326 | const uint32array = new Uint32Array(2); |
| 327 | win.crypto.getRandomValues(uint32array); |
| 328 | rand = String(uint32array[0]) + uint32array[1]; |
| 329 | } else { |
| 330 | // Fall back to Math.random. |
| 331 | rand = String(win.Math.random()).substr(2) + '0'; |
| 332 | } |
| 333 | return rand; |
| 334 | } |
| 335 | |
| 336 | /** |
| 337 | * Returns the custom base URL for 3p bootstrap iframes if it exists. |
no test coverage detected