SessionRecord: Once again serialize/deserialize within libsignal

This commit is contained in:
Scott Nonnenberg 2019-10-30 12:04:39 -07:00
parent b659ddc68c
commit fd5af8bb62
3 changed files with 20 additions and 14 deletions

View File

@ -329,7 +329,7 @@
const session = this.sessions[encodedNumber];
if (session) {
return libsignal.SessionRecord.deserialize(session.record);
return session.record;
}
return undefined;
@ -346,7 +346,7 @@
id: encodedNumber,
number,
deviceId,
record: record.serialize(),
record,
};
this.sessions[encodedNumber] = data;

View File

@ -35766,8 +35766,6 @@ Internal.SessionRecord = function() {
return SessionRecord;
}();
libsignal.SessionRecord = Internal.SessionRecord;
function SignalProtocolAddress(name, deviceId) {
this.name = name;
this.deviceId = deviceId;
@ -35846,15 +35844,18 @@ SessionBuilder.prototype = {
});
}.bind(this)).then(function(session) {
var address = this.remoteAddress.toString();
return this.storage.loadSession(address).then(function(record) {
if (record === undefined) {
return this.storage.loadSession(address).then(function(serialized) {
var record;
if (serialized !== undefined) {
record = Internal.SessionRecord.deserialize(serialized);
} else {
record = new Internal.SessionRecord();
}
record.archiveCurrentState();
record.updateSessionState(session);
return Promise.all([
this.storage.storeSession(address, record),
this.storage.storeSession(address, record.serialize()),
this.storage.saveIdentity(this.remoteAddress.toString(), device.identityKey)
]);
}.bind(this));
@ -36038,7 +36039,12 @@ function SessionCipher(storage, remoteAddress) {
SessionCipher.prototype = {
getRecord: function(encodedNumber) {
return this.storage.loadSession(encodedNumber);
return this.storage.loadSession(encodedNumber).then(function(serialized) {
if (serialized === undefined) {
return undefined;
}
return Internal.SessionRecord.deserialize(serialized);
});
},
// encoding is an optional parameter - wrap() will only translate if one is provided
encrypt: function(buffer, encoding) {
@ -36118,7 +36124,7 @@ SessionCipher.prototype = {
return this.storage.saveIdentity(this.remoteAddress.toString(), theirIdentityKey);
}.bind(this)).then(function() {
record.updateSessionState(session);
return this.storage.storeSession(address, record).then(function() {
return this.storage.storeSession(address, record.serialize()).then(function() {
return result;
});
}.bind(this));
@ -36205,7 +36211,7 @@ SessionCipher.prototype = {
return this.storage.saveIdentity(this.remoteAddress.toString(), result.session.indexInfo.remoteIdentityKey);
}.bind(this)).then(function() {
record.updateSessionState(result.session);
return this.storage.storeSession(address, record).then(function() {
return this.storage.storeSession(address, record.serialize()).then(function() {
return result.plaintext;
});
}.bind(this));
@ -36240,7 +36246,7 @@ SessionCipher.prototype = {
preKeyProto.message.toArrayBuffer(), session
).then(function(plaintext) {
record.updateSessionState(session);
return this.storage.storeSession(address, record).then(function() {
return this.storage.storeSession(address, record.serialize()).then(function() {
if (preKeyId !== undefined && preKeyId !== null) {
return this.storage.removePreKey(preKeyId);
}
@ -36438,7 +36444,7 @@ SessionCipher.prototype = {
}
record.archiveCurrentState();
return this.storage.storeSession(address, record);
return this.storage.storeSession(address, record.serialize());
}.bind(this));
}.bind(this));
},
@ -36452,7 +36458,7 @@ SessionCipher.prototype = {
}
record.deleteAllSessions();
return this.storage.storeSession(address, record);
return this.storage.storeSession(address, record.serialize());
}.bind(this));
}.bind(this));
}

View File

@ -301,7 +301,7 @@
"rule": "jQuery-load(",
"path": "js/signal_protocol_store.js",
"line": " await ConversationController.load();",
"lineNumber": 908,
"lineNumber": 894,
"reasonCategory": "falseMatch",
"updated": "2018-09-15T00:38:04.183Z"
},