Skip to content

Commit 0d24b78

Browse files
committed
cleanup
1 parent bc6a0c5 commit 0d24b78

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

packages/app-builder-lib/src/codeSign/windowsCodeSign.ts

+26-28
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,23 @@ export async function sign(options: WindowsSignOptions, packager: WinPackager):
6060
}
6161

6262
log.info(null, "signing with signtool.exe")
63-
const message = "deprecated field. Please move to win.signtoolOptions.<field_name>"
64-
if (options.options.certificateFile) {
65-
log.info({ field: "certificateFile" }, message)
66-
}
67-
if (options.options.certificatePassword) {
68-
log.info({ field: "certificatePassword" }, message)
69-
}
70-
if (options.options.certificateSha1) {
71-
log.info({ field: "certificateSha1" }, message)
72-
}
73-
if (options.options.certificateSubjectName) {
74-
log.info({ field: "certificateSubjectName" }, message)
75-
}
76-
if (options.options.additionalCertificateFile) {
77-
log.info({ field: "additionalCertificateFile" }, message)
78-
}
79-
if (options.options.rfc3161TimeStampServer) {
80-
log.info({ field: "rfc3161TimeStampServer" }, message)
81-
}
82-
if (options.options.timeStampServer) {
83-
log.info({ field: "timeStampServer" }, message)
84-
}
63+
const deprecatedFields = {
64+
sign: options.options.sign,
65+
signDlls: options.options.signDlls,
66+
signingHashAlgorithms: options.options.signingHashAlgorithms,
67+
certificateFile: options.options.certificateFile,
68+
certificatePassword: options.options.certificatePassword,
69+
certificateSha1: options.options.certificateSha1,
70+
certificateSubjectName: options.options.certificateSubjectName,
71+
additionalCertificateFile: options.options.additionalCertificateFile,
72+
rfc3161TimeStampServer: options.options.rfc3161TimeStampServer,
73+
timeStampServer: options.options.timeStampServer,
74+
}
75+
Object.entries(deprecatedFields).forEach((field, value) => {
76+
if (value) {
77+
log.info({ field }, `deprecated field. Please move to win.signtoolOptions.${field}`)
78+
}
79+
})
8580
return signUsingSigntool(options, packager)
8681
}
8782

@@ -187,8 +182,8 @@ export interface CertificateFromStoreInfo {
187182
}
188183

