From 73e69fe5ebf25c46d2a5a663bc889f2b9b44d8a5 Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 5 Oct 2016 22:01:52 +0900 Subject: [PATCH] Update libsignal-protocol 1.1.7 --- js/libtextsecure.js | 21 ++++++++++++++++++--- libtextsecure/libsignal-protocol.js | 21 ++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 3ee30e82..cf93ec91 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -35665,7 +35665,12 @@ Internal.SessionRecord = function() { } else if (thing === Object(thing)) { var obj = {}; for (var key in thing) { - obj[key] = ensureStringed(thing[key]); + try { + obj[key] = ensureStringed(thing[key]); + } catch (ex) { + console.log('Error serializing key', key); + throw ex; + } } return obj; } else if (thing === null) { @@ -35684,12 +35689,21 @@ Internal.SessionRecord = function() { version: 'v1', migrate: function migrateV1(data) { var sessions = data.sessions; + var key; if (data.registrationId) { - for (var key in sessions) { + for (key in sessions) { if (!sessions[key].registrationId) { sessions[key].registrationId = data.registrationId; } } + } else { + for (key in sessions) { + if (sessions[key].indexInfo.closed === -1) { + console.log('V1 session storage migration error: registrationId', + data.registrationId, 'for open session version', + data.version); + } + } } } } @@ -35734,7 +35748,8 @@ Internal.SessionRecord = function() { }); }, haveOpenSession: function() { - return this.getOpenSession() !== undefined; + var openSession = this.getOpenSession(); + return (!!openSession && !!openSession.registrationId); }, getSessionByBaseKey: function(baseKey) { diff --git a/libtextsecure/libsignal-protocol.js b/libtextsecure/libsignal-protocol.js index a66b8338..01a48808 100644 --- a/libtextsecure/libsignal-protocol.js +++ b/libtextsecure/libsignal-protocol.js @@ -35541,7 +35541,12 @@ Internal.SessionRecord = function() { } else if (thing === Object(thing)) { var obj = {}; for (var key in thing) { - obj[key] = ensureStringed(thing[key]); + try { + obj[key] = ensureStringed(thing[key]); + } catch (ex) { + console.log('Error serializing key', key); + throw ex; + } } return obj; } else if (thing === null) { @@ -35560,12 +35565,21 @@ Internal.SessionRecord = function() { version: 'v1', migrate: function migrateV1(data) { var sessions = data.sessions; + var key; if (data.registrationId) { - for (var key in sessions) { + for (key in sessions) { if (!sessions[key].registrationId) { sessions[key].registrationId = data.registrationId; } } + } else { + for (key in sessions) { + if (sessions[key].indexInfo.closed === -1) { + console.log('V1 session storage migration error: registrationId', + data.registrationId, 'for open session version', + data.version); + } + } } } } @@ -35610,7 +35624,8 @@ Internal.SessionRecord = function() { }); }, haveOpenSession: function() { - return this.getOpenSession() !== undefined; + var openSession = this.getOpenSession(); + return (!!openSession && !!openSession.registrationId); }, getSessionByBaseKey: function(baseKey) {