diff --git a/grunt/config/update_json.js b/grunt/config/update_json.js index 46a5656..01382ac 100644 --- a/grunt/config/update_json.js +++ b/grunt/config/update_json.js @@ -19,7 +19,8 @@ module.exports = { 'repository': null, 'keywords': null, 'main': null, - 'dependencies': null + 'dependencies': null, + 'optionalDependencies': null } }, bower: { diff --git a/package.json b/package.json index b7686de..7ac39a2 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,9 @@ "load-grunt-config": "^0.16.0", "lodash": "^4.17.11" }, + "optionalDependencies": { + "react-native-crypto": "^2.2.0" + }, "keywords": [ "security", "crypto", diff --git a/src/core.js b/src/core.js index 8ba28ed..c4e4451 100644 --- a/src/core.js +++ b/src/core.js @@ -29,6 +29,13 @@ var CryptoJS = CryptoJS || (function (Math, undefined) { } catch (err) {} } + // React native crypto import via require (React Native) + if (!crypto && typeof require === 'function') { + try { + crypto = require('react-native-crypto'); + } catch (err) {} + } + /* * Cryptographically secure pseudorandom number generator *