Error toast on computeSecret error.

This commit is contained in:
Mega-Mewthree 2018-08-11 16:28:34 -07:00
parent 7e41fe73e7
commit c10310af3a
2 changed files with 11 additions and 6 deletions

View File

@ -201,11 +201,15 @@ export default new class E2EE extends BuiltinModule {
} }
computeSecret(userID, otherKey) { computeSecret(userID, otherKey) {
const secret = this.ecdh[userID].computeSecret(otherKey, 'base64', 'base64'); try {
delete this.ecdh[userID]; const secret = this.ecdh[userID].computeSecret(otherKey, 'base64', 'base64');
const hash = crypto.createHash('sha256'); delete this.ecdh[userID];
hash.update(secret); const hash = crypto.createHash('sha256');
return hash.digest('base64'); hash.update(secret);
return hash.digest('base64');
} catch (e) {
throw e;
}
} }
handleChannelTextAreaSubmit(component, args, retVal) { handleChannelTextAreaSubmit(component, args, retVal) {

View File

@ -60,7 +60,8 @@
chatInput[Object.keys(chatInput).find(k => k.startsWith('__reactEventHandlers'))].onChange.call(chatInput, evt); chatInput[Object.keys(chatInput).find(k => k.startsWith('__reactEventHandlers'))].onChange.call(chatInput, evt);
Toasts.success("Encryption key has been set for this DM channel."); Toasts.success("Encryption key has been set for this DM channel.");
} catch (e) { } catch (e) {
throw e; Toasts.error("Invalid public key. Please set up a new key exchange.");
console.error(e);
} }
} }