From bace117ada440e14a40c22f070ae40a1b85ab803 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 11 Jan 2018 23:20:56 -0800 Subject: [PATCH] fixed error on metadata 404 --- app/fileReceiver.js | 7 ++++++- app/templates/preview.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/fileReceiver.js b/app/fileReceiver.js index 4fc742ac..0766f71e 100644 --- a/app/fileReceiver.js +++ b/app/fileReceiver.js @@ -6,7 +6,7 @@ export default class FileReceiver extends Nanobus { super('FileReceiver'); this.secretKeyPromise = window.crypto.subtle.importKey( 'raw', - b64ToArray(file.key), + b64ToArray(file.secretKey), 'HKDF', false, ['deriveKey'] @@ -122,6 +122,9 @@ export default class FileReceiver extends Nanobus { const xhr = new XMLHttpRequest(); xhr.onreadystatechange = () => { if (xhr.readyState === XMLHttpRequest.DONE) { + if (xhr.status === 404) { + return reject(new Error(xhr.status)); + } const nonce = xhr.getResponseHeader('WWW-Authenticate').split(' ')[1]; this.file.nonce = nonce; if (xhr.status === 200) { @@ -172,6 +175,8 @@ export default class FileReceiver extends Nanobus { this.file.iv = meta.iv; this.file.size = data.size; this.file.ttl = data.ttl; + this.file.dlimit = data.dlimit; + this.file.dtotal = data.dtotal; this.state = 'ready'; } catch (e) { this.state = 'invalid'; diff --git a/app/templates/preview.js b/app/templates/preview.js index e5485a8e..63b1ae2a 100644 --- a/app/templates/preview.js +++ b/app/templates/preview.js @@ -21,7 +21,7 @@ module.exports = function(state, emit) { return notFound(state, emit); } state.fileInfo.id = state.params.id; - state.fileInfo.key = state.params.key; + state.fileInfo.secretKey = state.params.key; const fileInfo = state.fileInfo; const size = fileInfo.size ? state.translate('downloadFileSize', { size: bytes(fileInfo.size) })