@polkadot/x-randomvalues
Advanced tools
Comparing version 11.1.4-12 to 12.0.1
export { packageInfo } from './packageInfo.js'; | ||
export declare const crypto: Crypto; | ||
export declare function getRandomValues<T extends Uint8Array>(arr: T): T; |
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; |
10
node.js
@@ -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 }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
20742
22
164
0
+ Added@polkadot/util@12.0.1(transitive)
+ Added@polkadot/x-bigint@12.0.1(transitive)
+ Added@polkadot/x-global@12.0.1(transitive)
+ Added@polkadot/x-textdecoder@12.0.1(transitive)
+ Added@polkadot/x-textencoder@12.0.1(transitive)
- Removed@polkadot/wasm-util@^7.0.3
- Removed@polkadot/util@11.1.4-1213.2.3(transitive)
- Removed@polkadot/x-bigint@11.1.4-1213.2.3(transitive)
- Removed@polkadot/x-global@11.1.4-1213.2.3(transitive)
- Removed@polkadot/x-textdecoder@11.1.4-1213.2.3(transitive)
- Removed@polkadot/x-textencoder@11.1.4-1213.2.3(transitive)
Updated@polkadot/x-global@12.0.1