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 ObjectMultiplex = require('obj-multiplex')
|
||||||
const extension = require('extensionizer')
|
const extension = require('extensionizer')
|
||||||
const PortStream = require('extension-port-stream')
|
const PortStream = require('extension-port-stream')
|
||||||
|
const TransformStream = require('stream').Transform
|
||||||
|
|
||||||
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString()
|
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString()
|
||||||
const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n'
|
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
|
// 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
|
// script level so malicious sites can't snoop on the currently-selected address
|
||||||
pageStream._write = function (data, encoding, cb) {
|
const approvalTransform = new TransformStream({
|
||||||
if (typeof data === 'object' && data.name && data.name === 'publicConfig' && !originApproved) {
|
objectMode: true,
|
||||||
cb()
|
transform: (data, _, done) => {
|
||||||
return
|
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
|
// forward communication plugin->inpage
|
||||||
pump(
|
pump(
|
||||||
pageStream,
|
pageStream,
|
||||||
pluginStream,
|
pluginStream,
|
||||||
|
approvalTransform,
|
||||||
pageStream,
|
pageStream,
|
||||||
(err) => logStreamDisconnectWarning('MetaMask Contentscript Forwarding', err)
|
(err) => logStreamDisconnectWarning('MetaMask Contentscript Forwarding', err)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user