1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

Bump sw-stream and setup "untrusted and trusted comunication"

This commit is contained in:
frankiebee 2017-03-29 15:19:46 -07:00
parent 2b1a9c5ae8
commit 4cf3beda25
4 changed files with 12 additions and 6 deletions

View File

@ -9,7 +9,10 @@ const background = new SWcontroller({
const pageStream = new ParentStream() const pageStream = new ParentStream()
background.on('ready', (_) => { background.on('ready', (_) => {
// var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller)) // var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller))
let swStream = SwStream(background.controller) let swStream = SwStream({
serviceWorker: background.controller,
context: 'dapp',
})
pageStream.pipe(swStream).pipe(pageStream) pageStream.pipe(swStream).pipe(pageStream)
console.log('********************WOOP*********************') console.log('********************WOOP*********************')
}) })

View File

@ -21,7 +21,10 @@ const background = new SWcontroller({
background.on('ready', (readSw) => { background.on('ready', (readSw) => {
// var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller)) // var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller))
// startPopup(inpageProvider) // startPopup(inpageProvider)
startPopup(SwStream(background.controller)) swStream = SwStream({
serviceWorker: background.controller,
})
startPopup()
}) })
background.on('message', (messageEvent) => {debugger}) background.on('message', (messageEvent) => {debugger})
background.startWorker() background.startWorker()

View File

@ -117,11 +117,11 @@ function setupController (initState, client) {
*/ */
connectionListener.on('remote', (portStream, messageEvent) => { connectionListener.on('remote', (portStream, messageEvent) => {
console.log('REMOTE CONECTION FOUND***********') console.log('REMOTE CONECTION FOUND***********')
connectRemote(portStream, messageEvent.origin) connectRemote(portStream, messageEvent.data.context)
}) })
function connectRemote (connectionStream, originDomain) { function connectRemote (connectionStream, context) {
var isMetaMaskInternalProcess = (originDomain === 'http://localhost:9001') var isMetaMaskInternalProcess = (context !== 'dapp')
if (isMetaMaskInternalProcess) { if (isMetaMaskInternalProcess) {
// communication with popup // communication with popup
controller.setupTrustedCommunication(connectionStream, 'MetaMask') controller.setupTrustedCommunication(connectionStream, 'MetaMask')

View File

@ -103,7 +103,7 @@
"request-promise": "^4.1.1", "request-promise": "^4.1.1",
"sandwich-expando": "^1.0.5", "sandwich-expando": "^1.0.5",
"semaphore": "^1.0.5", "semaphore": "^1.0.5",
"sw-stream": "^1.0.2", "sw-stream": "^2.0.0",
"textarea-caret": "^3.0.1", "textarea-caret": "^3.0.1",
"three.js": "^0.73.2", "three.js": "^0.73.2",
"through2": "^2.0.1", "through2": "^2.0.1",