Compare commits

..

68 Commits

Author SHA1 Message Date
RiotRobot
e368f44ebb v1.6.7 2020-06-29 16:16:53 +01:00
RiotRobot
fda652deaf Prepare changelog for v1.6.7 2020-06-29 16:16:53 +01:00
RiotRobot
ef94a61b5d v1.6.6 2020-06-23 15:19:38 +01:00
RiotRobot
dde4e2da9b Prepare changelog for v1.6.6 2020-06-23 15:19:38 +01:00
RiotRobot
c1e20617f5 Upgrade matrix-js-sdk to 7.0.0 2020-06-23 14:49:49 +01:00
RiotRobot
0168182f5b v1.6.6-rc.1 2020-06-17 21:40:42 +01:00
RiotRobot
9cf829730f Prepare changelog for v1.6.6-rc.1 2020-06-17 21:40:42 +01:00
RiotRobot
ab2a1e5fdd Upgrade matrix-js-sdk to 7.0.0-rc.1 2020-06-17 21:38:17 +01:00
Michael Telatynski
e10582749b Merge pull request #101 from vector-im/t3chguy/needle
Upgrade needle to avoid bugs with modern Node
2020-06-16 13:46:10 +01:00
Michael Telatynski
d0d14e80ce Upgrade needle to avoid bugs with modern Node
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-06-16 12:41:58 +01:00
RiotRobot
f9d928a534 Reset matrix-js-sdk back to develop branch 2020-06-16 11:16:49 +01:00
RiotRobot
8f4ef2d332 Merge branch 'master' into develop 2020-06-16 11:16:18 +01:00
RiotRobot
a5b809ab06 v1.6.5 2020-06-16 11:14:38 +01:00
RiotRobot
2891019044 Prepare changelog for v1.6.5 2020-06-16 11:14:38 +01:00
RiotRobot
0beda0bb19 Upgrade matrix-js-sdk to 6.2.2 2020-06-16 11:10:50 +01:00
Michael Telatynski
2c6000c49e Merge pull request #99 from vector-im/t3chguy/remember-updates
Fix riot-desktop manual update check getting stuck on Downloading...
2020-06-08 09:44:23 +01:00
Michael Telatynski
c2ecef12f2 Fix riot-desktop manual update check getting stuck on Downloading...
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-06-07 13:18:33 +01:00
Michael Telatynski
303a7f0bd0 Merge pull request #98 from vector-im/t3chguy/remember-updates
Electron recall latest downloaded update for when the user manually asks
2020-06-05 19:21:37 +01:00
Michael Telatynski
861c90c3d8 delint
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-06-05 18:41:29 +01:00
Michael Telatynski
799ccc6197 Electron recall latest downloaded update for when the user manually checks for updates
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-06-05 18:36:10 +01:00
RiotRobot
1ca51ced9c Reset matrix-js-sdk back to develop branch 2020-06-05 15:17:55 +01:00
RiotRobot
50bb0b3694 Merge branch 'master' into develop 2020-06-05 15:17:09 +01:00
RiotRobot
edb8b671f3 v1.6.4 2020-06-05 15:13:36 +01:00
RiotRobot
2f0b6ee984 Prepare changelog for v1.6.4 2020-06-05 15:13:36 +01:00
RiotRobot
ece9040247 Upgrade matrix-js-sdk to 6.2.1 2020-06-05 15:13:04 +01:00
RiotRobot
ffe9121589 Reset matrix-js-sdk back to develop branch 2020-06-04 15:21:41 +01:00
RiotRobot
2203f4628a Merge branch 'master' into develop 2020-06-04 15:19:58 +01:00
RiotRobot
cf2925853c v1.6.3 2020-06-04 15:19:33 +01:00
RiotRobot
e4aab36428 Prepare changelog for v1.6.3 2020-06-04 15:19:32 +01:00
RiotRobot
d106d23e2e Upgrade matrix-js-sdk to 6.2.0 2020-06-04 15:06:20 +01:00
Hubert Chathi
f841622e81 Merge pull request #95 from uhoreg/keytar
use keytar to store pickle keys
2020-06-03 16:54:48 -04:00
Hubert Chathi
b4af8d9ce5 remove unneeded stuff 2020-06-03 16:47:09 -04:00
RiotRobot
aaa3e71077 v1.6.3-rc.1 2020-06-02 13:58:27 +01:00
RiotRobot
b9d00395ed Prepare changelog for v1.6.3-rc.1 2020-06-02 13:58:26 +01:00
RiotRobot
00cf95e86b Upgrade matrix-js-sdk to 6.2.0-rc.1 2020-06-02 13:53:28 +01:00
Michael Telatynski
e56311fc06 Merge pull request #96 from vector-im/t3chguy/fix-save-as
Fix electron context menu copy/save-as
2020-06-01 17:09:03 +01:00
Travis Ralston
2e907b6e36 Merge pull request #97 from drlellinger/patch-1
Fixed error in README.md/User-specified config.json
2020-05-31 18:28:19 -06:00
drlellinger
c82c80a2e0 Fixed error in User-specified config.json
A / was missing
2020-05-31 18:25:26 +02:00
Michael Telatynski
20fb0f477b tidy comment
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-05-31 12:28:15 +01:00
Michael Telatynski
c6620735b4 Fix electron context menu copy/save-as
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-05-31 12:23:23 +01:00
Michael Telatynski
27b7db2b30 Merge pull request #92 from vector-im/t3chguy/modular-utm
Update Modular hosting link
2020-05-29 20:16:16 +01:00
Hubert Chathi
188190888b more lint 2020-05-28 15:36:06 -04:00
Hubert Chathi
b366dbb460 fix lint errors and add copyright info 2020-05-28 15:30:00 -04:00
Hubert Chathi
19edcd436e use keytar to store pickle keys 2020-05-28 15:07:39 -04:00
Travis Ralston
d33ce95dd0 Merge pull request #91 from vector-im/travis/ipc-renderer
Enforce sandbox on all spawned BrowserWindow objects
2020-05-27 10:03:28 -06:00
Michael Telatynski
be30a2fbab Merge pull request #93 from vector-im/t3chguy/flush-on-update
Run before-quit on updates too to flush rageshake
2020-05-26 11:58:22 +01:00
Michael Telatynski
66d9204578 Run before-quit on updates too to flush rageshake
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-05-23 11:52:49 +01:00
Michael Telatynski
ba0518005e Update Modular hosting link
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-05-23 08:48:29 +01:00
RiotRobot
b543a2e496 Reset matrix-js-sdk back to develop branch 2020-05-22 14:22:01 +01:00
RiotRobot
91b4987d52 Merge branch 'master' into develop 2020-05-22 14:21:28 +01:00
RiotRobot
73b9dcbb89 v1.6.2 2020-05-22 14:21:03 +01:00
RiotRobot
460148e66c Prepare changelog for v1.6.2 2020-05-22 14:21:03 +01:00
Travis Ralston
a568d766b0 Merge pull request #87 from vector-im/travis/room-list-2
Enable new room list labs flag
2020-05-21 13:30:45 -06:00
Travis Ralston
9635047c49 Merge branch 'develop' into travis/room-list-2 2020-05-21 13:28:35 -06:00
Michael Telatynski
1d339123e7 Merge pull request #59 from vector-im/t3chguy/script
Add asar-webapp script
2020-05-21 10:58:48 +01:00
J. Ryan Stinnett
0f6a42e250 Merge pull request #50 from vector-im/dependabot/npm_and_yarn/acorn-6.4.1
Bump acorn from 6.4.0 to 6.4.1
2020-05-21 10:55:51 +01:00
J. Ryan Stinnett
6e7919c6a0 Merge pull request #89 from vector-im/travis/scaling-labs
Enable font scaling flag for nightly
2020-05-21 10:52:54 +01:00
Travis Ralston
0269501d4f Enforce sandbox on all spawned BrowserWindow objects
The docs (https://www.atom.pe/docs/api/sandbox-option/) say we should be using the browser-native `window.open` implementation, but in practice that appears very much false. Electron, no matter our set of options, appears to always make a hit to the ipcRenderer with `window.open` calls, causing the calling code to explode due to the sandbox making that impossible.

By using `app.enableSandbox()`, it puts the sandbox in place over all BrowserWindow objects, including the temporary ones which empirically are being created for `window.open`. We do not need to specify `sandbox: true` to the BrowserWindow with this approach, though uncommenting and therefore reintroducing the flag causes our lovely ipcRenderer error again.

As far as I can tell, the sandbox does actually get applied to the window though the fact that `sandbox: true` still does things despite the docs saying otherwise leaves me a bit uncomfortable.

Fixes https://github.com/vector-im/riot-web/issues/13719
2020-05-20 16:16:57 -06:00
Travis Ralston
9b9b2ee847 Enable font scaling flag for nightly 2020-05-20 10:08:43 -06:00
Travis Ralston
f9c8aa1753 Merge pull request #88 from vector-im/travis/irc-labs
Enable IRC UI labs flag in nightly
2020-05-19 15:00:38 -06:00
Travis Ralston
96d272f76b Enable IRC UI labs flag in nightly
For https://github.com/vector-im/riot-web/pull/13350
2020-05-19 14:58:46 -06:00
RiotRobot
3e8feef642 Reset matrix-js-sdk back to develop branch 2020-05-19 11:16:19 +01:00
RiotRobot
48ab056785 Merge branch 'master' into develop 2020-05-19 11:15:22 +01:00
Travis Ralston
c3fde65a1b Enable new room list labs flag
See https://github.com/vector-im/riot-web/pull/13675
2020-05-14 14:28:43 -06:00
Michael Telatynski
829451c4c4 Merge pull request #86 from vector-im/t3chguy/update_help
Update help message to fix broken url to electron docs
2020-05-14 19:28:57 +01:00
Michael Telatynski
1cd23edb80 Update help message to fix broken url to electron docs
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-05-14 11:27:26 +01:00
Michael Telatynski
d73915e8f2 Add asar-webapp script
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2020-04-01 12:33:06 +01:00
dependabot[bot]
7ceaa4fd8e Bump acorn from 6.4.0 to 6.4.1
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.4.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-03-15 22:06:00 +00:00
12 changed files with 318 additions and 60 deletions

View File

@@ -1,3 +1,79 @@
Changes in [1.6.7](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.7) (2020-06-29)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.6...v1.6.7)
* No changes since 1.6.6
Changes in [1.6.6](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.6) (2020-06-23)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.6-rc.1...v1.6.6)
* No changes since rc.1
Changes in [1.6.6-rc.1](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.6-rc.1) (2020-06-17)
========================================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.5...v1.6.6-rc.1)
* Upgrade needle to avoid bugs with modern Node
[\#101](https://github.com/vector-im/riot-desktop/pull/101)
* Fix riot-desktop manual update check getting stuck on Downloading...
[\#99](https://github.com/vector-im/riot-desktop/pull/99)
* Electron recall latest downloaded update for when the user manually asks
[\#98](https://github.com/vector-im/riot-desktop/pull/98)
* use keytar to store pickle keys
[\#95](https://github.com/vector-im/riot-desktop/pull/95)
Changes in [1.6.5](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.5) (2020-06-16)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.4...v1.6.5)
* No changes since 1.6.4
Changes in [1.6.4](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.4) (2020-06-05)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.3...v1.6.4)
* No changes since 1.6.3
Changes in [1.6.3](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.3) (2020-06-04)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.3-rc.1...v1.6.3)
* No changes since rc.1
Changes in [1.6.3-rc.1](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.3-rc.1) (2020-06-02)
========================================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.2...v1.6.3-rc.1)
* Fix electron context menu copy/save-as
[\#96](https://github.com/vector-im/riot-desktop/pull/96)
* Fixed error in README.md/User-specified config.json
[\#97](https://github.com/vector-im/riot-desktop/pull/97)
* Update Modular hosting link
[\#92](https://github.com/vector-im/riot-desktop/pull/92)
* Enforce sandbox on all spawned BrowserWindow objects
[\#91](https://github.com/vector-im/riot-desktop/pull/91)
* Run before-quit on updates too to flush rageshake
[\#93](https://github.com/vector-im/riot-desktop/pull/93)
* Enable new room list labs flag
[\#87](https://github.com/vector-im/riot-desktop/pull/87)
* Add asar-webapp script
[\#59](https://github.com/vector-im/riot-desktop/pull/59)
* Bump acorn from 6.4.0 to 6.4.1
[\#50](https://github.com/vector-im/riot-desktop/pull/50)
* Enable font scaling flag for nightly
[\#89](https://github.com/vector-im/riot-desktop/pull/89)
* Enable IRC UI labs flag in nightly
[\#88](https://github.com/vector-im/riot-desktop/pull/88)
* Update help message to fix broken url to electron docs
[\#86](https://github.com/vector-im/riot-desktop/pull/86)
Changes in [1.6.2](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.2) (2020-05-22)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.1...v1.6.2)
* No changes since 1.6.2
Changes in [1.6.1](https://github.com/vector-im/riot-desktop/releases/tag/v1.6.1) (2020-05-19)
==============================================================================================
[Full Changelog](https://github.com/vector-im/riot-desktop/compare/v1.6.1-rc.1...v1.6.1)

View File

@@ -129,7 +129,7 @@ User-specified config.json
+ `%APPDATA%\$NAME\config.json` on Windows
+ `$XDG_CONFIG_HOME\$NAME\config.json` or `~/.config/$NAME/config.json` on Linux
+ `~Library/Application Support/$NAME/config.json` on macOS
+ `~/Library/Application Support/$NAME/config.json` on macOS
In the paths above, `$NAME` is typically `Riot`, unless you use `--profile
$PROFILE` in which case it becomes `Riot-$PROFILE`.

42
hak/keytar/build.js Normal file
View File

@@ -0,0 +1,42 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const path = require('path');
const childProcess = require('child_process');
module.exports = async function(hakEnv, moduleInfo) {
await buildKeytar(hakEnv, moduleInfo);
};
async function buildKeytar(hakEnv, moduleInfo) {
const env = hakEnv.makeGypEnv();
console.log("Running yarn with env", env);
await new Promise((resolve, reject) => {
const proc = childProcess.spawn(
path.join(moduleInfo.nodeModuleBinDir, 'node-gyp' + (hakEnv.isWin() ? '.cmd' : '')),
['rebuild'],
{
cwd: moduleInfo.moduleBuildDir,
env,
stdio: 'inherit',
},
);
proc.on('exit', (code) => {
code ? reject(code) : resolve();
});
});
}

36
hak/keytar/check.js Normal file
View File

@@ -0,0 +1,36 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const childProcess = require('child_process');
module.exports = async function(hakEnv, moduleInfo) {
const tools = [['python', '--version']]; // node-gyp uses python for reasons beyond comprehension
for (const tool of tools) {
await new Promise((resolve, reject) => {
const proc = childProcess.spawn(tool[0], tool.slice(1), {
stdio: ['ignore'],
});
proc.on('exit', (code) => {
if (code !== 0) {
reject("Can't find " + tool);
} else {
resolve();
}
});
});
}
};

10
hak/keytar/hak.json Normal file
View File

@@ -0,0 +1,10 @@
{
"scripts": {
"check": "check.js",
"build": "build.js"
},
"copy": "build/Release/keytar.node",
"dependencies": {
"libsecret": "0.20.3"
}
}

View File

@@ -2,7 +2,7 @@
"name": "riot-desktop",
"productName": "Riot",
"main": "src/electron-main.js",
"version": "1.6.1",
"version": "1.6.7",
"description": "A feature-rich client for Matrix.org",
"author": "New Vector Ltd.",
"repository": {
@@ -14,6 +14,7 @@
"scripts": {
"mkdirs": "mkdirp packages deploys",
"fetch": "yarn run mkdirs && node scripts/fetch-package.js",
"asar-webapp": "asar p webapp webapp.asar",
"start": "electron .",
"lint": "eslint src/ scripts/ hak/",
"build:native": "yarn run hak",
@@ -47,17 +48,18 @@
"find-npm-prefix": "^1.0.2",
"fs-extra": "^8.1.0",
"glob": "^7.1.6",
"matrix-js-sdk": "6.1.0",
"matrix-js-sdk": "7.0.0",
"mkdirp": "^1.0.3",
"needle": "^2.3.2",
"node-pre-gyp": "^0.14.0",
"needle": "^2.5.0",
"node-pre-gyp": "^0.15.0",
"npm": "^6.13.7",
"rimraf": "^3.0.2",
"semver": "^7.1.3",
"tar": "^6.0.1"
},
"hakDependencies": {
"matrix-seshat": "^1.3.3"
"matrix-seshat": "^1.3.3",
"keytar": "^5.6.0"
},
"build": {
"appId": "im.riot.app",

View File

@@ -11,7 +11,7 @@
"https://scalar-staging.vector.im/api",
"https://scalar-staging.riot.im/scalar/api"
],
"hosting_signup_link": "https://modular.im/?utm_source=riot-web&utm_medium=web",
"hosting_signup_link": "https://modular.im/services/matrix-hosting-riot?utm_source=riot-web&utm_medium=web",
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
"features": {
"feature_pinning": "labs",
@@ -23,7 +23,10 @@
"feature_dm_verification": "labs",
"feature_bridge_state": "labs",
"feature_presence_in_room_list": "labs",
"feature_custom_themes": "labs"
"feature_custom_themes": "labs",
"feature_new_room_list": "labs",
"feature_irc_ui": "labs",
"feature_font_scaling": "labs"
},
"piwik": {
"url": "https://piwik.riot.im/",

View File

@@ -11,7 +11,7 @@
"https://scalar-staging.vector.im/api",
"https://scalar-staging.riot.im/scalar/api"
],
"hosting_signup_link": "https://modular.im/?utm_source=riot-web&utm_medium=web",
"hosting_signup_link": "https://modular.im/services/matrix-hosting-riot?utm_source=riot-web&utm_medium=web",
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
"roomDirectory": {
"servers": [

View File

@@ -3,6 +3,7 @@ Copyright 2016 Aviral Dasgupta
Copyright 2016 OpenMarket Ltd
Copyright 2018, 2019 New Vector Ltd
Copyright 2017, 2019 Michael Telatynski <7t3chguy@gmail.com>
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -43,6 +44,18 @@ const Store = require('electron-store');
const fs = require('fs');
const afs = fs.promises;
const crypto = require('crypto');
let keytar;
try {
keytar = require('keytar');
} catch (e) {
if (e.code === "MODULE_NOT_FOUND") {
console.log("Keytar isn't installed; secure key storage is disabled.");
} else {
console.warn("Keytar unexpected error:", e);
}
}
let seshatSupported = false;
let Seshat;
let SeshatRecovery;
@@ -82,7 +95,7 @@ if (argv["help"]) {
console.log(" --hidden: Start the application hidden in the system tray.");
console.log(" --help: Displays this help message.");
console.log("And more such as --proxy, see:" +
"https://electronjs.org/docs/api/chrome-command-line-switches#supported-chrome-command-line-switches");
"https://electronjs.org/docs/api/command-line-switches");
app.exit();
}
@@ -241,17 +254,6 @@ ipcMain.on('app_onAction', function(ev, payload) {
}
});
autoUpdater.on('update-downloaded', (ev, releaseNotes, releaseName, releaseDate, updateURL) => {
if (!mainWindow) return;
// forward to renderer
mainWindow.webContents.send('update-downloaded', {
releaseNotes,
releaseName,
releaseDate,
updateURL,
});
});
ipcMain.on('ipcCall', async function(ev, payload) {
if (!mainWindow) return;
@@ -365,6 +367,41 @@ ipcMain.on('ipcCall', async function(ev, payload) {
recordSSOSession(args[0]);
break;
case 'getPickleKey':
try {
ret = await keytar.getPassword("riot.im", `${args[0]}|${args[1]}`);
} catch (e) {
// if an error is thrown (e.g. keytar can't connect to the keychain),
// then return null, which means the default pickle key will be used
ret = null;
}
break;
case 'createPickleKey':
try {
const randomArray = await new Promise((resolve, reject) => {
crypto.randomBytes(32, (err, buf) => {
if (err) {
reject(err);
} else {
resolve(buf);
}
});
});
const pickleKey = randomArray.toString("base64").replace(/=+$/g, '');
await keytar.setPassword("riot.im", `${args[0]}|${args[1]}`, pickleKey);
ret = pickleKey;
} catch (e) {
ret = null;
}
break;
case 'destroyPickleKey':
try {
await keytar.deletePassword("riot.im", `${args[0]}|${args[1]}`);
} catch (e) {}
break;
default:
mainWindow.webContents.send('ipcReply', {
id: payload.id,
@@ -615,6 +652,17 @@ protocol.registerSchemesAsPrivileged([{
},
}]);
// Turn the sandbox on for *all* windows we might generate. Doing this means we don't
// have to specify a `sandbox: true` to each BrowserWindow.
//
// This also fixes an issue with window.open where if we only specified the sandbox
// on the main window we'd run into cryptic "ipc_renderer be broke" errors. Turns out
// it's trying to jump the sandbox and make some calls into electron, which it can't
// do when half of it is sandboxed. By turning on the sandbox for everything, the new
// window (no matter how temporary it may be) is also sandboxed, allowing for a clean
// transition into the user's browser.
app.enableSandbox();
app.on('ready', async () => {
try {
await setupGlobals();
@@ -725,7 +773,7 @@ app.on('ready', async () => {
webPreferences: {
preload: preloadScript,
nodeIntegration: false,
sandbox: true,
//sandbox: true, // We enable sandboxing from app.enableSandbox() above
enableRemoteModule: false,
// We don't use this: it's useful for the preload script to
// share a context with the main page so we can give select
@@ -790,12 +838,15 @@ app.on('activate', () => {
mainWindow.show();
});
app.on('before-quit', () => {
function beforeQuit() {
global.appQuitting = true;
if (mainWindow) {
mainWindow.webContents.send('before-quit');
}
});
}
app.on('before-quit', beforeQuit);
app.on('before-quit-for-update', beforeQuit);
app.on('second-instance', (ev, commandLine, workingDirectory) => {
// If other instance launched with --hidden then skip showing window

View File

@@ -69,15 +69,31 @@ ipcMain.on('install_update', installUpdate);
ipcMain.on('check_updates', pollForUpdates);
function ipcChannelSendUpdateStatus(status) {
if (global.mainWindow) {
global.mainWindow.webContents.send('check_updates', status);
}
if (!global.mainWindow) return;
global.mainWindow.webContents.send('check_updates', status);
}
// cache the latest update which has been downloaded as electron offers no api to read it
let latestUpdateDownloaded;
autoUpdater.on('update-available', function() {
ipcChannelSendUpdateStatus(true);
}).on('update-not-available', function() {
ipcChannelSendUpdateStatus(false);
if (latestUpdateDownloaded) {
// the only time we will get `update-not-available` if `latestUpdateDownloaded` is already set
// is if the user used the Manual Update check and there is no update newer than the one we
// have downloaded, so show it to them as the latest again.
if (!global.mainWindow) return;
global.mainWindow.webContents.send('update-downloaded', latestUpdateDownloaded);
} else {
ipcChannelSendUpdateStatus(false);
}
}).on('error', function(error) {
ipcChannelSendUpdateStatus(error.message);
});
autoUpdater.on('update-downloaded', (ev, releaseNotes, releaseName, releaseDate, updateURL) => {
if (!global.mainWindow) return;
// forward to renderer
latestUpdateDownloaded = { releaseNotes, releaseName, releaseDate, updateURL };
global.mainWindow.webContents.send('update-downloaded', latestUpdateDownloaded);
});

View File

@@ -35,10 +35,27 @@ function onWindowOrNavigate(ev, target) {
safeOpenURL(target);
}
function writeNativeImage(filePath, img) {
switch (filePath.split('.').pop().toLowerCase()) {
case "jpg":
case "jpeg":
return fs.promises.writeFile(filePath, img.toJPEG(100));
case "bmp":
return fs.promises.writeFile(filePath, img.toBitmap());
case "png":
default:
return fs.promises.writeFile(filePath, img.toPNG());
}
}
function onLinkContextMenu(ev, params) {
let url = params.linkURL || params.srcURL;
if (url.startsWith('vector://vector/webapp')) {
// Avoid showing a context menu for app icons
if (params.hasImageContents) return;
// Rewrite URL so that it can be used outside of the app
url = "https://riot.im/app/" + url.substring(23);
}
@@ -53,22 +70,13 @@ function onLinkContextMenu(ev, params) {
}));
}
let addSaveAs = false;
if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
if (params.hasImageContents) {
popupMenu.append(new MenuItem({
label: '&Copy image',
click() {
if (url.startsWith('data:')) {
clipboard.writeImage(nativeImage.createFromDataURL(url));
} else {
ev.sender.copyImageAt(params.x, params.y);
}
ev.sender.copyImageAt(params.x, params.y);
},
}));
// We want the link to be ordered below the copy stuff, but don't want to duplicate
// the `if` statement, so use a flag.
addSaveAs = true;
}
// No point offering to copy a blob: URL either
@@ -91,12 +99,14 @@ function onLinkContextMenu(ev, params) {
}
}
if (addSaveAs) {
// XXX: We cannot easily save a blob from the main process as
// only the renderer can resolve them so don't give the user an option to.
if (params.hasImageContents && !url.startsWith('blob:')) {
popupMenu.append(new MenuItem({
label: 'Sa&ve image as...',
click() {
async click() {
const targetFileName = params.titleText || "image.png";
const filePath = dialog.showSaveDialog({
const {filePath} = await dialog.showSaveDialog({
defaultPath: targetFileName,
});
@@ -104,7 +114,7 @@ function onLinkContextMenu(ev, params) {
try {
if (url.startsWith("data:")) {
fs.writeFileSync(filePath, nativeImage.createFromDataURL(url));
await writeNativeImage(filePath, nativeImage.createFromDataURL(url));
} else {
request.get(url).pipe(fs.createWriteStream(filePath));
}

View File

@@ -115,9 +115,9 @@ acorn-jsx@^5.0.0:
integrity sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==
acorn@^6.0.7:
version "6.4.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.0.tgz#b659d2ffbafa24baf5db1cdbb2c94a983ecd2784"
integrity sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==
version "6.4.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
agent-base@4, agent-base@^4.3.0:
version "4.3.0"
@@ -2862,10 +2862,10 @@ map-age-cleaner@^0.1.1:
dependencies:
p-defer "^1.0.0"
matrix-js-sdk@6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-6.1.0.tgz#c28ad67c113c4aa9c8bce409c7ba550170bdc2ee"
integrity sha512-N+vCgxWORvhh7AGyWZlU5Z2brojbbnHnWlMkBF6JjWe6a+pfpjmRKp5/jeQpOz6yfe56sIQvU7ikBZl3JjlMiw==
matrix-js-sdk@7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-7.0.0.tgz#da2b24e57574379c3d8f7065eb68ea6c479d9806"
integrity sha512-0i1NmfwS5HzEPPjqUAXpw81o+8DImBS67QQBemJiM6D/imU3KFBacdhkmgjMLKXnAfTy6a+aCGfYBfVolfmNQw==
dependencies:
"@babel/runtime" "^7.8.3"
another-json "^0.2.0"
@@ -2959,6 +2959,11 @@ minimist@^1.2.0, minimist@^1.2.3:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.3.tgz#3db5c0765545ab8637be71f333a104a965a9ca3f"
integrity sha512-+bMdgqjMN/Z77a6NlY/I3U5LlRDbnmaAk6lDveAPKwSpcPM4tKAuYsvYF8xjhOPXhOYGe/73vVLVez5PW+jqhw==
minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
minipass@^2.3.5, minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6"
@@ -3012,6 +3017,13 @@ mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
dependencies:
minimist "0.0.8"
mkdirp@^0.5.3:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
dependencies:
minimist "^1.2.5"
mkdirp@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.3.tgz#4cf2e30ad45959dddea53ad97d518b6c8205e1ea"
@@ -3054,10 +3066,10 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
needle@^2.2.1, needle@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/needle/-/needle-2.3.2.tgz#3342dea100b7160960a450dc8c22160ac712a528"
integrity sha512-DUzITvPVDUy6vczKKYTnWc/pBZ0EnjMJnQ3y+Jo5zfKFimJs7S3HFCxCRZYB9FUZcrzUQr3WsmvZgddMEIZv6w==
needle@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/needle/-/needle-2.5.0.tgz#e6fc4b3cc6c25caed7554bd613a5cf0bac8c31c0"
integrity sha512-o/qITSDR0JCyCKEQ1/1bnUXMmznxabbwi/Y4WwJElf+evwJNFNwIDMCCt5IigFVxgeGBJESLohGtIS9gEzo1fA==
dependencies:
debug "^3.2.6"
iconv-lite "^0.4.4"
@@ -3094,14 +3106,14 @@ node-gyp@^5.0.2, node-gyp@^5.0.7:
tar "^4.4.12"
which "^1.3.1"
node-pre-gyp@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83"
integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA==
node-pre-gyp@^0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.15.0.tgz#c2fc383276b74c7ffa842925241553e8b40f1087"
integrity sha512-7QcZa8/fpaU/BKenjcaeFF9hLz2+7S9AqyXFhlH/rilsQ/hPZKK32RtR5EQHJElgu+q5RfbJ34KriI79UWaorA==
dependencies:
detect-libc "^1.0.2"
mkdirp "^0.5.1"
needle "^2.2.1"
mkdirp "^0.5.3"
needle "^2.5.0"
nopt "^4.0.1"
npm-packlist "^1.1.6"
npmlog "^4.0.2"