From d11f9fd53805e1ba69a43c8d25eb5b421549f49e Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 11 Aug 2016 18:13:26 -0700 Subject: [PATCH] Update libsignal-protocol v1.1.4 // FREEBIE --- js/libtextsecure.js | 28 +++++++++++++++++----------- libtextsecure/libsignal-protocol.js | 13 +++++++++++-- libtextsecure/outgoing_message.js | 15 ++++++--------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index a1beee97..03b83bab 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -36248,9 +36248,18 @@ SessionCipher.prototype = { preKeyMsg.message = message; var result = String.fromCharCode((3 << 4) | 3) + util.toString(preKeyMsg.encode()); - return {type: 3, body: result}; + return { + type : 3, + body : result, + registrationId : record.registrationId + }; + } else { - return {type: 1, body: util.toString(message)}; + return { + type : 1, + body : util.toString(message), + registrationId : record.registrationId + }; } }); }.bind(this)); @@ -38581,19 +38590,16 @@ OutgoingMessage.prototype = { }, encryptToDevice: function(address, plaintext, sessionCipher) { - return Promise.all([ - sessionCipher.encrypt(plaintext), - sessionCipher.getRemoteRegistrationId() - ]).then(function(result) { - return this.toJSON(address, result[0], result[1]); + return sessionCipher.encrypt(plaintext).then(function(ciphertext) { + return this.toJSON(address, ciphertext); }.bind(this)); }, - toJSON: function(address, encryptedMsg, registrationId) { + toJSON: function(address, encryptedMsg) { var json = { - type: encryptedMsg.type, - destinationDeviceId: address.getDeviceId(), - destinationRegistrationId: registrationId + type : encryptedMsg.type, + destinationDeviceId : address.getDeviceId(), + destinationRegistrationId : encryptedMsg.registrationId }; var content = btoa(encryptedMsg.body); diff --git a/libtextsecure/libsignal-protocol.js b/libtextsecure/libsignal-protocol.js index 414ad594..4671f7ca 100644 --- a/libtextsecure/libsignal-protocol.js +++ b/libtextsecure/libsignal-protocol.js @@ -36124,9 +36124,18 @@ SessionCipher.prototype = { preKeyMsg.message = message; var result = String.fromCharCode((3 << 4) | 3) + util.toString(preKeyMsg.encode()); - return {type: 3, body: result}; + return { + type : 3, + body : result, + registrationId : record.registrationId + }; + } else { - return {type: 1, body: util.toString(message)}; + return { + type : 1, + body : util.toString(message), + registrationId : record.registrationId + }; } }); }.bind(this)); diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index a618cf0e..95a0e154 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -157,19 +157,16 @@ OutgoingMessage.prototype = { }, encryptToDevice: function(address, plaintext, sessionCipher) { - return Promise.all([ - sessionCipher.encrypt(plaintext), - sessionCipher.getRemoteRegistrationId() - ]).then(function(result) { - return this.toJSON(address, result[0], result[1]); + return sessionCipher.encrypt(plaintext).then(function(ciphertext) { + return this.toJSON(address, ciphertext); }.bind(this)); }, - toJSON: function(address, encryptedMsg, registrationId) { + toJSON: function(address, encryptedMsg) { var json = { - type: encryptedMsg.type, - destinationDeviceId: address.getDeviceId(), - destinationRegistrationId: registrationId + type : encryptedMsg.type, + destinationDeviceId : address.getDeviceId(), + destinationRegistrationId : encryptedMsg.registrationId }; var content = btoa(encryptedMsg.body);