app-builder-lib 27.0.0-alpha.1 → 27.0.0-alpha.3

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 (179) 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 +407 -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 +19 -120
  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 +2 -2
  61. package/dist/indexInternal.d.ts.map +1 -1
  62. package/dist/indexInternal.js +1 -1
  63. package/dist/indexInternal.js.map +1 -1
  64. package/dist/macPackager.d.ts +14 -10
  65. package/dist/macPackager.d.ts.map +1 -1
  66. package/dist/macPackager.js +114 -121
  67. package/dist/macPackager.js.map +1 -1
  68. package/dist/node-module-collector/moduleManager.d.ts +7 -1
  69. package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
  70. package/dist/node-module-collector/moduleManager.js +2 -2
  71. package/dist/node-module-collector/moduleManager.js.map +1 -1
  72. package/dist/node-module-collector/nodeModulesCollector.js +1 -1
  73. package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
  74. package/dist/node-module-collector/packageManager.js +1 -1
  75. package/dist/node-module-collector/packageManager.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/options/FuseOptionsV1.d.ts +137 -0
  81. package/dist/options/FuseOptionsV1.d.ts.map +1 -0
  82. package/dist/options/FuseOptionsV1.js +2 -0
  83. package/dist/options/FuseOptionsV1.js.map +1 -0
  84. package/dist/options/PlatformSpecificBuildOptions.d.ts +1 -1
  85. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  86. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  87. package/dist/options/macOptions.d.ts +93 -126
  88. package/dist/options/macOptions.d.ts.map +1 -1
  89. package/dist/options/macOptions.js.map +1 -1
  90. package/dist/options/winOptions.d.ts +137 -63
  91. package/dist/options/winOptions.d.ts.map +1 -1
  92. package/dist/options/winOptions.js +12 -1
  93. package/dist/options/winOptions.js.map +1 -1
  94. package/dist/platformPackager.d.ts +4 -2
  95. package/dist/platformPackager.d.ts.map +1 -1
  96. package/dist/platformPackager.js +11 -7
  97. package/dist/platformPackager.js.map +1 -1
  98. package/dist/targets/ArchiveTarget.js +2 -2
  99. package/dist/targets/ArchiveTarget.js.map +1 -1
  100. package/dist/targets/archive.d.ts +10 -2
  101. package/dist/targets/archive.d.ts.map +1 -1
  102. package/dist/targets/archive.js +25 -6
  103. package/dist/targets/archive.js.map +1 -1
  104. package/dist/targets/linux/snap/core24.d.ts +2 -0
  105. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  106. package/dist/targets/linux/snap/core24.js +48 -8
  107. package/dist/targets/linux/snap/core24.js.map +1 -1
  108. package/dist/targets/linux/snap/coreLegacy.d.ts +2 -2
  109. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  110. package/dist/targets/linux/snap/coreLegacy.js +3 -4
  111. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  112. package/dist/targets/linux/snap/snapCommand.d.ts +13 -0
  113. package/dist/targets/linux/snap/snapCommand.d.ts.map +1 -0
  114. package/dist/targets/linux/snap/snapCommand.js +27 -0
  115. package/dist/targets/linux/snap/snapCommand.js.map +1 -0
  116. package/dist/targets/mac/MacTargetHelper.d.ts +12 -12
  117. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  118. package/dist/targets/mac/MacTargetHelper.js +72 -67
  119. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  120. package/dist/targets/mac/pkg.d.ts.map +1 -1
  121. package/dist/targets/mac/pkg.js +4 -4
  122. package/dist/targets/mac/pkg.js.map +1 -1
  123. package/dist/targets/win/AppxTarget.d.ts.map +1 -1
  124. package/dist/targets/win/AppxTarget.js +4 -4
  125. package/dist/targets/win/AppxTarget.js.map +1 -1
  126. package/dist/targets/win/nsis/NsisTarget.js +2 -2
  127. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  128. package/dist/targets/win/nsis/nsisScriptGenerator.js +1 -1
  129. package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
  130. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  131. package/dist/targets/win/nsis/nsisUtil.js +2 -2
  132. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  133. package/dist/toolsets/custom.d.ts +1 -0
  134. package/dist/toolsets/custom.d.ts.map +1 -1
  135. package/dist/toolsets/custom.js +19 -8
  136. package/dist/toolsets/custom.js.map +1 -1
  137. package/dist/toolsets/icons.js +1 -1
  138. package/dist/toolsets/icons.js.map +1 -1
  139. package/dist/toolsets/winCodeSign.d.ts +36 -0
  140. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  141. package/dist/toolsets/winCodeSign.js +84 -30
  142. package/dist/toolsets/winCodeSign.js.map +1 -1
  143. package/dist/toolsets/wine.d.ts.map +1 -1
  144. package/dist/toolsets/wine.js +20 -12
  145. package/dist/toolsets/wine.js.map +1 -1
  146. package/dist/util/config/schemaValidator.d.ts.map +1 -1
  147. package/dist/util/config/schemaValidator.js +1 -1
  148. package/dist/util/config/schemaValidator.js.map +1 -1
  149. package/dist/util/electronGet.d.ts +8 -25
  150. package/dist/util/electronGet.d.ts.map +1 -1
  151. package/dist/util/electronGet.js +107 -87
  152. package/dist/util/electronGet.js.map +1 -1
  153. package/dist/util/flags.d.ts +0 -3
  154. package/dist/util/flags.d.ts.map +1 -1
  155. package/dist/util/flags.js +0 -9
  156. package/dist/util/flags.js.map +1 -1
  157. package/dist/util/license.d.ts.map +1 -1
  158. package/dist/util/license.js +4 -1
  159. package/dist/util/license.js.map +1 -1
  160. package/dist/util/yarn.js +1 -1
  161. package/dist/util/yarn.js.map +1 -1
  162. package/dist/version.d.ts +1 -1
  163. package/dist/version.js +1 -1
  164. package/dist/version.js.map +1 -1
  165. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  166. package/dist/vm/ParallelsVm.js +13 -2
  167. package/dist/vm/ParallelsVm.js.map +1 -1
  168. package/dist/vm/vm.d.ts.map +1 -1
  169. package/dist/vm/vm.js +4 -1
  170. package/dist/vm/vm.js.map +1 -1
  171. package/dist/winPackager.d.ts +1 -2
  172. package/dist/winPackager.d.ts.map +1 -1
  173. package/dist/winPackager.js +17 -22
  174. package/dist/winPackager.js.map +1 -1
  175. package/package.json +15 -14
  176. package/scheme.json +484 -432
  177. package/dist/codeSign/signManager.d.ts.map +0 -1
  178. package/dist/codeSign/signManager.js +0 -2
  179. package/dist/codeSign/signManager.js.map +0 -1
@@ -4,6 +4,7 @@ import { AfterPackContext } from "./configuration.js";
4
4
  import { Platform } from "./core.js";
5
5
  import { ElectronPlatformName } from "./electron/ElectronFramework.js";
6
6
  import type { PlatformPackager } from "./platformPackager.js";
