Skip to content
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
1 change: 1 addition & 0 deletions packages/suite-desktop-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"devDependencies": {
"@currents/playwright": "^1.3.1",
"@electron/fuses": "^1.8.0",
Comment thread
Lemonexe marked this conversation as resolved.
"@electron/notarize": "2.5.0",
"@playwright/browser-chromium": "^1.49.1",
"@playwright/browser-firefox": "^1.49.1",
Expand Down
40 changes: 40 additions & 0 deletions packages/suite-desktop-core/scripts/setElectronFuses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { flipFuses, FuseV1Options, FuseVersion } = require('@electron/fuses');
const path = require('path');

// copied from https://github.com/electron-userland/electron-builder/blob/04be5699c664e6a93e093b820a16ad516355b5c7/packages/app-builder-lib/src/platformPackager.ts#L430-L434
const binaryExtensionByPlaformNameMap = {
darwin: '.app',
win32: '.exe',
linux: '',
};

exports.default = async function afterPack(context) {
const { electronPlatformName, appOutDir } = context;

/*
As of Electron 34.1.0, ASAR integrity:
- is not supported on Linux at all
- is supported on macOS, but does not work. TODO investigate & reenable
So we only set the appropriate fuses for Windows
*/
if (electronPlatformName !== 'win32') {
console.log('Skipping electron fuses ');

return;
}

const ext = binaryExtensionByPlaformNameMap[electronPlatformName];
const appName = context.packager.appInfo.productFilename;
const binaryFilename = `${appName}${ext}`;
const binaryPath = path.join(appOutDir, binaryFilename);

console.log(`Setting electron fuses on ${binaryPath}`);

await flipFuses(binaryPath, {
version: FuseVersion.V1,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
});

console.log('Successfully set electron fuses');
};
1 change: 1 addition & 0 deletions packages/suite-desktop/electron-builder-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ module.exports = {
category: 'Utility',
target: ['AppImage'],
},
afterPack: '../suite-desktop-core/scripts/setElectronFuses.js',
Copy link
Copy Markdown
Contributor Author

@Lemonexe Lemonexe Feb 17, 2025

Choose a reason for hiding this comment

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

Wait, why is the new script .js, but the other two are .ts? (notarize and sign-windows)
Because they're not really typescript! They have the extension, but they are written in CJS.
It's actually quite a mess.
That rhymes!
Anyway, in next PR I'll turn on TS (ofc it's not running currently) so you can look forward to me valiantly fighting skeletons in closet 💀

afterSign: '../suite-desktop-core/scripts/notarize.ts',
};
1 change: 1 addition & 0 deletions packages/suite-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"usb": "^2.14.0"
},
"devDependencies": {
"@electron/fuses": "^1.8.0",
"@electron/notarize": "2.5.0",
"electron": "34.1.0",
"electron-builder": "26.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ uuid
@electron/notarize
electron
electron-builder
@electron/fuses
electron-localshortcut
electron-store
electron-updater
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13353,6 +13353,7 @@ __metadata:
resolution: "@trezor/suite-desktop-core@workspace:packages/suite-desktop-core"
dependencies:
"@currents/playwright": "npm:^1.3.1"
"@electron/fuses": "npm:^1.8.0"
"@electron/notarize": "npm:2.5.0"
"@playwright/browser-chromium": "npm:^1.49.1"
"@playwright/browser-firefox": "npm:^1.49.1"
Expand Down Expand Up @@ -13439,6 +13440,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@trezor/suite-desktop@workspace:packages/suite-desktop"
dependencies:
"@electron/fuses": "npm:^1.8.0"
"@electron/notarize": "npm:2.5.0"
blake-hash: "npm:^2.0.0"
electron: "npm:34.1.0"
Expand Down