Remove closeOpenSessionForDevice from protocol_wrapper
// FREEBIE
This commit is contained in:
parent
0d5ec60a7a
commit
0483fa2f97
5 changed files with 50 additions and 42 deletions
|
@ -35493,11 +35493,6 @@ Internal.SessionLock.queueJobForNumber = function queueJobForNumber(number, runJ
|
||||||
|
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
window.textsecure.protocol_wrapper = {
|
window.textsecure.protocol_wrapper = {
|
||||||
closeOpenSessionForDevice: function(encodedNumber) {
|
|
||||||
return queueJobForNumber(encodedNumber, function() {
|
|
||||||
return protocolInstance.closeOpenSessionForDevice(encodedNumber);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
startWorker: function() {
|
startWorker: function() {
|
||||||
protocolInstance.startWorker('/js/libsignal-protocol-worker.js');
|
protocolInstance.startWorker('/js/libsignal-protocol-worker.js');
|
||||||
},
|
},
|
||||||
|
@ -37338,8 +37333,11 @@ MessageReceiver.prototype.extend({
|
||||||
console.log('got end session');
|
console.log('got end session');
|
||||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
||||||
return Promise.all(devices.map(function(device) {
|
return Promise.all(devices.map(function(device) {
|
||||||
console.log('closing session for', device.encodedNumber);
|
var address = new libsignal.SignalProtocolAddress(number, device.deviceId);
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||||
|
|
||||||
|
console.log('closing session for', address.toString());
|
||||||
|
return sessionCipher.closeOpenSessionForDevice();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -37552,7 +37550,14 @@ OutgoingMessage.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
doSendMessage: function(number, devicesForNumber, recurse) {
|
doSendMessage: function(number, devicesForNumber, recurse) {
|
||||||
return this.encryptToDevices(devicesForNumber).then(function(jsonData) {
|
var ciphers = {};
|
||||||
|
var plaintext = this.message.toArrayBuffer();
|
||||||
|
return Promise.all(devicesForNumber.map(function(device) {
|
||||||
|
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
|
||||||
|
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||||
|
ciphers[address.getDeviceId()] = sessionCipher;
|
||||||
|
return this.encryptToDevice(device, plaintext, sessionCipher);
|
||||||
|
}.bind(this))).then(function(jsonData) {
|
||||||
return this.transmitMessage(number, jsonData, this.timestamp).then(function() {
|
return this.transmitMessage(number, jsonData, this.timestamp).then(function() {
|
||||||
this.successfulNumbers[this.successfulNumbers.length] = number;
|
this.successfulNumbers[this.successfulNumbers.length] = number;
|
||||||
this.numberCompleted();
|
this.numberCompleted();
|
||||||
|
@ -37567,7 +37572,7 @@ OutgoingMessage.prototype = {
|
||||||
p = textsecure.storage.devices.removeDeviceIdsForNumber(number, error.response.extraDevices);
|
p = textsecure.storage.devices.removeDeviceIdsForNumber(number, error.response.extraDevices);
|
||||||
} else {
|
} else {
|
||||||
p = Promise.all(error.response.staleDevices.map(function(deviceId) {
|
p = Promise.all(error.response.staleDevices.map(function(deviceId) {
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(number + '.' + deviceId);
|
return ciphers[deviceId].closeOpenSessionForDevice();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37585,17 +37590,13 @@ OutgoingMessage.prototype = {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
encryptToDevices: function(deviceObjectList) {
|
encryptToDevice: function(device, plaintext, sessionCipher) {
|
||||||
var plaintext = this.message.toArrayBuffer();
|
return Promise.all([
|
||||||
return Promise.all(deviceObjectList.map(function(device) {
|
sessionCipher.encrypt(plaintext),
|
||||||
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
|
sessionCipher.getRemoteRegistrationId()
|
||||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
]).then(function(result) {
|
||||||
return sessionCipher.encrypt(plaintext).then(function(encryptedMsg) {
|
return this.toJSON(device, result[0], result[1]);
|
||||||
return sessionCipher.getRemoteRegistrationId().then(function(registrationId) {
|
}.bind(this));
|
||||||
return this.toJSON(device, encryptedMsg, registrationId);
|
|
||||||
}.bind(this));
|
|
||||||
}.bind(this));
|
|
||||||
}.bind(this)));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON: function(device, encryptedMsg, registrationId) {
|
toJSON: function(device, encryptedMsg, registrationId) {
|
||||||
|
@ -37930,7 +37931,10 @@ MessageSender.prototype = {
|
||||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
||||||
return Promise.all(devices.map(function(device) {
|
return Promise.all(devices.map(function(device) {
|
||||||
console.log('closing session for', device.encodedNumber);
|
console.log('closing session for', device.encodedNumber);
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
|
||||||
|
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
|
||||||
|
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||||
|
return sessionCipher.closeOpenSessionForDevice();
|
||||||
})).then(function() {
|
})).then(function() {
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
|
|
@ -345,8 +345,11 @@ MessageReceiver.prototype.extend({
|
||||||
console.log('got end session');
|
console.log('got end session');
|
||||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
||||||
return Promise.all(devices.map(function(device) {
|
return Promise.all(devices.map(function(device) {
|
||||||
console.log('closing session for', device.encodedNumber);
|
var address = new libsignal.SignalProtocolAddress(number, device.deviceId);
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||||
|
|
||||||
|
console.log('closing session for', address.toString());
|
||||||
|
return sessionCipher.closeOpenSessionForDevice();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -96,7 +96,14 @@ OutgoingMessage.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
doSendMessage: function(number, devicesForNumber, recurse) {
|
doSendMessage: function(number, devicesForNumber, recurse) {
|
||||||
return this.encryptToDevices(devicesForNumber).then(function(jsonData) {
|
var ciphers = {};
|
||||||
|
var plaintext = this.message.toArrayBuffer();
|
||||||
|
return Promise.all(devicesForNumber.map(function(device) {
|
||||||
|
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
|
||||||
|
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||||
|
ciphers[address.getDeviceId()] = sessionCipher;
|
||||||
|
return this.encryptToDevice(device, plaintext, sessionCipher);
|
||||||
|
}.bind(this))).then(function(jsonData) {
|
||||||
return this.transmitMessage(number, jsonData, this.timestamp).then(function() {
|
return this.transmitMessage(number, jsonData, this.timestamp).then(function() {
|
||||||
this.successfulNumbers[this.successfulNumbers.length] = number;
|
this.successfulNumbers[this.successfulNumbers.length] = number;
|
||||||
this.numberCompleted();
|
this.numberCompleted();
|
||||||
|
@ -111,7 +118,7 @@ OutgoingMessage.prototype = {
|
||||||
p = textsecure.storage.devices.removeDeviceIdsForNumber(number, error.response.extraDevices);
|
p = textsecure.storage.devices.removeDeviceIdsForNumber(number, error.response.extraDevices);
|
||||||
} else {
|
} else {
|
||||||
p = Promise.all(error.response.staleDevices.map(function(deviceId) {
|
p = Promise.all(error.response.staleDevices.map(function(deviceId) {
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(number + '.' + deviceId);
|
return ciphers[deviceId].closeOpenSessionForDevice();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,17 +136,13 @@ OutgoingMessage.prototype = {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
encryptToDevices: function(deviceObjectList) {
|
encryptToDevice: function(device, plaintext, sessionCipher) {
|
||||||
var plaintext = this.message.toArrayBuffer();
|
return Promise.all([
|
||||||
return Promise.all(deviceObjectList.map(function(device) {
|
sessionCipher.encrypt(plaintext),
|
||||||
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
|
sessionCipher.getRemoteRegistrationId()
|
||||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
]).then(function(result) {
|
||||||
return sessionCipher.encrypt(plaintext).then(function(encryptedMsg) {
|
return this.toJSON(device, result[0], result[1]);
|
||||||
return sessionCipher.getRemoteRegistrationId().then(function(registrationId) {
|
}.bind(this));
|
||||||
return this.toJSON(device, encryptedMsg, registrationId);
|
|
||||||
}.bind(this));
|
|
||||||
}.bind(this));
|
|
||||||
}.bind(this)));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON: function(device, encryptedMsg, registrationId) {
|
toJSON: function(device, encryptedMsg, registrationId) {
|
||||||
|
|
|
@ -28,11 +28,6 @@
|
||||||
|
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
window.textsecure.protocol_wrapper = {
|
window.textsecure.protocol_wrapper = {
|
||||||
closeOpenSessionForDevice: function(encodedNumber) {
|
|
||||||
return queueJobForNumber(encodedNumber, function() {
|
|
||||||
return protocolInstance.closeOpenSessionForDevice(encodedNumber);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
startWorker: function() {
|
startWorker: function() {
|
||||||
protocolInstance.startWorker('/js/libsignal-protocol-worker.js');
|
protocolInstance.startWorker('/js/libsignal-protocol-worker.js');
|
||||||
},
|
},
|
||||||
|
|
|
@ -298,7 +298,10 @@ MessageSender.prototype = {
|
||||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
||||||
return Promise.all(devices.map(function(device) {
|
return Promise.all(devices.map(function(device) {
|
||||||
console.log('closing session for', device.encodedNumber);
|
console.log('closing session for', device.encodedNumber);
|
||||||
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
|
||||||
|
var address = libsignal.SignalProtocolAddress.fromString(device.encodedNumber);
|
||||||
|
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||||
|
return sessionCipher.closeOpenSessionForDevice();
|
||||||
})).then(function() {
|
})).then(function() {
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue