app-builder-lib 27.0.0-alpha.2 → 27.0.0-alpha.4

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 (247) 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/asar/asarFileChecker.d.ts +4 -2
  5. package/dist/asar/asarFileChecker.d.ts.map +1 -1
  6. package/dist/asar/asarFileChecker.js +2 -3
  7. package/dist/asar/asarFileChecker.js.map +1 -1
  8. package/dist/codeSign/certInfo.d.ts +14 -0
  9. package/dist/codeSign/certInfo.d.ts.map +1 -1
  10. package/dist/codeSign/certInfo.js +49 -0
  11. package/dist/codeSign/certInfo.js.map +1 -1
  12. package/dist/codeSign/mac/macCodeSign.d.ts +3 -3
  13. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  14. package/dist/codeSign/mac/macCodeSign.js +40 -14
  15. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  16. package/dist/codeSign/win/hsmSignManager.d.ts +10 -0
  17. package/dist/codeSign/win/hsmSignManager.d.ts.map +1 -0
  18. package/dist/codeSign/win/hsmSignManager.js +50 -0
  19. package/dist/codeSign/win/hsmSignManager.js.map +1 -0
  20. package/dist/codeSign/win/pkcs11SignManager.d.ts +14 -0
  21. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -0
  22. package/dist/codeSign/win/pkcs11SignManager.js +82 -0
  23. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -0
  24. package/dist/codeSign/{signManager.d.ts → win/signManager.d.ts} +8 -6
  25. package/dist/codeSign/win/signManager.d.ts.map +1 -0
  26. package/dist/codeSign/win/signManager.js +19 -0
  27. package/dist/codeSign/win/signManager.js.map +1 -0
  28. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +71 -0
  29. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -0
  30. package/dist/codeSign/win/signtoolBaseSignManager.js +414 -0
  31. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -0
  32. package/dist/codeSign/win/windowsCodeSign.d.ts.map +1 -1
  33. package/dist/codeSign/win/windowsCodeSign.js +9 -4
  34. package/dist/codeSign/win/windowsCodeSign.js.map +1 -1
  35. package/dist/codeSign/win/windowsSignAzureManager.d.ts +9 -3
  36. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  37. package/dist/codeSign/win/windowsSignAzureManager.js +130 -36
  38. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  39. package/dist/codeSign/win/windowsSignToolManager.d.ts +1 -58
  40. package/dist/codeSign/win/windowsSignToolManager.d.ts.map +1 -1
  41. package/dist/codeSign/win/windowsSignToolManager.js +3 -363
  42. package/dist/codeSign/win/windowsSignToolManager.js.map +1 -1
  43. package/dist/configuration.d.ts +22 -123
  44. package/dist/configuration.d.ts.map +1 -1
  45. package/dist/configuration.js.map +1 -1
  46. package/dist/electron/ElectronFramework.d.ts +0 -2
  47. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  48. package/dist/electron/ElectronFramework.js +15 -27
  49. package/dist/electron/ElectronFramework.js.map +1 -1
  50. package/dist/electron/injectFFMPEG.js +2 -2
  51. package/dist/electron/injectFFMPEG.js.map +1 -1
  52. package/dist/electron/mac/electronMac.js +10 -8
  53. package/dist/electron/mac/electronMac.js.map +1 -1
  54. package/dist/electron/win/electronWin.js +1 -2
  55. package/dist/electron/win/electronWin.js.map +1 -1
  56. package/dist/index.d.ts +8 -4
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +3 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/indexInternal.d.ts +3 -3
  61. package/dist/indexInternal.d.ts.map +1 -1
  62. package/dist/indexInternal.js +2 -2
  63. package/dist/indexInternal.js.map +1 -1
  64. package/dist/macPackager.d.ts +19 -10
  65. package/dist/macPackager.d.ts.map +1 -1
  66. package/dist/macPackager.js +149 -121
  67. package/dist/macPackager.js.map +1 -1
  68. package/dist/node-module-collector/moduleManager.d.ts +9 -2
  69. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  70. package/dist/node-module-collector/moduleManager.js +4 -2
  71. package/dist/node-module-collector/moduleManager.js.map +1 -1
  72. package/dist/node-module-collector/nodeModulesCollector.d.ts +13 -23
  73. package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
  74. package/dist/node-module-collector/nodeModulesCollector.js +52 -122
  75. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  76. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts +48 -1
  77. package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts.map +1 -1
  78. package/dist/node-module-collector/pnpmNodeModulesCollector.js +216 -17
  79. package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
  80. package/dist/node-module-collector/types.d.ts +2 -0
  81. package/dist/node-module-collector/types.d.ts.map +1 -1
  82. package/dist/node-module-collector/types.js.map +1 -1
  83. package/dist/options/FuseOptionsV1.d.ts +137 -0
  84. package/dist/options/FuseOptionsV1.d.ts.map +1 -0
  85. package/dist/options/FuseOptionsV1.js +2 -0
  86. package/dist/options/FuseOptionsV1.js.map +1 -0
  87. package/dist/options/PlatformSpecificBuildOptions.d.ts +1 -1
  88. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  89. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  90. package/dist/options/linuxOptions.d.ts +0 -10
  91. package/dist/options/linuxOptions.d.ts.map +1 -1
  92. package/dist/options/linuxOptions.js.map +1 -1
  93. package/dist/options/macOptions.d.ts +93 -126
  94. package/dist/options/macOptions.d.ts.map +1 -1
  95. package/dist/options/macOptions.js.map +1 -1
  96. package/dist/options/winOptions.d.ts +137 -63
  97. package/dist/options/winOptions.d.ts.map +1 -1
  98. package/dist/options/winOptions.js +12 -1
  99. package/dist/options/winOptions.js.map +1 -1
  100. package/dist/packager.js +1 -1
  101. package/dist/packager.js.map +1 -1
  102. package/dist/platformPackager.d.ts +5 -2
  103. package/dist/platformPackager.d.ts.map +1 -1
  104. package/dist/platformPackager.js +16 -13
  105. package/dist/platformPackager.js.map +1 -1
  106. package/dist/targets/ArchiveTarget.js +2 -2
  107. package/dist/targets/ArchiveTarget.js.map +1 -1
  108. package/dist/targets/archive.d.ts +10 -2
  109. package/dist/targets/archive.d.ts.map +1 -1
  110. package/dist/targets/archive.js +25 -6
  111. package/dist/targets/archive.js.map +1 -1
  112. package/dist/targets/linux/FlatpakTarget.d.ts.map +1 -1
  113. package/dist/targets/linux/FlatpakTarget.js +4 -1
  114. package/dist/targets/linux/FlatpakTarget.js.map +1 -1
  115. package/dist/targets/linux/FpmTarget.d.ts +6 -0
  116. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  117. package/dist/targets/linux/FpmTarget.js +25 -3
  118. package/dist/targets/linux/FpmTarget.js.map +1 -1
  119. package/dist/targets/linux/LinuxTargetHelper.d.ts +14 -0
  120. package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
  121. package/dist/targets/linux/LinuxTargetHelper.js +38 -59
  122. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  123. package/dist/targets/linux/appimage/AppImageTarget.d.ts +1 -0
  124. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  125. package/dist/targets/linux/appimage/AppImageTarget.js +8 -9
  126. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  127. package/dist/targets/linux/appimage/appImageUtil.d.ts +4 -0
  128. package/dist/targets/linux/appimage/appImageUtil.d.ts.map +1 -1
  129. package/dist/targets/linux/appimage/appImageUtil.js +11 -4
  130. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  131. package/dist/targets/linux/appimage/appLauncher.d.ts.map +1 -1
  132. package/dist/targets/linux/appimage/appLauncher.js +5 -11
  133. package/dist/targets/linux/appimage/appLauncher.js.map +1 -1
  134. package/dist/targets/linux/launcherScript.d.ts +32 -0
  135. package/dist/targets/linux/launcherScript.d.ts.map +1 -0
  136. package/dist/targets/linux/launcherScript.js +24 -0
  137. package/dist/targets/linux/launcherScript.js.map +1 -0
  138. package/dist/targets/linux/snap/core24.d.ts +2 -0
  139. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  140. package/dist/targets/linux/snap/core24.js +48 -8
  141. package/dist/targets/linux/snap/core24.js.map +1 -1
  142. package/dist/targets/linux/snap/coreLegacy.d.ts +2 -2
  143. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  144. package/dist/targets/linux/snap/coreLegacy.js +9 -10
  145. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  146. package/dist/targets/linux/snap/snapCommand.d.ts +13 -0
  147. package/dist/targets/linux/snap/snapCommand.d.ts.map +1 -0
  148. package/dist/targets/linux/snap/snapCommand.js +21 -0
  149. package/dist/targets/linux/snap/snapCommand.js.map +1 -0
  150. package/dist/targets/mac/MacTargetHelper.d.ts +12 -12
  151. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  152. package/dist/targets/mac/MacTargetHelper.js +72 -67
  153. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  154. package/dist/targets/mac/pkg.d.ts.map +1 -1
  155. package/dist/targets/mac/pkg.js +4 -4
  156. package/dist/targets/mac/pkg.js.map +1 -1
  157. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  158. package/dist/targets/win/AppxTarget.js +9 -9
  159. package/dist/targets/win/AppxTarget.js.map +1 -1
  160. package/dist/targets/win/MsiTarget.d.ts.map +1 -1
  161. package/dist/targets/win/MsiTarget.js +8 -11
  162. package/dist/targets/win/MsiTarget.js.map +1 -1
  163. package/dist/targets/win/nsis/NsisTarget.js +5 -5
  164. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  165. package/dist/targets/win/nsis/nsisScriptGenerator.js +2 -2
  166. package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
  167. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  168. package/dist/targets/win/nsis/nsisUtil.js +2 -2
  169. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  170. package/dist/toolsets/custom.d.ts +1 -0
  171. package/dist/toolsets/custom.d.ts.map +1 -1
  172. package/dist/toolsets/custom.js +19 -8
  173. package/dist/toolsets/custom.js.map +1 -1
  174. package/dist/toolsets/icons.d.ts.map +1 -1
  175. package/dist/toolsets/icons.js +11 -3
  176. package/dist/toolsets/icons.js.map +1 -1
  177. package/dist/toolsets/winCodeSign.d.ts +36 -0
  178. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  179. package/dist/toolsets/winCodeSign.js +84 -30
  180. package/dist/toolsets/winCodeSign.js.map +1 -1
  181. package/dist/toolsets/wine.d.ts.map +1 -1
  182. package/dist/toolsets/wine.js +20 -12
  183. package/dist/toolsets/wine.js.map +1 -1
  184. package/dist/util/appFileCopier.d.ts.map +1 -1
  185. package/dist/util/appFileCopier.js +9 -4
  186. package/dist/util/appFileCopier.js.map +1 -1
  187. package/dist/util/archCompatibility.d.ts +42 -0
  188. package/dist/util/archCompatibility.d.ts.map +1 -0
  189. package/dist/util/archCompatibility.js +202 -0
  190. package/dist/util/archCompatibility.js.map +1 -0
  191. package/dist/util/config/schemaValidator.d.ts.map +1 -1
  192. package/dist/util/config/schemaValidator.js +1 -1
  193. package/dist/util/config/schemaValidator.js.map +1 -1
  194. package/dist/util/electronGet.d.ts +8 -25
  195. package/dist/util/electronGet.d.ts.map +1 -1
  196. package/dist/util/electronGet.js +107 -87
  197. package/dist/util/electronGet.js.map +1 -1
  198. package/dist/util/flags.d.ts +0 -3
  199. package/dist/util/flags.d.ts.map +1 -1
  200. package/dist/util/flags.js +0 -9
  201. package/dist/util/flags.js.map +1 -1
  202. package/dist/util/installOrRebuild.d.ts +38 -0
  203. package/dist/util/installOrRebuild.d.ts.map +1 -0
  204. package/dist/util/{yarn.js → installOrRebuild.js} +65 -14
  205. package/dist/util/installOrRebuild.js.map +1 -0
  206. package/dist/util/langs.d.ts.map +1 -1
  207. package/dist/util/langs.js +1 -0
  208. package/dist/util/langs.js.map +1 -1
  209. package/dist/util/license.d.ts.map +1 -1
  210. package/dist/util/license.js +4 -1
  211. package/dist/util/license.js.map +1 -1
  212. package/dist/util/mac/macosIconComposer.d.ts +2 -1
  213. package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
  214. package/dist/util/mac/macosIconComposer.js +40 -58
  215. package/dist/util/mac/macosIconComposer.js.map +1 -1
  216. package/dist/util/streamSpawnToFile.d.ts +47 -0
  217. package/dist/util/streamSpawnToFile.d.ts.map +1 -0
  218. package/dist/util/streamSpawnToFile.js +110 -0
  219. package/dist/util/streamSpawnToFile.js.map +1 -0
  220. package/dist/util/toolsetLock.d.ts +2 -0
  221. package/dist/util/toolsetLock.d.ts.map +1 -1
  222. package/dist/util/toolsetLock.js +31 -5
  223. package/dist/util/toolsetLock.js.map +1 -1
  224. package/dist/version.d.ts +1 -1
  225. package/dist/version.js +1 -1
  226. package/dist/version.js.map +1 -1
  227. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  228. package/dist/vm/ParallelsVm.js +13 -2
  229. package/dist/vm/ParallelsVm.js.map +1 -1
  230. package/dist/vm/vm.d.ts.map +1 -1
  231. package/dist/vm/vm.js +4 -1
  232. package/dist/vm/vm.js.map +1 -1
  233. package/dist/winPackager.d.ts +1 -2
  234. package/dist/winPackager.d.ts.map +1 -1
  235. package/dist/winPackager.js +17 -22
  236. package/dist/winPackager.js.map +1 -1
  237. package/package.json +15 -14
  238. package/scheme.json +486 -439
  239. package/templates/appx/appxmanifest.xml +1 -2
  240. package/templates/nsis/assistedMessages.yml +17 -0
  241. package/templates/nsis/messages.yml +5 -0
  242. package/dist/codeSign/signManager.d.ts.map +0 -1
  243. package/dist/codeSign/signManager.js +0 -2
  244. package/dist/codeSign/signManager.js.map +0 -1
  245. package/dist/util/yarn.d.ts +0 -23
  246. package/dist/util/yarn.d.ts.map +0 -1
  247. package/dist/util/yarn.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../../src/util/config/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,WAAW,EAAoB,MAAM,KAAK,CAAA;AAExD,MAAM,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,MAAM,CAAA;AAElF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;AAaD,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAE,gBAAqB,GAAG,IAAI,CA8BlG"}
