diff --git a/js/libtextsecure.js b/js/libtextsecure.js index e56c84ad..715d9df7 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37442,7 +37442,7 @@ window.axolotl.protocol = function(storage_interface) { // Inits a session (maybe) and then decrypts the message self.handlePreKeyWhisperMessage = function(from, encodedMessage) { - var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage, 'binary'); + var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage); return initSessionFromPreKeyWhisperMessage(from, preKeyProto).then(function(sessions) { return doDecryptWhisperMessage(from, axolotlInternal.utils.convertToString(preKeyProto.message), sessions[0], preKeyProto.registrationId).then(function(result) { if (sessions[1] !== undefined) @@ -37784,19 +37784,6 @@ axolotlInternal.RecipientRecord = function() { textsecure.storage.axolotl = new AxolotlStore(); var axolotlInstance = axolotl.protocol(textsecure.storage.axolotl); - var handlePreKeyWhisperMessage = function(from, message) { - try { - return axolotlInstance.handlePreKeyWhisperMessage(from, message); - } catch(e) { - if (e.message === 'Unknown identity key') { - // create an error that the UI will pick up and ask the - // user if they want to re-negotiate - throw new textsecure.IncomingIdentityKeyError(from, message); - } - throw e; - } - }; - window.textsecure = window.textsecure || {}; window.textsecure.protocol_wrapper = { decrypt: function(source, sourceDevice, type, blob) { @@ -37808,7 +37795,15 @@ axolotlInternal.RecipientRecord = function() { case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE: if (blob.readUint8() != ((3 << 4) | 3)) throw new Error("Bad version byte"); - return handlePreKeyWhisperMessage(fromAddress, getString(blob)); + var blob = blob.toArrayBuffer(); + return axolotlInstance.handlePreKeyWhisperMessage(fromAddress, blob).catch(function(e) { + if (e.message === 'Unknown identity key') { + // create an error that the UI will pick up and ask the + // user if they want to re-negotiate + throw new textsecure.IncomingIdentityKeyError(fromAddress, blob); + } + throw e; + }); default: return new Promise.reject(new Error("Unknown message type")); } diff --git a/libtextsecure/axolotl_wrapper.js b/libtextsecure/axolotl_wrapper.js index cafb69eb..63116b13 100644 --- a/libtextsecure/axolotl_wrapper.js +++ b/libtextsecure/axolotl_wrapper.js @@ -5,19 +5,6 @@ textsecure.storage.axolotl = new AxolotlStore(); var axolotlInstance = axolotl.protocol(textsecure.storage.axolotl); - var handlePreKeyWhisperMessage = function(from, message) { - try { - return axolotlInstance.handlePreKeyWhisperMessage(from, message); - } catch(e) { - if (e.message === 'Unknown identity key') { - // create an error that the UI will pick up and ask the - // user if they want to re-negotiate - throw new textsecure.IncomingIdentityKeyError(from, message); - } - throw e; - } - }; - window.textsecure = window.textsecure || {}; window.textsecure.protocol_wrapper = { decrypt: function(source, sourceDevice, type, blob) { @@ -29,7 +16,15 @@ case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE: if (blob.readUint8() != ((3 << 4) | 3)) throw new Error("Bad version byte"); - return handlePreKeyWhisperMessage(fromAddress, getString(blob)); + var blob = blob.toArrayBuffer(); + return axolotlInstance.handlePreKeyWhisperMessage(fromAddress, blob).catch(function(e) { + if (e.message === 'Unknown identity key') { + // create an error that the UI will pick up and ask the + // user if they want to re-negotiate + throw new textsecure.IncomingIdentityKeyError(fromAddress, blob); + } + throw e; + }); default: return new Promise.reject(new Error("Unknown message type")); } diff --git a/libtextsecure/libaxolotl.js b/libtextsecure/libaxolotl.js index 73d57759..0049b036 100644 --- a/libtextsecure/libaxolotl.js +++ b/libtextsecure/libaxolotl.js @@ -37365,7 +37365,7 @@ window.axolotl.protocol = function(storage_interface) { // Inits a session (maybe) and then decrypts the message self.handlePreKeyWhisperMessage = function(from, encodedMessage) { - var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage, 'binary'); + var preKeyProto = axolotlInternal.protobuf.PreKeyWhisperMessage.decode(encodedMessage); return initSessionFromPreKeyWhisperMessage(from, preKeyProto).then(function(sessions) { return doDecryptWhisperMessage(from, axolotlInternal.utils.convertToString(preKeyProto.message), sessions[0], preKeyProto.registrationId).then(function(result) { if (sessions[1] !== undefined)