Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds default fuses to templates #3480

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/template/base/tmpl/forge.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
packagerConfig: {
asar: true,
Expand Down Expand Up @@ -26,5 +29,16 @@ module.exports = {
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
4 changes: 4 additions & 0 deletions packages/template/base/tmpl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"make": "electron-forge make",
"publish": "electron-forge publish"
},
"devDependencies": {
"@electron/fuses": "^1.7.0",
"@electron-forge/plugin-fuses": "^7.2.0"
},
"keywords": [],
"author": "",
"license": "MIT"
Expand Down
17 changes: 16 additions & 1 deletion packages/template/vite-typescript/tmpl/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { MakerZIP } from '@electron-forge/maker-zip';
import { MakerDeb } from '@electron-forge/maker-deb';
import { MakerRpm } from '@electron-forge/maker-rpm';
import { VitePlugin } from '@electron-forge/plugin-vite';
import { FusesPlugin } from '@electron-forge/plugin-fuses';
import { FuseV1Options, FuseVersion } from '@electron/fuses';

const config: ForgeConfig = {
packagerConfig: {},
packagerConfig: {
asar: true,
Copy link
Member Author

@yangannyx yangannyx Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't sure if there was a reason why this config wasn't set to true for any of the vite templates. this needs to be true to set the OnlyLoadAppFromAsar fuse to true, since OnlyLoadAppFromAsar only reads app.asar

},
rebuildConfig: {},
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
plugins: [
Expand All @@ -31,6 +35,17 @@ const config: ForgeConfig = {
},
],
}),
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};

Expand Down
2 changes: 2 additions & 0 deletions packages/template/vite-typescript/tmpl/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"devDependencies": {
"@electron/fuses": "^1.7.0",
"@electron-forge/plugin-fuses": "^7.2.0",
"@electron-forge/plugin-vite": "ELECTRON_FORGE/VERSION",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
Expand Down
18 changes: 17 additions & 1 deletion packages/template/vite/tmpl/forge.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
packagerConfig: {},
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
Expand Down Expand Up @@ -44,5 +49,16 @@ module.exports = {
],
},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
2 changes: 2 additions & 0 deletions packages/template/vite/tmpl/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"devDependencies": {
"@electron/fuses": "^1.7.0",
"@electron-forge/plugin-fuses": "^7.2.0",
"@electron-forge/plugin-vite": "ELECTRON_FORGE/VERSION"
}
}
13 changes: 13 additions & 0 deletions packages/template/webpack-typescript/tmpl/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { MakerDeb } from '@electron-forge/maker-deb';
import { MakerRpm } from '@electron-forge/maker-rpm';
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
import { FusesPlugin } from '@electron-forge/plugin-fuses';
import { FuseV1Options, FuseVersion } from '@electron/fuses';

import { mainConfig } from './webpack.main.config';
import { rendererConfig } from './webpack.renderer.config';
Expand Down Expand Up @@ -33,6 +35,17 @@ const config: ForgeConfig = {
],
},
}),
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};

Expand Down
2 changes: 2 additions & 0 deletions packages/template/webpack-typescript/tmpl/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"devDependencies": {
"@electron/fuses": "^1.7.0",
"@electron-forge/plugin-fuses": "^7.2.0",
"@electron-forge/plugin-webpack": "ELECTRON_FORGE/VERSION",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/template/webpack/tmpl/forge.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
packagerConfig: {
asar: true,
Expand Down Expand Up @@ -45,5 +48,16 @@ module.exports = {
},
},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
Loading