Naively move device/session storage to wrapper

This commit is contained in:
Matt Corallo 2015-01-20 19:46:41 -10:00 committed by lilia
parent 870e5dc9dc
commit 04b2a13a75
2 changed files with 13 additions and 4 deletions

View file

@ -69,7 +69,7 @@ window.axolotl.protocol = function() {
} }
crypto_storage.saveSession = function(encodedNumber, session, registrationId) { 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) if (device === undefined)
device = { sessions: {}, encodedNumber: encodedNumber }; device = { sessions: {}, encodedNumber: encodedNumber };
@ -119,11 +119,11 @@ window.axolotl.protocol = function() {
delete device['registrationId']; delete device['registrationId'];
} catch(_) {} } catch(_) {}
textsecure.storage.devices.saveDeviceObject(device); axolotl.api.storage.sessions.put(device);
} }
var getSessions = function(encodedNumber) { 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) if (device === undefined || device.sessions === undefined)
return undefined; return undefined;
return device.sessions; return device.sessions;
@ -165,7 +165,7 @@ window.axolotl.protocol = function() {
crypto_storage.getSessionOrIdentityKeyByBaseKey = function(encodedNumber, baseKey) { crypto_storage.getSessionOrIdentityKeyByBaseKey = function(encodedNumber, baseKey) {
var sessions = getSessions(encodedNumber); var sessions = getSessions(encodedNumber);
var device = textsecure.storage.devices.getDeviceObject(encodedNumber); var device = axolotl.api.storage.sessions.get(encodedNumber);
if (device === undefined) if (device === undefined)
return undefined; return undefined;

View file

@ -24,6 +24,15 @@
remove: function(key) { remove: function(key) {
return textsecure.storage.removeEncrypted(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) { updateKeys: function(keys) {
return textsecure.api.registerKeys(keys).catch(function(e) { return textsecure.api.registerKeys(keys).catch(function(e) {