Update protocol libs
Rename storage functions // FREEBIE
This commit is contained in:
parent
b5ddd41a5e
commit
1fe5d63015
11 changed files with 91 additions and 91 deletions
|
@ -19,25 +19,25 @@ describe("Key generation", function() {
|
|||
}
|
||||
function itStoresPreKey(keyId) {
|
||||
it('prekey ' + keyId + ' is valid', function(done) {
|
||||
return textsecure.storage.axolotl.getPreKey(keyId).then(function(keyPair) {
|
||||
return textsecure.storage.axolotl.loadPreKey(keyId).then(function(keyPair) {
|
||||
validateStoredKeyPair(keyPair);
|
||||
}).then(done,done);
|
||||
});
|
||||
}
|
||||
function itStoresSignedPreKey(keyId) {
|
||||
it('signed prekey ' + keyId + ' is valid', function(done) {
|
||||
return textsecure.storage.axolotl.getSignedPreKey(keyId).then(function(keyPair) {
|
||||
return textsecure.storage.axolotl.loadSignedPreKey(keyId).then(function(keyPair) {
|
||||
validateStoredKeyPair(keyPair);
|
||||
}).then(done,done);
|
||||
});
|
||||
}
|
||||
function validateResultKey(resultKey) {
|
||||
return textsecure.storage.axolotl.getPreKey(resultKey.keyId).then(function(keyPair) {
|
||||
return textsecure.storage.axolotl.loadPreKey(resultKey.keyId).then(function(keyPair) {
|
||||
assertEqualArrayBuffers(resultKey.publicKey, keyPair.pubKey);
|
||||
});
|
||||
}
|
||||
function validateResultSignedKey(resultSignedKey) {
|
||||
return textsecure.storage.axolotl.getSignedPreKey(resultSignedKey.keyId).then(function(keyPair) {
|
||||
return textsecure.storage.axolotl.loadSignedPreKey(resultSignedKey.keyId).then(function(keyPair) {
|
||||
assertEqualArrayBuffers(resultSignedKey.publicKey, keyPair.pubKey);
|
||||
});
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ describe("Key generation", function() {
|
|||
validateResultSignedKey(result.signedPreKey).then(done,done);
|
||||
});
|
||||
it('deletes signed key 1', function() {
|
||||
textsecure.storage.axolotl.getSignedPreKey(1).then(function(keyPair) {
|
||||
textsecure.storage.axolotl.loadSignedPreKey(1).then(function(keyPair) {
|
||||
assert.isUndefined(keyPair);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,10 +3,10 @@ function AxolotlStore() {
|
|||
}
|
||||
|
||||
AxolotlStore.prototype = {
|
||||
getMyIdentityKey: function() {
|
||||
getIdentityKeyPair: function() {
|
||||
return Promise.resolve(this.get('identityKey'));
|
||||
},
|
||||
getMyRegistrationId: function() {
|
||||
getLocalRegistrationId: function() {
|
||||
return Promise.resolve(this.get('registrationId'));
|
||||
},
|
||||
put: function(key, value) {
|
||||
|
@ -29,7 +29,7 @@ AxolotlStore.prototype = {
|
|||
delete this.store[key];
|
||||
},
|
||||
|
||||
getIdentityKey: function(identifier) {
|
||||
loadIdentityKey: function(identifier) {
|
||||
if (identifier === null || identifier === undefined)
|
||||
throw new Error("Tried to get identity key for undefined/null key");
|
||||
return new Promise(function(resolve) {
|
||||
|
@ -45,13 +45,13 @@ AxolotlStore.prototype = {
|
|||
},
|
||||
|
||||
/* Returns a prekeypair object or undefined */
|
||||
getPreKey: function(keyId) {
|
||||
loadPreKey: function(keyId) {
|
||||
return new Promise(function(resolve) {
|
||||
var res = this.get('25519KeypreKey' + keyId);
|
||||
resolve(res);
|
||||
}.bind(this));
|
||||
},
|
||||
putPreKey: function(keyId, keyPair) {
|
||||
storePreKey: function(keyId, keyPair) {
|
||||
return new Promise(function(resolve) {
|
||||
resolve(this.put('25519KeypreKey' + keyId, keyPair));
|
||||
}.bind(this));
|
||||
|
@ -63,13 +63,13 @@ AxolotlStore.prototype = {
|
|||
},
|
||||
|
||||
/* Returns a signed keypair object or undefined */
|
||||
getSignedPreKey: function(keyId) {
|
||||
loadSignedPreKey: function(keyId) {
|
||||
return new Promise(function(resolve) {
|
||||
var res = this.get('25519KeysignedKey' + keyId);
|
||||
resolve(res);
|
||||
}.bind(this));
|
||||
},
|
||||
putSignedPreKey: function(keyId, keyPair) {
|
||||
storeSignedPreKey: function(keyId, keyPair) {
|
||||
return new Promise(function(resolve) {
|
||||
resolve(this.put('25519KeysignedKey' + keyId, keyPair));
|
||||
}.bind(this));
|
||||
|
@ -80,12 +80,12 @@ AxolotlStore.prototype = {
|
|||
}.bind(this));
|
||||
},
|
||||
|
||||
getSession: function(identifier) {
|
||||
loadSession: function(identifier) {
|
||||
return new Promise(function(resolve) {
|
||||
resolve(this.get('session' + identifier));
|
||||
}.bind(this));
|
||||
},
|
||||
putSession: function(identifier, record) {
|
||||
storeSession: function(identifier, record) {
|
||||
return new Promise(function(resolve) {
|
||||
resolve(this.put('session' + identifier, record));
|
||||
}.bind(this));
|
||||
|
|
|
@ -19,27 +19,27 @@ describe("AxolotlStore", function() {
|
|||
};
|
||||
it('retrieves my registration id', function(done) {
|
||||
store.put('registrationId', 1337);
|
||||
store.getMyRegistrationId().then(function(reg) {
|
||||
store.getLocalRegistrationId().then(function(reg) {
|
||||
assert.strictEqual(reg, 1337);
|
||||
}).then(done, done);
|
||||
});
|
||||
it('retrieves my identity key', function(done) {
|
||||
store.put('identityKey', identityKey);
|
||||
store.getMyIdentityKey().then(function(key) {
|
||||
store.getIdentityKeyPair().then(function(key) {
|
||||
assertEqualArrayBuffers(key.pubKey, identityKey.pubKey);
|
||||
assertEqualArrayBuffers(key.privKey, identityKey.privKey);
|
||||
}).then(done,done);
|
||||
});
|
||||
it('stores identity keys', function(done) {
|
||||
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
|
||||
return store.getIdentityKey(identifier).then(function(key) {
|
||||
return store.loadIdentityKey(identifier).then(function(key) {
|
||||
assertEqualArrayBuffers(key, testKey.pubKey);
|
||||
});
|
||||
}).then(done,done);
|
||||
});
|
||||
it('stores prekeys', function(done) {
|
||||
store.putPreKey(1, testKey).then(function() {
|
||||
return store.getPreKey(1).then(function(key) {
|
||||
store.storePreKey(1, testKey).then(function() {
|
||||
return store.loadPreKey(1).then(function(key) {
|
||||
assertEqualArrayBuffers(key.pubKey, testKey.pubKey);
|
||||
assertEqualArrayBuffers(key.privKey, testKey.privKey);
|
||||
});
|
||||
|
@ -47,17 +47,17 @@ describe("AxolotlStore", function() {
|
|||
});
|
||||
it('deletes prekeys', function(done) {
|
||||
before(function(done) {
|
||||
store.putPreKey(2, testKey).then(done);
|
||||
store.storePreKey(2, testKey).then(done);
|
||||
});
|
||||
store.removePreKey(2, testKey).then(function() {
|
||||
return store.getPreKey(2).then(function(key) {
|
||||
return store.loadPreKey(2).then(function(key) {
|
||||
assert.isUndefined(key);
|
||||
});
|
||||
}).then(done,done);
|
||||
});
|
||||
it('stores signed prekeys', function(done) {
|
||||
store.putSignedPreKey(3, testKey).then(function() {
|
||||
return store.getSignedPreKey(3).then(function(key) {
|
||||
store.storeSignedPreKey(3, testKey).then(function() {
|
||||
return store.loadSignedPreKey(3).then(function(key) {
|
||||
assertEqualArrayBuffers(key.pubKey, testKey.pubKey);
|
||||
assertEqualArrayBuffers(key.privKey, testKey.privKey);
|
||||
});
|
||||
|
@ -65,10 +65,10 @@ describe("AxolotlStore", function() {
|
|||
});
|
||||
it('deletes signed prekeys', function(done) {
|
||||
before(function(done) {
|
||||
store.putSignedPreKey(4, testKey).then(done);
|
||||
store.storeSignedPreKey(4, testKey).then(done);
|
||||
});
|
||||
store.removeSignedPreKey(4, testKey).then(function() {
|
||||
return store.getSignedPreKey(4).then(function(key) {
|
||||
return store.loadSignedPreKey(4).then(function(key) {
|
||||
assert.isUndefined(key);
|
||||
});
|
||||
}).then(done,done);
|
||||
|
@ -81,11 +81,11 @@ describe("AxolotlStore", function() {
|
|||
var promise = Promise.resolve();
|
||||
devices.forEach(function(encodedNumber) {
|
||||
promise = promise.then(function() {
|
||||
return store.putSession(encodedNumber, testRecord + encodedNumber)
|
||||
return store.storeSession(encodedNumber, testRecord + encodedNumber)
|
||||
});
|
||||
});
|
||||
promise.then(function() {
|
||||
return Promise.all(devices.map(store.getSession.bind(store))).then(function(records) {
|
||||
return Promise.all(devices.map(store.loadSession.bind(store))).then(function(records) {
|
||||
for (var i in records) {
|
||||
assert.strictEqual(records[i], testRecord + devices[i]);
|
||||
};
|
||||
|
@ -100,12 +100,12 @@ describe("AxolotlStore", function() {
|
|||
var promise = Promise.resolve();
|
||||
devices.forEach(function(encodedNumber) {
|
||||
promise = promise.then(function() {
|
||||
return store.putSession(encodedNumber, testRecord + encodedNumber)
|
||||
return store.storeSession(encodedNumber, testRecord + encodedNumber)
|
||||
});
|
||||
});
|
||||
promise.then(function() {
|
||||
return store.removeAllSessions(identifier).then(function(record) {
|
||||
return Promise.all(devices.map(store.getSession.bind(store))).then(function(records) {
|
||||
return Promise.all(devices.map(store.loadSession.bind(store))).then(function(records) {
|
||||
for (var i in records) {
|
||||
assert.isUndefined(records[i]);
|
||||
};
|
||||
|
@ -121,7 +121,7 @@ describe("AxolotlStore", function() {
|
|||
var promise = Promise.resolve();
|
||||
devices.forEach(function(encodedNumber) {
|
||||
promise = promise.then(function() {
|
||||
return store.putSession(encodedNumber, testRecord + encodedNumber)
|
||||
return store.storeSession(encodedNumber, testRecord + encodedNumber)
|
||||
});
|
||||
});
|
||||
promise.then(function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue