diff --git a/js/axolotl_store.js b/js/axolotl_store.js index bc6e866c..b576badd 100644 --- a/js/axolotl_store.js +++ b/js/axolotl_store.js @@ -83,7 +83,7 @@ AxolotlStore.prototype = { constructor: AxolotlStore, - getMyIdentityKey: function() { + getIdentityKeyPair: function() { var item = new Item({id: 'identityKey'}); return new Promise(function(resolve) { item.fetch().then(function() { @@ -91,7 +91,7 @@ }); }); }, - getMyRegistrationId: function() { + getLocalRegistrationId: function() { var item = new Item({id: 'registrationId'}); return new Promise(function(resolve) { item.fetch().then(function() { @@ -101,7 +101,7 @@ }, /* Returns a prekeypair object or undefined */ - getPreKey: function(keyId) { + loadPreKey: function(keyId) { var prekey = new PreKey({id: keyId}); return new Promise(function(resolve) { prekey.fetch().then(function() { @@ -112,7 +112,7 @@ }).fail(resolve); }); }, - putPreKey: function(keyId, keyPair) { + storePreKey: function(keyId, keyPair) { var prekey = new PreKey({ id : keyId, publicKey : keyPair.pubKey, @@ -139,7 +139,7 @@ }, /* Returns a signed keypair object or undefined */ - getSignedPreKey: function(keyId) { + loadSignedPreKey: function(keyId) { var prekey = new SignedPreKey({id: keyId}); return new Promise(function(resolve) { prekey.fetch().then(function() { @@ -150,7 +150,7 @@ }).fail(resolve); }); }, - putSignedPreKey: function(keyId, keyPair) { + storeSignedPreKey: function(keyId, keyPair) { var prekey = new SignedPreKey({ id : keyId, publicKey : keyPair.pubKey, @@ -171,7 +171,7 @@ }); }, - getSession: function(encodedNumber) { + loadSession: function(encodedNumber) { if (encodedNumber === null || encodedNumber === undefined) { throw new Error("Tried to get session for undefined/null number"); } @@ -183,7 +183,7 @@ }); }, - putSession: function(encodedNumber, record) { + storeSession: function(encodedNumber, record) { if (encodedNumber === null || encodedNumber === undefined) { throw new Error("Tried to put session for undefined/null number"); } @@ -246,7 +246,7 @@ }); }, - getIdentityKey: function(identifier) { + loadIdentityKey: function(identifier) { if (identifier === null || identifier === undefined) { throw new Error("Tried to get identity key for undefined/null key"); } diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 786d95de..9c34149f 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -34330,7 +34330,7 @@ window.axolotl.protocol = function(storage_interface) { var crypto_storage = {}; function getRecord(encodedNumber) { - return storage_interface.getSession(encodedNumber).then(function(serialized) { + return storage_interface.loadSession(encodedNumber).then(function(serialized) { if (serialized === undefined) { return undefined; } @@ -34390,12 +34390,12 @@ window.axolotl.protocol = function(storage_interface) { else if (record.registrationId === null) throw new Error("Had open sessions on a record that had no registrationId set"); - return storage_interface.getIdentityKey(encodedNumber).then(function(identityKey) { + return storage_interface.loadIdentityKey(encodedNumber).then(function(identityKey) { if (identityKey !== undefined && toString(identityKey) !== toString(record.identityKey)) throw new Error("Tried to change identity key at save time"); return storage_interface.putIdentityKey(encodedNumber, record.identityKey).then(function() { - return storage_interface.putSession(encodedNumber, record.serialize()); + return storage_interface.storeSession(encodedNumber, record.serialize()); }); }); }); @@ -34462,7 +34462,7 @@ window.axolotl.protocol = function(storage_interface) { crypto_storage.getSessionOrIdentityKeyByBaseKey = function(encodedNumber, baseKey) { return getRecord(encodedNumber).then(function(record) { if (record === undefined) { - return storage_interface.getIdentityKey(encodedNumber).then(function(identityKey) { + return storage_interface.loadIdentityKey(encodedNumber).then(function(identityKey) { if (identityKey === undefined) return undefined; return { indexInfo: { remoteIdentityKey: identityKey } }; @@ -34538,7 +34538,7 @@ window.axolotl.protocol = function(storage_interface) { } var initSession = function(isInitiator, ourEphemeralKey, ourSignedKey, encodedNumber, theirIdentityPubKey, theirEphemeralPubKey, theirSignedPubKey) { - return storage_interface.getMyIdentityKey().then(function(ourIdentityKey) { + return storage_interface.getIdentityKeyPair().then(function(ourIdentityKey) { if (isInitiator) { if (ourSignedKey !== undefined) { throw new Error("Invalid call to initSession"); @@ -34674,8 +34674,8 @@ window.axolotl.protocol = function(storage_interface) { var initSessionFromPreKeyWhisperMessage = function(encodedNumber, message) { var preKeyPair, signedPreKeyPair, session; return Promise.all([ - storage_interface.getPreKey(message.preKeyId), - storage_interface.getSignedPreKey(message.signedPreKeyId), + storage_interface.loadPreKey(message.preKeyId), + storage_interface.loadSignedPreKey(message.signedPreKeyId), crypto_storage.getSessionOrIdentityKeyByBaseKey(encodedNumber, toArrayBuffer(message.baseKey)) ]).then(function(results) { preKeyPair = results[0]; @@ -34839,7 +34839,7 @@ window.axolotl.protocol = function(storage_interface) { return HKDF(toArrayBuffer(messageKey), '', "WhisperMessageKeys"); }); }).then(function(keys) { - return storage_interface.getMyIdentityKey().then(function(ourIdentityKey) { + return storage_interface.getIdentityKeyPair().then(function(ourIdentityKey) { var macInput = new Uint8Array(messageProto.byteLength + 33*2 + 1); macInput.set(new Uint8Array(toArrayBuffer(session.indexInfo.remoteIdentityKey))); @@ -34920,8 +34920,8 @@ window.axolotl.protocol = function(storage_interface) { var ourIdentityKey, myRegistrationId, session, hadSession; return Promise.all([ - storage_interface.getMyIdentityKey(), - storage_interface.getMyRegistrationId(), + storage_interface.getIdentityKeyPair(), + storage_interface.getLocalRegistrationId(), crypto_storage.getOpenSession(deviceObject.encodedNumber) ]).then(function(results) { ourIdentityKey = results[0]; @@ -35614,7 +35614,7 @@ axolotlInternal.RecipientRecord = function() { window.textsecure.storage.devices = { saveKeysToDeviceObject: function(deviceObject) { var number = textsecure.utils.unencodeNumber(deviceObject.encodedNumber)[0]; - return textsecure.storage.axolotl.getIdentityKey(number).then(function(identityKey) { + return textsecure.storage.axolotl.loadIdentityKey(number).then(function(identityKey) { if (identityKey !== undefined && deviceObject.identityKey !== undefined && getString(identityKey) != getString(deviceObject.identityKey)) { var error = new Error("Identity key changed"); error.identityKey = deviceObject.identityKey; @@ -35658,7 +35658,7 @@ axolotlInternal.RecipientRecord = function() { }); }, getDeviceObjectsForNumber: function(number) { - return textsecure.storage.axolotl.getIdentityKey(number).then(function(identityKey) { + return textsecure.storage.axolotl.loadIdentityKey(number).then(function(identityKey) { if (identityKey === undefined) { return []; } @@ -36856,14 +36856,14 @@ var TextSecureServer = (function() { var store = textsecure.storage.axolotl; - return store.getMyIdentityKey().then(function(identityKey) { + return store.getIdentityKeyPair().then(function(identityKey) { var result = { preKeys: [], identityKey: identityKey.pubKey }; var promises = []; for (var keyId = startId; keyId < startId+count; ++keyId) { promises.push( axolotl.util.generatePreKey(keyId).then(function(res) { - store.putPreKey(res.keyId, res.keyPair); + store.storePreKey(res.keyId, res.keyPair); result.preKeys.push({ keyId : res.keyId, publicKey : res.keyPair.pubKey @@ -36875,7 +36875,7 @@ var TextSecureServer = (function() { promises.push( axolotl.util.generateSignedPreKey(identityKey, signedKeyId).then(function(res) { - store.putSignedPreKey(res.keyId, res.keyPair); + store.storeSignedPreKey(res.keyId, res.keyPair); result.signedPreKey = { keyId : res.keyId, publicKey : res.keyPair.pubKey, diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 7e5be9f1..fcd8febf 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -170,8 +170,8 @@ if (this.model.isPrivate()) { var their_number = this.model.id; var our_number = textsecure.storage.user.getNumber(); - textsecure.storage.axolotl.getIdentityKey(their_number).then(function(their_key) { - textsecure.storage.axolotl.getIdentityKey(our_number).then(function(our_key) { + textsecure.storage.axolotl.loadIdentityKey(their_number).then(function(their_key) { + textsecure.storage.axolotl.loadIdentityKey(our_number).then(function(our_key) { var view = new Whisper.KeyVerificationPanelView({ model: { their_key: their_key, your_key: our_key } }).render(); diff --git a/js/views/key_conflict_dialogue_view.js b/js/views/key_conflict_dialogue_view.js index 01aa4a21..38288f75 100644 --- a/js/views/key_conflict_dialogue_view.js +++ b/js/views/key_conflict_dialogue_view.js @@ -12,11 +12,11 @@ initialize: function(options) { this.contact = options.contact; this.conversation = options.conversation; - textsecure.storage.axolotl.getIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) { + textsecure.storage.axolotl.loadIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) { this.your_key = our_key; this.render(); }.bind(this)); - textsecure.storage.axolotl.getIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) { + textsecure.storage.axolotl.loadIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) { var view = new Whisper.KeyVerificationView({ model: { their_key : this.model.identityKey, diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index cca00856..760485b2 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -141,14 +141,14 @@ var store = textsecure.storage.axolotl; - return store.getMyIdentityKey().then(function(identityKey) { + return store.getIdentityKeyPair().then(function(identityKey) { var result = { preKeys: [], identityKey: identityKey.pubKey }; var promises = []; for (var keyId = startId; keyId < startId+count; ++keyId) { promises.push( axolotl.util.generatePreKey(keyId).then(function(res) { - store.putPreKey(res.keyId, res.keyPair); + store.storePreKey(res.keyId, res.keyPair); result.preKeys.push({ keyId : res.keyId, publicKey : res.keyPair.pubKey @@ -160,7 +160,7 @@ promises.push( axolotl.util.generateSignedPreKey(identityKey, signedKeyId).then(function(res) { - store.putSignedPreKey(res.keyId, res.keyPair); + store.storeSignedPreKey(res.keyId, res.keyPair); result.signedPreKey = { keyId : res.keyId, publicKey : res.keyPair.pubKey, diff --git a/libtextsecure/libaxolotl.js b/libtextsecure/libaxolotl.js index b90822b8..4b353e0c 100644 --- a/libtextsecure/libaxolotl.js +++ b/libtextsecure/libaxolotl.js @@ -34216,7 +34216,7 @@ window.axolotl.protocol = function(storage_interface) { var crypto_storage = {}; function getRecord(encodedNumber) { - return storage_interface.getSession(encodedNumber).then(function(serialized) { + return storage_interface.loadSession(encodedNumber).then(function(serialized) { if (serialized === undefined) { return undefined; } @@ -34276,12 +34276,12 @@ window.axolotl.protocol = function(storage_interface) { else if (record.registrationId === null) throw new Error("Had open sessions on a record that had no registrationId set"); - return storage_interface.getIdentityKey(encodedNumber).then(function(identityKey) { + return storage_interface.loadIdentityKey(encodedNumber).then(function(identityKey) { if (identityKey !== undefined && toString(identityKey) !== toString(record.identityKey)) throw new Error("Tried to change identity key at save time"); return storage_interface.putIdentityKey(encodedNumber, record.identityKey).then(function() { - return storage_interface.putSession(encodedNumber, record.serialize()); + return storage_interface.storeSession(encodedNumber, record.serialize()); }); }); }); @@ -34348,7 +34348,7 @@ window.axolotl.protocol = function(storage_interface) { crypto_storage.getSessionOrIdentityKeyByBaseKey = function(encodedNumber, baseKey) { return getRecord(encodedNumber).then(function(record) { if (record === undefined) { - return storage_interface.getIdentityKey(encodedNumber).then(function(identityKey) { + return storage_interface.loadIdentityKey(encodedNumber).then(function(identityKey) { if (identityKey === undefined) return undefined; return { indexInfo: { remoteIdentityKey: identityKey } }; @@ -34424,7 +34424,7 @@ window.axolotl.protocol = function(storage_interface) { } var initSession = function(isInitiator, ourEphemeralKey, ourSignedKey, encodedNumber, theirIdentityPubKey, theirEphemeralPubKey, theirSignedPubKey) { - return storage_interface.getMyIdentityKey().then(function(ourIdentityKey) { + return storage_interface.getIdentityKeyPair().then(function(ourIdentityKey) { if (isInitiator) { if (ourSignedKey !== undefined) { throw new Error("Invalid call to initSession"); @@ -34560,8 +34560,8 @@ window.axolotl.protocol = function(storage_interface) { var initSessionFromPreKeyWhisperMessage = function(encodedNumber, message) { var preKeyPair, signedPreKeyPair, session; return Promise.all([ - storage_interface.getPreKey(message.preKeyId), - storage_interface.getSignedPreKey(message.signedPreKeyId), + storage_interface.loadPreKey(message.preKeyId), + storage_interface.loadSignedPreKey(message.signedPreKeyId), crypto_storage.getSessionOrIdentityKeyByBaseKey(encodedNumber, toArrayBuffer(message.baseKey)) ]).then(function(results) { preKeyPair = results[0]; @@ -34725,7 +34725,7 @@ window.axolotl.protocol = function(storage_interface) { return HKDF(toArrayBuffer(messageKey), '', "WhisperMessageKeys"); }); }).then(function(keys) { - return storage_interface.getMyIdentityKey().then(function(ourIdentityKey) { + return storage_interface.getIdentityKeyPair().then(function(ourIdentityKey) { var macInput = new Uint8Array(messageProto.byteLength + 33*2 + 1); macInput.set(new Uint8Array(toArrayBuffer(session.indexInfo.remoteIdentityKey))); @@ -34806,8 +34806,8 @@ window.axolotl.protocol = function(storage_interface) { var ourIdentityKey, myRegistrationId, session, hadSession; return Promise.all([ - storage_interface.getMyIdentityKey(), - storage_interface.getMyRegistrationId(), + storage_interface.getIdentityKeyPair(), + storage_interface.getLocalRegistrationId(), crypto_storage.getOpenSession(deviceObject.encodedNumber) ]).then(function(results) { ourIdentityKey = results[0]; diff --git a/libtextsecure/storage/devices.js b/libtextsecure/storage/devices.js index 1e4dcbbe..5cde620b 100644 --- a/libtextsecure/storage/devices.js +++ b/libtextsecure/storage/devices.js @@ -16,7 +16,7 @@ window.textsecure.storage.devices = { saveKeysToDeviceObject: function(deviceObject) { var number = textsecure.utils.unencodeNumber(deviceObject.encodedNumber)[0]; - return textsecure.storage.axolotl.getIdentityKey(number).then(function(identityKey) { + return textsecure.storage.axolotl.loadIdentityKey(number).then(function(identityKey) { if (identityKey !== undefined && deviceObject.identityKey !== undefined && getString(identityKey) != getString(deviceObject.identityKey)) { var error = new Error("Identity key changed"); error.identityKey = deviceObject.identityKey; @@ -60,7 +60,7 @@ }); }, getDeviceObjectsForNumber: function(number) { - return textsecure.storage.axolotl.getIdentityKey(number).then(function(identityKey) { + return textsecure.storage.axolotl.loadIdentityKey(number).then(function(identityKey) { if (identityKey === undefined) { return []; } diff --git a/libtextsecure/test/generate_keys_test.js b/libtextsecure/test/generate_keys_test.js index 2803354a..8075af59 100644 --- a/libtextsecure/test/generate_keys_test.js +++ b/libtextsecure/test/generate_keys_test.js @@ -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); }); }); diff --git a/libtextsecure/test/in_memory_axolotl_store.js b/libtextsecure/test/in_memory_axolotl_store.js index c1b2f9d5..a4020ca4 100644 --- a/libtextsecure/test/in_memory_axolotl_store.js +++ b/libtextsecure/test/in_memory_axolotl_store.js @@ -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)); diff --git a/libtextsecure/test/storage_test.js b/libtextsecure/test/storage_test.js index 16e5a7f1..6664615f 100644 --- a/libtextsecure/test/storage_test.js +++ b/libtextsecure/test/storage_test.js @@ -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() { diff --git a/test/storage_test.js b/test/storage_test.js index d267b02f..125def19 100644 --- a/test/storage_test.js +++ b/test/storage_test.js @@ -21,19 +21,19 @@ describe("AxolotlStore", function() { privKey: textsecure.crypto.getRandomBytes(32), }; it('retrieves my registration id', function(done) { - 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.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); @@ -50,8 +50,8 @@ describe("AxolotlStore", function() { }); }); 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); }); @@ -59,17 +59,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); }); @@ -77,18 +77,18 @@ 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); }); it('stores sessions', function(done) { var testRecord = "an opaque string"; - store.putSession(identifier + '.1', testRecord).then(function() { - return store.getSession(identifier + '.1').then(function(record) { + store.storeSession(identifier + '.1', testRecord).then(function() { + return store.loadSession(identifier + '.1').then(function(record) { assert.deepEqual(record, testRecord); }); }).then(done,done); @@ -101,12 +101,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]); }; @@ -116,9 +116,9 @@ describe("AxolotlStore", function() { }); it ('clears the session store', function(done) { var testRecord = "an opaque string"; - store.putSession(identifier + '.1', testRecord).then(function() { + store.storeSession(identifier + '.1', testRecord).then(function() { return store.clearSessionStore().then(function() { - return store.getSession(identifier + '.1').then(function(record) { + return store.loadSession(identifier + '.1').then(function(record) { assert.isUndefined(record); }); }); @@ -133,7 +133,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() {