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
package/dist/util/electronGet.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import * as get from "@electron/get";
|
|
2
2
|
import { ElectronDownloadCacheMode, } from "@electron/get";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { exec, exists, log, PADDING, parseValidEnvVarUrl, sanitizeDirPath, to7zaOutputSwitch, ensureDir, moveDirAtomic } from "builder-util";
|
|
4
|
+
import { HttpError, MemoLazy, retry, sleep } from "builder-util-runtime";
|
|
5
|
+
import * as crypto from "crypto";
|
|
5
6
|
import { MultiProgress } from "electron-publish";
|
|
6
7
|
import { createReadStream, createWriteStream } from "fs";
|
|
7
8
|
import * as fs from "fs/promises";
|
|
8
|
-
import * as crypto from "crypto";
|
|
9
9
|
import * as os from "os";
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
import * as lockfile from "proper-lockfile";
|
|
12
12
|
import { pipeline } from "stream/promises";
|
|
13
13
|
import * as tar from "tar";
|
|
14
14
|
import * as unzipper from "unzipper";
|
|
15
|
-
import {
|
|
15
|
+
import { getPath7za } from "../toolsets/7zip.js";
|
|
16
|
+
import { checksumMismatchMessage, parseChecksum, verifyFileChecksum } from "./checksum.js";
|
|
16
17
|
import { CacheState, cleanupCacheDirectory, computeCacheMetadata, readCacheStateFile, validateCacheDirectory, writeCacheState } from "./cacheState.js";
|
|
17
|
-
function hashUrlSafe(input, length = 6) {
|
|
18
|
+
export function hashUrlSafe(input, length = 6) {
|
|
18
19
|
let hash = 5381;
|
|
19
20
|
for (let i = 0; i < input.length; i++) {
|
|
20
21
|
hash = ((hash << 5) + hash) ^ input.charCodeAt(i);
|
|
@@ -23,11 +24,24 @@ function hashUrlSafe(input, length = 6) {
|
|
|
23
24
|
const out = hash.toString(36);
|
|
24
25
|
return out.length >= length ? out.slice(0, length) : out.padStart(length, "0");
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
// MemoLazy (not Lazy): keyed on ELECTRON_BUILDER_CACHE so the resolved cache dir is recomputed if the
|
|
28
|
+
// override env var changes, while staying memoized when it doesn't (the production case). The creator
|
|
29
|
+
// also ensures the resolved dir exists — that side effect lives here, at the point of use, so
|
|
30
|
+
// getCacheDirectoryInternal stays a pure path resolver.
|
|
31
|
+
export const cacheDirectoryOverrideAllowed = new MemoLazy(() => process.env.ELECTRON_BUILDER_CACHE?.trim(), async () => {
|
|
32
|
+
const dir = await getCacheDirectoryInternal({ isAvoidSystemOnWindows: true, allowEnvVarOverride: true });
|
|
33
|
+
await ensureDir(dir);
|
|
34
|
+
return dir;
|
|
35
|
+
});
|
|
36
|
+
// Exposed for testing; not intended for public use. Pure path resolution (no I/O) — use the memoized
|
|
37
|
+
// const's above when you need the directory to exist on disk. Kept async for a stable Promise-returning
|
|
38
|
+
// contract across all call sites.
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
40
|
+
export async function getCacheDirectoryInternal(options) {
|
|
27
41
|
const { isAvoidSystemOnWindows = true, allowEnvVarOverride } = options;
|
|
28
42
|
const env = process.env.ELECTRON_BUILDER_CACHE?.trim();
|
|
29
43
|
if (allowEnvVarOverride && env && path.parse(env).root) {
|
|
30
|
-
return env;
|
|
44
|
+
return sanitizeDirPath(env);
|
|
31
45
|
}
|
|
32
46
|
const appName = "electron-builder";
|
|
33
47
|
const platform = os.platform();
|
|
@@ -58,6 +72,21 @@ function resolveCacheMode() {
|
|
|
58
72
|
}
|
|
59
73
|
return ElectronDownloadCacheMode.ReadWrite;
|
|
60
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns true when `destPath` is safely contained within `dir` (direct child or deeper).
|
|
77
|
+
* On Windows the filesystem is case-insensitive so the comparison is normalised to lowercase.
|
|
78
|
+
* @internal exported for unit testing
|
|
79
|
+
*/
|
|
80
|
+
export function isSafeExtractPath(destPath, dir) {
|
|
81
|
+
const normalizedDest = path.resolve(destPath);
|
|
82
|
+
const normalizedDir = path.resolve(dir);
|
|
83
|
+
if (process.platform === "win32") {
|
|
84
|
+
const d = normalizedDest.toLowerCase();
|
|
85
|
+
const b = normalizedDir.toLowerCase();
|
|
86
|
+
return d.startsWith(b + path.sep) || d === b;
|
|
87
|
+
}
|
|
88
|
+
return normalizedDest.startsWith(normalizedDir + path.sep) || normalizedDest === normalizedDir;
|
|
89
|
+
}
|
|
61
90
|
async function extractZipStreaming(file, dir) {
|
|
62
91
|
// Pass 1: read central directory once to collect Unix modes (one seek to EOF)
|
|
63
92
|
const zipDir = await unzipper.Open.file(file);
|
|
@@ -69,40 +98,49 @@ async function extractZipStreaming(file, dir) {
|
|
|
69
98
|
}
|
|
70
99
|
}
|
|
71
100
|
const isSymlink = (mode) => (mode & 0o170000) === 0o120000;
|
|
72
|
-
// Pass 2: stream from byte 0 — no per-entry seeks, no Docker hang
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (path.isAbsolute(target)) {
|
|
83
|
-
throw new Error(`Absolute symlink target blocked: ${target}`);
|
|
101
|
+
// Pass 2: stream from byte 0 — no per-entry seeks, no Docker hang.
|
|
102
|
+
// Destroy the read stream in a finally block so the file handle is always released,
|
|
103
|
+
// including when the loop exits early due to a thrown error.
|
|
104
|
+
const readStream = createReadStream(file);
|
|
105
|
+
try {
|
|
106
|
+
const entries = readStream.pipe(unzipper.Parse({ forceStream: true }));
|
|
107
|
+
for await (const entry of entries) {
|
|
108
|
+
const destPath = path.resolve(dir, entry.path);
|
|
109
|
+
if (!isSafeExtractPath(destPath, dir)) {
|
|
110
|
+
throw new Error(`Path traversal blocked: ${entry.path}`);
|
|
84
111
|
}
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
|
|
112
|
+
const mode = entryModes.get(entry.path) ?? 0;
|
|
113
|
+
if (mode > 0 && isSymlink(mode)) {
|
|
114
|
+
const target = (await entry.buffer()).toString();
|
|
115
|
+
if (path.isAbsolute(target)) {
|
|
116
|
+
throw new Error(`Absolute symlink target blocked: ${target}`);
|
|
117
|
+
}
|
|
118
|
+
const resolvedTarget = path.resolve(path.dirname(destPath), target);
|
|
119
|
+
if (!isSafeExtractPath(resolvedTarget, dir)) {
|
|
120
|
+
throw new Error(`Symlink target escapes extraction dir: ${target}`);
|
|
121
|
+
}
|
|
122
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
123
|
+
await fs.symlink(target, destPath);
|
|
88
124
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (mode > 0) {
|
|
100
|
-
await fs.chmod(destPath, mode & 0o7777);
|
|
125
|
+
else if (entry.type === "Directory") {
|
|
126
|
+
await fs.mkdir(destPath, { recursive: true });
|
|
127
|
+
entry.autodrain();
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
131
|
+
await pipeline(entry, createWriteStream(destPath));
|
|
132
|
+
if (mode > 0) {
|
|
133
|
+
await fs.chmod(destPath, mode & 0o7777);
|
|
134
|
+
}
|
|
101
135
|
}
|
|
102
136
|
}
|
|
103
137
|
}
|
|
138
|
+
finally {
|
|
139
|
+
readStream.destroy();
|
|
140
|
+
}
|
|
104
141
|
}
|
|
105
|
-
export async function extractArchive(
|
|
142
|
+
export async function extractArchive(archive, dir) {
|
|
143
|
+
const file = sanitizeDirPath(archive);
|
|
106
144
|
const tmpDir = `${dir}.tmp`;
|
|
107
145
|
await fs.mkdir(tmpDir, { recursive: true });
|
|
108
146
|
const release = await lockfile.lock(tmpDir, {
|
|
@@ -127,22 +165,25 @@ export async function extractArchive(file, dir) {
|
|
|
127
165
|
if (file.endsWith(".tar.gz") || file.endsWith(".tgz")) {
|
|
128
166
|
await tar.extract({ file, cwd: tmpDir, strip: 1 });
|
|
129
167
|
}
|
|
130
|
-
else if (file.endsWith(".tar.xz") || file.endsWith(".txz")) {
|
|
131
|
-
// node-tar cannot decompress xz,
|
|
168
|
+
else if (file.endsWith(".tar.xz") || file.endsWith(".txz") || file.endsWith(".tar.7z")) {
|
|
169
|
+
// Compressed tarballs node-tar cannot decompress itself (xz, 7z): use 7za to strip the outer
|
|
170
|
+
// compression layer into a .tar, then extract that tar.
|
|
171
|
+
// Note: the .tar.7z check MUST stay ahead of the plain .7z branch below, otherwise only the outer
|
|
172
|
+
// 7z layer is removed and the inner tar is left behind as-is (see https://github.com/electron-userland/electron-builder/issues/10002).
|
|
132
173
|
const cmd7za = await getPath7za();
|
|
133
|
-
const
|
|
134
|
-
await fs.rm(
|
|
135
|
-
await fs.mkdir(
|
|
174
|
+
const decompressOutDir = `${tmpDir}.decompress`;
|
|
175
|
+
await fs.rm(decompressOutDir, { recursive: true, force: true });
|
|
176
|
+
await fs.mkdir(decompressOutDir, { recursive: true });
|
|
136
177
|
try {
|
|
137
|
-
await exec(cmd7za, ["x", "-bd", file, to7zaOutputSwitch(sanitizeDirPath(
|
|
138
|
-
const innerTar = (await fs.readdir(
|
|
178
|
+
await exec(cmd7za, ["x", "-bd", file, to7zaOutputSwitch(sanitizeDirPath(decompressOutDir)), "-y"]);
|
|
179
|
+
const innerTar = (await fs.readdir(decompressOutDir)).find(f => f.endsWith(".tar"));
|
|
139
180
|
if (innerTar == null) {
|
|
140
|
-
throw new Error(`
|
|
181
|
+
throw new Error(`decompression of ${path.basename(file)} produced no .tar archive`);
|
|
141
182
|
}
|
|
142
|
-
await tar.extract({ file: path.join(
|
|
183
|
+
await tar.extract({ file: path.join(decompressOutDir, innerTar), cwd: tmpDir, strip: 1 });
|
|
143
184
|
}
|
|
144
185
|
finally {
|
|
145
|
-
await fs.rm(
|
|
186
|
+
await fs.rm(decompressOutDir, { recursive: true, force: true });
|
|
146
187
|
}
|
|
147
188
|
}
|
|
148
189
|
else if (file.endsWith(".zip")) {
|
|
@@ -157,7 +198,7 @@ export async function extractArchive(file, dir) {
|
|
|
157
198
|
// Check if extraction actually failed or just had benign warnings
|
|
158
199
|
const files = await fs.readdir(tmpDir);
|
|
159
200
|
if (files.length === 0) {
|
|
160
|
-
log.warn({ file, tmpDir, error: e.message }, "7z extraction produced no output");
|
|
201
|
+
log.warn({ file: log.filePath(file), tmpDir: log.filePath(tmpDir), error: e.message }, "7z extraction produced no output");
|
|
161
202
|
throw new Error(`7z extraction failed for ${file}: ${e.message}`);
|
|
162
203
|
}
|
|
163
204
|
// If files were extracted despite the error, log and continue
|
|
@@ -173,20 +214,110 @@ export async function extractArchive(file, dir) {
|
|
|
173
214
|
throw new Error(`Extraction of ${path.basename(file)} produced no files`);
|
|
174
215
|
}
|
|
175
216
|
await fs.rm(dir, { recursive: true, force: true });
|
|
176
|
-
await
|
|
217
|
+
await moveDirAtomic(tmpDir, dir);
|
|
177
218
|
}
|
|
178
219
|
finally {
|
|
179
220
|
await release().catch(err => log.warn({ err }, "failed to release lockfile"));
|
|
180
221
|
}
|
|
181
222
|
}
|
|
223
|
+
let proxyInitialized = false;
|
|
224
|
+
function initializeProxyOnce() {
|
|
225
|
+
if (!proxyInitialized) {
|
|
226
|
+
reinitializeProxy();
|
|
227
|
+
proxyInitialized = true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Forces undici's global proxy dispatcher to re-read the current HTTP(S)_PROXY / NO_PROXY env vars,
|
|
232
|
+
* bypassing the once-guard in initializeProxyOnce(). Exported for integration testing only.
|
|
233
|
+
*/
|
|
234
|
+
export function reinitializeProxy() {
|
|
235
|
+
get.initializeProxy();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Error codes considered transient for artifact downloads. Plain node socket errors carry the code
|
|
239
|
+
* directly on `error.code`; undici (the fetch implementation used by @electron/get v5) wraps them in
|
|
240
|
+
* a `TypeError: fetch failed` whose code lives on `error.cause.code` — including undici's own
|
|
241
|
+
* `UND_ERR_*` codes for connection resets and connect timeouts.
|
|
242
|
+
*/
|
|
243
|
+
const TRANSIENT_DOWNLOAD_ERROR_CODES = new Set([
|
|
244
|
+
"ENOTFOUND",
|
|
245
|
+
"ETIMEDOUT",
|
|
246
|
+
"ECONNRESET",
|
|
247
|
+
"ECONNREFUSED",
|
|
248
|
+
"EAI_AGAIN",
|
|
249
|
+
"EPIPE",
|
|
250
|
+
"ENOENT",
|
|
251
|
+
"UND_ERR_SOCKET",
|
|
252
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
253
|
+
]);
|
|
254
|
+
/**
|
|
255
|
+
* Decides whether a failed @electron/get download should be retried. Handles all three error shapes
|
|
256
|
+
* seen in practice (exported for tests):
|
|
257
|
+
* - builder-util-runtime's `HttpError` — retry on 5xx.
|
|
258
|
+
* - @electron/get v5's `HTTPError` (`FetchDownloader`) — a plain `Error` subclass with the fetch
|
|
259
|
+
* `Response` on `.response` and NO `.code`; retry on 5xx and 429. Matched by class and by
|
|
260
|
+
* `name === "HTTPError"` as a fallback in case multiple @electron/get copies are loaded.
|
|
261
|
+
* - transient network errors — code on `error.code`, or on `error.cause.code` for undici's
|
|
262
|
+
* `TypeError: fetch failed` wrapper.
|
|
263
|
+
*/
|
|
264
|
+
export function shouldRetryDownloadError(e) {
|
|
265
|
+
if (e == null) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (e instanceof HttpError) {
|
|
269
|
+
return e.isServerError();
|
|
270
|
+
}
|
|
271
|
+
if (e instanceof get.HTTPError || e.name === "HTTPError") {
|
|
272
|
+
const status = e.response?.status;
|
|
273
|
+
return typeof status === "number" && (status >= 500 || status === 429);
|
|
274
|
+
}
|
|
275
|
+
const code = typeof e.code === "string" ? e.code : typeof e.cause?.code === "string" ? e.cause.code : undefined;
|
|
276
|
+
return code != null && TRANSIENT_DOWNLOAD_ERROR_CODES.has(code);
|
|
277
|
+
}
|
|
278
|
+
const DOWNLOAD_ATTEMPT_TIMEOUT_MS = 10 * 60 * 1000;
|
|
279
|
+
/** undici gives up on a silent connection after its own headersTimeout/bodyTimeout (300s by default). */
|
|
280
|
+
const STALLED_DOWNLOAD_ERROR_CODES = new Set(["UND_ERR_HEADERS_TIMEOUT", "UND_ERR_BODY_TIMEOUT"]);
|
|
281
|
+
/**
|
|
282
|
+
* Runs a download with the transient-error retries. Each attempt gets its own `AbortSignal.timeout()` capping
|
|
283
|
+
* its total duration: a shared one stays aborted once it fires, so any later attempt would fail immediately.
|
|
284
|
+
* An attempt that hits that cap, or that undici drops as silent, is retried once. A caller-supplied signal is
|
|
285
|
+
* passed through as is, and its abort is final.
|
|
286
|
+
* Exported for tests.
|
|
287
|
+
*/
|
|
288
|
+
export function retryDownload(download, options = {}) {
|
|
289
|
+
const { label, callerSignal, attemptTimeoutMs = DOWNLOAD_ATTEMPT_TIMEOUT_MS } = options;
|
|
290
|
+
let timedOut = false;
|
|
291
|
+
return retry(() => download(callerSignal ?? AbortSignal.timeout(attemptTimeoutMs)), {
|
|
292
|
+
retries: 3,
|
|
293
|
+
interval: 2000,
|
|
294
|
+
backoff: 2000,
|
|
295
|
+
shouldRetry: e => {
|
|
296
|
+
// our own timeout abort is a DOMException with a numeric `code`, which shouldRetryDownloadError never matches
|
|
297
|
+
const reason = callerSignal == null && e?.name === "TimeoutError" ? "TimeoutError" : STALLED_DOWNLOAD_ERROR_CODES.has(e?.cause?.code) ? e.cause.code : null;
|
|
298
|
+
if (reason == null) {
|
|
299
|
+
return shouldRetryDownloadError(e);
|
|
300
|
+
}
|
|
301
|
+
if (timedOut) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
timedOut = true;
|
|
305
|
+
log.warn({ label, reason }, "download timed out, retrying");
|
|
306
|
+
return true;
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
}
|
|
182
310
|
async function downloadArtifactToFile(config, label) {
|
|
183
311
|
// Serialize concurrent downloads of the same artifact across vitest workers to prevent @electron/get's
|
|
184
312
|
// non-atomic putFileInCache (remove + move) from racing with a concurrent reader.
|
|
185
|
-
const
|
|
186
|
-
.
|
|
187
|
-
|
|
188
|
-
.
|
|
189
|
-
.
|
|
313
|
+
const key = {
|
|
314
|
+
p: config.platform,
|
|
315
|
+
a: config.arch,
|
|
316
|
+
v: config.version,
|
|
317
|
+
n: config.artifactName,
|
|
318
|
+
g: config.isGeneric,
|
|
319
|
+
};
|
|
320
|
+
const artifactLockKey = crypto.createHash("sha256").update(JSON.stringify(key)).digest("hex").slice(0, 20);
|
|
190
321
|
const artifactLockPath = path.join(os.tmpdir(), `eb-dl-${artifactLockKey}.lock`);
|
|
191
322
|
// This lock is taken even for cache hits (the cache-hit check lives inside @electron/get), so under
|
|
192
323
|
// heavy concurrency many builds serialize here. 30 retries (~137s of backoff) is too few — waiters
|
|
@@ -200,10 +331,11 @@ async function downloadArtifactToFile(config, label) {
|
|
|
200
331
|
});
|
|
201
332
|
let lastLoggedMilestone = -1;
|
|
202
333
|
const state = { bar: undefined };
|
|
334
|
+
// @electron/get v5 downloads via fetch, whose proxy support comes from undici's global dispatcher.
|
|
335
|
+
// initializeProxy() wires that up from HTTP(S)_PROXY/NO_PROXY env vars (replaces the got proxy agent).
|
|
336
|
+
initializeProxyOnce();
|
|
203
337
|
const downloadOptions = {
|
|
204
|
-
timeout: { request: 10 * 60 * 1000 }, // prevent indefinite hang on stalled connections
|
|
205
338
|
...config.downloadOptions,
|
|
206
|
-
agent: config.downloadOptions?.agent ?? buildGotProxyAgent(),
|
|
207
339
|
getProgressCallback: info => {
|
|
208
340
|
// @electron/get passes downloadOptions (including this callback) to its internal
|
|
209
341
|
// SHASUMS256.txt validation download. That file is tiny (<1 MB) and fires at 100%
|
|
@@ -231,20 +363,17 @@ async function downloadArtifactToFile(config, label) {
|
|
|
231
363
|
return Promise.resolve();
|
|
232
364
|
},
|
|
233
365
|
};
|
|
234
|
-
const
|
|
366
|
+
const callerSignal = config.downloadOptions?.signal;
|
|
367
|
+
// every call gets a fresh timeout signal, to prevent an indefinite hang on stalled connections
|
|
368
|
+
const withSignal = (signal = callerSignal ?? AbortSignal.timeout(DOWNLOAD_ATTEMPT_TIMEOUT_MS)) => ({ ...config, downloadOptions: { ...downloadOptions, signal } });
|
|
235
369
|
try {
|
|
236
370
|
let filePath;
|
|
237
371
|
try {
|
|
238
|
-
filePath = await
|
|
239
|
-
retries: 3,
|
|
240
|
-
interval: 2000,
|
|
241
|
-
backoff: 2000,
|
|
242
|
-
shouldRetry: (e) => e instanceof HttpError ? e.isServerError() : typeof e?.code === "string" && ["ENOTFOUND", "ETIMEDOUT", "ECONNRESET", "EPIPE", "ENOENT"].includes(e.code),
|
|
243
|
-
});
|
|
372
|
+
filePath = await retryDownload(signal => get.downloadArtifact(withSignal(signal)), { label, callerSignal });
|
|
244
373
|
}
|
|
245
374
|
catch (err) {
|
|
246
375
|
if (typeof err?.message === "string" && err.message.includes("dest already exists")) {
|
|
247
|
-
filePath = await get.downloadArtifact(
|
|
376
|
+
filePath = await get.downloadArtifact(withSignal());
|
|
248
377
|
}
|
|
249
378
|
else {
|
|
250
379
|
throw err;
|
|
@@ -252,7 +381,7 @@ async function downloadArtifactToFile(config, label) {
|
|
|
252
381
|
}
|
|
253
382
|
if (!(await exists(filePath))) {
|
|
254
383
|
log.warn({ filePath, label }, "cached artifact missing from disk; retrying with cache write");
|
|
255
|
-
filePath = await get.downloadArtifact({ ...
|
|
384
|
+
filePath = await get.downloadArtifact({ ...withSignal(), cacheMode: ElectronDownloadCacheMode.WriteOnly });
|
|
256
385
|
}
|
|
257
386
|
if (!state.bar && lastLoggedMilestone === -1) {
|
|
258
387
|
log.info({ label }, "using cached artifact");
|
|
@@ -267,26 +396,23 @@ async function downloadArtifactToFile(config, label) {
|
|
|
267
396
|
}
|
|
268
397
|
/**
|
|
269
398
|
* Checks electron-builder's own archive cache for a previously downloaded archive.
|
|
270
|
-
* Validates the SHA-256
|
|
399
|
+
* Validates the checksum (SHA-256 hex or base64 SHA-512) when one is known. Returns the cached path on hit,
|
|
271
400
|
* null on miss or checksum mismatch (mismatch also deletes the stale file).
|
|
401
|
+
*
|
|
402
|
+
* Air-gapped seeding contract: placing the archive at
|
|
403
|
+
* `<cacheDir>/<releaseName>/<archive>` (e.g. `$ELECTRON_BUILDER_CACHE/appimage@1.0.3/appimage-tools-runtime-20251108.tar.gz`)
|
|
404
|
+
* is sufficient for a fully offline toolset resolution — the checksum here is computed locally
|
|
405
|
+
* against the value hardcoded in the toolset module, and extraction happens locally too. No
|
|
406
|
+
* `.state` file needs to be seeded. See https://www.electron.build/tutorials/offline-air-gapped-builds.
|
|
272
407
|
*/
|
|
273
|
-
async function resolveFromArchiveCache(archiveCachePath, label,
|
|
408
|
+
async function resolveFromArchiveCache(archiveCachePath, label, expected) {
|
|
274
409
|
if (!(await exists(archiveCachePath))) {
|
|
275
410
|
return null;
|
|
276
411
|
}
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
s.on("error", reject);
|
|
282
|
-
s.on("data", (chunk) => h.update(chunk));
|
|
283
|
-
s.on("end", () => resolve(h.digest("hex")));
|
|
284
|
-
});
|
|
285
|
-
if (hash !== expectedSha256) {
|
|
286
|
-
log.warn({ file: label, archiveCachePath }, "cached archive checksum mismatch — removing and re-downloading");
|
|
287
|
-
await fs.rm(archiveCachePath).catch(() => { });
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
412
|
+
if (expected != null && !(await verifyFileChecksum(archiveCachePath, expected)).matches) {
|
|
413
|
+
log.warn({ file: label, archiveCachePath }, "cached archive checksum mismatch — removing and re-downloading");
|
|
414
|
+
await fs.rm(archiveCachePath).catch(() => { });
|
|
415
|
+
return null;
|
|
290
416
|
}
|
|
291
417
|
log.debug({ file: label, archiveCachePath }, "using cached archive — skipping download");
|
|
292
418
|
return archiveCachePath;
|
|
@@ -309,10 +435,15 @@ async function persistToArchiveCache(sourcePath, archiveCachePath) {
|
|
|
309
435
|
* progress bar, extraction (.zip or .tar.gz), and completion marker.
|
|
310
436
|
* Both public download functions delegate here after building their respective configs.
|
|
311
437
|
*/
|
|
312
|
-
async function downloadAndExtract(config, extractDir, label, archiveCachePath) {
|
|
313
|
-
|
|
314
|
-
//
|
|
315
|
-
//
|
|
438
|
+
async function downloadAndExtract(config, extractDir, label, archiveCachePath, expectedChecksum) {
|
|
439
|
+
// Create only the PARENT dir (e.g. <cache>/fpm@2.2.1), never extractDir itself, before locking.
|
|
440
|
+
// The parent is stable — cleanup only ever removes extractDir and its .state/.tmp/.lock siblings —
|
|
441
|
+
// so extractDir's whole lifecycle (mkdir, rm, re-mkdir) stays inside the lock. ensureDir absorbs
|
|
442
|
+
// the concurrent-recursive-mkdir ENOENT/EEXIST race while peers populate the cold cache tree.
|
|
443
|
+
await ensureDir(path.dirname(extractDir));
|
|
444
|
+
// Pre-lock fast path: read-only short-circuit for a definitively complete and valid cache.
|
|
445
|
+
// Safe unlocked — the cache-state helpers return null/false for a missing or half-written dir,
|
|
446
|
+
// so a racing read only ever falls through to take the lock. Do NOT mutate the dir here.
|
|
316
447
|
const stateData = await readCacheStateFile(extractDir);
|
|
317
448
|
if (stateData?.state === CacheState.complete) {
|
|
318
449
|
const isValid = await validateCacheDirectory(extractDir, stateData.fileCount);
|
|
@@ -327,6 +458,13 @@ async function downloadAndExtract(config, extractDir, label, archiveCachePath) {
|
|
|
327
458
|
// patience of withToolsetLock. proper-lockfile's update heartbeat keeps a live holder's lock fresh,
|
|
328
459
|
// so increasing waiter retries never falsely steals an in-progress extraction.
|
|
329
460
|
const release = await lockfile.lock(extractDir, {
|
|
461
|
+
// realpath:false so proper-lockfile creates <extractDir>.lock in the (already-created) parent
|
|
462
|
+
// WITHOUT calling fs.realpath(extractDir) first — which would throw ENOENT now that extractDir
|
|
463
|
+
// is created lazily inside the lock. This filesystem lock serializes peers both across worker
|
|
464
|
+
// processes AND within a single process (a second lock() for the same path retries until the
|
|
465
|
+
// first releases), so no in-process promise cache is needed — and one wouldn't help across the
|
|
466
|
+
// separate test worker processes anyway.
|
|
467
|
+
realpath: false,
|
|
330
468
|
retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },
|
|
331
469
|
stale: 120000,
|
|
332
470
|
});
|
|
@@ -347,13 +485,13 @@ async function downloadAndExtract(config, extractDir, label, archiveCachePath) {
|
|
|
347
485
|
}
|
|
348
486
|
// Cleanup inside the lock — skip lock files since we currently hold them
|
|
349
487
|
await cleanupCacheDirectory(extractDir, { skipLockFiles: true });
|
|
350
|
-
await
|
|
488
|
+
await ensureDir(extractDir);
|
|
351
489
|
// Check electron-builder's own archive cache before touching @electron/get.
|
|
352
490
|
// The cache lives alongside the extract dir: <cacheDir>/<releaseName>/<filename>.
|
|
353
491
|
// This lets repeated builds (or offline environments) skip the download entirely once
|
|
354
492
|
// the archive has been fetched at least once.
|
|
355
493
|
if (archiveCachePath) {
|
|
356
|
-
downloadedFile = await resolveFromArchiveCache(archiveCachePath, label,
|
|
494
|
+
downloadedFile = await resolveFromArchiveCache(archiveCachePath, label, expectedChecksum);
|
|
357
495
|
}
|
|
358
496
|
if (!downloadedFile) {
|
|
359
497
|
log.debug({ file: label }, "downloading");
|
|
@@ -361,6 +499,17 @@ async function downloadAndExtract(config, extractDir, label, archiveCachePath) {
|
|
|
361
499
|
if (!downloadedFile) {
|
|
362
500
|
throw new Error(`Failed to download artifact: ${label}`);
|
|
363
501
|
}
|
|
502
|
+
// A SHA-256 hex checksum is verified by @electron/get during the download. A base64 SHA-512 was passed with
|
|
503
|
+
// unsafelyDisableChecksums (sumchecker only understands SHA-256 hex), so verify it here, before the archive is
|
|
504
|
+
// persisted to the archive cache or extracted.
|
|
505
|
+
if (expectedChecksum != null && expectedChecksum.algorithm !== "sha256") {
|
|
506
|
+
const { matches, actual } = await verifyFileChecksum(downloadedFile, expectedChecksum);
|
|
507
|
+
if (!matches) {
|
|
508
|
+
await fs.rm(downloadedFile, { force: true }).catch(() => { });
|
|
509
|
+
throw new Error(`${checksumMismatchMessage(label, expectedChecksum, actual)} The corrupted download has been removed.`);
|
|
510
|
+
}
|
|
511
|
+
log.debug({ file: label, algorithm: expectedChecksum.algorithm }, "checksum verified");
|
|
512
|
+
}
|
|
364
513
|
// Persist the downloaded archive so future builds (and offline environments) can
|
|
365
514
|
// skip the network request entirely.
|
|
366
515
|
if (archiveCachePath) {
|
|
@@ -397,7 +546,7 @@ export async function download(url, output, checksum) {
|
|
|
397
546
|
const downloadedFile = await downloadArtifactToFile({
|
|
398
547
|
version: "9.9.9",
|
|
399
548
|
artifactName: filenameWithExt,
|
|
400
|
-
cacheRoot: path.resolve(
|
|
549
|
+
cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, "downloads"),
|
|
401
550
|
cacheMode: resolveCacheMode(),
|
|
402
551
|
...(checksum != null ? { checksums: { [filenameWithExt]: checksum } } : { unsafelyDisableChecksums: true }),
|
|
403
552
|
mirrorOptions: { resolveAssetURL: async () => Promise.resolve(url) },
|
|
@@ -421,7 +570,7 @@ const CUSTOM_DIR_ENV_VARS = [
|
|
|
421
570
|
* Resolves the final download URL for a builder binary, honouring:
|
|
422
571
|
* ELECTRON_BUILDER_BINARIES_DOWNLOAD_OVERRIDE_URL – fully replaces the URL directory
|
|
423
572
|
* ELECTRON_BUILDER_BINARIES_CUSTOM_DIR (and npm_ variants) – replaces releaseName in the path
|
|
424
|
-
* overrideUrl (caller-supplied) – used as-is when no env var is set
|
|
573
|
+
* overrideUrl (caller-supplied) – the complete file URL, used as-is when no env var is set
|
|
425
574
|
*
|
|
426
575
|
* Exported for unit testing; not part of the public API.
|
|
427
576
|
* @internal
|
|
@@ -432,7 +581,9 @@ export function resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, o
|
|
|
432
581
|
return `${envOverrideUrl}/${filenameWithExt}`;
|
|
433
582
|
}
|
|
434
583
|
if (overrideUrl != null) {
|
|
435
|
-
|
|
584
|
+
// The caller-supplied override (ToolsetCustom.url) points directly at the file — appending
|
|
585
|
+
// filenameWithExt would double the last path segment (e.g. …/bundle.7z/bundle.7z, issue #10084).
|
|
586
|
+
return overrideUrl;
|
|
436
587
|
}
|
|
437
588
|
const customDirEntry = CUSTOM_DIR_ENV_VARS.map(name => ({ name, value: process.env[name] })).find(e => e.value != null);
|
|
438
589
|
if (customDirEntry != null) {
|
|
@@ -444,16 +595,34 @@ export function resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, o
|
|
|
444
595
|
* Downloads a generic artifact (.tar.gz or .zip) from a GitHub release.
|
|
445
596
|
* Used for electron-builder-binaries tools (appimage, etc.).
|
|
446
597
|
*/
|
|
598
|
+
/**
|
|
599
|
+
* Every `toolsets.*` property now defaults to "latest", which resolves to a newer bundle than v26
|
|
600
|
+
* pinned (NSIS 3.0.4.1 -> 3.12, winCodeSign 2.6.0 -> 1.3.0, Wine 4.0.1 -> 11.0, AppImage FUSE2 ->
|
|
601
|
+
* static FUSE3). Nothing recorded which version was used: `downloadBuilderToolset` logged only at
|
|
602
|
+
* debug level, and on a warm cache it printed nothing at all — so a regression introduced by a new
|
|
603
|
+
* bundle had no trace in the build log tying it to the toolset.
|
|
604
|
+
*/
|
|
605
|
+
function announceToolsetVersion(releaseName) {
|
|
606
|
+
// once per toolset per process, so a multi-target build logs each one once
|
|
607
|
+
log.once(`toolset:${releaseName}`).info({ toolset: releaseName }, "using toolset");
|
|
608
|
+
}
|
|
447
609
|
export async function downloadBuilderToolset(options) {
|
|
448
610
|
const { releaseName, filenameWithExt, checksums, githubOrgRepo = "electron-userland/electron-builder-binaries", overrideUrl } = options;
|
|
611
|
+
announceToolsetVersion(releaseName);
|
|
449
612
|
if (/[/\\]|^\.\./.test(filenameWithExt) || filenameWithExt.includes("..")) {
|
|
450
613
|
throw new Error(`downloadBuilderToolset: unsafe filenameWithExt "${filenameWithExt}" — must be a plain filename with no path separators or traversal sequences`);
|
|
451
614
|
}
|
|
615
|
+
const { expectedChecksum, electronGetChecksums } = resolveToolsetChecksums(releaseName, filenameWithExt, checksums);
|
|
452
616
|
const baseUrl = getBinariesMirrorUrl(githubOrgRepo);
|
|
453
617
|
const fullUrl = resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, overrideUrl);
|
|
454
618
|
const suffix = hashUrlSafe(fullUrl, 5);
|
|
455
|
-
|
|
456
|
-
|
|
619
|
+
// tar.7z is listed before 7z so the full extension is stripped. Deliberate side effect: this changes the
|
|
620
|
+
// extract-dir name for .tar.7z toolsets (e.g. the snap template) from "<name>.tar-<hash>" to "<name>-<hash>",
|
|
621
|
+
// which busts caches poisoned by the broken .tar.7z extraction in 26.15.0-26.15.6 (issue #10002).
|
|
622
|
+
const folderName = `${filenameWithExt.replace(/\.(tar\.gz|tgz|tar\.xz|txz|tar\.7z|zip|7z)$/, "")}-${suffix}`;
|
|
623
|
+
// releaseName is library input; enforce cache-dir containment (rejects traversal, clears taint into shell extraction)
|
|
624
|
+
const cacheDir = await cacheDirectoryOverrideAllowed.value;
|
|
625
|
+
const extractDir = sanitizeDirPath(path.join(cacheDir, releaseName, folderName), cacheDir);
|
|
457
626
|
// Use resolveAssetURL so @electron/get's ELECTRON_MIRROR env var check cannot override
|
|
458
627
|
// the builder-binaries URL we've already resolved (see getArtifactRemoteURL in @electron/get).
|
|
459
628
|
const mirrorOptions = {
|
|
@@ -462,80 +631,164 @@ export async function downloadBuilderToolset(options) {
|
|
|
462
631
|
// Predictable archive cache: <cacheDir>/<releaseName>/<filename>, next to the extract dir.
|
|
463
632
|
// downloadAndExtract checks here before touching @electron/get and persists the archive here
|
|
464
633
|
// after every successful download, so subsequent builds never need a network round-trip.
|
|
465
|
-
const archiveCachePath = path.join(
|
|
634
|
+
const archiveCachePath = sanitizeDirPath(path.join(cacheDir, releaseName, filenameWithExt), cacheDir);
|
|
466
635
|
const config = {
|
|
467
636
|
version: "9.9.9", // must be >1.3.2 to bypass @electron/get validation shortcut
|
|
468
637
|
artifactName: filenameWithExt,
|
|
469
|
-
cacheRoot: path.resolve(
|
|
638
|
+
cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, "downloads"),
|
|
470
639
|
cacheMode: resolveCacheMode(),
|
|
471
|
-
...(
|
|
640
|
+
...(electronGetChecksums != null ? { checksums: electronGetChecksums } : { unsafelyDisableChecksums: true }),
|
|
472
641
|
mirrorOptions,
|
|
473
642
|
isGeneric: true,
|
|
474
643
|
};
|
|
475
|
-
return downloadAndExtract(config, extractDir, filenameWithExt, archiveCachePath);
|
|
644
|
+
return downloadAndExtract(config, extractDir, filenameWithExt, archiveCachePath, expectedChecksum);
|
|
476
645
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
646
|
+
/**
|
|
647
|
+
* Classifies every entry of a toolset checksum table up front, so a malformed value fails before anything is downloaded
|
|
648
|
+
* instead of as a sumchecker parse error or a generic mismatch afterwards. Returns the checksum for `filenameWithExt` and,
|
|
649
|
+
* when every entry is SHA-256 hex, the (lowercased) table to hand to `@electron/get`; base64 SHA-512 checksums are verified
|
|
650
|
+
* by electron-builder after the download instead (#10040).
|
|
651
|
+
*/
|
|
652
|
+
function resolveToolsetChecksums(releaseName, filenameWithExt, checksums) {
|
|
653
|
+
if (checksums == null) {
|
|
654
|
+
return {};
|
|
655
|
+
}
|
|
656
|
+
const parsed = Object.entries(checksums).map(([file, value]) => [file, parseChecksum(value, `The checksum for "${file}" (${releaseName})`)]);
|
|
657
|
+
const algorithms = new Set(parsed.map(([, checksum]) => checksum.algorithm));
|
|
658
|
+
if (algorithms.size > 1) {
|
|
659
|
+
throw new Error(`Checksums for ${releaseName} mix formats: use a single format for all entries, either SHA-256 hex or base64 SHA-512`);
|
|
660
|
+
}
|
|
661
|
+
const expectedChecksum = parsed.find(([file]) => file === filenameWithExt)?.[1];
|
|
662
|
+
if (algorithms.has("sha256")) {
|
|
663
|
+
return { expectedChecksum, electronGetChecksums: Object.fromEntries(parsed.map(([file, checksum]) => [file, checksum.value])) };
|
|
664
|
+
}
|
|
665
|
+
if (expectedChecksum == null) {
|
|
666
|
+
// @electron/get would reject a missing entry itself, but its validation is disabled for SHA-512 checksums: never let a
|
|
667
|
+
// table without an entry for this file turn into an unverified download.
|
|
668
|
+
throw new Error(`No checksum for "${filenameWithExt}" in the checksums for ${releaseName}`);
|
|
669
|
+
}
|
|
670
|
+
return { expectedChecksum };
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Mirrors @electron/get's default cache root (`env-paths("electron", { suffix: "" }).cache`).
|
|
674
|
+
* @electron/get does not export it and its package `exports` map blocks deep imports, so the
|
|
675
|
+
* (deliberately tiny) platform switch is replicated here. Must stay in sync with the
|
|
676
|
+
* `cacheRoot` default documented in @electron/get's `ElectronDownloadRequestOptions`.
|
|
677
|
+
* @internal exported for unit testing
|
|
678
|
+
*/
|
|
679
|
+
export function defaultElectronGetCacheRoot() {
|
|
680
|
+
const name = "electron";
|
|
681
|
+
const homeDir = os.homedir();
|
|
682
|
+
switch (os.platform()) {
|
|
683
|
+
case "darwin":
|
|
684
|
+
return path.join(homeDir, "Library", "Caches", name);
|
|
685
|
+
case "win32":
|
|
686
|
+
return path.join(process.env.LOCALAPPDATA || path.join(homeDir, "AppData", "Local"), name, "Cache");
|
|
687
|
+
default:
|
|
688
|
+
return path.join(process.env.XDG_CACHE_HOME || path.join(homeDir, ".cache"), name);
|
|
689
|
+
}
|
|
482
690
|
}
|
|
483
691
|
/**
|
|
484
|
-
*
|
|
485
|
-
*
|
|
692
|
+
* Parses the upstream `SHASUMS256.txt` format into the `Record<filename, sha256-hex>` shape that
|
|
693
|
+
* @electron/get accepts as inline `checksums`. Each line is `<sha256-hex> *<filename>` (binary
|
|
694
|
+
* mode) or `<sha256-hex> <filename>` (text mode); malformed lines are ignored.
|
|
695
|
+
* @internal exported for unit testing
|
|
486
696
|
*/
|
|
487
|
-
function
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
if (
|
|
492
|
-
|
|
493
|
-
artifactConfig = { ...artifactConfig, ...rest, cacheRoot, mirrorOptions };
|
|
697
|
+
export function parseChecksumFile(content) {
|
|
698
|
+
const checksums = {};
|
|
699
|
+
for (const rawLine of content.split("\n")) {
|
|
700
|
+
const match = /^([a-fA-F0-9]{64})\s+\*?(.+)$/.exec(rawLine.trim());
|
|
701
|
+
if (match != null) {
|
|
702
|
+
checksums[match[2]] = match[1].toLowerCase();
|
|
494
703
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
704
|
+
}
|
|
705
|
+
return checksums;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Looks for a locally seeded SHASUMS256 file at the root of the @electron/get cache and returns
|
|
709
|
+
* its contents as inline `checksums`, or null when nothing usable is seeded.
|
|
710
|
+
*
|
|
711
|
+
* Why: without inline `checksums`, @electron/get re-downloads `SHASUMS256.txt` with a hardcoded
|
|
712
|
+
* `cacheMode: Bypass` on EVERY build — even when the artifact itself is a cache hit — so a fully
|
|
713
|
+
* seeded cache still requires network access and air-gapped builds fail (#10039). Cache-seeding
|
|
714
|
+
* tools (e.g. flatpak-node-generator) already place `SHASUMS256.txt-<version>` flat at the cache
|
|
715
|
+
* root; feeding it back as inline `checksums` keeps checksum validation enabled while making it
|
|
716
|
+
* fully offline. A plain `SHASUMS256.txt` at the cache root is accepted as a manual-seeding
|
|
717
|
+
* fallback. A candidate file is only used when it actually contains an entry for the requested
|
|
718
|
+
* artifact, so a stale file for another version can never break an online build.
|
|
719
|
+
* See https://www.electron.build/tutorials/offline-air-gapped-builds for the seeding contract.
|
|
720
|
+
* @internal exported for unit testing
|
|
721
|
+
*/
|
|
722
|
+
export async function resolveSeededChecksums(cacheRoot, version, artifactFileName) {
|
|
723
|
+
const candidates = [path.join(cacheRoot, `SHASUMS256.txt-${version}`), path.join(cacheRoot, "SHASUMS256.txt")];
|
|
724
|
+
for (const candidate of candidates) {
|
|
725
|
+
if (!(await exists(candidate))) {
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
let content;
|
|
729
|
+
try {
|
|
730
|
+
content = await fs.readFile(candidate, "utf-8");
|
|
731
|
+
}
|
|
732
|
+
catch (err) {
|
|
733
|
+
log.warn({ file: log.filePath(candidate), err: err.message }, "failed to read seeded SHASUMS file — ignoring it");
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
const checksums = parseChecksumFile(content);
|
|
737
|
+
if (checksums[artifactFileName] == null) {
|
|
738
|
+
log.warn({ file: log.filePath(candidate), artifactFileName }, "seeded SHASUMS file has no entry for the requested artifact — ignoring it");
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
log.debug({ file: log.filePath(candidate), artifactFileName }, "using locally seeded SHASUMS256 checksums — checksum validation can run offline");
|
|
742
|
+
return checksums;
|
|
743
|
+
}
|
|
744
|
+
return null;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Assembles the `@electron/get` artifact config (`ElectronPlatformArtifactDetails`) from
|
|
748
|
+
* `ArtifactDownloadOptions`: spreads the caller's options and pins `cacheRoot`/`platform`/`arch`/
|
|
749
|
+
* `version`/`artifactName` and the resolved cache mode, warning when checksum verification is
|
|
750
|
+
* disabled. When the caller provides no `checksums` (user-provided `electronGet.checksums` always
|
|
751
|
+
* wins) and verification is not disabled, a locally seeded `SHASUMS256.txt-<version>` at the cache
|
|
752
|
+
* root is picked up as inline `checksums` so validation works offline (see resolveSeededChecksums).
|
|
753
|
+
* Callers pass the result to `downloadArtifactToFile` / `downloadAndExtract`.
|
|
754
|
+
* @internal exported for unit testing
|
|
755
|
+
*/
|
|
756
|
+
export async function buildElectronArtifactConfig(artifactOptions) {
|
|
757
|
+
const { options, arch, version, platformName: platform, artifactName, cacheDir: cacheRoot } = artifactOptions;
|
|
758
|
+
if (options?.unsafelyDisableChecksums) {
|
|
759
|
+
log.warn({ artifactName }, "electronGet.unsafelyDisableChecksums is enabled — downloaded artifacts will NOT be verified; a compromised mirror can serve malicious binaries undetected");
|
|
760
|
+
}
|
|
761
|
+
const artifactConfig = { ...options, cacheRoot, platform, arch, version, artifactName, cacheMode: resolveCacheMode() };
|
|
762
|
+
if (artifactConfig.checksums == null && !artifactConfig.unsafelyDisableChecksums) {
|
|
763
|
+
// Matches @electron/get's getArtifactFileName for non-generic artifacts; `artifactSuffix` and
|
|
764
|
+
// `customFilename` cannot diverge here — both are excluded from ElectronGetOptions.
|
|
765
|
+
const artifactFileName = `${artifactName}-v${version}-${platform}-${arch}.zip`;
|
|
766
|
+
const seededChecksums = await resolveSeededChecksums(cacheRoot ?? defaultElectronGetCacheRoot(), version, artifactFileName);
|
|
767
|
+
if (seededChecksums != null) {
|
|
768
|
+
artifactConfig.checksums = seededChecksums;
|
|
520
769
|
}
|
|
521
770
|
}
|
|
522
|
-
artifactConfig.cacheMode = resolveCacheMode();
|
|
523
771
|
return artifactConfig;
|
|
524
772
|
}
|
|
525
773
|
/**
|
|
526
774
|
* Downloads the electron artifact zip via @electron/get (with caching) and returns the zip file path.
|
|
527
775
|
* Use when you need to extract the zip yourself (e.g. directly to appOutDir to preserve empty dirs and symlinks).
|
|
528
776
|
*/
|
|
529
|
-
export function downloadElectronArtifactZip(options) {
|
|
530
|
-
const config = buildElectronArtifactConfig(options);
|
|
777
|
+
export async function downloadElectronArtifactZip(options) {
|
|
778
|
+
const config = await buildElectronArtifactConfig(options);
|
|
531
779
|
return downloadArtifactToFile(config, config.artifactName);
|
|
532
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* Downloads an electron platform artifact (e.g. ffmpeg) via `@electron/get` and extracts it into a
|
|
783
|
+
* content-addressed cache directory (keyed on a hash of the resolved artifact config), returning the
|
|
784
|
+
* extraction path.
|
|
785
|
+
*/
|
|
533
786
|
export async function downloadElectronArtifact(options) {
|
|
534
787
|
const { arch, version, platformName: platform, artifactName } = options;
|
|
535
|
-
const artifactConfig = buildElectronArtifactConfig(options);
|
|
788
|
+
const artifactConfig = await buildElectronArtifactConfig(options);
|
|
536
789
|
const suffix = hashUrlSafe(JSON.stringify(artifactConfig), 5);
|
|
537
790
|
const folderName = `${artifactName}-v${version}-${platform}-${arch}-${suffix}`;
|
|
538
|
-
const extractDir = path.join(
|
|
791
|
+
const extractDir = path.join(await cacheDirectoryOverrideAllowed.value, `${artifactName}-v${version}`, folderName);
|
|
539
792
|
return downloadAndExtract(artifactConfig, extractDir, artifactName);
|
|
540
793
|
}
|
|
541
794
|
/**
|