From 39a63cd16e372f132b14a1e10786dca9fb0696bc Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 5 Jun 2017 15:35:36 -0700 Subject: [PATCH 1/6] currently not working, decryption seems to fail --- frontend/src/fileReceiver.js | 5 +- package.json | 2 + server/config.js | 16 ++++ server/portal_server.js | 144 +++++++++++++++++++++++------------ 4 files changed, 119 insertions(+), 48 deletions(-) create mode 100644 server/config.js diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js index c030fb71..81311648 100644 --- a/frontend/src/fileReceiver.js +++ b/frontend/src/fileReceiver.js @@ -5,6 +5,7 @@ class FileReceiver extends EventEmitter { constructor() { super(); this.salt = strToIv(location.pathname.slice(10, -1)); + window.salt = this.salt; } download() { @@ -30,11 +31,13 @@ class FileReceiver extends EventEmitter { let blob = new Blob([this.response]); let fileReader = new FileReader(); fileReader.onload = function() { + window.data = this.result; + console.log(this.result); resolve({ data: this.result, fname: xhr .getResponseHeader('Content-Disposition') - .match(/filename="(.+)"/)[1] + .match(/="(.+)"/)[1] }); }; diff --git a/package.json b/package.json index 462d07fb..229f13e7 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,10 @@ "version": "1.0.0", "author": "Mozilla (https://mozilla.org)", "dependencies": { + "aws-sdk": "^2.62.0", "body-parser": "^1.17.2", "connect-busboy": "0.0.2", + "convict": "^3.0.0", "express": "^4.15.3", "fs-extra": "^3.0.1", "path": "^0.12.7", diff --git a/server/config.js b/server/config.js new file mode 100644 index 00000000..43860f77 --- /dev/null +++ b/server/config.js @@ -0,0 +1,16 @@ +const convict = require('convict'); + +let conf = convict({ + aws_credentials: { + region: 'us-west-2', + bucketName: 'testpilot-p2p' + } +}) + +// var env = conf.get('env'); +// conf.loadFile('./config/' + env + '.json'); + +// Perform validation +conf.validate({allowed: 'strict'}); + +module.exports = conf; \ No newline at end of file diff --git a/server/portal_server.js b/server/portal_server.js index 3d518ec4..c1577fd7 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -1,15 +1,24 @@ -const express = require('express'); -const busboy = require('connect-busboy'); -const path = require('path'); -const fs = require('fs-extra'); -const bodyParser = require('body-parser'); -const crypto = require('crypto'); +const express = require("express") +const busboy = require("connect-busboy"); +const path = require("path"); +const fs = require("fs-extra"); +const bodyParser = require("body-parser"); +const crypto = require("crypto"); +const conf = require('./config.js'); +const stream = require('stream'); -const app = express(); -const redis = require('redis'), - client = redis.createClient(); +let aws_credentials = conf.get('aws_credentials'); -client.on('error', err => { +const AWS = require('aws-sdk'); +AWS.config.loadFromPath('../../.aws/credentials'); +const s3 = new AWS.S3(); + + +const app = express() +const redis = require("redis"), + redis_client = redis.createClient(); + +redis_client.on("error", (err) => { console.log(err); }); @@ -28,22 +37,36 @@ app.get('/assets/download/:id', (req, res) => { return; } - client.hget(id, 'filename', (err, reply) => { - // maybe some expiration logic too - if (!reply) { - res.sendStatus(404); - } else { - res.setHeader('Content-Disposition', 'attachment; filename=' + reply); - res.setHeader('Content-Type', 'application/octet-stream'); + let params = { + Bucket: aws_credentials.bucketName, + Key: req.params.id + } - res.download(__dirname + '/../static/' + id, reply, err => { - if (!err) { - client.del(id); - fs.unlinkSync(__dirname + '/../static/' + id); - } - }); + s3.getObject(params, function(err, data) { + if (err) { + console.log(err, err.stack); // an error occurred } - }); + else { + res.writeHead(200, {"Content-Disposition": "attachment; filename=response", //+ reply, + "Content-Type": "application/octet-stream"}); + // res.setHeader("Content-Type", "application/octet-stream"); + res.end(new Buffer(data.Body)) + } + }) + + // redis_client.hget(id, "filename", (err, reply) => { // maybe some expiration logic too + // if (!reply) { + // res.sendStatus(404); + // } else { + + // res.download(__dirname + "/../static/" + id, reply, (err) => { + // if (!err) { + // redis_client.del(id); + // fs.unlinkSync(__dirname + "/../static/" + id); + // } + // }); + // } + // }) }); app.post('/delete/:id', (req, res) => { @@ -60,45 +83,72 @@ app.post('/delete/:id', (req, res) => { res.sendStatus(404); } +<<<<<<< HEAD client.hget(id, 'delete', (err, reply) => { if (!reply) { res.sendStatus(404); } else { client.del(id); fs.unlinkSync(__dirname + '/../static/' + id); +======= + redis_client.hget(id, "delete", (err, reply) => { + if (!reply) { + res.sendStatus(404); + } else { + redis_client.del(id); + fs.unlinkSync(__dirname + "/../static/" + id); +>>>>>>> currently not working, decryption seems to fail res.sendStatus(200); } }); }); -app.post('/upload/:id', (req, res, next) => { - if (!validateID(req.params.id)) { - res.send(404); - return; - } +app.post("/upload/:id", (req, res, next) => { - let fstream; - req.pipe(req.busboy); - req.busboy.on('file', (fieldname, file, filename) => { - console.log('Uploading: ' + filename); + if (!validateID(req.params.id)){ + res.send(404); + return; + } - //Path where image will be uploaded - fstream = fs.createWriteStream(__dirname + '/../static/' + req.params.id); - file.pipe(fstream); - fstream.on('close', () => { - let id = req.params.id; - let uuid = crypto.randomBytes(10).toString('hex'); + let fstream; + req.pipe(req.busboy); + req.busboy.on("file", (fieldname, file, filename) => { + console.log("Uploading: " + filename); - client.hmset([id, 'filename', filename, 'delete', uuid]); - // delete the file off the server in 24 hours - // setTimeout(() => { - // fs.unlinkSync(__dirname + "/static/" + id); - // }, 86400000); + let params = { + Bucket: aws_credentials.bucketName, + Key: req.params.id, + Body: file + } - client.expire(id, 86400000); - console.log('Upload Finished of ' + filename); - res.send(uuid); + s3.upload(params, function(err, data) { + if (err) { + console.log(err, err.stack); // an error occurred + } else { + console.log(data); + } + }) + + return; + + fstream = fs.createWriteStream(__dirname + "/../static/" + req.params.id); + file.pipe(fstream); + fstream.on("close", () => { + let id = req.params.id; + let uuid = crypto.randomBytes(10).toString('hex'); + + redis_client.hmset([id, "filename", filename, "delete", uuid]); + + // delete the file off the server in 24 hours + // setTimeout(() => { + // fs.unlinkSync(__dirname + "/static/" + id); + // }, 86400000); + + redis_client.expire(id, 86400000); + console.log("Upload Finished of " + filename); + res.send(uuid); + }); }); }); }); From f377aa45519135bc04962611fe0291ac6cf9fb83 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Tue, 6 Jun 2017 10:23:37 -0700 Subject: [PATCH 2/6] working s3 integration --- frontend/src/fileReceiver.js | 2 +- server/portal_server.js | 108 +++++++++++++++++------------------ 2 files changed, 54 insertions(+), 56 deletions(-) diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js index 81311648..14a539ea 100644 --- a/frontend/src/fileReceiver.js +++ b/frontend/src/fileReceiver.js @@ -37,7 +37,7 @@ class FileReceiver extends EventEmitter { data: this.result, fname: xhr .getResponseHeader('Content-Disposition') - .match(/="(.+)"/)[1] + .match(/=(.+)/)[1] }); }; diff --git a/server/portal_server.js b/server/portal_server.js index c1577fd7..ca1a1bbf 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -37,36 +37,48 @@ app.get('/assets/download/:id', (req, res) => { return; } - let params = { - Bucket: aws_credentials.bucketName, - Key: req.params.id - } + redis_client.hget(id, "filename", (err, reply) => { // maybe some expiration logic too + if (!reply) { + res.sendStatus(404); + } else { + + let params = { + Bucket: aws_credentials.bucketName, + Key: id + } + + s3.headObject(params, function(err, data) { + res.writeHead(200, {"Content-Disposition": "attachment; filename=" + reply, + "Content-Type": "application/octet-stream", + "Content-Length": data.ContentLength}); + let file_stream = s3.getObject(params).createReadStream(); + + file_stream.on('finish', () => { + redis_client.del(id); + s3.deleteObject(params, function(err, data) { + if (!err) { + console.log('Deleted off s3.'); + } + }) + }); + + file_stream.pipe(res); + }); + + // s3.getObject(params, function(err, data) { + // if (err) { + // console.log(err, err.stack); // an error occurred + // res.sendStatus(404); + // } + // else { + + + + // } + // }) - s3.getObject(params, function(err, data) { - if (err) { - console.log(err, err.stack); // an error occurred - } - else { - res.writeHead(200, {"Content-Disposition": "attachment; filename=response", //+ reply, - "Content-Type": "application/octet-stream"}); - // res.setHeader("Content-Type", "application/octet-stream"); - res.end(new Buffer(data.Body)) } }) - - // redis_client.hget(id, "filename", (err, reply) => { // maybe some expiration logic too - // if (!reply) { - // res.sendStatus(404); - // } else { - - // res.download(__dirname + "/../static/" + id, reply, (err) => { - // if (!err) { - // redis_client.del(id); - // fs.unlinkSync(__dirname + "/../static/" + id); - // } - // }); - // } - // }) }); app.post('/delete/:id', (req, res) => { @@ -83,21 +95,22 @@ app.post('/delete/:id', (req, res) => { res.sendStatus(404); } -<<<<<<< HEAD - client.hget(id, 'delete', (err, reply) => { - if (!reply) { - res.sendStatus(404); - } else { - client.del(id); - fs.unlinkSync(__dirname + '/../static/' + id); -======= redis_client.hget(id, "delete", (err, reply) => { - if (!reply) { + if (!reply || (delete_token !== reply)) { res.sendStatus(404); } else { redis_client.del(id); - fs.unlinkSync(__dirname + "/../static/" + id); ->>>>>>> currently not working, decryption seems to fail + let params = { + Bucket: aws_credentials.bucketName, + Key: id + } + + s3.deleteObject(params, function(err, data) { + if (!err) { + console.log('Deleted off s3.'); + } + }) + res.sendStatus(200); } }); @@ -110,12 +123,10 @@ app.post("/upload/:id", (req, res, next) => { return; } - let fstream; req.pipe(req.busboy); req.busboy.on("file", (fieldname, file, filename) => { console.log("Uploading: " + filename); - let params = { Bucket: aws_credentials.bucketName, Key: req.params.id, @@ -126,29 +137,16 @@ app.post("/upload/:id", (req, res, next) => { if (err) { console.log(err, err.stack); // an error occurred } else { - console.log(data); - } - }) - - return; - - fstream = fs.createWriteStream(__dirname + "/../static/" + req.params.id); - file.pipe(fstream); - fstream.on("close", () => { let id = req.params.id; let uuid = crypto.randomBytes(10).toString('hex'); redis_client.hmset([id, "filename", filename, "delete", uuid]); - // delete the file off the server in 24 hours - // setTimeout(() => { - // fs.unlinkSync(__dirname + "/static/" + id); - // }, 86400000); - redis_client.expire(id, 86400000); console.log("Upload Finished of " + filename); res.send(uuid); - }); + } + }) }); }); }); From af4edfef1642f6febb736ea112769c63374604cd Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Tue, 6 Jun 2017 10:24:58 -0700 Subject: [PATCH 3/6] working s3 integration, commented out load credentials from json --- frontend/src/fileReceiver.js | 3 - frontend/src/fileSender.js | 5 +- frontend/src/upload.js | 3 +- package.json | 5 +- server/config.js | 30 ++++--- server/portal_server.js | 156 ++++++++++++++++++++--------------- 6 files changed, 116 insertions(+), 86 deletions(-) diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js index 14a539ea..a1a50457 100644 --- a/frontend/src/fileReceiver.js +++ b/frontend/src/fileReceiver.js @@ -5,7 +5,6 @@ class FileReceiver extends EventEmitter { constructor() { super(); this.salt = strToIv(location.pathname.slice(10, -1)); - window.salt = this.salt; } download() { @@ -31,8 +30,6 @@ class FileReceiver extends EventEmitter { let blob = new Blob([this.response]); let fileReader = new FileReader(); fileReader.onload = function() { - window.data = this.result; - console.log(this.result); resolve({ data: this.result, fname: xhr diff --git a/frontend/src/fileSender.js b/frontend/src/fileSender.js index 776bddb0..69fe597a 100644 --- a/frontend/src/fileSender.js +++ b/frontend/src/fileSender.js @@ -85,10 +85,13 @@ class FileSender extends EventEmitter { xhr.onreadystatechange = () => { if (xhr.readyState == XMLHttpRequest.DONE) { + // uuid field and url field + let responseObj = JSON.parse(xhr.responseText); resolve({ + url: responseObj.url, fileId: fileId, secretKey: keydata.k, - deleteToken: xhr.responseText + deleteToken: responseObj.uuid }); } }; diff --git a/frontend/src/upload.js b/frontend/src/upload.js index 2c478610..40ee4b90 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -58,8 +58,7 @@ $(document).ready(function() { progress.innerText = `Progress: ${percentComplete}%`; }); fileSender.upload().then(info => { - const url = `${window.location - .origin}/download/${info.fileId}/#${info.secretKey}`; + const url = info.url.trim() + `#${info.secretKey}`.trim(); $('#link').attr('value', url); link.innerHTML = url; localStorage.setItem(info.fileId, info.deleteToken); diff --git a/package.json b/package.json index 229f13e7..885f6213 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,13 @@ "convict": "^3.0.0", "express": "^4.15.3", "fs-extra": "^3.0.1", + "node-fetch": "^1.7.1", "path": "^0.12.7", "redis": "^2.7.1" }, "devDependencies": { "browserify": "^14.4.0", + "cross-env": "^5.0.0", "prettier": "^1.3.1", "watchify": "^3.9.0" }, @@ -22,7 +24,8 @@ "repository": "mozilla/something-awesome", "scripts": { "format": "prettier --single-quote --write 'frontend/src/*.js' 'server/*.js'", - "start": "watchify frontend/src/main.js -o public/bundle.js -d | node server/portal_server.js", + "dev": "watchify frontend/src/main.js -o public/bundle.js -d | node server/portal_server.js", + "start": "watchify frontend/src/main.js -o public/bundle.js -d | cross-env NODE_ENV=production node server/portal_server.js", "test": "echo \"Error: no test specified\" && exit 1" } } diff --git a/server/config.js b/server/config.js index 43860f77..92095fb4 100644 --- a/server/config.js +++ b/server/config.js @@ -1,16 +1,22 @@ const convict = require('convict'); +let api_key = 'INSERT API KEY HERE'; let conf = convict({ - aws_credentials: { - region: 'us-west-2', - bucketName: 'testpilot-p2p' - } -}) + aws_credentials: { + region: 'us-west-2', + bucketName: 'testpilot-p2p' + }, + bitly_credentials: { + api_key: api_key + }, + env: { + format: ['production', 'development'], + default: 'development', + env: 'NODE_ENV' + } +}); -// var env = conf.get('env'); -// conf.loadFile('./config/' + env + '.json'); - -// Perform validation -conf.validate({allowed: 'strict'}); - -module.exports = conf; \ No newline at end of file +// Perform validation +conf.validate({ allowed: 'strict' }); + +module.exports = conf.getProperties(); diff --git a/server/portal_server.js b/server/portal_server.js index ca1a1bbf..e47e3222 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -1,24 +1,25 @@ -const express = require("express") -const busboy = require("connect-busboy"); -const path = require("path"); -const fs = require("fs-extra"); -const bodyParser = require("body-parser"); -const crypto = require("crypto"); +const express = require('express'); +const busboy = require('connect-busboy'); +const path = require('path'); +const fs = require('fs-extra'); +const bodyParser = require('body-parser'); +const crypto = require('crypto'); const conf = require('./config.js'); const stream = require('stream'); +const fetch = require('node-fetch'); -let aws_credentials = conf.get('aws_credentials'); +let aws_credentials = conf.aws_credentials; +let bitly_credentials = conf.bitly_credentials; +let isProduction = conf.env === 'production'; const AWS = require('aws-sdk'); -AWS.config.loadFromPath('../../.aws/credentials'); const s3 = new AWS.S3(); +const app = express(); +const redis = require('redis'); +const redis_client = redis.createClient(); -const app = express() -const redis = require("redis"), - redis_client = redis.createClient(); - -redis_client.on("error", (err) => { +redis_client.on('error', err => { console.log(err); }); @@ -33,24 +34,26 @@ app.get('/download/:id', (req, res) => { app.get('/assets/download/:id', (req, res) => { let id = req.params.id; if (!validateID(id)) { - res.send(404); + res.sendStatus(404); return; } - redis_client.hget(id, "filename", (err, reply) => { // maybe some expiration logic too + redis_client.hget(id, 'filename', (err, reply) => { + // maybe some expiration logic too if (!reply) { res.sendStatus(404); } else { - let params = { Bucket: aws_credentials.bucketName, Key: id - } + }; s3.headObject(params, function(err, data) { - res.writeHead(200, {"Content-Disposition": "attachment; filename=" + reply, - "Content-Type": "application/octet-stream", - "Content-Length": data.ContentLength}); + res.writeHead(200, { + 'Content-Disposition': 'attachment; filename=' + reply, + 'Content-Type': 'application/octet-stream', + 'Content-Length': data.ContentLength + }); let file_stream = s3.getObject(params).createReadStream(); file_stream.on('finish', () => { @@ -59,26 +62,13 @@ app.get('/assets/download/:id', (req, res) => { if (!err) { console.log('Deleted off s3.'); } - }) + }); }); file_stream.pipe(res); }); - - // s3.getObject(params, function(err, data) { - // if (err) { - // console.log(err, err.stack); // an error occurred - // res.sendStatus(404); - // } - // else { - - - - // } - // }) - } - }) + }); }); app.post('/delete/:id', (req, res) => { @@ -95,66 +85,98 @@ app.post('/delete/:id', (req, res) => { res.sendStatus(404); } - redis_client.hget(id, "delete", (err, reply) => { - if (!reply || (delete_token !== reply)) { + redis_client.hget(id, 'delete', (err, reply) => { + if (!reply || delete_token !== reply) { res.sendStatus(404); } else { redis_client.del(id); let params = { Bucket: aws_credentials.bucketName, Key: id - } + }; s3.deleteObject(params, function(err, data) { if (!err) { console.log('Deleted off s3.'); } - }) + }); res.sendStatus(200); } }); }); -app.post("/upload/:id", (req, res, next) => { +app.post('/upload/:id', (req, res, next) => { + if (!validateID(req.params.id)) { + res.send(404); + return; + } - if (!validateID(req.params.id)){ - res.send(404); - return; - } + req.pipe(req.busboy); + req.busboy.on('file', (fieldname, file, filename) => { + console.log('Uploading: ' + filename); - req.pipe(req.busboy); - req.busboy.on("file", (fieldname, file, filename) => { - console.log("Uploading: " + filename); + let params = { + Bucket: aws_credentials.bucketName, + Key: req.params.id, + Body: file + }; - let params = { - Bucket: aws_credentials.bucketName, - Key: req.params.id, - Body: file + s3.upload(params, function(err, data) { + if (err) { + console.log(err, err.stack); // an error occurred + } else { + let id = req.params.id; + let uuid = crypto.randomBytes(10).toString('hex'); + + redis_client.hmset([id, 'filename', filename, 'delete', uuid]); + + redis_client.expire(id, 86400000); + console.log('Upload Finished of ' + filename); + + if (isProduction) { + let url = + req.protocol + + `://` + + req.get('host') + + '/download/' + + req.params.id + + '/'; + fetch( + 'https://api-ssl.bitly.com/v3/shorten?access_token=' + + bitly_credentials.api_key + + '&longUrl=' + + encodeURIComponent(url) + + '&format=txt' + ) + .then(res => { + return res.text(); + }) + .then(body => { + res.json({ + uuid: uuid, + url: body + }); + }); + } else { + res.json({ + uuid: uuid, + url: url + }); } - - s3.upload(params, function(err, data) { - if (err) { - console.log(err, err.stack); // an error occurred - } else { - let id = req.params.id; - let uuid = crypto.randomBytes(10).toString('hex'); - - redis_client.hmset([id, "filename", filename, "delete", uuid]); - - redis_client.expire(id, 86400000); - console.log("Upload Finished of " + filename); - res.send(uuid); - } - }) + } }); }); }); -app.listen(3000, () => { +let server = app.listen(3000, () => { console.log('Portal app listening on port 3000!'); }); let validateID = route_id => { return route_id.match(/^[0-9a-fA-F]{32}$/) !== null; }; + +if (bitly_credentials.api_key === 'INSERT API KEY HERE') { + throw new Error('Copy paste a bitly API key into server/config.js'); +} From 8bb42c137a17f65c2ba5e199555edf85a0aa4205 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Tue, 6 Jun 2017 23:52:56 -0700 Subject: [PATCH 4/6] changed config --- package-lock.json | 767 +++++++++++++++++++++++++--------------- server/config.js | 23 +- server/portal_server.js | 29 +- 3 files changed, 514 insertions(+), 305 deletions(-) diff --git a/package-lock.json b/package-lock.json index 51eaa966..15ee7454 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,12 +17,14 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true }, "anymatch": { "version": "1.3.0", @@ -92,7 +94,8 @@ "ast-types": { "version": "0.9.8", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.9.8.tgz", - "integrity": "sha1-bLakC+ujH0nyCSjihDn8FKPasHg=" + "integrity": "sha1-bLakC+ujH0nyCSjihDn8FKPasHg=", + "dev": true }, "astw": { "version": "2.2.0", @@ -106,26 +109,50 @@ "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", "dev": true }, + "aws-sdk": { + "version": "2.64.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.64.0.tgz", + "integrity": "sha1-Nl2n2Mfz7WTCINX3Ov14YgxJI6M=", + "dependencies": { + "crypto-browserify": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-1.0.9.tgz", + "integrity": "sha1-zFRJaF37hesRyYKKzHy4erW7/MA=" + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=" + } + } + }, "babel-code-frame": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", - "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=" + "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", + "dev": true }, "babylon": { "version": "7.0.0-beta.8", "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.8.tgz", - "integrity": "sha1-K9xa42YEFELCfgaMzm8NfAbqmUk=" + "integrity": "sha1-K9xa42YEFELCfgaMzm8NfAbqmUk=", + "dev": true }, "balanced-match": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=" + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", + "dev": true }, "base64-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.0.tgz", - "integrity": "sha1-o5mS1yNYSBGYK+XikLtqU9hnAPE=", - "dev": true + "integrity": "sha1-o5mS1yNYSBGYK+XikLtqU9hnAPE=" }, "binary-extensions": { "version": "1.8.0", @@ -147,7 +174,8 @@ "brace-expansion": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", - "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=" + "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", + "dev": true }, "braces": { "version": "1.8.5", @@ -246,8 +274,7 @@ "buffer": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.6.tgz", - "integrity": "sha1-LqZp9+7Atu2gWwj4tf9mGyhXNYg=", - "dev": true + "integrity": "sha1-LqZp9+7Atu2gWwj4tf9mGyhXNYg=" }, "buffer-shims": { "version": "1.0.0", @@ -286,7 +313,8 @@ "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=" + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true }, "chokidar": { "version": "1.7.0", @@ -303,12 +331,14 @@ "color-convert": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=" + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "dev": true }, "color-name": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.2.tgz", - "integrity": "sha1-XIq3K2S9IhXWF66VWeuxSEdc+Y0=" + "integrity": "sha1-XIq3K2S9IhXWF66VWeuxSEdc+Y0=", + "dev": true }, "combine-source-map": { "version": "0.7.2", @@ -319,7 +349,8 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "concat-stream": { "version": "1.5.2", @@ -374,6 +405,61 @@ "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", "dev": true }, + "convict": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/convict/-/convict-3.0.0.tgz", + "integrity": "sha1-JZ8wv7h+4JRIYEhiA1GdRntNUbU=", + "dependencies": { + "depd": { + "version": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=" + }, + "json5": { + "version": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" + }, + "lodash.clonedeep": { + "version": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" + }, + "minimist": { + "version": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "moment": { + "version": "https://registry.npmjs.org/moment/-/moment-2.17.1.tgz", + "integrity": "sha1-/tlQYGPzaxDwZsi1mhRNf66+HYI=" + }, + "validator": { + "version": "https://registry.npmjs.org/validator/-/validator-7.0.0.tgz", + "integrity": "sha1-x03rgGNRL6w1VHk45vCxUEooL9I=" + }, + "varify": { + "version": "https://registry.npmjs.org/varify/-/varify-0.2.0.tgz", + "integrity": "sha1-GR2p/p3EzWjQ0USY1OKpEP9OZRY=", + "optional": true, + "dependencies": { + "redeyed": { + "version": "https://registry.npmjs.org/redeyed/-/redeyed-1.0.1.tgz", + "integrity": "sha1-6WwZO0DAgWsArshCaY5hGF5VSYo=", + "optional": true, + "dependencies": { + "esprima": { + "version": "https://registry.npmjs.org/esprima/-/esprima-3.0.0.tgz", + "integrity": "sha1-U88kes2ncxPlUcOqLnM0LT+099k=", + "optional": true + } + } + }, + "through": { + "version": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "optional": true + } + } + } + } + }, "cookie": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", @@ -407,6 +493,18 @@ "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", "dev": true }, + "cross-env": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-5.0.0.tgz", + "integrity": "sha1-VlzK5NCWdkQaUIf0Bv52YaKckxs=", + "dev": true + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true + }, "crypto-browserify": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.0.tgz", @@ -522,6 +620,11 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=" + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -530,12 +633,14 @@ "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true }, "etag": { "version": "1.8.0", @@ -597,7 +702,8 @@ "flow-parser": { "version": "0.45.0", "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.45.0.tgz", - "integrity": "sha1-qinUrifwaqAoF3crug/L7+9+YvA=" + "integrity": "sha1-qinUrifwaqAoF3crug/L7+9+YvA=", + "dev": true }, "for-in": { "version": "1.0.2", @@ -629,7 +735,8 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "fsevents": { "version": "1.1.1", @@ -639,688 +746,688 @@ "optional": true, "dependencies": { "abbrev": { - "version": "1.1.0", - "bundled": true, + "version": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", + "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", "dev": true, "optional": true }, "ansi-regex": { - "version": "2.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "ansi-styles": { - "version": "2.2.1", - "bundled": true, + "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true, "optional": true }, "aproba": { - "version": "1.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz", + "integrity": "sha1-ldNgDwdxCqDpKYxyatXs8urLq6s=", "dev": true, "optional": true }, "are-we-there-yet": { - "version": "1.1.2", - "bundled": true, + "version": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz", + "integrity": "sha1-gORw6VoIR5T+GJkmLFZnxuiN4bM=", "dev": true, "optional": true }, "asn1": { - "version": "0.2.3", - "bundled": true, + "version": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", "dev": true, "optional": true }, "assert-plus": { - "version": "0.2.0", - "bundled": true, + "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", "dev": true, "optional": true }, "asynckit": { - "version": "0.4.0", - "bundled": true, + "version": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true, "optional": true }, "aws-sign2": { - "version": "0.6.0", - "bundled": true, + "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", "dev": true, "optional": true }, "aws4": { - "version": "1.6.0", - "bundled": true, + "version": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", "dev": true, "optional": true }, "balanced-match": { - "version": "0.4.2", - "bundled": true, + "version": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", "dev": true }, "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "dev": true, "optional": true }, "block-stream": { - "version": "0.0.9", - "bundled": true, + "version": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "dev": true }, "boom": { - "version": "2.10.1", - "bundled": true, + "version": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true }, "brace-expansion": { - "version": "1.1.6", - "bundled": true, + "version": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz", + "integrity": "sha1-cZfX6qm4fmSDkOph/GbIRCdCDfk=", "dev": true }, "buffer-shims": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "dev": true }, "caseless": { - "version": "0.11.0", - "bundled": true, + "version": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", + "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", "dev": true, "optional": true }, "chalk": { - "version": "1.1.3", - "bundled": true, + "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "optional": true }, "code-point-at": { - "version": "1.1.0", - "bundled": true, + "version": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, "combined-stream": { - "version": "1.0.5", - "bundled": true, + "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", "dev": true }, "commander": { - "version": "2.9.0", - "bundled": true, + "version": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "optional": true }, "concat-map": { - "version": "0.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "console-control-strings": { - "version": "1.1.0", - "bundled": true, + "version": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "dev": true }, "core-util-is": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, "cryptiles": { - "version": "2.0.5", - "bundled": true, + "version": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", "dev": true, "optional": true }, "dashdash": { - "version": "1.14.1", - "bundled": true, + "version": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, "optional": true, "dependencies": { "assert-plus": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true, "optional": true } } }, "debug": { - "version": "2.2.0", - "bundled": true, + "version": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", "dev": true, "optional": true }, "deep-extend": { - "version": "0.4.1", - "bundled": true, + "version": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", + "integrity": "sha1-7+QRPQgIX05vlod1mBD4B0aeIlM=", "dev": true, "optional": true }, "delayed-stream": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, "delegates": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true, "optional": true }, "ecc-jsbn": { - "version": "0.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "dev": true, "optional": true }, "escape-string-regexp": { - "version": "1.0.5", - "bundled": true, + "version": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true, "optional": true }, "extend": { - "version": "3.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", + "integrity": "sha1-WkdDU7nzNT3dgXbf03uRyDpG8dQ=", "dev": true, "optional": true }, "extsprintf": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", + "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", "dev": true }, "forever-agent": { - "version": "0.6.1", - "bundled": true, + "version": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", "dev": true, "optional": true }, "form-data": { - "version": "2.1.2", - "bundled": true, + "version": "https://registry.npmjs.org/form-data/-/form-data-2.1.2.tgz", + "integrity": "sha1-icNTQAi5fq2ky7FX1Y9vXfAl6uQ=", "dev": true, "optional": true }, "fs.realpath": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "fstream": { - "version": "1.0.10", - "bundled": true, + "version": "https://registry.npmjs.org/fstream/-/fstream-1.0.10.tgz", + "integrity": "sha1-YE6Kkv4m/9n2+uMDmdSYThqyKCI=", "dev": true }, "fstream-ignore": { - "version": "1.0.5", - "bundled": true, + "version": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", + "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", "dev": true, "optional": true }, "gauge": { - "version": "2.7.3", - "bundled": true, + "version": "https://registry.npmjs.org/gauge/-/gauge-2.7.3.tgz", + "integrity": "sha1-HCOFX5YvF7OtPQ3HRD8wRULt/gk=", "dev": true, "optional": true }, "generate-function": { - "version": "2.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", "dev": true, "optional": true }, "generate-object-property": { - "version": "1.2.0", - "bundled": true, + "version": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", "dev": true, "optional": true }, "getpass": { - "version": "0.1.6", - "bundled": true, + "version": "https://registry.npmjs.org/getpass/-/getpass-0.1.6.tgz", + "integrity": "sha1-KD/9n8ElaECHUxHBtg6MQBhxEOY=", "dev": true, "optional": true, "dependencies": { "assert-plus": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true, "optional": true } } }, "glob": { - "version": "7.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "dev": true }, "graceful-fs": { - "version": "4.1.11", - "bundled": true, + "version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, "graceful-readlink": { - "version": "1.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", "dev": true, "optional": true }, "har-validator": { - "version": "2.0.6", - "bundled": true, + "version": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", + "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", "dev": true, "optional": true }, "has-ansi": { - "version": "2.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "optional": true }, "has-unicode": { - "version": "2.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true, "optional": true }, "hawk": { - "version": "3.1.3", - "bundled": true, + "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", "dev": true, "optional": true }, "hoek": { - "version": "2.16.3", - "bundled": true, + "version": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", "dev": true }, "http-signature": { - "version": "1.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", "dev": true, "optional": true }, "inflight": { - "version": "1.0.6", - "bundled": true, + "version": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true }, "inherits": { - "version": "2.0.3", - "bundled": true, + "version": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "ini": { - "version": "1.3.4", - "bundled": true, + "version": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", "dev": true, "optional": true }, "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true }, "is-my-json-valid": { - "version": "2.15.0", - "bundled": true, + "version": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz", + "integrity": "sha1-k27do8o8IR/ZjzstPgjaQ/eykVs=", "dev": true, "optional": true }, "is-property": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", "dev": true, "optional": true }, "is-typedarray": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true, "optional": true }, "isarray": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, "isstream": { - "version": "0.1.2", - "bundled": true, + "version": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true, "optional": true }, "jodid25519": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", + "integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=", "dev": true, "optional": true }, "jsbn": { - "version": "0.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true, "optional": true }, "json-schema": { - "version": "0.2.3", - "bundled": true, + "version": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "dev": true, "optional": true }, "json-stringify-safe": { - "version": "5.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true, "optional": true }, "jsonpointer": { - "version": "4.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true, "optional": true }, "jsprim": { - "version": "1.3.1", - "bundled": true, + "version": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.1.tgz", + "integrity": "sha1-KnJW9wQSop7jZwqspiWZTE3P8lI=", "dev": true, "optional": true }, "mime-db": { - "version": "1.26.0", - "bundled": true, + "version": "https://registry.npmjs.org/mime-db/-/mime-db-1.26.0.tgz", + "integrity": "sha1-6v/NDk/Gk1z4E02iRuLmw1MFrf8=", "dev": true }, "mime-types": { - "version": "2.1.14", - "bundled": true, + "version": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", + "integrity": "sha1-9+99l1g/yvO30oK2+LVnnaselO4=", "dev": true }, "minimatch": { - "version": "3.0.3", - "bundled": true, + "version": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha1-Kk5AkLlrLbBqnX3wEFWmKnfJt3Q=", "dev": true }, "minimist": { - "version": "0.0.8", - "bundled": true, + "version": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "mkdirp": { - "version": "0.5.1", - "bundled": true, + "version": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true }, "ms": { - "version": "0.7.1", - "bundled": true, + "version": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", "dev": true, "optional": true }, "node-pre-gyp": { - "version": "0.6.33", - "bundled": true, + "version": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.33.tgz", + "integrity": "sha1-ZArFUZj2qSWXLgwWxKwmoDTV7Mk=", "dev": true, "optional": true }, "nopt": { - "version": "3.0.6", - "bundled": true, + "version": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "optional": true }, "npmlog": { - "version": "4.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.2.tgz", + "integrity": "sha1-0DlQ4OeM4VJ7om0qdZLpNIrD518=", "dev": true, "optional": true }, "number-is-nan": { - "version": "1.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, "oauth-sign": { - "version": "0.8.2", - "bundled": true, + "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", "dev": true, "optional": true }, "object-assign": { - "version": "4.1.1", - "bundled": true, + "version": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true, "optional": true }, "once": { - "version": "1.4.0", - "bundled": true, + "version": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true }, "path-is-absolute": { - "version": "1.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, "pinkie": { - "version": "2.0.4", - "bundled": true, + "version": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", "dev": true, "optional": true }, "pinkie-promise": { - "version": "2.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "optional": true }, "process-nextick-args": { - "version": "1.0.7", - "bundled": true, + "version": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, "punycode": { - "version": "1.4.1", - "bundled": true, + "version": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "dev": true, "optional": true }, "qs": { - "version": "6.3.1", - "bundled": true, + "version": "https://registry.npmjs.org/qs/-/qs-6.3.1.tgz", + "integrity": "sha1-kYwLO802Z5dyuvE1say0wWUe150=", "dev": true, "optional": true }, "rc": { - "version": "1.1.7", - "bundled": true, + "version": "https://registry.npmjs.org/rc/-/rc-1.1.7.tgz", + "integrity": "sha1-xepWS7B6/5/TpbMukGwdOmWUD+o=", "dev": true, "optional": true, "dependencies": { "minimist": { - "version": "1.2.0", - "bundled": true, + "version": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true } } }, "readable-stream": { - "version": "2.2.2", - "bundled": true, + "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", + "integrity": "sha1-qeb+w8fdqF+LsbO6cChgRVb8gl4=", "dev": true, "optional": true }, "request": { - "version": "2.79.0", - "bundled": true, + "version": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", + "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", "dev": true, "optional": true }, "rimraf": { - "version": "2.5.4", - "bundled": true, + "version": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", + "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", "dev": true }, "semver": { - "version": "5.3.0", - "bundled": true, + "version": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true, "optional": true }, "set-blocking": { - "version": "2.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true, "optional": true }, "signal-exit": { - "version": "3.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true, "optional": true }, "sntp": { - "version": "1.0.9", - "bundled": true, + "version": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", "dev": true, "optional": true }, "sshpk": { - "version": "1.10.2", - "bundled": true, + "version": "https://registry.npmjs.org/sshpk/-/sshpk-1.10.2.tgz", + "integrity": "sha1-1agEziJpVRVjjnmNviMnPeBwpfo=", "dev": true, "optional": true, "dependencies": { "assert-plus": { - "version": "1.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true, "optional": true } } }, "string_decoder": { - "version": "0.10.31", - "bundled": true, + "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, "string-width": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true }, "stringstream": { - "version": "0.0.5", - "bundled": true, + "version": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", "dev": true, "optional": true }, "strip-ansi": { - "version": "3.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true }, "strip-json-comments": { - "version": "2.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true, "optional": true }, "supports-color": { - "version": "2.0.0", - "bundled": true, + "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true, "optional": true }, "tar": { - "version": "2.2.1", - "bundled": true, + "version": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "dev": true }, "tar-pack": { - "version": "3.3.0", - "bundled": true, + "version": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.3.0.tgz", + "integrity": "sha1-MJMYFkGPVa/E0hd1r91nIM7kXa4=", "dev": true, "optional": true, "dependencies": { "once": { - "version": "1.3.3", - "bundled": true, + "version": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", "dev": true, "optional": true }, "readable-stream": { - "version": "2.1.5", - "bundled": true, + "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", "dev": true, "optional": true } } }, "tough-cookie": { - "version": "2.3.2", - "bundled": true, + "version": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", "dev": true, "optional": true }, "tunnel-agent": { - "version": "0.4.3", - "bundled": true, + "version": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", "dev": true, "optional": true }, "tweetnacl": { - "version": "0.14.5", - "bundled": true, + "version": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true, "optional": true }, "uid-number": { - "version": "0.0.6", - "bundled": true, + "version": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", + "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", "dev": true, "optional": true }, "util-deprecate": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, "uuid": { - "version": "3.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", + "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=", "dev": true, "optional": true }, "verror": { - "version": "1.3.6", - "bundled": true, + "version": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", + "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", "dev": true, "optional": true }, "wide-align": { - "version": "1.1.0", - "bundled": true, + "version": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz", + "integrity": "sha1-QO3egCpx/qHwcNo+YtzaLnrdlq0=", "dev": true, "optional": true }, "wrappy": { - "version": "1.0.2", - "bundled": true, + "version": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "xtend": { - "version": "4.0.1", - "bundled": true, + "version": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true, "optional": true } @@ -1335,12 +1442,14 @@ "get-stdin": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", - "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=" + "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", + "dev": true }, "glob": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=" + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true }, "glob-base": { "version": "0.3.0", @@ -1368,7 +1477,8 @@ "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=" + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true }, "hash-base": { "version": "2.0.2", @@ -1413,8 +1523,7 @@ "ieee754": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", - "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", - "dev": true + "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=" }, "indexof": { "version": "0.0.1", @@ -1425,7 +1534,8 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=" + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true }, "inherits": { "version": "2.0.3", @@ -1509,11 +1619,28 @@ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", "dev": true }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-windows": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.1.tgz", + "integrity": "sha1-MQ23D3QtJZoWo2kgK1GvhCMzENk=", + "dev": true + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, "isobject": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", @@ -1531,17 +1658,25 @@ "jest-matcher-utils": { "version": "19.0.0", "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-19.0.0.tgz", - "integrity": "sha1-Xs2bY1ZdKwAfYfv37Ex/U3lkVk0=" + "integrity": "sha1-Xs2bY1ZdKwAfYfv37Ex/U3lkVk0=", + "dev": true }, "jest-validate": { "version": "19.0.0", "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-19.0.0.tgz", - "integrity": "sha1-jGMYog7P6roLpTeL+7gner3tQXM=" + "integrity": "sha1-jGMYog7P6roLpTeL+7gner3tQXM=", + "dev": true + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" }, "js-tokens": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.1.tgz", - "integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=" + "integrity": "sha1-COnxMkhKLEWjCQfp3E1VZ7fxFNc=", + "dev": true }, "json-stable-stringify": { "version": "0.0.1", @@ -1587,7 +1722,8 @@ "leven": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", - "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=" + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true }, "lexical-scope": { "version": "1.2.0", @@ -1595,12 +1731,23 @@ "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", "dev": true }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, + "lru-cache": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.0.tgz", + "integrity": "sha512-aHGs865JXz6bkB4AHL+3AhyvTFKL3iZamKVWjIUKnXOXyasJvqPK8WAjOnAQKQZVpeXDVz19u1DD0r/12bWAdQ==", + "dev": true + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -1658,12 +1805,14 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==" + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true }, "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true }, "module-deps": { "version": "4.1.1", @@ -1708,6 +1857,11 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" }, + "node-fetch": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz", + "integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ==" + }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -1728,7 +1882,8 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true }, "os-browserify": { "version": "0.1.2", @@ -1785,7 +1940,8 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, "path-parse": { "version": "1.0.5", @@ -1819,17 +1975,20 @@ "prettier": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.3.1.tgz", - "integrity": "sha1-+g6oS0WsC6beah5M7Nz/kA1WMVE=" + "integrity": "sha1-+g6oS0WsC6beah5M7Nz/kA1WMVE=", + "dev": true }, "pretty-format": { "version": "19.0.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-19.0.0.tgz", "integrity": "sha1-VlMNMqy5ij+khRxOK503tCBoTIQ=", + "dev": true, "dependencies": { "ansi-styles": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.0.0.tgz", - "integrity": "sha1-VATpOlRMT+x/BIJil3vr/jFV4ME=" + "integrity": "sha1-VATpOlRMT+x/BIJil3vr/jFV4ME=", + "dev": true } } }, @@ -1849,6 +2008,12 @@ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz", "integrity": "sha1-J+VF9pYKRKYn2bREZ+NcG2tM4vM=" }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, "public-encrypt": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", @@ -1869,8 +2034,7 @@ "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" }, "querystring-es3": { "version": "0.2.1", @@ -2014,6 +2178,11 @@ "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", "dev": true }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, "send": { "version": "0.15.3", "resolved": "https://registry.npmjs.org/send/-/send-0.15.3.tgz", @@ -2047,6 +2216,18 @@ "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, "shell-quote": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", @@ -2181,7 +2362,8 @@ "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=" + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true }, "subarg": { "version": "1.0.0", @@ -2192,7 +2374,8 @@ "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true }, "syntax-error": { "version": "1.3.0", @@ -2314,6 +2497,11 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" }, + "uuid": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", + "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=" + }, "vary": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", @@ -2331,16 +2519,39 @@ "integrity": "sha1-8HX9LoqGrN6Eztum5cKgvt1SPZ4=", "dev": true }, + "which": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", + "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "dev": true + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "xml2js": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", + "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=" + }, + "xmlbuilder": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", + "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=" }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true } } } diff --git a/server/config.js b/server/config.js index 92095fb4..4cf39ccf 100644 --- a/server/config.js +++ b/server/config.js @@ -1,13 +1,24 @@ const convict = require('convict'); -let api_key = 'INSERT API KEY HERE'; let conf = convict({ - aws_credentials: { - region: 'us-west-2', - bucketName: 'testpilot-p2p' + bitly_key: { + format: String, + env: 'P2P_BITLY_KEY' }, - bitly_credentials: { - api_key: api_key + s3_bucket: { + format: String, + env: 'P2P_S3_BUCKET' + }, + redis_host: { + format: String, + default: 'localhost', + env: 'P2P_REDIS_HOST' + }, + listen_port: { + format: 'port', + default: 1443, + arg: 'port', + env: 'P2P_LISTEN_PORT' }, env: { format: ['production', 'development'], diff --git a/server/portal_server.js b/server/portal_server.js index e47e3222..e20baae7 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -8,8 +8,6 @@ const conf = require('./config.js'); const stream = require('stream'); const fetch = require('node-fetch'); -let aws_credentials = conf.aws_credentials; -let bitly_credentials = conf.bitly_credentials; let isProduction = conf.env === 'production'; const AWS = require('aws-sdk'); @@ -44,7 +42,7 @@ app.get('/assets/download/:id', (req, res) => { res.sendStatus(404); } else { let params = { - Bucket: aws_credentials.bucketName, + Bucket: config.s3_bucket, Key: id }; @@ -91,7 +89,7 @@ app.post('/delete/:id', (req, res) => { } else { redis_client.del(id); let params = { - Bucket: aws_credentials.bucketName, + Bucket: config.s3_bucket, Key: id }; @@ -117,7 +115,7 @@ app.post('/upload/:id', (req, res, next) => { console.log('Uploading: ' + filename); let params = { - Bucket: aws_credentials.bucketName, + Bucket: config.s3_bucket, Key: req.params.id, Body: file }; @@ -133,18 +131,11 @@ app.post('/upload/:id', (req, res, next) => { redis_client.expire(id, 86400000); console.log('Upload Finished of ' + filename); - - if (isProduction) { - let url = - req.protocol + - `://` + - req.get('host') + - '/download/' + - req.params.id + - '/'; + let url = `${req.protocol}://${req.get('host')}/download/${req.params.id}/`; + if (config.bitly_key) { fetch( 'https://api-ssl.bitly.com/v3/shorten?access_token=' + - bitly_credentials.api_key + + config.bitly_key + '&longUrl=' + encodeURIComponent(url) + '&format=txt' @@ -169,14 +160,10 @@ app.post('/upload/:id', (req, res, next) => { }); }); -let server = app.listen(3000, () => { - console.log('Portal app listening on port 3000!'); +let server = app.listen(conf.listen_port, () => { + console.log(`Portal app listening on port ${conf.listen_port}!`); }); let validateID = route_id => { return route_id.match(/^[0-9a-fA-F]{32}$/) !== null; }; - -if (bitly_credentials.api_key === 'INSERT API KEY HERE') { - throw new Error('Copy paste a bitly API key into server/config.js'); -} From 1ad71904bc7c4e1547d397ff02bd233524c378f4 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Wed, 7 Jun 2017 14:07:31 -0700 Subject: [PATCH 5/6] npm run dev now runs on local file storage. npm start runs in production, but if there is either no aws bucket or bitly key specified as env vars, it defaults back to local storage --- server/config.js | 2 + server/portal_server.js | 116 +++++++--------------- server/storage.js | 208 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 243 insertions(+), 83 deletions(-) create mode 100644 server/storage.js diff --git a/server/config.js b/server/config.js index 4cf39ccf..1e1119a4 100644 --- a/server/config.js +++ b/server/config.js @@ -3,10 +3,12 @@ const convict = require('convict'); let conf = convict({ bitly_key: { format: String, + default: 'localhost', env: 'P2P_BITLY_KEY' }, s3_bucket: { format: String, + default: 'localhost', env: 'P2P_S3_BUCKET' }, redis_host: { diff --git a/server/portal_server.js b/server/portal_server.js index e20baae7..bf70acc6 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -7,8 +7,12 @@ const crypto = require('crypto'); const conf = require('./config.js'); const stream = require('stream'); const fetch = require('node-fetch'); +const storage = require('./storage.js'); -let isProduction = conf.env === 'production'; +let isProduction = + conf.env === 'production' && + conf.s3_bucket !== 'localhost' && + conf.bitly_key !== 'localhost'; const AWS = require('aws-sdk'); const s3 = new AWS.S3(); @@ -37,34 +41,28 @@ app.get('/assets/download/:id', (req, res) => { } redis_client.hget(id, 'filename', (err, reply) => { - // maybe some expiration logic too if (!reply) { res.sendStatus(404); } else { - let params = { - Bucket: config.s3_bucket, - Key: id - }; - - s3.headObject(params, function(err, data) { + storage.length(id).then(contentLength => { res.writeHead(200, { 'Content-Disposition': 'attachment; filename=' + reply, 'Content-Type': 'application/octet-stream', - 'Content-Length': data.ContentLength + 'Content-Length': contentLength }); - let file_stream = s3.getObject(params).createReadStream(); - - file_stream.on('finish', () => { - redis_client.del(id); - s3.deleteObject(params, function(err, data) { - if (!err) { - console.log('Deleted off s3.'); - } - }); - }); - - file_stream.pipe(res); }); + + let file_stream = storage.get(id); + + file_stream.on('close', () => { + storage.forceDelete(id, redis_client).then(err => { + if (!err) { + console.log('Deleted.'); + } + }); + }); + + file_stream.pipe(res); } }); }); @@ -83,25 +81,14 @@ app.post('/delete/:id', (req, res) => { res.sendStatus(404); } - redis_client.hget(id, 'delete', (err, reply) => { - if (!reply || delete_token !== reply) { - res.sendStatus(404); - } else { - redis_client.del(id); - let params = { - Bucket: config.s3_bucket, - Key: id - }; - - s3.deleteObject(params, function(err, data) { - if (!err) { - console.log('Deleted off s3.'); - } - }); - - res.sendStatus(200); - } - }); + storage + .delete(id, redis_client, delete_token) + .then(err => { + if (!err) { + console.log('Deleted off s3.'); + } + }) + .catch(err => res.sendStatus(404)); }); app.post('/upload/:id', (req, res, next) => { @@ -113,50 +100,13 @@ app.post('/upload/:id', (req, res, next) => { req.pipe(req.busboy); req.busboy.on('file', (fieldname, file, filename) => { console.log('Uploading: ' + filename); + let url = `${req.protocol}://${req.get('host')}/download/${req.params.id}/`; - let params = { - Bucket: config.s3_bucket, - Key: req.params.id, - Body: file - }; - - s3.upload(params, function(err, data) { - if (err) { - console.log(err, err.stack); // an error occurred - } else { - let id = req.params.id; - let uuid = crypto.randomBytes(10).toString('hex'); - - redis_client.hmset([id, 'filename', filename, 'delete', uuid]); - - redis_client.expire(id, 86400000); - console.log('Upload Finished of ' + filename); - let url = `${req.protocol}://${req.get('host')}/download/${req.params.id}/`; - if (config.bitly_key) { - fetch( - 'https://api-ssl.bitly.com/v3/shorten?access_token=' + - config.bitly_key + - '&longUrl=' + - encodeURIComponent(url) + - '&format=txt' - ) - .then(res => { - return res.text(); - }) - .then(body => { - res.json({ - uuid: uuid, - url: body - }); - }); - } else { - res.json({ - uuid: uuid, - url: url - }); - } - } - }); + storage + .set(req.params.id, file, filename, redis_client, url) + .then(linkAndID => { + res.json(linkAndID); + }); }); }); diff --git a/server/storage.js b/server/storage.js new file mode 100644 index 00000000..21350318 --- /dev/null +++ b/server/storage.js @@ -0,0 +1,208 @@ +const AWS = require('aws-sdk'); +const s3 = new AWS.S3(); + +const conf = require('./config.js'); +const fs = require('fs'); +const path = require('path'); +const fetch = require('node-fetch'); +const crypto = require('crypto'); + +let isProduction = + conf.env === 'production' && + conf.s3_bucket !== 'localhost' && + conf.bitly_key !== 'localhost'; + +if (isProduction) { + module.exports = { + length: AWSLength, + get: AWSGet, + set: AWSSet, + delete: AWSDelete, + forceDelete: AWSForceDelete + }; +} else { + module.exports = { + length: LocalLength, + get: LocalGet, + set: LocalSet, + delete: LocalDelete, + forceDelete: LocalForceDelete + }; +} + +function LocalLength(id) { + return new Promise((resolve, reject) => { + try { + resolve(fs.statSync(__dirname + '/../static/' + id).size); + } catch (err) { + reject(); + } + }); +} + +function LocalGet(id) { + return fs.createReadStream(__dirname + '/../static/' + id); +} + +function LocalSet(id, file, filename, client, url) { + return new Promise((resolve, reject) => { + fstream = fs.createWriteStream(__dirname + '/../static/' + id); + file.pipe(fstream); + fstream.on('close', () => { + let uuid = crypto.randomBytes(10).toString('hex'); + + client.hmset([id, 'filename', filename, 'delete', uuid]); + client.expire(id, 86400000); + console.log('Upload Finished of ' + filename); + resolve({ + uuid: uuid, + url: url + }); + }); + }); +} + +function LocalDelete(id, client, delete_token) { + return new Promise((resolve, reject) => { + client.hget(id, 'delete', (err, reply) => { + if (!reply || delete_token !== reply) { + resolve( + new Promise((resolve, reject) => { + reject(); + }) + ); + } else { + resolve( + new Promise((resolve, reject) => { + client.del(id); + resolve(fs.unlinkSync(__dirname + '/../static/' + id)); + }) + ); + } + }); + }); +} + +function LocalForceDelete(id, client) { + return new Promise((resolve, reject) => { + client.del(id); + resolve(fs.unlinkSync(__dirname + '/../static/' + id)); + }); +} + +function AWSLength(id) { + let params = { + Bucket: conf.s3_bucket, + Key: id + }; + return new Promise((resolve, reject) => { + s3.headObject(params, function(err, data) { + resolve(data.ContentLength); + }); + }); +} + +function AWSGet(id) { + let params = { + Bucket: conf.s3_bucket, + Key: id + }; + + return s3.getObject(params).createReadStream(); +} + +function AWSSet(id, file, filename, client, url) { + let params = { + Bucket: conf.s3_bucket, + Key: id, + Body: file + }; + + return new Promise((resolve, reject) => { + s3.upload(params, function(err, data) { + if (err) { + console.log(err, err.stack); // an error occurred + } else { + let uuid = crypto.randomBytes(10).toString('hex'); + + client.hmset([id, 'filename', filename, 'delete', uuid]); + + client.expire(id, 86400000); + console.log('Upload Finished of ' + filename); + resolve( + new Promise((resolve, reject) => { + if (conf.bitly_key) { + fetch( + 'https://api-ssl.bitly.com/v3/shorten?access_token=' + + conf.bitly_key + + '&longUrl=' + + encodeURIComponent(url) + + '&format=txt' + ) + .then(res => { + return res.text(); + }) + .then(body => { + resolve({ + uuid: uuid, + url: body + }); + }); + } else { + resolve({ + uuid: uuid, + url: url + }); + } + }) + ); + } + }); + }); +} + +function AWSDelete(id, client, delete_token) { + return new Promise((resolve, reject) => { + client.hget(id, 'delete', (err, reply) => { + if (!reply || delete_token !== reply) { + resolve( + new Promise((resolve, reject) => { + reject(); + }) + ); + } else { + client.del(id); + let params = { + Bucket: conf.s3_bucket, + Key: id + }; + + resolve( + new Promise((resolve, reject) => { + s3.deleteObject(params, function(err, data) { + resolve(err); + }); + }) + ); + } + }); + }); +} + +function AWSForceDelete(id, client) { + return new Promise((resolve, reject) => { + client.del(id); + let params = { + Bucket: conf.s3_bucket, + Key: id + }; + + resolve( + new Promise((resolve, reject) => { + s3.deleteObject(params, function(err, data) { + resolve(err); + }); + }) + ); + }); +} From f9c2eb1ae45a5964c91d534f33cf38c10efca058 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Wed, 7 Jun 2017 16:16:38 -0700 Subject: [PATCH 6/6] using handlebars templating engine, refactored server code and storage code --- package-lock.json | 214 +++++++++++++++--- package.json | 4 + server/portal_server.js | 65 +++--- server/storage.js | 176 +++++++------- .../download.handlebars | 16 ++ public/index.html => views/index.handlebars | 4 +- views/layouts/main.handlebars | 1 + 7 files changed, 331 insertions(+), 149 deletions(-) rename public/download.html => views/download.handlebars (68%) rename public/index.html => views/index.handlebars (95%) create mode 100644 views/layouts/main.handlebars diff --git a/package-lock.json b/package-lock.json index 15ee7454..d511dbb5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,16 @@ "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", "dev": true }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=" + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -79,6 +89,11 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "asap": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.5.tgz", + "integrity": "sha1-UidltQw1EEkOUtfc/ghe+bqWlY8=" + }, "asn1.js": { "version": "4.9.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", @@ -103,6 +118,11 @@ "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", "dev": true }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, "async-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", @@ -146,8 +166,7 @@ "balanced-match": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", - "dev": true + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=" }, "base64-js": { "version": "1.2.0", @@ -174,8 +193,7 @@ "brace-expansion": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", - "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", - "dev": true + "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=" }, "braces": { "version": "1.8.5", @@ -300,9 +318,9 @@ "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=" }, "bytes": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", - "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.5.0.tgz", + "integrity": "sha1-TJQj6i0lLCcMQbK97+/5u2tiwGo=" }, "cached-path-relative": { "version": "1.0.1", @@ -310,6 +328,18 @@ "integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=", "dev": true }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "optional": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "optional": true + }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -328,17 +358,29 @@ "integrity": "sha1-7qvxlEGc6QDaMBjCB9IS8qbfCgc=", "dev": true }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "optional": true, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "optional": true + } + } + }, "color-convert": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", - "dev": true + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=" }, "color-name": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.2.tgz", - "integrity": "sha1-XIq3K2S9IhXWF66VWeuxSEdc+Y0=", - "dev": true + "integrity": "sha1-XIq3K2S9IhXWF66VWeuxSEdc+Y0=" }, "combine-source-map": { "version": "0.7.2", @@ -349,8 +391,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { "version": "1.5.2", @@ -522,6 +563,17 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=" }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "optional": true + }, + "define-properties": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", + "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=" + }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", @@ -676,6 +728,18 @@ "resolved": "https://registry.npmjs.org/express/-/express-4.15.3.tgz", "integrity": "sha1-urZdDwOqgMNYQIly/HAPkWlEtmI=" }, + "express-handlebars": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-3.0.0.tgz", + "integrity": "sha1-gKBwu4GbCeSvLKbQeA91zgXnXC8=", + "dependencies": { + "glob": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=" + } + } + }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", @@ -717,6 +781,11 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true }, + "foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + }, "forwarded": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", @@ -1436,8 +1505,7 @@ "function-bind": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", - "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=", - "dev": true + "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=" }, "get-stdin": { "version": "5.0.1", @@ -1468,6 +1536,18 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, + "handlebars": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", + "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", + "dependencies": { + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=" + } + } + }, "has": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", @@ -1534,8 +1614,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=" }, "inherits": { "version": "2.0.3", @@ -1568,8 +1647,7 @@ "is-buffer": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", - "dev": true + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" }, "is-dotfile": { "version": "1.0.3", @@ -1710,8 +1788,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=" }, "labeled-stream-splicer": { "version": "2.0.0", @@ -1719,6 +1796,12 @@ "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", "dev": true }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "optional": true + }, "leven": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", @@ -1742,10 +1825,15 @@ "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" + }, "lru-cache": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.0.tgz", - "integrity": "sha512-aHGs865JXz6bkB4AHL+3AhyvTFKL3iZamKVWjIUKnXOXyasJvqPK8WAjOnAQKQZVpeXDVz19u1DD0r/12bWAdQ==", + "integrity": "sha1-Wb5JpoO42YapOfHKYP22mJ9LIEY=", "dev": true }, "media-typer": { @@ -1805,8 +1893,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=" }, "minimist": { "version": "1.2.0", @@ -1860,7 +1947,7 @@ "node-fetch": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz", - "integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ==" + "integrity": "sha1-iZyz0KPJL5UsR/G4dvTIrqvUANU=" }, "normalize-path": { "version": "2.1.1", @@ -1868,6 +1955,16 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true }, + "object-keys": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz", + "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=" + }, + "object.assign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.0.4.tgz", + "integrity": "sha1-scnMBE7xuf5jYG/BQau7MuFHMMw=" + }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", @@ -1882,8 +1979,19 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=" + } + } }, "os-browserify": { "version": "0.1.2", @@ -1940,8 +2048,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-parse": { "version": "1.0.5", @@ -2003,6 +2110,11 @@ "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, + "promise": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.1.1.tgz", + "integrity": "sha1-SJZUxpJha4qlWwck+oCbt9tJxb8=" + }, "proxy-addr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz", @@ -2157,8 +2269,7 @@ "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" }, "resolve": { "version": "1.3.3", @@ -2166,6 +2277,12 @@ "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", "dev": true }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "optional": true + }, "ripemd160": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", @@ -2237,8 +2354,7 @@ "source-map": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "dev": true + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" }, "statuses": { "version": "1.3.1", @@ -2444,6 +2560,18 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "uglify-js": { + "version": "2.8.28", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.28.tgz", + "integrity": "sha512-WqKNbmNJKzIdIEQu/U2ytgGBbhCy2PVks94GoetczOAJ/zCgVu2CuO7gguI5KPFGPtUtI1dmPQl6h0D4cPzypA==", + "optional": true + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "optional": true + }, "umd": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", @@ -2525,11 +2653,21 @@ "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", "dev": true }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "optional": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "xml2js": { "version": "0.4.17", @@ -2552,6 +2690,12 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "optional": true } } } diff --git a/package.json b/package.json index 885f6213..41934f48 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,12 @@ "dependencies": { "aws-sdk": "^2.62.0", "body-parser": "^1.17.2", + "bytes": "^2.5.0", + "color-convert": "^1.9.0", "connect-busboy": "0.0.2", "convict": "^3.0.0", "express": "^4.15.3", + "express-handlebars": "^3.0.0", "fs-extra": "^3.0.1", "node-fetch": "^1.7.1", "path": "^0.12.7", @@ -16,6 +19,7 @@ }, "devDependencies": { "browserify": "^14.4.0", + "buffer-shims": "^1.0.0", "cross-env": "^5.0.0", "prettier": "^1.3.1", "watchify": "^3.9.0" diff --git a/server/portal_server.js b/server/portal_server.js index bf70acc6..31329320 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -1,36 +1,50 @@ const express = require('express'); +const exphbs = require('express-handlebars'); const busboy = require('connect-busboy'); const path = require('path'); const fs = require('fs-extra'); const bodyParser = require('body-parser'); const crypto = require('crypto'); -const conf = require('./config.js'); const stream = require('stream'); const fetch = require('node-fetch'); +const bytes = require('bytes'); +const conf = require('./config.js'); const storage = require('./storage.js'); -let isProduction = +let notLocalHost = conf.env === 'production' && conf.s3_bucket !== 'localhost' && conf.bitly_key !== 'localhost'; -const AWS = require('aws-sdk'); -const s3 = new AWS.S3(); - const app = express(); -const redis = require('redis'); -const redis_client = redis.createClient(); -redis_client.on('error', err => { - console.log(err); -}); +app.engine('handlebars', exphbs({ defaultLayout: 'main' })); +app.set('view engine', 'handlebars'); app.use(busboy()); app.use(bodyParser.json()); + app.use(express.static(path.join(__dirname, '../public'))); +app.get('/', (req, res) => { + res.render('index'); +}); + app.get('/download/:id', (req, res) => { - res.sendFile(path.join(__dirname + '/../public/download.html')); + let id = req.params.id; + storage.filename(id).then(filename => { + storage + .length(id) + .then(contentLength => { + res.render('download', { + filename: filename, + filesize: bytes(contentLength) + }); + }) + .catch(() => { + res.render('download'); + }); + }); }); app.get('/assets/download/:id', (req, res) => { @@ -40,10 +54,9 @@ app.get('/assets/download/:id', (req, res) => { return; } - redis_client.hget(id, 'filename', (err, reply) => { - if (!reply) { - res.sendStatus(404); - } else { + storage + .filename(id) + .then(reply => { storage.length(id).then(contentLength => { res.writeHead(200, { 'Content-Disposition': 'attachment; filename=' + reply, @@ -54,8 +67,8 @@ app.get('/assets/download/:id', (req, res) => { let file_stream = storage.get(id); - file_stream.on('close', () => { - storage.forceDelete(id, redis_client).then(err => { + file_stream.on(notLocalHost ? 'finish' : 'close', () => { + storage.forceDelete(id).then(err => { if (!err) { console.log('Deleted.'); } @@ -63,8 +76,10 @@ app.get('/assets/download/:id', (req, res) => { }); file_stream.pipe(res); - } - }); + }) + .catch(err => { + res.sendStatus(404); + }); }); app.post('/delete/:id', (req, res) => { @@ -82,10 +97,10 @@ app.post('/delete/:id', (req, res) => { } storage - .delete(id, redis_client, delete_token) + .delete(id, delete_token) .then(err => { if (!err) { - console.log('Deleted off s3.'); + console.log('Deleted.'); } }) .catch(err => res.sendStatus(404)); @@ -102,11 +117,9 @@ app.post('/upload/:id', (req, res, next) => { console.log('Uploading: ' + filename); let url = `${req.protocol}://${req.get('host')}/download/${req.params.id}/`; - storage - .set(req.params.id, file, filename, redis_client, url) - .then(linkAndID => { - res.json(linkAndID); - }); + storage.set(req.params.id, file, filename, url).then(linkAndID => { + res.json(linkAndID); + }); }); }); diff --git a/server/storage.js b/server/storage.js index 21350318..2b72cb9c 100644 --- a/server/storage.js +++ b/server/storage.js @@ -7,30 +7,51 @@ const path = require('path'); const fetch = require('node-fetch'); const crypto = require('crypto'); -let isProduction = +const redis = require('redis'); +const redis_client = redis.createClient(); + +redis_client.on('error', err => { + console.log(err); +}); + +let notLocalhost = conf.env === 'production' && conf.s3_bucket !== 'localhost' && conf.bitly_key !== 'localhost'; -if (isProduction) { +if (notLocalhost) { module.exports = { - length: AWSLength, - get: AWSGet, - set: AWSSet, - delete: AWSDelete, - forceDelete: AWSForceDelete + filename: filename, + length: awsLength, + get: awsGet, + set: awsSet, + delete: awsDelete, + forceDelete: awsForceDelete }; } else { module.exports = { - length: LocalLength, - get: LocalGet, - set: LocalSet, - delete: LocalDelete, - forceDelete: LocalForceDelete + filename: filename, + length: localLength, + get: localGet, + set: localSet, + delete: localDelete, + forceDelete: localForceDelete }; } -function LocalLength(id) { +function filename(id) { + return new Promise((resolve, reject) => { + redis_client.hget(id, 'filename', (err, reply) => { + if (!err) { + resolve(reply); + } else { + reject(); + } + }); + }); +} + +function localLength(id) { return new Promise((resolve, reject) => { try { resolve(fs.statSync(__dirname + '/../static/' + id).size); @@ -40,69 +61,67 @@ function LocalLength(id) { }); } -function LocalGet(id) { +function localGet(id) { return fs.createReadStream(__dirname + '/../static/' + id); } -function LocalSet(id, file, filename, client, url) { +function localSet(id, file, filename, url) { return new Promise((resolve, reject) => { fstream = fs.createWriteStream(__dirname + '/../static/' + id); file.pipe(fstream); fstream.on('close', () => { let uuid = crypto.randomBytes(10).toString('hex'); - client.hmset([id, 'filename', filename, 'delete', uuid]); - client.expire(id, 86400000); + redis_client.hmset([id, 'filename', filename, 'delete', uuid]); + redis_client.expire(id, 86400000); console.log('Upload Finished of ' + filename); resolve({ uuid: uuid, url: url }); }); + + fstream.on('error', () => reject()); }); } -function LocalDelete(id, client, delete_token) { +function localDelete(id, delete_token) { return new Promise((resolve, reject) => { - client.hget(id, 'delete', (err, reply) => { + redis_client.hget(id, 'delete', (err, reply) => { if (!reply || delete_token !== reply) { - resolve( - new Promise((resolve, reject) => { - reject(); - }) - ); + reject(); } else { - resolve( - new Promise((resolve, reject) => { - client.del(id); - resolve(fs.unlinkSync(__dirname + '/../static/' + id)); - }) - ); + redis_client.del(id); + resolve(fs.unlinkSync(__dirname + '/../static/' + id)); } }); }); } -function LocalForceDelete(id, client) { +function localForceDelete(id) { return new Promise((resolve, reject) => { - client.del(id); + redis_client.del(id); resolve(fs.unlinkSync(__dirname + '/../static/' + id)); }); } -function AWSLength(id) { +function awsLength(id) { let params = { Bucket: conf.s3_bucket, Key: id }; return new Promise((resolve, reject) => { s3.headObject(params, function(err, data) { - resolve(data.ContentLength); + if (!err) { + resolve(data.ContentLength); + } else { + reject(); + } }); }); } -function AWSGet(id) { +function awsGet(id) { let params = { Bucket: conf.s3_bucket, Key: id @@ -111,7 +130,7 @@ function AWSGet(id) { return s3.getObject(params).createReadStream(); } -function AWSSet(id, file, filename, client, url) { +function awsSet(id, file, filename, url) { let params = { Bucket: conf.s3_bucket, Key: id, @@ -122,87 +141,72 @@ function AWSSet(id, file, filename, client, url) { s3.upload(params, function(err, data) { if (err) { console.log(err, err.stack); // an error occurred + reject(); } else { let uuid = crypto.randomBytes(10).toString('hex'); - client.hmset([id, 'filename', filename, 'delete', uuid]); + redis_client.hmset([id, 'filename', filename, 'delete', uuid]); - client.expire(id, 86400000); + redis_client.expire(id, 86400000); console.log('Upload Finished of ' + filename); - resolve( - new Promise((resolve, reject) => { - if (conf.bitly_key) { - fetch( - 'https://api-ssl.bitly.com/v3/shorten?access_token=' + - conf.bitly_key + - '&longUrl=' + - encodeURIComponent(url) + - '&format=txt' - ) - .then(res => { - return res.text(); - }) - .then(body => { - resolve({ - uuid: uuid, - url: body - }); - }); - } else { + if (conf.bitly_key) { + fetch( + 'https://api-ssl.bitly.com/v3/shorten?access_token=' + + conf.bitly_key + + '&longUrl=' + + encodeURIComponent(url) + + '&format=txt' + ) + .then(res => { + return res.text(); + }) + .then(body => { resolve({ uuid: uuid, - url: url + url: body }); - } - }) - ); + }); + } else { + resolve({ + uuid: uuid, + url: url + }); + } } }); }); } -function AWSDelete(id, client, delete_token) { +function awsDelete(id, delete_token) { return new Promise((resolve, reject) => { - client.hget(id, 'delete', (err, reply) => { + redis_client.hget(id, 'delete', (err, reply) => { if (!reply || delete_token !== reply) { - resolve( - new Promise((resolve, reject) => { - reject(); - }) - ); + reject(); } else { - client.del(id); + redis_client.del(id); let params = { Bucket: conf.s3_bucket, Key: id }; - resolve( - new Promise((resolve, reject) => { - s3.deleteObject(params, function(err, data) { - resolve(err); - }); - }) - ); + s3.deleteObject(params, function(err, data) { + resolve(err); + }); } }); }); } -function AWSForceDelete(id, client) { +function awsForceDelete(id) { return new Promise((resolve, reject) => { - client.del(id); + redis_client.del(id); let params = { Bucket: conf.s3_bucket, Key: id }; - resolve( - new Promise((resolve, reject) => { - s3.deleteObject(params, function(err, data) { - resolve(err); - }); - }) - ); + s3.deleteObject(params, function(err, data) { + resolve(err); + }); }); } diff --git a/public/download.html b/views/download.handlebars similarity index 68% rename from public/download.html rename to views/download.handlebars index 513d3c96..516172c3 100644 --- a/public/download.html +++ b/views/download.handlebars @@ -11,9 +11,13 @@
+ {{#if filename}}
Your friend is sending you a file:
+ + {{{filename}}} ({{{filesize}}}) +
diff --git a/public/index.html b/views/index.handlebars similarity index 95% rename from public/index.html rename to views/index.handlebars index 128d3a95..d44e98e0 100644 --- a/public/index.html +++ b/views/index.handlebars @@ -3,9 +3,9 @@ Firefox Fileshare - + - + diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars new file mode 100644 index 00000000..4839ad4c --- /dev/null +++ b/views/layouts/main.handlebars @@ -0,0 +1 @@ +{{{body}}} \ No newline at end of file