1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/library/lib/setup-untrusted-connection.js
2017-03-28 18:02:08 -07:00

28 lines
859 B
JavaScript

/*
IFRAME
var pageStream = new LocalMessageDuplexStream({
name: 'contentscript',
target: 'inpage',
})
SERVICEWORKER
pageStream.on('error', console.error)
var pluginPort = extension.runtime.connect({name: 'contentscript'})
var pluginStream = new PortStream(pluginPort)
pluginStream.on('error', console.error)
IFRAME --> SW
// forward communication plugin->inpage
pageStream.pipe(pluginStream).pipe(pageStream)
*/
module.exports = SetupUntrustedComunicationWithSW
function SetupUntrustedComunicationWithSW (connectionStream, readySwStream) {
pageStream.on('error', console.error)
var pluginPort = extension.runtime.connect({name: 'contentscript'})
var pluginStream = new PortStream(pluginPort)
pluginStream.on('error', console.error)
// forward communication plugin->inpage
pageStream.pipe(pluginStream).pipe(pageStream)
}