Rename axolotl storage

// FREEBIE
This commit is contained in:
lilia 2016-04-22 13:39:05 -07:00
parent ee3bc11e3c
commit 1d60dc38fb
13 changed files with 66 additions and 66 deletions

View file

@ -16,14 +16,14 @@
window.textsecure.storage.devices = {
saveKeysToDeviceObject: function(deviceObject) {
var number = textsecure.utils.unencodeNumber(deviceObject.encodedNumber)[0];
return textsecure.storage.axolotl.loadIdentityKey(number).then(function(identityKey) {
return textsecure.storage.protocol.loadIdentityKey(number).then(function(identityKey) {
if (identityKey !== undefined && deviceObject.identityKey !== undefined && getString(identityKey) != getString(deviceObject.identityKey)) {
var error = new Error("Identity key changed");
error.identityKey = deviceObject.identityKey;
throw error;
}
return textsecure.storage.axolotl.putIdentityKey(number, deviceObject.identityKey).then(function() {
return textsecure.storage.protocol.putIdentityKey(number, deviceObject.identityKey).then(function() {
tempKeys[deviceObject.encodedNumber] = {
preKey: deviceObject.preKey,
preKeyId: deviceObject.preKeyId,
@ -42,7 +42,7 @@
},
getStaleDeviceIdsForNumber: function(number) {
return textsecure.storage.axolotl.getDeviceIds(number).then(function(deviceIds) {
return textsecure.storage.protocol.getDeviceIds(number).then(function(deviceIds) {
if (deviceIds.length === 0) {
return [1];
}
@ -60,11 +60,11 @@
});
},
getDeviceObjectsForNumber: function(number) {
return textsecure.storage.axolotl.loadIdentityKey(number).then(function(identityKey) {
return textsecure.storage.protocol.loadIdentityKey(number).then(function(identityKey) {
if (identityKey === undefined) {
return [];
}
return textsecure.storage.axolotl.getDeviceIds(number).then(function(deviceIds) {
return textsecure.storage.protocol.getDeviceIds(number).then(function(deviceIds) {
// Add pending devices from tempKeys
for (var encodedNumber in tempKeys) {
var deviceNumber = textsecure.utils.unencodeNumber(encodedNumber)[0];
@ -95,7 +95,7 @@
promise = promise.then(function() {
var encodedNumber = number + "." + deviceIdsToRemove[j];
delete tempKeys[encodedNumber];
return textsecure.storage.axolotl.removeSession(encodedNumber);
return textsecure.storage.protocol.removeSession(encodedNumber);
});
}
return promise;

View file

@ -14,7 +14,7 @@
// create a random group id that we haven't seen before.
function generateNewGroupId() {
var groupId = getString(textsecure.crypto.getRandomBytes(16));
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined) {
return groupId;
} else {
@ -29,7 +29,7 @@
var groupId = groupId;
return new Promise(function(resolve) {
if (groupId !== undefined) {
resolve(textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
resolve(textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group !== undefined) {
throw new Error("Tried to recreate group");
}
@ -60,14 +60,14 @@
for (var i in finalNumbers)
groupObject.numberRegistrationIds[finalNumbers[i]] = {};
return textsecure.storage.axolotl.putGroup(groupId, groupObject).then(function() {
return textsecure.storage.protocol.putGroup(groupId, groupObject).then(function() {
return {id: groupId, numbers: finalNumbers};
});
});
},
getNumbers: function(groupId) {
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined)
return undefined;
@ -76,7 +76,7 @@
},
removeNumber: function(groupId, number) {
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined)
return undefined;
@ -88,7 +88,7 @@
if (i > -1) {
group.numbers.splice(i, 1);
delete group.numberRegistrationIds[number];
return textsecure.storage.axolotl.putGroup(groupId, group).then(function() {
return textsecure.storage.protocol.putGroup(groupId, group).then(function() {
return group.numbers;
});
}
@ -98,7 +98,7 @@
},
addNumbers: function(groupId, numbers) {
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined)
return undefined;
@ -112,18 +112,18 @@
}
}
return textsecure.storage.axolotl.putGroup(groupId, group).then(function() {
return textsecure.storage.protocol.putGroup(groupId, group).then(function() {
return group.numbers;
});
});
},
deleteGroup: function(groupId) {
return textsecure.storage.axolotl.removeGroup(groupId);
return textsecure.storage.protocol.removeGroup(groupId);
},
getGroup: function(groupId) {
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined)
return undefined;
@ -132,7 +132,7 @@
},
updateNumbers: function(groupId, numbers) {
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined)
throw new Error("Tried to update numbers for unknown group");
@ -156,7 +156,7 @@
},
needUpdateByDeviceRegistrationId: function(groupId, number, encodedNumber, registrationId) {
return textsecure.storage.axolotl.getGroup(groupId).then(function(group) {
return textsecure.storage.protocol.getGroup(groupId).then(function(group) {
if (group === undefined)
throw new Error("Unknown group for device registration id");
@ -168,7 +168,7 @@
var needUpdate = group.numberRegistrationIds[number][encodedNumber] !== undefined;
group.numberRegistrationIds[number][encodedNumber] = registrationId;
return textsecure.storage.axolotl.putGroup(groupId, group).then(function() {
return textsecure.storage.protocol.putGroup(groupId, group).then(function() {
return needUpdate;
});
});