1
+ {"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../../src/util/config/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAoB,MAAM,KAAK,CAAA;AAExD,MAAM,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,MAAM,CAAA;AAElF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;AAaD,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAE,gBAAqB,GAAG,IAAI,CA8BlG"}
@@ -1,4 +1,4 @@
1
- import Ajv from "ajv";
1
+ import { Ajv } from "ajv";
2
2
  const ajv = new Ajv({
3
3
  allErrors: true,
4
4
  verbose: true,
@@ -1 +1 @@
1
- {"version":3,"file":"schemaValidator.js","sourceRoot":"","sources":["../../../src/util/config/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,GAAsC,MAAM,KAAK,CAAA;AASxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IAClB,SAAS,EAAE,IAAI;IACf,OAAO,E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C,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QACjD,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,KAAK,CAAC,CAAA;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC;AAED,SAAS,cAAc,CAAC,GAAW,EAAE,MAAc;IACjD,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import Ajv, { ErrorObject, ValidateFunction } from \"ajv\"\n\nexport type PostFormatter = (formattedError: string, error: ErrorObject) => string\n\nexport interface ValidationConfig {\n name?: string\n postFormatter?: PostFormatter\n}\n\nconst ajv = new Ajv({\n allErrors: true,\n verbose: true,\n coerceTypes: true,\n strict: false,\n})\n\n// Cache the compiled validator for the canonical scheme.json so it is only\n// compiled once per process lifetime.\nlet _cachedValidate: ValidateFunction | undefined\n\nexport function validateSchema(schema: unknown, data: unknown, config: ValidationConfig = {}): void {\n if (_cachedValidate == null || _cachedValidate.schema !== schema) {\n _cachedValidate = ajv.compile(schema as object)\n }\n const validate = _cachedValidate\n\n if (validate(data)) {\n return\n }\n\n const errors = validate.errors ?? []\n const baseDataPath = \"configuration\"\n const name = config.name ?? \"Object\"\n\n const relevant = filterRelevantErrors(errors)\n const formatted = relevant.map(error => {\n let msg = formatError(error, baseDataPath)\n if (config.postFormatter != null) {\n msg = config.postFormatter(msg, error)\n }\n return ` - ${indentNewlines(msg, \" \")}`\n })\n\n const header = `Invalid configuration object. ${name} has been initialized using a configuration object that does not match the API schema.`\n const guidance = [\n `Please check the documentation to ensure that your configuration matches the expected schema: https://www.electron.build/configuration`,\n `If you recently upgraded electron-builder to v27, please run \\`electron-builder migrate-schema\\` to automatically update your configuration.`,\n `Check the release notes for breaking changes: https://www.electron.build/docs/migration/v26-to-v27`,\n ]\n throw new Error(`${header}\\n${formatted.join(\"\\n\")}\\n${guidance.join(\"\\n\")}`)\n}\n\n/**\n * Filters the flat list of ajv errors to the most actionable subset.\n * Composite keywords (anyOf/oneOf/if) are suppressed when more specific\n * errors exist at the same or deeper paths. When all errors share the\n * same instancePath and a composite parent for that path exists, the\n * parent is kept instead so the user sees a single \"should be one of\"\n * message rather than every failed branch listed separately.\n */\nfunction filterRelevantErrors(errors: ErrorObject[]): ErrorObject[] {\n const compositeKeywords = new Set([\"anyOf\", \"oneOf\", \"if\"])\n const specific = errors.filter(e => !compositeKeywords.has(e.keyword))\n\n if (specific.length === 0) {\n return errors.filter(e => compositeKeywords.has(e.keyword))\n }\n\n // Group specific errors by instancePath\n const byPath = new Map<string, ErrorObject[]>()\n for (const e of specific) {\n const list = byPath.get(e.instancePath)\n if (list != null) {\n list.push(e)\n } else {\n byPath.set(e.instancePath, [e])\n }\n }\n\n const result: ErrorObject[] = []\n for (const [path, group] of byPath) {\n if (group.length > 1) {\n // additionalProperties errors are the most actionable (\"has unknown\n // property X\") — prefer them over anyOf-parent collapse or type noise.\n const additionalProps = group.filter(e => e.keyword === \"additionalProperties\")\n if (additionalProps.length > 0) {\n result.push(...additionalProps)\n continue\n }\n // For other multi-error groups, prefer the anyOf parent (one concise\n // \"should be one of these\" message).\n const parent = errors.find(e => e.instancePath === path && compositeKeywords.has(e.keyword))\n if (parent != null) {\n result.push(parent)\n continue\n }\n }\n result.push(...group)\n }\n return result\n}\n\n/** Decodes a single RFC 6901 JSON Pointer segment (`~1` → `/`, `~0` → `~`). */\nfunction decodePointerSegment(segment: string): string {\n return segment.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n}\n\nfunction instancePathToLabel(instancePath: string, baseDataPath: string): string {\n if (!instancePath) {\n return baseDataPath\n }\n const segments = instancePath.split(\"/\").filter(Boolean).map(decodePointerSegment)\n return [baseDataPath, ...segments].join(\".\")\n}\n\nfunction formatError(error: ErrorObject, baseDataPath: string): string {\n const label = instancePathToLabel(error.instancePath, baseDataPath)\n const params = error.params as Record<string, unknown>\n const parentSchema = (error as ErrorObject & { parentSchema?: Record<string, unknown> }).parentSchema\n\n switch (error.keyword) {\n case \"additionalProperties\":\n return `${label} has an unknown property '${params.additionalProperty}'`\n\n case \"required\": {\n const missingProp = String(params.missingProperty).replace(/^\\./, \"\")\n return `${label} misses the property '${missingProp}'`\n }\n\n case \"type\": {\n const type = params.type\n if (Array.isArray(type)) {\n const typeList = (type as string[]).join(\" | \")\n const desc = descriptionSuffix(parentSchema)\n return `${label} should be:\\n${typeList}${desc}`\n }\n return `${label} should be a ${type}`\n }\n\n case \"enum\": {\n const enumVals = (parentSchema?.enum as unknown[] | undefined) ?? []\n if (enumVals.length === 1) {\n return `${label} should be ${JSON.stringify(enumVals[0])}`\n }\n return `${label} should be one of these:\\n${enumVals.map(v => JSON.stringify(v)).join(\" | \")}`\n }\n\n case \"anyOf\":\n case \"oneOf\": {\n const schemaText = formatSchemaType(parentSchema)\n return `${label} should be one of these:\\n${schemaText}`\n }\n\n default:\n return `${label} ${error.message}`\n }\n}\n\nfunction descriptionSuffix(schema: Record<string, unknown> | undefined): string {\n return typeof schema?.description === \"string\" ? `\\n-> ${schema.description}` : \"\"\n}\n\nfunction formatSchemaType(schema: Record<string, unknown> | undefined): string {\n if (schema == null) {\n return \"\"\n }\n if (Array.isArray(schema.type)) {\n return (schema.type as string[]).join(\" | \")\n }\n if (typeof schema.type === \"string\") {\n return schema.type\n }\n if (Array.isArray(schema.anyOf)) {\n return (schema.anyOf as Array<Record<string, unknown>>)\n .map(s => {\n if (Array.isArray(s.type)) {\n return (s.type as string[]).join(\" | \")\n }\n return typeof s.type === \"string\" ? s.type : \"\"\n })\n .filter(Boolean)\n .join(\" | \")\n }\n return JSON.stringify(schema)\n}\n\nfunction indentNewlines(str: string, prefix: string): string {\n return str.replace(/\\n(?!$)/g, `\\n${prefix}`)\n}\n"]}
1
+ {"version":3,"file":"schemaValidator.js","sourceRoot":"","s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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,OAAQ,CAAC,CAAC,IAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACzC,CAAC;YACD,OAAO,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QACjD,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,KAAK,CAAC,CAAA;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC;AAED,SAAS,cAAc,CAAC,GAAW,EAAE,MAAc;IACjD,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import { Ajv, ErrorObject, ValidateFunction } from \"ajv\"\n\nexport type PostFormatter = (formattedError: string, error: ErrorObject) => string\n\nexport interface ValidationConfig {\n name?: string\n postFormatter?: PostFormatter\n}\n\nconst ajv = new Ajv({\n allErrors: true,\n verbose: true,\n coerceTypes: true,\n strict: false,\n})\n\n// Cache the compiled validator for the canonical scheme.json so it is only\n// compiled once per process lifetime.\nlet _cachedValidate: ValidateFunction | undefined\n\nexport function validateSchema(schema: unknown, data: unknown, config: ValidationConfig = {}): void {\n if (_cachedValidate == null || _cachedValidate.schema !== schema) {\n _cachedValidate = ajv.compile(schema as object)\n }\n const validate = _cachedValidate\n\n if (validate(data)) {\n return\n }\n\n const errors = validate.errors ?? []\n const baseDataPath = \"configuration\"\n const name = config.name ?? \"Object\"\n\n const relevant = filterRelevantErrors(errors)\n const formatted = relevant.map(error => {\n let msg = formatError(error, baseDataPath)\n if (config.postFormatter != null) {\n msg = config.postFormatter(msg, error)\n }\n return ` - ${indentNewlines(msg, \" \")}`\n })\n\n const header = `Invalid configuration object. ${name} has been initialized using a configuration object that does not match the API schema.`\n const guidance = [\n `Please check the documentation to ensure that your configuration matches the expected schema: https://www.electron.build/configuration`,\n `If you recently upgraded electron-builder to v27, please run \\`electron-builder migrate-schema\\` to automatically update your configuration.`,\n `Check the release notes for breaking changes: https://www.electron.build/docs/migration/v26-to-v27`,\n ]\n throw new Error(`${header}\\n${formatted.join(\"\\n\")}\\n${guidance.join(\"\\n\")}`)\n}\n\n/**\n * Filters the flat list of ajv errors to the most actionable subset.\n * Composite keywords (anyOf/oneOf/if) are suppressed when more specific\n * errors exist at the same or deeper paths. When all errors share the\n * same instancePath and a composite parent for that path exists, the\n * parent is kept instead so the user sees a single \"should be one of\"\n * message rather than every failed branch listed separately.\n */\nfunction filterRelevantErrors(errors: ErrorObject[]): ErrorObject[] {\n const compositeKeywords = new Set([\"anyOf\", \"oneOf\", \"if\"])\n const specific = errors.filter(e => !compositeKeywords.has(e.keyword))\n\n if (specific.length === 0) {\n return errors.filter(e => compositeKeywords.has(e.keyword))\n }\n\n // Group specific errors by instancePath\n const byPath = new Map<string, ErrorObject[]>()\n for (const e of specific) {\n const list = byPath.get(e.instancePath)\n if (list != null) {\n list.push(e)\n } else {\n byPath.set(e.instancePath, [e])\n }\n }\n\n const result: ErrorObject[] = []\n for (const [path, group] of byPath) {\n if (group.length > 1) {\n // additionalProperties errors are the most actionable (\"has unknown\n // property X\") — prefer them over anyOf-parent collapse or type noise.\n const additionalProps = group.filter(e => e.keyword === \"additionalProperties\")\n if (additionalProps.length > 0) {\n result.push(...additionalProps)\n continue\n }\n // For other multi-error groups, prefer the anyOf parent (one concise\n // \"should be one of these\" message).\n const parent = errors.find(e => e.instancePath === path && compositeKeywords.has(e.keyword))\n if (parent != null) {\n result.push(parent)\n continue\n }\n }\n result.push(...group)\n }\n return result\n}\n\n/** Decodes a single RFC 6901 JSON Pointer segment (`~1` → `/`, `~0` → `~`). */\nfunction decodePointerSegment(segment: string): string {\n return segment.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n}\n\nfunction instancePathToLabel(instancePath: string, baseDataPath: string): string {\n if (!instancePath) {\n return baseDataPath\n }\n const segments = instancePath.split(\"/\").filter(Boolean).map(decodePointerSegment)\n return [baseDataPath, ...segments].join(\".\")\n}\n\nfunction formatError(error: ErrorObject, baseDataPath: string): string {\n const label = instancePathToLabel(error.instancePath, baseDataPath)\n const params = error.params as Record<string, unknown>\n const parentSchema = (error as ErrorObject & { parentSchema?: Record<string, unknown> }).parentSchema\n\n switch (error.keyword) {\n case \"additionalProperties\":\n return `${label} has an unknown property '${params.additionalProperty}'`\n\n case \"required\": {\n const missingProp = String(params.missingProperty).replace(/^\\./, \"\")\n return `${label} misses the property '${missingProp}'`\n }\n\n case \"type\": {\n const type = params.type\n if (Array.isArray(type)) {\n const typeList = (type as string[]).join(\" | \")\n const desc = descriptionSuffix(parentSchema)\n return `${label} should be:\\n${typeList}${desc}`\n }\n return `${label} should be a ${type}`\n }\n\n case \"enum\": {\n const enumVals = (parentSchema?.enum as unknown[] | undefined) ?? []\n if (enumVals.length === 1) {\n return `${label} should be ${JSON.stringify(enumVals[0])}`\n }\n return `${label} should be one of these:\\n${enumVals.map(v => JSON.stringify(v)).join(\" | \")}`\n }\n\n case \"anyOf\":\n case \"oneOf\": {\n const schemaText = formatSchemaType(parentSchema)\n return `${label} should be one of these:\\n${schemaText}`\n }\n\n default:\n return `${label} ${error.message}`\n }\n}\n\nfunction descriptionSuffix(schema: Record<string, unknown> | undefined): string {\n return typeof schema?.description === \"string\" ? `\\n-> ${schema.description}` : \"\"\n}\n\nfunction formatSchemaType(schema: Record<string, unknown> | undefined): string {\n if (schema == null) {\n return \"\"\n }\n if (Array.isArray(schema.type)) {\n return (schema.type as string[]).join(\" | \")\n }\n if (typeof schema.type === \"string\") {\n return schema.type\n }\n if (Array.isArray(schema.anyOf)) {\n return (schema.anyOf as Array<Record<string, unknown>>)\n .map(s => {\n if (Array.isArray(s.type)) {\n return (s.type as string[]).join(\" | \")\n }\n return typeof s.type === \"string\" ? s.type : \"\"\n })\n .filter(Boolean)\n .join(\" | \")\n }\n return JSON.stringify(schema)\n}\n\nfunction indentNewlines(str: string, prefix: string): string {\n return str.replace(/\\n(?!$)/g, `\\n${prefix}`)\n}\n"]}
@@ -1,42 +1,25 @@
1
1
  import { ElectronPlatformArtifactDetails, MirrorOptions } from "@electron/get";
2
- import { ElectronPlatformName } from "../electron/ElectronFramework.js";
3
- export type ElectronGetOptions = Omit<ElectronPlatformArtifactDetails, "platform" | "arch" | "version" | "artifactName" | "artifactSuffix" | "customFilename" | "tempDirectory" | "downloader" | "cacheMode" | "cacheRoot" | "downloadOptions" | "isGeneric" | "mirrorOptions"> & {
2
+ export interface ElectronGetOptions extends Omit<ElectronPlatformArtifactDetails, "platform" | "arch" | "version" | "artifactName" | "artifactSuffix" | "customFilename" | "tempDirectory" | "downloader" | "cacheMode" | "cacheRoot" | "downloadOptions" | "isGeneric" | "mirrorOptions"> {
4
3
  mirrorOptions?: Omit<MirrorOptions, "customDir" | "customFilename" | "customVersion">;
5
- };
4
+ }
6
5
  export type ArtifactDownloadOptions = {
7
- electronDownload?: ElectronGetOptions | ElectronDownloadOptions | null;
6
+ options?: ElectronGetOptions | null;
8
7
  artifactName: string;
9
8
  platformName: string;
10
9
  arch: string;
11
10
  version: string;
12
11
  cacheDir?: string;
13
12
  };
14
- export interface ElectronDownloadOptions {
15
- version?: string;
16
- /**
17
- * The [cache location](https://github.com/electron-userland/electron-download#cache-location).
18
- */
19
- cache?: string | null;
20
- /**
21
- * The mirror.
22
- */
23
- mirror?: string | null;
24
- /** @private */
25
- customDir?: string | null;
26
- /** @private */
27
- customFilename?: string | null;
28
- /** @private */
29
- strictSSL?: boolean;
30
- /** @private */
31
- isVerifyChecksum?: boolean;
32
- platform?: ElectronPlatformName;
33
- arch?: string;
34
- }
35
13
  export declare function getCacheDirectory(options: {
36
14
  isAvoidSystemOnWindows?: boolean;
37
15
  allowEnvVarOverride: boolean;
38
16
  }): string;
39
17
  export declare function extractArchive(file: string, dir: string): Promise<void>;
18
+ /**
19
+ * Forces undici's global proxy dispatcher to re-read the current HTTP(S)_PROXY / NO_PROXY env vars,
20
+ * bypassing the once-guard in initializeProxyOnce(). Exported for integration testing only.
21
+ */
22
+ export declare function reinitializeProxy(): void;
40
23
  /**
41
24
  * Copies a remote artifact to a specific output path on disk.
42
25
  * Unlike downloadBuilderToolset, this does not extract archives — it copies the raw file.
@@ -1 +1 @@
1
- {"version":3,"file":"electronGet.d.ts","sourceRoot":"","sources":["../../src/util/electronGet.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,+BAA+B,EAE/B,aAAa,EACd,MAAM,eAAe,CAAA;AActB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAIvE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,+BAA+B,EAC7B,UAAU,GACV,MAAM,GACN,SAAS,GACT,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,YAAY,GACZ,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,WAAW,GACX,eAAe,CAClB,GAAG;IACF,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,gBAAgB,GAAG,eAAe,CAAC,CAAA;CACtF,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,gBAAgB,CAAC,EAAE,kBAAkB,GAAG,uBAAuB,GAAG,IAAI,CAAA;IACtE,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,uBAAuB;IAGtC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtB,eAAe;IAC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,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoClB;AAoBD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7F;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAShG;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAclE"}
@@ -1,18 +1,18 @@
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, 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
16
  import { CacheState, cleanupCacheDirectory, computeCacheMetadata, readCacheStateFile, validateCacheDirectory, writeCacheState } from "./cacheState.js";
17
17
  function hashUrlSafe(input, length = 6) {
18
18
  let hash = 5381;
@@ -58,6 +58,21 @@ function resolveCacheMode() {
58
58
  }
59
59
  return ElectronDownloadCacheMode.ReadWrite;
60
60
  }
61
+ /**
62
+ * Returns true when `destPath` is safely contained within `dir` (direct child or deeper).
63
+ * On Windows the filesystem is case-insensitive so the comparison is normalised to lowercase.
64
+ * @internal exported for unit testing
65
+ */
66
+ export function isSafeExtractPath(destPath, dir) {
67
+ const normalizedDest = path.resolve(destPath);
68
+ const normalizedDir = path.resolve(dir);
69
+ if (process.platform === "win32") {
70
+ const d = normalizedDest.toLowerCase();
71
+ const b = normalizedDir.toLowerCase();
72
+ return d.startsWith(b + path.sep) || d === b;
73
+ }
74
+ return normalizedDest.startsWith(normalizedDir + path.sep) || normalizedDest === normalizedDir;
75
+ }
61
76
  async function extractZipStreaming(file, dir) {
62
77
  // Pass 1: read central directory once to collect Unix modes (one seek to EOF)
63
78
  const zipDir = await unzipper.Open.file(file);
@@ -69,38 +84,46 @@ async function extractZipStreaming(file, dir) {
69
84
  }
70
85
  }
71
86
  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}`);
87
+ // Pass 2: stream from byte 0 — no per-entry seeks, no Docker hang.
88
+ // Destroy the read stream in a finally block so the file handle is always released,
89
+ // including when the loop exits early due to a thrown error.
90
+ const readStream = createReadStream(file);
91
+ try {
92
+ const entries = readStream.pipe(unzipper.Parse({ forceStream: true }));
93
+ for await (const entry of entries) {
94
+ const destPath = path.resolve(dir, entry.path);
95
+ if (!isSafeExtractPath(destPath, dir)) {
96
+ throw new Error(`Path traversal blocked: ${entry.path}`);
84
97
  }
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}`);
98
+ const mode = entryModes.get(entry.path) ?? 0;
99
+ if (mode > 0 && isSymlink(mode)) {
100
+ const target = (await entry.buffer()).toString();
101
+ if (path.isAbsolute(target)) {
102
+ throw new Error(`Absolute symlink target blocked: ${target}`);
103
+ }
104
+ const resolvedTarget = path.resolve(path.dirname(destPath), target);
105
+ if (!isSafeExtractPath(resolvedTarget, dir)) {
106
+ throw new Error(`Symlink target escapes extraction dir: ${target}`);
107
+ }
108
+ await fs.mkdir(path.dirname(destPath), { recursive: true });
109
+ await fs.symlink(target, destPath);
88
110
  }
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);
111
+ else if (entry.type === "Directory") {
112
+ await fs.mkdir(destPath, { recursive: true });
113
+ entry.autodrain();
114
+ }
115
+ else {
116
+ await fs.mkdir(path.dirname(destPath), { recursive: true });
117
+ await pipeline(entry, createWriteStream(destPath));
118
+ if (mode > 0) {
119
+ await fs.chmod(destPath, mode & 0o7777);
120
+ }
101
121
  }
