From 890c3cbc40f518b1a6a68cf0ef5c9204576e4f08 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sat, 29 Aug 2020 17:15:09 +1000 Subject: [PATCH] hopefully address CSP problem with #66 --- CHANGELOG.md | 1 + README.md | 28 ++++++++++++---------------- pkg/loader.js | 25 ++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0058d..6299e0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### v0.8.5 (wip) - bugfix: separate text highlight and select tag variables. +- bugfix: bypass CSP for the `enhancement://` protocol - was failing on some platforms? ### v0.8.4 (2020-08-29) diff --git a/README.md b/README.md index e92dd06..dc54d00 100644 --- a/README.md +++ b/README.md @@ -30,34 +30,30 @@ a chrome extension may be coming soon for web client support. ## installation -**coming from <= v0.7.0? things are a bit different - have a read of [the update guide](UPDATING.md)** -**before following these instructions.** +> coming from <= v0.7.0? things are a bit different - have a read of [the update guide](UPDATING.md)\*\* +> before following these instructions. -
- Windows, macOS +during installation/removal, make sure no notion processes are running! (check your task manager.) + +**win10, macOS** 1. [install node.js](https://nodejs.org/en/download/) (_a computer restart may be required here._) -2. make sure no notion processes are running -3. execute `npm i -g notion-enhancer` in the terminal/command prompt. Make sure you have root/admin rights. -
+2. execute `npm i -g notion-enhancer` in the terminal/command prompt as a root/admin user. -
- Ubuntu-based distros, WSL, ChromeOS +**debian/ubuntu, chromeOS, WSL (to modify the win10 app)** + +execute the following lines in the terminal: -Execute the following commands: ``` bash curl -sL https://deb.nodesource.com setup_current.x | sudo -E bash - sudo apt-get install -y nodejs sudo npm i -g notion-enhancer ``` -
-
- Arch Linux, Manjaro: +**arch linux, manjaro** -Use the [AUR package]( https://aur.archlinux.org/packages/notion-enhancer ). -install with `yay -S notion-enhancer` (use your AUR helper instead of yay) -
+install the [aur package](https://aur.archlinux.org/packages/notion-enhancer) +with your aur helper (e.g. `yay -S notion-enhancer`). ### command-line interface diff --git a/pkg/loader.js b/pkg/loader.js index a91aa06..14b45ab 100644 --- a/pkg/loader.js +++ b/pkg/loader.js @@ -17,7 +17,7 @@ module.exports = function (__file, __exports) { .slice(path.resolve(`${__notion}/app`).length + 1) .replace(/\\/g, '/'); - if (__file === 'main/main.js') { + if (__file === 'main/security.js') { const electron = require('electron'); electron.app.whenReady().then(() => { electron.session @@ -30,6 +30,29 @@ module.exports = function (__file, __exports) { }); }); }); + electron.protocol.registerSchemesAsPrivileged([ + { + scheme: 'notion', + privileges: { + standard: true, + secure: true, + allowServiceWorkers: true, + supportFetchAPI: true, + corsEnabled: true, + }, + }, + { + scheme: 'enhancement', + privileges: { + standard: true, + secure: true, + allowServiceWorkers: true, + supportFetchAPI: true, + corsEnabled: true, + bypassCSP: true, + }, + }, + ]); } const modules = helpers.getEnhancements();