Remove processPreKey from protocol_wrapper

Use SessionBuilder directly instead of protocol_wrapper

// FREEBIE
This commit is contained in:
lilia 2016-05-01 14:46:16 -07:00
parent 843036f0ce
commit 891ddacd35
4 changed files with 10 additions and 18 deletions

View file

@ -35541,13 +35541,6 @@ Internal.SessionLock.queueJobForNumber = function queueJobForNumber(number, runJ
throw e;
});
});
},
processPreKey: function(preKeyBundle) {
return queueJobForNumber(preKeyBundle.encodedNumber, function() {
var address = libsignal.SignalProtocolAddress.fromString(preKeyBundle.encodedNumber);
var builder = new libsignal.SessionBuilder(textsecure.storage.protocol, address);
return builder.processPreKey(preKeyBundle);
});
}
};
})();
@ -37527,7 +37520,9 @@ OutgoingMessage.prototype = {
device.identityKey = response.identityKey;
device.encodedNumber = number + "." + device.deviceId;
if (updateDevices === undefined || updateDevices.indexOf(device.deviceId) > -1) {
return textsecure.protocol_wrapper.processPreKey(device).catch(function(error) {
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
var builder = new libsignal.SessionBuilder(textsecure.storage.protocol, address);
return builder.processPreKey(device).catch(function(error) {
if (error.message === "Identity key changed") {
error = new textsecure.OutgoingIdentityKeyError(
number, this.message.toArrayBuffer(),

View file

@ -55,7 +55,9 @@ OutgoingMessage.prototype = {
device.identityKey = response.identityKey;
device.encodedNumber = number + "." + device.deviceId;
if (updateDevices === undefined || updateDevices.indexOf(device.deviceId) > -1) {
return textsecure.protocol_wrapper.processPreKey(device).catch(function(error) {
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
var builder = new libsignal.SessionBuilder(textsecure.storage.protocol, address);
return builder.processPreKey(device).catch(function(error) {
if (error.message === "Identity key changed") {
error = new textsecure.OutgoingIdentityKeyError(
number, this.message.toArrayBuffer(),

View file

@ -76,13 +76,6 @@
throw e;
});
});
},
processPreKey: function(preKeyBundle) {
return queueJobForNumber(preKeyBundle.encodedNumber, function() {
var address = libsignal.SignalProtocolAddress.fromString(preKeyBundle.encodedNumber);
var builder = new libsignal.SessionBuilder(textsecure.storage.protocol, address);
return builder.processPreKey(preKeyBundle);
});
}
};
})();

View file

@ -18,9 +18,11 @@ describe('Protocol Wrapper', function() {
});
describe('processPreKey', function() {
it('rejects if the identity key changes', function(done) {
return textsecure.protocol_wrapper.processPreKey({
var address = new libsignal.SignalProtocolAddress(identifier, 1);
var builder = new libsignal.SessionBuilder(store, address);
return builder.processPreKey({
identityKey: textsecure.crypto.getRandomBytes(33),
encodedNumber: identifier + '.1'
encodedNumber: address.toString()
}).then(function() {
done(new Error('Allowed to overwrite identity key'));
}).catch(function(e) {