Skip to content

A local-first personal finance app

Enable stricter electron build options (#7609)

Julian Dominguez-Schatzea50db524b21
diff --git a/packages/desktop-electron/afterSignHook.ts b/packages/desktop-electron/afterSignHook.ts
new file mode 100644
index 0000000000..da8fc631dc
--- /dev/null
+++ b/packages/desktop-electron/afterSignHook.ts
@@ -0,0 +1,27 @@
+import { execFile } from 'node:child_process';
+import { promisify } from 'node:util';
+
+import type { AfterPackContext } from 'electron-builder';
+
+const execFileAsync = promisify(execFile);
+
+const afterSignHook = async (context: AfterPackContext) => {
+ if (context.electronPlatformName !== 'darwin' || process.env.CSC_LINK) {
+ return;
+ }
+
+ const appName = `${context.packager.appInfo.productFilename}.app`;
+ const appPath = `${context.appOutDir}/${appName}`;
+
+ await execFileAsync('codesign', [
+ '--sign',
+ '-',
+ '--force',
+ '--preserve-metadata=entitlements,requirements,flags,runtime',
+ '--deep',
+ appPath,
+ ]);
+};
+
+// oxlint-disable-next-line import/no-default-export
+export default afterSignHook;
diff --git a/packages/desktop-electron/package.json b/packages/desktop-electron/package.json
index 836c50ae9d..680bac5ffa 100644
--- a/packages/desktop-electron/package.json
+++ b/packages/desktop-electron/package.json
@@ -47,6 +47,12 @@
"!build/loot-core/lib-dist/electron/{browser,bundle.mobile*}"
],
"beforePack": "./build/desktop-electron/beforePackHook.js",
+ "afterSign": "./build/desktop-electron/afterSignHook.js",
+ "electronFuses": {
+ "runAsNode": false,
+ "enableNodeOptionsEnvironmentVariable": false,
+ "enableNodeCliInspectArguments": false
+ },
"mac": {
"category": "public.app-category.finance",
"icon": "icons/icon.icns",
diff --git a/upcoming-release-notes/7609.md b/upcoming-release-notes/7609.md
new file mode 100644
index 0000000000..17aa047d80
--- /dev/null
+++ b/upcoming-release-notes/7609.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [jfdoming]
+---
+
+Enable stricter electron build options