Handle identity errors on decrypt

Previously we only expected these errors to occur when decrypting prekey
messages, so we need to add handling for them in the case of a normal message.

// FREEBIE
This commit is contained in:
lilia 2017-06-01 11:45:03 -07:00 committed by Scott Nonnenberg
parent 1eec94dbb7
commit 6fdd0f1625
2 changed files with 20 additions and 0 deletions

View file

@ -38354,6 +38354,16 @@ MessageReceiver.prototype.extend({
promise = Promise.reject(new Error("Unknown message type"));
}
return promise.catch(function(error) {
if (error.message === 'Unknown identity key') {
// create an error that the UI will pick up and ask the
// user if they want to re-negotiate
var buffer = dcodeIO.ByteBuffer.wrap(ciphertext);
error = new textsecure.IncomingIdentityKeyError(
address.toString(),
buffer.toArrayBuffer(),
error.identityKey
);
}
var ev = new Event('error');
ev.error = error;
ev.proto = envelope;

View file

@ -149,6 +149,16 @@ MessageReceiver.prototype.extend({
promise = Promise.reject(new Error("Unknown message type"));
}
return promise.catch(function(error) {
if (error.message === 'Unknown identity key') {
// create an error that the UI will pick up and ask the
// user if they want to re-negotiate
var buffer = dcodeIO.ByteBuffer.wrap(ciphertext);
error = new textsecure.IncomingIdentityKeyError(
address.toString(),
buffer.toArrayBuffer(),
error.identityKey
);
}
var ev = new Event('error');
ev.error = error;
ev.proto = envelope;