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.
Files changed (489) hide show
  1. package/dist/Framework.d.ts +2 -0
  2. package/dist/Framework.d.ts.map +1 -1
  3. package/dist/Framework.js.map +1 -1
  4. package/dist/appInfo.d.ts +1 -1
  5. package/dist/appInfo.d.ts.map +1 -1
  6. package/dist/appInfo.js +3 -3
  7. package/dist/appInfo.js.map +1 -1
  8. package/dist/asar/asar.js.map +1 -1
  9. package/dist/asar/asarAlign.d.ts +35 -0
  10. package/dist/asar/asarAlign.d.ts.map +1 -0
  11. package/dist/asar/asarAlign.js +149 -0
  12. package/dist/asar/asarAlign.js.map +1 -0
  13. package/dist/asar/asarFileChecker.d.ts +4 -2
  14. package/dist/asar/asarFileChecker.d.ts.map +1 -1
  15. package/dist/asar/asarFileChecker.js +2 -3
  16. package/dist/asar/asarFileChecker.js.map +1 -1
  17. package/dist/asar/asarUtil.d.ts +15 -1
  18. package/dist/asar/asarUtil.d.ts.map +1 -1
  19. package/dist/asar/asarUtil.js +132 -72
  20. package/dist/asar/asarUtil.js.map +1 -1
  21. package/dist/codeSign/certInfo.d.ts +14 -0
  22. package/dist/codeSign/certInfo.d.ts.map +1 -1
  23. package/dist/codeSign/certInfo.js +49 -0
  24. package/dist/codeSign/certInfo.js.map +1 -1
  25. package/dist/codeSign/mac/macCodeSign.d.ts +3 -3
  26. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  27. package/dist/codeSign/mac/macCodeSign.js +50 -25
  28. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  29. package/dist/codeSign/signResult.d.ts +26 -0
  30. package/dist/codeSign/signResult.d.ts.map +1 -0
  31. package/dist/codeSign/signResult.js +12 -0
  32. package/dist/codeSign/signResult.js.map +1 -0
  33. package/dist/codeSign/win/hsmSignManager.d.ts +10 -0
  34. package/dist/codeSign/win/hsmSignManager.d.ts.map +1 -0
  35. package/dist/codeSign/win/hsmSignManager.js +50 -0
  36. package/dist/codeSign/win/hsmSignManager.js.map +1 -0
  37. package/dist/codeSign/win/pkcs11SignManager.d.ts +14 -0
  38. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -0
  39. package/dist/codeSign/win/pkcs11SignManager.js +82 -0
  40. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -0
  41. package/dist/codeSign/win/signManager.d.ts +17 -0
  42. package/dist/codeSign/win/signManager.d.ts.map +1 -0
  43. package/dist/codeSign/win/signManager.js +19 -0
  44. package/dist/codeSign/win/signManager.js.map +1 -0
  45. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +95 -0
  46. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -0
  47. package/dist/codeSign/win/signtoolBaseSignManager.js +507 -0
  48. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -0
  49. package/dist/codeSign/win/windowsCodeSign.d.ts +2 -1
  50. package/dist/codeSign/win/windowsCodeSign.d.ts.map +1 -1
  51. package/dist/codeSign/win/windowsCodeSign.js +22 -8
  52. package/dist/codeSign/win/windowsCodeSign.js.map +1 -1
  53. package/dist/codeSign/win/windowsSignAzureManager.d.ts +11 -4
  54. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  55. package/dist/codeSign/win/windowsSignAzureManager.js +142 -37
  56. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  57. package/dist/codeSign/win/windowsSignToolManager.d.ts +1 -58
  58. package/dist/codeSign/win/windowsSignToolManager.d.ts.map +1 -1
  59. package/dist/codeSign/win/windowsSignToolManager.js +3 -363
  60. package/dist/codeSign/win/windowsSignToolManager.js.map +1 -1
  61. package/dist/configuration.d.ts +233 -166
  62. package/dist/configuration.d.ts.map +1 -1
  63. package/dist/configuration.js +11 -1
  64. package/dist/configuration.js.map +1 -1
  65. package/dist/core.d.ts +14 -0
  66. package/dist/core.d.ts.map +1 -1
  67. package/dist/core.js +11 -0
  68. package/dist/core.js.map +1 -1
  69. package/dist/electron/ElectronFramework.d.ts +3 -3
  70. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  71. package/dist/electron/ElectronFramework.js +60 -61
  72. package/dist/electron/ElectronFramework.js.map +1 -1
  73. package/dist/electron/electronArchSupport.d.ts +12 -0
  74. package/dist/electron/electronArchSupport.d.ts.map +1 -0
  75. package/dist/electron/electronArchSupport.js +58 -0
  76. package/dist/electron/electronArchSupport.js.map +1 -0
  77. package/dist/electron/electronVersion.d.ts.map +1 -1
  78. package/dist/electron/electronVersion.js +1 -11
  79. package/dist/electron/electronVersion.js.map +1 -1
  80. package/dist/electron/injectFFMPEG.js +2 -2
  81. package/dist/electron/injectFFMPEG.js.map +1 -1
  82. package/dist/electron/mac/electronMac.js +24 -35
  83. package/dist/electron/mac/electronMac.js.map +1 -1
  84. package/dist/electron/mac/electronMacUtils.d.ts +24 -0
  85. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -0
  86. package/dist/electron/mac/electronMacUtils.js +42 -0
  87. package/dist/electron/mac/electronMacUtils.js.map +1 -0
  88. package/dist/electron/win/electronWin.js +2 -2
  89. package/dist/electron/win/electronWin.js.map +1 -1
  90. package/dist/fileMatcher.d.ts +55 -3
  91. package/dist/fileMatcher.d.ts.map +1 -1
  92. package/dist/fileMatcher.js +274 -28
  93. package/dist/fileMatcher.js.map +1 -1
  94. package/dist/index.d.ts +13 -7
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +17 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/indexInternal.d.ts +20 -8
  99. package/dist/indexInternal.d.ts.map +1 -1
  100. package/dist/indexInternal.js +19 -7
  101. package/dist/indexInternal.js.map +1 -1
  102. package/dist/linuxPackager.d.ts.map +1 -1
  103. package/dist/linuxPackager.js +19 -1
  104. package/dist/linuxPackager.js.map +1 -1
  105. package/dist/macPackager.d.ts +31 -14
  106. package/dist/macPackager.d.ts.map +1 -1
  107. package/dist/macPackager.js +236 -147
  108. package/dist/macPackager.js.map +1 -1
  109. package/dist/node-module-collector/index.d.ts.map +1 -1
  110. package/dist/node-module-collector/index.js +47 -16
  111. package/dist/node-module-collector/index.js.map +1 -1
  112. package/dist/node-module-collector/moduleManager.d.ts +11 -2
  113. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  114. package/dist/node-module-collector/moduleManager.js +34 -14
  115. package/dist/node-module-collector/moduleManager.js.map +1 -1
  116. package/dist/node-module-collector/nodeModulesCollector.d.ts +47 -26
  117. package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
  118. package/dist/node-module-collector/nodeModulesCollector.js +157 -142
  119. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  120. package/dist/node-module-collector/packageManager.js +1 -1
  121. package/dist/node-module-collector/packageManager.js.map +1 -1
  122. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts +90 -1
  123. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts.map +1 -1
  124. package/dist/node-module-collector/pnpmNodeModulesCollector.js +325 -25
  125. package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  126. package/dist/node-module-collector/types.d.ts +4 -0
  127. package/dist/node-module-collector/types.d.ts.map +1 -1
  128. package/dist/node-module-collector/types.js.map +1 -1
  129. package/dist/options/FuseOptionsV1.d.ts +137 -0
  130. package/dist/options/FuseOptionsV1.d.ts.map +1 -0
  131. package/dist/options/FuseOptionsV1.js +2 -0
  132. package/dist/options/FuseOptionsV1.js.map +1 -0
  133. package/dist/options/MsixOptions.d.ts +126 -0
  134. package/dist/options/MsixOptions.d.ts.map +1 -0
  135. package/dist/options/MsixOptions.js +2 -0
  136. package/dist/options/MsixOptions.js.map +1 -0
  137. package/dist/options/PlatformSpecificBuildOptions.d.ts +147 -12
  138. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  139. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  140. package/dist/options/SnapOptions.d.ts +59 -32
  141. package/dist/options/SnapOptions.d.ts.map +1 -1
  142. package/dist/options/SnapOptions.js.map +1 -1
  143. package/dist/options/SquirrelWindowsOptions.d.ts +0 -5
  144. package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
  145. package/dist/options/SquirrelWindowsOptions.js.map +1 -1
  146. package/dist/options/linuxOptions.d.ts +61 -30
  147. package/dist/options/linuxOptions.d.ts.map +1 -1
  148. package/dist/options/linuxOptions.js.map +1 -1
  149. package/dist/options/macOptions.d.ts +113 -131
  150. package/dist/options/macOptions.d.ts.map +1 -1
  151. package/dist/options/macOptions.js.map +1 -1
  152. package/dist/options/pkgOptions.d.ts +1 -1
  153. package/dist/options/pkgOptions.js.map +1 -1
  154. package/dist/options/winOptions.d.ts +282 -70
  155. package/dist/options/winOptions.d.ts.map +1 -1
  156. package/dist/options/winOptions.js +12 -1
  157. package/dist/options/winOptions.js.map +1 -1
  158. package/dist/packager.d.ts +6 -1
  159. package/dist/packager.d.ts.map +1 -1
  160. package/dist/packager.js +123 -40
  161. package/dist/packager.js.map +1 -1
  162. package/dist/packagerApi.d.ts +10 -1
  163. package/dist/packagerApi.d.ts.map +1 -1
  164. package/dist/packagerApi.js.map +1 -1
  165. package/dist/platformPackager.d.ts +55 -4
  166. package/dist/platformPackager.d.ts.map +1 -1
  167. package/dist/platformPackager.js +160 -22
  168. package/dist/platformPackager.js.map +1 -1
  169. package/dist/presets/rectCra.js +3 -1
  170. package/dist/presets/rectCra.js.map +1 -1
  171. package/dist/publish/PublishManager.d.ts +40 -2
  172. package/dist/publish/PublishManager.d.ts.map +1 -1
  173. package/dist/publish/PublishManager.js +365 -23
  174. package/dist/publish/PublishManager.js.map +1 -1
  175. package/dist/publish/updateInfoBuilder.d.ts +1 -1
  176. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  177. package/dist/publish/updateInfoBuilder.js +108 -32
  178. package/dist/publish/updateInfoBuilder.js.map +1 -1
  179. package/dist/targets/ArchiveTarget.d.ts +1 -0
  180. package/dist/targets/ArchiveTarget.d.ts.map +1 -1
  181. package/dist/targets/ArchiveTarget.js +13 -4
  182. package/dist/targets/ArchiveTarget.js.map +1 -1
  183. package/dist/targets/archive.d.ts +39 -2
  184. package/dist/targets/archive.d.ts.map +1 -1
  185. package/dist/targets/archive.js +114 -30
  186. package/dist/targets/archive.js.map +1 -1
  187. package/dist/targets/blockmap/blockmap.d.ts +44 -3
  188. package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
  189. package/dist/targets/blockmap/blockmap.js +142 -15
  190. package/dist/targets/blockmap/blockmap.js.map +1 -1
  191. package/dist/targets/blockmap/verbatimRange.d.ts +44 -0
  192. package/dist/targets/blockmap/verbatimRange.d.ts.map +1 -0
  193. package/dist/targets/blockmap/verbatimRange.js +117 -0
  194. package/dist/targets/blockmap/verbatimRange.js.map +1 -0
  195. package/dist/targets/differentialUpdateInfoBuilder.d.ts +28 -2
  196. package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
  197. package/dist/targets/differentialUpdateInfoBuilder.js +75 -6
  198. package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
  199. package/dist/targets/linux/FlatpakTarget.d.ts +17 -0
  200. package/dist/targets/linux/FlatpakTarget.d.ts.map +1 -1
  201. package/dist/targets/linux/FlatpakTarget.js +245 -45
  202. package/dist/targets/linux/FlatpakTarget.js.map +1 -1
  203. package/dist/targets/linux/FpmTarget.d.ts +14 -0
  204. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  205. package/dist/targets/linux/FpmTarget.js +92 -12
  206. package/dist/targets/linux/FpmTarget.js.map +1 -1
  207. package/dist/targets/linux/LinuxTargetHelper.d.ts +13 -0
  208. package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
  209. package/dist/targets/linux/LinuxTargetHelper.js +81 -61
  210. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  211. package/dist/targets/linux/appimage/AppImageTarget.d.ts +2 -0
  212. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  213. package/dist/targets/linux/appimage/AppImageTarget.js +20 -15
  214. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  215. package/dist/targets/linux/appimage/appImageUtil.d.ts +8 -2
  216. package/dist/targets/linux/appimage/appImageUtil.d.ts.map +1 -1
  217. package/dist/targets/linux/appimage/appImageUtil.js +16 -9
  218. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  219. package/dist/targets/linux/appimage/appLauncher.d.ts +6 -0
  220. package/dist/targets/linux/appimage/appLauncher.d.ts.map +1 -1
  221. package/dist/targets/linux/appimage/appLauncher.js +18 -20
  222. package/dist/targets/linux/appimage/appLauncher.js.map +1 -1
  223. package/dist/targets/linux/flatpakBundle.d.ts +43 -0
  224. package/dist/targets/linux/flatpakBundle.d.ts.map +1 -0
  225. package/dist/targets/linux/flatpakBundle.js +210 -0
  226. package/dist/targets/linux/flatpakBundle.js.map +1 -0
  227. package/dist/targets/linux/launcherScript.d.ts +32 -0
  228. package/dist/targets/linux/launcherScript.d.ts.map +1 -0
  229. package/dist/targets/linux/launcherScript.js +24 -0
  230. package/dist/targets/linux/launcherScript.js.map +1 -0
  231. package/dist/targets/linux/snap/SnapTarget.d.ts +1 -1
  232. package/dist/targets/linux/snap/SnapTarget.d.ts.map +1 -1
  233. package/dist/targets/linux/snap/SnapTarget.js +23 -1
  234. package/dist/targets/linux/snap/SnapTarget.js.map +1 -1
  235. package/dist/targets/linux/snap/core24.d.ts +13 -2
  236. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  237. package/dist/targets/linux/snap/core24.js +107 -95
  238. package/dist/targets/linux/snap/core24.js.map +1 -1
  239. package/dist/targets/linux/snap/coreCustom.d.ts +1 -1
  240. package/dist/targets/linux/snap/coreCustom.d.ts.map +1 -1
  241. package/dist/targets/linux/snap/coreCustom.js +2 -2
  242. package/dist/targets/linux/snap/coreCustom.js.map +1 -1
  243. package/dist/targets/linux/snap/coreLegacy.d.ts +10 -3
  244. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  245. package/dist/targets/linux/snap/coreLegacy.js +37 -18
  246. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  247. package/dist/targets/linux/snap/snapCommand.d.ts +13 -0
  248. package/dist/targets/linux/snap/snapCommand.d.ts.map +1 -0
  249. package/dist/targets/linux/snap/snapCommand.js +21 -0
  250. package/dist/targets/linux/snap/snapCommand.js.map +1 -0
  251. package/dist/targets/linux/snap/snapPlugs.d.ts +76 -0
  252. package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -0
  253. package/dist/targets/linux/snap/snapPlugs.js +242 -0
  254. package/dist/targets/linux/snap/snapPlugs.js.map +1 -0
  255. package/dist/targets/linux/snap/snapcraft.d.ts +190 -0
  256. package/dist/targets/linux/snap/snapcraft.d.ts.map +1 -0
  257. package/dist/targets/linux/snap/snapcraft.js +11 -0
  258. package/dist/targets/linux/snap/snapcraft.js.map +1 -0
  259. package/dist/targets/linux/snap/snapcraftBuilder.d.ts +7 -1
  260. package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
  261. package/dist/targets/linux/snap/snapcraftBuilder.js +57 -20
  262. package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
  263. package/dist/targets/mac/MacTargetHelper.d.ts +146 -14
  264. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  265. package/dist/targets/mac/MacTargetHelper.js +485 -91
  266. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  267. package/dist/targets/mac/pkg.d.ts +16 -0
  268. package/dist/targets/mac/pkg.d.ts.map +1 -1
  269. package/dist/targets/mac/pkg.js +31 -5
  270. package/dist/targets/mac/pkg.js.map +1 -1
  271. package/dist/targets/targetFactory.d.ts +7 -0
  272. package/dist/targets/targetFactory.d.ts.map +1 -1
  273. package/dist/targets/targetFactory.js +28 -0
  274. package/dist/targets/targetFactory.js.map +1 -1
  275. package/dist/targets/win/AppxTarget.d.ts +1 -2
  276. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  277. package/dist/targets/win/AppxTarget.js +37 -314
  278. package/dist/targets/win/AppxTarget.js.map +1 -1
  279. package/dist/targets/win/MsiTarget.d.ts.map +1 -1
  280. package/dist/targets/win/MsiTarget.js +13 -13
  281. package/dist/targets/win/MsiTarget.js.map +1 -1
  282. package/dist/targets/win/MsixTarget.d.ts +22 -0
  283. package/dist/targets/win/MsixTarget.d.ts.map +1 -0
  284. package/dist/targets/win/MsixTarget.js +214 -0
  285. package/dist/targets/win/MsixTarget.js.map +1 -0
  286. package/dist/targets/win/nsis/Defines.d.ts +4 -0
  287. package/dist/targets/win/nsis/Defines.d.ts.map +1 -1
  288. package/dist/targets/win/nsis/Defines.js.map +1 -1
  289. package/dist/targets/win/nsis/NsisTarget.d.ts +64 -3
  290. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  291. package/dist/targets/win/nsis/NsisTarget.js +277 -113
  292. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  293. package/dist/targets/win/nsis/WebInstallerTarget.d.ts.map +1 -1
  294. package/dist/targets/win/nsis/WebInstallerTarget.js +23 -12
  295. package/dist/targets/win/nsis/WebInstallerTarget.js.map +1 -1
  296. package/dist/targets/win/nsis/nsisOptions.d.ts +58 -48
  297. package/dist/targets/win/nsis/nsisOptions.d.ts.map +1 -1
  298. package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
  299. package/dist/targets/win/nsis/nsisScriptGenerator.d.ts.map +1 -1
  300. package/dist/targets/win/nsis/nsisScriptGenerator.js +4 -3
  301. package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
  302. package/dist/targets/win/nsis/nsisUtil.d.ts +17 -2
  303. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  304. package/dist/targets/win/nsis/nsisUtil.js +148 -41
  305. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  306. package/dist/targets/win/nsis/progId.d.ts +21 -0
  307. package/dist/targets/win/nsis/progId.d.ts.map +1 -0
  308. package/dist/targets/win/nsis/progId.js +60 -0
  309. package/dist/targets/win/nsis/progId.js.map +1 -0
  310. package/dist/targets/win/winAppUtil.d.ts +115 -0
  311. package/dist/targets/win/winAppUtil.d.ts.map +1 -0
  312. package/dist/targets/win/winAppUtil.js +409 -0
  313. package/dist/targets/win/winAppUtil.js.map +1 -0
  314. package/dist/toolsets/7zip.d.ts +32 -0
  315. package/dist/toolsets/7zip.d.ts.map +1 -1
  316. package/dist/toolsets/7zip.js +39 -11
  317. package/dist/toolsets/7zip.js.map +1 -1
  318. package/dist/toolsets/appimage.d.ts +3 -3
  319. package/dist/toolsets/appimage.d.ts.map +1 -1
  320. package/dist/toolsets/appimage.js +24 -21
  321. package/dist/toolsets/appimage.js.map +1 -1
  322. package/dist/toolsets/custom.d.ts +2 -3
  323. package/dist/toolsets/custom.d.ts.map +1 -1
  324. package/dist/toolsets/custom.js +67 -149
  325. package/dist/toolsets/custom.js.map +1 -1
  326. package/dist/toolsets/fpm.d.ts.map +1 -1
  327. package/dist/toolsets/fpm.js +11 -5
  328. package/dist/toolsets/fpm.js.map +1 -1
  329. package/dist/toolsets/icons.d.ts.map +1 -1
  330. package/dist/toolsets/icons.js +17 -3
  331. package/dist/toolsets/icons.js.map +1 -1
  332. package/dist/toolsets/linuxToolsMac.d.ts.map +1 -1
  333. package/dist/toolsets/linuxToolsMac.js +17 -4
  334. package/dist/toolsets/linuxToolsMac.js.map +1 -1
  335. package/dist/toolsets/nsis.d.ts +5 -0
  336. package/dist/toolsets/nsis.d.ts.map +1 -1
  337. package/dist/toolsets/nsis.js +20 -4
  338. package/dist/toolsets/nsis.js.map +1 -1
  339. package/dist/toolsets/version.d.ts +12 -0
  340. package/dist/toolsets/version.d.ts.map +1 -0
  341. package/dist/toolsets/version.js +13 -0
  342. package/dist/toolsets/version.js.map +1 -0
  343. package/dist/toolsets/winCodeSign.d.ts +56 -3
  344. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  345. package/dist/toolsets/winCodeSign.js +125 -42
  346. package/dist/toolsets/winCodeSign.js.map +1 -1
  347. package/dist/toolsets/wine.d.ts +2 -1
  348. package/dist/toolsets/wine.d.ts.map +1 -1
  349. package/dist/toolsets/wine.js +31 -15
  350. package/dist/toolsets/wine.js.map +1 -1
  351. package/dist/util/AppFileWalker.js +9 -1
  352. package/dist/util/AppFileWalker.js.map +1 -1
  353. package/dist/util/NodeModuleCopyHelper.js +14 -6
  354. package/dist/util/NodeModuleCopyHelper.js.map +1 -1
  355. package/dist/util/appFileCopier.d.ts +67 -2
  356. package/dist/util/appFileCopier.d.ts.map +1 -1
  357. package/dist/util/appFileCopier.js +244 -32
  358. package/dist/util/appFileCopier.js.map +1 -1
  359. package/dist/util/archCompatibility.d.ts +42 -0
  360. package/dist/util/archCompatibility.d.ts.map +1 -0
  361. package/dist/util/archCompatibility.js +202 -0
  362. package/dist/util/archCompatibility.js.map +1 -0
  363. package/dist/util/checksum.d.ts +36 -0
  364. package/dist/util/checksum.d.ts.map +1 -0
  365. package/dist/util/checksum.js +48 -0
  366. package/dist/util/checksum.js.map +1 -0
  367. package/dist/util/config/config.d.ts +2 -1
  368. package/dist/util/config/config.d.ts.map +1 -1
  369. package/dist/util/config/config.js +42 -20
  370. package/dist/util/config/config.js.map +1 -1
  371. package/dist/util/config/fileOptions.d.ts +30 -0
  372. package/dist/util/config/fileOptions.d.ts.map +1 -0
  373. package/dist/util/config/fileOptions.js +120 -0
  374. package/dist/util/config/fileOptions.js.map +1 -0
  375. package/dist/util/config/legacyConfigGuard.d.ts +7 -0
  376. package/dist/util/config/legacyConfigGuard.d.ts.map +1 -0
  377. package/dist/util/config/legacyConfigGuard.js +214 -0
  378. package/dist/util/config/legacyConfigGuard.js.map +1 -0
  379. package/dist/util/config/legacyOptions.d.ts +86 -0
  380. package/dist/util/config/legacyOptions.d.ts.map +1 -0
  381. package/dist/util/config/legacyOptions.js +413 -0
  382. package/dist/util/config/legacyOptions.js.map +1 -0
  383. package/dist/util/config/load.d.ts +2 -2
  384. package/dist/util/config/load.d.ts.map +1 -1
  385. package/dist/util/config/load.js +3 -12
  386. package/dist/util/config/load.js.map +1 -1
  387. package/dist/util/config/schemaValidator.d.ts.map +1 -1
  388. package/dist/util/config/schemaValidator.js +26 -3
  389. package/dist/util/config/schemaValidator.js.map +1 -1
  390. package/dist/util/electronGet.d.ts +43 -32
  391. package/dist/util/electronGet.d.ts.map +1 -1
  392. package/dist/util/electronGet.js +390 -137
  393. package/dist/util/electronGet.js.map +1 -1
  394. package/dist/util/flags.d.ts +5 -5
  395. package/dist/util/flags.d.ts.map +1 -1
  396. package/dist/util/flags.js +124 -16
  397. package/dist/util/flags.js.map +1 -1
  398. package/dist/util/hash.d.ts +1 -1
  399. package/dist/util/hash.d.ts.map +1 -1
  400. package/dist/util/hash.js +1 -15
  401. package/dist/util/hash.js.map +1 -1
  402. package/dist/util/installOrRebuild.d.ts +44 -0
  403. package/dist/util/installOrRebuild.d.ts.map +1 -0
  404. package/dist/util/installOrRebuild.js +276 -0
  405. package/dist/util/installOrRebuild.js.map +1 -0
  406. package/dist/util/langs.d.ts.map +1 -1
  407. package/dist/util/langs.js +1 -0
  408. package/dist/util/langs.js.map +1 -1
  409. package/dist/util/license.d.ts.map +1 -1
  410. package/dist/util/license.js +4 -1
  411. package/dist/util/license.js.map +1 -1
  412. package/dist/util/mac/macosIconComposer.d.ts +2 -1
  413. package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
  414. package/dist/util/mac/macosIconComposer.js +40 -58
  415. package/dist/util/mac/macosIconComposer.js.map +1 -1
  416. package/dist/util/mac/macosVersion.d.ts +0 -1
  417. package/dist/util/mac/macosVersion.d.ts.map +1 -1
  418. package/dist/util/mac/macosVersion.js +0 -3
  419. package/dist/util/mac/macosVersion.js.map +1 -1
  420. package/dist/util/mac/plist.d.ts +1 -1
  421. package/dist/util/mac/plist.d.ts.map +1 -1
  422. package/dist/util/mac/plist.js +5 -0
  423. package/dist/util/mac/plist.js.map +1 -1
  424. package/dist/util/nativeBinaryVerifier.d.ts +40 -0
  425. package/dist/util/nativeBinaryVerifier.d.ts.map +1 -0
  426. package/dist/util/nativeBinaryVerifier.js +381 -0
  427. package/dist/util/nativeBinaryVerifier.js.map +1 -0
  428. package/dist/util/packageMetadata.js +57 -31
  429. package/dist/util/packageMetadata.js.map +1 -1
  430. package/dist/util/removedEnvVars.d.ts +25 -0
  431. package/dist/util/removedEnvVars.d.ts.map +1 -0
  432. package/dist/util/removedEnvVars.js +54 -0
  433. package/dist/util/removedEnvVars.js.map +1 -0
  434. package/dist/util/repositoryInfo.js +6 -3
  435. package/dist/util/repositoryInfo.js.map +1 -1
  436. package/dist/util/resolve.js +1 -1
  437. package/dist/util/resolve.js.map +1 -1
  438. package/dist/util/streamSpawnToFile.d.ts +47 -0
  439. package/dist/util/streamSpawnToFile.d.ts.map +1 -0
  440. package/dist/util/streamSpawnToFile.js +110 -0
  441. package/dist/util/streamSpawnToFile.js.map +1 -0
  442. package/dist/util/toolsetLock.d.ts +2 -0
  443. package/dist/util/toolsetLock.d.ts.map +1 -1
  444. package/dist/util/toolsetLock.js +31 -5
  445. package/dist/util/toolsetLock.js.map +1 -1
  446. package/dist/util/trustedSourceRoots.d.ts +59 -0
  447. package/dist/util/trustedSourceRoots.d.ts.map +1 -0
  448. package/dist/util/trustedSourceRoots.js +127 -0
  449. package/dist/util/trustedSourceRoots.js.map +1 -0
  450. package/dist/version.d.ts +1 -1
  451. package/dist/version.d.ts.map +1 -1
  452. package/dist/version.js +1 -1
  453. package/dist/version.js.map +1 -1
  454. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  455. package/dist/vm/ParallelsVm.js +29 -3
  456. package/dist/vm/ParallelsVm.js.map +1 -1
  457. package/dist/vm/vm.d.ts +2 -0
  458. package/dist/vm/vm.d.ts.map +1 -1
  459. package/dist/vm/vm.js +29 -6
  460. package/dist/vm/vm.js.map +1 -1
  461. package/dist/winPackager.d.ts +6 -5
  462. package/dist/winPackager.d.ts.map +1 -1
  463. package/dist/winPackager.js +45 -39
  464. package/dist/winPackager.js.map +1 -1
  465. package/package.json +20 -20
  466. package/scheme.json +2112 -1495
  467. package/templates/appx/appxmanifest.xml +2 -3
  468. package/templates/entitlements.mac.adhoc.plist +15 -0
  469. package/templates/entitlements.mac.plist +9 -6
  470. package/templates/msix/appxmanifest.xml +45 -0
  471. package/templates/nsis/assistedMessages.yml +17 -0
  472. package/templates/nsis/common.nsh +2 -2
  473. package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +96 -13
  474. package/templates/nsis/include/extractAppPackage.nsh +5 -2
  475. package/templates/nsis/include/installUtil.nsh +2 -2
  476. package/templates/nsis/include/installer.nsh +94 -53
  477. package/templates/nsis/include/webPackage.nsh +52 -27
  478. package/templates/nsis/installSection.nsh +29 -0
  479. package/templates/nsis/installer.nsi +1 -1
  480. package/templates/nsis/messages.yml +5 -0
  481. package/templates/nsis/multiUserUi.nsh +1 -1
  482. package/dist/codeSign/signManager.d.ts +0 -14
  483. package/dist/codeSign/signManager.d.ts.map +0 -1
  484. package/dist/codeSign/signManager.js +0 -2
  485. package/dist/codeSign/signManager.js.map +0 -1
  486. package/dist/util/yarn.d.ts +0 -23
  487. package/dist/util/yarn.d.ts.map +0 -1
  488. package/dist/util/yarn.js +0 -153
  489. package/dist/util/yarn.js.map +0 -1
