windows-sign.d.mts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * Build the minimal CMD environment for one Electron artifact.
  3. *
  4. * @param environment Parent environment.
  5. * @param input Validated signing identity and task.
  6. * @returns Scrubbed environment plus the fields consumed and cleared by the signing CMD.
  7. */
  8. export function buildWindowsSigningEnvironment(environment: NodeJS.ProcessEnv, input: {
  9. certificateFile: string
  10. signTool: string
  11. path: string
  12. isNest: boolean
  13. tokenPin: string
  14. keyContainer: string
  15. }): NodeJS.ProcessEnv
  16. /**
  17. * Create the electron-builder hook for a hardware-backed Windows code-signing certificate.
  18. *
  19. * @param options Release signing configuration.
  20. * @returns The signing hook.
  21. */
  22. export function createWindowsTokenSigner(options: {
  23. certificateFile?: string | undefined
  24. signTool?: string | undefined
  25. tokenPin?: string | undefined
  26. keyContainer?: string | undefined
  27. commandInterpreter?: string | undefined
  28. }): (
  29. configuration: {
  30. path: string
  31. hash: string
  32. isNest: boolean
  33. },
  34. ) => Promise<void>
  35. /**
  36. * Remove inherited credentials before starting a signing-related subprocess.
  37. *
  38. * @param environment Parent environment.
  39. * @returns Environment without credential-shaped names.
  40. */
  41. export function scrubWindowsSigningEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv
  42. /**
  43. * Replace a SignTool failure with a diagnostic that cannot retain its command line.
  44. *
  45. * @param error SignTool process failure.
  46. * @param path Artifact that failed signing.
  47. * @param secrets Values that must not appear in the diagnostic.
  48. * @returns Sanitized signing failure without the original error as its cause.
  49. */
  50. export function createRedactedWindowsSigningError(
  51. error: unknown,
  52. path: string,
  53. secrets: readonly string[],
  54. ): Error
  55. /**
  56. * Clear a certificate-table entry that points beyond the end of a generated executable.
  57. *
  58. * @param path Executable to inspect.
  59. * @returns Whether an invalid certificate-table entry was cleared.
  60. */
  61. export function repairDanglingAuthenticodeDirectory(path: string): Promise<boolean>
  62. /**
  63. * Sign electron-builder's temporary NSIS executable before enterprise code integrity evaluates it.
  64. *
  65. * @param options Signing hook and injectable host values.
  66. * @returns Nothing.
  67. */
  68. export function installWindowsNsisBootstrapSigner(options: {
  69. sign: (configuration: {
  70. path: string
  71. hash: string
  72. isNest: boolean
  73. }) => Promise<void>
  74. wineVmManager?: {
  75. prototype: {
  76. exec: (
  77. file: string,
  78. args: string[],
  79. options?: { env?: NodeJS.ProcessEnv },
  80. isLogOutIfDebug?: boolean,
  81. ) => unknown
  82. }
  83. }
  84. platform?: NodeJS.Platform
  85. environment?: NodeJS.ProcessEnv
  86. }): void