102
122
  }
103
123
  }
124
+ finally {
125
+ readStream.destroy();
126
+ }
104
127
  }
105
128
  export async function extractArchive(file, dir) {
106
129
  const tmpDir = `${dir}.tmp`;
@@ -157,7 +180,7 @@ export async function extractArchive(file, dir) {
157
180
  // Check if extraction actually failed or just had benign warnings
158
181
  const files = await fs.readdir(tmpDir);
159
182
  if (files.length === 0) {
160
- log.warn({ file, tmpDir, error: e.message }, "7z extraction produced no output");
183
+ log.warn({ file: log.filePath(file), tmpDir: log.filePath(tmpDir), error: e.message }, "7z extraction produced no output");
161
184
  throw new Error(`7z extraction failed for ${file}: ${e.message}`);
162
185
  }
163
186
  // If files were extracted despite the error, log and continue
@@ -173,20 +196,37 @@ export async function extractArchive(file, dir) {
173
196
  throw new Error(`Extraction of ${path.basename(file)} produced no files`);
174
197
  }
175
198
  await fs.rm(dir, { recursive: true, force: true });
176
- await fs.rename(tmpDir, dir);
199
+ await moveDirAtomic(tmpDir, dir);
177
200
  }
178
201
  finally {
179
202
  await release().catch(err => log.warn({ err }, "failed to release lockfile"));
180
203
  }
181
204
  }
