Ensure the latest contact signed prekey is used

pull/495/head
sachaaaaa 6 years ago
parent f9df221638
commit 6de6b762e6

@ -1169,7 +1169,7 @@ async function getContactSignedPreKeyById(id) {
}
async function getContactSignedPreKeyByIdentityKey(key) {
const row = await db.get(
`SELECT * FROM ${CONTACT_SIGNED_PRE_KEYS_TABLE} WHERE identityKeyString = $identityKeyString;`,
`SELECT * FROM ${CONTACT_SIGNED_PRE_KEYS_TABLE} WHERE identityKeyString = $identityKeyString ORDER BY keyId DESC;`,
{
$identityKeyString: key,
}

@ -171,6 +171,8 @@
return -1;
};
Whisper.events = _.clone(Backbone.Events);
Whisper.events.isListenedTo = eventName =>
Whisper.events._events ? !!Whisper.events._events[eventName] : false;
let accountManager;
window.getAccountManager = () => {
if (!accountManager) {
@ -757,6 +759,10 @@
cb(e);
}
});
Whisper.events.on('devicePairingRequestRejected', async pubKey => {
await window.libloki.storage.removeContactPreKeyBundle(pubKey);
});
}
window.getSyncRequest = () =>

@ -207,6 +207,12 @@
dialog.once('devicePairingRequestAccepted', (pubKey, cb) =>
Whisper.events.trigger('devicePairingRequestAccepted', pubKey, cb)
);
dialog.on('devicePairingRequestRejected', (pubKey, cb) =>
Whisper.events.trigger('devicePairingRequestRejected', pubKey)
);
dialog.once('close', () => {
Whisper.events.off('devicePairingRequestReceived');
});
this.el.append(dialog.el);
},
});

@ -58,6 +58,7 @@
this.$('.requestAcceptedView .ok').show();
},
skipDevice() {
this.trigger('devicePairingRequestRejected', this.pubKey);
this.nextPubKey();
this.showView();
},
@ -91,6 +92,10 @@
},
close() {
this.remove();
if (this.pubKey && !this.accepted) {
this.trigger('devicePairingRequestRejected', this.pubKey);
}
this.trigger('close');
},
});
})();

@ -145,8 +145,6 @@
},
async resetRegistration() {
await window.Signal.Data.removeAllIdentityKeys();
await window.Signal.Data.removeAllPreKeys();
await window.Signal.Data.removeAllSignedPreKeys();
await window.Signal.Data.removeAllConversations();
Whisper.Registration.remove();
// Do not remove all items since they are only set

@ -1095,12 +1095,20 @@ MessageReceiver.prototype.extend({
},
async handlePairingRequest(envelope, pairingRequest) {
const valid = await this.validateAuthorisation(pairingRequest);
if (valid) {
await window.libloki.storage.savePairingAuthorisation(pairingRequest);
if (!valid) {
return this.removeFromCache(envelope);
}
await window.libloki.storage.savePairingAuthorisation(pairingRequest);
if (Whisper.events.isListenedTo('devicePairingRequestReceived')) {
Whisper.events.trigger(
'devicePairingRequestReceived',
pairingRequest.secondaryDevicePubKey
);
} else {
Whisper.events.trigger(
'devicePairingRequestRejected',
pairingRequest.secondaryDevicePubKey
);
}
return this.removeFromCache(envelope);
},

Loading…
Cancel
Save