factored out progress into progress.js

This commit is contained in:
Danny Coates 2017-08-05 18:06:43 -07:00
parent 5ac013ca40
commit c91d24cd86
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
12 changed files with 229 additions and 240 deletions

View file

@ -62,7 +62,7 @@ class FileReceiver extends EventEmitter {
});
})
.then(([fdata, key]) => {
this.emit('decrypting', true);
this.emit('decrypting');
return Promise.all([
window.crypto.subtle
.decrypt(
@ -76,7 +76,6 @@ class FileReceiver extends EventEmitter {
fdata.data
)
.then(decrypted => {
this.emit('decrypting', false);
return Promise.resolve(decrypted);
}),
fdata.filename,
@ -84,11 +83,10 @@ class FileReceiver extends EventEmitter {
]);
})
.then(([decrypted, fname, proposedHash]) => {
this.emit('hashing', true);
this.emit('hashing');
return window.crypto.subtle
.digest('SHA-256', decrypted)
.then(calculatedHash => {
this.emit('hashing', false);
const integrity =
new Uint8Array(calculatedHash).toString() ===
proposedHash.toString();