@@ -1,20 +1,21 @@
1
1
  import * as get from "@electron/get";
2
2
  import { ElectronDownloadCacheMode, } from "@electron/get";
3
- import { buildGotProxyAgent, exec, exists, log, PADDING, parseValidEnvVarUrl, sanitizeDirPath, to7zaOutputSwitch } from "builder-util";
4
- import { getPath7za } from "../toolsets/7zip.js";
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 { HttpError, retry, sleep } from "builder-util-runtime";
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
- export function getCacheDirectory(options) {
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
- const entries = createReadStream(file).pipe(unzipper.Parse({ forceStream: true }));
74
- for await (const entry of entries) {
75
- const destPath = path.resolve(dir, entry.path);
76
- if (!destPath.startsWith(dir + path.sep) && destPath !== dir) {
77
- throw new Error(`Path traversal blocked: ${entry.path}`);
78
- }
79
- const mode = entryModes.get(entry.path) ?? 0;
80
- if (mode > 0 && isSymlink(mode)) {
81
- const target = (await entry.buffer()).toString();
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 resolvedTarget = path.resolve(path.dirname(destPath), target);
86
- if (!resolvedTarget.startsWith(dir + path.sep) && resolvedTarget !== dir) {
87
- throw new Error(`Symlink target escapes extraction dir: ${target}`);
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
- await fs.mkdir(path.dirname(destPath), { recursive: true });
90
- await fs.symlink(target, destPath);
91
- }
92
- else if (entry.type === "Directory") {
93
- await fs.mkdir(destPath, { recursive: true });
94
- entry.autodrain();
95
- }
96
- else {
97
- await fs.mkdir(path.dirname(destPath), { recursive: true });
98
- await pipeline(entry, createWriteStream(destPath));
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(file, dir) {
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, so use 7za to turn the .tar.xz into a .tar, then extract that tar.
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 xzOutDir = `${tmpDir}.xz`;
134
- await fs.rm(xzOutDir, { recursive: true, force: true });
135
- await fs.mkdir(xzOutDir, { recursive: true });
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(xzOutDir)), "-y"]);
138
- const innerTar = (await fs.readdir(xzOutDir)).find(f => f.endsWith(".tar"));
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(`xz decompression of ${path.basename(file)} produced no .tar archive`);
181
+ throw new Error(`decompression of ${path.basename(file)} produced no .tar archive`);
141
182
  }
142
- await tar.extract({ file: path.join(xzOutDir, innerTar), cwd: tmpDir, strip: 1 });
183
+ await tar.extract({ file: path.join(decompressOutDir, innerTar), cwd: tmpDir, strip: 1 });
143
184
  }
