From 605863ffa35a3f79194df2cee33d866d604815f5 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 14 May 2014 02:08:01 -0400 Subject: [PATCH] Fix decryption of large messages (eg w/ attachments) --- js/helpers.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/helpers.js b/js/helpers.js index 18c4aca5a..42381a1ff 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -95,7 +95,7 @@ function base64EncArr (aBytes) { *** Type conversion utilities *** *********************************/ function intToArrayBuffer(nInt) { - var res = new ArrayBuffer(4); + var res = new ArrayBuffer(16); var thing = new Uint8Array(res); thing[0] = (nInt >> 24) & 0xff; thing[1] = (nInt >> 16) & 0xff; @@ -461,12 +461,13 @@ function subscribeToPush(message_callback) { // b) we should handle them gracefully and tell the user they received an invalid message console.log("Successfully decoded message with id: " + message.id); socket.send(JSON.stringify({type: 1, id: message.id})); - crypto.handleIncomingPushMessageProto(proto).then(function(decrypted) { + return crypto.handleIncomingPushMessageProto(proto).then(function(decrypted) { storeMessage(decrypted); message_callback(decrypted); - }); // Decrypts/decodes/fills in fields/etc + }) }).catch(function(e) { - console.log("Error decoding message: " + e); + console.log("Error handling incoming message: "); + console.log(e); }); } };