7
+ import type { PlatformType } from "./targets/mac/MacTargetHelper.js";
7
8
  export interface Framework {
8
9
  readonly name: string;
9
10
  readonly version: string;
@@ -25,6 +26,7 @@ export interface BeforeCopyExtraFilesOptions {
25
26
  appOutDir: string;
26
27
  asarIntegrity: AsarIntegrity | null;
27
28
  platformName: string;
29
+ platformType?: PlatformType;
28
30
  }
29
31
  export interface PrepareApplicationStageDirectoryOptions {
30
32
  readonly packager: PlatformPackager<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;IAEnC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAA;IAEtC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IAErC,cAAc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AQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IAEjB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IAGnC,YAAY,EAAE,MAAM,CAAA;IAIpB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;AAED,MAAM,WAAW,uCAAuC;IACtD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACxC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAA;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAE7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"Framework.js","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAsDA,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU,CAAA;AACtC,CAAC","sourcesContent":["import { FileTransformer } from \"builder-util\"\nimport { AsarIntegrity } from \"./asar/integrity.js\"\nimport { AfterPackContext } from \"./configuration.js\"\nimport { Platform } from \"./core.js\"\nimport { ElectronPlatformName } from \"./electron/ElectronFramework.js\"\nimport type { PlatformPackager } from \"./platformPackager.js\"\n\nexport interface Framework {\n readonly name: string\n readonly version: string\n readonly distMacOsAppName: string\n readonly macOsDefaultTargets: Array<string>\n readonly defaultAppIdPrefix: string\n\n readonly isNpmRebuildRequired: boolean\n\n readonly isCopyElevateHelper: boolean\n\n getDefaultIcon?(platform: Platform): string | null\n\n getMainFile?(platform: Platform): string | null\n\n getExcludedDependencies?(platform: Platform): Array<string> | null\n\n prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions): Promise<any>\n\n beforeCopyExtraFiles?(options: BeforeCopyExtraFilesOptions): Promise<any>\n\n afterPack?(context: AfterPackContext): Promise<any>\n\n createTransformer?(): FileTransformer | null\n}\n\nexport interface BeforeCopyExtraFilesOptions {\n packager: PlatformPackager<any>\n appOutDir: string\n\n asarIntegrity: AsarIntegrity | null\n\n // ElectronPlatformName\n platformName: string\n}\n\nexport interface PrepareApplicationStageDirectoryOptions {\n readonly packager: PlatformPackager<any>\n /**\n * Platform doesn't process application output directory in any way. Unpack implementation must create or empty dir if need.\n */\n readonly appOutDir: string\n readonly platformName: ElectronPlatformName\n readonly arch: string\n readonly version: string\n}\n\nexport function isElectronBased(framework: Framework): boolean {\n return framework.name === \"electron\"\n}\n"]}
1
+ {"version":3,"file":"Framework.js","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AA2DA,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU,CAAA;AACtC,CAAC","sourcesContent":["import { FileTransformer } from \"builder-util\"\nimport { AsarIntegrity } from \"./asar/integrity.js\"\nimport { AfterPackContext } from \"./configuration.js\"\nimport { Platform } from \"./core.js\"\nimport { ElectronPlatformName } from \"./electron/ElectronFramework.js\"\nimport type { PlatformPackager } from \"./platformPackager.js\"\nimport type { PlatformType } from \"./targets/mac/MacTargetHelper.js\"\n\nexport interface Framework {\n readonly name: string\n readonly version: string\n readonly distMacOsAppName: string\n readonly macOsDefaultTargets: Array<string>\n readonly defaultAppIdPrefix: string\n\n readonly isNpmRebuildRequired: boolean\n\n readonly isCopyElevateHelper: boolean\n\n getDefaultIcon?(platform: Platform): string | null\n\n getMainFile?(platform: Platform): string | null\n\n getExcludedDependencies?(platform: Platform): Array<string> | null\n\n prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions): Promise<any>\n\n beforeCopyExtraFiles?(options: BeforeCopyExtraFilesOptions): Promise<any>\n\n afterPack?(context: AfterPackContext): Promise<any>\n\n createTransformer?(): FileTransformer | null\n}\n\nexport interface BeforeCopyExtraFilesOptions {\n packager: PlatformPackager<any>\n appOutDir: string\n\n asarIntegrity: AsarIntegrity | null\n\n // ElectronPlatformName\n platformName: string\n\n // macOS-only: the authoritative 3-way build flavor (\"mac\" | \"mas\" | \"mas-dev\").\n // Distinct from `platformName`, which collapses mas/mas-dev to \"mas\".\n platformType?: PlatformType\n}\n\nexport interface PrepareApplicationStageDirectoryOptions {\n readonly packager: PlatformPackager<any>\n /**\n * Platform doesn't process application output directory in any way. Unpack implementation must create or empty dir if need.\n */\n readonly appOutDir: string\n readonly platformName: ElectronPlatformName\n readonly arch: string\n readonly version: string\n}\n\nexport function isElectronBased(framework: Framework): boolean {\n return framework.name === \"electron\"\n}\n"]}
@@ -1,3 +1,5 @@
1
- import type { FilesystemEntry } from "@electron/asar/lib/filesystem";
2
- export declare function checkFileInArchive(asarFile: string, relativeFile: string, messagePrefix: string): Promise<FilesystemEntry>;
1
+ import * as asar from "@electron/asar";
2
+ type FilesystemEntry = ReturnType<typeof asar.statFile>;
3
+ export declare function checkFileInArchive(asarFile: string, relativeFile: string, messagePrefix: string): FilesystemEntry;
4
+ export {};
3
5
  //# sourceMappingURL=asarFileChecker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asarFileChecker.d.ts","sourceRoot":"","sources":["../../src/asar/asarFileChecker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,+BAA+B,CAAA;AAGzF,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAkBhI"}
1
+ {"version":3,"file":"asarFileChecker.d.ts","sourceRoot":"","sources":["../../src/asar/asarFileChecker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAGtC,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAA;AAGvD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,eAAe,CAiBjH"}
@@ -1,6 +1,5 @@
1
- import { dynamicImport } from "../util/dynamicImport.js";
2
- export async function checkFileInArchive(asarFile, relativeFile, messagePrefix) {
3
- const asar = await dynamicImport("@electron/asar");
1
+ import * as asar from "@electron/asar";
2
+ export function checkFileInArchive(asarFile, relativeFile, messagePrefix) {
4
3
  function error(text) {
5
4
  return new Error(`${messagePrefix} "${relativeFile}" in the "${asarFile}" ${text}`);
6
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"asarFileChecker.js","sourceRoot":"","sources":["../../src/asar/asarFileChecker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAgB,EAAE,YAAoB,EAAE,aAAqB;IACpG,MAAM,IAAI,GAAG,MAAM,aAAa,CAAkC,gBAAgB,CAAC,CAAA;IACnF,SAAS,KAAK,CAAC,IAAY;QACzB,OAAO,IAAI,KAAK,CAAC,GAAG,aAAa,KAAK,YAAY,aAAa,QAAQ,KAAK,IAAI,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,IAAI,IAAqB,CAAA;IACzB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,sDAAsD,CAAC,EAAE,CAAC;YAC/E,MAAM,KAAK,CAAC,mDAAmD,CAAC,CAAA;QAClE,CAAC;QACD,MAAM,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IACnC,CAAC;IACD,IAAK,IAA4B,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { FilesystemEntry, FilesystemFileEntry } from \"@electron/asar/lib/filesystem\"\nimport { dynamicImport } from \"../util/dynamicImport.js\"\n\nexport async function checkFileInArchive(asarFile: string, relativeFile: string, messagePrefix: string): Promise<FilesystemEntry> {\n const asar = await dynamicImport<typeof import(\"@electron/asar\")>(\"@electron/asar\")\n function error(text: string) {\n return new Error(`${messagePrefix} \"${relativeFile}\" in the \"${asarFile}\" ${text}`)\n }\n let stat: FilesystemEntry\n try {\n stat = asar.statFile(asarFile, relativeFile, false)\n } catch (e: any) {\n if (e.message.includes(\"Cannot read properties of undefined (reading 'link')\")) {\n throw error(\"does not exist. Seems like a wrong configuration.\")\n }\n throw error(`is corrupted: ${e}`)\n }\n if ((stat as FilesystemFileEntry).size === 0) {\n throw error(`is corrupted: size 0`)\n }\n return stat\n}\n"]}
1
+ {"version":3,"file":"asarFileChecker.js","sourceRoot":"","sources":["../../src/asar/asarFileChecker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AAMtC,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,YAAoB,EAAE,aAAqB;IAC9F,SAAS,KAAK,CAAC,IAAY;QACzB,OAAO,IAAI,KAAK,CAAC,GAAG,aAAa,KAAK,YAAY,aAAa,QAAQ,KAAK,IAAI,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,IAAI,IAAqB,CAAA;IACzB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,sDAAsD,CAAC,EAAE,CAAC;YAC/E,MAAM,KAAK,CAAC,mDAAmD,CAAC,CAAA;QAClE,CAAC;QACD,MAAM,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IACnC,CAAC;IACD,IAAK,IAA4B,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import * as asar from \"@electron/asar\"\n\n// @electron/asar v4 no longer exports its filesystem entry types from the package root, so derive them from `statFile`'s return type.\ntype FilesystemEntry = ReturnType<typeof asar.statFile>\ntype FilesystemFileEntry = Extract<FilesystemEntry, { size: number }>\n\nexport function checkFileInArchive(asarFile: string, relativeFile: string, messagePrefix: string): FilesystemEntry {\n function error(text: string) {\n return new Error(`${messagePrefix} \"${relativeFile}\" in the \"${asarFile}\" ${text}`)\n }\n let stat: FilesystemEntry\n try {\n stat = asar.statFile(asarFile, relativeFile, false)\n } catch (e: any) {\n if (e.message.includes(\"Cannot read properties of undefined (reading 'link')\")) {\n throw error(\"does not exist. Seems like a wrong configuration.\")\n }\n throw error(`is corrupted: ${e}`)\n }\n if ((stat as FilesystemFileEntry).size === 0) {\n throw error(`is corrupted: size 0`)\n }\n return stat\n}\n"]}
@@ -41,6 +41,20 @@ export declare function readCertInfo(file: string, password: string): Promise<{
41
41
  commonName: string;
42
42
  bloodyMicrosoftSubjectDn: string;
43
43
  }>;
44
+ /**
45
+ * Reads certificate info from a plain X.509 certificate file (.crt / .cer).
46
+ * Accepts both PEM (base64 with -----BEGIN CERTIFICATE----- headers) and DER (raw binary) encoding.
47
+ *
48
+ * Unlike `readCertInfo`, this does not require a password and does not parse PKCS#12.
49
+ * Used when HSM mode supplies a public-cert-only file alongside /csp + /kc or pkcs11Module.
50
+ *
51
+ * Returns `null` when the publisher name cannot be determined (e.g. no CN attribute), so
52
+ * callers should fall back to requiring an explicit `publisherName` in that case.
53
+ */
54
+ export declare function readCertInfoFromX509(file: string): Promise<{
55
+ commonName: string;
56
+ bloodyMicrosoftSubjectDn: string;
57
+ } | null>;
44
58
  /**
45
59
  * Internal functions exported exclusively for unit testing.
46
60
  * Not part of the public API — do not use outside of test files.
@@ -1 +1 @@
1
- {"version":3,"file":"certInfo.d.ts","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"AAwHA;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA0E3F;AAqBD;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAqElH;AAED;;;;GAIG;AACH,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASvD;AAyCD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAA;CAAE,CAAC,CAuIpI;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;CAKxB,CAAA"}
1
+ {"version":3,"file":"certInfo.d.ts","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"AAwHA;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA0E3F;AAqBD;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAqElH;AAED;;;;GAIG;AACH,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASvD;AAyCD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAA;CAAE,CAAC,CAuIpI;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAyCjI;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;CAKxB,CAAA"}
@@ -446,6 +446,55 @@ export async function readCertInfo(file, password) {
446
446
  .join(",");
447
447
  return { commonName, bloodyMicrosoftSubjectDn };
448
448
  }
449
+ /**
450
+ * Reads certificate info from a plain X.509 certificate file (.crt / .cer).
451
+ * Accepts both PEM (base64 with -----BEGIN CERTIFICATE----- headers) and DER (raw binary) encoding.
452
+ *
453
+ * Unlike `readCertInfo`, this does not require a password and does not parse PKCS#12.
454
+ * Used when HSM mode supplies a public-cert-only file alongside /csp + /kc or pkcs11Module.
455
+ *
456
+ * Returns `null` when the publisher name cannot be determined (e.g. no CN attribute), so
457
+ * callers should fall back to requiring an explicit `publisherName` in that case.
458
+ */
459
+ export async function readCertInfoFromX509(file) {
460
+ const raw = await readFile(file);
461
+ // Support PEM (ASCII armor) and DER (raw binary) encoding.
462
+ let derBytes;
463
+ const pemContent = raw.toString("ascii");
464
+ if (pemContent.includes("-----BEGIN CERTIFICATE-----")) {
465
+ const b64 = pemContent
466
+ .replace(/-----BEGIN CERTIFICATE-----/g, "")
467
+ .replace(/-----END CERTIFICATE-----/g, "")
468
+ .replace(/\s+/g, "");
469
+ derBytes = Buffer.from(b64, "base64");
470
+ }
471
+ else {
472
+ derBytes = raw;
473
+ }
474
+ let cert;
475
+ try {
476
+ const asn1Result = asn1js.fromBER(toArrayBuffer(derBytes));
477
+ if (asn1Result.offset === -1) {
478
+ throw new Error("offset -1: invalid BER encoding");
479
+ }
480
+ cert = new pkijs.Certificate({ schema: asn1Result.result });
481
+ }
482
+ catch (err) {
483
+ throw new Error(`X.509 certificate file "${file}" could not be parsed: ${err instanceof Error ? err.message : String(err)}`);
484
+ }
485
+ const cnAttr = cert.subject.typesAndValues.find(a => a.type === "2.5.4.3");
486
+ if (cnAttr == null) {
487
+ return null;
488
+ }
489
+ const commonName = String(cnAttr.value.valueBlock.value);
490
+ const bloodyMicrosoftSubjectDn = cert.subject.typesAndValues
491
+ .map(a => {
492
+ const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type;
493
+ return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`;
494
+ })
495
+ .join(",");
496
+ return { commonName, bloodyMicrosoftSubjectDn };
497
+ }
449
498
  /**
450
499
  * Internal functions exported exclusively for unit testing.
451
500
  * Not part of the public API — do not use outside of test files.
@@ -1 +1 @@
1
- {"version":3,"file":"certInfo.js","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAE9D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAA;AAE7B,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C,2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OAAO,GAAG,QAAQ,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;IACzE,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;IAEZ,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,qBAAqB;IACrB,aAAa;IACb,yBAAyB;CAC1B,CAAA","sourcesContent":["import { createDecipheriv, createHash } from \"crypto\"\nimport * as asn1js from \"asn1js\"\nimport * as pkijs from \"pkijs\"\nimport { Crypto as PeculiarCrypto } from \"@peculiar/webcrypto\"\n\nimport { log } from \"builder-util\"\nimport _fsExtra from \"fs-extra\"\nconst { readFile } = _fsExtra\n\n// OID for codeSigning extended key usage\nconst CODE_SIGNING_OID = \"1.3.6.1.5.5.7.3.3\"\n\n// OID for the PKCS#12 certificate bag type\nconst CERT_BAG_OID = \"1.2.840.113549.1.12.10.1.3\"\n\n// Maps certificate attribute OIDs to their short names.\n// Matches the attributeTypeNames map in the Go reference implementation exactly:\n// https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\nconst ATTRIBUTE_TYPE_NAMES: Record<string, string> = {\n \"2.5.4.6\": \"C\",\n \"2.5.4.10\": \"O\",\n \"2.5.4.11\": \"OU\",\n \"2.5.4.3\": \"CN\",\n \"2.5.4.5\": \"SERIALNUMBER\",\n \"2.5.4.7\": \"L\",\n \"2.5.4.8\": \"ST\",\n \"2.5.4.9\": \"STREET\",\n \"2.5.4.17\": \"POSTALCODE\",\n}\n\n// Characters that must be quoted in a DN value to match Go binary BloodyMsString output\nconst NEEDS_DN_ESCAPING = /[,+\"\\\\<>;]/\n\nfunction escapeDnValue(value: string): string {\n if (NEEDS_DN_ESCAPING.test(value)) {\n // Escape embedded double-quotes by doubling them, then wrap entire value in quotes\n return `\"${value.replace(/\"/g, '\"\"')}\"`\n }\n return value\n}\n\n// Set up the pkijs WebCrypto engine once. @peculiar/webcrypto supports legacy cipher suites\n// (RC2, 3DES) used by real-world CA-issued PFX files, unlike native Node.js WebCrypto.\nconst peculiarCrypto = new PeculiarCrypto()\npkijs.setEngine(\"peculiar\", new pkijs.CryptoEngine({ name: \"peculiar\", crypto: peculiarCrypto as any, subtle: peculiarCrypto.subtle }) as any)\n\nfunction toArrayBuffer(buf: Buffer): ArrayBuffer {\n const ab = new ArrayBuffer(buf.byteLength)\n new Uint8Array(ab).set(buf)\n return ab\n}\n\n// ── PKCS#12 legacy PBE support (RFC 7292 Appendix B) ───────────────────────\n//\n// pkijs's CryptoEngine.decryptEncryptedContentInfo only handles PBES2\n// (OID 1.2.840.113549.1.5.13). Many real-world PFX files use the older\n// pkcs-12PbeIds ciphers (SHA1+3DES, SHA1+2DES, SHA1+RC2-128, SHA1+RC2-40).\n// We implement 3DES/2DES using Node.js's built-in `crypto` module and RC2\n// with a pure-TypeScript RFC 2268 implementation — RC2 was moved to\n// OpenSSL 3's legacy provider (not loaded by default) and is unavailable\n// via `createDecipheriv` in Node.js 22+.\n\n// ── RFC 2268 RC2-CBC implementation ─────────────────────────────────────────\n\n/** Permutation table from RFC 2268. */\nconst RC2_PITABLE = Uint8Array.from([\n 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d, 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44,\n 0x8b, 0xfb, 0xa2, 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32, 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95,\n 0x21, 0x22, 0x5c, 0x6b, 0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 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad,\n])\n\n/** Rotation amounts for R[0], R[1], R[2], R[3] in each mix round. */\nconst RC2_ROT = [1, 2, 3, 5] as const\n\n/**\n * Expand a variable-length key to 64 sixteen-bit subkeys (RFC 2268 Section 2).\n * `effectiveBits` controls the effective key length for export-grade keys\n * (40 = RC2-40, 128 = RC2-128).\n */\nfunction rc2ExpandKey(key: Buffer, effectiveBits: number): number[] {\n // Guard: effectiveBits = 0 causes T8 = 0, making L[128-0] = L[128] an OOB\n // access on a 128-element Uint8Array (silently returns undefined, producing\n // a wrong key schedule). Values > 1024 exceed the RFC 2268 key schedule table.\n if (!Number.isInteger(effectiveBits) || effectiveBits < 1 || effectiveBits > 1024) {\n throw new Error(`rc2ExpandKey: effectiveBits must be an integer in [1, 1024], got ${effectiveBits}`)\n }\n const T = key.length\n const T8 = Math.ceil(effectiveBits / 8)\n // 0xff >> (effectiveBits & 7) gives 0xff for multiples-of-8 effective lengths\n // (no masking), and a smaller mask for non-multiples.\n const TM = 0xff >> (effectiveBits & 7)\n const L = new Uint8Array(128)\n for (let i = 0; i < T; i++) {\n L[i] = key[i]\n }\n for (let i = T; i < 128; i++) {\n L[i] = RC2_PITABLE[(L[i - 1] + L[i - T]) & 0xff]\n }\n L[128 - T8] = RC2_PITABLE[L[128 - T8] & TM]\n for (let i = 127 - T8; i >= 0; i--) {\n L[i] = RC2_PITABLE[L[i + 1] ^ L[i + T8]]\n }\n const K: number[] = new Array(64)\n for (let i = 0; i < 64; i++) {\n K[i] = L[2 * i] | (L[2 * i + 1] << 8)\n }\n return K\n}\n\n/** Rotate a 16-bit word right by `bits` positions. */\nfunction ror16(word: number, bits: number): number {\n return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff)\n}\n\n/**\n * Decrypt `data` using RC2-CBC with PKCS#7 padding removal (RFC 2268).\n *\n * Used for pbeWithSHAAnd40BitRC2CBC (OID 1.2.840.113549.1.12.1.6) and\n * pbeWithSHAAnd128BitRC2CBC (OID 1.2.840.113549.1.12.1.5).\n *\n * These OIDs are commonly used to encrypt certificate bags in PKCS#12\n * files produced by OpenSSL and Windows with default settings. Node.js 22+\n * (OpenSSL 3 default provider) does not support RC2 via `createDecipheriv`.\n */\nfunction rc2CbcDecrypt(key: Buffer, iv: Buffer, data: Buffer, effectiveBits: number): Buffer {\n // Guard: a non-multiple-of-8 ciphertext causes the last partial block to be\n // processed with `undefined` bytes. In JS, `undefined | (undefined << 8)`\n // produces NaN, and `NaN & 0xffff` produces 0 — so partial blocks silently\n // produce garbage output rather than throwing.\n if (data.length === 0 || data.length % 8 !== 0) {\n throw new Error(`rc2CbcDecrypt: ciphertext length ${data.length} is not a positive multiple of the 8-byte RC2 block size`)\n }\n if (iv.length !== 8) {\n throw new Error(`rc2CbcDecrypt: IV must be exactly 8 bytes, got ${iv.length}`)\n }\n const K = rc2ExpandKey(key, effectiveBits)\n const out = Buffer.alloc(data.length)\n const prev = Buffer.from(iv) // CBC running state; starts as the IV\n\n for (let offset = 0; offset < data.length; offset += 8) {\n const ct = data.subarray(offset, offset + 8)\n // Parse ciphertext block as four little-endian 16-bit words\n const R = [(ct[0] | (ct[1] << 8)) & 0xffff, (ct[2] | (ct[3] << 8)) & 0xffff, (ct[4] | (ct[5] << 8)) & 0xffff, (ct[6] | (ct[7] << 8)) & 0xffff]\n\n // Reverse the encryption round plan [5 mix, 1 mash, 6 mix, 1 mash, 5 mix].\n // For decryption j starts at 63 and decrements in each reverse-mix step.\n let j = 63\n\n const rMix = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = ror16(R[i], RC2_ROT[i])\n const r3 = R[(i + 3) % 4]\n R[i] = (R[i] - K[j] - (r3 & R[(i + 2) % 4]) - (~r3 & 0xffff & R[(i + 1) % 4])) & 0xffff\n j--\n }\n }\n\n const rMash = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = (R[i] - K[R[(i + 3) % 4] & 63]) & 0xffff\n }\n }\n\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 6; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n\n // XOR decrypted words with previous ciphertext block (CBC mode)\n for (let i = 0; i < 4; i++) {\n out[offset + i * 2] = (R[i] & 0xff) ^ prev[i * 2]\n out[offset + i * 2 + 1] = (R[i] >> 8) ^ prev[i * 2 + 1]\n }\n // Advance CBC state to current ciphertext block\n ct.copy(prev)\n }\n\n // Validate and strip PKCS#7 padding.\n // Without this guard, padLen = 0 silently returns the full buffer (no stripping)\n // and padLen > 8 causes Buffer.subarray(0, negative) → empty buffer, both\n // silently. A wrong key/IV produces decrypted bytes that fail this check.\n const padLen = out[out.length - 1]\n if (padLen < 1 || padLen > 8) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 pad byte 0x${padLen.toString(16).padStart(2, \"0\")} — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n for (let i = out.length - padLen; i < out.length; i++) {\n if (out[i] !== padLen) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 padding — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n }\n return out.subarray(0, out.length - padLen)\n}\n\n/** PKCS#12 legacy PBE OIDs (pkcs-12PbeIds) and their cipher parameters. */\nconst PKCS12_PBE_ALGOS: Record<string, { cipher: string; keyLen: number; ivLen: number; rc2Bits?: number }> = {\n \"1.2.840.113549.1.12.1.3\": { cipher: \"des-ede3-cbc\", keyLen: 24, ivLen: 8 }, // pbeWithSHAAnd3KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.4\": { cipher: \"des-ede-cbc\", keyLen: 16, ivLen: 8 }, // pbeWithSHAAnd2KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.5\": { cipher: \"rc2-cbc\", keyLen: 16, ivLen: 8, rc2Bits: 128 }, // pbeWithSHAAnd128BitRC2CBC\n \"1.2.840.113549.1.12.1.6\": { cipher: \"rc2-cbc\", keyLen: 5, ivLen: 8, rc2Bits: 40 }, // pbeWithSHAAnd40BitRC2CBC\n}\n\n/**\n * Maximum PKCS#12 PBE iteration count accepted.\n *\n * A maliciously crafted PFX can set iterations to Number.MAX_SAFE_INTEGER,\n * causing the SHA-1 loop to run for an arbitrary amount of time (DoS).\n * Real-world PFX files use 1 000–50 000 iterations; this cap is generous\n * enough to accommodate even unusually high-security certs while blocking\n * obviously hostile inputs.\n */\nconst MAX_PKCS12_PBE_ITERATIONS = 300_000\n\n/**\n * PKCS#12 key/IV derivation function from RFC 7292 Appendix B (SHA-1 variant).\n * id = 1 to derive a key, id = 2 to derive an IV.\n *\n * Throws if `iterations` is outside [1, MAX_PKCS12_PBE_ITERATIONS] to prevent\n * CPU exhaustion from a crafted PFX file.\n */\nfunction pkcs12PbeDeriveKey(password: Buffer, salt: Buffer, iterations: number, id: number, length: number): Buffer {\n if (!Number.isInteger(iterations) || iterations < 1 || iterations > MAX_PKCS12_PBE_ITERATIONS) {\n throw new Error(\n `PKCS#12 PBE iteration count ${iterations} is outside safe range [1, ${MAX_PKCS12_PBE_ITERATIONS}]; refusing to process — the file may be crafted to exhaust CPU`\n )\n }\n // A crafted PFX could supply a multi-megabyte salt, causing Buffer.alloc(sLen) inside\n // the KDF to allocate gigabytes (sLen = ceil(salt.length / 64) * 64).\n const MAX_SALT_BYTES = 4096\n if (salt.length > MAX_SALT_BYTES) {\n throw new Error(`PKCS#12 PBE salt length ${salt.length} exceeds the safe maximum of ${MAX_SALT_BYTES} bytes — the file may be crafted to exhaust memory`)\n }\n\n const u = 20 // SHA-1 output bytes\n const v = 64 // SHA-1 block bytes\n\n // Step 1: D = ID byte repeated v times\n const D = Buffer.alloc(v, id)\n\n // Step 2: S = salt bytes repeated to fill ceil(salt.length / v) * v bytes\n const sLen = salt.length > 0 ? Math.ceil(salt.length / v) * v : 0\n const S = Buffer.alloc(sLen)\n for (let i = 0; i < sLen; i++) {\n S[i] = salt[i % salt.length]\n }\n\n // Step 3: P = password bytes repeated to fill ceil(password.length / v) * v bytes\n const pLen = password.length > 0 ? Math.ceil(password.length / v) * v : 0\n const P = Buffer.alloc(pLen)\n for (let i = 0; i < pLen; i++) {\n P[i] = password[i % password.length]\n }\n\n // Step 4: I = S || P (mutable, updated in step 6C)\n const I = new Uint8Array(Buffer.concat([S, P]))\n\n const c = Math.ceil(length / u)\n const result = Buffer.alloc(c * u)\n\n for (let i = 0; i < c; i++) {\n // Step 6A: A_i = H^iterations(D || I)\n let Ai: Buffer = createHash(\"sha1\").update(D).update(Buffer.from(I)).digest()\n for (let j = 1; j < iterations; j++) {\n Ai = createHash(\"sha1\").update(Ai).digest()\n }\n Ai.copy(result, i * u)\n\n // Step 6B: B = A_i repeated to fill v bytes\n const B = new Uint8Array(v)\n for (let j = 0; j < v; j++) {\n B[j] = Ai[j % u]\n }\n\n // Step 6C: each v-byte block of I is incremented by (B + 1) mod 2^(v*8)\n const blockCount = Math.ceil(I.length / v)\n for (let j = 0; j < blockCount; j++) {\n let carry = 1\n for (let b = v - 1; b >= 0; b--) {\n const idx = j * v + b\n if (idx < I.length) {\n const sum = I[idx] + B[b] + carry\n I[idx] = sum & 0xff\n carry = sum >> 8\n }\n }\n }\n }\n\n return result.subarray(0, length)\n}\n\n/**\n * Encode a password as UTF-16 Big Endian with a null terminator, which is the\n * format required by PKCS#12 PBE key derivation (RFC 7292).\n * An empty string yields [0x00, 0x00] (just the null terminator).\n */\nfunction pkcs12PasswordToUtf16(password: string): Buffer {\n const buf = Buffer.alloc((password.length + 1) * 2)\n for (let i = 0; i < password.length; i++) {\n const code = password.charCodeAt(i)\n buf[i * 2] = (code >> 8) & 0xff\n buf[i * 2 + 1] = code & 0xff\n }\n // Last two bytes are already 0x00 0x00 (null terminator) from Buffer.alloc.\n return buf\n}\n\n/**\n * Decrypt PKCS#12 legacy PBE encrypted content using Node.js crypto.\n *\n * @param algId - OID from PKCS12_PBE_ALGOS\n * @param algParams - asn1js object for PKCS12PBEParams (SEQUENCE { OCTET STRING, INTEGER })\n * @param encContent - asn1js object for the encrypted content (Constructed or Primitive [0] IMPLICIT)\n * @param password - plain-text password string\n */\nfunction decryptLegacyPkcs12Pbe(algId: string, algParams: any, encContent: any, password: string): Buffer {\n const algo = PKCS12_PBE_ALGOS[algId]\n\n // PKCS12PBEParams ::= SEQUENCE { salt OCTET STRING, iterations INTEGER }\n const salt = Buffer.from(algParams.valueBlock.value[0].valueBlock.valueHexView)\n const iterations = Number(algParams.valueBlock.value[1].valueBlock.valueDec)\n\n const pwdBytes = pkcs12PasswordToUtf16(password)\n const key = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 1, algo.keyLen)\n const iv = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 2, algo.ivLen)\n\n // Extract raw encrypted bytes from the [0] IMPLICIT OCTET STRING.\n // The encryptedContent field can be a Constructed (fragmented) or Primitive tag.\n let encBytes: Buffer\n if (encContent.idBlock?.isConstructed) {\n encBytes = Buffer.concat((encContent.valueBlock.value as any[]).map((p: any) => Buffer.from(p.valueBlock.valueHexView)))\n } else {\n encBytes = Buffer.from(encContent.valueBlock.valueHexView)\n }\n\n if (algo.rc2Bits != null) {\n // RC2 is not available in Node.js 22+ via createDecipheriv (OpenSSL 3 moved\n // it to the legacy provider which is not loaded by default). Use our pure-TS\n // RFC 2268 implementation instead.\n return rc2CbcDecrypt(key, iv, encBytes, algo.rc2Bits)\n }\n\n const decipher = createDecipheriv(algo.cipher, key, iv)\n return Buffer.concat([decipher.update(encBytes), decipher.final()])\n}\n\n/**\n * Reads certificate info from a PKCS#12 (.pfx) file using pkijs (unobfuscated TypeScript).\n * Mirrors the `certificate-info` subcommand of app-builder-bin.\n * https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\n *\n * Returns { commonName, bloodyMicrosoftSubjectDn } on success.\n *\n * Known divergences from the Go binary:\n * - No OpenSSL fallback when the pure PKCS#12 decoder fails for a non-password reason.\n * - Unknown OIDs are rendered using the raw numeric OID as the type name (e.g. `2.5.4.100=value`); Go uses `OID=#hexbytes` when ASN.1 marshal succeeds.\n * - RDN ordering uses DER order; Go normalizes via pkix.Name.ToRDNSequence then reverses via\n * BloodyMsString. These coincide for pkijs-generated certs (CN-first DER) but may\n * differ for real CA-issued certs stored in traditional C-first DER order.\n */\nexport async function readCertInfo(file: string, password: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string }> {\n const pfxDer = await readFile(file)\n\n // asn1js requires a plain ArrayBuffer\n const pfxBuf = toArrayBuffer(pfxDer)\n let asn1: ReturnType<typeof asn1js.fromBER>\n try {\n asn1 = asn1js.fromBER(pfxBuf)\n if (asn1.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n } catch (err) {\n throw new Error(`PKCS#12 file \"${file}\" contains invalid ASN.1/DER data: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const pfx = new pkijs.PFX({ schema: asn1.result })\n const pwBuf = toArrayBuffer(Buffer.from(password, \"utf-8\"))\n\n // Step 1: Verify MAC (or signature) integrity and parse the AuthenticatedSafe container.\n // pkijs throws \"Integrity for the PKCS#12 data is broken!\" on wrong password.\n try {\n await pfx.parseInternalValues({ password: pwBuf, checkIntegrity: true })\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err)\n const lower = detail.toLowerCase()\n if (lower.includes(\"integrity\") || lower.includes(\"mac\") || lower.includes(\"password\") || lower.includes(\"pkcs#12\")) {\n throw new Error(`password incorrect for certificate file \"${file}\" — verify the password matches the PFX. pkijs detail: ${detail}`)\n }\n log.debug({ file, error: detail }, \"pkijs failed to decode PKCS#12; no OpenSSL fallback available in Node.js\")\n throw new Error(`Failed to decode PKCS#12 file \"${file}\" — the file may be corrupt, use an unsupported cipher, or require OpenSSL. pkijs detail: ${detail}`)\n }\n\n const authSafe = pfx.parsedValue?.authenticatedSafe\n if (authSafe == null) {\n throw new Error(`Failed to parse AuthenticatedSafe in PKCS#12 file \"${file}\"`)\n }\n\n // Step 2: Iterate over the authenticated-safe ContentInfos and extract all certificates.\n //\n // We do NOT call authSafe.parseInternalValues() because pkijs's CryptoEngine only handles\n // PBES2 (OID 1.2.840.113549.1.5.13) for EncryptedData. Real-world PFX files (including\n // CA-issued and electron-builder-generated certs) often use the older pkcs-12PbeIds ciphers\n // (e.g. pbeWithSHAAnd3KeyTripleDESCBC). We handle those with our own Node.js crypto path.\n const certs: pkijs.Certificate[] = []\n\n for (const ci of authSafe.safeContents) {\n let safeBER: ArrayBuffer\n\n if (ci.contentType === pkijs.id_ContentType_Data) {\n // Data: content is an OCTET STRING containing DER-encoded SafeContents.\n safeBER = (ci.content as asn1js.OctetString).getValue()\n } else if (ci.contentType === pkijs.id_ContentType_EncryptedData) {\n // EncryptedData: decrypt the SafeContents, routing by algorithm OID.\n const encData = new pkijs.EncryptedData({ schema: ci.content })\n const algId = encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId\n\n if (Object.prototype.hasOwnProperty.call(PKCS12_PBE_ALGOS, algId)) {\n // Legacy PKCS#12 PBE (pbeWithSHAAnd*) — use our RFC 7292 implementation.\n const decrypted = decryptLegacyPkcs12Pbe(\n algId,\n encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams,\n encData.encryptedContentInfo.encryptedContent,\n password\n )\n safeBER = toArrayBuffer(decrypted)\n } else {\n // PBES2 or other modern OID — delegate to the pkijs engine.\n safeBER = await encData.decrypt({ password: pwBuf })\n }\n } else {\n // EnvelopedData or other types — skip (not needed for cert extraction).\n continue\n }\n\n // Parse SafeContents and collect X.509 certificates from cert bags.\n const sc = pkijs.SafeContents.fromBER(safeBER)\n for (const bag of sc.safeBags) {\n if (bag.bagId === CERT_BAG_OID) {\n const certBag = bag.bagValue as pkijs.CertBag\n if (certBag.parsedValue instanceof pkijs.Certificate) {\n certs.push(certBag.parsedValue)\n }\n }\n }\n }\n\n if (certs.length === 0) {\n throw new Error(`No certificates found in PKCS#12 file \"${file}\" — the file may be a key-only PFX or be empty`)\n }\n\n // Find the certificate with the codeSigning Extended Key Usage.\n // pkijs auto-parses known extensions via ExtensionValueFactory (registered at module init).\n const signingCert = certs.find(cert => {\n const ekuExt = cert.extensions?.find(e => e.extnID === pkijs.id_ExtKeyUsage)\n if (ekuExt == null) {\n return false\n }\n if (ekuExt.parsedValue instanceof pkijs.ExtKeyUsage) {\n return ekuExt.parsedValue.keyPurposes.includes(CODE_SIGNING_OID)\n }\n // Fallback: manually parse the extension OctetString value.\n try {\n const inner = asn1js.fromBER(ekuExt.extnValue.valueBlock.valueHexView)\n if (inner.offset === -1) {\n return false\n }\n const eku = new pkijs.ExtKeyUsage({ schema: inner.result })\n return eku.keyPurposes.includes(CODE_SIGNING_OID)\n } catch {\n return false\n }\n })\n\n if (signingCert == null) {\n throw new Error(\n `No certificate with ExtKeyUsageCodeSigning found in \"${file}\" — ${certs.length} certificate(s) present but none have the codeSigning extended key usage. ` +\n `Ensure the PFX contains a code-signing certificate, not just a CA or TLS certificate.`\n )\n }\n\n const cnAttr = signingCert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n const commonName = String(cnAttr?.value.valueBlock.value ?? \"\")\n\n // Format DN as \"CN=X,O=X,...\" matching Go's BloodyMsString output.\n // Uses ATTRIBUTE_TYPE_NAMES to mirror Go's attributeTypeNames map exactly, so STREET,\n // POSTALCODE, and SERIALNUMBER (present in EV code-signing certs) are handled correctly.\n // Unknown OIDs fall back to the bare OID string as the type name.\n const bloodyMicrosoftSubjectDn = signingCert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn }\n}\n\n/**\n * Internal functions exported exclusively for unit testing.\n * Not part of the public API — do not use outside of test files.\n */\nexport const _testingOnly = {\n pkcs12PbeDeriveKey,\n pkcs12PasswordToUtf16,\n rc2CbcDecrypt,\n MAX_PKCS12_PBE_ITERATIONS,\n}\n"]}
1
+ {"version":3,"file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AC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;IACzE,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;IAEZ,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,qBAAqB;IACrB,aAAa;IACb,yBAAyB;CAC1B,CAAA","sourcesContent":["import { createDecipheriv, createHash } from \"crypto\"\nimport * as asn1js from \"asn1js\"\nimport * as pkijs from \"pkijs\"\nimport { Crypto as PeculiarCrypto } from \"@peculiar/webcrypto\"\n\nimport { log } from \"builder-util\"\nimport _fsExtra from \"fs-extra\"\nconst { readFile } = _fsExtra\n\n// OID for codeSigning extended key usage\nconst CODE_SIGNING_OID = \"1.3.6.1.5.5.7.3.3\"\n\n// OID for the PKCS#12 certificate bag type\nconst CERT_BAG_OID = \"1.2.840.113549.1.12.10.1.3\"\n\n// Maps certificate attribute OIDs to their short names.\n// Matches the attributeTypeNames map in the Go reference implementation exactly:\n// https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\nconst ATTRIBUTE_TYPE_NAMES: Record<string, string> = {\n \"2.5.4.6\": \"C\",\n \"2.5.4.10\": \"O\",\n \"2.5.4.11\": \"OU\",\n \"2.5.4.3\": \"CN\",\n \"2.5.4.5\": \"SERIALNUMBER\",\n \"2.5.4.7\": \"L\",\n \"2.5.4.8\": \"ST\",\n \"2.5.4.9\": \"STREET\",\n \"2.5.4.17\": \"POSTALCODE\",\n}\n\n// Characters that must be quoted in a DN value to match Go binary BloodyMsString output\nconst NEEDS_DN_ESCAPING = /[,+\"\\\\<>;]/\n\nfunction escapeDnValue(value: string): string {\n if (NEEDS_DN_ESCAPING.test(value)) {\n // Escape embedded double-quotes by doubling them, then wrap entire value in quotes\n return `\"${value.replace(/\"/g, '\"\"')}\"`\n }\n return value\n}\n\n// Set up the pkijs WebCrypto engine once. @peculiar/webcrypto supports legacy cipher suites\n// (RC2, 3DES) used by real-world CA-issued PFX files, unlike native Node.js WebCrypto.\nconst peculiarCrypto = new PeculiarCrypto()\npkijs.setEngine(\"peculiar\", new pkijs.CryptoEngine({ name: \"peculiar\", crypto: peculiarCrypto as any, subtle: peculiarCrypto.subtle }) as any)\n\nfunction toArrayBuffer(buf: Buffer): ArrayBuffer {\n const ab = new ArrayBuffer(buf.byteLength)\n new Uint8Array(ab).set(buf)\n return ab\n}\n\n// ── PKCS#12 legacy PBE support (RFC 7292 Appendix B) ───────────────────────\n//\n// pkijs's CryptoEngine.decryptEncryptedContentInfo only handles PBES2\n// (OID 1.2.840.113549.1.5.13). Many real-world PFX files use the older\n// pkcs-12PbeIds ciphers (SHA1+3DES, SHA1+2DES, SHA1+RC2-128, SHA1+RC2-40).\n// We implement 3DES/2DES using Node.js's built-in `crypto` module and RC2\n// with a pure-TypeScript RFC 2268 implementation — RC2 was moved to\n// OpenSSL 3's legacy provider (not loaded by default) and is unavailable\n// via `createDecipheriv` in Node.js 22+.\n\n// ── RFC 2268 RC2-CBC implementation ─────────────────────────────────────────\n\n/** Permutation table from RFC 2268. */\nconst RC2_PITABLE = Uint8Array.from([\n 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d, 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44,\n 0x8b, 0xfb, 0xa2, 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32, 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95,\n 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82, 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 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0xad,\n])\n\n/** Rotation amounts for R[0], R[1], R[2], R[3] in each mix round. */\nconst RC2_ROT = [1, 2, 3, 5] as const\n\n/**\n * Expand a variable-length key to 64 sixteen-bit subkeys (RFC 2268 Section 2).\n * `effectiveBits` controls the effective key length for export-grade keys\n * (40 = RC2-40, 128 = RC2-128).\n */\nfunction rc2ExpandKey(key: Buffer, effectiveBits: number): number[] {\n // Guard: effectiveBits = 0 causes T8 = 0, making L[128-0] = L[128] an OOB\n // access on a 128-element Uint8Array (silently returns undefined, producing\n // a wrong key schedule). Values > 1024 exceed the RFC 2268 key schedule table.\n if (!Number.isInteger(effectiveBits) || effectiveBits < 1 || effectiveBits > 1024) {\n throw new Error(`rc2ExpandKey: effectiveBits must be an integer in [1, 1024], got ${effectiveBits}`)\n }\n const T = key.length\n const T8 = Math.ceil(effectiveBits / 8)\n // 0xff >> (effectiveBits & 7) gives 0xff for multiples-of-8 effective lengths\n // (no masking), and a smaller mask for non-multiples.\n const TM = 0xff >> (effectiveBits & 7)\n const L = new Uint8Array(128)\n for (let i = 0; i < T; i++) {\n L[i] = key[i]\n }\n for (let i = T; i < 128; i++) {\n L[i] = RC2_PITABLE[(L[i - 1] + L[i - T]) & 0xff]\n }\n L[128 - T8] = RC2_PITABLE[L[128 - T8] & TM]\n for (let i = 127 - T8; i >= 0; i--) {\n L[i] = RC2_PITABLE[L[i + 1] ^ L[i + T8]]\n }\n const K: number[] = new Array(64)\n for (let i = 0; i < 64; i++) {\n K[i] = L[2 * i] | (L[2 * i + 1] << 8)\n }\n return K\n}\n\n/** Rotate a 16-bit word right by `bits` positions. */\nfunction ror16(word: number, bits: number): number {\n return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff)\n}\n\n/**\n * Decrypt `data` using RC2-CBC with PKCS#7 padding removal (RFC 2268).\n *\n * Used for pbeWithSHAAnd40BitRC2CBC (OID 1.2.840.113549.1.12.1.6) and\n * pbeWithSHAAnd128BitRC2CBC (OID 1.2.840.113549.1.12.1.5).\n *\n * These OIDs are commonly used to encrypt certificate bags in PKCS#12\n * files produced by OpenSSL and Windows with default settings. Node.js 22+\n * (OpenSSL 3 default provider) does not support RC2 via `createDecipheriv`.\n */\nfunction rc2CbcDecrypt(key: Buffer, iv: Buffer, data: Buffer, effectiveBits: number): Buffer {\n // Guard: a non-multiple-of-8 ciphertext causes the last partial block to be\n // processed with `undefined` bytes. In JS, `undefined | (undefined << 8)`\n // produces NaN, and `NaN & 0xffff` produces 0 — so partial blocks silently\n // produce garbage output rather than throwing.\n if (data.length === 0 || data.length % 8 !== 0) {\n throw new Error(`rc2CbcDecrypt: ciphertext length ${data.length} is not a positive multiple of the 8-byte RC2 block size`)\n }\n if (iv.length !== 8) {\n throw new Error(`rc2CbcDecrypt: IV must be exactly 8 bytes, got ${iv.length}`)\n }\n const K = rc2ExpandKey(key, effectiveBits)\n const out = Buffer.alloc(data.length)\n const prev = Buffer.from(iv) // CBC running state; starts as the IV\n\n for (let offset = 0; offset < data.length; offset += 8) {\n const ct = data.subarray(offset, offset + 8)\n // Parse ciphertext block as four little-endian 16-bit words\n const R = [(ct[0] | (ct[1] << 8)) & 0xffff, (ct[2] | (ct[3] << 8)) & 0xffff, (ct[4] | (ct[5] << 8)) & 0xffff, (ct[6] | (ct[7] << 8)) & 0xffff]\n\n // Reverse the encryption round plan [5 mix, 1 mash, 6 mix, 1 mash, 5 mix].\n // For decryption j starts at 63 and decrements in each reverse-mix step.\n let j = 63\n\n const rMix = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = ror16(R[i], RC2_ROT[i])\n const r3 = R[(i + 3) % 4]\n R[i] = (R[i] - K[j] - (r3 & R[(i + 2) % 4]) - (~r3 & 0xffff & R[(i + 1) % 4])) & 0xffff\n j--\n }\n }\n\n const rMash = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = (R[i] - K[R[(i + 3) % 4] & 63]) & 0xffff\n }\n }\n\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 6; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n\n // XOR decrypted words with previous ciphertext block (CBC mode)\n for (let i = 0; i < 4; i++) {\n out[offset + i * 2] = (R[i] & 0xff) ^ prev[i * 2]\n out[offset + i * 2 + 1] = (R[i] >> 8) ^ prev[i * 2 + 1]\n }\n // Advance CBC state to current ciphertext block\n ct.copy(prev)\n }\n\n // Validate and strip PKCS#7 padding.\n // Without this guard, padLen = 0 silently returns the full buffer (no stripping)\n // and padLen > 8 causes Buffer.subarray(0, negative) → empty buffer, both\n // silently. A wrong key/IV produces decrypted bytes that fail this check.\n const padLen = out[out.length - 1]\n if (padLen < 1 || padLen > 8) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 pad byte 0x${padLen.toString(16).padStart(2, \"0\")} — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n for (let i = out.length - padLen; i < out.length; i++) {\n if (out[i] !== padLen) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 padding — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n }\n return out.subarray(0, out.length - padLen)\n}\n\n/** PKCS#12 legacy PBE OIDs (pkcs-12PbeIds) and their cipher parameters. */\nconst PKCS12_PBE_ALGOS: Record<string, { cipher: string; keyLen: number; ivLen: number; rc2Bits?: number }> = {\n \"1.2.840.113549.1.12.1.3\": { cipher: \"des-ede3-cbc\", keyLen: 24, ivLen: 8 }, // pbeWithSHAAnd3KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.4\": { cipher: \"des-ede-cbc\", keyLen: 16, ivLen: 8 }, // pbeWithSHAAnd2KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.5\": { cipher: \"rc2-cbc\", keyLen: 16, ivLen: 8, rc2Bits: 128 }, // pbeWithSHAAnd128BitRC2CBC\n \"1.2.840.113549.1.12.1.6\": { cipher: \"rc2-cbc\", keyLen: 5, ivLen: 8, rc2Bits: 40 }, // pbeWithSHAAnd40BitRC2CBC\n}\n\n/**\n * Maximum PKCS#12 PBE iteration count accepted.\n *\n * A maliciously crafted PFX can set iterations to Number.MAX_SAFE_INTEGER,\n * causing the SHA-1 loop to run for an arbitrary amount of time (DoS).\n * Real-world PFX files use 1 000–50 000 iterations; this cap is generous\n * enough to accommodate even unusually high-security certs while blocking\n * obviously hostile inputs.\n */\nconst MAX_PKCS12_PBE_ITERATIONS = 300_000\n\n/**\n * PKCS#12 key/IV derivation function from RFC 7292 Appendix B (SHA-1 variant).\n * id = 1 to derive a key, id = 2 to derive an IV.\n *\n * Throws if `iterations` is outside [1, MAX_PKCS12_PBE_ITERATIONS] to prevent\n * CPU exhaustion from a crafted PFX file.\n */\nfunction pkcs12PbeDeriveKey(password: Buffer, salt: Buffer, iterations: number, id: number, length: number): Buffer {\n if (!Number.isInteger(iterations) || iterations < 1 || iterations > MAX_PKCS12_PBE_ITERATIONS) {\n throw new Error(\n `PKCS#12 PBE iteration count ${iterations} is outside safe range [1, ${MAX_PKCS12_PBE_ITERATIONS}]; refusing to process — the file may be crafted to exhaust CPU`\n )\n }\n // A crafted PFX could supply a multi-megabyte salt, causing Buffer.alloc(sLen) inside\n // the KDF to allocate gigabytes (sLen = ceil(salt.length / 64) * 64).\n const MAX_SALT_BYTES = 4096\n if (salt.length > MAX_SALT_BYTES) {\n throw new Error(`PKCS#12 PBE salt length ${salt.length} exceeds the safe maximum of ${MAX_SALT_BYTES} bytes — the file may be crafted to exhaust memory`)\n }\n\n const u = 20 // SHA-1 output bytes\n const v = 64 // SHA-1 block bytes\n\n // Step 1: D = ID byte repeated v times\n const D = Buffer.alloc(v, id)\n\n // Step 2: S = salt bytes repeated to fill ceil(salt.length / v) * v bytes\n const sLen = salt.length > 0 ? Math.ceil(salt.length / v) * v : 0\n const S = Buffer.alloc(sLen)\n for (let i = 0; i < sLen; i++) {\n S[i] = salt[i % salt.length]\n }\n\n // Step 3: P = password bytes repeated to fill ceil(password.length / v) * v bytes\n const pLen = password.length > 0 ? Math.ceil(password.length / v) * v : 0\n const P = Buffer.alloc(pLen)\n for (let i = 0; i < pLen; i++) {\n P[i] = password[i % password.length]\n }\n\n // Step 4: I = S || P (mutable, updated in step 6C)\n const I = new Uint8Array(Buffer.concat([S, P]))\n\n const c = Math.ceil(length / u)\n const result = Buffer.alloc(c * u)\n\n for (let i = 0; i < c; i++) {\n // Step 6A: A_i = H^iterations(D || I)\n let Ai: Buffer = createHash(\"sha1\").update(D).update(Buffer.from(I)).digest()\n for (let j = 1; j < iterations; j++) {\n Ai = createHash(\"sha1\").update(Ai).digest()\n }\n Ai.copy(result, i * u)\n\n // Step 6B: B = A_i repeated to fill v bytes\n const B = new Uint8Array(v)\n for (let j = 0; j < v; j++) {\n B[j] = Ai[j % u]\n }\n\n // Step 6C: each v-byte block of I is incremented by (B + 1) mod 2^(v*8)\n const blockCount = Math.ceil(I.length / v)\n for (let j = 0; j < blockCount; j++) {\n let carry = 1\n for (let b = v - 1; b >= 0; b--) {\n const idx = j * v + b\n if (idx < I.length) {\n const sum = I[idx] + B[b] + carry\n I[idx] = sum & 0xff\n carry = sum >> 8\n }\n }\n }\n }\n\n return result.subarray(0, length)\n}\n\n/**\n * Encode a password as UTF-16 Big Endian with a null terminator, which is the\n * format required by PKCS#12 PBE key derivation (RFC 7292).\n * An empty string yields [0x00, 0x00] (just the null terminator).\n */\nfunction pkcs12PasswordToUtf16(password: string): Buffer {\n const buf = Buffer.alloc((password.length + 1) * 2)\n for (let i = 0; i < password.length; i++) {\n const code = password.charCodeAt(i)\n buf[i * 2] = (code >> 8) & 0xff\n buf[i * 2 + 1] = code & 0xff\n }\n // Last two bytes are already 0x00 0x00 (null terminator) from Buffer.alloc.\n return buf\n}\n\n/**\n * Decrypt PKCS#12 legacy PBE encrypted content using Node.js crypto.\n *\n * @param algId - OID from PKCS12_PBE_ALGOS\n * @param algParams - asn1js object for PKCS12PBEParams (SEQUENCE { OCTET STRING, INTEGER })\n * @param encContent - asn1js object for the encrypted content (Constructed or Primitive [0] IMPLICIT)\n * @param password - plain-text password string\n */\nfunction decryptLegacyPkcs12Pbe(algId: string, algParams: any, encContent: any, password: string): Buffer {\n const algo = PKCS12_PBE_ALGOS[algId]\n\n // PKCS12PBEParams ::= SEQUENCE { salt OCTET STRING, iterations INTEGER }\n const salt = Buffer.from(algParams.valueBlock.value[0].valueBlock.valueHexView)\n const iterations = Number(algParams.valueBlock.value[1].valueBlock.valueDec)\n\n const pwdBytes = pkcs12PasswordToUtf16(password)\n const key = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 1, algo.keyLen)\n const iv = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 2, algo.ivLen)\n\n // Extract raw encrypted bytes from the [0] IMPLICIT OCTET STRING.\n // The encryptedContent field can be a Constructed (fragmented) or Primitive tag.\n let encBytes: Buffer\n if (encContent.idBlock?.isConstructed) {\n encBytes = Buffer.concat((encContent.valueBlock.value as any[]).map((p: any) => Buffer.from(p.valueBlock.valueHexView)))\n } else {\n encBytes = Buffer.from(encContent.valueBlock.valueHexView)\n }\n\n if (algo.rc2Bits != null) {\n // RC2 is not available in Node.js 22+ via createDecipheriv (OpenSSL 3 moved\n // it to the legacy provider which is not loaded by default). Use our pure-TS\n // RFC 2268 implementation instead.\n return rc2CbcDecrypt(key, iv, encBytes, algo.rc2Bits)\n }\n\n const decipher = createDecipheriv(algo.cipher, key, iv)\n return Buffer.concat([decipher.update(encBytes), decipher.final()])\n}\n\n/**\n * Reads certificate info from a PKCS#12 (.pfx) file using pkijs (unobfuscated TypeScript).\n * Mirrors the `certificate-info` subcommand of app-builder-bin.\n * https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\n *\n * Returns { commonName, bloodyMicrosoftSubjectDn } on success.\n *\n * Known divergences from the Go binary:\n * - No OpenSSL fallback when the pure PKCS#12 decoder fails for a non-password reason.\n * - Unknown OIDs are rendered using the raw numeric OID as the type name (e.g. `2.5.4.100=value`); Go uses `OID=#hexbytes` when ASN.1 marshal succeeds.\n * - RDN ordering uses DER order; Go normalizes via pkix.Name.ToRDNSequence then reverses via\n * BloodyMsString. These coincide for pkijs-generated certs (CN-first DER) but may\n * differ for real CA-issued certs stored in traditional C-first DER order.\n */\nexport async function readCertInfo(file: string, password: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string }> {\n const pfxDer = await readFile(file)\n\n // asn1js requires a plain ArrayBuffer\n const pfxBuf = toArrayBuffer(pfxDer)\n let asn1: ReturnType<typeof asn1js.fromBER>\n try {\n asn1 = asn1js.fromBER(pfxBuf)\n if (asn1.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n } catch (err) {\n throw new Error(`PKCS#12 file \"${file}\" contains invalid ASN.1/DER data: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const pfx = new pkijs.PFX({ schema: asn1.result })\n const pwBuf = toArrayBuffer(Buffer.from(password, \"utf-8\"))\n\n // Step 1: Verify MAC (or signature) integrity and parse the AuthenticatedSafe container.\n // pkijs throws \"Integrity for the PKCS#12 data is broken!\" on wrong password.\n try {\n await pfx.parseInternalValues({ password: pwBuf, checkIntegrity: true })\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err)\n const lower = detail.toLowerCase()\n if (lower.includes(\"integrity\") || lower.includes(\"mac\") || lower.includes(\"password\") || lower.includes(\"pkcs#12\")) {\n throw new Error(`password incorrect for certificate file \"${file}\" — verify the password matches the PFX. pkijs detail: ${detail}`)\n }\n log.debug({ file, error: detail }, \"pkijs failed to decode PKCS#12; no OpenSSL fallback available in Node.js\")\n throw new Error(`Failed to decode PKCS#12 file \"${file}\" — the file may be corrupt, use an unsupported cipher, or require OpenSSL. pkijs detail: ${detail}`)\n }\n\n const authSafe = pfx.parsedValue?.authenticatedSafe\n if (authSafe == null) {\n throw new Error(`Failed to parse AuthenticatedSafe in PKCS#12 file \"${file}\"`)\n }\n\n // Step 2: Iterate over the authenticated-safe ContentInfos and extract all certificates.\n //\n // We do NOT call authSafe.parseInternalValues() because pkijs's CryptoEngine only handles\n // PBES2 (OID 1.2.840.113549.1.5.13) for EncryptedData. Real-world PFX files (including\n // CA-issued and electron-builder-generated certs) often use the older pkcs-12PbeIds ciphers\n // (e.g. pbeWithSHAAnd3KeyTripleDESCBC). We handle those with our own Node.js crypto path.\n const certs: pkijs.Certificate[] = []\n\n for (const ci of authSafe.safeContents) {\n let safeBER: ArrayBuffer\n\n if (ci.contentType === pkijs.id_ContentType_Data) {\n // Data: content is an OCTET STRING containing DER-encoded SafeContents.\n safeBER = (ci.content as asn1js.OctetString).getValue()\n } else if (ci.contentType === pkijs.id_ContentType_EncryptedData) {\n // EncryptedData: decrypt the SafeContents, routing by algorithm OID.\n const encData = new pkijs.EncryptedData({ schema: ci.content })\n const algId = encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId\n\n if (Object.prototype.hasOwnProperty.call(PKCS12_PBE_ALGOS, algId)) {\n // Legacy PKCS#12 PBE (pbeWithSHAAnd*) — use our RFC 7292 implementation.\n const decrypted = decryptLegacyPkcs12Pbe(\n algId,\n encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams,\n encData.encryptedContentInfo.encryptedContent,\n password\n )\n safeBER = toArrayBuffer(decrypted)\n } else {\n // PBES2 or other modern OID — delegate to the pkijs engine.\n safeBER = await encData.decrypt({ password: pwBuf })\n }\n } else {\n // EnvelopedData or other types — skip (not needed for cert extraction).\n continue\n }\n\n // Parse SafeContents and collect X.509 certificates from cert bags.\n const sc = pkijs.SafeContents.fromBER(safeBER)\n for (const bag of sc.safeBags) {\n if (bag.bagId === CERT_BAG_OID) {\n const certBag = bag.bagValue as pkijs.CertBag\n if (certBag.parsedValue instanceof pkijs.Certificate) {\n certs.push(certBag.parsedValue)\n }\n }\n }\n }\n\n if (certs.length === 0) {\n throw new Error(`No certificates found in PKCS#12 file \"${file}\" — the file may be a key-only PFX or be empty`)\n }\n\n // Find the certificate with the codeSigning Extended Key Usage.\n // pkijs auto-parses known extensions via ExtensionValueFactory (registered at module init).\n const signingCert = certs.find(cert => {\n const ekuExt = cert.extensions?.find(e => e.extnID === pkijs.id_ExtKeyUsage)\n if (ekuExt == null) {\n return false\n }\n if (ekuExt.parsedValue instanceof pkijs.ExtKeyUsage) {\n return ekuExt.parsedValue.keyPurposes.includes(CODE_SIGNING_OID)\n }\n // Fallback: manually parse the extension OctetString value.\n try {\n const inner = asn1js.fromBER(ekuExt.extnValue.valueBlock.valueHexView)\n if (inner.offset === -1) {\n return false\n }\n const eku = new pkijs.ExtKeyUsage({ schema: inner.result })\n return eku.keyPurposes.includes(CODE_SIGNING_OID)\n } catch {\n return false\n }\n })\n\n if (signingCert == null) {\n throw new Error(\n `No certificate with ExtKeyUsageCodeSigning found in \"${file}\" — ${certs.length} certificate(s) present but none have the codeSigning extended key usage. ` +\n `Ensure the PFX contains a code-signing certificate, not just a CA or TLS certificate.`\n )\n }\n\n const cnAttr = signingCert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n const commonName = String(cnAttr?.value.valueBlock.value ?? \"\")\n\n // Format DN as \"CN=X,O=X,...\" matching Go's BloodyMsString output.\n // Uses ATTRIBUTE_TYPE_NAMES to mirror Go's attributeTypeNames map exactly, so STREET,\n // POSTALCODE, and SERIALNUMBER (present in EV code-signing certs) are handled correctly.\n // Unknown OIDs fall back to the bare OID string as the type name.\n const bloodyMicrosoftSubjectDn = signingCert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn }\n}\n\n/**\n * Reads certificate info from a plain X.509 certificate file (.crt / .cer).\n * Accepts both PEM (base64 with -----BEGIN CERTIFICATE----- headers) and DER (raw binary) encoding.\n *\n * Unlike `readCertInfo`, this does not require a password and does not parse PKCS#12.\n * Used when HSM mode supplies a public-cert-only file alongside /csp + /kc or pkcs11Module.\n *\n * Returns `null` when the publisher name cannot be determined (e.g. no CN attribute), so\n * callers should fall back to requiring an explicit `publisherName` in that case.\n */\nexport async function readCertInfoFromX509(file: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string } | null> {\n const raw = await readFile(file)\n\n // Support PEM (ASCII armor) and DER (raw binary) encoding.\n let derBytes: Buffer\n const pemContent = raw.toString(\"ascii\")\n if (pemContent.includes(\"-----BEGIN CERTIFICATE-----\")) {\n const b64 = pemContent\n .replace(/-----BEGIN CERTIFICATE-----/g, \"\")\n .replace(/-----END CERTIFICATE-----/g, \"\")\n .replace(/\\s+/g, \"\")\n derBytes = Buffer.from(b64, \"base64\")\n } else {\n derBytes = raw\n }\n\n let cert: pkijs.Certificate\n try {\n const asn1Result = asn1js.fromBER(toArrayBuffer(derBytes))\n if (asn1Result.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n cert = new pkijs.Certificate({ schema: asn1Result.result })\n } catch (err) {\n throw new Error(`X.509 certificate file \"${file}\" could not be parsed: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const cnAttr = cert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n if (cnAttr == null) {\n return null\n }\n const commonName = String(cnAttr.value.valueBlock.value)\n\n const bloodyMicrosoftSubjectDn = cert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn }\n}\n\n/**\n * Internal functions exported exclusively for unit testing.\n * Not part of the public API — do not use outside of test files.\n */\nexport const _testingOnly = {\n pkcs12PbeDeriveKey,\n pkcs12PasswordToUtf16,\n rc2CbcDecrypt,\n MAX_PKCS12_PBE_ITERATIONS,\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { SignOptions } from "@electron/osx-sign/dist/cjs/types";
1
+ import type { SignOptions } from "@electron/osx-sign";
2
2
  import { TmpDir } from "builder-util";
3
3
  import { Nullish } from "builder-util-runtime";
4
4
  export declare const appleCertificatePrefixes: string[];
@@ -22,8 +22,8 @@ export declare function sign(opts: SignOptions): Promise<void>;
22
22
  export declare let findIdentityRawResult: Promise<Array<string>> | null;
23
23
  export declare class Identity {
24
24
  readonly name: string;
25
- readonly hash?: string;
26
- constructor(name: string, hash?: string);
25
+ readonly hash?: string | undefined;
26
+ constructor(name: string, hash?: string | undefined);
27
27
  }
28
28
  export declare function findIdentity(certType: CertType, qualifier?: string | null, keychain?: string | null): Promise<Identity | null>;
29
29
  //# sourceMappingURL=macCodeSign.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"macCodeSign.d.ts","sourceRoot":"","sources":["../../../src/codeSign/mac/macCodeSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAyG,MAAM,EAAkB,MAAM,cAAc,CAAA;AAC5J,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAW9C,eAAO,MAAM,wBAAwB,UAAyI,CAAA;AAE9K,MAAM,MAAM,QAAQ,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,qCAAqC,GACrC,mCAAmC,GACnC,eAAe,GACf,mBAAmB,GACnB,oBAAoB,CAAA;AAExB,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,wBAAgB,aAAa,CAAC,WAAW,UAAO,GAAG,OAAO,CA6BzD;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,EAAE,kBAAkB,EAAE,OAAO,iBAqCvK;AAsCD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MA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,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,YAAA;CAEzB;AASD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAe9H"}
@@ -1,3 +1,4 @@
1
+ import { sign as _sign } from "@electron/osx-sign";
1
2
  import { copyFile, exec, InvalidConfigurationError, isEmptyOrSpaces, isPullRequest, log, Logger, retry, unlinkIfExists } from "builder-util";
2
3
  import { createHash, randomBytes } from "crypto";
3
4
  import { rename } from "fs/promises";
@@ -5,7 +6,6 @@ import { Lazy } from "lazy-val";
5
6
  import { homedir, tmpdir } from "os";
6
7
  import * as path from "path";
7
8
  import { getTempName } from "temp-file";
8
- import { dynamicImport } from "../../util/dynamicImport.js";
9
9
  import { isAutoDiscoveryCodeSignIdentity, isCscForPullRequest, isTravis } from "../../util/flags.js";
10
10
  import { importCertificate } from "../codesign.js";
11
11
  export const appleCertificatePrefixes = ["Developer ID Application:", "Developer ID Installer:", "3rd Party Mac Developer Application:", "3rd Party Mac Developer Installer:"];
@@ -80,7 +80,7 @@ const bundledCertKeychainAdded = new Lazy(async () => {
80
80
  const keychainPath = path.join(cacheDir, "electron-builder-root-certs.keychain");
81
81
  const results = await Promise.all([
82
82
  listUserKeychains(),
83
- copyFile(path.join(import.meta.dirname, "..", "..", "certs", "root_certs.keychain"), tmpKeychainPath).then(() => rename(tmpKeychainPath, keychainPath)),
83
+ copyFile(path.join(import.meta.dirname, "..", "..", "..", "certs", "root_certs.keychain"), tmpKeychainPath).then(() => rename(tmpKeychainPath, keychainPath)),
84
84
  ]);
85
85
  const list = results[0];
86
86
  if (!list.includes(keychainPath)) {
@@ -161,14 +161,22 @@ async function importCerts(keychainFile, paths, keyPasswords) {
161
161
  };
162
162
  }
163
163
  export async function sign(opts) {
164
- const { signAsync } = await dynamicImport("@electron/osx-sign");
165
- return retry(() => signAsync(opts), {
164
+ return retry(() => _sign(opts), {
166
165
  retries: 3,
167
166
  interval: 5000,
168
167
  backoff: 5000,
169
168
  });
170
169
  }
171
170
  export let findIdentityRawResult = null;
171
+ // Discovery of untrusted self-signed identities is OFF in production, and there is intentionally NO env var
172
+ // or build-config option to enable it: an untrusted identity must never be silently accepted in a real
173
+ // build. This in-process flag exists solely as a seam for electron-builder's own signing tests, which
174
+ // provision an ephemeral self-signed cert and flip it via setAllowUntrustedSelfSignedIdentityForTesting().
175
+ let allowUntrustedSelfSignedIdentity = false;
176
+ /** @internal Test-only. Enables discovery of untrusted self-signed code-signing identities. Never use in production. */
177
+ export function setAllowUntrustedSelfSignedIdentityForTesting(value) {
178
+ allowUntrustedSelfSignedIdentity = value;
179
+ }
172
180
  async function getValidIdentities(keychain) {
173
181
  function addKeychain(args) {
174
182
  if (keychain != null) {
@@ -180,7 +188,7 @@ async function getValidIdentities(keychain) {
180
188
  if (result == null || keychain != null) {
181
189
  // https://github.com/electron-userland/electron-builder/issues/481
182
190
  // https://github.com/electron-userland/electron-builder/issues/535
183
- result = Promise.all([
191
+ const commands = [
184
192
  exec("/usr/bin/security", addKeychain(["find-identity", "-v"])).then(it => it
185
193
  .trim()
186
194
  .split("\n")
@@ -193,10 +201,22 @@ async function getValidIdentities(keychain) {
193
201
  return false;
194
202
  })),
195
203
  exec("/usr/bin/security", addKeychain(["find-identity", "-v", "-p", "codesigning"])).then(it => it.trim().split("\n")),
196
- ]).then(it => {
197
- const array = it[0]
198
- .concat(it[1])
199
- .filter(it => !it.includes("(Missing required extension)") && !it.includes("valid identities found") && !it.includes("iPhone ") && !it.includes("com.apple.idms.appleid.prd."))
204
+ ];
205
+ // Test-only seam: also accept untrusted self-signed identities. `find-identity` without `-v` lists them;
206
+ // trusted identities discovered above still take precedence (they appear first and dupes are de-duped).
207
+ if (allowUntrustedSelfSignedIdentity) {
208
+ commands.push(exec("/usr/bin/security", addKeychain(["find-identity"])).then(it => it.trim().split("\n")));
209
+ }
210
+ result = Promise.all(commands).then(it => {
211
+ const array = it
212
+ .flat()
213
+ .filter(it => !it.includes("(Missing required extension)") &&
214
+ !it.includes("identities found") &&
215
+ !it.includes("Policy: X.509 Basic") &&
216
+ !it.includes("Matching identities") &&
217
+ !it.includes("Valid identities only") &&
218
+ !it.includes("iPhone ") &&
219
+ !it.includes("com.apple.idms.appleid.prd."))
200
220
  // remove 1)
201
221
  .map(it => it.substring(it.indexOf(")") + 1).trim());
202
222
  return Array.from(new Set(array));
@@ -217,7 +237,7 @@ async function _findIdentity(type, qualifier, keychain) {
217
237
  continue;
218
238
  }
219
239
  if (line.includes(namePrefix)) {
220
- return await parseIdentity(line);
240
+ return parseIdentity(line);
221
241
  }
222
242
  }
223
243
  if (type === "Developer ID Application") {
@@ -235,17 +255,23 @@ async function _findIdentity(type, qualifier, keychain) {
235
255
  continue l;
236
256
  }
237
257
  }
238
- return await parseIdentity(line);
258
+ return parseIdentity(line);
239
259
  }
240
260
  }
241
261
  return null;
242
262
  }
243
- async function parseIdentity(line) {
263
+ // @electron/osx-sign v2 no longer exposes its `Identity` class via the package's public exports, so we own this lightweight equivalent.
264
+ export class Identity {
265
+ constructor(name, hash) {
266
+ this.name = name;
267
+ this.hash = hash;
268
+ }
269
+ }
270
+ function parseIdentity(line) {
244
271
  const firstQuoteIndex = line.indexOf('"');
245
272
  const name = line.substring(firstQuoteIndex + 1, line.lastIndexOf('"'));
246
273
  const hash = line.substring(0, firstQuoteIndex - 1);
247
- const { Identity: IdentityClass } = await dynamicImport("@electron/osx-sign/dist/cjs/util-identities");
248
- return new IdentityClass(name, hash);
274
+ return new Identity(name, hash);
249
275
  }
250
276
  export function findIdentity(certType, qualifier, keychain) {
251
277
  let identity = qualifier || process.env.CSC_NAME;