Rename and move around files

feature/default_network_editable
frankiebee 8 years ago
parent 29a602a89b
commit 8d49d519c0
  1. 27
      library/lib/setup-untrusted-connection.js
  2. 9
      library/server.js
  3. 16
      library/src/background.js
  4. 4
      library/src/dapp-connection.js
  5. 0
      library/src/lib/index-db-controller.js
  6. 0
      library/src/lib/setup-iframe.js
  7. 2
      library/src/lib/setup-provider.js
  8. 0
      library/src/mascara.js
  9. 8
      library/src/popup.js
  10. 64
      library/sw-controller.js
  11. 1
      package.json

@ -1,27 +0,0 @@
/*
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)
}

@ -3,11 +3,12 @@ const browserify = require('browserify')
const watchify = require('watchify') const watchify = require('watchify')
const babelify = require('babelify') const babelify = require('babelify')
const zeroBundle = createBundle('./index.js') const zeroBundle = createBundle('./src/mascara.js')
const controllerBundle = createBundle('./controller.js') const controllerBundle = createBundle('./src/dapp-connection.js')
const popupBundle = createBundle('./popup.js') const popupBundle = createBundle('./src/popup.js')
const swBuild = createBundle('./src/background.js')
const appBundle = createBundle('./example/index.js') const appBundle = createBundle('./example/index.js')
const swBuild = createBundle('./sw-core.js')
// //
// Iframe Server // Iframe Server

@ -4,18 +4,18 @@ const pipe = require('pump')
const SwGlobalListener = require('sw-stream/lib/sw-global-listener.js') const SwGlobalListener = require('sw-stream/lib/sw-global-listener.js')
const connectionListener = new SwGlobalListener(self) const connectionListener = new SwGlobalListener(self)
const setupMultiplex = require('../app/scripts/lib/stream-utils.js').setupMultiplex const setupMultiplex = require('../../app/scripts/lib/stream-utils.js').setupMultiplex
const PortStream = require('../app/scripts/lib/port-stream.js') const PortStream = require('../../app/scripts/lib/port-stream.js')
const DbController = require('./controllers/index-db-controller') const DbController = require('./lib/index-db-controller')
const MetamaskController = require('../app/scripts/metamask-controller') const MetamaskController = require('../../app/scripts/metamask-controller')
const extension = {} //require('../app/scripts/lib/extension') const extension = {} //require('../../app/scripts/lib/extension')
const storeTransform = require('obs-store/lib/transform') const storeTransform = require('obs-store/lib/transform')
const Migrator = require('../app/scripts/lib/migrator/') const Migrator = require('../../app/scripts/lib/migrator/')
const migrations = require('../app/scripts/migrations/') const migrations = require('../../app/scripts/migrations/')
const firstTimeState = require('../app/scripts/first-time-state') const firstTimeState = require('../../app/scripts/first-time-state')
const STORAGE_KEY = 'metamask-config' const STORAGE_KEY = 'metamask-config'
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'

@ -1,14 +1,14 @@
const ParentStream = require('iframe-stream').ParentStream const ParentStream = require('iframe-stream').ParentStream
const SWcontroller = require('./sw-controller') const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
const SwStream = require('sw-stream/lib/sw-stream.js') const SwStream = require('sw-stream/lib/sw-stream.js')
const SetupUntrustedComunication = ('./lib/setup-untrusted-connection.js') const SetupUntrustedComunication = ('./lib/setup-untrusted-connection.js')
const background = new SWcontroller({ const background = new SWcontroller({
fileName: '/popup/sw-build.js', fileName: '/popup/sw-build.js',
}) })
const pageStream = new ParentStream() const pageStream = new ParentStream()
background.on('ready', (_) => { background.on('ready', (_) => {
// var inpageProvider = new MetamaskInpageProvider(SwStream(background.controller))
let swStream = SwStream({ let swStream = SwStream({
serviceWorker: background.controller, serviceWorker: background.controller,
context: 'dapp', context: 'dapp',

@ -1,5 +1,5 @@
const setupIframe = require('./setup-iframe.js') const setupIframe = require('./setup-iframe.js')
const MetamaskInpageProvider = require('../../app/scripts/lib/inpage-provider.js') const MetamaskInpageProvider = require('../../../app/scripts/lib/inpage-provider.js')
module.exports = getProvider module.exports = getProvider

@ -1,10 +1,10 @@
const injectCss = require('inject-css') const injectCss = require('inject-css')
const MetaMaskUiCss = require('../ui/css') const MetaMaskUiCss = require('../../ui/css')
const setupIframe = require('./lib/setup-iframe.js') const setupIframe = require('./lib/setup-iframe.js')
const MetamaskInpageProvider = require('../app/scripts/lib/inpage-provider.js') const MetamaskInpageProvider = require('../../app/scripts/lib/inpage-provider.js')
const SWcontroller = require('./sw-controller') const SWcontroller = require('client-sw-ready-event/lib/sw-client.js')
const SwStream = require('sw-stream/lib/sw-stream.js') const SwStream = require('sw-stream/lib/sw-stream.js')
const startPopup = require('../app/scripts/popup-core') const startPopup = require('../../app/scripts/popup-core')
var css = MetaMaskUiCss() var css = MetaMaskUiCss()

@ -1,64 +0,0 @@
const EventEmitter = require('events')
module.exports = class ClientSideServiceWorker extends EventEmitter{
constructor (opts) {
super()
this.fileName = opts.fileName
this.startDelay = opts.startDelay
this.serviceWorkerApi = navigator.serviceWorker
this.serviceWorkerApi.onmessage = (messageEvent) => this.emit('message', messageEvent)
this.serviceWorkerApi.onerror = (err) => this.emit('error', err)
this.on('message', (messageEvent) => {debugger})
if (opts.initStart) this.startWorker()
}
get controller () {
return this.sw || this.serviceWorkerApi.controller
}
startWorker () {
return this.registerWorker()
.then((sw) => {
this.sw = sw
this.sw.onerror = (err) => this.emit('error', err)
this.sw = sw
this.emit('ready', this.sw)
})
.catch((err) => this.emit('error', err))
}
registerWorker () {
return this.serviceWorkerApi.register(this.fileName)
.then((registerdWorker) => {
return new Promise((resolve, reject) => {
let timeOutId = setTimeout(() => {
if (this.serviceWorkerApi.controller) return resolve(this.serviceWorkerApi.controller)
if (registerdWorker.active) return resolve(registerdWorker.active)
return reject(new Error('ClientSideServiceWorker: No controller found and onupdatefound timed out'))
}, this.startDelay || 1000 )
registerdWorker.onupdatefound = (event) => {
this.emit('updatefound')
registerdWorker.update()
}
})
})
}
sendMessage (message) {
const self = this
return new Promise((resolve, reject) => {
var messageChannel = new MessageChannel()
messageChannel.port1.onmessage = (event) => {
if (event.data.err) {
reject(event.data.error)
} else {
resolve(event.data.data)
}
}
this.controller.postMessage(message, [messageChannel.port2])
})
}
}

@ -42,6 +42,7 @@
"bip39": "^2.2.0", "bip39": "^2.2.0",
"browser-passworder": "^2.0.3", "browser-passworder": "^2.0.3",
"browserify-derequire": "^0.9.4", "browserify-derequire": "^0.9.4",
"client-sw-ready-event": "^1.0.2",
"clone": "^1.0.2", "clone": "^1.0.2",
"copy-to-clipboard": "^2.0.0", "copy-to-clipboard": "^2.0.0",
"debounce": "^1.0.0", "debounce": "^1.0.0",

Loading…
Cancel
Save