aboutsummaryrefslogtreecommitdiffstats
path: root/.electron-builder.config.js
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-25 03:03:30 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-25 03:06:04 +0100
commita85c8af24a7ce6706357964116cae0067b1f2a73 (patch)
tree2fe77773df9df6e025b0e521116e0473d767f96b /.electron-builder.config.js
parentchore: Bump dependency versions (diff)
downloadsophie-a85c8af24a7ce6706357964116cae0067b1f2a73.tar.gz
sophie-a85c8af24a7ce6706357964116cae0067b1f2a73.tar.zst
sophie-a85c8af24a7ce6706357964116cae0067b1f2a73.zip
feat: Fuse the electron binary
Disables some node flags in production and enables cookie encryption.
Diffstat (limited to '.electron-builder.config.js')
-rw-r--r--.electron-builder.config.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/.electron-builder.config.js b/.electron-builder.config.js
index e0f59e7..4ff94d7 100644
--- a/.electron-builder.config.js
+++ b/.electron-builder.config.js
@@ -1,5 +1,9 @@
1// @ts-check 1// @ts-check
2 2
3const { Arch } = require('electron-builder');
4const { flipFuses, FuseV1Options, FuseVersion } = require('@electron/fuses');
5const { join } = require('path');
6
3if (process.env.VITE_APP_VERSION === undefined) { 7if (process.env.VITE_APP_VERSION === undefined) {
4 const now = new Date; 8 const now = new Date;
5 process.env.VITE_APP_VERSION = `${now.getUTCFullYear() - 2000}.${now.getUTCMonth() + 1}.${now.getUTCDate()}-${now.getUTCHours() * 60 + now.getUTCMinutes()}`; 9 process.env.VITE_APP_VERSION = `${now.getUTCFullYear() - 2000}.${now.getUTCMonth() + 1}.${now.getUTCDate()}-${now.getUTCHours() * 60 + now.getUTCMinutes()}`;
@@ -20,6 +24,34 @@ const config = {
20 extraMetadata: { 24 extraMetadata: {
21 version: process.env.VITE_APP_VERSION, 25 version: process.env.VITE_APP_VERSION,
22 }, 26 },
27 /**
28 * @param {import('electron-builder').AfterPackContext} context The `electron-builder` context.
29 * @return {Promise<void>} The promise to flip the fuses.
30 * @see https://github.com/electron-userland/electron-builder/issues/6365
31 */
32 afterPack(context) {
33 /** @type {string} */
34 const ext = {
35 darwin: '.app',
36 win32: '.exe',
37 }[context.electronPlatformName] || '';
38 const electronBinaryPath = join(
39 context.appOutDir,
40 `${context.packager.appInfo.productFilename}${ext}`
41 );
42 /** @type {import('@electron/fuses').FuseConfig<boolean>} */
43 const fuseConfig = {
44 version: FuseVersion.V1,
45 resetAdHocDarwinSignature: context.electronPlatformName === 'darwin' && context.arch === Arch.arm64,
46 [FuseV1Options.RunAsNode]: false,
47 [FuseV1Options.EnableCookieEncryption]: true,
48 [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
49 [FuseV1Options.EnableNodeCliInspectArguments]: false,
50 [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
51 [FuseV1Options.OnlyLoadAppFromAsar]: true,
52 };
53 return flipFuses(electronBinaryPath, fuseConfig);
54 },
23}; 55};
24 56
25module.exports = config; 57module.exports = config;