diff --git a/index.ios.js b/index.ios.js index a62de4618..851a2d7c2 100644 --- a/index.ios.js +++ b/index.ios.js @@ -6,7 +6,6 @@ import './shim'; import App from './app/components/App'; global.platform = 'ios'; -global.DOMPurify = require('dompurify'); const nicebear = () => ( diff --git a/package.json b/package.json index 1adca8c19..19e313498 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "3.133.0", "private": true, "scripts": { - "postinstall": "sh scripts/setup-env.sh && npm run icebear:compile && rn-nodeify --install 'crypto, stream, process, events, vm' --hack && bash scripts/setup-rn-debugging.sh && bash scripts/copy-android-resources.sh && bash scripts/android-switch-to-rn-fork.sh", + "postinstall": "sh scripts/setup-env.sh && npm run icebear:compile && bash scripts/setup-rn-debugging.sh && bash scripts/copy-android-resources.sh && bash scripts/android-switch-to-rn-fork.sh", "commit": "git-cz", "code:packager": "./node_modules/react-native/packager/packager.sh --reset-cache", - "icebear:compile": "babel node_modules/@peerio/peerio-icebear/src -d app/lib/peerio-icebear", + "icebear:compile": "babel node_modules/@peerio/peerio-icebear/src -d app/lib/peerio-icebear && bash ./scripts/remove-require-crypto.sh", "icebear:watch": "npm run icebear:compile -- -w", "start": "source env.sh && npm-run-all -l -p icebear:watch code:packager", "expandoo": "source env-expandoo.sh && ./node_modules/react-native/packager/packager.sh --reset-cache", @@ -41,7 +41,6 @@ "bluebird": "3.5.0", "buffer": "5.0.6", "capitalize": "^1.0.0", - "dompurify": "^0.9.0", "eventemitter3": "2.0.3", "events": "1.1.1", "file-loader": "0.9.0", @@ -70,7 +69,6 @@ "react-native-billing": "2.3.0", "react-native-cli": "2.0.1", "react-native-contacts": "git+https://github.com/PeerioTechnologies/react-native-contacts.git", - "react-native-crypto": "2.0.1", "react-native-device-info": "git+https://github.com/PeerioTechnologies/react-native-device-info.git", "react-native-file-opener": "git+https://github.com/PeerioTechnologies/react-native-file-opener.git", "react-native-file-picker": "0.0.8", @@ -91,13 +89,9 @@ "react-native-sound": "0.9.0", "react-native-sqlcipher-storage": "git+ssh://git@github.com/PeerioTechnologies/react-native-sqlcipher-storage.git", "react-native-vector-icons": "4.0.0", - "readable-stream": "1.0.33", - "rn-workers": "git+https://github.com/PeerioTechnologies/react-native-workers.git", "scrypt-async": "1.3.1", "socket.io-client": "^2.0.3", - "stream-browserify": "1.0.0", - "tweetnacl": "1.0.0", - "vm-browserify": "0.0.4" + "tweetnacl": "1.0.0" }, "devDependencies": { "appium": "1.6.5", @@ -121,7 +115,6 @@ "npm-run-all": "^4.0.2", "opt-cli": "^1.5.2", "repeating-cli": "^2.0.0", - "rn-nodeify": "github:mvayngrib/rn-nodeify", "semantic-release": "6.3.2", "sinon": "^1.17.7", "sinon-chai": "^2.13.0", @@ -151,26 +144,6 @@ "helpMessage": "Convention: https://goo.gl/3TgTsh" } }, - "react-native": { - "crypto": "react-native-crypto", - "_stream_transform": "readable-stream/transform", - "_stream_readable": "readable-stream/readable", - "_stream_writable": "readable-stream/writable", - "_stream_duplex": "readable-stream/duplex", - "_stream_passthrough": "readable-stream/passthrough", - "stream": "stream-browserify", - "vm": "vm-browserify" - }, - "browser": { - "crypto": "react-native-crypto", - "_stream_transform": "readable-stream/transform", - "_stream_readable": "readable-stream/readable", - "_stream_writable": "readable-stream/writable", - "_stream_duplex": "readable-stream/duplex", - "_stream_passthrough": "readable-stream/passthrough", - "stream": "stream-browserify", - "vm": "vm-browserify" - }, "standard-version": { "skip": { "changelog": true diff --git a/scripts/remove-require-crypto.sh b/scripts/remove-require-crypto.sh new file mode 100755 index 000000000..0aa3ed97b --- /dev/null +++ b/scripts/remove-require-crypto.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Removing require('crypto') references" +perl -pi -e 's/require\(.crypto.\)/null/g' app/lib/peerio-icebear/crypto/util.random.js +perl -pi -e 's/require\(.crypto.\)/null/g' node_modules/sjcl/sjcl.js diff --git a/shim.js b/shim.js index 2b8126d46..0012321a7 100644 --- a/shim.js +++ b/shim.js @@ -45,10 +45,9 @@ global.WebSocket = function(url) { return r; }; -const cryptoShim = require('react-native-crypto'); -global.cryptoShim = cryptoShim; +const { randomBytes } = require('react-native-randombytes'); +global.cryptoShim = { randomBytes }; -const randomBytes = cryptoShim.randomBytes; console.log(`shim.js: checking randomBytes`); console.log(randomBytes(8)); @@ -177,4 +176,4 @@ if (!String.fromCodePoint) { String.fromCodePoint = fromCodePoint; } }()); -} \ No newline at end of file +}