diff --git a/.eslintignore b/.eslintignore index c4fcdff64..f0d5a4a8c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,10 +7,8 @@ mnemonic_languages/** js/curve/* js/components.js js/libtextsecure.js -js/libloki.js js/util_worker.js libtextsecure/components.js -libloki/test/test.js libtextsecure/test/test.js test/test.js @@ -24,8 +22,3 @@ test/blanket_mocha.js # TypeScript generated files ts/**/*.js **/ts/**/*.js - - -# Libloki specific files -libloki/test/components.js -libloki/modules/mnemonic.js diff --git a/.gitignore b/.gitignore index 595b3f859..6032522bc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,11 +18,8 @@ sql/ js/components.js js/util_worker.js js/libtextsecure.js -js/libloki.js libtextsecure/components.js libtextsecure/test/test.js -libloki/test/components.js -libloki/test/test.js stylesheets/*.css test/test.js diff --git a/.prettierignore b/.prettierignore index d21e26970..f77873563 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,7 +8,6 @@ dist/** js/components.js js/util_worker.js js/libtextsecure.js -js/libloki.js libtextsecure/components.js libtextsecure/test/test.js stylesheets/*.css @@ -20,10 +19,6 @@ ts/protobuf/*.js stylesheets/manifest.css ts/util/lint/exceptions.json -# Libloki specific files -libloki/test/test.js -libloki/test/components.js - # Third-party files node_modules/** components/** diff --git a/Gruntfile.js b/Gruntfile.js index 0fbb37b64..697d23011 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,16 +25,11 @@ module.exports = grunt => { libtextsecurecomponents.push(bower.concat.libtextsecure[i]); } - const liblokicomponents = []; - // eslint-disable-next-line guard-for-in, no-restricted-syntax - for (const i in bower.concat.libloki) { - liblokicomponents.push(bower.concat.libloki[i]); - } - const utilWorkerComponents = [ 'node_modules/bytebuffer/dist/bytebuffer.js', 'js/curve/curve25519_compiled.js', 'js/curve/curve25519_wrapper.js', + 'libtextsecure/libsignal-protocol.js', 'js/util_worker_tasks.js', ]; @@ -55,10 +50,6 @@ module.exports = grunt => { src: libtextsecurecomponents, dest: 'libtextsecure/components.js', }, - liblokicomponents: { - src: liblokicomponents, - dest: 'libloki/test/components.js', - }, test: { src: ['node_modules/mocha/mocha.js', 'node_modules/chai/chai.js', 'test/_test.js'], dest: 'test/test.js', @@ -84,14 +75,6 @@ module.exports = grunt => { ], dest: 'js/libtextsecure.js', }, - libloki: { - src: ['libloki/crypto.js', 'libloki/service_nodes.js', 'libloki/storage.js'], - dest: 'js/libloki.js', - }, - lokitest: { - src: ['node_modules/mocha/mocha.js', 'node_modules/chai/chai.js', 'libloki/test/_test.js'], - dest: 'libloki/test/test.js', - }, libtextsecuretest: { src: [ 'node_modules/jquery/dist/jquery.js', @@ -123,10 +106,6 @@ module.exports = grunt => { files: utilWorkerComponents, tasks: ['concat:util_worker'], }, - libloki: { - files: ['./libloki/*.js'], - tasks: ['concat:libloki'], - }, protobuf: { files: ['./protos/SignalService.proto'], tasks: ['exec:build-protobuf'], diff --git a/background.html b/background.html index fe93ef0f9..3e21aa937 100644 --- a/background.html +++ b/background.html @@ -45,7 +45,6 @@ - diff --git a/background_test.html b/background_test.html index 5f22170a7..2e04c0cab 100644 --- a/background_test.html +++ b/background_test.html @@ -45,7 +45,6 @@ - diff --git a/bower.json b/bower.json index fbe4fd919..a853b9a72 100644 --- a/bower.json +++ b/bower.json @@ -35,9 +35,6 @@ "libtextsecure": [ "node_modules/long/dist/long.js", "components/protobuf/**/*.js" - ], - "libloki": [ - "node_modules/long/dist/long.js" ] } } \ No newline at end of file diff --git a/js/libloki.js b/js/libloki.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/util_worker_tasks.js b/js/util_worker_tasks.js index 1bd418c39..7a6e386e4 100644 --- a/js/util_worker_tasks.js +++ b/js/util_worker_tasks.js @@ -6,6 +6,10 @@ const functions = { arrayBufferToStringBase64, fromBase64ToArrayBuffer, verifySignature, + DecryptAESGCM, + deriveSymmetricKey, + encryptForPubkey, + generateEphemeralKeyPair, }; onmessage = async e => { @@ -40,17 +44,43 @@ function arrayBufferToStringBase64(arrayBuffer) { return dcodeIO.ByteBuffer.wrap(arrayBuffer).toString('base64'); } -function fromBase64ToArrayBuffer(value) { - return dcodeIO.ByteBuffer.wrap(value, 'base64').toArrayBuffer(); +function fromBase64ToArrayBuffer(base64Str) { + return dcodeIO.ByteBuffer.wrap(base64Str, 'base64').toArrayBuffer(); } +function fromHexToArray(hexStr) { + return new Uint8Array(dcodeIO.ByteBuffer.wrap(hexStr, 'hex').toArrayBuffer()); +} + +function fromHexToArrayBuffer(hexStr) { + return dcodeIO.ByteBuffer.wrap(hexStr, 'hex').toArrayBuffer(); +} + +function bytesFromString(string) { + return dcodeIO.ByteBuffer.wrap(string, 'utf8').toArrayBuffer(); +} + +// hexString, base64String, base64String async function verifySignature(senderPubKey, messageBase64, signatureBase64) { try { + if (typeof senderPubKey !== 'string') { + throw new Error('senderPubKey type not correct'); + } + if (typeof messageBase64 !== 'string') { + throw new Error('messageBase64 type not correct'); + } + if (typeof signatureBase64 !== 'string') { + throw new Error('signatureBase64 type not correct'); + } const messageData = new Uint8Array(fromBase64ToArrayBuffer(messageBase64)); const signature = new Uint8Array(fromBase64ToArrayBuffer(signatureBase64)); // verify returns true if the signature is not correct - const verifyRet = Internal.curve25519.verify(senderPubKey, messageData, signature); + const verifyRet = Internal.curve25519.verify( + fromHexToArray(senderPubKey), + messageData, + signature + ); if (verifyRet) { console.warn('Invalid signature'); return false; @@ -62,3 +92,107 @@ async function verifySignature(senderPubKey, messageBase64, signatureBase64) { return false; } } + +const NONCE_LENGTH = 12; + +// uint8array, uint8array +async function deriveSymmetricKey(x25519PublicKey, x25519PrivateKey) { + assertArrayBufferView(x25519PublicKey); + assertArrayBufferView(x25519PrivateKey); + const ephemeralSecret = await libsignal.Curve.async.calculateAgreement( + x25519PublicKey.buffer, + x25519PrivateKey.buffer + ); + + const salt = bytesFromString('LOKI'); + + const key = await crypto.subtle.importKey( + 'raw', + salt, + { name: 'HMAC', hash: { name: 'SHA-256' } }, + false, + ['sign'] + ); + const symmetricKey = await crypto.subtle.sign( + { name: 'HMAC', hash: 'SHA-256' }, + key, + ephemeralSecret + ); + + return symmetricKey; +} + +async function generateEphemeralKeyPair() { + const keys = await libsignal.Curve.async.generateKeyPair(); + // Signal protocol prepends with "0x05" + keys.pubKey = keys.pubKey.slice(1); + return keys; +} + +function assertArrayBufferView(val) { + if (!ArrayBuffer.isView(val)) { + throw new Error('val type not correct'); + } +} + +// encryptForPubkey: hexString, payloadBytes: Uint8Array +async function encryptForPubkey(pubkeyX25519str, payloadBytes) { + try { + if (typeof pubkeyX25519str !== 'string') { + throw new Error('pubkeyX25519str type not correct'); + } + assertArrayBufferView(payloadBytes); + const ephemeral = await generateEphemeralKeyPair(); + const pubkeyX25519Buffer = fromHexToArray(pubkeyX25519str); + const symmetricKey = await deriveSymmetricKey( + pubkeyX25519Buffer, + new Uint8Array(ephemeral.privKey) + ); + const ciphertext = await EncryptAESGCM(symmetricKey, payloadBytes); + + return { ciphertext, symmetricKey, ephemeralKey: ephemeral.pubKey }; + } catch (e) { + console.warn('encryptForPubkey got an error:', e); + return null; + } +} + +async function EncryptAESGCM(symmetricKey, plaintext) { + const nonce = crypto.getRandomValues(new Uint8Array(NONCE_LENGTH)); + + const key = await crypto.subtle.importKey('raw', symmetricKey, { name: 'AES-GCM' }, false, [ + 'encrypt', + ]); + + const ciphertext = await crypto.subtle.encrypt( + { name: 'AES-GCM', iv: nonce, tagLength: 128 }, + key, + plaintext + ); + + const ivAndCiphertext = new Uint8Array(NONCE_LENGTH + ciphertext.byteLength); + + ivAndCiphertext.set(nonce); + ivAndCiphertext.set(new Uint8Array(ciphertext), nonce.byteLength); + + return ivAndCiphertext; +} + +// uint8array, uint8array +async function DecryptAESGCM(symmetricKey, ivAndCiphertext) { + assertArrayBufferView(symmetricKey); + + assertArrayBufferView(ivAndCiphertext); + + const nonce = ivAndCiphertext.buffer.slice(0, NONCE_LENGTH); + const ciphertext = ivAndCiphertext.buffer.slice(NONCE_LENGTH); + const key = await crypto.subtle.importKey( + 'raw', + symmetricKey.buffer, + { name: 'AES-GCM' }, + false, + ['decrypt'] + ); + + return crypto.subtle.decrypt({ name: 'AES-GCM', iv: nonce }, key, ciphertext); +} diff --git a/libloki/crypto.d.ts b/libloki/crypto.d.ts deleted file mode 100644 index 303b59709..000000000 --- a/libloki/crypto.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface CryptoInterface { - DecryptAESGCM: (symmetricKey: ArrayBuffer, ivAndCiphertext: ArrayBuffer) => Promise; // AES-GCM - deriveSymmetricKey: (pubkey: ArrayBuffer, seckey: ArrayBuffer) => Promise; - encryptForPubkey: ( - publicKey: string, - data: Uint8Array - ) => Promise<{ ciphertext: Uint8Array; symmetricKey: ArrayBuffer; ephemeralKey: ArrayBuffer }>; -} diff --git a/libloki/crypto.js b/libloki/crypto.js deleted file mode 100644 index fe180c3c2..000000000 --- a/libloki/crypto.js +++ /dev/null @@ -1,95 +0,0 @@ -/* global - window, - libsignal, - StringView, - TextEncoder, - TextDecoder, - crypto, - libloki -*/ - -// eslint-disable-next-line func-names -(function() { - window.libloki = window.libloki || {}; - - const NONCE_LENGTH = 12; - - async function deriveSymmetricKey(x25519PublicKey, x25519PrivateKey) { - const ephemeralSecret = await libsignal.Curve.async.calculateAgreement( - x25519PublicKey, - x25519PrivateKey - ); - - const salt = window.Signal.Crypto.bytesFromString('LOKI'); - - const key = await crypto.subtle.importKey( - 'raw', - salt, - { name: 'HMAC', hash: { name: 'SHA-256' } }, - false, - ['sign'] - ); - const symmetricKey = await crypto.subtle.sign( - { name: 'HMAC', hash: 'SHA-256' }, - key, - ephemeralSecret - ); - - return symmetricKey; - } - - // encryptForPubkey: string, payloadBytes: Uint8Array - async function encryptForPubkey(pubkeyX25519, payloadBytes) { - const ephemeral = await libloki.crypto.generateEphemeralKeyPair(); - const snPubkey = StringView.hexToArrayBuffer(pubkeyX25519); - const symmetricKey = await deriveSymmetricKey(snPubkey, ephemeral.privKey); - const ciphertext = await EncryptAESGCM(symmetricKey, payloadBytes); - - return { ciphertext, symmetricKey, ephemeralKey: ephemeral.pubKey }; - } - - async function EncryptAESGCM(symmetricKey, plaintext) { - const nonce = crypto.getRandomValues(new Uint8Array(NONCE_LENGTH)); - - const key = await crypto.subtle.importKey('raw', symmetricKey, { name: 'AES-GCM' }, false, [ - 'encrypt', - ]); - - const ciphertext = await crypto.subtle.encrypt( - { name: 'AES-GCM', iv: nonce, tagLength: 128 }, - key, - plaintext - ); - - const ivAndCiphertext = new Uint8Array(NONCE_LENGTH + ciphertext.byteLength); - - ivAndCiphertext.set(nonce); - ivAndCiphertext.set(new Uint8Array(ciphertext), nonce.byteLength); - - return ivAndCiphertext; - } - - async function DecryptAESGCM(symmetricKey, ivAndCiphertext) { - const nonce = ivAndCiphertext.slice(0, NONCE_LENGTH); - const ciphertext = ivAndCiphertext.slice(NONCE_LENGTH); - const key = await crypto.subtle.importKey('raw', symmetricKey, { name: 'AES-GCM' }, false, [ - 'decrypt', - ]); - - return crypto.subtle.decrypt({ name: 'AES-GCM', iv: nonce }, key, ciphertext); - } - async function generateEphemeralKeyPair() { - const keys = await libsignal.Curve.async.generateKeyPair(); - // Signal protocol prepends with "0x05" - keys.pubKey = keys.pubKey.slice(1); - return keys; - } - - window.libloki.crypto = { - EncryptAESGCM, // AES-GCM - DecryptAESGCM, // AES-GCM - deriveSymmetricKey, - generateEphemeralKeyPair, - encryptForPubkey, - }; -})(); diff --git a/libloki/index.d.ts b/libloki/index.d.ts deleted file mode 100644 index 0a0c93e6a..000000000 --- a/libloki/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { CryptoInterface } from './crypto'; - -export interface Libloki { - api: any; - crypto: CryptoInterface; - storage: any; -} diff --git a/libtextsecure/libsignal-protocol.js b/libtextsecure/libsignal-protocol.js index 653de97fd..4a30de345 100644 --- a/libtextsecure/libsignal-protocol.js +++ b/libtextsecure/libsignal-protocol.js @@ -1,6 +1,12 @@ + +var libsignal ; (function () { var Internal = {}; - window.libsignal = {}; + libsignal = typeof window === 'undefined' ? {} : window.libsignal || {}; + if (typeof window !== 'undefined') { + window.libsignal = libsignal; + } + // The Module object: Our interface to the outside world. We import // and export values on it, and do the work to get that through // closure compiler if necessary. There are various ways Module can be used: @@ -35178,7 +35184,7 @@ (function () { 'use strict'; - var crypto = window.crypto; + var crypto = typeof window === 'undefined' ? self.crypto : window.crypto || {}; if (!crypto || !crypto.subtle || typeof crypto.getRandomValues !== 'function') { throw new Error('WebCrypto not found'); diff --git a/package.json b/package.json index a027c1b55..eba0d1e02 100644 --- a/package.json +++ b/package.json @@ -290,7 +290,6 @@ "password.html", "debug_log.html", "_locales/**", - "libloki/modules/*.js", "mnemonic_languages/**", "protos/*", "js/**", diff --git a/test/index.html b/test/index.html index cb961f017..5818b0412 100644 --- a/test/index.html +++ b/test/index.html @@ -28,7 +28,6 @@ - diff --git a/ts/components/session/conversation/SessionRightPanel.tsx b/ts/components/session/conversation/SessionRightPanel.tsx index 2e9f4ebf8..649b24a65 100644 --- a/ts/components/session/conversation/SessionRightPanel.tsx +++ b/ts/components/session/conversation/SessionRightPanel.tsx @@ -281,7 +281,6 @@ export const SessionRightPanelWithDetails = (props: Props) => { } = props; const showMemberCount = !!(memberCount && memberCount > 0); const commonNoShow = isKickedFromGroup || left || isBlocked; - console.warn('AUDRIC: render right panel'); const hasDisappearingMessages = !isPublic && !commonNoShow; const leaveGroupString = isPublic ? window.i18n('leaveGroup') diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 290e4c9db..2fb92c817 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -169,7 +169,7 @@ export class ConversationModel extends Backbone.Model { public updateLastMessage: () => any; public throttledBumpTyping: any; public throttledNotify: any; - public markRead: any; + public markRead: (newestUnreadDate: number, providedOptions: any) => Promise; public initialPromise: any; private typingRefreshTimer?: NodeJS.Timeout | null; diff --git a/ts/opengroup/opengroupV2/ApiAuth.ts b/ts/opengroup/opengroupV2/ApiAuth.ts index cf1f94f40..afd27eaad 100644 --- a/ts/opengroup/opengroupV2/ApiAuth.ts +++ b/ts/opengroup/opengroupV2/ApiAuth.ts @@ -153,19 +153,27 @@ export async function requestNewAuthToken({ window?.log?.warn('Parsing failed'); return null; } - const ciphertext = await window.callWorker('fromBase64ToArrayBuffer', base64EncodedCiphertext); - const ephemeralPublicKey = await window.callWorker( + const ciphertext = (await window.callWorker( + 'fromBase64ToArrayBuffer', + base64EncodedCiphertext + )) as ArrayBuffer; + const ephemeralPublicKey = (await window.callWorker( 'fromBase64ToArrayBuffer', base64EncodedEphemeralPublicKey - ); + )) as ArrayBuffer; try { - const symmetricKey = await window.libloki.crypto.deriveSymmetricKey( - ephemeralPublicKey, - userKeyPair.privKey + const symmetricKey = (await window.callWorker( + 'deriveSymmetricKey', + new Uint8Array(ephemeralPublicKey), + new Uint8Array(userKeyPair.privKey) + )) as ArrayBuffer; + + const plaintextBuffer = await window.callWorker( + 'DecryptAESGCM', + new Uint8Array(symmetricKey), + new Uint8Array(ciphertext) ); - const plaintextBuffer = await window.libloki.crypto.DecryptAESGCM(symmetricKey, ciphertext); - const token = toHex(plaintextBuffer); return token; diff --git a/ts/opengroup/opengroupV2/ApiUtil.ts b/ts/opengroup/opengroupV2/ApiUtil.ts index 77f856ae2..36a5e8f36 100644 --- a/ts/opengroup/opengroupV2/ApiUtil.ts +++ b/ts/opengroup/opengroupV2/ApiUtil.ts @@ -68,7 +68,7 @@ export const parseMessages = async ( const signatureValid = (await window.callWorker( 'verifySignature', - fromHexToArray(senderPubKey), + senderPubKey, opengroupv2Message.base64EncodedData, opengroupv2Message.base64EncodedSignature )) as boolean; diff --git a/ts/receiver/attachments.ts b/ts/receiver/attachments.ts index b1a7950b6..96dcf68b5 100644 --- a/ts/receiver/attachments.ts +++ b/ts/receiver/attachments.ts @@ -51,11 +51,10 @@ export async function downloadAttachment(attachment: any) { throw new Error('Attachment is not raw but we do not have a key to decode it'); } - data = await window.textsecure.crypto.decryptAttachment( - data, - await window.callWorker('fromBase64ToArrayBuffer', key), - await window.callWorker('fromBase64ToArrayBuffer', digest) - ); + const keyBuffer = await window.callWorker('fromBase64ToArrayBuffer', key); + const digestBuffer = await window.callWorker('fromBase64ToArrayBuffer', digest); + + data = await window.textsecure.crypto.decryptAttachment(data, keyBuffer, digestBuffer); if (!size || size !== data.byteLength) { // we might have padding, check that all the remaining bytes are padding bytes diff --git a/ts/receiver/closedGroups.ts b/ts/receiver/closedGroups.ts index 776217c98..306ebd520 100644 --- a/ts/receiver/closedGroups.ts +++ b/ts/receiver/closedGroups.ts @@ -45,7 +45,7 @@ const cacheOfClosedGroupKeyPairs: Map> = new Map(); export async function getAllCachedECKeyPair(groupPubKey: string) { let keyPairsFound = cacheOfClosedGroupKeyPairs.get(groupPubKey); - if (!keyPairsFound) { + if (!keyPairsFound || keyPairsFound.length === 0) { keyPairsFound = (await getAllEncryptionKeyPairsForGroup(groupPubKey)) || []; cacheOfClosedGroupKeyPairs.set(groupPubKey, keyPairsFound); } @@ -414,6 +414,7 @@ async function handleClosedGroupEncryptionKeyPair( ourWrapper.encryptedKeyPair, ECKeyPair.fromKeyPair(ourKeyPair) ); + if (!buffer || buffer.byteLength === 0) { throw new Error(); } diff --git a/ts/receiver/receiver.ts b/ts/receiver/receiver.ts index eac39e4a6..398a93fdd 100644 --- a/ts/receiver/receiver.ts +++ b/ts/receiver/receiver.ts @@ -1,5 +1,3 @@ -// TODO: fix libloki and textsecure not being available here yet - import { EnvelopePlus } from './types'; export { downloadAttachment } from './attachments'; import { v4 as uuidv4 } from 'uuid'; diff --git a/ts/session/snode_api/onions.ts b/ts/session/snode_api/onions.ts index 765c16114..ec4a1a04f 100644 --- a/ts/session/snode_api/onions.ts +++ b/ts/session/snode_api/onions.ts @@ -4,7 +4,7 @@ import https from 'https'; import { dropSnodeFromSnodePool, dropSnodeFromSwarmIfNeeded, updateSwarmFor } from './snodePool'; import ByteBuffer from 'bytebuffer'; import { OnionPaths } from '../onions'; -import { toHex } from '../utils/String'; +import { fromHex, toHex } from '../utils/String'; import pRetry from 'p-retry'; import { incrementBadPathCountOrDrop } from '../onions/onionPath'; import _ from 'lodash'; @@ -49,7 +49,7 @@ async function encryptForPubKey(pubKeyX25519hex: string, reqObj: any): Promise { }, }); - TestUtils.stubWindow('libloki', { - crypto: { - encryptForPubkey: sinon.fake.returns(''), - } as any, - }); - sandbox.stub(UserUtils, 'getOurPubKeyStrFromCache').returns(ourNumber); sandbox.stub(UserUtils, 'getUserED25519KeyPair').resolves(ourUserEd25516Keypair); }); diff --git a/ts/test/session/unit/onion/OnionErrors_test.ts b/ts/test/session/unit/onion/OnionErrors_test.ts index 44a9a538c..84e530cc6 100644 --- a/ts/test/session/unit/onion/OnionErrors_test.ts +++ b/ts/test/session/unit/onion/OnionErrors_test.ts @@ -132,12 +132,6 @@ describe('OnionPathsErrors', () => { await OnionPaths.getOnionPath(); oldOnionPaths = OnionPaths.TEST_getTestOnionPath(); - - TestUtils.stubWindow('libloki', { - crypto: { - DecryptAESGCM: async (s: any, e: string) => e, - } as any, - }); sandbox .stub(SNodeAPI.Onions, 'decodeOnionResult') .callsFake((_symkey: ArrayBuffer, plaintext: string) => diff --git a/ts/util/lint/linter.ts b/ts/util/lint/linter.ts index 03a9d7a19..a217f8056 100644 --- a/ts/util/lint/linter.ts +++ b/ts/util/lint/linter.ts @@ -56,7 +56,6 @@ const excludedFiles = [ '^js/components.js', '^js/curve/', '^js/libtextsecure.js', - '^js/libloki.js', '^js/util_worker.js', '^libtextsecure/components.js', '^libtextsecure/test/test.js', @@ -66,7 +65,6 @@ const excludedFiles = [ '^libtextsecure/libsignal-protocol.js', // Test files - '^libloki/test/*', '^libtextsecure/test/*', '^test/*', diff --git a/ts/window.d.ts b/ts/window.d.ts index c31b16749..2fdc03466 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -3,7 +3,6 @@ import {} from 'styled-components/cssprop'; import { LocalizerType } from '../types/Util'; import { LibsignalProtocol } from '../../libtextsecure/libsignal-protocol'; import { SignalInterface } from '../../js/modules/signal'; -import { Libloki } from '../libloki'; import { LibTextsecure } from '../libtextsecure'; import { ConfirmationDialogParams } from '../background'; @@ -19,6 +18,8 @@ We declare window stuff here instead of global.d.ts because we are importing oth If you import anything in global.d.ts, the type system won't work correctly. */ +type UtilWorkerFunctionType = (fnName: string, ...args: any) => Promise; + declare global { interface Window { CONSTANTS: any; @@ -40,7 +41,6 @@ declare global { getFriendsFromContacts: any; getSettingValue: any; i18n: LocalizerType; - libloki: Libloki; libsignal: LibsignalProtocol; log: any; lokiFeatureFlags: { @@ -81,9 +81,6 @@ declare global { LokiPushNotificationServer: any; globalOnlineStatus: boolean; confirmationDialog: any; - callWorker: ( - fnName: 'arrayBufferToStringBase64' | 'fromBase64ToArrayBuffer' | 'verifySignature', - ...args - ) => Promise; + callWorker: (fnName: string, ...args: any) => Promise; } }