s/getEncodedNumber// (with XXXs)
This commit is contained in:
parent
9aae93fc99
commit
d387cd22f5
2 changed files with 12 additions and 21 deletions
15
js/crypto.js
15
js/crypto.js
|
@ -144,7 +144,7 @@ window.textsecure.crypto = new function() {
|
|||
}
|
||||
|
||||
crypto_storage.saveSession = function(encodedNumber, session) {
|
||||
var sessions = textsecure.storage.getEncrypted("session" + getEncodedNumber(encodedNumber));
|
||||
var sessions = textsecure.storage.getEncrypted("session" + encodedNumber);
|
||||
if (sessions === undefined)
|
||||
sessions = {};
|
||||
|
||||
|
@ -171,11 +171,11 @@ window.textsecure.crypto = new function() {
|
|||
else
|
||||
sessions[getString(session.indexInfo.baseKey)] = session;
|
||||
|
||||
textsecure.storage.putEncrypted("session" + getEncodedNumber(encodedNumber), sessions);
|
||||
textsecure.storage.putEncrypted("session" + encodedNumber, sessions);
|
||||
}
|
||||
|
||||
crypto_storage.getOpenSession = function(encodedNumber) {
|
||||
var sessions = textsecure.storage.getEncrypted("session" + getEncodedNumber(encodedNumber));
|
||||
var sessions = textsecure.storage.getEncrypted("session" + encodedNumber);
|
||||
if (sessions === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -190,7 +190,7 @@ window.textsecure.crypto = new function() {
|
|||
}
|
||||
|
||||
crypto_storage.getSessionByRemoteEphemeralKey = function(encodedNumber, remoteEphemeralKey) {
|
||||
var sessions = textsecure.storage.getEncrypted("session" + getEncodedNumber(encodedNumber));
|
||||
var sessions = textsecure.storage.getEncrypted("session" + encodedNumber);
|
||||
if (sessions === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -217,7 +217,7 @@ window.textsecure.crypto = new function() {
|
|||
|
||||
|
||||
crypto_storage.getSessionOrIdentityKeyByBaseKey = function(encodedNumber, baseKey) {
|
||||
var sessions = textsecure.storage.getEncrypted("session" + getEncodedNumber(encodedNumber));
|
||||
var sessions = textsecure.storage.getEncrypted("session" + encodedNumber);
|
||||
if (sessions === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -603,14 +603,15 @@ window.textsecure.crypto = new function() {
|
|||
case 0: //TYPE_MESSAGE_PLAINTEXT
|
||||
return Promise.resolve(textsecure.protos.decodePushMessageContentProtobuf(getString(proto.message)));
|
||||
case 1: //TYPE_MESSAGE_CIPHERTEXT
|
||||
return decryptWhisperMessage(proto.source, getString(proto.message)).then(function(result) {
|
||||
return decryptWhisperMessage(proto.source + "." + proto.sourceDevice, getString(proto.message)).then(function(result) {
|
||||
return {message:result, pushMessage: proto};
|
||||
});
|
||||
case 3: //TYPE_MESSAGE_PREKEY_BUNDLE
|
||||
if (proto.message.readUint8() != (2 << 4 | 2))
|
||||
throw new Error("Bad version byte");
|
||||
var preKeyProto = textsecure.protos.decodePreKeyWhisperMessageProtobuf(getString(proto.message));
|
||||
return initSessionFromPreKeyWhisperMessage(proto.source, preKeyProto).then(function(sessions) {
|
||||
//XXX: proto.sourceDevice == jsNumber??? (and above)
|
||||
return initSessionFromPreKeyWhisperMessage(proto.source + "." + proto.sourceDevice, preKeyProto).then(function(sessions) {
|
||||
return decryptWhisperMessage(proto.source, getString(preKeyProto.message), sessions[0]).then(function(result) {
|
||||
if (sessions[1] !== undefined)
|
||||
crypto_storage.saveSession(proto.source, sessions[1]);
|
||||
|
|
|
@ -195,17 +195,6 @@ function getNumberFromString(string) {
|
|||
return string.split(".")[0];
|
||||
}
|
||||
|
||||
function getEncodedNumber(number) {
|
||||
var split = number.split(".");
|
||||
if (split.length > 1) {
|
||||
if (split[1] == 1)
|
||||
return split[0];
|
||||
else
|
||||
return number;
|
||||
} else
|
||||
return number;
|
||||
}
|
||||
|
||||
function verifyNumber(string) {
|
||||
//TODO: fancy country-code guessing and number verification
|
||||
return getEncodedNumber(string.trim());
|
||||
|
@ -285,10 +274,11 @@ window.textsecure.storage = function() {
|
|||
*** Device Storage ***
|
||||
**********************/
|
||||
self.devices = function() {
|
||||
//TODO: Just store numbers with the device list in the object, not a list of pointers...
|
||||
var self = {};
|
||||
|
||||
self.getDeviceObject = function(encodedNumber) {
|
||||
return textsecure.storage.getEncrypted("deviceObject" + getEncodedNumber(encodedNumber));
|
||||
return textsecure.storage.getEncrypted("deviceObject" + encodedNumber);
|
||||
}
|
||||
|
||||
self.getDeviceIdListFromNumber = function(number) {
|
||||
|
@ -316,7 +306,7 @@ window.textsecure.storage = function() {
|
|||
self.saveDeviceObject = function(deviceObject) {
|
||||
var existing = this.getDeviceObject(deviceObject.encodedNumber);
|
||||
if (existing === undefined)
|
||||
existing = {encodedNumber: getEncodedNumber(deviceObject.encodedNumber)};
|
||||
existing = {encodedNumber: deviceObject.encodedNumber};
|
||||
for (key in deviceObject) {
|
||||
if (key == "encodedNumber")
|
||||
continue;
|
||||
|
@ -326,7 +316,7 @@ window.textsecure.storage = function() {
|
|||
|
||||
existing[key] = deviceObject[key];
|
||||
}
|
||||
textsecure.storage.putEncrypted("deviceObject" + getEncodedNumber(deviceObject.encodedNumber), existing);
|
||||
textsecure.storage.putEncrypted("deviceObject" + deviceObject.encodedNumber, existing);
|
||||
this.addDeviceIdForNumber(deviceObject.encodedNumber, getDeviceId(deviceObject.encodedNumber));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue