diff --git a/.stylelintrc b/.stylelintrc
index 3c593e83..c0c673c7 100644
--- a/.stylelintrc
+++ b/.stylelintrc
@@ -1,6 +1,6 @@
extends: stylelint-config-standard
rules:
- color-hex-case: upper
+ color-hex-case: lower
declaration-colon-newline-after: null
selector-list-comma-newline-after: null
diff --git a/frontend/src/common.js b/frontend/src/common.js
index 82d7e35b..5fa712a3 100644
--- a/frontend/src/common.js
+++ b/frontend/src/common.js
@@ -7,4 +7,4 @@ window.analytics = new testPilotGA({
an: 'Firefox Send',
ds: 'web',
tid: window.trackerId
-})
+});
diff --git a/frontend/src/download.js b/frontend/src/download.js
index 033335a6..21db9ccb 100644
--- a/frontend/src/download.js
+++ b/frontend/src/download.js
@@ -18,12 +18,10 @@ $(document).ready(function() {
target.preventDefault();
sendEvent('recipient', 'restarted', {
cd2: 'completed'
- })
- .then(() => {
+ }).then(() => {
location.href = target.currentTarget.href;
});
- })
-
+ });
$('.legal-links a, .social-links a, #dl-firefox').click(function(target) {
target.preventDefault();
@@ -31,15 +29,14 @@ $(document).ready(function() {
// record exited event by recipient
sendEvent('recipient', 'exited', {
cd3: metric
- })
- .then(() => {
+ }).then(() => {
location.href = target.currentTarget.href;
});
- })
+ });
$('#expired-send-new').click(function() {
storage.referrer = 'errored-download';
- })
+ });
const filename = $('#dl-filename').html();
const bytelength = Number($('#dl-bytelength').text());
@@ -60,9 +57,7 @@ $(document).ready(function() {
const fileReceiver = new FileReceiver();
const unexpiredFiles = storage.numFiles;
-
fileReceiver.on('progress', progress => {
-
window.onunload = function() {
storage.referrer = 'cancelled-download';
// record download-stopped (cancelled by tab close or reload)
@@ -72,8 +67,8 @@ $(document).ready(function() {
cm6: unexpiredFiles,
cm7: storage.totalDownloads,
cd2: 'cancelled'
- })
- }
+ });
+ };
$('#download-page-one').attr('hidden', true);
$('#download-progress').removeAttr('hidden');
@@ -81,15 +76,21 @@ $(document).ready(function() {
// update progress bar
$('#dl-progress').circleProgress('value', percent);
$('.percent-number').html(`${Math.floor(percent * 100)}`);
- $('.progress-text').text(`${filename} (${bytes(progress[0], {decimalPlaces: 1, fixedDecimals: true})} of ${bytes(progress[1], {decimalPlaces: 1})})`);
+ $('.progress-text').text(
+ `${filename} (${bytes(progress[0], {
+ decimalPlaces: 1,
+ fixedDecimals: true
+ })} of ${bytes(progress[1], { decimalPlaces: 1 })})`
+ );
//on complete
if (percent === 1) {
fileReceiver.removeAllListeners('progress');
- document.l10n.formatValues('downloadNotification', 'downloadFinish')
- .then(translated => {
- notify(translated[0]);
- $('.title').html(translated[1]);
- });
+ document.l10n
+ .formatValues('downloadNotification', 'downloadFinish')
+ .then(translated => {
+ notify(translated[0]);
+ $('.title').html(translated[1]);
+ });
window.onunload = null;
}
});
@@ -138,10 +139,9 @@ $(document).ready(function() {
cd6: err
});
- document.l10n.formatValue('expiredPageHeader')
- .then(translated => {
- $('.title').text(translated);
- });
+ document.l10n.formatValue('expiredPageHeader').then(translated => {
+ $('.title').text(translated);
+ });
$('#download-btn').attr('hidden', true);
$('#expired-img').removeAttr('hidden');
console.log('The file has expired, or has already been deleted.');
diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js
index 155a8dd9..ad1611df 100644
--- a/frontend/src/fileReceiver.js
+++ b/frontend/src/fileReceiver.js
@@ -58,41 +58,46 @@ class FileReceiver extends EventEmitter {
true,
['encrypt', 'decrypt']
)
- ]).then(([fdata, key]) => {
- this.emit('decrypting', true);
- return Promise.all([
- window.crypto.subtle.decrypt(
- {
- name: 'AES-GCM',
- iv: hexToArray(fdata.iv),
- additionalData: hexToArray(fdata.aad)
- },
- key,
- fdata.data
- ).then(decrypted => {
- this.emit('decrypting', false);
- return Promise.resolve(decrypted)
- }),
- fdata.filename,
- hexToArray(fdata.aad)
- ]);
- }).then(([decrypted, fname, proposedHash]) => {
- this.emit('hashing', true);
- return window.crypto.subtle.digest('SHA-256', decrypted).then(calculatedHash => {
- this.emit('hashing', false);
- const integrity = new Uint8Array(calculatedHash).toString() === proposedHash.toString();
- if (!integrity) {
- this.emit('unsafe', true)
- return Promise.reject();
- } else {
- this.emit('safe', true);
- return Promise.all([
- decrypted,
- decodeURIComponent(fname)
- ]);
- }
+ ])
+ .then(([fdata, key]) => {
+ this.emit('decrypting', true);
+ return Promise.all([
+ window.crypto.subtle
+ .decrypt(
+ {
+ name: 'AES-GCM',
+ iv: hexToArray(fdata.iv),
+ additionalData: hexToArray(fdata.aad)
+ },
+ key,
+ fdata.data
+ )
+ .then(decrypted => {
+ this.emit('decrypting', false);
+ return Promise.resolve(decrypted);
+ }),
+ fdata.filename,
+ hexToArray(fdata.aad)
+ ]);
})
- })
+ .then(([decrypted, fname, proposedHash]) => {
+ this.emit('hashing', true);
+ return window.crypto.subtle
+ .digest('SHA-256', decrypted)
+ .then(calculatedHash => {
+ this.emit('hashing', false);
+ const integrity =
+ new Uint8Array(calculatedHash).toString() ===
+ proposedHash.toString();
+ if (!integrity) {
+ this.emit('unsafe', true);
+ return Promise.reject();
+ } else {
+ this.emit('safe', true);
+ return Promise.all([decrypted, decodeURIComponent(fname)]);
+ }
+ });
+ });
}
}
diff --git a/frontend/src/storage.js b/frontend/src/storage.js
index c7a9aa85..c95d93a6 100644
--- a/frontend/src/storage.js
+++ b/frontend/src/storage.js
@@ -2,9 +2,9 @@ const { isFile } = require('./utils');
class Storage {
constructor(engine) {
- this.engine = engine
+ this.engine = engine;
}
-
+
get totalDownloads() {
return Number(this.engine.getItem('totalDownloads'));
}
@@ -23,7 +23,7 @@ class Storage {
set referrer(str) {
this.engine.setItem('referrer', str);
}
-
+
get files() {
const fs = [];
for (let i = 0; i < this.engine.length; i++) {
@@ -49,7 +49,7 @@ class Storage {
getFileById(id) {
return this.engine.getItem(id);
}
-
+
has(property) {
return this.engine.hasOwnProperty(property);
}
@@ -57,10 +57,10 @@ class Storage {
remove(property) {
this.engine.removeItem(property);
}
-
+
addFile(id, file) {
this.engine.setItem(id, JSON.stringify(file));
}
}
-module.exports = Storage;
\ No newline at end of file
+module.exports = Storage;
diff --git a/frontend/src/upload.js b/frontend/src/upload.js
index b4f535f9..e836d297 100644
--- a/frontend/src/upload.js
+++ b/frontend/src/upload.js
@@ -1,7 +1,13 @@
/* global MAXFILESIZE */
require('./common');
const FileSender = require('./fileSender');
-const { notify, gcmCompliant, findMetric, sendEvent, ONE_DAY_IN_MS } = require('./utils');
+const {
+ notify,
+ gcmCompliant,
+ findMetric,
+ sendEvent,
+ ONE_DAY_IN_MS
+} = require('./utils');
const bytes = require('bytes');
const Storage = require('./storage');
const storage = new Storage(localStorage);
@@ -19,15 +25,13 @@ if (storage.has('referrer')) {
}
$(document).ready(function() {
-
- gcmCompliant()
- .catch(err => {
- $('#page-one').attr('hidden', true);
- $('#unsupported-browser').removeAttr('hidden');
- // record unsupported event
- sendEvent('sender', 'unsupported', {
- cd6: err
- });
+ gcmCompliant().catch(err => {
+ $('#page-one').attr('hidden', true);
+ $('#unsupported-browser').removeAttr('hidden');
+ // record unsupported event
+ sendEvent('sender', 'unsupported', {
+ cd6: err
+ });
});
$('#file-upload').change(onUpload);
@@ -38,35 +42,32 @@ $(document).ready(function() {
// record exited event by recipient
sendEvent('sender', 'exited', {
cd3: metric
- })
- .then(() => {
+ }).then(() => {
location.href = target.currentTarget.href;
});
- })
+ });
$('#send-new-completed').click(function(target) {
target.preventDefault();
// record restarted event
sendEvent('sender', 'restarted', {
cd2: 'completed'
- })
- .then(() => {
+ }).then(() => {
storage.referrer = 'completed-upload';
location.href = target.currentTarget.href;
});
- })
+ });
$('#send-new-error').click(function(target) {
target.preventDefault();
// record restarted event
sendEvent('sender', 'restarted', {
cd2: 'errored'
- })
- .then(() => {
+ }).then(() => {
storage.referrer = 'errored-upload';
location.href = target.currentTarget.href;
});
- })
+ });
$('body').on('dragover', allowDrop).on('drop', onUpload);
// reset copy button
@@ -87,7 +88,6 @@ $(document).ready(function() {
}
}
-
// copy link to clipboard
$copyBtn.click(() => {
// record copied event from success screen
@@ -103,7 +103,9 @@ $(document).ready(function() {
//disable button for 3s
$copyBtn.attr('disabled', true);
$('#link').attr('disabled', true);
- $copyBtn.html('');
+ $copyBtn.html(
+ '
'
+ );
window.setTimeout(() => {
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
@@ -137,12 +139,14 @@ $(document).ready(function() {
let file = '';
if (event.type === 'drop') {
- if (event.originalEvent.dataTransfer.files.length > 1 || event.originalEvent.dataTransfer.files[0].size === 0){
+ if (
+ event.originalEvent.dataTransfer.files.length > 1 ||
+ event.originalEvent.dataTransfer.files[0].size === 0
+ ) {
$('.upload-window').removeClass('ondrag');
- document.l10n.formatValue('uploadPageMultipleFilesAlert')
- .then(str => {
- alert(str);
- });
+ document.l10n.formatValue('uploadPageMultipleFilesAlert').then(str => {
+ alert(str);
+ });
return;
}
file = event.originalEvent.dataTransfer.files[0];
@@ -151,7 +155,9 @@ $(document).ready(function() {
}
if (file.size > MAXFILESIZE) {
- return document.l10n.formatValue('fileTooBig', {size: bytes(MAXFILESIZE)}).then(alert);
+ return document.l10n
+ .formatValue('fileTooBig', { size: bytes(MAXFILESIZE) })
+ .then(alert);
}
$('#page-one').attr('hidden', true);
@@ -165,10 +171,9 @@ $(document).ready(function() {
$('#cancel-upload').click(() => {
fileSender.cancel();
location.reload();
- document.l10n.formatValue('uploadCancelNotification')
- .then(str => {
- notify(str);
- });
+ document.l10n.formatValue('uploadCancelNotification').then(str => {
+ notify(str);
+ });
storage.referrer = 'cancelled-upload';
// record upload-stopped (cancelled) by sender
@@ -189,7 +194,12 @@ $(document).ready(function() {
$('#ul-progress').circleProgress().on('circle-animation-end', function() {
$('.percent-number').html(`${Math.floor(percent * 100)}`);
});
- $('.progress-text').text(`${file.name} (${bytes(progress[0], {decimalPlaces: 1, fixedDecimals: true})} of ${bytes(progress[1], {decimalPlaces: 1})})`);
+ $('.progress-text').text(
+ `${file.name} (${bytes(progress[0], {
+ decimalPlaces: 1,
+ fixedDecimals: true
+ })} of ${bytes(progress[1], { decimalPlaces: 1 })})`
+ );
});
fileSender.on('loading', isStillLoading => {
@@ -245,15 +255,15 @@ $(document).ready(function() {
// record upload-stopped (completed) by sender
sendEvent('sender', 'upload-stopped', {
- cm1: file.size,
- cm2: totalTime,
- cm3: uploadSpeed,
- cm5: storage.totalUploads,
- cm6: unexpiredFiles,
- cm7: storage.totalDownloads,
- cd1: event.type === 'drop' ? 'drop' : 'click',
- cd2: 'completed'
- });
+ cm1: file.size,
+ cm2: totalTime,
+ cm3: uploadSpeed,
+ cm5: storage.totalUploads,
+ cm6: unexpiredFiles,
+ cm7: storage.totalDownloads,
+ cd1: event.type === 'drop' ? 'drop' : 'click',
+ cd2: 'completed'
+ });
const fileData = {
name: file.name,
@@ -270,7 +280,10 @@ $(document).ready(function() {
};
storage.addFile(info.fileId, fileData);
- $('#upload-filename').attr('data-l10n-id', 'uploadSuccessConfirmHeader');
+ $('#upload-filename').attr(
+ 'data-l10n-id',
+ 'uploadSuccessConfirmHeader'
+ );
t = window.setTimeout(() => {
$('#page-one').attr('hidden', true);
$('#upload-progress').attr('hidden', true);
@@ -279,10 +292,9 @@ $(document).ready(function() {
}, 1000);
populateFileList(fileData);
- document.l10n.formatValue('notifyUploadDone')
- .then(str => {
- notify(str);
- });
+ document.l10n.formatValue('notifyUploadDone').then(str => {
+ notify(str);
+ });
})
.catch(err => {
Raven.captureException(err);
@@ -334,10 +346,18 @@ $(document).ready(function() {
const row = document.createElement('tr');
const name = document.createElement('td');
const link = document.createElement('td');
- const $copyIcon = $('
', { src: '/resources/copy-16.svg', class: 'icon-copy', 'data-l10n-id': 'copyUrlHover'});
+ const $copyIcon = $('
', {
+ src: '/resources/copy-16.svg',
+ class: 'icon-copy',
+ 'data-l10n-id': 'copyUrlHover'
+ });
const expiry = document.createElement('td');
const del = document.createElement('td');
- const $delIcon = $('
', { src: '/resources/close-16.svg', class: 'icon-delete', 'data-l10n-id': 'deleteButtonHover' });
+ const $delIcon = $('
', {
+ src: '/resources/close-16.svg',
+ class: 'icon-delete',
+ 'data-l10n-id': 'deleteButtonHover'
+ });
const popupDiv = document.createElement('div');
const $popupText = $('