mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 00:59:38 +08:00
* feat(desktop): cloud-first thin shell, local atoms, signed config, and complete Sentry observability * feat(desktop): add in-app update banner, release notes preview, and mandatory update gate * fix(ci): resolve backend typecheck, dock short-host floor, ci-scope, and source privacy scan * fix(desktop): address all P1 and P2 security/robustness review findings on PR #1001 * fix(local-atoms): accept TOML array-of-tables headers in merged structure check --------- Co-authored-by: heggria <bshengtao@gmail.com>
50 lines
1.7 KiB
JavaScript
50 lines
1.7 KiB
JavaScript
const { spawnSync } = require('node:child_process');
|
|
const { existsSync } = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
/**
|
|
* Unused privacy keys injected by Electron's default Info.plist template that
|
|
* OpenDesign thin shell does not require on macOS.
|
|
*/
|
|
const UNUSED_MAC_PLIST_KEYS = [
|
|
'NSBluetoothAlwaysUsageDescription',
|
|
'NSBluetoothPeripheralUsageDescription',
|
|
'NSAudioCaptureUsageDescription',
|
|
];
|
|
|
|
/**
|
|
* electron-builder afterPack hook:
|
|
* - Strips unused Electron default privacy keys (Bluetooth, generic audio capture)
|
|
* from macOS Info.plist so privacy declarations stay minimal and accurate.
|
|
* - Ensures NSAppTransportSecurity does not leave NSAllowsArbitraryLoads=true.
|
|
*/
|
|
module.exports = async function afterPack(context) {
|
|
if (context.electronPlatformName !== 'darwin') return;
|
|
|
|
const productFilename = context.packager.appInfo.productFilename;
|
|
const plistPath = path.join(context.appOutDir, `${productFilename}.app`, 'Contents', 'Info.plist');
|
|
if (!existsSync(plistPath)) return;
|
|
|
|
const plistBuddy = '/usr/libexec/PlistBuddy';
|
|
if (!existsSync(plistBuddy)) return;
|
|
|
|
for (const key of UNUSED_MAC_PLIST_KEYS) {
|
|
spawnSync(plistBuddy, ['-c', `Delete :${key}`, plistPath], { stdio: 'ignore' });
|
|
}
|
|
|
|
// Enforce strict ATS: disallow arbitrary cleartext HTTP loads while keeping local loopback.
|
|
spawnSync(plistBuddy, ['-c', 'Delete :NSAppTransportSecurity:NSAllowsArbitraryLoads', plistPath], {
|
|
stdio: 'ignore',
|
|
});
|
|
spawnSync(
|
|
plistBuddy,
|
|
['-c', 'Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool false', plistPath],
|
|
{ stdio: 'ignore' },
|
|
);
|
|
spawnSync(
|
|
plistBuddy,
|
|
['-c', 'Set :NSAppTransportSecurity:NSAllowsLocalNetworking true', plistPath],
|
|
{ stdio: 'ignore' },
|
|
);
|
|
};
|