Skip to content

Commit

Permalink
Update Electron to 6.0.1, SQLCipher to 4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Aug 21, 2019
1 parent b6da081 commit e29eee4
Show file tree
Hide file tree
Showing 11 changed files with 785 additions and 931 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.13.0
12.4.0
2 changes: 1 addition & 1 deletion app/global_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function handleError(prefix, error) {

if (app.isReady()) {
// title field is not shown on macOS, so we don't use it
const buttonIndex = dialog.showMessageBox({
const buttonIndex = dialog.showMessageBoxSync({
buttons: [quitText, copyErrorAndQuitText],
defaultId: 0,
detail: redactAll(error.stack),
Expand Down
22 changes: 21 additions & 1 deletion app/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ async function getSQLCipherVersion(instance) {
}
}

async function getSQLIntegrityCheck(instance) {
const row = await instance.get('PRAGMA cipher_integrity_check;');
if (row) {
return row.cipher_integrity_check;
}

return null;
}

const INVALID_KEY = /[^0-9A-Fa-f]/;
async function setupSQLCipher(instance, { key }) {
const match = INVALID_KEY.exec(key);
Expand All @@ -209,6 +218,9 @@ async function setupSQLCipher(instance, { key }) {
// https://www.zetetic.net/sqlcipher/sqlcipher-api/#key
await instance.run(`PRAGMA key = "x'${key}'";`);

// https://www.zetetic.net/blog/2018/11/30/sqlcipher-400-release/#compatability-sqlcipher-4-0-0
await instance.run('PRAGMA cipher_migrate;');

// Because foreign key support is not enabled by default!
await instance.run('PRAGMA foreign_keys = ON;');
}
Expand Down Expand Up @@ -1162,15 +1174,23 @@ async function initialize({ configDir, key, messages }) {
// });

await setupSQLCipher(promisified, { key });

await updateSchema(promisified);

db = promisified;

// test database

const result = await getSQLIntegrityCheck(db);
if (result) {
console.log('Database integrity check failed:', result);
throw new Error(`Integrity check failed: ${result}`);
}

await getMessageCount();
} catch (error) {
console.log('Database startup error:', error.stack);
const buttonIndex = dialog.showMessageBox({
const buttonIndex = dialog.showMessageBoxSync({
buttons: [
messages.copyErrorAndQuit.message,
messages.deleteAndRestart.message,
Expand Down
10 changes: 2 additions & 8 deletions js/spell_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,11 @@ const dummyChecker = {
window.spellChecker = simpleChecker;
window.disableSpellCheck = () => {
window.removeEventListener('contextmenu', spellCheckHandler);
webFrame.setSpellCheckProvider('en-US', false, dummyChecker);
webFrame.setSpellCheckProvider('en-US', dummyChecker);
};

window.enableSpellCheck = () => {
webFrame.setSpellCheckProvider(
'en-US',
// Not sure what this parameter (`autoCorrectWord`) does: https://github.com/atom/electron/issues/4371
// The documentation for `webFrame.setSpellCheckProvider` passes `true` so we do too.
true,
simpleChecker
);
webFrame.setSpellCheckProvider('en-US', simpleChecker);
window.addEventListener('contextmenu', spellCheckHandler);
};

Expand Down
5 changes: 5 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ function createWindow() {
config.environment === 'test' || config.environment === 'test-lib'
? '#ffffff' // Tests should always be rendered on a white background
: '#2090EA',
vibrancy: 'appearance-based',
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
Expand Down Expand Up @@ -472,6 +473,7 @@ function showAbout() {
autoHideMenuBar: true,
backgroundColor: '#2090EA',
show: false,
vibrancy: 'appearance-based',
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
Expand Down Expand Up @@ -517,6 +519,7 @@ async function showSettingsWindow() {
backgroundColor: '#FFFFFF',
show: false,
modal: true,
vibrancy: 'appearance-based',
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
Expand Down Expand Up @@ -562,6 +565,7 @@ async function showDebugLogWindow() {
backgroundColor: '#FFFFFF',
show: false,
modal: true,
vibrancy: 'appearance-based',
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
Expand Down Expand Up @@ -610,6 +614,7 @@ async function showPermissionsPopupWindow() {
backgroundColor: '#FFFFFF',
show: false,
modal: true,
vibrancy: 'appearance-based',
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"grunt": "grunt",
"icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build",
"generate": "yarn icon-gen && yarn grunt",
"build": "build --config.extraMetadata.environment=$SIGNAL_ENV",
"build": "electron-builder --config.extraMetadata.environment=$SIGNAL_ENV",
"build-release": "SIGNAL_ENV=production npm run build -- --config.directories.output=release",
"sign-release": "node ts/updater/generateSignature.js",
"build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js",
Expand All @@ -44,7 +44,7 @@
"ready": "yarn clean-transpile && yarn grunt && yarn lint && yarn test-node && yarn test-electron && yarn lint-deps"
},
"dependencies": {
"@journeyapps/sqlcipher": "https://github.com/scottnonnenberg-signal/node-sqlcipher.git#2e28733b61640556b0272a3bfc78b0357daf71e6",
"@journeyapps/sqlcipher": "https://github.com/scottnonnenberg-signal/node-sqlcipher.git#00fd0f8a6623c6683280976d2a92b41d09c744bc",
"@sindresorhus/is": "0.8.0",
"backbone": "1.3.3",
"blob-util": "1.3.0",
Expand Down Expand Up @@ -80,7 +80,6 @@
"mustache": "2.3.0",
"node-fetch": "https://github.com/scottnonnenberg-signal/node-fetch.git#3e5f51e08c647ee5f20c43b15cf2d352d61c36b4",
"node-gyp": "5.0.3",
"node-sass": "4.9.3",
"os-locale": "2.1.0",
"p-map": "2.1.0",
"p-queue": "5.0.0",
Expand All @@ -102,7 +101,7 @@
"reselect": "4.0.0",
"rimraf": "2.6.2",
"semver": "5.4.1",
"spellchecker": "3.5.1",
"spellchecker": "3.7.0",
"tar": "4.4.8",
"testcheck": "1.0.0-rc.2",
"tmp": "0.0.33",
Expand Down Expand Up @@ -147,8 +146,8 @@
"bower": "1.8.2",
"chai": "4.1.2",
"dashdash": "1.14.1",
"electron": "4.2.2",
"electron-builder": "20.39.0",
"electron": "6.0.1",
"electron-builder": "21.2.0",
"electron-icon-maker": "0.0.3",
"eslint": "4.14.0",
"eslint-config-airbnb-base": "12.1.0",
Expand All @@ -165,8 +164,10 @@
"grunt-exec": "3.0.0",
"grunt-gitinfo": "0.1.7",
"grunt-sass": "3.0.1",
"jsdoc": "3.6.2",
"mocha": "4.1.0",
"mocha-testcheck": "1.0.0-rc.0",
"node-sass": "4.12.0",
"node-sass-import-once": "1.2.0",
"nyc": "11.4.1",
"patch-package": "6.1.2",
Expand All @@ -183,7 +184,7 @@
"webpack": "4.4.1"
},
"engines": {
"node": "10.13.0"
"node": "12.4.0"
},
"build": {
"appId": "org.whispersystems.signal-desktop",
Expand All @@ -199,7 +200,7 @@
}
],
"target": [
"zip"
"zip", "dmg"
],
"bundleVersion": "1"
},
Expand Down
25 changes: 5 additions & 20 deletions ts/updater/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,38 +160,23 @@ export async function showUpdateDialog(
cancelId: RESTART_BUTTON,
};

return new Promise(resolve => {
dialog.showMessageBox(mainWindow, options, response => {
if (response === RESTART_BUTTON) {
// It's key to delay any install calls here because they don't seem to work inside this
// callback - but only if the message box has a parent window.
// Fixes this: https://github.com/signalapp/Signal-Desktop/issues/1864
resolve(true);

return;
}

resolve(false);
});
});
const { response } = await dialog.showMessageBox(mainWindow, options);

return response === RESTART_BUTTON;
}

export async function showCannotUpdateDialog(
mainWindow: BrowserWindow,
messages: MessagesType
): Promise<boolean> {
): Promise<any> {
const options = {
type: 'error',
buttons: [messages.ok.message],
title: messages.cannotUpdate.message,
message: messages.cannotUpdateDetail.message,
};

return new Promise(resolve => {
dialog.showMessageBox(mainWindow, options, () => {
resolve();
});
});
await dialog.showMessageBox(mainWindow, options);
}

// Helper functions
Expand Down
6 changes: 1 addition & 5 deletions ts/updater/macos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,5 @@ export async function showReadOnlyDialog(
message: messages.readOnlyVolume.message,
};

return new Promise(resolve => {
dialog.showMessageBox(mainWindow, options, () => {
resolve();
});
});
await dialog.showMessageBox(mainWindow, options);
}

0 comments on commit e29eee4

Please sign in to comment.