diff --git a/js/modules/migrations/migrations_0_database_with_attachment_data.js b/js/modules/migrations/migrations_0_database_with_attachment_data.js index aec09f75c..f4490d63b 100644 --- a/js/modules/migrations/migrations_0_database_with_attachment_data.js +++ b/js/modules/migrations/migrations_0_database_with_attachment_data.js @@ -48,11 +48,11 @@ const migrations = [ transaction.db.createObjectStore('signedPreKeys'); transaction.db.createObjectStore('items'); - const contactPreKeys = transaction.db.createObjectStore('contactPreKeys', { autoIncrement : true }); - contactPreKeys.createIndex('publicKeyString', 'publicKeyString', { unique: false }); + const contactPreKeys = transaction.db.createObjectStore('contactPreKeys', { keyPath: 'id', autoIncrement : true }); + contactPreKeys.createIndex('identityKeyString', 'identityKeyString', { unique: false }); - const contactSignedPreKeys = transaction.db.createObjectStore('contactSignedPreKeys', { autoIncrement : true }); - contactSignedPreKeys.createIndex('publicKeyString', 'publicKeyString', { unique: false }); + const contactSignedPreKeys = transaction.db.createObjectStore('contactSignedPreKeys', { keyPath: 'id', autoIncrement : true }); + contactSignedPreKeys.createIndex('identityKeyString', 'identityKeyString', { unique: false }); window.log.info('creating debug log'); transaction.db.createObjectStore('debug'); diff --git a/js/signal_protocol_store.js b/js/signal_protocol_store.js index 7da36892a..22310e3a6 100644 --- a/js/signal_protocol_store.js +++ b/js/signal_protocol_store.js @@ -224,15 +224,16 @@ }); }, loadContactPreKey(pubKey) { - const prekey = new ContactPreKey({ id: pubKey }); + const prekey = new ContactPreKey({ identityKeyString: pubKey }); return new Promise(resolve => { prekey.fetch().then( () => { window.log.info('Successfully fetched contact prekey:', pubKey); resolve({ + id: prekey.get('id'), keyId: prekey.get('keyId'), publicKey: prekey.get('publicKey'), - identityKey: prekey.get('identityKey'), + identityKeyString: prekey.get('identityKeyString'), }); }, () => { @@ -245,7 +246,7 @@ storeContactPreKey(pubKey, preKey) { const prekey = new ContactPreKey({ // id: (autoincrement) - publicKeyString: pubKey, + identityKeyString: pubKey, publicKey: preKey.publicKey, keyId: preKey.keyId, }); @@ -320,7 +321,7 @@ }); }, loadContactSignedPreKey(pubKey) { - const prekey = new ContactSignedPreKey({ id: pubKey }); + const prekey = new ContactSignedPreKey({ identityKeyString: pubKey }); return new Promise(resolve => { prekey .fetch() @@ -330,8 +331,8 @@ prekey.get('id') ); resolve({ - id: preKey.get('id'), - publicKeyString: preKey.get('publicKeyString'), + id: prekey.get('id'), + identityKeyString: prekey.get('identityKeyString'), publicKey: prekey.get('publicKey'), signature: prekey.get('signature'), created_at: prekey.get('created_at'), @@ -383,7 +384,7 @@ storeContactSignedPreKey(pubKey, signedPreKey) { const prekey = new ContactSignedPreKey({ // id: (autoincrement) - publicKeyString: pubKey, + identityKeyString: pubKey, keyId: signedPreKey.keyId, publicKey: signedPreKey.publicKey, signature: signedPreKey.signature, diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index b20ad28e1..d48445853 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -78,7 +78,7 @@ }), ]; - for (let keyId = 0; keyId < 100; keyId += 1) { + for (let keyId = 0; keyId < 10; keyId += 1) { promises.push( libsignal.KeyHelper.generatePreKey(keyId) .then((preKey) => { @@ -86,7 +86,7 @@ }), ) } - Promise.all(promises).then( + return Promise.all(promises).then( log.info("Added mock contact with pubkey " + pubKey) ); });