1
0
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:
Laurent Cozic
2017-12-12 17:51:07 +00:00
parent 8a282fd2e1
commit 92b857d83b
11 changed files with 49 additions and 798 deletions

View File

@ -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)