|
|
|
@ -34608,7 +34608,7 @@ window.libsignal.protocol = function(storage_interface) {
|
|
|
|
|
throw new Error("Expected plaintext to be an ArrayBuffer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ourIdentityKey, myRegistrationId, record, session, hadSession;
|
|
|
|
|
var ourIdentityKey, myRegistrationId, record, session;
|
|
|
|
|
return Promise.all([
|
|
|
|
|
storage_interface.getIdentityKeyPair(),
|
|
|
|
|
storage_interface.getLocalRegistrationId(),
|
|
|
|
@ -34617,29 +34617,13 @@ window.libsignal.protocol = function(storage_interface) {
|
|
|
|
|
ourIdentityKey = results[0];
|
|
|
|
|
myRegistrationId = results[1];
|
|
|
|
|
record = results[2];
|
|
|
|
|
if (record) {
|
|
|
|
|
session = record.getOpenSession();
|
|
|
|
|
if (!record) {
|
|
|
|
|
throw new Error("No record for " + deviceObject.encodedNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hadSession = session !== undefined;
|
|
|
|
|
|
|
|
|
|
if (session === undefined) {
|
|
|
|
|
var address = SignalProtocolAddress.fromString(deviceObject.encodedNumber);
|
|
|
|
|
var builder = new SessionBuilder(storage_interface, address);
|
|
|
|
|
|
|
|
|
|
return builder.processPreKey(deviceObject);
|
|
|
|
|
session = record.getOpenSession();
|
|
|
|
|
if (!session) {
|
|
|
|
|
throw new Error("No session to encrypt message for " + deviceObject.encodedNumber);
|
|
|
|
|
}
|
|
|
|
|
}).then(function() {
|
|
|
|
|
return getRecord(deviceObject.encodedNumber).then(function(refreshed) {
|
|
|
|
|
record = refreshed;
|
|
|
|
|
if (!record) {
|
|
|
|
|
throw new Error("No record for " + deviceObject.encodedNumber);
|
|
|
|
|
}
|
|
|
|
|
session = record.getOpenSession();
|
|
|
|
|
if (!session) {
|
|
|
|
|
throw new Error("No session to encrypt message for " + deviceObject.encodedNumber);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}).then(function doEncryptPushMessageContent() {
|
|
|
|
|
var msg = new Internal.protobuf.WhisperMessage();
|
|
|
|
|
|
|
|
|
@ -35208,7 +35192,7 @@ SessionBuilder.prototype = {
|
|
|
|
|
record.updateSessionState(session, device.registrationId);
|
|
|
|
|
return Promise.all([
|
|
|
|
|
this.storage.storeSession(address, record.serialize()),
|
|
|
|
|
this.storage.putIdentityKey(address, record.identityKey)
|
|
|
|
|
this.storage.putIdentityKey(this.remoteAddress.getName(), record.identityKey)
|
|
|
|
|
]);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}.bind(this));
|
|
|
|
@ -35268,7 +35252,7 @@ SessionBuilder.prototype = {
|
|
|
|
|
// end of decryptWhisperMessage ... to ensure that the sender
|
|
|
|
|
// actually holds the private keys for all reported pubkeys
|
|
|
|
|
record.updateSessionState(new_session, message.registrationId);
|
|
|
|
|
return this.storage.putIdentityKey(this.remoteAddress.toString(), message.identityKey.toArrayBuffer()).then(function() {
|
|
|
|
|
return this.storage.putIdentityKey(this.remoteAddress.getName(), message.identityKey.toArrayBuffer()).then(function() {
|
|
|
|
|
return message.preKeyId;
|
|
|
|
|
});
|
|
|
|
|
}.bind(this));
|
|
|
|
|