app-builder-lib 27.0.0-alpha.1 → 27.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Framework.d.ts +2 -0
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js.map +1 -1
- package/dist/appInfo.d.ts +1 -1
- package/dist/appInfo.d.ts.map +1 -1
- package/dist/appInfo.js +3 -3
- package/dist/appInfo.js.map +1 -1
- package/dist/asar/asar.js.map +1 -1
- package/dist/asar/asarAlign.d.ts +35 -0
- package/dist/asar/asarAlign.d.ts.map +1 -0
- package/dist/asar/asarAlign.js +149 -0
- package/dist/asar/asarAlign.js.map +1 -0
- package/dist/asar/asarFileChecker.d.ts +4 -2
- package/dist/asar/asarFileChecker.d.ts.map +1 -1
- package/dist/asar/asarFileChecker.js +2 -3
- package/dist/asar/asarFileChecker.js.map +1 -1
- package/dist/asar/asarUtil.d.ts +15 -1
- package/dist/asar/asarUtil.d.ts.map +1 -1
- package/dist/asar/asarUtil.js +132 -72
- package/dist/asar/asarUtil.js.map +1 -1
- package/dist/codeSign/certInfo.d.ts +14 -0
- package/dist/codeSign/certInfo.d.ts.map +1 -1
- package/dist/codeSign/certInfo.js +49 -0
- package/dist/codeSign/certInfo.js.map +1 -1
- package/dist/codeSign/mac/macCodeSign.d.ts +3 -3
- package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
- package/dist/codeSign/mac/macCodeSign.js +50 -25
- package/dist/codeSign/mac/macCodeSign.js.map +1 -1
- package/dist/codeSign/signResult.d.ts +26 -0
- package/dist/codeSign/signResult.d.ts.map +1 -0
- package/dist/codeSign/signResult.js +12 -0
- package/dist/codeSign/signResult.js.map +1 -0
- package/dist/codeSign/win/hsmSignManager.d.ts +10 -0
- package/dist/codeSign/win/hsmSignManager.d.ts.map +1 -0
- package/dist/codeSign/win/hsmSignManager.js +50 -0
- package/dist/codeSign/win/hsmSignManager.js.map +1 -0
- package/dist/codeSign/win/pkcs11SignManager.d.ts +14 -0
- package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -0
- package/dist/codeSign/win/pkcs11SignManager.js +82 -0
- package/dist/codeSign/win/pkcs11SignManager.js.map +1 -0
- package/dist/codeSign/win/signManager.d.ts +17 -0
- package/dist/codeSign/win/signManager.d.ts.map +1 -0
- package/dist/codeSign/win/signManager.js +19 -0
- package/dist/codeSign/win/signManager.js.map +1 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts +95 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -0
- package/dist/codeSign/win/signtoolBaseSignManager.js +507 -0
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -0
- package/dist/codeSign/win/windowsCodeSign.d.ts +2 -1
- package/dist/codeSign/win/windowsCodeSign.d.ts.map +1 -1
- package/dist/codeSign/win/windowsCodeSign.js +22 -8
- package/dist/codeSign/win/windowsCodeSign.js.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts +11 -4
- package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.js +142 -37
- package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
- package/dist/codeSign/win/windowsSignToolManager.d.ts +1 -58
- package/dist/codeSign/win/windowsSignToolManager.d.ts.map +1 -1
- package/dist/codeSign/win/windowsSignToolManager.js +3 -363
- package/dist/codeSign/win/windowsSignToolManager.js.map +1 -1
- package/dist/configuration.d.ts +233 -166
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +11 -1
- package/dist/configuration.js.map +1 -1
- package/dist/core.d.ts +14 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +11 -0
- package/dist/core.js.map +1 -1
- package/dist/electron/ElectronFramework.d.ts +3 -3
- package/dist/electron/ElectronFramework.d.ts.map +1 -1
- package/dist/electron/ElectronFramework.js +60 -61
- package/dist/electron/ElectronFramework.js.map +1 -1
- package/dist/electron/electronArchSupport.d.ts +12 -0
- package/dist/electron/electronArchSupport.d.ts.map +1 -0
- package/dist/electron/electronArchSupport.js +58 -0
- package/dist/electron/electronArchSupport.js.map +1 -0
- package/dist/electron/electronVersion.d.ts.map +1 -1
- package/dist/electron/electronVersion.js +1 -11
- package/dist/electron/electronVersion.js.map +1 -1
- package/dist/electron/injectFFMPEG.js +2 -2
- package/dist/electron/injectFFMPEG.js.map +1 -1
- package/dist/electron/mac/electronMac.js +24 -35
- package/dist/electron/mac/electronMac.js.map +1 -1
- package/dist/electron/mac/electronMacUtils.d.ts +24 -0
- package/dist/electron/mac/electronMacUtils.d.ts.map +1 -0
- package/dist/electron/mac/electronMacUtils.js +42 -0
- package/dist/electron/mac/electronMacUtils.js.map +1 -0
- package/dist/electron/win/electronWin.js +2 -2
- package/dist/electron/win/electronWin.js.map +1 -1
- package/dist/fileMatcher.d.ts +55 -3
- package/dist/fileMatcher.d.ts.map +1 -1
- package/dist/fileMatcher.js +274 -28
- package/dist/fileMatcher.js.map +1 -1
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +20 -8
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +19 -7
- package/dist/indexInternal.js.map +1 -1
- package/dist/linuxPackager.d.ts.map +1 -1
- package/dist/linuxPackager.js +19 -1
- package/dist/linuxPackager.js.map +1 -1
- package/dist/macPackager.d.ts +31 -14
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +236 -147
- package/dist/macPackager.js.map +1 -1
- package/dist/node-module-collector/index.d.ts.map +1 -1
- package/dist/node-module-collector/index.js +47 -16
- package/dist/node-module-collector/index.js.map +1 -1
- package/dist/node-module-collector/moduleManager.d.ts +11 -2
- package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
- package/dist/node-module-collector/moduleManager.js +34 -14
- package/dist/node-module-collector/moduleManager.js.map +1 -1
- package/dist/node-module-collector/nodeModulesCollector.d.ts +47 -26
- package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
- package/dist/node-module-collector/nodeModulesCollector.js +157 -142
- package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/dist/node-module-collector/packageManager.js +1 -1
- package/dist/node-module-collector/packageManager.js.map +1 -1
- package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts +90 -1
- package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts.map +1 -1
- package/dist/node-module-collector/pnpmNodeModulesCollector.js +325 -25
- package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/dist/node-module-collector/types.d.ts +4 -0
- package/dist/node-module-collector/types.d.ts.map +1 -1
- package/dist/node-module-collector/types.js.map +1 -1
- package/dist/options/FuseOptionsV1.d.ts +137 -0
- package/dist/options/FuseOptionsV1.d.ts.map +1 -0
- package/dist/options/FuseOptionsV1.js +2 -0
- package/dist/options/FuseOptionsV1.js.map +1 -0
- package/dist/options/MsixOptions.d.ts +126 -0
- package/dist/options/MsixOptions.d.ts.map +1 -0
- package/dist/options/MsixOptions.js +2 -0
- package/dist/options/MsixOptions.js.map +1 -0
- package/dist/options/PlatformSpecificBuildOptions.d.ts +147 -12
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/SnapOptions.d.ts +59 -32
- package/dist/options/SnapOptions.d.ts.map +1 -1
- package/dist/options/SnapOptions.js.map +1 -1
- package/dist/options/SquirrelWindowsOptions.d.ts +0 -5
- package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
- package/dist/options/SquirrelWindowsOptions.js.map +1 -1
- package/dist/options/linuxOptions.d.ts +61 -30
- package/dist/options/linuxOptions.d.ts.map +1 -1
- package/dist/options/linuxOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +113 -131
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/pkgOptions.d.ts +1 -1
- package/dist/options/pkgOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +282 -70
- package/dist/options/winOptions.d.ts.map +1 -1
- package/dist/options/winOptions.js +12 -1
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +6 -1
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +123 -40
- package/dist/packager.js.map +1 -1
- package/dist/packagerApi.d.ts +10 -1
- package/dist/packagerApi.d.ts.map +1 -1
- package/dist/packagerApi.js.map +1 -1
- package/dist/platformPackager.d.ts +55 -4
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +160 -22
- package/dist/platformPackager.js.map +1 -1
- package/dist/presets/rectCra.js +3 -1
- package/dist/presets/rectCra.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +40 -2
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +365 -23
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/updateInfoBuilder.d.ts +1 -1
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +108 -32
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/targets/ArchiveTarget.d.ts +1 -0
- package/dist/targets/ArchiveTarget.d.ts.map +1 -1
- package/dist/targets/ArchiveTarget.js +13 -4
- package/dist/targets/ArchiveTarget.js.map +1 -1
- package/dist/targets/archive.d.ts +39 -2
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +114 -30
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/blockmap/blockmap.d.ts +44 -3
- package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
- package/dist/targets/blockmap/blockmap.js +142 -15
- package/dist/targets/blockmap/blockmap.js.map +1 -1
- package/dist/targets/blockmap/verbatimRange.d.ts +44 -0
- package/dist/targets/blockmap/verbatimRange.d.ts.map +1 -0
- package/dist/targets/blockmap/verbatimRange.js +117 -0
- package/dist/targets/blockmap/verbatimRange.js.map +1 -0
- package/dist/targets/differentialUpdateInfoBuilder.d.ts +28 -2
- package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.js +75 -6
- package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/dist/targets/linux/FlatpakTarget.d.ts +17 -0
- package/dist/targets/linux/FlatpakTarget.d.ts.map +1 -1
- package/dist/targets/linux/FlatpakTarget.js +245 -45
- package/dist/targets/linux/FlatpakTarget.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts +14 -0
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +92 -12
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.d.ts +13 -0
- package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js +81 -61
- package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.d.ts +2 -0
- package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.js +20 -15
- package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
- package/dist/targets/linux/appimage/appImageUtil.d.ts +8 -2
- package/dist/targets/linux/appimage/appImageUtil.d.ts.map +1 -1
- package/dist/targets/linux/appimage/appImageUtil.js +16 -9
- package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
- package/dist/targets/linux/appimage/appLauncher.d.ts +6 -0
- package/dist/targets/linux/appimage/appLauncher.d.ts.map +1 -1
- package/dist/targets/linux/appimage/appLauncher.js +18 -20
- package/dist/targets/linux/appimage/appLauncher.js.map +1 -1
- package/dist/targets/linux/flatpakBundle.d.ts +43 -0
- package/dist/targets/linux/flatpakBundle.d.ts.map +1 -0
- package/dist/targets/linux/flatpakBundle.js +210 -0
- package/dist/targets/linux/flatpakBundle.js.map +1 -0
- package/dist/targets/linux/launcherScript.d.ts +32 -0
- package/dist/targets/linux/launcherScript.d.ts.map +1 -0
- package/dist/targets/linux/launcherScript.js +24 -0
- package/dist/targets/linux/launcherScript.js.map +1 -0
- package/dist/targets/linux/snap/SnapTarget.d.ts +1 -1
- package/dist/targets/linux/snap/SnapTarget.d.ts.map +1 -1
- package/dist/targets/linux/snap/SnapTarget.js +23 -1
- package/dist/targets/linux/snap/SnapTarget.js.map +1 -1
- package/dist/targets/linux/snap/core24.d.ts +13 -2
- package/dist/targets/linux/snap/core24.d.ts.map +1 -1
- package/dist/targets/linux/snap/core24.js +107 -95
- package/dist/targets/linux/snap/core24.js.map +1 -1
- package/dist/targets/linux/snap/coreCustom.d.ts +1 -1
- package/dist/targets/linux/snap/coreCustom.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreCustom.js +2 -2
- package/dist/targets/linux/snap/coreCustom.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts +10 -3
- package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +37 -18
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/linux/snap/snapCommand.d.ts +13 -0
- package/dist/targets/linux/snap/snapCommand.d.ts.map +1 -0
- package/dist/targets/linux/snap/snapCommand.js +21 -0
- package/dist/targets/linux/snap/snapCommand.js.map +1 -0
- package/dist/targets/linux/snap/snapPlugs.d.ts +76 -0
- package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -0
- package/dist/targets/linux/snap/snapPlugs.js +242 -0
- package/dist/targets/linux/snap/snapPlugs.js.map +1 -0
- package/dist/targets/linux/snap/snapcraft.d.ts +190 -0
- package/dist/targets/linux/snap/snapcraft.d.ts.map +1 -0
- package/dist/targets/linux/snap/snapcraft.js +11 -0
- package/dist/targets/linux/snap/snapcraft.js.map +1 -0
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts +7 -1
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.js +57 -20
- package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +146 -14
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +485 -91
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts +16 -0
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +31 -5
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/targetFactory.d.ts +7 -0
- package/dist/targets/targetFactory.d.ts.map +1 -1
- package/dist/targets/targetFactory.js +28 -0
- package/dist/targets/targetFactory.js.map +1 -1
- package/dist/targets/win/AppxTarget.d.ts +1 -2
- package/dist/targets/win/AppxTarget.d.ts.map +1 -1
- package/dist/targets/win/AppxTarget.js +37 -314
- package/dist/targets/win/AppxTarget.js.map +1 -1
- package/dist/targets/win/MsiTarget.d.ts.map +1 -1
- package/dist/targets/win/MsiTarget.js +13 -13
- package/dist/targets/win/MsiTarget.js.map +1 -1
- package/dist/targets/win/MsixTarget.d.ts +22 -0
- package/dist/targets/win/MsixTarget.d.ts.map +1 -0
- package/dist/targets/win/MsixTarget.js +214 -0
- package/dist/targets/win/MsixTarget.js.map +1 -0
- package/dist/targets/win/nsis/Defines.d.ts +4 -0
- package/dist/targets/win/nsis/Defines.d.ts.map +1 -1
- package/dist/targets/win/nsis/Defines.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts +64 -3
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +277 -113
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/WebInstallerTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/WebInstallerTarget.js +23 -12
- package/dist/targets/win/nsis/WebInstallerTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.d.ts +58 -48
- package/dist/targets/win/nsis/nsisOptions.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.js +4 -3
- package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
- package/dist/targets/win/nsis/nsisUtil.d.ts +17 -2
- package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisUtil.js +148 -41
- package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
- package/dist/targets/win/nsis/progId.d.ts +21 -0
- package/dist/targets/win/nsis/progId.d.ts.map +1 -0
- package/dist/targets/win/nsis/progId.js +60 -0
- package/dist/targets/win/nsis/progId.js.map +1 -0
- package/dist/targets/win/winAppUtil.d.ts +115 -0
- package/dist/targets/win/winAppUtil.d.ts.map +1 -0
- package/dist/targets/win/winAppUtil.js +409 -0
- package/dist/targets/win/winAppUtil.js.map +1 -0
- package/dist/toolsets/7zip.d.ts +32 -0
- package/dist/toolsets/7zip.d.ts.map +1 -1
- package/dist/toolsets/7zip.js +39 -11
- package/dist/toolsets/7zip.js.map +1 -1
- package/dist/toolsets/appimage.d.ts +3 -3
- package/dist/toolsets/appimage.d.ts.map +1 -1
- package/dist/toolsets/appimage.js +24 -21
- package/dist/toolsets/appimage.js.map +1 -1
- package/dist/toolsets/custom.d.ts +2 -3
- package/dist/toolsets/custom.d.ts.map +1 -1
- package/dist/toolsets/custom.js +67 -149
- package/dist/toolsets/custom.js.map +1 -1
- package/dist/toolsets/fpm.d.ts.map +1 -1
- package/dist/toolsets/fpm.js +11 -5
- package/dist/toolsets/fpm.js.map +1 -1
- package/dist/toolsets/icons.d.ts.map +1 -1
- package/dist/toolsets/icons.js +17 -3
- package/dist/toolsets/icons.js.map +1 -1
- package/dist/toolsets/linuxToolsMac.d.ts.map +1 -1
- package/dist/toolsets/linuxToolsMac.js +17 -4
- package/dist/toolsets/linuxToolsMac.js.map +1 -1
- package/dist/toolsets/nsis.d.ts +5 -0
- package/dist/toolsets/nsis.d.ts.map +1 -1
- package/dist/toolsets/nsis.js +20 -4
- package/dist/toolsets/nsis.js.map +1 -1
- package/dist/toolsets/version.d.ts +12 -0
- package/dist/toolsets/version.d.ts.map +1 -0
- package/dist/toolsets/version.js +13 -0
- package/dist/toolsets/version.js.map +1 -0
- package/dist/toolsets/winCodeSign.d.ts +56 -3
- package/dist/toolsets/winCodeSign.d.ts.map +1 -1
- package/dist/toolsets/winCodeSign.js +125 -42
- package/dist/toolsets/winCodeSign.js.map +1 -1
- package/dist/toolsets/wine.d.ts +2 -1
- package/dist/toolsets/wine.d.ts.map +1 -1
- package/dist/toolsets/wine.js +31 -15
- package/dist/toolsets/wine.js.map +1 -1
- package/dist/util/AppFileWalker.js +9 -1
- package/dist/util/AppFileWalker.js.map +1 -1
- package/dist/util/NodeModuleCopyHelper.js +14 -6
- package/dist/util/NodeModuleCopyHelper.js.map +1 -1
- package/dist/util/appFileCopier.d.ts +67 -2
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +244 -32
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/archCompatibility.d.ts +42 -0
- package/dist/util/archCompatibility.d.ts.map +1 -0
- package/dist/util/archCompatibility.js +202 -0
- package/dist/util/archCompatibility.js.map +1 -0
- package/dist/util/checksum.d.ts +36 -0
- package/dist/util/checksum.d.ts.map +1 -0
- package/dist/util/checksum.js +48 -0
- package/dist/util/checksum.js.map +1 -0
- package/dist/util/config/config.d.ts +2 -1
- package/dist/util/config/config.d.ts.map +1 -1
- package/dist/util/config/config.js +42 -20
- package/dist/util/config/config.js.map +1 -1
- package/dist/util/config/fileOptions.d.ts +30 -0
- package/dist/util/config/fileOptions.d.ts.map +1 -0
- package/dist/util/config/fileOptions.js +120 -0
- package/dist/util/config/fileOptions.js.map +1 -0
- package/dist/util/config/legacyConfigGuard.d.ts +7 -0
- package/dist/util/config/legacyConfigGuard.d.ts.map +1 -0
- package/dist/util/config/legacyConfigGuard.js +214 -0
- package/dist/util/config/legacyConfigGuard.js.map +1 -0
- package/dist/util/config/legacyOptions.d.ts +86 -0
- package/dist/util/config/legacyOptions.d.ts.map +1 -0
- package/dist/util/config/legacyOptions.js +413 -0
- package/dist/util/config/legacyOptions.js.map +1 -0
- package/dist/util/config/load.d.ts +2 -2
- package/dist/util/config/load.d.ts.map +1 -1
- package/dist/util/config/load.js +3 -12
- package/dist/util/config/load.js.map +1 -1
- package/dist/util/config/schemaValidator.d.ts.map +1 -1
- package/dist/util/config/schemaValidator.js +26 -3
- package/dist/util/config/schemaValidator.js.map +1 -1
- package/dist/util/electronGet.d.ts +43 -32
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +390 -137
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/flags.d.ts +5 -5
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +124 -16
- package/dist/util/flags.js.map +1 -1
- package/dist/util/hash.d.ts +1 -1
- package/dist/util/hash.d.ts.map +1 -1
- package/dist/util/hash.js +1 -15
- package/dist/util/hash.js.map +1 -1
- package/dist/util/installOrRebuild.d.ts +44 -0
- package/dist/util/installOrRebuild.d.ts.map +1 -0
- package/dist/util/installOrRebuild.js +276 -0
- package/dist/util/installOrRebuild.js.map +1 -0
- package/dist/util/langs.d.ts.map +1 -1
- package/dist/util/langs.js +1 -0
- package/dist/util/langs.js.map +1 -1
- package/dist/util/license.d.ts.map +1 -1
- package/dist/util/license.js +4 -1
- package/dist/util/license.js.map +1 -1
- package/dist/util/mac/macosIconComposer.d.ts +2 -1
- package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
- package/dist/util/mac/macosIconComposer.js +40 -58
- package/dist/util/mac/macosIconComposer.js.map +1 -1
- package/dist/util/mac/macosVersion.d.ts +0 -1
- package/dist/util/mac/macosVersion.d.ts.map +1 -1
- package/dist/util/mac/macosVersion.js +0 -3
- package/dist/util/mac/macosVersion.js.map +1 -1
- package/dist/util/mac/plist.d.ts +1 -1
- package/dist/util/mac/plist.d.ts.map +1 -1
- package/dist/util/mac/plist.js +5 -0
- package/dist/util/mac/plist.js.map +1 -1
- package/dist/util/nativeBinaryVerifier.d.ts +40 -0
- package/dist/util/nativeBinaryVerifier.d.ts.map +1 -0
- package/dist/util/nativeBinaryVerifier.js +381 -0
- package/dist/util/nativeBinaryVerifier.js.map +1 -0
- package/dist/util/packageMetadata.js +57 -31
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/util/removedEnvVars.d.ts +25 -0
- package/dist/util/removedEnvVars.d.ts.map +1 -0
- package/dist/util/removedEnvVars.js +54 -0
- package/dist/util/removedEnvVars.js.map +1 -0
- package/dist/util/repositoryInfo.js +6 -3
- package/dist/util/repositoryInfo.js.map +1 -1
- package/dist/util/resolve.js +1 -1
- package/dist/util/resolve.js.map +1 -1
- package/dist/util/streamSpawnToFile.d.ts +47 -0
- package/dist/util/streamSpawnToFile.d.ts.map +1 -0
- package/dist/util/streamSpawnToFile.js +110 -0
- package/dist/util/streamSpawnToFile.js.map +1 -0
- package/dist/util/toolsetLock.d.ts +2 -0
- package/dist/util/toolsetLock.d.ts.map +1 -1
- package/dist/util/toolsetLock.js +31 -5
- package/dist/util/toolsetLock.js.map +1 -1
- package/dist/util/trustedSourceRoots.d.ts +59 -0
- package/dist/util/trustedSourceRoots.d.ts.map +1 -0
- package/dist/util/trustedSourceRoots.js +127 -0
- package/dist/util/trustedSourceRoots.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/vm/ParallelsVm.d.ts.map +1 -1
- package/dist/vm/ParallelsVm.js +29 -3
- package/dist/vm/ParallelsVm.js.map +1 -1
- package/dist/vm/vm.d.ts +2 -0
- package/dist/vm/vm.d.ts.map +1 -1
- package/dist/vm/vm.js +29 -6
- package/dist/vm/vm.js.map +1 -1
- package/dist/winPackager.d.ts +6 -5
- package/dist/winPackager.d.ts.map +1 -1
- package/dist/winPackager.js +45 -39
- package/dist/winPackager.js.map +1 -1
- package/package.json +20 -20
- package/scheme.json +2112 -1495
- package/templates/appx/appxmanifest.xml +2 -3
- package/templates/entitlements.mac.adhoc.plist +15 -0
- package/templates/entitlements.mac.plist +9 -6
- package/templates/msix/appxmanifest.xml +45 -0
- package/templates/nsis/assistedMessages.yml +17 -0
- package/templates/nsis/common.nsh +2 -2
- package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +96 -13
- package/templates/nsis/include/extractAppPackage.nsh +5 -2
- package/templates/nsis/include/installUtil.nsh +2 -2
- package/templates/nsis/include/installer.nsh +94 -53
- package/templates/nsis/include/webPackage.nsh +52 -27
- package/templates/nsis/installSection.nsh +29 -0
- package/templates/nsis/installer.nsi +1 -1
- package/templates/nsis/messages.yml +5 -0
- package/templates/nsis/multiUserUi.nsh +1 -1
- package/dist/codeSign/signManager.d.ts +0 -14
- package/dist/codeSign/signManager.d.ts.map +0 -1
- package/dist/codeSign/signManager.js +0 -2
- package/dist/codeSign/signManager.js.map +0 -1
- package/dist/util/yarn.d.ts +0 -23
- package/dist/util/yarn.d.ts.map +0 -1
- package/dist/util/yarn.js +0 -153
- package/dist/util/yarn.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as childProcess from "child_process";
|
|
2
|
+
import { createWriteStream } from "node:fs";
|
|
3
|
+
/**
|
|
4
|
+
* Spawns a command and streams its stdout to a file, returning the exit code and captured stderr.
|
|
5
|
+
*
|
|
6
|
+
* stdout is piped straight to `outputFile` (never buffered in memory), so arbitrarily large output —
|
|
7
|
+
* a full dependency tree, a verbose `install` log — costs no heap. stderr is small by comparison and
|
|
8
|
+
* is accumulated so the caller can surface it on failure.
|
|
9
|
+
*
|
|
10
|
+
* On Windows the package-manager command is typically a `.cmd` shim (npm.cmd/pnpm.cmd/yarn.cmd),
|
|
11
|
+
* which Node can no longer spawn directly (CVE-2024-27980). Rather than spawn with `shell: true` —
|
|
12
|
+
* which emits the DEP0190 "args with shell" deprecation warning and forces manual metacharacter
|
|
13
|
+
* escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)
|
|
14
|
+
* payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn
|
|
15
|
+
* directly with no shell. See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This
|
|
16
|
+
* also avoids the cmd.exe "The batch file cannot be found." re-open race that plagues `.cmd` shims.
|
|
17
|
+
*
|
|
18
|
+
* Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's
|
|
19
|
+
* job (e.g. `npm list` returns 1 in expected scenarios). Only genuine infrastructure failures —
|
|
20
|
+
* spawn errors and write-stream errors — reject.
|
|
21
|
+
*
|
|
22
|
+
* @param command - The command to execute
|
|
23
|
+
* @param args - Array of command-line arguments
|
|
24
|
+
* @param cwd - The working directory to execute the command in
|
|
25
|
+
* @param outputFile - The path to the file where stdout will be streamed
|
|
26
|
+
* @param env - The environment for the child process (callers are responsible for stripping secrets)
|
|
27
|
+
*/
|
|
28
|
+
export function streamSpawnToFile(command, args, cwd, outputFile, env) {
|
|
29
|
+
const [spawnCommand, spawnArgs] = process.platform === "win32" ? ["powershell.exe", buildPowerShellEncodedArgs(command, args)] : [command, args];
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const outStream = createWriteStream(outputFile);
|
|
32
|
+
const child = childProcess.spawn(spawnCommand, spawnArgs, { cwd, env });
|
|
33
|
+
let stderr = "";
|
|
34
|
+
// The process can close before all piped stdout has been flushed to disk. Resolving on the
|
|
35
|
+
// child's "close" alone races the write stream and lets the caller read a TRUNCATED file
|
|
36
|
+
// (manifesting as "No JSON content found in output"). Gate the settle on BOTH the child exit
|
|
37
|
+
// (for the code/stderr) and the write stream's "finish" (all bytes flushed).
|
|
38
|
+
let exitCode = null;
|
|
39
|
+
let childClosed = false;
|
|
40
|
+
let streamFinished = false;
|
|
41
|
+
let settled = false;
|
|
42
|
+
// `pipe` ends `outStream` when stdout EOFs, which triggers its "finish" once flushed.
|
|
43
|
+
child.stdout.pipe(outStream);
|
|
44
|
+
child.stderr.on("data", chunk => {
|
|
45
|
+
stderr += chunk.toString();
|
|
46
|
+
});
|
|
47
|
+
const fail = (err) => {
|
|
48
|
+
if (settled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
settled = true;
|
|
52
|
+
// Best-effort cleanup: stop the child and close the stream so we don't
|
|
53
|
+
// waste CPU writing to a broken fd after rejection.
|
|
54
|
+
try {
|
|
55
|
+
child.kill();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// ignore
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
outStream.destroy();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// ignore
|
|
65
|
+
}
|
|
66
|
+
reject(err);
|
|
67
|
+
};
|
|
68
|
+
const settle = () => {
|
|
69
|
+
if (settled || !childClosed || !streamFinished) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
settled = true;
|
|
73
|
+
resolve({ code: exitCode, stderr });
|
|
74
|
+
};
|
|
75
|
+
outStream.on("error", err => fail(new Error(`Failed writing process output (${command}): ${err.message}`)));
|
|
76
|
+
outStream.on("finish", () => {
|
|
77
|
+
streamFinished = true;
|
|
78
|
+
settle();
|
|
79
|
+
});
|
|
80
|
+
child.on("error", err => {
|
|
81
|
+
fail(new Error(`Process spawn (${command} ${JSON.stringify(args)}) failed: ${err.message}`));
|
|
82
|
+
});
|
|
83
|
+
child.on("close", code => {
|
|
84
|
+
exitCode = code;
|
|
85
|
+
childClosed = true;
|
|
86
|
+
settle();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Build the argv for invoking a Windows command through `powershell.exe -EncodedCommand`.
|
|
92
|
+
*
|
|
93
|
+
* Each token is wrapped in a PowerShell single-quoted string (with embedded single quotes doubled),
|
|
94
|
+
* so no character is interpreted by a shell. The script:
|
|
95
|
+
* - pins `[Console]::OutputEncoding` to UTF-8 *without* a BOM so the JSON dependency tree is not
|
|
96
|
+
* corrupted by the console's OEM code page (and no BOM is prepended to break `JSON.parse`),
|
|
97
|
+
* - invokes the command via the call operator `&`,
|
|
98
|
+
* - re-emits the command's own exit code via `exit $LASTEXITCODE` (e.g. `npm list` returns 1 in
|
|
99
|
+
* expected scenarios, which the caller's shouldIgnore logic relies on).
|
|
100
|
+
*
|
|
101
|
+
* The whole script is base64-encoded as UTF-16LE per PowerShell's `-EncodedCommand` contract.
|
|
102
|
+
*/
|
|
103
|
+
export function buildPowerShellEncodedArgs(command, args) {
|
|
104
|
+
const psQuote = (value) => `'${value.replace(/'/g, "''")}'`;
|
|
105
|
+
const invocation = ["&", psQuote(command), ...args.map(psQuote)].join(" ");
|
|
106
|
+
const script = `[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false); ${invocation}; exit $LASTEXITCODE`;
|
|
107
|
+
const encoded = Buffer.from(script, "utf16le").toString("base64");
|
|
108
|
+
return ["-NoProfile", "-NonInteractive", "-EncodedCommand", encoded];
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=streamSpawnToFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamSpawnToFile.js","sourceRoot":"","sources":["../../src/util/streamSpawnToFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAS3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,IAAc,EAAE,GAAW,EAAE,UAAkB,EAAE,GAAsB;IACxH,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,QA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,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1E,MAAM,MAAM,GAAG,sEAAsE,UAAU,sBAAsB,CAAA;IACrH,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACjE,OAAO,CAAC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import * as childProcess from \"child_process\"\nimport { createWriteStream } from \"node:fs\"\n\nexport interface StreamSpawnResult {\n /** The child's exit code (null if it was killed by a signal). */\n code: number | null\n /** Everything the child wrote to stderr, accumulated. */\n stderr: string\n}\n\n/**\n * Spawns a command and streams its stdout to a file, returning the exit code and captured stderr.\n *\n * stdout is piped straight to `outputFile` (never buffered in memory), so arbitrarily large output —\n * a full dependency tree, a verbose `install` log — costs no heap. stderr is small by comparison and\n * is accumulated so the caller can surface it on failure.\n *\n * On Windows the package-manager command is typically a `.cmd` shim (npm.cmd/pnpm.cmd/yarn.cmd),\n * which Node can no longer spawn directly (CVE-2024-27980). Rather than spawn with `shell: true` —\n * which emits the DEP0190 \"args with shell\" deprecation warning and forces manual metacharacter\n * escaping — wrap the invocation in a single PowerShell `-EncodedCommand`. The base64 (UTF-16LE)\n * payload sidesteps every shell-quoting layer, and `powershell.exe` is a real executable we spawn\n * directly with no shell. See buildPowerShellEncodedArgs for the UTF-8 / exit-code handling. This\n * also avoids the cmd.exe \"The batch file cannot be found.\" re-open race that plagues `.cmd` shims.\n *\n * Resolves with `{ code, stderr }` for ANY exit code — interpreting a non-zero code is the caller's\n * job (e.g. `npm list` returns 1 in expected scenarios). Only genuine infrastructure failures —\n * spawn errors and write-stream errors — reject.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param outputFile - The path to the file where stdout will be streamed\n * @param env - The environment for the child process (callers are responsible for stripping secrets)\n */\nexport function streamSpawnToFile(command: string, args: string[], cwd: string, outputFile: string, env: NodeJS.ProcessEnv): Promise<StreamSpawnResult> {\n const [spawnCommand, spawnArgs] = process.platform === \"win32\" ? ([\"powershell.exe\", buildPowerShellEncodedArgs(command, args)] as const) : ([command, args] as const)\n\n return new Promise<StreamSpawnResult>((resolve, reject) => {\n const outStream = createWriteStream(outputFile)\n\n const child = childProcess.spawn(spawnCommand, spawnArgs, { cwd, env })\n\n let stderr = \"\"\n // The process can close before all piped stdout has been flushed to disk. Resolving on the\n // child's \"close\" alone races the write stream and lets the caller read a TRUNCATED file\n // (manifesting as \"No JSON content found in output\"). Gate the settle on BOTH the child exit\n // (for the code/stderr) and the write stream's \"finish\" (all bytes flushed).\n let exitCode: number | null = null\n let childClosed = false\n let streamFinished = false\n let settled = false\n\n // `pipe` ends `outStream` when stdout EOFs, which triggers its \"finish\" once flushed.\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n\n const fail = (err: Error) => {\n if (settled) {\n return\n }\n settled = true\n // Best-effort cleanup: stop the child and close the stream so we don't\n // waste CPU writing to a broken fd after rejection.\n try {\n child.kill()\n } catch {\n // ignore\n }\n try {\n outStream.destroy()\n } catch {\n // ignore\n }\n reject(err)\n }\n\n const settle = () => {\n if (settled || !childClosed || !streamFinished) {\n return\n }\n settled = true\n resolve({ code: exitCode, stderr })\n }\n\n outStream.on(\"error\", err => fail(new Error(`Failed writing process output (${command}): ${err.message}`)))\n outStream.on(\"finish\", () => {\n streamFinished = true\n settle()\n })\n child.on(\"error\", err => {\n fail(new Error(`Process spawn (${command} ${JSON.stringify(args)}) failed: ${err.message}`))\n })\n child.on(\"close\", code => {\n exitCode = code\n childClosed = true\n settle()\n })\n })\n}\n\n/**\n * Build the argv for invoking a Windows command through `powershell.exe -EncodedCommand`.\n *\n * Each token is wrapped in a PowerShell single-quoted string (with embedded single quotes doubled),\n * so no character is interpreted by a shell. The script:\n * - pins `[Console]::OutputEncoding` to UTF-8 *without* a BOM so the JSON dependency tree is not\n * corrupted by the console's OEM code page (and no BOM is prepended to break `JSON.parse`),\n * - invokes the command via the call operator `&`,\n * - re-emits the command's own exit code via `exit $LASTEXITCODE` (e.g. `npm list` returns 1 in\n * expected scenarios, which the caller's shouldIgnore logic relies on).\n *\n * The whole script is base64-encoded as UTF-16LE per PowerShell's `-EncodedCommand` contract.\n */\nexport function buildPowerShellEncodedArgs(command: string, args: string[]): string[] {\n const psQuote = (value: string) => `'${value.replace(/'/g, \"''\")}'`\n const invocation = [\"&\", psQuote(command), ...args.map(psQuote)].join(\" \")\n const script = `[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false); ${invocation}; exit $LASTEXITCODE`\n const encoded = Buffer.from(script, \"utf16le\").toString(\"base64\")\n return [\"-NoProfile\", \"-NonInteractive\", \"-EncodedCommand\", encoded]\n}\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function withToolsetLock<T>(task: () => Promise<T>): Promise<T>;
|
|
2
|
+
export declare function withSigntoolLock<T>(task: () => Promise<T>): Promise<T>;
|
|
3
|
+
export declare function withIconsLock<T>(task: () => Promise<T>): Promise<T>;
|
|
2
4
|
//# sourceMappingURL=toolsetLock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolsetLock.d.ts","sourceRoot":"","sources":["../../src/util/toolsetLock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toolsetLock.d.ts","sourceRoot":"","sources":["../../src/util/toolsetLock.ts"],"names":[],"mappings":"AAuBA,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAErE;AAUD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEtE;AASD,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEnE"}
|
package/dist/util/toolsetLock.js
CHANGED
|
@@ -3,10 +3,12 @@ import { writeFile } from "fs/promises";
|
|
|
3
3
|
import * as lockfile from "proper-lockfile";
|
|
4
4
|
import * as os from "os";
|
|
5
5
|
import * as path from "path";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const TOOLSET_LOCK_FILE = path.join(os.tmpdir(), ".electron-builder-toolset.lock");
|
|
7
|
+
const SIGNTOOL_LOCK_FILE = path.join(os.tmpdir(), ".electron-builder-signtool.lock");
|
|
8
|
+
const ICONS_LOCK_FILE = path.join(os.tmpdir(), ".electron-builder-icons.lock");
|
|
9
|
+
async function withLock(lockFile, task) {
|
|
10
|
+
await writeFile(lockFile, "", { flag: "a" });
|
|
11
|
+
const release = await lockfile.lock(lockFile, {
|
|
10
12
|
retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },
|
|
11
13
|
stale: 120_000,
|
|
12
14
|
});
|
|
@@ -14,7 +16,31 @@ export async function withToolsetLock(task) {
|
|
|
14
16
|
return await task();
|
|
15
17
|
}
|
|
16
18
|
finally {
|
|
17
|
-
await release().catch((err) => log.warn({ err }, "failed to release
|
|
19
|
+
await release().catch((err) => log.warn({ err }, "failed to release lock"));
|
|
18
20
|
}
|
|
19
21
|
}
|
|
22
|
+
export function withToolsetLock(task) {
|
|
23
|
+
return withLock(TOOLSET_LOCK_FILE, task);
|
|
24
|
+
}
|
|
25
|
+
// `signtool sign /f <pfx>` imports the PFX via PFXImportCertStore, which mutates the per-user
|
|
26
|
+
// CryptoAPI/CNG key+cert storage — a process-global resource that is not safe for concurrent access.
|
|
27
|
+
// winPackager already serializes signing within a single packager (signingQueue), but parallel builds
|
|
28
|
+
// (e.g. the test harness running multiple packagers across vitest workers that share one Windows user
|
|
29
|
+
// profile) race on that shared store and intermittently fail, after cert selection, with
|
|
30
|
+
// "SignTool Error: An error occurred while attempting to load the signing certificate". A dedicated
|
|
31
|
+
// cross-process lock (separate from the toolset lock so it does not block MSI/Squirrel builds)
|
|
32
|
+
// serializes signtool invocations. No-op overhead for real single builds, which are already serial.
|
|
33
|
+
export function withSigntoolLock(task) {
|
|
34
|
+
return withLock(SIGNTOOL_LOCK_FILE, task);
|
|
35
|
+
}
|
|
36
|
+
// The icons toolset CLI (icon-tool.js) converts via a WebAssembly-backed image pipeline, and each
|
|
37
|
+
// invocation reserves a large `WebAssembly.Memory`. A single build converting one icon is fine, but
|
|
38
|
+
// parallel builds — most acutely the test harness running many packagers across forked vitest workers
|
|
39
|
+
// on one machine — spawn enough concurrent icon-tool processes to exhaust memory, failing with
|
|
40
|
+
// "WebAssembly.Memory(): could not allocate memory". A cross-process lock (separate from the toolset
|
|
41
|
+
// lock so it does not serialize against MSI/Squirrel/DMG builds) caps icon conversion at one at a
|
|
42
|
+
// time. No-op overhead for real single builds, which are already serial.
|
|
43
|
+
export function withIconsLock(task) {
|
|
44
|
+
return withLock(ICONS_LOCK_FILE, task);
|
|
45
|
+
}
|
|
20
46
|
//# sourceMappingURL=toolsetLock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolsetLock.js","sourceRoot":"","sources":["../../src/util/toolsetLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,MAAM,
|
|
1
|
+
{"version":3,"file":"toolsetLock.js","sourceRo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iBAAiB,EAAE,IAAI,CAAC,CAAA;AAC1C,CAAC;AAED,8FAA8F;AAC9F,qGAAqG;AACrG,sGAAsG;AACtG,sGAAsG;AACtG,yFAAyF;AACzF,oGAAoG;AACpG,+FAA+F;AAC/F,oGAAoG;AACpG,MAAM,UAAU,gBAAgB,CAAI,IAAsB;IACxD,OAAO,QAAQ,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;AAC3C,CAAC;AAED,kGAAkG;AAClG,oGAAoG;AACpG,sGAAsG;AACtG,+FAA+F;AAC/F,qGAAqG;AACrG,kGAAkG;AAClG,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAI,IAAsB;IACrD,OAAO,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import { log } from \"builder-util\"\nimport { writeFile } from \"fs/promises\"\nimport * as lockfile from \"proper-lockfile\"\nimport * as os from \"os\"\nimport * as path from \"path\"\n\nconst TOOLSET_LOCK_FILE = path.join(os.tmpdir(), \".electron-builder-toolset.lock\")\nconst SIGNTOOL_LOCK_FILE = path.join(os.tmpdir(), \".electron-builder-signtool.lock\")\nconst ICONS_LOCK_FILE = path.join(os.tmpdir(), \".electron-builder-icons.lock\")\n\nasync function withLock<T>(lockFile: string, task: () => Promise<T>): Promise<T> {\n await writeFile(lockFile, \"\", { flag: \"a\" })\n const release = await lockfile.lock(lockFile, {\n retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },\n stale: 120_000,\n })\n try {\n return await task()\n } finally {\n await release().catch((err: Error) => log.warn({ err }, \"failed to release lock\"))\n }\n}\n\nexport function withToolsetLock<T>(task: () => Promise<T>): Promise<T> {\n return withLock(TOOLSET_LOCK_FILE, task)\n}\n\n// `signtool sign /f <pfx>` imports the PFX via PFXImportCertStore, which mutates the per-user\n// CryptoAPI/CNG key+cert storage — a process-global resource that is not safe for concurrent access.\n// winPackager already serializes signing within a single packager (signingQueue), but parallel builds\n// (e.g. the test harness running multiple packagers across vitest workers that share one Windows user\n// profile) race on that shared store and intermittently fail, after cert selection, with\n// \"SignTool Error: An error occurred while attempting to load the signing certificate\". A dedicated\n// cross-process lock (separate from the toolset lock so it does not block MSI/Squirrel builds)\n// serializes signtool invocations. No-op overhead for real single builds, which are already serial.\nexport function withSigntoolLock<T>(task: () => Promise<T>): Promise<T> {\n return withLock(SIGNTOOL_LOCK_FILE, task)\n}\n\n// The icons toolset CLI (icon-tool.js) converts via a WebAssembly-backed image pipeline, and each\n// invocation reserves a large `WebAssembly.Memory`. A single build converting one icon is fine, but\n// parallel builds — most acutely the test harness running many packagers across forked vitest workers\n// on one machine — spawn enough concurrent icon-tool processes to exhaust memory, failing with\n// \"WebAssembly.Memory(): could not allocate memory\". A cross-process lock (separate from the toolset\n// lock so it does not serialize against MSI/Squirrel/DMG builds) caps icon conversion at one at a\n// time. No-op overhead for real single builds, which are already serial.\nexport function withIconsLock<T>(task: () => Promise<T>): Promise<T> {\n return withLock(ICONS_LOCK_FILE, task)\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AllowExternalLinksValue, ExternalLinkPolicy } from "builder-util";
|
|
2
|
+
import { Nullish } from "builder-util-runtime";
|
|
3
|
+
import type { FilesBuildOptions } from "../options/PlatformSpecificBuildOptions.js";
|
|
4
|
+
/** Where the rule for files reached through symlinks is documented. */
|
|
5
|
+
export declare const LINKED_FILES_DOCS_URL = "https://www.electron.build/docs/contents#linked-files-must-resolve-inside-the-workspace";
|
|
6
|
+
/** What {@link getTrustedSourceRoots} needs to know about the build: `Packager` and `PlatformPackager` both have it. */
|
|
7
|
+
export interface SourceRootsInfo {
|
|
8
|
+
readonly projectDir: string;
|
|
9
|
+
readonly appDir: string;
|
|
10
|
+
getWorkspaceRoot(): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
/** The configuration root, or a platform section (`mac`, `win`, `linux`): both may set `fileOptions`. */
|
|
13
|
+
interface FileOptionsHolder {
|
|
14
|
+
readonly fileOptions?: FilesBuildOptions | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The effective `fileOptions.allowExternalLinks` value for a platform, read from the normalized `fileOptions` like `files`,
|
|
18
|
+
* `extraResources` and `extraFiles`: the platform-level value (`mac.fileOptions.allowExternalLinks`, ...) when it is set, `false`
|
|
19
|
+
* included, otherwise the root one. Unlike the file lists, the two are not combined: the platform value replaces the root one.
|
|
20
|
+
*
|
|
21
|
+
* `optionPath` names where the value came from, for the errors about a malformed value.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveAllowExternalLinks(config: FileOptionsHolder, platformOptions: FileOptionsHolder | Nullish, platformKey: string): {
|
|
24
|
+
value: AllowExternalLinksValue;
|
|
25
|
+
optionPath: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The store directories of pnpm, read from the `node_modules/.modules.yaml` that pnpm writes: the content-addressable store and the
|
|
29
|
+
* virtual store, which `enableGlobalVirtualStore` puts outside the project. Other package managers keep everything they link to
|
|
30
|
+
* inside the workspace (`node_modules/.bun`, workspace packages), so they need nothing here.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readPackageManagerStoreDirs(nodeModulesDir: string): Promise<Array<string>>;
|
|
33
|
+
/**
|
|
34
|
+
* The directories that files of the app may come from through a symlink, as real paths: the workspace root, the project and app
|
|
35
|
+
* directories (chosen by the build configuration) and the package-manager store. A file whose real path is anywhere else is refused.
|
|
36
|
+
* Computed once per `key` (the packager).
|
|
37
|
+
*/
|
|
38
|
+
export declare function getTrustedSourceRoots(info: SourceRootsInfo, key?: object): Promise<Array<string>>;
|
|
39
|
+
/**
|
|
40
|
+
* Refuses a file of the app (packed into the asar archive or copied with `asar: false`) whose real path, through symlinks, is outside
|
|
41
|
+
* every trusted source root ({@link getTrustedSourceRoots}), unless the `fileOptions.allowExternalLinks` build option (`externalLinks`) allows it.
|
|
42
|
+
*
|
|
43
|
+
* Only the workspace and the package-manager store are trusted: a file reached through a symlink that leads anywhere else on the build
|
|
44
|
+
* machine (the home or temp directory, a system directory) is refused.
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertSourceFileInTrustedRoots(file: string, trustedRoots: ReadonlyArray<string>, externalLinks?: ExternalLinkPolicy | null): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* The `copyDir` options for copying the app output directory into a staging directory (snap, AppImage): a symlink that the
|
|
49
|
+
* `extraResources`/`extraFiles` copy kept, because it leads into the workspace or the store or `fileOptions.allowExternalLinks` allows it, is kept
|
|
50
|
+
* again rather than failing the staging copy.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getStagingCopyLinkOptions(packager: SourceRootsInfo & {
|
|
53
|
+
getExternalLinkPolicy(): Promise<ExternalLinkPolicy>;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
allowedSymlinkRoots: ReadonlyArray<string>;
|
|
56
|
+
externalLinks: ExternalLinkPolicy;
|
|
57
|
+
}>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=trustedSourceRoots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trustedSourceRoots.d.ts","sourceRoot":"","sources":["../../src/util/trustedSourceRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,uBAAuB,EAAE,kBAAkB,EAAqE,MAAM,cAAc,CAAA;AAC1K,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAI9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAEnF,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,4FAA4F,CAAA;AAE9H,wHAAwH;AACxH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CACpC;AAED,yGAAyG;AACzG,UAAU,iBAAiB;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAChD;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,iBAAiB,EACzB,eAAe,EAAE,iBAAiB,GAAG,OAAO,EAC5C,WAAW,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,uBAAuB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAMxD;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAyBhG;AAID;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,GAAE,MAAa,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAOvG;AAUD;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,GAAE,kBAAkB,GAAG,IAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBtK;AAyBD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,eAAe,GAAG;IAAE,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAAE,GACnF,OAAO,CAAC;IAAE,mBAAmB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAAC,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAE5F"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ALLOW_EXTERNAL_LINKS_OPTION, ExternalLinkPolicy, InvalidConfigurationError, isPathWithin, log, resolvePhysicalPath } from "builder-util";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { load } from "js-yaml";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
/** Where the rule for files reached through symlinks is documented. */
|
|
6
|
+
export const LINKED_FILES_DOCS_URL = "https://www.electron.build/docs/contents#linked-files-must-resolve-inside-the-workspace";
|
|
7
|
+
/**
|
|
8
|
+
* The effective `fileOptions.allowExternalLinks` value for a platform, read from the normalized `fileOptions` like `files`,
|
|
9
|
+
* `extraResources` and `extraFiles`: the platform-level value (`mac.fileOptions.allowExternalLinks`, ...) when it is set, `false`
|
|
10
|
+
* included, otherwise the root one. Unlike the file lists, the two are not combined: the platform value replaces the root one.
|
|
11
|
+
*
|
|
12
|
+
* `optionPath` names where the value came from, for the errors about a malformed value.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveAllowExternalLinks(config, platformOptions, platformKey) {
|
|
15
|
+
const platformValue = platformOptions?.fileOptions?.allowExternalLinks;
|
|
16
|
+
if (platformValue != null) {
|
|
17
|
+
return { value: platformValue, optionPath: `${platformKey}.${ALLOW_EXTERNAL_LINKS_OPTION}` };
|
|
18
|
+
}
|
|
19
|
+
return { value: config.fileOptions?.allowExternalLinks, optionPath: ALLOW_EXTERNAL_LINKS_OPTION };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The store directories of pnpm, read from the `node_modules/.modules.yaml` that pnpm writes: the content-addressable store and the
|
|
23
|
+
* virtual store, which `enableGlobalVirtualStore` puts outside the project. Other package managers keep everything they link to
|
|
24
|
+
* inside the workspace (`node_modules/.bun`, workspace packages), so they need nothing here.
|
|
25
|
+
*/
|
|
26
|
+
export async function readPackageManagerStoreDirs(nodeModulesDir) {
|
|
27
|
+
let content;
|
|
28
|
+
try {
|
|
29
|
+
content = await readFile(path.join(nodeModulesDir, ".modules.yaml"), "utf8");
|
|
30
|
+
}
|
|
31
|
+
catch (_e) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
let data;
|
|
35
|
+
try {
|
|
36
|
+
data = load(content);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
log.debug({ file: path.join(nodeModulesDir, ".modules.yaml"), error: e.message }, "cannot parse the pnpm modules file");
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (data == null || typeof data !== "object") {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const key of ["storeDir", "virtualStoreDir"]) {
|
|
47
|
+
const value = data[key];
|
|
48
|
+
if (typeof value === "string" && value.length > 0) {
|
|
49
|
+
result.push(path.resolve(nodeModulesDir, value));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
const cache = new WeakMap();
|
|
55
|
+
/**
|
|
56
|
+
* The directories that files of the app may come from through a symlink, as real paths: the workspace root, the project and app
|
|
57
|
+
* directories (chosen by the build configuration) and the package-manager store. A file whose real path is anywhere else is refused.
|
|
58
|
+
* Computed once per `key` (the packager).
|
|
59
|
+
*/
|
|
60
|
+
export function getTrustedSourceRoots(info, key = info) {
|
|
61
|
+
let result = cache.get(key);
|
|
62
|
+
if (result == null) {
|
|
63
|
+
result = computeTrustedSourceRoots(info);
|
|
64
|
+
cache.set(key, result);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
async function computeTrustedSourceRoots(info) {
|
|
69
|
+
const workspaceRoot = await info.getWorkspaceRoot();
|
|
70
|
+
const dirs = Array.from(new Set([workspaceRoot, info.projectDir, info.appDir]));
|
|
71
|
+
const storeDirs = (await Promise.all(dirs.map(it => readPackageManagerStoreDirs(path.join(it, "node_modules"))))).flat();
|
|
72
|
+
const roots = await Promise.all([...dirs, ...storeDirs].map(it => resolvePhysicalPath(it)));
|
|
73
|
+
return Array.from(new Set(roots));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Refuses a file of the app (packed into the asar archive or copied with `asar: false`) whose real path, through symlinks, is outside
|
|
77
|
+
* every trusted source root ({@link getTrustedSourceRoots}), unless the `fileOptions.allowExternalLinks` build option (`externalLinks`) allows it.
|
|
78
|
+
*
|
|
79
|
+
* Only the workspace and the package-manager store are trusted: a file reached through a symlink that leads anywhere else on the build
|
|
80
|
+
* machine (the home or temp directory, a system directory) is refused.
|
|
81
|
+
*/
|
|
82
|
+
export async function assertSourceFileInTrustedRoots(file, trustedRoots, externalLinks = null) {
|
|
83
|
+
const resolved = await resolvePhysicalPath(file);
|
|
84
|
+
if (trustedRoots.some(root => isPathWithin(root, resolved))) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const policy = externalLinks ?? ExternalLinkPolicy.NONE;
|
|
88
|
+
if (policy.allows(file, resolved)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
log.error({ source: file, realPath: resolved }, "denied access to a file outside the workspace");
|
|
92
|
+
throw new InvalidConfigurationError(`Cannot copy file [${policy.displayPath(file)}] symlinked to file [${resolved}] outside the package: electron-builder only packages files whose real path ` +
|
|
93
|
+
`is inside the workspace root (${trustedRoots[0] ?? "unknown"}) or the package-manager store. Add the linked package to the workspace (or install it from a tarball or ` +
|
|
94
|
+
`the registry instead of linking it), or replace the symlink with a copy. ${await policy.hint([await outermostOutsideTrustedRoots(file, resolved, trustedRoots)])} ` +
|
|
95
|
+
`See ${LINKED_FILES_DOCS_URL}`, "ERR_ELECTRON_BUILDER_FILE_OUTSIDE_WORKSPACE");
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Where the linked tree that `file` (real path `resolved`) is part of starts: the real path of its highest ancestor that is still outside
|
|
99
|
+
* the trusted roots, e.g. the linked package `../lib` for `node_modules/lib/src/index.js`, so that a suggested `fileOptions.allowExternalLinks` entry
|
|
100
|
+
* covers the whole package rather than the one file that was checked first.
|
|
101
|
+
*/
|
|
102
|
+
async function outermostOutsideTrustedRoots(file, resolved, trustedRoots) {
|
|
103
|
+
let result = resolved;
|
|
104
|
+
let current = path.resolve(file);
|
|
105
|
+
for (;;) {
|
|
106
|
+
const parent = path.dirname(current);
|
|
107
|
+
if (parent === current) {
|
|
108
|
+
// not below a trusted root at all: only the file itself is known to be linked
|
|
109
|
+
return resolved;
|
|
110
|
+
}
|
|
111
|
+
const realParent = await resolvePhysicalPath(parent);
|
|
112
|
+
if (trustedRoots.some(root => isPathWithin(root, realParent))) {
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
result = realParent;
|
|
116
|
+
current = parent;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The `copyDir` options for copying the app output directory into a staging directory (snap, AppImage): a symlink that the
|
|
121
|
+
* `extraResources`/`extraFiles` copy kept, because it leads into the workspace or the store or `fileOptions.allowExternalLinks` allows it, is kept
|
|
122
|
+
* again rather than failing the staging copy.
|
|
123
|
+
*/
|
|
124
|
+
export async function getStagingCopyLinkOptions(packager) {
|
|
125
|
+
return { allowedSymlinkRoots: await getTrustedSourceRoots(packager), externalLinks: await packager.getExternalLinkPolicy() };
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=trustedSourceRoots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trustedSourceRoots.js","sourceRoot":"","sources":["../../src/util/trustedSourceRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAA2B,kBAAkB,EAAE,yBAAyB,EAAE,YAAY,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE1K,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAG5B,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,yFAAyF,CAAA;AAc9H;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAyB,EACzB,eAA4C,EAC5C,WAAmB;IAEnB,MAAM,aAAa,GAAG,eAAe,EAAE,WAAW,EAAE,kBAAkB,CAAA;IACtE,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;QAC1B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU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9E,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAA;QACpD,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;YAC9D,OAAO,MAAM,CAAA;QACf,CAAC;QACD,MAAM,GAAG,UAAU,CAAA;QACnB,OAAO,GAAG,MAAM,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,QAAoF;IAEpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC,qBAAqB,EAAE,EAAE,CAAA;AAC9H,CAAC","sourcesContent":["import { ALLOW_EXTERNAL_LINKS_OPTION, AllowExternalLinksValue, ExternalLinkPolicy, InvalidConfigurationError, isPathWithin, log, resolvePhysicalPath } from \"builder-util\"\nimport { Nullish } from \"builder-util-runtime\"\nimport { readFile } from \"fs/promises\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport type { FilesBuildOptions } from \"../options/PlatformSpecificBuildOptions.js\"\n\n/** Where the rule for files reached through symlinks is documented. */\nexport const LINKED_FILES_DOCS_URL = \"https://www.electron.build/docs/contents#linked-files-must-resolve-inside-the-workspace\"\n\n/** What {@link getTrustedSourceRoots} needs to know about the build: `Packager` and `PlatformPackager` both have it. */\nexport interface SourceRootsInfo {\n readonly projectDir: string\n readonly appDir: string\n getWorkspaceRoot(): Promise<string>\n}\n\n/** The configuration root, or a platform section (`mac`, `win`, `linux`): both may set `fileOptions`. */\ninterface FileOptionsHolder {\n readonly fileOptions?: FilesBuildOptions | null\n}\n\n/**\n * The effective `fileOptions.allowExternalLinks` value for a platform, read from the normalized `fileOptions` like `files`,\n * `extraResources` and `extraFiles`: the platform-level value (`mac.fileOptions.allowExternalLinks`, ...) when it is set, `false`\n * included, otherwise the root one. Unlike the file lists, the two are not combined: the platform value replaces the root one.\n *\n * `optionPath` names where the value came from, for the errors about a malformed value.\n */\nexport function resolveAllowExternalLinks(\n config: FileOptionsHolder,\n platformOptions: FileOptionsHolder | Nullish,\n platformKey: string\n): { value: AllowExternalLinksValue; optionPath: string } {\n const platformValue = platformOptions?.fileOptions?.allowExternalLinks\n if (platformValue != null) {\n return { value: platformValue, optionPath: `${platformKey}.${ALLOW_EXTERNAL_LINKS_OPTION}` }\n }\n return { value: config.fileOptions?.allowExternalLinks, optionPath: ALLOW_EXTERNAL_LINKS_OPTION }\n}\n\n/**\n * The store directories of pnpm, read from the `node_modules/.modules.yaml` that pnpm writes: the content-addressable store and the\n * virtual store, which `enableGlobalVirtualStore` puts outside the project. Other package managers keep everything they link to\n * inside the workspace (`node_modules/.bun`, workspace packages), so they need nothing here.\n */\nexport async function readPackageManagerStoreDirs(nodeModulesDir: string): Promise<Array<string>> {\n let content: string\n try {\n content = await readFile(path.join(nodeModulesDir, \".modules.yaml\"), \"utf8\")\n } catch (_e: any) {\n return []\n }\n let data: unknown\n try {\n data = load(content)\n } catch (e: any) {\n log.debug({ file: path.join(nodeModulesDir, \".modules.yaml\"), error: e.message }, \"cannot parse the pnpm modules file\")\n return []\n }\n if (data == null || typeof data !== \"object\") {\n return []\n }\n const result: Array<string> = []\n for (const key of [\"storeDir\", \"virtualStoreDir\"]) {\n const value: unknown = (data as Record<string, unknown>)[key]\n if (typeof value === \"string\" && value.length > 0) {\n result.push(path.resolve(nodeModulesDir, value))\n }\n }\n return result\n}\n\nconst cache = new WeakMap<object, Promise<Array<string>>>()\n\n/**\n * The directories that files of the app may come from through a symlink, as real paths: the workspace root, the project and app\n * directories (chosen by the build configuration) and the package-manager store. A file whose real path is anywhere else is refused.\n * Computed once per `key` (the packager).\n */\nexport function getTrustedSourceRoots(info: SourceRootsInfo, key: object = info): Promise<Array<string>> {\n let result = cache.get(key)\n if (result == null) {\n result = computeTrustedSourceRoots(info)\n cache.set(key, result)\n }\n return result\n}\n\nasync function computeTrustedSourceRoots(info: SourceRootsInfo): Promise<Array<string>> {\n const workspaceRoot = await info.getWorkspaceRoot()\n const dirs = Array.from(new Set([workspaceRoot, info.projectDir, info.appDir]))\n const storeDirs = (await Promise.all(dirs.map(it => readPackageManagerStoreDirs(path.join(it, \"node_modules\"))))).flat()\n const roots = await Promise.all([...dirs, ...storeDirs].map(it => resolvePhysicalPath(it)))\n return Array.from(new Set(roots))\n}\n\n/**\n * Refuses a file of the app (packed into the asar archive or copied with `asar: false`) whose real path, through symlinks, is outside\n * every trusted source root ({@link getTrustedSourceRoots}), unless the `fileOptions.allowExternalLinks` build option (`externalLinks`) allows it.\n *\n * Only the workspace and the package-manager store are trusted: a file reached through a symlink that leads anywhere else on the build\n * machine (the home or temp directory, a system directory) is refused.\n */\nexport async function assertSourceFileInTrustedRoots(file: string, trustedRoots: ReadonlyArray<string>, externalLinks: ExternalLinkPolicy | null = null): Promise<void> {\n const resolved = await resolvePhysicalPath(file)\n if (trustedRoots.some(root => isPathWithin(root, resolved))) {\n return\n }\n const policy = externalLinks ?? ExternalLinkPolicy.NONE\n if (policy.allows(file, resolved)) {\n return\n }\n log.error({ source: file, realPath: resolved }, \"denied access to a file outside the workspace\")\n throw new InvalidConfigurationError(\n `Cannot copy file [${policy.displayPath(file)}] symlinked to file [${resolved}] outside the package: electron-builder only packages files whose real path ` +\n `is inside the workspace root (${trustedRoots[0] ?? \"unknown\"}) or the package-manager store. Add the linked package to the workspace (or install it from a tarball or ` +\n `the registry instead of linking it), or replace the symlink with a copy. ${await policy.hint([await outermostOutsideTrustedRoots(file, resolved, trustedRoots)])} ` +\n `See ${LINKED_FILES_DOCS_URL}`,\n \"ERR_ELECTRON_BUILDER_FILE_OUTSIDE_WORKSPACE\"\n )\n}\n\n/**\n * Where the linked tree that `file` (real path `resolved`) is part of starts: the real path of its highest ancestor that is still outside\n * the trusted roots, e.g. the linked package `../lib` for `node_modules/lib/src/index.js`, so that a suggested `fileOptions.allowExternalLinks` entry\n * covers the whole package rather than the one file that was checked first.\n */\nasync function outermostOutsideTrustedRoots(file: string, resolved: string, trustedRoots: ReadonlyArray<string>): Promise<string> {\n let result = resolved\n let current = path.resolve(file)\n for (;;) {\n const parent = path.dirname(current)\n if (parent === current) {\n // not below a trusted root at all: only the file itself is known to be linked\n return resolved\n }\n const realParent = await resolvePhysicalPath(parent)\n if (trustedRoots.some(root => isPathWithin(root, realParent))) {\n return result\n }\n result = realParent\n current = parent\n }\n}\n\n/**\n * The `copyDir` options for copying the app output directory into a staging directory (snap, AppImage): a symlink that the\n * `extraResources`/`extraFiles` copy kept, because it leads into the workspace or the store or `fileOptions.allowExternalLinks` allows it, is kept\n * again rather than failing the staging copy.\n */\nexport async function getStagingCopyLinkOptions(\n packager: SourceRootsInfo & { getExternalLinkPolicy(): Promise<ExternalLinkPolicy> }\n): Promise<{ allowedSymlinkRoots: ReadonlyArray<string>; externalLinks: ExternalLinkPolicy }> {\n return { allowedSymlinkRoots: await getTrustedSourceRoots(packager), externalLinks: await packager.getExternalLinkPolicy() }\n}\n"]}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "27.0.0-alpha.
|
|
1
|
+
export declare const PACKAGE_VERSION = "27.0.0-alpha.11";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,oBAAoB,CAAA"}
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = "27.0.0-alpha.
|
|
1
|
+
export const PACKAGE_VERSION = "27.0.0-alpha.11";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"27.0.0-alpha.11\"\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParallelsVm.d.ts","sourceRoot":"","sources":["../../src/vm/ParallelsVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ParallelsVm.d.ts","sourceRoot":"","sources":["../../src/vm/ParallelsVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAA4D,MAAM,cAAc,CAAA;AACvH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAA;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAiCnC,qBAAa,kBAAmB,SAAQ,SAAS;IAKnC,OAAO,CAAC,QAAQ,CAAC,EAAE;IAJ/B,OAAO,CAAC,YAAY,CAAc;IAElC,OAAO,CAAC,eAAe,CAAQ;gBAEF,EAAE,EAAE,WAAW;IAM5C,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,OAAO,CAAC,kBAAkB;IASpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAUnF,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;YAKxG,SAAS;IAgCvB,OAAO,CAAC,mBAAmB;IAS3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAI/B;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,UA4BrD;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAA;IACjD,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA;CAC3C"}
|
package/dist/vm/ParallelsVm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { exec, log, spawn } from "builder-util";
|
|
1
|
+
import { exec, log, sanitizeDirPath, spawn, stripSensitiveEnvVars } from "builder-util";
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
|
+
import { homedir } from "os";
|
|
3
4
|
import { VmManager } from "./vm.js";
|
|
4
5
|
/** @internal */
|
|
5
6
|
export async function parseVmList(debugLogger) {
|
|
@@ -47,8 +48,10 @@ export class ParallelsVmManager extends VmManager {
|
|
|
47
48
|
}
|
|
48
49
|
async exec(file, args, options) {
|
|
49
50
|
await this.ensureThatVmStarted();
|
|
51
|
+
// Merge caller-supplied env onto the base environment, so extra vars don't strip PATH and `prlctl` itself stays resolvable.
|
|
52
|
+
const mergedOptions = options?.env != null ? { ...options, env: { ...stripSensitiveEnvVars(process.env), ...options.env } } : options;
|
|
50
53
|
// it is important to use "--current-user" to execute command under logged in user - to access certs.
|
|
51
|
-
return await exec("prlctl", ["exec", this.vm.id, "--current-user", file.startsWith("/") ? macPathToParallelsWindows(file) : file].concat(args),
|
|
54
|
+
return await exec("prlctl", ["exec", this.vm.id, "--current-user", file.startsWith("/") ? macPathToParallelsWindows(file) : file].concat(args), mergedOptions).catch(error => this.handleExecuteError(error));
|
|
52
55
|
}
|
|
53
56
|
async spawn(file, args, options, extraOptions) {
|
|
54
57
|
await this.ensureThatVmStarted();
|
|
@@ -102,6 +105,29 @@ export function macPathToParallelsWindows(file) {
|
|
|
102
105
|
if (file.startsWith("C:\\")) {
|
|
103
106
|
return file;
|
|
104
107
|
}
|
|
105
|
-
|
|
108
|
+
if (!file.startsWith("/")) {
|
|
109
|
+
throw new Error(`Invalid path for Parallels VM execution: "${file}"`);
|
|
110
|
+
}
|
|
111
|
+
// Validate the raw host path up-front and reject control bytes plus shell/UNC-significant
|
|
112
|
+
// metacharacters BEFORE it is concatenated into the \\Mac\... path passed to `prlctl exec`. The
|
|
113
|
+
// `/`→`\` conversion below only adds backslashes (not in the deny-set), so validating the input here
|
|
114
|
+
// is the single sanitizing barrier for the value that reaches the command.
|
|
115
|
+
// (CodeQL js/shell-command-constructed-from-input — sanitize the tainted input at the source.)
|
|
116
|
+
// eslint-disable-next-line no-control-regex
|
|
117
|
+
if (/[\x00-\x1F\x7F"*?<>|]/.test(file)) {
|
|
118
|
+
throw new Error(`Invalid path for Parallels VM execution: "${file}"`);
|
|
119
|
+
}
|
|
120
|
+
// sanitizeDirPath additionally rejects null/newline and resolves the path; the input is already
|
|
121
|
+
// validated above, so the resulting UNC path is safe to hand to prlctl.
|
|
122
|
+
const sanitized = sanitizeDirPath(file);
|
|
123
|
+
// \\Mac\Home maps to the current user's home directory and is always accessible
|
|
124
|
+
// in both --current-user and SYSTEM exec contexts (unlike \\Mac\Host which requires
|
|
125
|
+
// "All Disks" sharing to be enabled in Parallels preferences).
|
|
126
|
+
const home = homedir();
|
|
127
|
+
// codeql[js/shell-command-constructed-from-input] - `file` is validated above (control bytes + shell/UNC metacharacters rejected) and resolved via sanitizeDirPath; the resulting UNC path is passed to prlctl as a discrete execFile argv element (array args, no shell), so no shell interpretation occurs
|
|
128
|
+
const uncPath = sanitized.startsWith(home + "/")
|
|
129
|
+
? "\\\\Mac\\Home\\" + sanitized.substring(home.length + 1).replace(/\//g, "\\")
|
|
130
|
+
: "\\\\Mac\\Host\\" + sanitized.replace(/\//g, "\\");
|
|
131
|
+
return uncPath;
|
|
106
132
|
}
|
|
107
133
|
//# sourceMappingURL=ParallelsVm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParallelsVm.js","sourceRoot":"","sources":["../../src/vm/ParallelsVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAiC,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAwB;IACxD,oEAAoE;IACpE,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IAClF,WAAW,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAE1C,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAEnD,kCAAkC;IAClC,MAAM,MAAM,GAAuB,EAAE,CAAA;IACrC,KAAK,MAAM,IAAI,IAAI,OAAO;SACvB,KAAK,CAAC,MAAM,CAAC;SACb,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC/B,MAAM,EAAE,GAAQ,EAAE,CAAA;QAClB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CA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,CAAA;AACtD,CAAC","sourcesContent":["import { DebugLogger, ExtraSpawnOptions, exec, log, spawn } from \"builder-util\"\nimport { ExecFileOptions, SpawnOptions, execFileSync } from \"child_process\"\nimport { VmManager } from \"./vm.js\"\n\n/** @internal */\nexport async function parseVmList(debugLogger: DebugLogger) {\n // do not log output if debug - it is huge, logged using debugLogger\n let rawList = await exec(\"prlctl\", [\"list\", \"-i\", \"-s\", \"name\"], undefined, false)\n debugLogger.add(\"parallels.list\", rawList)\n\n rawList = rawList.substring(rawList.indexOf(\"ID:\"))\n\n // let match: Array<string> | null\n const result: Array<ParallelsVm> = []\n for (const info of rawList\n .split(\"\\n\\n\")\n .map(it => it.trim())\n .filter(it => it.length > 0)) {\n const vm: any = {}\n for (const line of info.split(\"\\n\")) {\n const meta = /^([^:(\"]+): (.*)$/.exec(line)\n if (meta == null) {\n continue\n }\n\n const key = meta[1].toLowerCase()\n if (key === \"id\" || key === \"os\" || key === \"name\" || key === \"state\" || key === \"name\") {\n vm[key] = meta[2].trim()\n }\n }\n result.push(vm)\n }\n return result\n}\n\nexport class ParallelsVmManager extends VmManager {\n private startPromise: Promise<any>\n\n private isExitHookAdded = false\n\n constructor(private readonly vm: ParallelsVm) {\n super()\n\n this.startPromise = this.doStartVm()\n }\n\n get pathSep(): string {\n return \"/\"\n }\n\n private handleExecuteError(error: Error): any {\n if (error.message.includes(\"Unable to open new session in this virtual machine\")) {\n throw new Error(`Please ensure that your are logged in \"${this.vm.name}\" parallels virtual machine. In the future please do not stop VM, but suspend.\\n\\n${error.message}`)\n }\n\n log.warn(\"ensure that 'Share folders' is set to 'All Disks', see https://goo.gl/E6XphP\")\n throw error\n }\n\n async exec(file: string, args: Array<string>, options?: ExecFileOptions): Promise<string> {\n await this.ensureThatVmStarted()\n // it is important to use \"--current-user\" to execute command under logged in user - to access certs.\n return await exec(\"prlctl\", [\"exec\", this.vm.id, \"--current-user\", file.startsWith(\"/\") ? macPathToParallelsWindows(file) : file].concat(args), options).catch(error =>\n this.handleExecuteError(error)\n )\n }\n\n async spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n await this.ensureThatVmStarted()\n return await spawn(\"prlctl\", [\"exec\", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error))\n }\n\n private async doStartVm() {\n const vmId = this.vm.id\n const state = this.vm.state\n if (state === \"running\") {\n return\n }\n\n if (!this.isExitHookAdded) {\n this.isExitHookAdded = true\n const stopArgs = [\"suspend\", vmId]\n // Suspend the VM on normal exit and on termination signals.\n // SIGTERM/SIGINT use async exec(); the synchronous 'exit' fallback fires\n // after all async callbacks have already resolved, so execFileSync is safe.\n const suspendAsync = () => exec(\"prlctl\", stopArgs).catch(() => {})\n const suspendSync = () => {\n try {\n execFileSync(\"prlctl\", stopArgs)\n } catch {\n /* best-effort */\n }\n }\n process.once(\"SIGTERM\", () => {\n void suspendAsync()\n })\n process.once(\"SIGINT\", () => {\n void suspendAsync()\n })\n process.once(\"exit\", suspendSync)\n }\n await exec(\"prlctl\", [\"start\", vmId])\n }\n\n private ensureThatVmStarted() {\n let startPromise = this.startPromise\n if (startPromise == null) {\n startPromise = this.doStartVm()\n this.startPromise = startPromise\n }\n return startPromise\n }\n\n toVmFile(file: string): string {\n // https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator\n return macPathToParallelsWindows(file)\n }\n}\n\nexport function macPathToParallelsWindows(file: string) {\n if (file.startsWith(\"C:\\\\\")) {\n return file\n }\n return \"\\\\\\\\Mac\\\\Host\\\\\" + file.replace(/\\//g, \"\\\\\")\n}\n\nexport interface ParallelsVm {\n id: string\n name: string\n os: \"win-10\" | \"win-11\" | \"ubuntu\" | \"elementary\"\n state: \"running\" | \"suspended\" | \"stopped\"\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ParallelsVm.js","sourceRoot":"","sources":["../../src/vm/ParallelsVm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,IAAI,EAA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,IAAI,KAAK,CAAC,6CAA6C,IAAI,GAAG,CAAC,CAAA;IACvE,CAAC;IACD,0FAA0F;IAC1F,gGAAgG;IAChG,qGAAqG;IACrG,2EAA2E;IAC3E,+FAA+F;IAC/F,4CAA4C;IAC5C,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,6CAA6C,IAAI,GAAG,CAAC,CAAA;IACvE,CAAC;IACD,gGAAgG;IAChG,wEAAwE;IACxE,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IACvC,gFAAgF;IAChF,oFAAoF;IACpF,+DAA+D;IAC/D,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,6SAA6S;IAC7S,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC;QAC9C,CAAC,CAAC,iBAAiB,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;QAC/E,CAAC,CAAC,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { DebugLogger, ExtraSpawnOptions, exec, log, sanitizeDirPath, spawn, stripSensitiveEnvVars } from \"builder-util\"\nimport { ExecFileOptions, SpawnOptions, execFileSync } from \"child_process\"\nimport { homedir } from \"os\"\nimport { VmManager } from \"./vm.js\"\n\n/** @internal */\nexport async function parseVmList(debugLogger: DebugLogger) {\n // do not log output if debug - it is huge, logged using debugLogger\n let rawList = await exec(\"prlctl\", [\"list\", \"-i\", \"-s\", \"name\"], undefined, false)\n debugLogger.add(\"parallels.list\", rawList)\n\n rawList = rawList.substring(rawList.indexOf(\"ID:\"))\n\n // let match: Array<string> | null\n const result: Array<ParallelsVm> = []\n for (const info of rawList\n .split(\"\\n\\n\")\n .map(it => it.trim())\n .filter(it => it.length > 0)) {\n const vm: any = {}\n for (const line of info.split(\"\\n\")) {\n const meta = /^([^:(\"]+): (.*)$/.exec(line)\n if (meta == null) {\n continue\n }\n\n const key = meta[1].toLowerCase()\n if (key === \"id\" || key === \"os\" || key === \"name\" || key === \"state\" || key === \"name\") {\n vm[key] = meta[2].trim()\n }\n }\n result.push(vm)\n }\n return result\n}\n\nexport class ParallelsVmManager extends VmManager {\n private startPromise: Promise<any>\n\n private isExitHookAdded = false\n\n constructor(private readonly vm: ParallelsVm) {\n super()\n\n this.startPromise = this.doStartVm()\n }\n\n get pathSep(): string {\n return \"/\"\n }\n\n private handleExecuteError(error: Error): any {\n if (error.message.includes(\"Unable to open new session in this virtual machine\")) {\n throw new Error(`Please ensure that your are logged in \"${this.vm.name}\" parallels virtual machine. In the future please do not stop VM, but suspend.\\n\\n${error.message}`)\n }\n\n log.warn(\"ensure that 'Share folders' is set to 'All Disks', see https://goo.gl/E6XphP\")\n throw error\n }\n\n async exec(file: string, args: Array<string>, options?: ExecFileOptions): Promise<string> {\n await this.ensureThatVmStarted()\n // Merge caller-supplied env onto the base environment, so extra vars don't strip PATH and `prlctl` itself stays resolvable.\n const mergedOptions = options?.env != null ? { ...options, env: { ...stripSensitiveEnvVars(process.env), ...options.env } } : options\n // it is important to use \"--current-user\" to execute command under logged in user - to access certs.\n return await exec(\"prlctl\", [\"exec\", this.vm.id, \"--current-user\", file.startsWith(\"/\") ? macPathToParallelsWindows(file) : file].concat(args), mergedOptions).catch(error =>\n this.handleExecuteError(error)\n )\n }\n\n async spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n await this.ensureThatVmStarted()\n return await spawn(\"prlctl\", [\"exec\", this.vm.id, file].concat(args), options, extraOptions).catch(error => this.handleExecuteError(error))\n }\n\n private async doStartVm() {\n const vmId = this.vm.id\n const state = this.vm.state\n if (state === \"running\") {\n return\n }\n\n if (!this.isExitHookAdded) {\n this.isExitHookAdded = true\n const stopArgs = [\"suspend\", vmId]\n // Suspend the VM on normal exit and on termination signals.\n // SIGTERM/SIGINT use async exec(); the synchronous 'exit' fallback fires\n // after all async callbacks have already resolved, so execFileSync is safe.\n const suspendAsync = () => exec(\"prlctl\", stopArgs).catch(() => {})\n const suspendSync = () => {\n try {\n execFileSync(\"prlctl\", stopArgs)\n } catch {\n /* best-effort */\n }\n }\n process.once(\"SIGTERM\", () => {\n void suspendAsync()\n })\n process.once(\"SIGINT\", () => {\n void suspendAsync()\n })\n process.once(\"exit\", suspendSync)\n }\n await exec(\"prlctl\", [\"start\", vmId])\n }\n\n private ensureThatVmStarted() {\n let startPromise = this.startPromise\n if (startPromise == null) {\n startPromise = this.doStartVm()\n this.startPromise = startPromise\n }\n return startPromise\n }\n\n toVmFile(file: string): string {\n // https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator\n return macPathToParallelsWindows(file)\n }\n}\n\nexport function macPathToParallelsWindows(file: string) {\n if (file.startsWith(\"C:\\\\\")) {\n return file\n }\n if (!file.startsWith(\"/\")) {\n throw new Error(`Invalid path for Parallels VM execution: \"${file}\"`)\n }\n // Validate the raw host path up-front and reject control bytes plus shell/UNC-significant\n // metacharacters BEFORE it is concatenated into the \\\\Mac\\... path passed to `prlctl exec`. The\n // `/`→`\\` conversion below only adds backslashes (not in the deny-set), so validating the input here\n // is the single sanitizing barrier for the value that reaches the command.\n // (CodeQL js/shell-command-constructed-from-input — sanitize the tainted input at the source.)\n // eslint-disable-next-line no-control-regex\n if (/[\\x00-\\x1F\\x7F\"*?<>|]/.test(file)) {\n throw new Error(`Invalid path for Parallels VM execution: \"${file}\"`)\n }\n // sanitizeDirPath additionally rejects null/newline and resolves the path; the input is already\n // validated above, so the resulting UNC path is safe to hand to prlctl.\n const sanitized = sanitizeDirPath(file)\n // \\\\Mac\\Home maps to the current user's home directory and is always accessible\n // in both --current-user and SYSTEM exec contexts (unlike \\\\Mac\\Host which requires\n // \"All Disks\" sharing to be enabled in Parallels preferences).\n const home = homedir()\n // codeql[js/shell-command-constructed-from-input] - `file` is validated above (control bytes + shell/UNC metacharacters rejected) and resolved via sanitizeDirPath; the resulting UNC path is passed to prlctl as a discrete execFile argv element (array args, no shell), so no shell interpretation occurs\n const uncPath = sanitized.startsWith(home + \"/\")\n ? \"\\\\\\\\Mac\\\\Home\\\\\" + sanitized.substring(home.length + 1).replace(/\\//g, \"\\\\\")\n : \"\\\\\\\\Mac\\\\Host\\\\\" + sanitized.replace(/\\//g, \"\\\\\")\n return uncPath\n}\n\nexport interface ParallelsVm {\n id: string\n name: string\n os: \"win-10\" | \"win-11\" | \"ubuntu\" | \"elementary\"\n state: \"running\" | \"suspended\" | \"stopped\"\n}\n"]}
|
package/dist/vm/vm.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DebugLogger, ExtraSpawnOptions } from "builder-util";
|
|
2
2
|
import { ExecFileOptions, SpawnOptions } from "child_process";
|
|
3
3
|
import { Lazy } from "lazy-val";
|
|
4
|
+
import { ToolsetConfig } from "../configuration.js";
|
|
4
5
|
export declare class VmManager {
|
|
5
6
|
get pathSep(): string;
|
|
6
7
|
exec(file: string, args: Array<string>, options?: ExecFileOptions, isLogOutIfDebug?: boolean): Promise<string>;
|
|
@@ -9,6 +10,7 @@ export declare class VmManager {
|
|
|
9
10
|
readonly powershellCommand: Lazy<string>;
|
|
10
11
|
}
|
|
11
12
|
export declare function getWindowsVm(debugLogger: DebugLogger): Promise<VmManager>;
|
|
13
|
+
export declare function getWindowsExecVm(debugLogger: DebugLogger, wineToolset: ToolsetConfig["wine"], buildResourcesDir: string): Promise<VmManager>;
|
|
12
14
|
export declare function getLinuxVm(debugLogger: DebugLogger): Promise<VmManager | undefined>;
|
|
13
15
|
export declare const isPwshAvailable: Lazy<boolean>;
|
|
14
16
|
export declare const isCommandAvailable: (command: string, args: string[]) => Promise<boolean>;
|
package/dist/vm/vm.d.ts.map
CHAN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