205
+ let proxyInitialized = false;
206
+ function initializeProxyOnce() {
207
+ if (!proxyInitialized) {
208
+ reinitializeProxy();
209
+ proxyInitialized = true;
210
+ }
211
+ }
212
+ /**
213
+ * Forces undici's global proxy dispatcher to re-read the current HTTP(S)_PROXY / NO_PROXY env vars,
214
+ * bypassing the once-guard in initializeProxyOnce(). Exported for integration testing only.
215
+ */
216
+ export function reinitializeProxy() {
217
+ get.initializeProxy();
218
+ }
182
219
  async function downloadArtifactToFile(config, label) {
183
220
  // Serialize concurrent downloads of the same artifact across vitest workers to prevent @electron/get's
184
221
  // 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);
222
+ const key = {
223
+ p: config.platform,
224
+ a: config.arch,
225
+ v: config.version,
226
+ n: config.artifactName,
227
+ g: config.isGeneric,
228
+ };
229
+ const artifactLockKey = crypto.createHash("sha256").update(JSON.stringify(key)).digest("hex").slice(0, 20);
190
230
  const artifactLockPath = path.join(os.tmpdir(), `eb-dl-${artifactLockKey}.lock`);
191
231
  // This lock is taken even for cache hits (the cache-hit check lives inside @electron/get), so under
192
232
  // heavy concurrency many builds serialize here. 30 retries (~137s of backoff) is too few — waiters
@@ -200,10 +240,12 @@ async function downloadArtifactToFile(config, label) {
200
240
  });