144
185
  finally {
145
- await fs.rm(xzOutDir, { recursive: true, force: true });
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 fs.rename(tmpDir, dir);
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 artifactLockKey = crypto
186
- .createHash("sha256")
187
- .update(JSON.stringify({ v: config.version, p: config.platform, a: config.arch, n: config.artifactName }))
188
- .digest("hex")
189
- .slice(0, 20);
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 configWithProgress = { ...config, downloadOptions };
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 retry(() => get.downloadArtifact(configWithProgress), {
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(configWithProgress);
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({ ...configWithProgress, cacheMode: ElectronDownloadCacheMode.WriteOnly });
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 checksum when one is known. Returns the cached path on hit,
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, expectedSha256) {
408
+ async function resolveFromArchiveCache(archiveCachePath, label, expected) {
274
409
  if (!(await exists(archiveCachePath))) {
275
410
  return null;
276
411
  }
277
- if (expectedSha256) {
278
- const hash = await new Promise((resolve, reject) => {
279
- const h = crypto.createHash("sha256");
280
- const s = createReadStream(archiveCachePath);
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
- await fs.mkdir(extractDir, { recursive: true });
314
- // Pre-lock fast path: only short-circuit for a definitively complete and valid cache.
315
- // Do NOT clean up here — concurrent processes could race to delete under each other.
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 fs.mkdir(extractDir, { recursive: true });
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, config.checksums?.[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(getCacheDirectory({ allowEnvVarOverride: true }), "downloads"),
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
- return `${overrideUrl}/${filenameWithExt}`;
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
- const folderName = `${filenameWithExt.replace(/\.(tar\.gz|tgz|tar\.xz|txz|zip|7z)$/, "")}-${suffix}`;
456
- const extractDir = path.join(getCacheDirectory({ allowEnvVarOverride: true }), releaseName, folderName);
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(getCacheDirectory({ allowEnvVarOverride: true }), releaseName, filenameWithExt);
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(getCacheDirectory({ allowEnvVarOverride: true }), "downloads"),
638
+ cacheRoot: path.resolve(await cacheDirectoryOverrideAllowed.value, "downloads"),
470
639
  cacheMode: resolveCacheMode(),
471
- ...(checksums != null ? { checksums } : { unsafelyDisableChecksums: true }),
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
- // Keys present in ElectronGetOptions but absent from ElectronDownloadOptions.
478
- // Used to discriminate between the two config shapes at runtime.
479
- const ELECTRON_GET_EXCLUSIVE_KEYS = ["mirrorOptions", "force", "unsafelyDisableChecksums"];
480
- function isElectronGetOptions(dl) {
481
- return ELECTRON_GET_EXCLUSIVE_KEYS.some(k => Object.hasOwnProperty.call(dl, k));
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
- * Downloads and extracts an electron platform artifact (e.g. ffmpeg) using @electron/get.
485
- * Deduplicates concurrent calls for the same artifact within the same process.
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 buildElectronArtifactConfig(options) {
488
- const { electronDownload, arch, version, platformName: platform, artifactName, cacheDir: cacheRoot } = options;
489
- let artifactConfig = { cacheRoot, platform, arch, version, artifactName };
490
- if (electronDownload != null) {
491
- if (isElectronGetOptions(electronDownload)) {
492
- const { mirrorOptions, ...rest } = electronDownload;
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
- else {
496
- const { mirror, customDir, cache, customFilename, isVerifyChecksum, strictSSL, platform: overridePlatform, arch: overrideArch } = electronDownload;
497
- // strictSSL: false disables TLS certificate validation for all
498
- // electron/tool downloads. This option exists only for air-gapped or
499
- // self-signed-cert environments; ensure your build network is fully trusted.
500
- if (strictSSL === false) {
501
- log.warn({ option: "electronDownload.strictSSL" }, "strictSSL is false — TLS certificate validation is DISABLED for Electron downloads. Only use this option in a trusted, isolated build environment.");
502
- }
503
- artifactConfig = {
504
- ...artifactConfig,
505
- unsafelyDisableChecksums: isVerifyChecksum === false,
506
- cacheRoot: cache ?? cacheRoot,
507
- mirrorOptions: {
508
- mirror: mirror || undefined,
509
- customDir: customDir || undefined,
510
- customFilename: customFilename || undefined,
511
- },
512
- ...(strictSSL === false ? { downloadOptions: { https: { rejectUnauthorized: false } } } : {}),
513
- };
514
- if (overridePlatform != null) {
515
- artifactConfig.platform = overridePlatform;
516
- }
517
- if (overrideArch != null) {
518
- artifactConfig.arch = overrideArch;
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(getCacheDirectory({ allowEnvVarOverride: true }), `${artifactName}-v${version}`, folderName);
791
+ const extractDir = path.join(await cacheDirectoryOverrideAllowed.value, `${artifactName}-v${version}`, folderName);
539
792
  return downloadAndExtract(artifactConfig, extractDir, artifactName);
540
793
  }
541
794
  /**