From 04b2a13a759ccd7eac99d4bad8a018d0686327b6 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 20 Jan 2015 19:46:41 -1000 Subject: [PATCH] Naively move device/session storage to wrapper --- libaxolotl/protocol.js | 8 ++++---- libtextsecure/axolotl_wrapper.js | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libaxolotl/protocol.js b/libaxolotl/protocol.js index ccd5c01b..625250e5 100644 --- a/libaxolotl/protocol.js +++ b/libaxolotl/protocol.js @@ -69,7 +69,7 @@ window.axolotl.protocol = function() { } crypto_storage.saveSession = function(encodedNumber, session, registrationId) { - var device = textsecure.storage.devices.getDeviceObject(encodedNumber); + var device = axolotl.api.storage.sessions.get(encodedNumber); if (device === undefined) device = { sessions: {}, encodedNumber: encodedNumber }; @@ -119,11 +119,11 @@ window.axolotl.protocol = function() { delete device['registrationId']; } catch(_) {} - textsecure.storage.devices.saveDeviceObject(device); + axolotl.api.storage.sessions.put(device); } var getSessions = function(encodedNumber) { - var device = textsecure.storage.devices.getDeviceObject(encodedNumber); + var device = axolotl.api.storage.sessions.get(encodedNumber); if (device === undefined || device.sessions === undefined) return undefined; return device.sessions; @@ -165,7 +165,7 @@ window.axolotl.protocol = function() { crypto_storage.getSessionOrIdentityKeyByBaseKey = function(encodedNumber, baseKey) { var sessions = getSessions(encodedNumber); - var device = textsecure.storage.devices.getDeviceObject(encodedNumber); + var device = axolotl.api.storage.sessions.get(encodedNumber); if (device === undefined) return undefined; diff --git a/libtextsecure/axolotl_wrapper.js b/libtextsecure/axolotl_wrapper.js index 9108fdf5..09cdf5ee 100644 --- a/libtextsecure/axolotl_wrapper.js +++ b/libtextsecure/axolotl_wrapper.js @@ -24,6 +24,15 @@ remove: function(key) { return textsecure.storage.removeEncrypted(key); }, + + sessions: { + get: function(identifier) { + return textsecure.storage.devices.getDeviceObject(identifier); + }, + put: function(object) { + return textsecure.storage.devices.saveDeviceObject(object); + } + } }, updateKeys: function(keys) { return textsecure.api.registerKeys(keys).catch(function(e) {