diff options
author | bitpshr <mail@bitpshr.net> | 2018-10-30 02:31:06 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | ace7cfa065d701b49fb07c4e6f169e7cce545c56 (patch) | |
tree | ae5d55200570abe24c0fc8f78b8dff78ab0e52b1 /app/scripts/contentscript.js | |
parent | f35466a247e503659228f0b8e098275a875026a4 (diff) | |
download | tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.tar tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.tar.gz tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.tar.bz2 tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.tar.lz tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.tar.xz tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.tar.zst tangerine-wallet-browser-ace7cfa065d701b49fb07c4e6f169e7cce545c56.zip |
Only filter selectedAddress from publicConfig store
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r-- | app/scripts/contentscript.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index bb79e1d4a..aa06068c0 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -7,6 +7,7 @@ const PongStream = require('ping-pong-stream/pong') const ObjectMultiplex = require('obj-multiplex') const extension = require('extensionizer') const PortStream = require('extension-port-stream') +const TransformStream = require('stream').Transform const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString() const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n' @@ -58,18 +59,21 @@ function setupStreams () { // Until this origin is approved, cut-off publicConfig stream writes at the content // script level so malicious sites can't snoop on the currently-selected address - pageStream._write = function (data, encoding, cb) { - if (typeof data === 'object' && data.name && data.name === 'publicConfig' && !originApproved) { - cb() - return + const approvalTransform = new TransformStream({ + objectMode: true, + transform: (data, _, done) => { + if (typeof data === 'object' && data.name && data.name === 'publicConfig' && !originApproved) { + data.data.selectedAddress = undefined + } + done(null, { ...data }) } - LocalMessageDuplexStream.prototype._write.apply(pageStream, arguments) - } + }) // forward communication plugin->inpage pump( pageStream, pluginStream, + approvalTransform, pageStream, (err) => logStreamDisconnectWarning('MetaMask Contentscript Forwarding', err) ) |