diff --git a/js/signal_protocol_store.js b/js/signal_protocol_store.js index 332174b7e4..4bd51060ec 100644 --- a/js/signal_protocol_store.js +++ b/js/signal_protocol_store.js @@ -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; diff --git a/libtextsecure/libsignal-protocol.js b/libtextsecure/libsignal-protocol.js index 7c24517e69..d9549ad123 100644 --- a/libtextsecure/libsignal-protocol.js +++ b/libtextsecure/libsignal-protocol.js @@ -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)); } diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index 37eff25a8d..754acc3619 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -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" },