201
241
  let lastLoggedMilestone = -1;
202
242
  const state = { bar: undefined };
243
+ // @electron/get v5 downloads via fetch, whose proxy support comes from undici's global dispatcher.
244
+ // initializeProxy() wires that up from HTTP(S)_PROXY/NO_PROXY env vars (replaces the got proxy agent).
245
+ initializeProxyOnce();
203
246
  const downloadOptions = {
204
- timeout: { request: 10 * 60 * 1000 }, // prevent indefinite hang on stalled connections
247
+ signal: AbortSignal.timeout(10 * 60 * 1000), // prevent indefinite hang on stalled connections
205
248
  ...config.downloadOptions,
206
- agent: config.downloadOptions?.agent ?? buildGotProxyAgent(),
207
249
  getProgressCallback: info => {
208
250
  // @electron/get passes downloadOptions (including this callback) to its internal
209
251
  // SHASUMS256.txt validation download. That file is tiny (<1 MB) and fires at 100%
@@ -310,9 +352,14 @@ async function persistToArchiveCache(sourcePath, archiveCachePath) {
310
352
  * Both public download functions delegate here after building their respective configs.
311
353
  */
312
354
  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.
355
+ // Create only the PARENT dir (e.g. <cache>/fpm@2.2.1), never extractDir itself, before locking.
356
+ // The parent is stable — cleanup only ever removes extractDir and its .state/.tmp/.lock siblings —
357
+ // so extractDir's whole lifecycle (mkdir, rm, re-mkdir) stays inside the lock. ensureDir absorbs
358
+ // the concurrent-recursive-mkdir ENOENT/EEXIST race while peers populate the cold cache tree.
359
+ await ensureDir(path.dirname(extractDir));
360
+ // Pre-lock fast path: read-only short-circuit for a definitively complete and valid cache.
361
+ // Safe unlocked — the cache-state helpers return null/false for a missing or half-written dir,
362
+ // so a racing read only ever falls through to take the lock. Do NOT mutate the dir here.
316
363
  const stateData = await readCacheStateFile(extractDir);
317
364
  if (stateData?.state === CacheState.complete) {
318
365
  const isValid = await validateCacheDirectory(extractDir, stateData.fileCount);
@@ -327,6 +374,13 @@ async function downloadAndExtract(config, extractDir, label, archiveCachePath) {
327
374
  // patience of withToolsetLock. proper-lockfile's update heartbeat keeps a live holder's lock fresh,
328
375
  // so increasing waiter retries never falsely steals an in-progress extraction.
329
376
  const release = await lockfile.lock(extractDir, {
377
+ // realpath:false so proper-lockfile creates <extractDir>.lock in the (already-created) parent
378
+ // WITHOUT calling fs.realpath(extractDir) first — which would throw ENOENT now that extractDir
379
+ // is created lazily inside the lock. This filesystem lock serializes peers both across worker
380
+ // processes AND within a single process (a second lock() for the same path retries until the
381
+ // first releases), so no in-process promise cache is needed — and one wouldn't help across the
382
+ // separate test worker processes anyway.
383
+ realpath: false,
330
384
  retries: { retries: 100, minTimeout: 1000, maxTimeout: 5000 },
331
385
  stale: 120000,
332
386
  });
@@ -347,7 +401,7 @@ async function downloadAndExtract(config, extractDir, label, archiveCachePath) {
347
401
  }
348
402
  // Cleanup inside the lock — skip lock files since we currently hold them
349
403
  await cleanupCacheDirectory(extractDir, { skipLockFiles: true });
350
- await fs.mkdir(extractDir, { recursive: true });
404
+ await ensureDir(extractDir);
351
405
  // Check electron-builder's own archive cache before touching @electron/get.
352
406
  // The cache lives alongside the extract dir: <cacheDir>/<releaseName>/<filename>.
353
407
  // This lets repeated builds (or offline environments) skip the download entirely once
@@ -453,7 +507,9 @@ export async function downloadBuilderToolset(options) {
453
507
  const fullUrl = resolveBuilderBinaryUrl(releaseName, filenameWithExt, baseUrl, overrideUrl);
454
508
  const suffix = hashUrlSafe(fullUrl, 5);
455
509
  const folderName = `${filenameWithExt.replace(/\.(tar\.gz|tgz|tar\.xz|txz|zip|7z)$/, "")}-${suffix}`;
456
- const extractDir = path.join(getCacheDirectory({ allowEnvVarOverride: true }), releaseName, folderName);
510
+ // releaseName is library input; enforce cache-dir containment (rejects traversal, clears taint into shell extraction)
511
+ const cacheDir = getCacheDirectory({ allowEnvVarOverride: true });
512
+ const extractDir = sanitizeDirPath(path.join(cacheDir, releaseName, folderName), cacheDir);
457
513
  // Use resolveAssetURL so @electron/get's ELECTRON_MIRROR env var check cannot override
458
514
  // the builder-binaries URL we've already resolved (see getArtifactRemoteURL in @electron/get).
459
515
  const mirrorOptions = {
@@ -462,7 +518,7 @@ export async function downloadBuilderToolset(options) {
462
518
  // Predictable archive cache: <cacheDir>/<releaseName>/<filename>, next to the extract dir.
463
519
  // downloadAndExtract checks here before touching @electron/get and persists the archive here
464
520
  // after every successful download, so subsequent builds never need a network round-trip.
465
- const archiveCachePath = path.join(getCacheDirectory({ allowEnvVarOverride: true }), releaseName, filenameWithExt);
521
+ const archiveCachePath = sanitizeDirPath(path.join(cacheDir, releaseName, filenameWithExt), cacheDir);
466
522
  const config = {
467
523
  version: "9.9.9", // must be >1.3.2 to bypass @electron/get validation shortcut
468
524
  artifactName: filenameWithExt,
@@ -474,52 +530,16 @@ export async function downloadBuilderToolset(options) {
474
530
  };
475
531
  return downloadAndExtract(config, extractDir, filenameWithExt, archiveCachePath);
476
532
  }
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));
482
- }
483
533
  /**
484
534
  * Downloads and extracts an electron platform artifact (e.g. ffmpeg) using @electron/get.
485
535
  * Deduplicates concurrent calls for the same artifact within the same process.
486
536
  */
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 };
494
- }
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
- }
520
- }
537
+ function buildElectronArtifactConfig(artifactOptions) {
538
+ const { options, arch, version, platformName: platform, artifactName, cacheDir: cacheRoot } = artifactOptions;
539
+ if (options?.unsafelyDisableChecksums) {
540
+ log.warn({ artifactName }, "electronGet.unsafelyDisableChecksums is enabled — downloaded artifacts will NOT be verified.txt; a compromised mirror can serve malicious binaries undetected");
521
541
  }
522
- artifactConfig.cacheMode = resolveCacheMode();
542
+ const artifactConfig = { ...options, cacheRoot, platform, arch, version, artifactName, cacheMode: resolveCacheMode() };
523
543
  return artifactConfig;
524
544
  }
525
545
  /**