diff --git a/js/background.js b/js/background.js index 9f8b84d05..271b9de2e 100644 --- a/js/background.js +++ b/js/background.js @@ -207,11 +207,11 @@ window.log.info('Storage fetch'); storage.fetch(); - + let specialConvInited = false; const initSpecialConversations = async () => { if (specialConvInited) { - return + return; } const rssFeedConversations = await window.Signal.Data.getAllRssFeedConversations( { @@ -769,7 +769,7 @@ appView.showQRDialog(ourNumber); } }); - + Whisper.events.on('showDevicePairingDialog', async () => { if (appView) { appView.showDevicePairingDialog(); diff --git a/libloki/crypto.js b/libloki/crypto.js index 0e2d5769a..bf0f9b77f 100644 --- a/libloki/crypto.js +++ b/libloki/crypto.js @@ -204,25 +204,25 @@ // Throws for invalid signature await libsignal.Curve.async.verifySignature(issuer, data.buffer, signature); } - async function decryptToken({ cipherText64, serverPubKey64 }) { - const ivAndCiphertext = new Uint8Array( - dcodeIO.ByteBuffer.fromBase64(cipherText64).toArrayBuffer() - ); - - const serverPubKey = new Uint8Array( - dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer() - ); - const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair(); - const symmetricKey = libsignal.Curve.calculateAgreement( - serverPubKey, - privKey - ); - - const token = await DHDecrypt(symmetricKey, ivAndCiphertext); - - const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8'); - return tokenString; - } + async function decryptToken({ cipherText64, serverPubKey64 }) { + const ivAndCiphertext = new Uint8Array( + dcodeIO.ByteBuffer.fromBase64(cipherText64).toArrayBuffer() + ); + + const serverPubKey = new Uint8Array( + dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer() + ); + const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair(); + const symmetricKey = libsignal.Curve.calculateAgreement( + serverPubKey, + privKey + ); + + const token = await DHDecrypt(symmetricKey, ivAndCiphertext); + + const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8'); + return tokenString; + } const snodeCipher = new LokiSnodeChannel(); window.libloki.crypto = { @@ -231,7 +231,7 @@ FallBackSessionCipher, FallBackDecryptionError, snodeCipher, -   decryptToken, + decryptToken, generateSignatureForPairing, verifyPairingAuthorisation, // for testing diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 18799f021..8dbb648d4 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1190,14 +1190,17 @@ MessageReceiver.prototype.extend({ const contactBuffer = new ContactBuffer(attachmentPointer.data); let contactDetails = contactBuffer.next(); // Extract just the pubkeys - const friendPubKeys = [] + const friendPubKeys = []; while (contactDetails !== undefined) { friendPubKeys.push(contactDetails.number); contactDetails = contactBuffer.next(); } return Promise.all( friendPubKeys.map(async pubKey => { - const c = await window.ConversationController.getOrCreateAndWait(pubKey, 'private'); + const c = await window.ConversationController.getOrCreateAndWait( + pubKey, + 'private' + ); if (!c) { return null; }