Use forEach instead of loop

// FREEBIE
This commit is contained in:
lilia 2016-03-13 14:15:16 -07:00
parent c02054d5da
commit 84235ef58e
2 changed files with 16 additions and 16 deletions

View file

@ -36605,16 +36605,16 @@ var TextSecureServer = (function() {
throw new Error("Invalid response"); throw new Error("Invalid response");
} }
res.identityKey = StringView.base64ToBytes(res.identityKey); res.identityKey = StringView.base64ToBytes(res.identityKey);
for (var i = 0; i < res.devices.length; i++) { res.devices.forEach(function(device) {
if ( !validateResponse(res.devices[i], {signedPreKey: 'object', preKey: 'object'}) || if ( !validateResponse(device, {signedPreKey: 'object', preKey: 'object'}) ||
!validateResponse(res.devices[i].signedPreKey, {publicKey: 'string', signature: 'string'}) || !validateResponse(device.signedPreKey, {publicKey: 'string', signature: 'string'}) ||
!validateResponse(res.devices[i].preKey, {publicKey: 'string'})) { !validateResponse(device.preKey, {publicKey: 'string'})) {
throw new Error("Invalid response"); throw new Error("Invalid response");
} }
res.devices[i].signedPreKey.publicKey = StringView.base64ToBytes(res.devices[i].signedPreKey.publicKey); device.signedPreKey.publicKey = StringView.base64ToBytes(device.signedPreKey.publicKey);
res.devices[i].signedPreKey.signature = StringView.base64ToBytes(res.devices[i].signedPreKey.signature); device.signedPreKey.signature = StringView.base64ToBytes(device.signedPreKey.signature);
res.devices[i].preKey.publicKey = StringView.base64ToBytes(res.devices[i].preKey.publicKey); device.preKey.publicKey = StringView.base64ToBytes(device.preKey.publicKey);
} });
return res; return res;
}); });
}, },

View file

@ -285,16 +285,16 @@ var TextSecureServer = (function() {
throw new Error("Invalid response"); throw new Error("Invalid response");
} }
res.identityKey = StringView.base64ToBytes(res.identityKey); res.identityKey = StringView.base64ToBytes(res.identityKey);
for (var i = 0; i < res.devices.length; i++) { res.devices.forEach(function(device) {
if ( !validateResponse(res.devices[i], {signedPreKey: 'object', preKey: 'object'}) || if ( !validateResponse(device, {signedPreKey: 'object', preKey: 'object'}) ||
!validateResponse(res.devices[i].signedPreKey, {publicKey: 'string', signature: 'string'}) || !validateResponse(device.signedPreKey, {publicKey: 'string', signature: 'string'}) ||
!validateResponse(res.devices[i].preKey, {publicKey: 'string'})) { !validateResponse(device.preKey, {publicKey: 'string'})) {
throw new Error("Invalid response"); throw new Error("Invalid response");
} }
res.devices[i].signedPreKey.publicKey = StringView.base64ToBytes(res.devices[i].signedPreKey.publicKey); device.signedPreKey.publicKey = StringView.base64ToBytes(device.signedPreKey.publicKey);
res.devices[i].signedPreKey.signature = StringView.base64ToBytes(res.devices[i].signedPreKey.signature); device.signedPreKey.signature = StringView.base64ToBytes(device.signedPreKey.signature);
res.devices[i].preKey.publicKey = StringView.base64ToBytes(res.devices[i].preKey.publicKey); device.preKey.publicKey = StringView.base64ToBytes(device.preKey.publicKey);
} });
return res; return res;
}); });
}, },