mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 14:57:56 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
+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 });
|
||||
Reference in New Issue
Block a user