diff options
Diffstat (limited to 'config/burnFuses.cjs')
-rw-r--r-- | config/burnFuses.cjs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/config/burnFuses.cjs b/config/burnFuses.cjs new file mode 100644 index 0000000..a6ea197 --- /dev/null +++ b/config/burnFuses.cjs | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | const path = require('node:path'); | ||
22 | |||
23 | const { flipFuses } = require('@electron/fuses'); | ||
24 | |||
25 | /** | ||
26 | * Hardens the shipped electron binary by burning some electron fuses. | ||
27 | * | ||
28 | * | ||
29 | * @param {import('electron-builder').AfterPackContext} context The `electron-builder` context. | ||
30 | * @param {import('@electron/fuses').FuseConfig<boolean>} config The fuses to burn. | ||
31 | * @return {Promise<void>} The promise to flip the fuses. | ||
32 | * @see https://github.com/electron/fuses | ||
33 | */ | ||
34 | module.exports = async function burnFuses(context, config) { | ||
35 | /** @type {string} */ | ||
36 | const ext = | ||
37 | { | ||
38 | darwin: '.app', | ||
39 | win32: '.exe', | ||
40 | }[context.electronPlatformName] || ''; | ||
41 | const electronBinaryPath = path.join( | ||
42 | context.appOutDir, | ||
43 | `${context.packager.appInfo.productFilename}${ext}`, | ||
44 | ); | ||
45 | /** @type {import('@electron/fuses').FuseConfig<boolean>} */ | ||
46 | return flipFuses(electronBinaryPath, config); | ||
47 | }; | ||