189184
export async function getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {
190-
const certificateSubjectName = options.signtoolOptions?.certificateSubjectName
191-
const certificateSha1 = options.signtoolOptions?.certificateSha1 ? options.signtoolOptions?.certificateSha1.toUpperCase() : options.signtoolOptions?.certificateSha1
185+
const certificateSubjectName = chooseNotNull(options.signtoolOptions?.certificateSubjectName, options.certificateSubjectName)
186+
const certificateSha1 = chooseNotNull(options.signtoolOptions?.certificateSha1, options.certificateSha1)?.toUpperCase()
192187

193188
const ps = await getPSCmd(vm)
194189
const rawResult = await vm.exec(ps, [
@@ -278,11 +273,13 @@ function computeSignToolArgs(options: WindowsSignTaskConfiguration, isWin: boole
278273
const args = isWin ? ["sign"] : ["-in", inputFile, "-out", outputPath]
279274

280275
if (process.env.ELECTRON_BUILDER_OFFLINE !== "true") {
281-
const timestampingServiceUrl = options.options.signtoolOptions?.timeStampServer || "http://timestamp.digicert.com"
276+
const timestampingServiceUrl = chooseNotNull(options.options.signtoolOptions?.timeStampServer, options.options.timeStampServer) || "http://timestamp.digicert.com"
282277
if (isWin) {
283278
args.push(
284279
options.isNest || options.hash === "sha256" ? "/tr" : "/t",
285-
options.isNest || options.hash === "sha256" ? options.options.signtoolOptions?.rfc3161TimeStampServer || "http://timestamp.digicert.com" : timestampingServiceUrl
280+
options.isNest || options.hash === "sha256"
281+
? chooseNotNull(options.options.signtoolOptions?.rfc3161TimeStampServer, options.options.rfc3161TimeStampServer) || "http://timestamp.digicert.com"
282+
: timestampingServiceUrl
286283
)
287284
} else {
288285
args.push("-t", timestampingServiceUrl)
@@ -336,8 +333,9 @@ function computeSignToolArgs(options: WindowsSignTaskConfiguration, isWin: boole
336333
args.push(isWin ? "/p" : "-pass", password)
337334
}
338335

339-
if (options.options.signtoolOptions?.additionalCertificateFile) {
340-
args.push(isWin ? "/ac" : "-ac", vm.toVmFile(options.options.signtoolOptions?.additionalCertificateFile))
336+
const additionalCert = chooseNotNull(options.options.signtoolOptions?.additionalCertificateFile, options.options.additionalCertificateFile)
337+
if (additionalCert) {
338+
args.push(isWin ? "/ac" : "-ac", vm.toVmFile(additionalCert))
341339
}
342340

343341
const httpsProxyFromEnv = process.env.HTTPS_PROXY

packages/app-builder-lib/src/options/winOptions.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,51 @@ export interface WindowsConfiguration extends PlatformSpecificBuildOptions {
2525

2626
/**
2727
* Array of signing algorithms used. For AppX `sha256` is always used.
28-
* @deprecated Please use win.signtoolSigning.signingHashAlgorithms
28+
* @deprecated Please use win.signtoolOptions.signingHashAlgorithms
2929
*/
3030
readonly signingHashAlgorithms?: Array<"sha1" | "sha256"> | null
3131
/**
3232
* The custom function (or path to file or module id) to sign Windows executables
33-
* @deprecated Please use win.signtoolSigning.sign
33+
* @deprecated Please use win.signtoolOptions.sign
3434
*/
3535
readonly sign?: CustomWindowsSign | string | null
3636
/**
3737
* The path to the *.pfx certificate you want to sign with. Please use it only if you cannot use env variable `CSC_LINK` (`WIN_CSC_LINK`) for some reason.
3838
* Please see [Code Signing](/code-signing).
39-
* @deprecated Please use win.signtoolSigning.certificateFile
39+
* @deprecated Please use win.signtoolOptions.certificateFile
4040
*/
4141
readonly certificateFile?: string | null
4242
/**
4343
* The password to the certificate provided in `certificateFile`. Please use it only if you cannot use env variable `CSC_KEY_PASSWORD` (`WIN_CSC_KEY_PASSWORD`) for some reason.
4444
* Please see [Code Signing](/code-signing).
45-
* @deprecated Please use win.signtoolSigning.certificatePassword
45+
* @deprecated Please use win.signtoolOptions.certificatePassword
4646
*/
4747
readonly certificatePassword?: string | null
4848
/**
4949
* The name of the subject of the signing certificate, which is often labeled with the field name `issued to`. Required only for EV Code Signing and works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).
50-
* @deprecated Please use win.signtoolSigning.certificateSubjectName
50+
* @deprecated Please use win.signtoolOptions.certificateSubjectName
5151
*/
5252
readonly certificateSubjectName?: string | null
5353
/**
5454
* The SHA1 hash of the signing certificate. The SHA1 hash is commonly specified when multiple certificates satisfy the criteria specified by the remaining switches. Works only on Windows (or on macOS if [Parallels Desktop](https://www.parallels.com/products/desktop/) Windows 10 virtual machines exits).
55-
* @deprecated Please use win.signtoolSigning.certificateSha1
55+
* @deprecated Please use win.signtoolOptions.certificateSha1
5656
*/
5757
readonly certificateSha1?: string | null
5858
/**
5959
* The path to an additional certificate file you want to add to the signature block.
60-
* @deprecated Please use win.signtoolSigning.additionalCertificateFile
60+
* @deprecated Please use win.signtoolOptions.additionalCertificateFile
6161
*/
6262
readonly additionalCertificateFile?: string | null
6363
/**
6464
* The URL of the RFC 3161 time stamp server.
6565
* @default http://timestamp.digicert.com
66-
* @deprecated Please use win.signtoolSigning.rfc3161TimeStampServer
66+
* @deprecated Please use win.signtoolOptions.rfc3161TimeStampServer
6767
*/
6868
readonly rfc3161TimeStampServer?: string | null
6969
/**
7070
* The URL of the time stamp server.
7171
* @default http://timestamp.digicert.com
72-
* @deprecated Please use win.signtoolSigning.timeStampServer
72+
* @deprecated Please use win.signtoolOptions.timeStampServer
7373
*/
7474
readonly timeStampServer?: string | null
7575

0 commit comments

Comments
 (0)