From 67f586b65cf957203bb4f6ab22a487b352fd56af Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 29 Jun 2017 10:30:08 -0700 Subject: [PATCH] format --- frontend/src/fileReceiver.js | 4 +-- frontend/src/fileSender.js | 49 +++++++++++++++++++++++------------- frontend/src/utils.js | 1 - server/log.js | 2 +- server/portal_server.js | 8 +++--- server/storage.js | 8 +++--- 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js index 29d07784..db3f1515 100644 --- a/frontend/src/fileReceiver.js +++ b/frontend/src/fileReceiver.js @@ -1,8 +1,6 @@ const EventEmitter = require('events'); const { hexToArray } = require('./utils'); -const Raven = window.Raven; - class FileReceiver extends EventEmitter { constructor() { super(); @@ -34,7 +32,7 @@ class FileReceiver extends EventEmitter { const blob = new Blob([this.response]); const fileReader = new FileReader(); fileReader.onload = function() { - const meta = JSON.parse(xhr.getResponseHeader('X-File-Metadata')) + const meta = JSON.parse(xhr.getResponseHeader('X-File-Metadata')); resolve({ data: this.result, aad: meta.aad, diff --git a/frontend/src/fileSender.js b/frontend/src/fileSender.js index 837dfbd0..cbcbd76d 100644 --- a/frontend/src/fileSender.js +++ b/frontend/src/fileSender.js @@ -38,14 +38,18 @@ class FileSender extends EventEmitter { upload() { return Promise.all([ - window.crypto.subtle.generateKey( - { - name: 'AES-GCM', - length: 128 - }, - true, - ['encrypt', 'decrypt'] - ).catch(err => console.log('There was an error generating a crypto key')), + window.crypto.subtle + .generateKey( + { + name: 'AES-GCM', + length: 128 + }, + true, + ['encrypt', 'decrypt'] + ) + .catch(err => + console.log('There was an error generating a crypto key') + ), new Promise((resolve, reject) => { const reader = new FileReader(); reader.readAsArrayBuffer(this.file); @@ -56,15 +60,17 @@ class FileSender extends EventEmitter { ]) .then(([secretKey, plaintext]) => { return Promise.all([ - window.crypto.subtle.encrypt( - { - name: 'AES-GCM', - iv: this.iv, - additionalData: this.aad - }, - secretKey, - plaintext - ).catch(err => console.log('Error with encrypting.')), + window.crypto.subtle + .encrypt( + { + name: 'AES-GCM', + iv: this.iv, + additionalData: this.aad + }, + secretKey, + plaintext + ) + .catch(err => console.log('Error with encrypting.')), window.crypto.subtle.exportKey('jwk', secretKey) ]); }) @@ -100,7 +106,14 @@ class FileSender extends EventEmitter { }; xhr.open('post', '/upload/' + fileId, true); - xhr.setRequestHeader('X-File-Metadata', JSON.stringify({ aad: arrayToHex(this.aad), iv: fileId, filename: file.name })) + xhr.setRequestHeader( + 'X-File-Metadata', + JSON.stringify({ + aad: arrayToHex(this.aad), + iv: fileId, + filename: file.name + }) + ); xhr.send(fd); }); }) diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 39f058ca..2e6400ce 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -20,7 +20,6 @@ function hexToArray(str) { return iv; } - function notify(str) { if (!('Notification' in window)) { return; diff --git a/server/log.js b/server/log.js index 0042b6bc..27919e8d 100644 --- a/server/log.js +++ b/server/log.js @@ -1,6 +1,6 @@ const conf = require('./config.js'); -const isProduction = conf.env === 'production' +const isProduction = conf.env === 'production'; const mozlog = require('mozlog')({ app: 'FirefoxFileshare', diff --git a/server/portal_server.js b/server/portal_server.js index 9685ac14..8439675f 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -78,10 +78,10 @@ app.get('/assets/download/:id', (req, res) => { return; } - storage.metadata(id) + storage + .metadata(id) .then(meta => { storage.length(id).then(contentLength => { - res.writeHead(200, { 'Content-Disposition': 'attachment; filename=' + meta.filename, 'Content-Type': 'application/octet-stream', @@ -142,7 +142,7 @@ app.post('/upload/:id', (req, res, next) => { return; } const meta = JSON.parse(req.header('X-File-Metadata')); - log.info('meta', meta) + log.info('meta', meta); req.pipe(req.busboy); req.busboy.on('file', (fieldname, file, filename) => { @@ -157,8 +157,6 @@ app.post('/upload/:id', (req, res, next) => { }); }); }); - - }); app.get('/__lbheartbeat__', (req, res) => { diff --git a/server/storage.js b/server/storage.js index ce912186..2d37e163 100644 --- a/server/storage.js +++ b/server/storage.js @@ -58,8 +58,8 @@ function metadata(id) { } else { reject(err); } - }) - }) + }); + }); } function filename(id) { @@ -98,8 +98,8 @@ function aad(id) { } else { reject(); } - }) - }) + }); + }); } function localLength(id) {