1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/mascara/src/proxy.js

26 lines
741 B
JavaScript
Raw Normal View History

const createParentStream = require('iframe-stream').ParentStream
2017-04-03 07:01:44 +02:00
const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
const SwStream = require('sw-stream/lib/sw-stream.js')
2017-04-03 07:01:44 +02:00
2017-10-05 08:03:47 +02:00
const intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000
const background = new SWcontroller({
fileName: '/background.js',
letBeIdle: false,
2017-04-06 21:57:02 +02:00
wakeUpInterval: 30000,
intervalDelay,
})
2017-04-06 18:58:41 +02:00
const pageStream = createParentStream()
2017-09-15 22:13:13 +02:00
background.on('ready', () => {
2017-10-05 08:03:47 +02:00
const swStream = SwStream({
serviceWorker: background.controller,
context: 'dapp',
})
pageStream.pipe(swStream).pipe(pageStream)
2017-03-30 20:28:22 +02:00
})
background.on('updatefound', () => window.location.reload())
background.on('error', console.error)
background.startWorker()