mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Only filter selectedAddress from publicConfig store
This commit is contained in:
parent
f35466a247
commit
ace7cfa065
@ -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) {
|
||||
const approvalTransform = new TransformStream({
|
||||
objectMode: true,
|
||||
transform: (data, _, done) => {
|
||||
if (typeof data === 'object' && data.name && data.name === 'publicConfig' && !originApproved) {
|
||||
cb()
|
||||
return
|
||||
data.data.selectedAddress = undefined
|
||||
}
|
||||
LocalMessageDuplexStream.prototype._write.apply(pageStream, arguments)
|
||||
done(null, { ...data })
|
||||
}
|
||||
})
|
||||
|
||||
// forward communication plugin->inpage
|
||||
pump(
|
||||
pageStream,
|
||||
pluginStream,
|
||||
approvalTransform,
|
||||
pageStream,
|
||||
(err) => logStreamDisconnectWarning('MetaMask Contentscript Forwarding', err)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user