mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 06:47:57 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
export declare const crypto: Crypto;
|
||||
export declare function getRandomValues<T extends Uint8Array>(arr: T): T;
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.crypto = exports.packageInfo = void 0;
|
||||
exports.getRandomValues = getRandomValues;
|
||||
const x_global_1 = require("@pezkuwi/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) {
|
||||
return exports.crypto.getRandomValues(arr);
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare function insecureRandomValues<T extends Uint8Array>(arr: T): T;
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.insecureRandomValues = insecureRandomValues;
|
||||
let warned = false;
|
||||
function insecureRandomValues(arr) {
|
||||
if (!warned) {
|
||||
console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto');
|
||||
warned = true;
|
||||
}
|
||||
let r = 0;
|
||||
for (let i = 0, count = arr.length; i < count; i++) {
|
||||
if ((i & 0b11) === 0) {
|
||||
r = Math.random() * 0x100000000;
|
||||
}
|
||||
arr[i] = (r >>> ((i & 0b11) << 3)) & 0xff;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
export declare const crypto: Crypto;
|
||||
export declare function getRandomValues<T extends Uint8Array>(output: T): T;
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.crypto = exports.packageInfo = void 0;
|
||||
exports.getRandomValues = getRandomValues;
|
||||
const tslib_1 = require("tslib");
|
||||
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
||||
const x_global_1 = require("@pezkuwi/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) {
|
||||
return exports.crypto.getRandomValues(output);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export declare const packageInfo: {
|
||||
name: string;
|
||||
path: string;
|
||||
type: string;
|
||||
version: string;
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.packageInfo = void 0;
|
||||
exports.packageInfo = { name: '@pezkuwi/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.10' };
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* A getRandomValues util that detects and uses the available RN
|
||||
* random utiliy generation functions.
|
||||
**/
|
||||
declare function getRandomValuesRn(output: Uint8Array): Uint8Array;
|
||||
export declare const getRandomValues: typeof getRandomValuesRn;
|
||||
export declare const crypto: Crypto | {
|
||||
getRandomValues: typeof getRandomValuesRn;
|
||||
};
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.crypto = exports.getRandomValues = exports.packageInfo = void 0;
|
||||
const react_native_1 = require("react-native");
|
||||
const base64_1 = require("@pezkuwi/wasm-util/base64");
|
||||
const x_global_1 = require("@pezkuwi/x-global");
|
||||
const browser_js_1 = require("./browser.js");
|
||||
var packageInfo_js_1 = require("./packageInfo.js");
|
||||
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* A getRandomValues util that detects and uses the available RN
|
||||
* random utiliy generation functions.
|
||||
**/
|
||||
function getRandomValuesRn(output) {
|
||||
if (!react_native_1.NativeModules['ExpoRandom'] && !react_native_1.NativeModules.RNGetRandomValues) {
|
||||
throw new Error('No secure random number generator available. This environment does not support crypto.getRandomValues and no React Native secure RNG module is available.');
|
||||
}
|
||||
return (0, base64_1.base64Decode)(react_native_1.NativeModules.RNGetRandomValues
|
||||
? react_native_1.NativeModules.RNGetRandomValues.getRandomBase64(output.length)
|
||||
: react_native_1.NativeModules.ExpoRandom.getRandomBase64String(output.length), output);
|
||||
}
|
||||
const hasNativeRNModules = !!react_native_1.NativeModules['ExpoRandom'] || !!react_native_1.NativeModules.RNGetRandomValues;
|
||||
const hasNativeCrypto = typeof x_global_1.xglobal.crypto === 'object' && typeof x_global_1.xglobal.crypto.getRandomValues === 'function';
|
||||
exports.getRandomValues = (hasNativeRNModules
|
||||
? getRandomValuesRn
|
||||
: hasNativeCrypto
|
||||
? browser_js_1.getRandomValues
|
||||
: () => {
|
||||
throw new Error('No secure random number generator available. This environment does not support crypto.getRandomValues.');
|
||||
});
|
||||
exports.crypto = (exports.getRandomValues === browser_js_1.getRandomValues
|
||||
? browser_js_1.crypto
|
||||
: { getRandomValues: exports.getRandomValues });
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const x_global_1 = require("@pezkuwi/x-global");
|
||||
const x_randomvalues_1 = require("@pezkuwi/x-randomvalues");
|
||||
(0, x_global_1.exposeGlobal)('crypto', x_randomvalues_1.crypto);
|
||||
Reference in New Issue
Block a user