From 57655073f6ab4e93b9947302d46a20bd2c7288f1 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 3 Apr 2017 11:08:31 +0200 Subject: Rename mascara root directory --- mascara/server/index.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mascara/server/index.html (limited to 'mascara/server') diff --git a/mascara/server/index.html b/mascara/server/index.html new file mode 100644 index 000000000..2308dd98b --- /dev/null +++ b/mascara/server/index.html @@ -0,0 +1,20 @@ + + + + + + + MetaMask ZeroClient Iframe + + + + + + + + Hello! I am the MetaMask iframe. + + + \ No newline at end of file -- cgit v1.2.3 From 0cfad78f5decbce04a7fa56e8f80e4fcecd12a79 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 4 Apr 2017 22:45:39 -0700 Subject: mascara - rename things + break out mascara asset server --- mascara/server/index.html | 20 -------------------- mascara/server/index.js | 32 ++++++++++++++++++++++++++++++++ mascara/server/util.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 20 deletions(-) delete mode 100644 mascara/server/index.html create mode 100644 mascara/server/index.js create mode 100644 mascara/server/util.js (limited to 'mascara/server') diff --git a/mascara/server/index.html b/mascara/server/index.html deleted file mode 100644 index 2308dd98b..000000000 --- a/mascara/server/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - MetaMask ZeroClient Iframe - - - - - - - - Hello! I am the MetaMask iframe. - - - \ No newline at end of file diff --git a/mascara/server/index.js b/mascara/server/index.js new file mode 100644 index 000000000..61dc61a02 --- /dev/null +++ b/mascara/server/index.js @@ -0,0 +1,32 @@ +const express = require('express') +const createBundle = require('./util').createBundle +const serveBundle = require('./util').serveBundle + +module.exports = createMetamascaraServer + + +function createMetamascaraServer(){ + + // start bundlers + const metamascaraBundle = createBundle('./src/mascara.js') + const proxyBundle = createBundle('./src/proxy.js') + const uiBundle = createBundle('./src/popup.js') + const backgroundBuild = createBundle('./src/background.js') + + // serve bundles + const server = express() + // ui window + serveBundle(server, '/ui.js', uiBundle) + server.use(express.static(__dirname+'/../ui/')) + server.use(express.static(__dirname+'/../../dist/chrome')) + // metamascara + serveBundle(server, '/metamascara.js', metamascaraBundle) + // proxy + serveBundle(server, '/proxy/proxy.js', proxyBundle) + server.use('/proxy/', express.static(__dirname+'/../proxy')) + // background + serveBundle(server, '/background.js', backgroundBuild) + + return server + +} diff --git a/mascara/server/util.js b/mascara/server/util.js new file mode 100644 index 000000000..6e25b35d8 --- /dev/null +++ b/mascara/server/util.js @@ -0,0 +1,45 @@ +const browserify = require('browserify') +const watchify = require('watchify') + +module.exports = { + serveBundle, + createBundle, +} + + +function serveBundle(server, path, bundle){ + server.get(path, function(req, res){ + res.setHeader('Content-Type', 'application/javascript; charset=UTF-8') + res.send(bundle.latest) + }) +} + +function createBundle(entryPoint){ + + var bundleContainer = {} + + var bundler = browserify({ + entries: [entryPoint], + cache: {}, + packageCache: {}, + plugin: [watchify], + }) + + bundler.on('update', bundle) + bundle() + + return bundleContainer + + function bundle() { + bundler.bundle(function(err, result){ + if (err) { + console.log(`Bundle failed! (${entryPoint})`) + console.error(err) + return + } + console.log(`Bundle updated! (${entryPoint})`) + bundleContainer.latest = result.toString() + }) + } + +} -- cgit v1.2.3 From 1aac162b462424f5b6ce6685f337670368bd10b5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 4 Apr 2017 23:08:46 -0700 Subject: mascara - rename popup to ui --- mascara/server/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mascara/server') diff --git a/mascara/server/index.js b/mascara/server/index.js index 61dc61a02..9fd664eee 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -10,7 +10,7 @@ function createMetamascaraServer(){ // start bundlers const metamascaraBundle = createBundle('./src/mascara.js') const proxyBundle = createBundle('./src/proxy.js') - const uiBundle = createBundle('./src/popup.js') + const uiBundle = createBundle('./src/ui.js') const backgroundBuild = createBundle('./src/background.js') // serve bundles -- cgit v1.2.3 From 4b8324620e4f850b1674692cf8c45a4ca70101b4 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 5 Apr 2017 22:59:25 -0700 Subject: mascara - ready to deploy via docker --- mascara/server/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mascara/server') diff --git a/mascara/server/index.js b/mascara/server/index.js index 9fd664eee..14e3fa18e 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -8,10 +8,10 @@ module.exports = createMetamascaraServer function createMetamascaraServer(){ // start bundlers - const metamascaraBundle = createBundle('./src/mascara.js') - const proxyBundle = createBundle('./src/proxy.js') - const uiBundle = createBundle('./src/ui.js') - const backgroundBuild = createBundle('./src/background.js') + const metamascaraBundle = createBundle(__dirname + '/../src/mascara.js') + const proxyBundle = createBundle(__dirname + '/../src/proxy.js') + const uiBundle = createBundle(__dirname + '/../src/ui.js') + const backgroundBuild = createBundle(__dirname + '/../src/background.js') // serve bundles const server = express() -- cgit v1.2.3