Eslintify all of libtextsecure

This commit is contained in:
Scott Nonnenberg 2018-07-21 14:51:20 -07:00
parent 4b3f9e969a
commit 0774ba2903
36 changed files with 1960 additions and 2128 deletions

View file

@ -1,37 +1,32 @@
'use strict';
describe('Protocol Wrapper', function() {
var store = textsecure.storage.protocol;
var identifier = '+5558675309';
var another_identifier = '+5555590210';
var prekeys, identityKey, testKey;
const store = textsecure.storage.protocol;
const identifier = '+5558675309';
const another_identifier = '+5555590210';
let prekeys, identityKey, testKey;
this.timeout(5000);
before(function(done) {
before(done => {
localStorage.clear();
libsignal.KeyHelper.generateIdentityKeyPair()
.then(function(identityKey) {
return textsecure.storage.protocol.saveIdentity(
identifier,
identityKey
);
})
.then(function() {
.then(identityKey =>
textsecure.storage.protocol.saveIdentity(identifier, identityKey)
)
.then(() => {
done();
});
});
describe('processPreKey', function() {
it('rejects if the identity key changes', function() {
var address = new libsignal.SignalProtocolAddress(identifier, 1);
var builder = new libsignal.SessionBuilder(store, address);
describe('processPreKey', () => {
it('rejects if the identity key changes', () => {
const address = new libsignal.SignalProtocolAddress(identifier, 1);
const builder = new libsignal.SessionBuilder(store, address);
return builder
.processPreKey({
identityKey: textsecure.crypto.getRandomBytes(33),
encodedNumber: address.toString(),
})
.then(function() {
.then(() => {
throw new Error('Allowed to overwrite identity key');
})
.catch(function(e) {
.catch(e => {
assert.strictEqual(e.message, 'Identity key changed');
});
});