Update libsignal-protocol
// FREEBIE
This commit is contained in:
parent
6fd438951c
commit
519d3ec31b
2 changed files with 16 additions and 48 deletions
|
@ -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));
|
||||
|
|
|
@ -34494,7 +34494,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(),
|
||||
|
@ -34503,29 +34503,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();
|
||||
|
||||
|
@ -35094,7 +35078,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));
|
||||
|
@ -35154,7 +35138,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));
|
||||
|
|
Loading…
Reference in a new issue