diff --git a/web/crypto/aes-gcm-crypto-utils.js b/web/crypto/aes-gcm-crypto-utils.js --- a/web/crypto/aes-gcm-crypto-utils.js +++ b/web/crypto/aes-gcm-crypto-utils.js @@ -6,7 +6,7 @@ 'decrypt', ]; -type EncryptedData = { +export type EncryptedData = { +iv: BufferSource, +ciphertext: Uint8Array, }; diff --git a/web/database/database-module-provider.js b/web/database/database-module-provider.js --- a/web/database/database-module-provider.js +++ b/web/database/database-module-provider.js @@ -131,7 +131,9 @@ } async function getSafariEncryptionKey(): Promise { - const encryptionKey = await localforage.getItem(SQLITE_ENCRYPTION_KEY); + const encryptionKey = await localforage.getItem( + SQLITE_ENCRYPTION_KEY, + ); if (encryptionKey) { return await exportKeyToJWK(encryptionKey); } diff --git a/web/database/worker/db-worker.js b/web/database/worker/db-worker.js --- a/web/database/worker/db-worker.js +++ b/web/database/worker/db-worker.js @@ -11,6 +11,7 @@ encryptData, generateCryptoKey, importJWKKey, + type EncryptedData, } from '../../crypto/aes-gcm-crypto-utils.js'; import { type SharedWorkerMessageEvent, @@ -74,7 +75,9 @@ } } - const encryptedContent = await localforage.getItem(SQLITE_CONTENT); + const encryptedContent = await localforage.getItem( + SQLITE_CONTENT, + ); let dbContent = null; try { diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -233,7 +233,7 @@ } static completedMessageIDs(state: State): Set { - const completed = new Map(); + const completed = new Map(); for (const threadID in state.pendingUploads) { const pendingUploads = state.pendingUploads[threadID]; for (const localUploadID in pendingUploads) { @@ -251,7 +251,7 @@ } } } - const messageIDs = new Set(); + const messageIDs = new Set(); for (const [messageID, isCompleted] of completed) { if (isCompleted) { messageIDs.add(messageID); @@ -266,7 +266,7 @@ return; } - const previouslyAssignedMessageIDs = new Set(); + const previouslyAssignedMessageIDs = new Set(); for (const threadID in prevState.pendingUploads) { const pendingUploads = prevState.pendingUploads[threadID]; for (const localUploadID in pendingUploads) { @@ -277,7 +277,14 @@ } } - const newlyAssignedUploads = new Map(); + const newlyAssignedUploads = new Map< + string, + { + +threadID: string, + +shouldEncrypt: boolean, + +uploads: PendingMultimediaUpload[], + }, + >(); for (const threadID in this.state.pendingUploads) { const pendingUploads = this.state.pendingUploads[threadID]; for (const localUploadID in pendingUploads) { @@ -307,7 +314,7 @@ } } - const newMessageInfos = new Map(); + const newMessageInfos = new Map(); for (const [messageID, assignedUploads] of newlyAssignedUploads) { const { uploads, threadID, shouldEncrypt } = assignedUploads; const creatorID = this.props.viewerID; @@ -1537,7 +1544,7 @@ payload: newRawMessageInfo, }); - const uploadIDsToRetry = new Set(); + const uploadIDsToRetry = new Set(); const uploadsToRetry = []; for (const pendingUpload of pendingUploads) { const { serverID, messageID, localID, abort } = pendingUpload; @@ -1670,7 +1677,7 @@ [], ); const textMessageCreationSideEffectsFunc = - useMessageCreationSideEffectsFunc(messageTypes.TEXT); + useMessageCreationSideEffectsFunc(messageTypes.TEXT); return ( Math.floor(Math.random() * 255)), + new Array(100).fill(0).map(() => Math.floor(Math.random() * 255)), ); describe('generateKey', () => { diff --git a/web/modals/chat/message-results-modal.react.js b/web/modals/chat/message-results-modal.react.js --- a/web/modals/chat/message-results-modal.react.js +++ b/web/modals/chat/message-results-modal.react.js @@ -90,7 +90,10 @@ // By the nature of using messageListData and passing in // the desired translatedMessageResults as additional // messages, we will have duplicate ChatMessageInfoItems. - const uniqueChatMessageInfoItemsMap = new Map(); + const uniqueChatMessageInfoItemsMap = new Map< + string, + ChatMessageInfoItem, + >(); chatMessageInfoItems.forEach( item => item.messageInfo && @@ -103,8 +106,12 @@ // in the order of pin_time (newest first). const sortedChatMessageInfoItems = []; for (let i = 0; i < rawMessageResults.length; i++) { + const rawMessageID = rawMessageResults[i].id; + if (!rawMessageID) { + continue; + } sortedChatMessageInfoItems.push( - uniqueChatMessageInfoItemsMap.get(rawMessageResults[i].id), + uniqueChatMessageInfoItemsMap.get(rawMessageID), ); } diff --git a/web/push-notif/notif-crypto-utils.js b/web/push-notif/notif-crypto-utils.js --- a/web/push-notif/notif-crypto-utils.js +++ b/web/push-notif/notif-crypto-utils.js @@ -17,6 +17,7 @@ decryptData, encryptData, importJWKKey, + type EncryptedData, } from '../crypto/aes-gcm-crypto-utils.js'; import { NOTIFICATIONS_OLM_DATA_CONTENT, @@ -51,7 +52,7 @@ const { id, encryptedPayload } = encryptedNotification; const retrieveEncryptionKeyPromise: Promise = (async () => { - const persistedCryptoKey = await localforage.getItem( + const persistedCryptoKey = await localforage.getItem( NOTIFICATIONS_OLM_DATA_ENCRYPTION_KEY, ); if (isDesktopSafari && persistedCryptoKey) { @@ -63,9 +64,11 @@ })(); const [encryptedOlmData, encryptionKey, utilsData] = await Promise.all([ - localforage.getItem(NOTIFICATIONS_OLM_DATA_CONTENT), + localforage.getItem(NOTIFICATIONS_OLM_DATA_CONTENT), retrieveEncryptionKeyPromise, - localforage.getItem(WEB_NOTIFS_SERVICE_UTILS_KEY), + localforage.getItem( + WEB_NOTIFS_SERVICE_UTILS_KEY, + ), ]); if (!utilsData) { diff --git a/web/roles/community-roles-modal.react.js b/web/roles/community-roles-modal.react.js --- a/web/roles/community-roles-modal.react.js +++ b/web/roles/community-roles-modal.react.js @@ -5,6 +5,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js'; import { threadInfoSelector } from 'lib/selectors/thread-selectors.js'; import { useRoleMemberCountsForCommunity } from 'lib/shared/thread-utils.js'; +import type { UserSurfacedPermission } from 'lib/types/thread-permission-types.js'; import type { ThreadInfo } from 'lib/types/thread-types.js'; import css from './community-roles-modal.css'; @@ -49,7 +50,10 @@ [roleNamesToMembers, threadInfo], ); - const rolePermissionsForNewRole = React.useMemo(() => new Set(), []); + const rolePermissionsForNewRole = React.useMemo( + () => new Set(), + [], + ); const onClickCreateRole = React.useCallback( () => diff --git a/web/search/message-search-state-provider.react.js b/web/search/message-search-state-provider.react.js --- a/web/search/message-search-state-provider.react.js +++ b/web/search/message-search-state-provider.react.js @@ -37,7 +37,7 @@ [threadID: string]: $ReadOnlyArray, }>({}); - const endsReached = React.useRef(new Set()); + const endsReached = React.useRef(new Set()); const lastIDs = React.useRef<{ [threadID: string]: string,