Use x-global inside x-randomvalues (#1354)

* Use x-global inside x-randomvalues

* CHANGELOG
This commit is contained in:
Jaco
2022-01-04 11:05:03 +02:00
committed by GitHub
parent 6fa855b6fc
commit e38562e8dc
3 changed files with 15 additions and 5 deletions
+6 -1
View File
@@ -1,8 +1,13 @@
// Copyright 2017-2022 @polkadot/x-randomvalues authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { xglobal } from '@polkadot/x-global';
export { packageInfo } from './packageInfo';
export function getRandomValues <T extends Uint8Array> (arr: T): T {
return crypto.getRandomValues(arr);
// 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);
}