Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Electron app housekeeping (polkadot-js#3958)
Browse files Browse the repository at this point in the history
* Update Electron version. Externalize electron builder configuration.

* Move script-related CSP to script-src section

* Change local dev address to 127.0.0.1.

* Update content security policy hashes

* Upgrade electron-log

* Remove dependency no react types
  • Loading branch information
krzysztof-jelski authored Nov 2, 2020
1 parent 7cd76fc commit d9318de
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 41 deletions.
17 changes: 17 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
productName: Polkadot-JS Apps
artifactName: Polkadot-JS-Apps-${version}.${ext}
files:
- "./packages/apps-electron/build"
- "./packages/apps-electron/assets"
- "./packages/apps-electron/appleEntitlements"
appId: com.polkadotjs.polkadotjs-apps
mac:
artifactName: Polkadot-JS-Apps-mac-${version}.${ext}
category: public.app-category.finance
entitlements: "./packages/apps-electron/appleEntitlements/entitlements.mac.plist"
hardenedRuntime: true
directories:
buildResources: "./packages/apps-electron/assets"
output: "./packages/apps-electron/release"
afterSign: electron-builder-notarize
23 changes: 1 addition & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@
"workspaces": [
"packages/*"
],
"build": {
"productName": "Polkadot-JS Apps",
"artifactName": "Polkadot-JS-Apps-${version}.${ext}",
"files": [
"./packages/apps-electron/build",
"./packages/apps-electron/assets",
"./packages/apps-electron/appleEntitlements"
],
"appId": "com.polkadotjs.polkadotjs-apps",
"mac": {
"artifactName": "Polkadot-JS-Apps-mac-${version}.${ext}",
"category": "public.app-category.finance",
"entitlements": "./packages/apps-electron/appleEntitlements/entitlements.mac.plist",
"hardenedRuntime": true
},
"directories": {
"buildResources": "./packages/apps-electron/assets",
"output": "./packages/apps-electron/release"
},
"afterSign": "electron-builder-notarize"
},
"resolutions": {
"@polkadot/api": "^2.4.2-20",
"@polkadot/api-contract": "^2.4.2-20",
Expand Down Expand Up @@ -102,7 +81,7 @@
"concurrently": "^5.3.0",
"devtron": "^1.4.0",
"dnslink-cloudflare": "^3.0.0",
"electron": "^9.3.2",
"electron": "^10.1.5",
"electron-builder": "^22.9.1",
"electron-builder-notarize": "^1.2.0",
"i18next-scanner": "^2.11.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/apps-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
"@babel/polyfill": "^7.12.1",
"@polkadot/dev": "^0.59.10",
"@polkadot/react-components": "^0.64.2-8",
"electron-log": "^4.2.4",
"electron-log": "^4.3.0",
"electron-updater": "^4.3.5"
},
"devDependencies": {
"@types/react": "^16.9.53",
"@types/react-dom": "^16.9.8",
"@types/tmp": "^0.2.0",
"babel-loader": "^8.1.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/apps-electron/src/electron/contentSecurityPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export const setupContentSecurityPolicy = (_: string): void => {
const headersReceivedResponse = {
responseHeaders: {
...details.responseHeaders,
// unsafe-eval is needed for the WASM content - same as the extension
// script hash here is for the window.top script (not technically needed)
'Content-Security-Policy': ["default-src 'self' 'unsafe-eval' 'sha256-02/ejyoV/iwRdJ4NAsxjzF6WVUtLMPM6Nv96EbAm6u8=';" +
'Content-Security-Policy': ["default-src 'self';" +
" style-src-elem 'self' https://fonts.googleapis.com/css 'unsafe-inline';" +
" font-src data: 'self' https://fonts.gstatic.com;" +
" style-src 'unsafe-inline';" +
" connect-src 'self' wss:;" +
" img-src 'self' data:"]
" img-src 'self' data:;" +
// unsafe-eval is needed for the WASM content - same as the extension
// script hashes here are for the window.top script (not technically needed)
" script-src 'self' 'unsafe-eval' 'sha256-02/ejyoV/iwRdJ4NAsxjzF6WVUtLMPM6Nv96EbAm6u8=' 'sha256-wW/WsLudCDaPo/ibpeK0KslHqYpCzcAKNFxFBXwCHJg='"]
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/apps-electron/src/electron/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function createWindow (environment: string): Promise<unknown> {
if (environment === 'development') {
win.webContents.openDevTools();

return win.loadURL('http://0.0.0.0:3000/');
return win.loadURL('http://127.0.0.1:3000/');
}

const mainFilePath = path.resolve(__dirname, 'index.html');
Expand Down
23 changes: 11 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2277,12 +2277,11 @@ __metadata:
"@babel/polyfill": ^7.12.1
"@polkadot/dev": ^0.59.10
"@polkadot/react-components": ^0.64.2-8
"@types/react": ^16.9.53
"@types/react-dom": ^16.9.8
"@types/tmp": ^0.2.0
babel-loader: ^8.1.0
copy-webpack-plugin: ^6.2.1
electron-log: ^4.2.4
electron-log: ^4.3.0
electron-updater: ^4.3.5
html-webpack-plugin: ^4.5.0
react: ^17.0.1
Expand Down Expand Up @@ -3468,7 +3467,7 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:*, @types/react@npm:^16.9.53":
"@types/react@npm:*":
version: 16.9.53
resolution: "@types/react@npm:16.9.53"
dependencies:
Expand Down Expand Up @@ -7479,10 +7478,10 @@ __metadata:
languageName: node
linkType: hard

"electron-log@npm:^4.2.4":
version: 4.2.4
resolution: "electron-log@npm:4.2.4"
checksum: 4177cd7dc7670d0942534a5e4a8d1bfa85d87911d4a1699e9d64cc3fd9645126620e65e20f42d55139f94e33712102c0058b4b8085750bb5fd7082a0bfe9ae42
"electron-log@npm:^4.3.0":
version: 4.3.0
resolution: "electron-log@npm:4.3.0"
checksum: b618b1adb958d5e4590e8d9a7aa22b37d2d6258684f31a6ec4b670ebf6aefc7563fa758562fcfd479582ac380b883e8aa3f1d5a751034928c7c967b8fc91d217
languageName: node
linkType: hard

Expand Down Expand Up @@ -7534,16 +7533,16 @@ __metadata:
languageName: node
linkType: hard

"electron@npm:^9.3.2":
version: 9.3.2
resolution: "electron@npm:9.3.2"
"electron@npm:^10.1.5":
version: 10.1.5
resolution: "electron@npm:10.1.5"
dependencies:
"@electron/get": ^1.0.1
"@types/node": ^12.0.12
extract-zip: ^1.0.3
bin:
electron: cli.js
checksum: 9464c1bb8c6fc78f1af17ced322a5615fb966f93ce06f3465792cb08db152abc45d43801520c27a0fef62c3d652659bb778b2d8a760befcb3250b885fe7d5fb4
checksum: e5047d7928386a3841136e0352e3e1d2f35d3076572bc2fbc3f78210f42f1eb4edf5c7341ee8e57461cf42bc48a78e5959e63787c91233af4af76009b4a41c3a
languageName: node
linkType: hard

Expand Down Expand Up @@ -14146,7 +14145,7 @@ fsevents@^1.2.7:
concurrently: ^5.3.0
devtron: ^1.4.0
dnslink-cloudflare: ^3.0.0
electron: ^9.3.2
electron: ^10.1.5
electron-builder: ^22.9.1
electron-builder-notarize: ^1.2.0
i18next-scanner: ^2.11.0
Expand Down

0 comments on commit d9318de

Please sign in to comment.