Integrate libsignal.SessionCipher
Bypass the old protocolInstance wrapper methods and use the shiny new SessionCipher class directly. // FREEBIE
This commit is contained in:
parent
b19ec6c05b
commit
e68031019b
2 changed files with 20 additions and 8 deletions
|
@ -35434,9 +35434,11 @@ libsignal.SessionCipher = function(storage, remoteAddress) {
|
|||
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.protocol_wrapper = {
|
||||
decryptWhisperMessage: function(fromAddress, blob) {
|
||||
decryptWhisperMessage: function(fromAddress, message) {
|
||||
return queueJobForNumber(fromAddress, function() {
|
||||
return protocolInstance.decryptWhisperMessage(fromAddress, blob.toArrayBuffer());
|
||||
var address = libsignal.SignalProtocolAddress.fromString(fromAddress);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.decryptWhisperMessage(message.toArrayBuffer());
|
||||
});
|
||||
},
|
||||
closeOpenSessionForDevice: function(encodedNumber) {
|
||||
|
@ -35446,7 +35448,9 @@ libsignal.SessionCipher = function(storage, remoteAddress) {
|
|||
},
|
||||
encryptMessageFor: function(deviceObject, pushMessageContent) {
|
||||
return queueJobForNumber(deviceObject.encodedNumber, function() {
|
||||
return protocolInstance.encryptMessageFor(deviceObject, pushMessageContent);
|
||||
var address = libsignal.SignalProtocolAddress.fromString(deviceObject.encodedNumber);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.encrypt(pushMessageContent);
|
||||
});
|
||||
},
|
||||
startWorker: function() {
|
||||
|
@ -35477,7 +35481,9 @@ libsignal.SessionCipher = function(storage, remoteAddress) {
|
|||
throw new Error("Incompatible version byte");
|
||||
}
|
||||
return queueJobForNumber(from, function() {
|
||||
return protocolInstance.handlePreKeyWhisperMessage(from, blob).catch(function(e) {
|
||||
var address = libsignal.SignalProtocolAddress.fromString(from);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.decryptPreKeyWhisperMessage(blob).catch(function(e) {
|
||||
if (e.message === 'Unknown identity key') {
|
||||
blob.reset(); // restore the version byte.
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@
|
|||
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.protocol_wrapper = {
|
||||
decryptWhisperMessage: function(fromAddress, blob) {
|
||||
decryptWhisperMessage: function(fromAddress, message) {
|
||||
return queueJobForNumber(fromAddress, function() {
|
||||
return protocolInstance.decryptWhisperMessage(fromAddress, blob.toArrayBuffer());
|
||||
var address = libsignal.SignalProtocolAddress.fromString(fromAddress);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.decryptWhisperMessage(message.toArrayBuffer());
|
||||
});
|
||||
},
|
||||
closeOpenSessionForDevice: function(encodedNumber) {
|
||||
|
@ -40,7 +42,9 @@
|
|||
},
|
||||
encryptMessageFor: function(deviceObject, pushMessageContent) {
|
||||
return queueJobForNumber(deviceObject.encodedNumber, function() {
|
||||
return protocolInstance.encryptMessageFor(deviceObject, pushMessageContent);
|
||||
var address = libsignal.SignalProtocolAddress.fromString(deviceObject.encodedNumber);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.encrypt(pushMessageContent);
|
||||
});
|
||||
},
|
||||
startWorker: function() {
|
||||
|
@ -71,7 +75,9 @@
|
|||
throw new Error("Incompatible version byte");
|
||||
}
|
||||
return queueJobForNumber(from, function() {
|
||||
return protocolInstance.handlePreKeyWhisperMessage(from, blob).catch(function(e) {
|
||||
var address = libsignal.SignalProtocolAddress.fromString(from);
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.decryptPreKeyWhisperMessage(blob).catch(function(e) {
|
||||
if (e.message === 'Unknown identity key') {
|
||||
blob.reset(); // restore the version byte.
|
||||
|
||||
|
|
Loading…
Reference in a new issue