-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-desktop): turn on ASAR integrity check via afterPack hook
- Loading branch information
Showing
6 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters