You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
All: Added methods to get secure random bytes
This commit is contained in:
@ -2,6 +2,7 @@ const { shim } = require('lib/shim.js');
|
||||
const { GeolocationReact } = require('lib/geolocation-react.js');
|
||||
const { PoorManIntervals } = require('lib/poor-man-intervals.js');
|
||||
const RNFetchBlob = require('react-native-fetch-blob').default;
|
||||
const { generateSecureRandom } = require('react-native-securerandom');
|
||||
|
||||
function shimInit() {
|
||||
shim.Geolocation = GeolocationReact;
|
||||
@ -9,6 +10,16 @@ function shimInit() {
|
||||
shim.clearInterval = PoorManIntervals.clearInterval;
|
||||
shim.sjclModule = require('lib/vendor/sjcl-rn.js');
|
||||
|
||||
shim.randomBytes = async (count) => {
|
||||
const randomBytes = await generateSecureRandom(count);
|
||||
let temp = [];
|
||||
for (let n in randomBytes) {
|
||||
if (!randomBytes.hasOwnProperty(n)) continue;
|
||||
temp.push(randomBytes[n]);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
shim.fetch = async function(url, options = null) {
|
||||
return shim.fetchWithRetry(() => {
|
||||
return shim.nativeFetch_(url, options)
|
||||
|
Reference in New Issue
Block a user