diff --git a/js/api.js b/js/api.js index 5c6860cb0..41272b9df 100644 --- a/js/api.js +++ b/js/api.js @@ -31,7 +31,7 @@ window.textsecure.api = function() { var URL_CALLS = {}; URL_CALLS['accounts'] = "/v1/accounts"; URL_CALLS['devices'] = "/v1/devices"; - URL_CALLS['keys'] = "/v1/keys"; + URL_CALLS['keys'] = "/v2/keys"; URL_CALLS['push'] = "/v1/websocket"; URL_CALLS['messages'] = "/v1/messages"; URL_CALLS['attachment'] = "/v1/attachments"; diff --git a/js/crypto.js b/js/crypto.js index a949bcdde..e384c2081 100644 --- a/js/crypto.js +++ b/js/crypto.js @@ -779,15 +779,14 @@ window.textsecure.crypto = function() { var signedKeyId = textsecure.storage.getEncrypted("signedKeyId", 0); textsecure.storage.putEncrypted("signedKeyId", signedKeyId + 1); - textsecure.storage.putEncrypted("lastSignedKeyUpdate", Date.now()); var keys = {}; keys.identityKey = identityKeyPair.pubKey; - keys.keys = []; + keys.preKeys = []; var generateKey = function(keyId) { return crypto_storage.getNewStoredKeyPair("preKey" + keyId, false).then(function(keyPair) { - keys.keys[keyId] = {keyId: keyId, publicKey: keyPair.pubKey}; + keys.preKeys[keyId] = {keyId: keyId, publicKey: keyPair.pubKey}; }); }; @@ -797,7 +796,7 @@ window.textsecure.crypto = function() { promises[firstPreKeyId + GENERATE_KEYS_KEYS_GENERATED] = crypto_storage.getNewStoredKeyPair("signedKey" + signedKeyId).then(function(keyPair) { return Ed25519Sign(identityKeyPair.privKey, keyPair.pubKey).then(function(sig) { - keys.signedKey = {keyId: signedKeyId, publicKey: keyPair.pubKey, signature: sig}; + keys.signedPreKey = {keyId: signedKeyId, publicKey: keyPair.pubKey, signature: sig}; }); }); @@ -814,6 +813,7 @@ window.textsecure.crypto = function() { } window.textsecure.registerOnLoadFunction(function() { + //TODO: Dont always update prekeys here if (textsecure.storage.getEncrypted("lastSignedKeyUpdate", Date.now()) < Date.now() - MESSAGE_LOST_THRESHOLD_MS) self.generateKeys(); });