Math.random change to cryptoObj.getRandomValues (#8)
This commit is contained in:
Родитель
14576ee0d1
Коммит
0f2f8f8f3a
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "window-post-message-proxy",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"description": "A library used in place of the native window.postMessage which when used on both the sending and receiving windows allow for a nicer asynchronouse promise messaging between the windows",
|
||||
"main": "dist/windowPostMessageProxy.js",
|
||||
"typings": "dist/windowPostMessageProxy.d.ts",
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
declare global {
|
||||
interface Window {
|
||||
msCrypto: Crypto;
|
||||
}
|
||||
}
|
||||
|
||||
interface IDeferred {
|
||||
resolve: <T>(value?: T | Promise<T>) => void;
|
||||
reject: <T>(error: T) => void;
|
||||
|
@ -85,7 +91,13 @@ export class WindowPostMessageProxy {
|
|||
* Utility to generate random sequence of characters used as tracking id for promises.
|
||||
*/
|
||||
private static createRandomString(): string {
|
||||
return (Math.random() + 1).toString(36).substring(7);
|
||||
|
||||
// window.msCrypto for IE
|
||||
var cryptoObj = window.crypto || window.msCrypto;
|
||||
var randomValueArray = new Uint32Array(1);
|
||||
cryptoObj.getRandomValues(randomValueArray);
|
||||
|
||||
return randomValueArray[0].toString(36).substring(1);
|
||||
}
|
||||
|
||||
// Private
|
||||
|
|
Загрузка…
Ссылка в новой задаче