Align x-randomvalues with webCrypto (#1782)

* Align x-randomvalues with webCrypto

* Deno export from browser

* export * for x-ws

* export * from RN

* CHANGELOG
This commit is contained in:
Jaco
2023-04-21 10:27:30 +03:00
committed by GitHub
parent f5a3a6fd73
commit dfd07e04d4
14 changed files with 39 additions and 42 deletions
+5 -4
View File
@@ -5,9 +5,10 @@ import { xglobal } from '@polkadot/x-global';
export { packageInfo } from './packageInfo.js';
export const crypto = xglobal.crypto;
// getRandomValues needs to be called on the crypto object,
// hence the need for the wrapper function
export function getRandomValues <T extends Uint8Array> (arr: T): T {
// We use x-global here - this prevents packagers such as rollup
// confusing this with the "normal" Node.js import and stubbing it
// (and also aligns with eg. x-fetch, where x-global is used)
return xglobal.crypto.getRandomValues(arr);
return crypto.getRandomValues(arr);
}