Fix undefined variable in for's (browser update to strict mode?)
This commit is contained in:
parent
de83429962
commit
0d4ae6a8cb
4 changed files with 23 additions and 19 deletions
|
@ -17,6 +17,8 @@
|
|||
window.textsecure = window.textsecure || {};
|
||||
|
||||
window.textsecure.api = function() {
|
||||
'use strict';
|
||||
|
||||
var self = {};
|
||||
|
||||
/************************************************
|
||||
|
@ -147,7 +149,7 @@ window.textsecure.api = function() {
|
|||
|
||||
keys.preKeys = [];
|
||||
var j = 0;
|
||||
for (i in genKeys.preKeys)
|
||||
for (var i in genKeys.preKeys)
|
||||
keys.preKeys[j++] = {keyId: i, publicKey: btoa(getString(genKeys.preKeys[i].publicKey))};
|
||||
|
||||
//TODO: This is just to make the server happy (v2 clients should choke on publicKey),
|
||||
|
|
10
js/crypto.js
10
js/crypto.js
|
@ -52,7 +52,7 @@ window.textsecure.crypto = function() {
|
|||
|
||||
function objectContainsKeys(object) {
|
||||
var count = 0;
|
||||
for (key in object) {
|
||||
for (var key in object) {
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ window.textsecure.crypto = function() {
|
|||
|
||||
if (!doDeleteSession) {
|
||||
var keysLeft = false;
|
||||
for (key in session) {
|
||||
for (var key in session) {
|
||||
if (key != "indexInfo" && key != "indexInfo" && key != "oldRatchetList") {
|
||||
keysLeft = true;
|
||||
break;
|
||||
|
@ -186,7 +186,7 @@ window.textsecure.crypto = function() {
|
|||
if (sessions === undefined)
|
||||
return undefined;
|
||||
|
||||
for (key in sessions)
|
||||
for (var key in sessions)
|
||||
if (sessions[key].indexInfo.closed == -1)
|
||||
return sessions[key];
|
||||
return undefined;
|
||||
|
@ -200,7 +200,7 @@ window.textsecure.crypto = function() {
|
|||
var searchKey = getString(remoteEphemeralKey);
|
||||
|
||||
var openSession = undefined;
|
||||
for (key in sessions) {
|
||||
for (var key in sessions) {
|
||||
if (sessions[key].indexInfo.closed == -1) {
|
||||
if (openSession !== undefined)
|
||||
throw new Error("Datastore inconsistensy: multiple open sessions for " + encodedNumber);
|
||||
|
@ -465,7 +465,7 @@ window.textsecure.crypto = function() {
|
|||
var closeSession = function(session) {
|
||||
// Clear any data which would allow session continuation:
|
||||
// Lock down current receive ratchet
|
||||
for (key in session)
|
||||
for (var key in session)
|
||||
if (key.chainKey !== undefined && key.chainKey.key !== undefined)
|
||||
delete key.chainKey.key;
|
||||
// Delete current sending ratchet
|
||||
|
|
|
@ -264,7 +264,7 @@ window.textsecure.utils = function() {
|
|||
return res;
|
||||
} else if (thing === Object(thing)) {
|
||||
var res = {};
|
||||
for (key in thing)
|
||||
for (var key in thing)
|
||||
res[key] = ensureStringed(thing[key]);
|
||||
return res;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ window.textsecure.storage = function() {
|
|||
throw new Error("Identity key changed");
|
||||
else {
|
||||
var updated = false;
|
||||
for (i in map.devices) {
|
||||
for (var i in map.devices) {
|
||||
if (map.devices[i].encodedNumber == deviceObject.encodedNumber) {
|
||||
map.devices[i] = deviceObject;
|
||||
updated = true;
|
||||
|
@ -376,7 +376,7 @@ window.textsecure.storage = function() {
|
|||
if (devices === undefined)
|
||||
return undefined;
|
||||
|
||||
for (i in devices)
|
||||
for (var i in devices)
|
||||
if (devices[i].encodedNumber == encodedNumber)
|
||||
return devices[i];
|
||||
|
||||
|
@ -390,9 +390,9 @@ window.textsecure.storage = function() {
|
|||
|
||||
var newDevices = [];
|
||||
var devicesRemoved = 0;
|
||||
for (i in map.devices) {
|
||||
for (var i in map.devices) {
|
||||
var keep = true;
|
||||
for (j in deviceIdsToRemove)
|
||||
for (var j in deviceIdsToRemove)
|
||||
if (map.devices[i].encodedNumber == number + "." + deviceIdsToRemove[j])
|
||||
keep = false;
|
||||
|
||||
|
@ -445,7 +445,7 @@ window.textsecure.storage = function() {
|
|||
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
||||
var haveMe = false;
|
||||
var finalNumbers = [];
|
||||
for (i in numbers) {
|
||||
for (var i in numbers) {
|
||||
var number = textsecure.utils.verifyNumber(numbers[i]);
|
||||
if (number == me)
|
||||
haveMe = true;
|
||||
|
@ -501,7 +501,7 @@ window.textsecure.storage = function() {
|
|||
if (group === undefined)
|
||||
return undefined;
|
||||
|
||||
for (i in numbers) {
|
||||
for (var i in numbers) {
|
||||
var number = textsecure.utils.verifyNumber(numbers[i]);
|
||||
if (group.numbers.indexOf(number) < 0) {
|
||||
group.numbers.push(number);
|
||||
|
@ -744,7 +744,7 @@ window.textsecure.subscribeToPush = function() {
|
|||
}
|
||||
}
|
||||
|
||||
for (i in decrypted.attachments)
|
||||
for (var i in decrypted.attachments)
|
||||
promises.push(handleAttachment(decrypted.attachments[i]));
|
||||
return Promise.all(promises).then(function() {
|
||||
message_callback({pushMessage: proto, message: decrypted});
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
// sendMessage(numbers = [], message = PushMessageContentProto, callback(success/failure map))
|
||||
window.textsecure.messaging = function() {
|
||||
'use strict';
|
||||
|
||||
var self = {};
|
||||
|
||||
function getKeysForNumber(number, updateDevices) {
|
||||
return textsecure.api.getKeysForNumber(number).then(function(response) {
|
||||
for (i in response.devices) {
|
||||
for (var i in response.devices) {
|
||||
if (updateDevices === undefined || updateDevices.indexOf(response.devices[i].deviceId) > -1)
|
||||
textsecure.storage.devices.saveDeviceObject({
|
||||
encodedNumber: number + "." + response.devices[i].deviceId,
|
||||
|
@ -65,7 +67,7 @@ window.textsecure.messaging = function() {
|
|||
var refreshGroups = function(number) {
|
||||
var groups = textsecure.storage.groups.getGroupListForNumber(number);
|
||||
var promises = [];
|
||||
for (i in groups) {
|
||||
for (var i in groups) {
|
||||
var group = textsecure.storage.groups.getGroup(groups[i]);
|
||||
|
||||
var proto = new textsecure.protos.PushMessageContentProtobuf();
|
||||
|
@ -218,7 +220,7 @@ window.textsecure.messaging = function() {
|
|||
proto.body = messageText;
|
||||
|
||||
var promises = [];
|
||||
for (i in attachments)
|
||||
for (var i in attachments)
|
||||
promises.push(makeAttachmentPointer(attachments[i]));
|
||||
return Promise.all(promises).then(function(attachmentsArray) {
|
||||
proto.attachments = attachmentsArray;
|
||||
|
@ -228,7 +230,7 @@ window.textsecure.messaging = function() {
|
|||
|
||||
self.closeSession = function(number) {
|
||||
var devices = textsecure.storage.devices.getDeviceObjectsForNumber(number);
|
||||
for (i in devices)
|
||||
for (var i in devices)
|
||||
textsecure.crypto.closeOpenSessionForDevice(devices[i].encodedNumber);
|
||||
|
||||
var proto = new textsecure.protos.PushMessageContentProtobuf();
|
||||
|
@ -248,7 +250,7 @@ window.textsecure.messaging = function() {
|
|||
return new Promise(function(resolve, reject) { reject(new Error("Unknown Group")); });
|
||||
|
||||
var promises = [];
|
||||
for (i in attachments)
|
||||
for (var i in attachments)
|
||||
promises.push(makeAttachmentPointer(attachments[i]));
|
||||
return Promise.all(promises).then(function(attachmentsArray) {
|
||||
proto.attachments = attachmentsArray;
|
||||
|
|
Loading…
Reference in a new issue