From 9374832ea486af4555718043aa418e8fb69786da Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 12 Jan 2023 19:24:59 -0500 Subject: [PATCH] Enables ContextIsolation --- app/main.ts | 14 +- background.html | 16 -- .../webaudiorecorder/lib/WebAudioRecorder.js | 199 -------------- package.json | 7 +- test/index.html | 43 ---- test/test.js | 34 ++- ts/CI.ts | 58 +++-- ts/ConversationController.ts | 6 +- ts/SignalProtocolStore.ts | 4 + ts/WebAudioRecorder.ts | 161 ++++++++++++ ts/background.ts | 104 ++------ ts/components/App.tsx | 17 +- ts/components/CompositionInput.tsx | 6 +- ts/components/ConversationList.tsx | 1 + ts/components/StandaloneRegistration.tsx | 2 +- ts/components/ToastManager.tsx | 2 +- ts/components/conversation/GIF.tsx | 9 +- ts/components/conversation/Message.tsx | 11 +- ts/components/conversation/Timeline.tsx | 2 +- .../conversation/TimelineMessage.stories.tsx | 1 - .../ConversationDetailsHeader.tsx | 4 +- .../BaseConversationListItem.tsx | 19 +- .../conversationList/ContactCheckbox.tsx | 6 + .../conversationList/ContactListItem.tsx | 4 + .../conversationList/ConversationListItem.tsx | 4 + .../conversationList/CreateNewGroupButton.tsx | 1 + ts/components/stickers/StickerManager.tsx | 7 +- .../stickers/StickerManagerPackRow.tsx | 1 + ts/groups.ts | 18 +- ts/manage_full_screen_class.ts | 14 - ts/messageModifiers/MessageReceipts.ts | 4 +- ts/messageModifiers/ReadSyncs.ts | 5 +- ts/models/conversations.ts | 5 +- ts/models/messages.ts | 16 +- ts/scripts/{copy-and-concat.ts => copy.ts} | 24 +- ts/services/LinkPreview.ts | 5 +- ts/services/audioRecorder.ts | 27 +- ts/services/calling.ts | 6 +- ts/services/notifications.ts | 2 +- ts/services/storage.ts | 4 +- ts/set_os_class.ts | 21 -- ts/shims/Whisper.ts | 2 +- ts/shims/deleteAllData.ts | 2 +- ts/signal.ts | 53 ---- ts/state/ducks/app.ts | 4 +- ts/state/ducks/crashReports.ts | 4 +- ts/state/ducks/user.ts | 71 ++--- ts/state/getInitialState.ts | 41 +-- ts/state/smart/App.tsx | 15 +- ts/state/smart/CallManager.tsx | 2 +- ts/state/smart/InstallScreen.tsx | 10 +- ts/test-mock/benchmarks/convo_open_bench.ts | 3 +- ts/test-mock/benchmarks/group_send_bench.ts | 14 +- ts/test-mock/benchmarks/send_bench.ts | 10 +- ts/test-mock/benchmarks/storage_sync_bench.ts | 9 +- ts/test-mock/playwright.ts | 4 +- ts/test-mock/pnp/accept_gv2_invite_test.ts | 14 +- ts/test-mock/pnp/change_number_test.ts | 8 +- ts/test-mock/pnp/merge_test.ts | 15 +- ts/test-mock/pnp/pni_change_test.ts | 40 ++- ts/test-mock/pnp/pni_signature_test.ts | 22 +- ts/test-mock/pnp/send_gv2_invite_test.ts | 12 +- ts/test-mock/storage/archive_test.ts | 16 +- ts/test-mock/storage/max_read_keys_test.ts | 12 +- ts/test-mock/storage/message_request_test.ts | 8 +- ts/test-mock/storage/pin_unpin_test.ts | 25 +- ts/test-mock/storage/sticker_test.ts | 17 +- ts/textsecure/AccountManager.ts | 2 +- ts/util/StartupQueue.ts | 19 ++ ts/util/attachmentDownloadQueue.ts | 74 ++++++ ts/util/callingPermissions.ts | 6 +- ts/util/createIPCEvents.ts | 14 +- ts/util/handleRetry.ts | 2 +- ts/util/index.ts | 2 - ts/util/requestMicrophonePermissions.ts | 6 +- ts/{shims => util}/showConfirmationDialog.tsx | 22 +- ts/window.d.ts | 243 ++++++------------ ts/windows/main/phase1-ipc.ts | 192 +++++++------- ts/windows/main/phase2-dependencies.ts | 14 +- ts/windows/main/phase4-test.ts | 4 +- ts/windows/main/start.ts | 129 ++++++++++ ts/windows/preload.ts | 13 - yarn.lock | 13 +- 83 files changed, 1009 insertions(+), 1073 deletions(-) delete mode 100644 components/webaudiorecorder/lib/WebAudioRecorder.js create mode 100644 ts/WebAudioRecorder.ts delete mode 100644 ts/manage_full_screen_class.ts rename ts/scripts/{copy-and-concat.ts => copy.ts} (50%) delete mode 100644 ts/set_os_class.ts create mode 100644 ts/util/attachmentDownloadQueue.ts rename ts/{shims => util}/showConfirmationDialog.tsx (69%) diff --git a/app/main.ts b/app/main.ts index bfdd37e094c9..55a395dbb5db 100644 --- a/app/main.ts +++ b/app/main.ts @@ -675,7 +675,7 @@ async function createWindow() { nodeIntegration: false, nodeIntegrationInWorker: false, sandbox: false, - contextIsolation: false, + contextIsolation: !isTestEnvironment(getEnvironment()), preload: join( __dirname, usePreloadBundle @@ -1138,7 +1138,7 @@ async function showScreenShareWindow(sourceName: string) { ...defaultWebPrefs, nodeIntegration: false, nodeIntegrationInWorker: false, - sandbox: false, + sandbox: true, contextIsolation: true, preload: join(__dirname, '../ts/windows/screenShare/preload.js'), }, @@ -1192,7 +1192,7 @@ async function showAbout() { ...defaultWebPrefs, nodeIntegration: false, nodeIntegrationInWorker: false, - sandbox: false, + sandbox: true, contextIsolation: true, preload: join(__dirname, '../ts/windows/about/preload.js'), nativeWindowOpen: true, @@ -1240,7 +1240,7 @@ async function showSettingsWindow() { ...defaultWebPrefs, nodeIntegration: false, nodeIntegrationInWorker: false, - sandbox: false, + sandbox: true, contextIsolation: true, preload: join(__dirname, '../ts/windows/settings/preload.js'), nativeWindowOpen: true, @@ -1379,7 +1379,7 @@ async function showDebugLogWindow() { ...defaultWebPrefs, nodeIntegration: false, nodeIntegrationInWorker: false, - sandbox: false, + sandbox: true, contextIsolation: true, preload: join(__dirname, '../ts/windows/debuglog/preload.js'), nativeWindowOpen: true, @@ -1443,7 +1443,7 @@ function showPermissionsPopupWindow(forCalling: boolean, forCamera: boolean) { ...defaultWebPrefs, nodeIntegration: false, nodeIntegrationInWorker: false, - sandbox: false, + sandbox: true, contextIsolation: true, preload: join(__dirname, '../ts/windows/permissions/preload.js'), nativeWindowOpen: true, @@ -1784,7 +1784,7 @@ app.on('ready', async () => { webPreferences: { ...defaultWebPrefs, nodeIntegration: false, - sandbox: false, + sandbox: true, contextIsolation: true, preload: join(__dirname, '../ts/windows/loading/preload.js'), }, diff --git a/background.html b/background.html index 0e22129179c1..9980afcfd390 100644 --- a/background.html +++ b/background.html @@ -118,22 +118,6 @@ .addEventListener('dblclick', () => window.showDebugLog()); - - - - - - -