Use x-global inside x-randomvalues (#1354)
* Use x-global inside x-randomvalues * CHANGELOG
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user