Skip to content

Commit

Permalink
🎉 Add support for Expo SDK 41+ (#28)
Browse files Browse the repository at this point in the history
* ❌ Get rid of .expo.js extension, no longer supported in Expo SDK 41+

* 🌹 Move getRandomBase64 back into main file

Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
  • Loading branch information
brentvatne and LinusU committed Apr 12, 2021
1 parent 3afc0fa commit 358e46b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 0 additions & 8 deletions getRandomBase64.expo.js

This file was deleted.

1 change: 0 additions & 1 deletion getRandomBase64.js

This file was deleted.

16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const base64Decode = require('fast-base64-decode')
const getRandomBase64 = require('./getRandomBase64')
const { NativeModules } = require('react-native')

class TypeMismatchError extends Error {}
class QuotaExceededError extends Error {}
Expand All @@ -19,6 +19,20 @@ function insecureRandomValues (array) {
return array
}

/**
* @param {number} byteLength
* @returns {string}
*/
function getRandomBase64 (byteLength) {
if (NativeModules.RNGetRandomValues) {
return NativeModules.RNGetRandomValues.getRandomBase64(byteLength)
} else if (NativeModules.ExpoRandom) {
return NativeModules.ExpoRandom.getRandomBase64String(byteLength)
} else {
throw new Error('Native module not found')
}
}

/**
* @param {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Uint8ClampedArray} array
*/
Expand Down

0 comments on commit 358e46b

Please sign in to comment.