Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@polkadot/x-randomvalues

Package Overview
Dependencies
Maintainers
2
Versions
721
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot/x-randomvalues - npm Package Compare versions

Comparing version 11.1.4-12 to 12.0.1

cjs/shim.js

1

browser.d.ts
export { packageInfo } from './packageInfo.js';
export declare const crypto: Crypto;
export declare function getRandomValues<T extends Uint8Array>(arr: T): T;

6

browser.js
import { xglobal } from '@polkadot/x-global';
export { packageInfo } from './packageInfo.js';
export const crypto = xglobal.crypto;
export function 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);
return crypto.getRandomValues(arr);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRandomValues = exports.packageInfo = void 0;
exports.getRandomValues = exports.crypto = exports.packageInfo = void 0;
const x_global_1 = require("@polkadot/x-global");
var packageInfo_js_1 = require("./packageInfo.js");
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
exports.crypto = x_global_1.xglobal.crypto;
function 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 x_global_1.xglobal.crypto.getRandomValues(arr);
return exports.crypto.getRandomValues(arr);
}
exports.getRandomValues = getRandomValues;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRandomValues = exports.packageInfo = void 0;
exports.getRandomValues = exports.crypto = exports.packageInfo = void 0;
const tslib_1 = require("tslib");
const crypto_1 = tslib_1.__importDefault(require("crypto"));
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
const x_global_1 = require("@polkadot/x-global");
var packageInfo_js_1 = require("./packageInfo.js");
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
exports.crypto = (0, x_global_1.extractGlobal)('crypto', node_crypto_1.default.webcrypto);
function getRandomValues(output) {
const bytes = crypto_1.default.randomBytes(output.length);
for (let i = 0; i < bytes.length; i++) {
output[i] = bytes[i];
}
return output;
return exports.crypto.getRandomValues(output);
}
exports.getRandomValues = getRandomValues;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageInfo = void 0;
exports.packageInfo = { name: '@polkadot/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '11.1.4-12' };
exports.packageInfo = { name: '@polkadot/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '12.0.1' };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRandomValues = exports.packageInfo = void 0;
exports.crypto = exports.getRandomValues = exports.packageInfo = void 0;
const react_native_1 = require("react-native");

@@ -17,3 +17,3 @@ const base64_1 = require("@polkadot/wasm-util/base64");

**/
function getRandomValuesNative(output) {
function getRandomValuesRn(output) {
return (0, base64_1.base64Decode)(react_native_1.NativeModules.RNGetRandomValues

@@ -23,6 +23,9 @@ ? react_native_1.NativeModules.RNGetRandomValues.getRandomBase64(output.length)

}
exports.getRandomValues = (typeof x_global_1.xglobal.crypto === 'object' && typeof x_global_1.xglobal.crypto.getRandomValues === 'function'
exports.getRandomValues = ((typeof x_global_1.xglobal.crypto === 'object' && typeof x_global_1.xglobal.crypto.getRandomValues === 'function')
? browser_js_1.getRandomValues
: (typeof x_global_1.xglobal.nativeCallSyncHook === 'undefined' || !react_native_1.NativeModules.ExpoRandom)
? fallback_js_1.insecureRandomValues
: getRandomValuesNative);
: getRandomValuesRn);
exports.crypto = (exports.getRandomValues === browser_js_1.getRandomValues
? browser_js_1.crypto
: { getRandomValues: exports.getRandomValues });
export { packageInfo } from './packageInfo.js';
export declare const crypto: Crypto;
export declare function getRandomValues<T extends Uint8Array>(output: T): T;

@@ -1,9 +0,7 @@

import crypto from 'crypto';
import nodeCrypto from 'node:crypto';
import { extractGlobal } from '@polkadot/x-global';
export { packageInfo } from './packageInfo.js';
export const crypto = /*#__PURE__*/ extractGlobal('crypto', nodeCrypto.webcrypto);
export function getRandomValues(output) {
const bytes = crypto.randomBytes(output.length);
for (let i = 0; i < bytes.length; i++) {
output[i] = bytes[i];
}
return output;
return crypto.getRandomValues(output);
}

@@ -6,3 +6,3 @@ {

"engines": {
"node": ">=14"
"node": ">=16"
},

@@ -19,3 +19,3 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-randomvalues#readme",

"type": "module",
"version": "11.1.4-12",
"version": "12.0.1",
"main": "./cjs/node.js",

@@ -77,15 +77,22 @@ "module": "./node.js",

"default": "./react-native.js"
},
"./shim.js": {
"types": "./shim.d.ts",
"require": "./cjs/shim.js",
"default": "./shim.js"
},
"./shim": {
"types": "./shim.d.ts",
"require": "./cjs/shim.js",
"default": "./shim.js"
}
},
"dependencies": {
"@polkadot/wasm-util": "^7.0.3",
"@polkadot/x-global": "11.1.4-12",
"@polkadot/x-global": "12.0.1",
"tslib": "^2.5.0"
},
"peerDependencies": {
"@polkadot/util": "11.1.4-12"
},
"denoDependencies": {
"crypto": "std@0.161.0/node/crypto.ts"
"@polkadot/util": "12.0.1",
"@polkadot/wasm-util": "*"
}
}

@@ -1,1 +0,1 @@

export const packageInfo = { name: '@polkadot/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '11.1.4-12' };
export const packageInfo = { name: '@polkadot/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '12.0.1' };

@@ -8,3 +8,6 @@ export { packageInfo } from './packageInfo.js';

**/
declare function getRandomValuesNative(output: Uint8Array): Uint8Array;
export declare const getRandomValues: typeof getRandomValuesNative;
declare function getRandomValuesRn(output: Uint8Array): Uint8Array;
export declare const getRandomValues: typeof getRandomValuesRn;
export declare const crypto: Crypto | {
getRandomValues: typeof getRandomValuesRn;
};
import { NativeModules } from 'react-native';
import { base64Decode } from '@polkadot/wasm-util/base64';
import { xglobal } from '@polkadot/x-global';
import { getRandomValues as getRandomValuesGlobal } from './browser.js';
import { crypto as cryptoBrowser, getRandomValues as getRandomValuesBrowser } from './browser.js';
import { insecureRandomValues } from './fallback.js';

@@ -13,3 +13,3 @@ export { packageInfo } from './packageInfo.js';

**/
function getRandomValuesNative(output) {
function getRandomValuesRn(output) {
return base64Decode(NativeModules.RNGetRandomValues

@@ -19,6 +19,9 @@ ? NativeModules.RNGetRandomValues.getRandomBase64(output.length)

}
export const getRandomValues = (typeof xglobal.crypto === 'object' && typeof xglobal.crypto.getRandomValues === 'function'
? getRandomValuesGlobal
export const getRandomValues = ((typeof xglobal.crypto === 'object' && typeof xglobal.crypto.getRandomValues === 'function')
? getRandomValuesBrowser
: (typeof xglobal.nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
? insecureRandomValues
: getRandomValuesNative);
: getRandomValuesRn);
export const crypto = (getRandomValues === getRandomValuesBrowser
? cryptoBrowser
: { getRandomValues });
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc