app-builder-lib 25.0.6 → 25.1.1

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 (45) hide show
  1. package/out/codeSign/windowsCodeSign.d.ts +2 -31
  2. package/out/codeSign/windowsCodeSign.js +28 -246
  3. package/out/codeSign/windowsCodeSign.js.map +1 -1
  4. package/out/codeSign/windowsSignAzureManager.d.ts +12 -0
  5. package/out/codeSign/windowsSignAzureManager.js +81 -0
  6. package/out/codeSign/windowsSignAzureManager.js.map +1 -0
  7. package/out/codeSign/windowsSignToolManager.d.ts +53 -0
  8. package/out/codeSign/windowsSignToolManager.js +341 -0
  9. package/out/codeSign/windowsSignToolManager.js.map +1 -0
  10. package/out/configuration.d.ts +14 -12
  11. package/out/configuration.js.map +1 -1
  12. package/out/electron/electronWin.js +1 -1
  13. package/out/electron/electronWin.js.map +1 -1
  14. package/out/electron/injectFFMPEG.js +1 -1
  15. package/out/electron/injectFFMPEG.js.map +1 -1
  16. package/out/index.d.ts +5 -4
  17. package/out/index.js.map +1 -1
  18. package/out/options/winOptions.d.ts +89 -4
  19. package/out/options/winOptions.js.map +1 -1
  20. package/out/packager.d.ts +1 -1
  21. package/out/packager.js +4 -4
  22. package/out/packager.js.map +1 -1
  23. package/out/platformPackager.d.ts +4 -4
  24. package/out/platformPackager.js.map +1 -1
  25. package/out/publish/PublishManager.js +3 -3
  26. package/out/publish/PublishManager.js.map +1 -1
  27. package/out/targets/AppxTarget.js +6 -5
  28. package/out/targets/AppxTarget.js.map +1 -1
  29. package/out/targets/FpmTarget.js +1 -1
  30. package/out/targets/FpmTarget.js.map +1 -1
  31. package/out/targets/nsis/nsisOptions.d.ts +1 -2
  32. package/out/targets/nsis/nsisOptions.js.map +1 -1
  33. package/out/util/config/load.js +1 -1
  34. package/out/util/config/load.js.map +1 -1
  35. package/out/util/packageDependencies.d.ts +1 -1
  36. package/out/util/packageDependencies.js +4 -2
  37. package/out/util/packageDependencies.js.map +1 -1
  38. package/out/version.d.ts +1 -1
  39. package/out/version.js +1 -1
  40. package/out/version.js.map +1 -1
  41. package/out/winPackager.d.ts +6 -7
  42. package/out/winPackager.js +28 -103
  43. package/out/winPackager.js.map +1 -1
  44. package/package.json +11 -11
  45. package/scheme.json +150 -2
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WindowsSignToolManager = void 0;
4
+ exports.getSignVendorPath = getSignVendorPath;
5
+ exports.isOldWin6 = isOldWin6;
6
+ const builder_util_1 = require("builder-util");
7
+ const binDownload_1 = require("../binDownload");
8
+ const appBuilder_1 = require("../util/appBuilder");
9
+ const bundledTool_1 = require("../util/bundledTool");
10
+ const fs_extra_1 = require("fs-extra");
11
+ const os = require("os");
12
+ const path = require("path");
13
+ const resolve_1 = require("../util/resolve");
14
+ const flags_1 = require("../util/flags");
15
+ const vm_1 = require("../vm/vm");
16
+ const platformPackager_1 = require("../platformPackager");
17
+ const windowsCodeSign_1 = require("./windowsCodeSign");
18
+ const builder_util_runtime_1 = require("builder-util-runtime");
19
+ const lazy_val_1 = require("lazy-val");
20
+ const codesign_1 = require("./codesign");
21
+ function getSignVendorPath() {
22
+ return (0, binDownload_1.getBin)("winCodeSign");
23
+ }
24
+ class WindowsSignToolManager {
25
+ constructor(packager) {
26
+ this.packager = packager;
27
+ this.computedPublisherName = new lazy_val_1.Lazy(async () => {
28
+ var _a;
29
+ const publisherName = (0, platformPackager_1.chooseNotNull)((_a = this.platformSpecificBuildOptions.signtoolOptions) === null || _a === void 0 ? void 0 : _a.publisherName, this.platformSpecificBuildOptions.publisherName);
30
+ if (publisherName === null) {
31
+ return null;
32
+ }
33
+ else if (publisherName != null) {
34
+ return (0, builder_util_1.asArray)(publisherName);
35
+ }
36
+ const certInfo = await this.lazyCertInfo.value;
37
+ return certInfo == null ? null : [certInfo.commonName];
38
+ });
39
+ this.lazyCertInfo = new builder_util_runtime_1.MemoLazy(() => this.cscInfo, async (csc) => {
40
+ const cscInfo = await csc.value;
41
+ if (cscInfo == null) {
42
+ return null;
43
+ }
44
+ if ("subject" in cscInfo) {
45
+ const bloodyMicrosoftSubjectDn = cscInfo.subject;
46
+ return {
47
+ commonName: (0, builder_util_runtime_1.parseDn)(bloodyMicrosoftSubjectDn).get("CN"),
48
+ bloodyMicrosoftSubjectDn,
49
+ };
50
+ }
51
+ const cscFile = cscInfo.file;
52
+ if (cscFile == null) {
53
+ return null;
54
+ }
55
+ return await this.getCertInfo(cscFile, cscInfo.password || "");
56
+ });
57
+ this.cscInfo = new builder_util_runtime_1.MemoLazy(() => this.platformSpecificBuildOptions, platformSpecificBuildOptions => {
58
+ var _a, _b, _c;
59
+ const subjectName = (0, platformPackager_1.chooseNotNull)((_a = platformSpecificBuildOptions.signtoolOptions) === null || _a === void 0 ? void 0 : _a.certificateSubjectName, platformSpecificBuildOptions.certificateSubjectName);
60
+ const shaType = (0, platformPackager_1.chooseNotNull)((_b = platformSpecificBuildOptions.signtoolOptions) === null || _b === void 0 ? void 0 : _b.certificateSha1, platformSpecificBuildOptions.certificateSha1);
61
+ if (subjectName != null || shaType != null) {
62
+ return this.packager.vm.value
63
+ .then(vm => this.getCertificateFromStoreInfo(platformSpecificBuildOptions, vm))
64
+ .catch((e) => {
65
+ var _a;
66
+ // https://github.com/electron-userland/electron-builder/pull/2397
67
+ if ((0, platformPackager_1.chooseNotNull)((_a = platformSpecificBuildOptions.signtoolOptions) === null || _a === void 0 ? void 0 : _a.sign, platformSpecificBuildOptions.sign) == null) {
68
+ throw e;
69
+ }
70
+ else {
71
+ builder_util_1.log.debug({ error: e }, "getCertificateFromStoreInfo error");
72
+ return null;
73
+ }
74
+ });
75
+ }
76
+ const certificateFile = (0, platformPackager_1.chooseNotNull)((_c = platformSpecificBuildOptions.signtoolOptions) === null || _c === void 0 ? void 0 : _c.certificateFile, platformSpecificBuildOptions.certificateFile);
77
+ if (certificateFile != null) {
78
+ const certificatePassword = this.packager.getCscPassword();
79
+ return Promise.resolve({
80
+ file: certificateFile,
81
+ password: certificatePassword == null ? null : certificatePassword.trim(),
82
+ });
83
+ }
84
+ const cscLink = this.packager.getCscLink("WIN_CSC_LINK");
85
+ if (cscLink == null || cscLink === "") {
86
+ return Promise.resolve(null);
87
+ }
88
+ return ((0, codesign_1.importCertificate)(cscLink, this.packager.info.tempDirManager, this.packager.projectDir)
89
+ // before then
90
+ .catch((e) => {
91
+ if (e instanceof builder_util_1.InvalidConfigurationError) {
92
+ throw new builder_util_1.InvalidConfigurationError(`Env WIN_CSC_LINK is not correct, cannot resolve: ${e.message}`);
93
+ }
94
+ else {
95
+ throw e;
96
+ }
97
+ })
98
+ .then(path => {
99
+ return {
100
+ file: path,
101
+ password: this.packager.getCscPassword(),
102
+ };
103
+ }));
104
+ });
105
+ this.platformSpecificBuildOptions = packager.platformSpecificBuildOptions;
106
+ }
107
+ async signUsingSigntool(options) {
108
+ var _a, _b;
109
+ let hashes = (0, platformPackager_1.chooseNotNull)((_a = options.options.signtoolOptions) === null || _a === void 0 ? void 0 : _a.signingHashAlgorithms, options.options.signingHashAlgorithms);
110
+ // msi does not support dual-signing
111
+ if (options.path.endsWith(".msi")) {
112
+ hashes = [hashes != null && !hashes.includes("sha1") ? "sha256" : "sha1"];
113
+ }
114
+ else if (options.path.endsWith(".appx")) {
115
+ hashes = ["sha256"];
116
+ }
117
+ else if (hashes == null) {
118
+ hashes = ["sha1", "sha256"];
119
+ }
120
+ else {
121
+ hashes = Array.isArray(hashes) ? hashes : [hashes];
122
+ }
123
+ const cscInfo = await this.cscInfo.value;
124
+ const name = this.packager.appInfo.productName;
125
+ const site = await this.packager.appInfo.computePackageUrl();
126
+ const customSign = await (0, resolve_1.resolveFunction)(this.packager.appInfo.type, (0, platformPackager_1.chooseNotNull)((_b = options.options.signtoolOptions) === null || _b === void 0 ? void 0 : _b.sign, options.options.sign), "sign");
127
+ const executor = customSign || ((config, packager) => this.doSign(config, packager));
128
+ let isNest = false;
129
+ for (const hash of hashes) {
130
+ const taskConfiguration = { ...options, name, site, cscInfo, hash, isNest };
131
+ await Promise.resolve(executor({
132
+ ...taskConfiguration,
133
+ computeSignToolArgs: isWin => this.computeSignToolArgs(taskConfiguration, isWin),
134
+ }, this.packager));
135
+ isNest = true;
136
+ if (taskConfiguration.resultOutputPath != null) {
137
+ await (0, fs_extra_1.rename)(taskConfiguration.resultOutputPath, options.path);
138
+ }
139
+ }
140
+ return true;
141
+ }
142
+ async getCertInfo(file, password) {
143
+ let result = null;
144
+ const errorMessagePrefix = "Cannot extract publisher name from code signing certificate. As workaround, set win.publisherName. Error: ";
145
+ try {
146
+ result = await (0, appBuilder_1.executeAppBuilderAsJson)(["certificate-info", "--input", file, "--password", password]);
147
+ }
148
+ catch (e) {
149
+ throw new Error(`${errorMessagePrefix}${e.stack || e}`);
150
+ }
151
+ if (result.error != null) {
152
+ // noinspection ExceptionCaughtLocallyJS
153
+ throw new builder_util_1.InvalidConfigurationError(`${errorMessagePrefix}${result.error}`);
154
+ }
155
+ return result;
156
+ }
157
+ // on windows be aware of http://stackoverflow.com/a/32640183/1910191
158
+ computeSignToolArgs(options, isWin, vm = new vm_1.VmManager()) {
159
+ var _a, _b, _c;
160
+ const inputFile = vm.toVmFile(options.path);
161
+ const outputPath = isWin ? inputFile : this.getOutputPath(inputFile, options.hash);
162
+ if (!isWin) {
163
+ options.resultOutputPath = outputPath;
164
+ }
165
+ const args = isWin ? ["sign"] : ["-in", inputFile, "-out", outputPath];
166
+ if (process.env.ELECTRON_BUILDER_OFFLINE !== "true") {
167
+ const timestampingServiceUrl = (0, platformPackager_1.chooseNotNull)((_a = options.options.signtoolOptions) === null || _a === void 0 ? void 0 : _a.timeStampServer, options.options.timeStampServer) || "http://timestamp.digicert.com";
168
+ if (isWin) {
169
+ args.push(options.isNest || options.hash === "sha256" ? "/tr" : "/t", options.isNest || options.hash === "sha256"
170
+ ? (0, platformPackager_1.chooseNotNull)((_b = options.options.signtoolOptions) === null || _b === void 0 ? void 0 : _b.rfc3161TimeStampServer, options.options.rfc3161TimeStampServer) || "http://timestamp.digicert.com"
171
+ : timestampingServiceUrl);
172
+ }
173
+ else {
174
+ args.push("-t", timestampingServiceUrl);
175
+ }
176
+ }
177
+ const certificateFile = options.cscInfo.file;
178
+ if (certificateFile == null) {
179
+ const cscInfo = options.cscInfo;
180
+ const subjectName = cscInfo.thumbprint;
181
+ if (!isWin) {
182
+ throw new Error(`${subjectName == null ? "certificateSha1" : "certificateSubjectName"} supported only on Windows`);
183
+ }
184
+ args.push("/sha1", cscInfo.thumbprint);
185
+ args.push("/s", cscInfo.store);
186
+ if (cscInfo.isLocalMachineStore) {
187
+ args.push("/sm");
188
+ }
189
+ }
190
+ else {
191
+ const certExtension = path.extname(certificateFile);
192
+ if (certExtension === ".p12" || certExtension === ".pfx") {
193
+ args.push(isWin ? "/f" : "-pkcs12", vm.toVmFile(certificateFile));
194
+ }
195
+ else {
196
+ throw new Error(`Please specify pkcs12 (.p12/.pfx) file, ${certificateFile} is not correct`);
197
+ }
198
+ }
199
+ if (!isWin || options.hash !== "sha1") {
200
+ args.push(isWin ? "/fd" : "-h", options.hash);
201
+ if (isWin && process.env.ELECTRON_BUILDER_OFFLINE !== "true") {
202
+ args.push("/td", "sha256");
203
+ }
204
+ }
205
+ if (options.name) {
206
+ args.push(isWin ? "/d" : "-n", options.name);
207
+ }
208
+ if (options.site) {
209
+ args.push(isWin ? "/du" : "-i", options.site);
210
+ }
211
+ // msi does not support dual-signing
212
+ if (options.isNest) {
213
+ args.push(isWin ? "/as" : "-nest");
214
+ }
215
+ const password = options.cscInfo == null ? null : options.cscInfo.password;
216
+ if (password) {
217
+ args.push(isWin ? "/p" : "-pass", password);
218
+ }
219
+ const additionalCert = (0, platformPackager_1.chooseNotNull)((_c = options.options.signtoolOptions) === null || _c === void 0 ? void 0 : _c.additionalCertificateFile, options.options.additionalCertificateFile);
220
+ if (additionalCert) {
221
+ args.push(isWin ? "/ac" : "-ac", vm.toVmFile(additionalCert));
222
+ }
223
+ const httpsProxyFromEnv = process.env.HTTPS_PROXY;
224
+ if (!isWin && httpsProxyFromEnv != null && httpsProxyFromEnv.length) {
225
+ args.push("-p", httpsProxyFromEnv);
226
+ }
227
+ if (isWin) {
228
+ // https://github.com/electron-userland/electron-builder/issues/2875#issuecomment-387233610
229
+ args.push("/debug");
230
+ // must be last argument
231
+ args.push(inputFile);
232
+ }
233
+ return args;
234
+ }
235
+ getOutputPath(inputPath, hash) {
236
+ const extension = path.extname(inputPath);
237
+ return path.join(path.dirname(inputPath), `${path.basename(inputPath, extension)}-signed-${hash}${extension}`);
238
+ }
239
+ getWinSignTool(vendorPath) {
240
+ // use modern signtool on Windows Server 2012 R2 to be able to sign AppX
241
+ if (isOldWin6()) {
242
+ return path.join(vendorPath, "windows-6", "signtool.exe");
243
+ }
244
+ else {
245
+ return path.join(vendorPath, "windows-10", process.arch, "signtool.exe");
246
+ }
247
+ }
248
+ async getToolPath(isWin = process.platform === "win32") {
249
+ if ((0, flags_1.isUseSystemSigncode)()) {
250
+ return { path: "osslsigncode" };
251
+ }
252
+ const result = process.env.SIGNTOOL_PATH;
253
+ if (result) {
254
+ return { path: result };
255
+ }
256
+ const vendorPath = await getSignVendorPath();
257
+ if (isWin) {
258
+ // use modern signtool on Windows Server 2012 R2 to be able to sign AppX
259
+ return { path: this.getWinSignTool(vendorPath) };
260
+ }
261
+ else if (process.platform === "darwin") {
262
+ const toolDirPath = path.join(vendorPath, process.platform, "10.12");
263
+ return {
264
+ path: path.join(toolDirPath, "osslsigncode"),
265
+ env: (0, bundledTool_1.computeToolEnv)([path.join(toolDirPath, "lib")]),
266
+ };
267
+ }
268
+ else {
269
+ return { path: path.join(vendorPath, process.platform, "osslsigncode") };
270
+ }
271
+ }
272
+ async getCertificateFromStoreInfo(options, vm) {
273
+ var _a, _b, _c;
274
+ const certificateSubjectName = (0, platformPackager_1.chooseNotNull)((_a = options.signtoolOptions) === null || _a === void 0 ? void 0 : _a.certificateSubjectName, options.certificateSubjectName);
275
+ const certificateSha1 = (_c = (0, platformPackager_1.chooseNotNull)((_b = options.signtoolOptions) === null || _b === void 0 ? void 0 : _b.certificateSha1, options.certificateSha1)) === null || _c === void 0 ? void 0 : _c.toUpperCase();
276
+ const ps = await (0, windowsCodeSign_1.getPSCmd)(vm);
277
+ const rawResult = await vm.exec(ps, [
278
+ "-NoProfile",
279
+ "-NonInteractive",
280
+ "-Command",
281
+ "Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress",
282
+ ]);
283
+ const certList = rawResult.length === 0 ? [] : (0, builder_util_1.asArray)(JSON.parse(rawResult));
284
+ for (const certInfo of certList) {
285
+ if ((certificateSubjectName != null && !certInfo.Subject.includes(certificateSubjectName)) ||
286
+ (certificateSha1 != null && certInfo.Thumbprint.toUpperCase() !== certificateSha1)) {
287
+ continue;
288
+ }
289
+ const parentPath = certInfo.PSParentPath;
290
+ const store = parentPath.substring(parentPath.lastIndexOf("\\") + 1);
291
+ builder_util_1.log.debug({ store, PSParentPath: parentPath }, "auto-detect certificate store");
292
+ // https://github.com/electron-userland/electron-builder/issues/1717
293
+ const isLocalMachineStore = parentPath.includes("Certificate::LocalMachine");
294
+ builder_util_1.log.debug(null, "auto-detect using of LocalMachine store");
295
+ return {
296
+ thumbprint: certInfo.Thumbprint,
297
+ subject: certInfo.Subject,
298
+ store,
299
+ isLocalMachineStore,
300
+ };
301
+ }
302
+ throw new Error(`Cannot find certificate ${certificateSubjectName || certificateSha1}, all certs: ${rawResult}`);
303
+ }
304
+ async doSign(configuration, packager) {
305
+ // https://github.com/electron-userland/electron-builder/pull/1944
306
+ const timeout = parseInt(process.env.SIGNTOOL_TIMEOUT, 10) || 10 * 60 * 1000;
307
+ // decide runtime argument by cases
308
+ let args;
309
+ let env = process.env;
310
+ let vm;
311
+ const vmRequired = configuration.path.endsWith(".appx") || !("file" in configuration.cscInfo); /* certificateSubjectName and other such options */
312
+ const isWin = process.platform === "win32" || vmRequired;
313
+ const toolInfo = await this.getToolPath(isWin);
314
+ const tool = toolInfo.path;
315
+ if (vmRequired) {
316
+ vm = await packager.vm.value;
317
+ args = this.computeSignToolArgs(configuration, isWin, vm);
318
+ }
319
+ else {
320
+ vm = new vm_1.VmManager();
321
+ args = configuration.computeSignToolArgs(isWin);
322
+ if (toolInfo.env != null) {
323
+ env = toolInfo.env;
324
+ }
325
+ }
326
+ await (0, builder_util_1.retry)(() => vm.exec(tool, args, { timeout, env }), 2, 15000, 10000, 0, (e) => {
327
+ if (e.message.includes("The file is being used by another process") ||
328
+ e.message.includes("The specified timestamp server either could not be reached" || e.message.includes("No certificates were found that met all the given criteria."))) {
329
+ builder_util_1.log.warn(`Attempt to code sign failed, another attempt will be made in 15 seconds: ${e.message}`);
330
+ return true;
331
+ }
332
+ return false;
333
+ });
334
+ }
335
+ }
336
+ exports.WindowsSignToolManager = WindowsSignToolManager;
337
+ function isOldWin6() {
338
+ const winVersion = os.release();
339
+ return winVersion.startsWith("6.") && !winVersion.startsWith("6.3");
340
+ }
341
+ //# sourceMappingURL=windowsSignToolManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windowsSignToolManager.js","sourceRoot":"","sources":["../../src/codeSign/windowsSignToolManager.ts"],"names":[],"mappings":";;;AAmBA,8CAEC;AAuZD,8BAGC;AA/aD,+CAA6E;AAC7E,gDAAuC;AAEvC,mDAA4D;AAC5D,qDAA8D;AAC9D,uCAAiC;AACjC,yBAAwB;AACxB,6BAA4B;AAC5B,6CAAiD;AACjD,yCAAmD;AACnD,iCAAoC;AAEpC,0DAAmD;AAEnD,uDAA4C;AAC5C,+DAAwD;AACxD,uCAA+B;AAC/B,yCAA8C;AAE9C,SAAgB,iBAAiB;IAC/B,OAAO,IAAA,oBAAM,EAAC,aAAa,CAAC,CAAA;AAC9B,CAAC;AA8CD,MAAa,sBAAsB;IAGjC,YAA6B,QAAqB;QAArB,aAAQ,GAAR,QAAQ,CAAa;QAIzC,0BAA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C/C,IAAI,QAAQ,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;gBACzB,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAA;YACpB,CAAC;QACH,CAAC;QAED,MAAM,IAAA,oBAAK,EACT,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAC3C,CAAC,EACD,KAAK,EACL,KAAK,EACL,CAAC,EACD,CAAC,CAAM,EAAE,EAAE;YACT,IACE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,2CAA2C,CAAC;gBAC/D,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,4DAA4D,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,6DAA6D,CAAC,CAAC,EACrK,CAAC;gBACD,kBAAG,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;gBACjG,OAAO,IAAI,CAAA;YACb,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC,CACF,CAAA;IACH,CAAC;CACF;AAvWD,wDAuWC;AAED,SAAgB,SAAS;IACvB,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IAC/B,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AACrE,CAAC","sourcesContent":["import { InvalidConfigurationError, asArray, log, retry } from \"builder-util\"\nimport { getBin } from \"../binDownload\"\nimport { WindowsConfiguration } from \"../options/winOptions\"\nimport { executeAppBuilderAsJson } from \"../util/appBuilder\"\nimport { computeToolEnv, ToolInfo } from \"../util/bundledTool\"\nimport { rename } from \"fs-extra\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { isUseSystemSigncode } from \"../util/flags\"\nimport { VmManager } from \"../vm/vm\"\nimport { WinPackager } from \"../winPackager\"\nimport { chooseNotNull } from \"../platformPackager\"\nimport { WindowsSignOptions } from \"./windowsCodeSign\"\nimport { getPSCmd } from \"./windowsCodeSign\"\nimport { MemoLazy, parseDn } from \"builder-util-runtime\"\nimport { Lazy } from \"lazy-val\"\nimport { importCertificate } from \"./codesign\"\n\nexport function getSignVendorPath() {\n return getBin(\"winCodeSign\")\n}\n\nexport type CustomWindowsSign = (configuration: CustomWindowsSignTaskConfiguration, packager?: WinPackager) => Promise<any>\n\nexport interface WindowsSignToolOptions extends WindowsSignOptions {\n readonly name: string\n readonly site: string | null\n}\n\nexport interface FileCodeSigningInfo {\n readonly file: string\n readonly password: string | null\n}\n\nexport interface WindowsSignTaskConfiguration extends WindowsSignToolOptions {\n readonly cscInfo: FileCodeSigningInfo | CertificateFromStoreInfo | null\n\n // set if output path differs from input (e.g. osslsigncode cannot sign file in-place)\n resultOutputPath?: string\n\n hash: string\n isNest: boolean\n}\n\nexport interface CustomWindowsSignTaskConfiguration extends WindowsSignTaskConfiguration {\n computeSignToolArgs(isWin: boolean): Array<string>\n}\n\nexport interface CertificateInfo {\n readonly commonName: string\n readonly bloodyMicrosoftSubjectDn: string\n}\n\nexport interface CertificateFromStoreInfo {\n thumbprint: string\n subject: string\n store: string\n isLocalMachineStore: boolean\n}\n\ninterface CertInfo {\n Subject: string\n Thumbprint: string\n PSParentPath: string\n}\n\nexport class WindowsSignToolManager {\n private readonly platformSpecificBuildOptions: WindowsConfiguration\n\n constructor(private readonly packager: WinPackager) {\n this.platformSpecificBuildOptions = packager.platformSpecificBuildOptions\n }\n\n readonly computedPublisherName = new Lazy<Array<string> | null>(async () => {\n const publisherName = chooseNotNull(this.platformSpecificBuildOptions.signtoolOptions?.publisherName, this.platformSpecificBuildOptions.publisherName)\n if (publisherName === null) {\n return null\n } else if (publisherName != null) {\n return asArray(publisherName)\n }\n\n const certInfo = await this.lazyCertInfo.value\n return certInfo == null ? null : [certInfo.commonName]\n })\n\n readonly lazyCertInfo = new MemoLazy<MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>, CertificateInfo | null>(\n () => this.cscInfo,\n async csc => {\n const cscInfo = await csc.value\n if (cscInfo == null) {\n return null\n }\n\n if (\"subject\" in cscInfo) {\n const bloodyMicrosoftSubjectDn = cscInfo.subject\n return {\n commonName: parseDn(bloodyMicrosoftSubjectDn).get(\"CN\")!,\n bloodyMicrosoftSubjectDn,\n }\n }\n\n const cscFile = cscInfo.file\n if (cscFile == null) {\n return null\n }\n return await this.getCertInfo(cscFile, cscInfo.password || \"\")\n }\n )\n\n readonly cscInfo = new MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>(\n () => this.platformSpecificBuildOptions,\n platformSpecificBuildOptions => {\n const subjectName = chooseNotNull(platformSpecificBuildOptions.signtoolOptions?.certificateSubjectName, platformSpecificBuildOptions.certificateSubjectName)\n const shaType = chooseNotNull(platformSpecificBuildOptions.signtoolOptions?.certificateSha1, platformSpecificBuildOptions.certificateSha1)\n if (subjectName != null || shaType != null) {\n return this.packager.vm.value\n .then(vm => this.getCertificateFromStoreInfo(platformSpecificBuildOptions, vm))\n .catch((e: any) => {\n // https://github.com/electron-userland/electron-builder/pull/2397\n if (chooseNotNull(platformSpecificBuildOptions.signtoolOptions?.sign, platformSpecificBuildOptions.sign) == null) {\n throw e\n } else {\n log.debug({ error: e }, \"getCertificateFromStoreInfo error\")\n return null\n }\n })\n }\n\n const certificateFile = chooseNotNull(platformSpecificBuildOptions.signtoolOptions?.certificateFile, platformSpecificBuildOptions.certificateFile)\n if (certificateFile != null) {\n const certificatePassword = this.packager.getCscPassword()\n return Promise.resolve({\n file: certificateFile,\n password: certificatePassword == null ? null : certificatePassword.trim(),\n })\n }\n\n const cscLink = this.packager.getCscLink(\"WIN_CSC_LINK\")\n if (cscLink == null || cscLink === \"\") {\n return Promise.resolve(null)\n }\n\n return (\n importCertificate(cscLink, this.packager.info.tempDirManager, this.packager.projectDir)\n // before then\n .catch((e: any) => {\n if (e instanceof InvalidConfigurationError) {\n throw new InvalidConfigurationError(`Env WIN_CSC_LINK is not correct, cannot resolve: ${e.message}`)\n } else {\n throw e\n }\n })\n .then(path => {\n return {\n file: path,\n password: this.packager.getCscPassword(),\n }\n })\n )\n }\n )\n\n async signUsingSigntool(options: WindowsSignOptions): Promise<boolean> {\n let hashes = chooseNotNull(options.options.signtoolOptions?.signingHashAlgorithms, options.options.signingHashAlgorithms)\n // msi does not support dual-signing\n if (options.path.endsWith(\".msi\")) {\n hashes = [hashes != null && !hashes.includes(\"sha1\") ? \"sha256\" : \"sha1\"]\n } else if (options.path.endsWith(\".appx\")) {\n hashes = [\"sha256\"]\n } else if (hashes == null) {\n hashes = [\"sha1\", \"sha256\"]\n } else {\n hashes = Array.isArray(hashes) ? hashes : [hashes]\n }\n\n const cscInfo = await this.cscInfo.value\n const name = this.packager.appInfo.productName\n const site = await this.packager.appInfo.computePackageUrl()\n\n const customSign = await resolveFunction(this.packager.appInfo.type, chooseNotNull(options.options.signtoolOptions?.sign, options.options.sign), \"sign\")\n const executor = customSign || ((config: CustomWindowsSignTaskConfiguration, packager: WinPackager) => this.doSign(config, packager))\n let isNest = false\n for (const hash of hashes) {\n const taskConfiguration: WindowsSignTaskConfiguration = { ...options, name, site, cscInfo, hash, isNest }\n await Promise.resolve(\n executor(\n {\n ...taskConfiguration,\n computeSignToolArgs: isWin => this.computeSignToolArgs(taskConfiguration, isWin),\n },\n this.packager\n )\n )\n isNest = true\n if (taskConfiguration.resultOutputPath != null) {\n await rename(taskConfiguration.resultOutputPath, options.path)\n }\n }\n\n return true\n }\n\n async getCertInfo(file: string, password: string): Promise<CertificateInfo> {\n let result: any = null\n const errorMessagePrefix = \"Cannot extract publisher name from code signing certificate. As workaround, set win.publisherName. Error: \"\n try {\n result = await executeAppBuilderAsJson<any>([\"certificate-info\", \"--input\", file, \"--password\", password])\n } catch (e: any) {\n throw new Error(`${errorMessagePrefix}${e.stack || e}`)\n }\n\n if (result.error != null) {\n // noinspection ExceptionCaughtLocallyJS\n throw new InvalidConfigurationError(`${errorMessagePrefix}${result.error}`)\n }\n return result\n }\n\n // on windows be aware of http://stackoverflow.com/a/32640183/1910191\n computeSignToolArgs(options: WindowsSignTaskConfiguration, isWin: boolean, vm: VmManager = new VmManager()): Array<string> {\n const inputFile = vm.toVmFile(options.path)\n const outputPath = isWin ? inputFile : this.getOutputPath(inputFile, options.hash)\n if (!isWin) {\n options.resultOutputPath = outputPath\n }\n\n const args = isWin ? [\"sign\"] : [\"-in\", inputFile, \"-out\", outputPath]\n\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const timestampingServiceUrl = chooseNotNull(options.options.signtoolOptions?.timeStampServer, options.options.timeStampServer) || \"http://timestamp.digicert.com\"\n if (isWin) {\n args.push(\n options.isNest || options.hash === \"sha256\" ? \"/tr\" : \"/t\",\n options.isNest || options.hash === \"sha256\"\n ? chooseNotNull(options.options.signtoolOptions?.rfc3161TimeStampServer, options.options.rfc3161TimeStampServer) || \"http://timestamp.digicert.com\"\n : timestampingServiceUrl\n )\n } else {\n args.push(\"-t\", timestampingServiceUrl)\n }\n }\n\n const certificateFile = (options.cscInfo as FileCodeSigningInfo).file\n if (certificateFile == null) {\n const cscInfo = options.cscInfo as CertificateFromStoreInfo\n const subjectName = cscInfo.thumbprint\n if (!isWin) {\n throw new Error(`${subjectName == null ? \"certificateSha1\" : \"certificateSubjectName\"} supported only on Windows`)\n }\n\n args.push(\"/sha1\", cscInfo.thumbprint)\n args.push(\"/s\", cscInfo.store)\n if (cscInfo.isLocalMachineStore) {\n args.push(\"/sm\")\n }\n } else {\n const certExtension = path.extname(certificateFile)\n if (certExtension === \".p12\" || certExtension === \".pfx\") {\n args.push(isWin ? \"/f\" : \"-pkcs12\", vm.toVmFile(certificateFile))\n } else {\n throw new Error(`Please specify pkcs12 (.p12/.pfx) file, ${certificateFile} is not correct`)\n }\n }\n\n if (!isWin || options.hash !== \"sha1\") {\n args.push(isWin ? \"/fd\" : \"-h\", options.hash)\n if (isWin && process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n args.push(\"/td\", \"sha256\")\n }\n }\n\n if (options.name) {\n args.push(isWin ? \"/d\" : \"-n\", options.name)\n }\n\n if (options.site) {\n args.push(isWin ? \"/du\" : \"-i\", options.site)\n }\n\n // msi does not support dual-signing\n if (options.isNest) {\n args.push(isWin ? \"/as\" : \"-nest\")\n }\n\n const password = options.cscInfo == null ? null : (options.cscInfo as FileCodeSigningInfo).password\n if (password) {\n args.push(isWin ? \"/p\" : \"-pass\", password)\n }\n\n const additionalCert = chooseNotNull(options.options.signtoolOptions?.additionalCertificateFile, options.options.additionalCertificateFile)\n if (additionalCert) {\n args.push(isWin ? \"/ac\" : \"-ac\", vm.toVmFile(additionalCert))\n }\n\n const httpsProxyFromEnv = process.env.HTTPS_PROXY\n if (!isWin && httpsProxyFromEnv != null && httpsProxyFromEnv.length) {\n args.push(\"-p\", httpsProxyFromEnv)\n }\n\n if (isWin) {\n // https://github.com/electron-userland/electron-builder/issues/2875#issuecomment-387233610\n args.push(\"/debug\")\n // must be last argument\n args.push(inputFile)\n }\n\n return args\n }\n\n getOutputPath(inputPath: string, hash: string) {\n const extension = path.extname(inputPath)\n return path.join(path.dirname(inputPath), `${path.basename(inputPath, extension)}-signed-${hash}${extension}`)\n }\n\n getWinSignTool(vendorPath: string): string {\n // use modern signtool on Windows Server 2012 R2 to be able to sign AppX\n if (isOldWin6()) {\n return path.join(vendorPath, \"windows-6\", \"signtool.exe\")\n } else {\n return path.join(vendorPath, \"windows-10\", process.arch, \"signtool.exe\")\n }\n }\n\n async getToolPath(isWin = process.platform === \"win32\"): Promise<ToolInfo> {\n if (isUseSystemSigncode()) {\n return { path: \"osslsigncode\" }\n }\n\n const result = process.env.SIGNTOOL_PATH\n if (result) {\n return { path: result }\n }\n\n const vendorPath = await getSignVendorPath()\n if (isWin) {\n // use modern signtool on Windows Server 2012 R2 to be able to sign AppX\n return { path: this.getWinSignTool(vendorPath) }\n } else if (process.platform === \"darwin\") {\n const toolDirPath = path.join(vendorPath, process.platform, \"10.12\")\n return {\n path: path.join(toolDirPath, \"osslsigncode\"),\n env: computeToolEnv([path.join(toolDirPath, \"lib\")]),\n }\n } else {\n return { path: path.join(vendorPath, process.platform, \"osslsigncode\") }\n }\n }\n\n async getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {\n const certificateSubjectName = chooseNotNull(options.signtoolOptions?.certificateSubjectName, options.certificateSubjectName)\n const certificateSha1 = chooseNotNull(options.signtoolOptions?.certificateSha1, options.certificateSha1)?.toUpperCase()\n\n const ps = await getPSCmd(vm)\n const rawResult = await vm.exec(ps, [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n \"Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress\",\n ])\n const certList = rawResult.length === 0 ? [] : asArray<CertInfo>(JSON.parse(rawResult))\n for (const certInfo of certList) {\n if (\n (certificateSubjectName != null && !certInfo.Subject.includes(certificateSubjectName)) ||\n (certificateSha1 != null && certInfo.Thumbprint.toUpperCase() !== certificateSha1)\n ) {\n continue\n }\n\n const parentPath = certInfo.PSParentPath\n const store = parentPath.substring(parentPath.lastIndexOf(\"\\\\\") + 1)\n log.debug({ store, PSParentPath: parentPath }, \"auto-detect certificate store\")\n // https://github.com/electron-userland/electron-builder/issues/1717\n const isLocalMachineStore = parentPath.includes(\"Certificate::LocalMachine\")\n log.debug(null, \"auto-detect using of LocalMachine store\")\n return {\n thumbprint: certInfo.Thumbprint,\n subject: certInfo.Subject,\n store,\n isLocalMachineStore,\n }\n }\n\n throw new Error(`Cannot find certificate ${certificateSubjectName || certificateSha1}, all certs: ${rawResult}`)\n }\n\n async doSign(configuration: CustomWindowsSignTaskConfiguration, packager: WinPackager) {\n // https://github.com/electron-userland/electron-builder/pull/1944\n const timeout = parseInt(process.env.SIGNTOOL_TIMEOUT as any, 10) || 10 * 60 * 1000\n // decide runtime argument by cases\n let args: Array<string>\n let env = process.env\n let vm: VmManager\n const vmRequired = configuration.path.endsWith(\".appx\") || !(\"file\" in configuration.cscInfo!) /* certificateSubjectName and other such options */\n const isWin = process.platform === \"win32\" || vmRequired\n const toolInfo = await this.getToolPath(isWin)\n const tool = toolInfo.path\n if (vmRequired) {\n vm = await packager.vm.value\n args = this.computeSignToolArgs(configuration, isWin, vm)\n } else {\n vm = new VmManager()\n args = configuration.computeSignToolArgs(isWin)\n if (toolInfo.env != null) {\n env = toolInfo.env\n }\n }\n\n await retry(\n () => vm.exec(tool, args, { timeout, env }),\n 2,\n 15000,\n 10000,\n 0,\n (e: any) => {\n if (\n e.message.includes(\"The file is being used by another process\") ||\n e.message.includes(\"The specified timestamp server either could not be reached\" || e.message.includes(\"No certificates were found that met all the given criteria.\"))\n ) {\n log.warn(`Attempt to code sign failed, another attempt will be made in 15 seconds: ${e.message}`)\n return true\n }\n return false\n }\n )\n }\n}\n\nexport function isOldWin6() {\n const winVersion = os.release()\n return winVersion.startsWith(\"6.\") && !winVersion.startsWith(\"6.3\")\n}\n"]}
@@ -147,7 +147,7 @@ export interface Configuration extends PlatformSpecificBuildOptions {
147
147
  /**
148
148
  * Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory
149
149
  */
150
- readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string);
150
+ readonly electronDist?: string | CustomElectronDistributable;
151
151
  /**
152
152
  * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.
153
153
  */
@@ -193,49 +193,49 @@ export interface Configuration extends PlatformSpecificBuildOptions {
193
193
  /**
194
194
  * The function (or path to file or module id) to be [run before pack](#beforepack)
195
195
  */
196
- readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null;
196
+ readonly beforePack?: Hook<BeforePackContext, any> | string | null;
197
197
  /**
198
198
  * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)
199
199
  */
200
- readonly afterExtract?: ((context: AfterExtractContext) => Promise<any> | any) | string | null;
200
+ readonly afterExtract?: Hook<AfterExtractContext, any> | string | null;
201
201
  /**
202
202
  * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).
203
203
  */
204
- readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
204
+ readonly afterPack?: Hook<AfterPackContext, any> | string | null;
205
205
  /**
206
206
  * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).
207
207
  */
208
- readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
208
+ readonly afterSign?: Hook<AfterPackContext, any> | string | null;
209
209
  /**
210
210
  * The function (or path to file or module id) to be run on artifact build start.
211
211
  */
212
- readonly artifactBuildStarted?: ((context: ArtifactBuildStarted) => Promise<any> | any) | string | null;
212
+ readonly artifactBuildStarted?: Hook<ArtifactBuildStarted, any> | string | null;
213
213
  /**
214
214
  * The function (or path to file or module id) to be run on artifact build completed.
215
215
  */
216
- readonly artifactBuildCompleted?: ((context: ArtifactCreated) => Promise<any> | any) | string | null;
216
+ readonly artifactBuildCompleted?: Hook<ArtifactCreated, any> | string | null;
217
217
  /**
218
218
  * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).
219
219
  */
220
- readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null;
220
+ readonly afterAllArtifactBuild?: Hook<BuildResult, Array<string>> | string | null;
221
221
  /**
222
222
  * MSI project created on disk - not packed into .msi package yet.
223
223
  */
224
- readonly msiProjectCreated?: ((path: string) => Promise<any> | any) | string | null;
224
+ readonly msiProjectCreated?: Hook<string, any> | string | null;
225
225
  /**
226
226
  * Appx manifest created on disk - not packed into .appx package yet.
227
227
  */
228
- readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null;
228
+ readonly appxManifestCreated?: Hook<string, any> | string | null;
229
229
  /**
230
230
  * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic
231
231
  */
232
- readonly onNodeModuleFile?: ((path: string) => void | boolean) | string | null;
232
+ readonly onNodeModuleFile?: Hook<string, void | boolean> | string | null;
233
233
  /**
234
234
  * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.
235
235
  *
236
236
  * If provided and `node_modules` are missing, it will not invoke production dependencies check.
237
237
  */
238
- readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null;
238
+ readonly beforeBuild?: Hook<BeforeBuildContext, boolean | void> | string | null;
239
239
  /**
240
240
  * Whether to include PDB files.
241
241
  * @default false
@@ -288,4 +288,6 @@ export interface MetadataDirectories {
288
288
  */
289
289
  readonly app?: string | null;
290
290
  }
291
+ export type CustomElectronDistributable = (options: PrepareApplicationStageDirectoryOptions) => string;
292
+ export type Hook<T, V> = (contextOrPath: T) => Promise<V> | V;
291
293
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"","sourcesContent":["import { Arch } from \"builder-util\"\nimport { BeforeBuildContext, Target } from \"./core\"\nimport { ElectronBrandingOptions, ElectronDownloadOptions } from \"./electron/ElectronFramework\"\nimport { PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nimport { AppXOptions } from \"./options/AppXOptions\"\nimport { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nimport { DmgOptions, MacConfiguration, MasConfiguration } from \"./options/macOptions\"\nimport { MsiOptions } from \"./options/MsiOptions\"\nimport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nimport { PkgOptions } from \"./options/pkgOptions\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { SnapOptions } from \"./options/SnapOptions\"\nimport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nimport { WindowsConfiguration } from \"./options/winOptions\"\nimport { BuildResult } from \"./packager\"\nimport { ArtifactBuildStarted, ArtifactCreated } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\n// duplicate appId here because it is important\n/**\n * Configuration Options\n */\nexport interface Configuration extends PlatformSpecificBuildOptions {\n /**\n * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as\n * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.\n * @default com.electron.${name}\n */\n readonly appId?: string | null\n\n /**\n * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\n * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.\n */\n readonly productName?: string | null\n\n /**\n * The human-readable copyright line for the app.\n * @default Copyright © year ${author}\n */\n readonly copyright?: string | null\n\n readonly directories?: MetadataDirectories | null\n\n /**\n * Options related to how build macOS targets.\n */\n readonly mac?: MacConfiguration | null\n /**\n * MAS (Mac Application Store) options.\n */\n readonly mas?: MasConfiguration | null\n /**\n * MAS (Mac Application Store) development options (`mas-dev` target).\n */\n readonly masDev?: MasConfiguration | null\n /**\n * macOS DMG options.\n */\n readonly dmg?: DmgOptions | null\n /**\n * macOS PKG options.\n */\n readonly pkg?: PkgOptions | null\n\n /**\n * Options related to how build Windows targets.\n */\n readonly win?: WindowsConfiguration | null\n readonly nsis?: NsisOptions | null\n readonly nsisWeb?: NsisWebOptions | null\n readonly portable?: PortableOptions | null\n readonly appx?: AppXOptions | null\n /** @private */\n readonly msi?: MsiOptions | null\n /** @private */\n readonly msiWrapped?: MsiWrappedOptions | null\n readonly squirrelWindows?: SquirrelWindowsOptions | null\n\n /**\n * Options related to how build Linux targets.\n */\n readonly linux?: LinuxConfiguration | null\n /**\n * Debian package options.\n */\n readonly deb?: DebOptions | null\n /**\n * Snap options.\n */\n readonly snap?: SnapOptions | null\n /**\n * AppImage options.\n */\n readonly appImage?: AppImageOptions | null\n /**\n * Flatpak options.\n */\n readonly flatpak?: FlatpakOptions | null\n readonly pacman?: LinuxTargetSpecificOptions | null\n readonly rpm?: LinuxTargetSpecificOptions | null\n readonly freebsd?: LinuxTargetSpecificOptions | null\n readonly p5p?: LinuxTargetSpecificOptions | null\n readonly apk?: LinuxTargetSpecificOptions | null\n\n /**\n * Whether to include *all* of the submodules node_modules directories\n * @default false\n */\n includeSubNodeModules?: boolean\n\n /**\n * Whether to build the application native dependencies from source.\n * @default false\n */\n buildDependenciesFromSource?: boolean\n /**\n * Whether to execute `node-gyp rebuild` before starting to package the app.\n *\n * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.\n * @default false\n */\n readonly nodeGypRebuild?: boolean\n /**\n * Additional command line arguments to use when installing app native deps.\n */\n readonly npmArgs?: Array<string> | string | null\n /**\n * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.\n * @default true\n */\n readonly npmRebuild?: boolean\n /**\n * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.\n * @default sequential\n */\n readonly nativeRebuilder?: \"legacy\" | \"sequential\" | \"parallel\" | null\n\n /**\n * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.\n * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.\n */\n readonly buildNumber?: string | null\n\n /**\n * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\n * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).\n */\n readonly buildVersion?: string | null\n\n /**\n * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing\n */\n readonly downloadAlternateFFmpeg?: boolean\n\n /**\n * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.\n */\n readonly electronCompile?: boolean\n\n /**\n * Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory\n */\n readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string)\n\n /**\n * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.\n */\n readonly electronDownload?: ElectronDownloadOptions\n\n /**\n * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.\n */\n readonly electronBranding?: ElectronBrandingOptions\n\n /**\n * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.\n */\n electronVersion?: string | null\n\n /**\n * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).\n *\n * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.\n *\n * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.\n */\n extends?: Array<string> | string | null\n\n /**\n * Inject properties to `package.json`.\n */\n readonly extraMetadata?: any\n\n /**\n * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).\n * @default false\n */\n readonly forceCodeSigning?: boolean\n\n /**\n * *libui-based frameworks only* The version of NodeJS you are packaging for.\n * You can set it to `current` to set the Node.js version that you use to run.\n */\n readonly nodeVersion?: string | null\n\n /**\n * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.\n */\n readonly launchUiVersion?: boolean | string | null\n\n /**\n * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.\n */\n readonly framework?: string | null\n\n /**\n * The function (or path to file or module id) to be [run before pack](#beforepack)\n */\n readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)\n */\n readonly afterExtract?: ((context: AfterExtractContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).\n */\n readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).\n */\n readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null\n\n /**\n * The function (or path to file or module id) to be run on artifact build start.\n */\n readonly artifactBuildStarted?: ((context: ArtifactBuildStarted) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be run on artifact build completed.\n */\n readonly artifactBuildCompleted?: ((context: ArtifactCreated) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).\n */\n readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null\n /**\n * MSI project created on disk - not packed into .msi package yet.\n */\n readonly msiProjectCreated?: ((path: string) => Promise<any> | any) | string | null\n /**\n * Appx manifest created on disk - not packed into .appx package yet.\n */\n readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null\n /**\n * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic\n */\n readonly onNodeModuleFile?: ((path: string) => void | boolean) | string | null\n /**\n * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n *\n * If provided and `node_modules` are missing, it will not invoke production dependencies check.\n */\n readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null\n\n /**\n * Whether to include PDB files.\n * @default false\n */\n readonly includePdb?: boolean\n\n /**\n * Whether to remove `scripts` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageScripts?: boolean\n\n /**\n * Whether to remove `keywords` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageKeywords?: boolean\n\n /**\n * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)\n * @default false\n */\n readonly disableSanityCheckAsar?: boolean\n}\n\ninterface PackContext {\n readonly outDir: string\n readonly appOutDir: string\n readonly packager: PlatformPackager<any>\n readonly electronPlatformName: string\n readonly arch: Arch\n readonly targets: Array<Target>\n}\nexport type AfterPackContext = PackContext\nexport type BeforePackContext = PackContext\nexport type AfterExtractContext = PackContext\n\nexport interface MetadataDirectories {\n /**\n * The path to build resources.\n *\n * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `\"files\": [\"**\\/*\", \"build/icon.*\"]`\n * @default build\n */\n readonly buildResources?: string | null\n\n /**\n * The output directory. [File macros](/file-patterns#file-macros) are supported.\n * @default dist\n */\n readonly output?: string | null\n\n /**\n * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.\n */\n readonly app?: string | null\n}\n"]}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"","sourcesContent":["import { Arch } from \"builder-util\"\nimport { BeforeBuildContext, Target } from \"./core\"\nimport { ElectronBrandingOptions, ElectronDownloadOptions } from \"./electron/ElectronFramework\"\nimport { PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nimport { AppXOptions } from \"./options/AppXOptions\"\nimport { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nimport { DmgOptions, MacConfiguration, MasConfiguration } from \"./options/macOptions\"\nimport { MsiOptions } from \"./options/MsiOptions\"\nimport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nimport { PkgOptions } from \"./options/pkgOptions\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { SnapOptions } from \"./options/SnapOptions\"\nimport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nimport { WindowsConfiguration } from \"./options/winOptions\"\nimport { BuildResult } from \"./packager\"\nimport { ArtifactBuildStarted, ArtifactCreated } from \"./packagerApi\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport { NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\n// duplicate appId here because it is important\n/**\n * Configuration Options\n */\nexport interface Configuration extends PlatformSpecificBuildOptions {\n /**\n * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as\n * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.\n * @default com.electron.${name}\n */\n readonly appId?: string | null\n\n /**\n * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\n * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.\n */\n readonly productName?: string | null\n\n /**\n * The human-readable copyright line for the app.\n * @default Copyright © year ${author}\n */\n readonly copyright?: string | null\n\n readonly directories?: MetadataDirectories | null\n\n /**\n * Options related to how build macOS targets.\n */\n readonly mac?: MacConfiguration | null\n /**\n * MAS (Mac Application Store) options.\n */\n readonly mas?: MasConfiguration | null\n /**\n * MAS (Mac Application Store) development options (`mas-dev` target).\n */\n readonly masDev?: MasConfiguration | null\n /**\n * macOS DMG options.\n */\n readonly dmg?: DmgOptions | null\n /**\n * macOS PKG options.\n */\n readonly pkg?: PkgOptions | null\n\n /**\n * Options related to how build Windows targets.\n */\n readonly win?: WindowsConfiguration | null\n readonly nsis?: NsisOptions | null\n readonly nsisWeb?: NsisWebOptions | null\n readonly portable?: PortableOptions | null\n readonly appx?: AppXOptions | null\n /** @private */\n readonly msi?: MsiOptions | null\n /** @private */\n readonly msiWrapped?: MsiWrappedOptions | null\n readonly squirrelWindows?: SquirrelWindowsOptions | null\n\n /**\n * Options related to how build Linux targets.\n */\n readonly linux?: LinuxConfiguration | null\n /**\n * Debian package options.\n */\n readonly deb?: DebOptions | null\n /**\n * Snap options.\n */\n readonly snap?: SnapOptions | null\n /**\n * AppImage options.\n */\n readonly appImage?: AppImageOptions | null\n /**\n * Flatpak options.\n */\n readonly flatpak?: FlatpakOptions | null\n readonly pacman?: LinuxTargetSpecificOptions | null\n readonly rpm?: LinuxTargetSpecificOptions | null\n readonly freebsd?: LinuxTargetSpecificOptions | null\n readonly p5p?: LinuxTargetSpecificOptions | null\n readonly apk?: LinuxTargetSpecificOptions | null\n\n /**\n * Whether to include *all* of the submodules node_modules directories\n * @default false\n */\n includeSubNodeModules?: boolean\n\n /**\n * Whether to build the application native dependencies from source.\n * @default false\n */\n buildDependenciesFromSource?: boolean\n /**\n * Whether to execute `node-gyp rebuild` before starting to package the app.\n *\n * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.\n * @default false\n */\n readonly nodeGypRebuild?: boolean\n /**\n * Additional command line arguments to use when installing app native deps.\n */\n readonly npmArgs?: Array<string> | string | null\n /**\n * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.\n * @default true\n */\n readonly npmRebuild?: boolean\n /**\n * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.\n * @default sequential\n */\n readonly nativeRebuilder?: \"legacy\" | \"sequential\" | \"parallel\" | null\n\n /**\n * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.\n * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.\n */\n readonly buildNumber?: string | null\n\n /**\n * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\n * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).\n */\n readonly buildVersion?: string | null\n\n /**\n * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing\n */\n readonly downloadAlternateFFmpeg?: boolean\n\n /**\n * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.\n */\n readonly electronCompile?: boolean\n\n /**\n * Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory\n */\n readonly electronDist?: string | CustomElectronDistributable\n\n /**\n * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.\n */\n readonly electronDownload?: ElectronDownloadOptions\n\n /**\n * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.\n */\n readonly electronBranding?: ElectronBrandingOptions\n\n /**\n * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.\n */\n electronVersion?: string | null\n\n /**\n * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).\n *\n * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.\n *\n * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.\n */\n extends?: Array<string> | string | null\n\n /**\n * Inject properties to `package.json`.\n */\n readonly extraMetadata?: any\n\n /**\n * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).\n * @default false\n */\n readonly forceCodeSigning?: boolean\n\n /**\n * *libui-based frameworks only* The version of NodeJS you are packaging for.\n * You can set it to `current` to set the Node.js version that you use to run.\n */\n readonly nodeVersion?: string | null\n\n /**\n * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.\n */\n readonly launchUiVersion?: boolean | string | null\n\n /**\n * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.\n */\n readonly framework?: string | null\n\n /**\n * The function (or path to file or module id) to be [run before pack](#beforepack)\n */\n readonly beforePack?: Hook<BeforePackContext, any> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)\n */\n readonly afterExtract?: Hook<AfterExtractContext, any> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).\n */\n readonly afterPack?: Hook<AfterPackContext, any> | string | null\n\n /**\n * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).\n */\n readonly afterSign?: Hook<AfterPackContext, any> | string | null\n\n /**\n * The function (or path to file or module id) to be run on artifact build start.\n */\n readonly artifactBuildStarted?: Hook<ArtifactBuildStarted, any> | string | null\n /**\n * The function (or path to file or module id) to be run on artifact build completed.\n */\n readonly artifactBuildCompleted?: Hook<ArtifactCreated, any> | string | null\n /**\n * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).\n */\n readonly afterAllArtifactBuild?: Hook<BuildResult, Array<string>> | string | null\n /**\n * MSI project created on disk - not packed into .msi package yet.\n */\n readonly msiProjectCreated?: Hook<string, any> | string | null\n /**\n * Appx manifest created on disk - not packed into .appx package yet.\n */\n readonly appxManifestCreated?: Hook<string, any> | string | null\n /**\n * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic\n */\n readonly onNodeModuleFile?: Hook<string, void | boolean> | string | null\n /**\n * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n *\n * If provided and `node_modules` are missing, it will not invoke production dependencies check.\n */\n readonly beforeBuild?: Hook<BeforeBuildContext, boolean | void> | string | null\n\n /**\n * Whether to include PDB files.\n * @default false\n */\n readonly includePdb?: boolean\n\n /**\n * Whether to remove `scripts` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageScripts?: boolean\n\n /**\n * Whether to remove `keywords` field from `package.json` files.\n *\n * @default true\n */\n readonly removePackageKeywords?: boolean\n\n /**\n * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)\n * @default false\n */\n readonly disableSanityCheckAsar?: boolean\n}\n\ninterface PackContext {\n readonly outDir: string\n readonly appOutDir: string\n readonly packager: PlatformPackager<any>\n readonly electronPlatformName: string\n readonly arch: Arch\n readonly targets: Array<Target>\n}\nexport type AfterPackContext = PackContext\nexport type BeforePackContext = PackContext\nexport type AfterExtractContext = PackContext\n\nexport interface MetadataDirectories {\n /**\n * The path to build resources.\n *\n * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `\"files\": [\"**\\/*\", \"build/icon.*\"]`\n * @default build\n */\n readonly buildResources?: string | null\n\n /**\n * The output directory. [File macros](/file-patterns#file-macros) are supported.\n * @default dist\n */\n readonly output?: string | null\n\n /**\n * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.\n */\n readonly app?: string | null\n}\n\nexport type CustomElectronDistributable = (options: PrepareApplicationStageDirectoryOptions) => string\n\nexport type Hook<T, V> = (contextOrPath: T) => Promise<V> | V\n"]}
@@ -32,6 +32,6 @@ async function addWinAsarIntegrity(executablePath, asarIntegrity) {
32
32
  });
33
33
  resource.outputResource(executable);
34
34
  await (0, promises_1.writeFile)(executablePath, Buffer.from(executable.generate()));
35
- builder_util_1.log.info({ executablePath }, "updating asar integrity executable resource");
35
+ builder_util_1.log.info({ executablePath: builder_util_1.log.filePath(executablePath) }, "updating asar integrity executable resource");
36
36
  }
37
37
  //# sourceMappingURL=electronWin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"electronWin.js","sourceRoot":"","sources":["../../src/electron/electronWin.ts"],"names":[],"mappings":";;AAMA,kDAkCC;AAxCD,0CAAiD;AACjD,+CAAkC;AAClC,qCAAsE;AAGtE,gBAAgB;AACT,KAAK,UAAU,mBAAmB,CAAC,cAAsB,EAAE,aAA4B;IAC5F,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,cAAc,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,sBAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,8BAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAEtD,MAAM,WAAW,GAAG,kBAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACtE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,mCAAmC,cAAc,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAA;IACjE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,cAAc,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,8GAA8G;IAC9G,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChH,IAAI;QACJ,GAAG;QACH,KAAK;KACN,CAAC,CAAC,CAAA;IAEH,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,IAAI,EAAE,WAAW;QACjB,EAAE,EAAE,cAAc;QAClB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;QACvB,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ;KAChC,CAAC,CAAA;IAEF,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IAEnC,MAAM,IAAA,oBAAS,EAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACnE,kBAAG,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,EAAE,6CAA6C,CAAC,CAAA;AAC7E,CAAC","sourcesContent":["import { readFile, writeFile } from \"fs/promises\"\nimport { log } from \"builder-util\"\nimport { NtExecutable, NtExecutableResource, Resource } from \"resedit\"\nimport { AsarIntegrity } from \"../asar/integrity\"\n\n/** @internal */\nexport async function addWinAsarIntegrity(executablePath: string, asarIntegrity: AsarIntegrity) {\n const buffer = await readFile(executablePath)\n const executable = NtExecutable.from(buffer)\n const resource = NtExecutableResource.from(executable)\n\n const versionInfo = Resource.VersionInfo.fromEntries(resource.entries)\n if (versionInfo.length !== 1) {\n throw new Error(`Failed to parse version info in ${executablePath}`)\n }\n\n const languages = versionInfo[0].getAllLanguagesForStringValues()\n if (languages.length !== 1) {\n throw new Error(`Failed to locate languages in ${executablePath}`)\n }\n\n // See: https://github.com/electron/packager/blob/00d20b99cf4aa4621103dbbd09ff7de7d2f7f539/src/resedit.ts#L124\n const integrityList = Array.from(Object.entries(asarIntegrity)).map(([file, { algorithm: alg, hash: value }]) => ({\n file,\n alg,\n value,\n }))\n\n resource.entries.push({\n type: \"INTEGRITY\",\n id: \"ELECTRONASAR\",\n bin: Buffer.from(JSON.stringify(integrityList)),\n lang: languages[0].lang,\n codepage: languages[0].codepage,\n })\n\n resource.outputResource(executable)\n\n await writeFile(executablePath, Buffer.from(executable.generate()))\n log.info({ executablePath }, \"updating asar integrity executable resource\")\n}\n"]}
1
+ {"version":3,"file":"electronWin.js","sourceRoot":"","sources":["../../src/electron/electronWin.ts"],"names":[],"mappings":";;AAMA,kDAkCC;AAxCD,0CAAiD;AACjD,+CAAkC;AAClC,qCAAsE;AAGtE,gBAAgB;AACT,KAAK,UAAU,mBAAmB,CAAC,cAAsB,EAAE,aAA4B;IAC5F,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,cAAc,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,sBAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,8BAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAEtD,MAAM,WAAW,GAAG,kBAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACtE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,mCAAmC,cAAc,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAA;IACjE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,cAAc,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,8GAA8G;IAC9G,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChH,IAAI;QACJ,GAAG;QACH,KAAK;KACN,CAAC,CAAC,CAAA;IAEH,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,IAAI,EAAE,WAAW;QACjB,EAAE,EAAE,cAAc;QAClB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;QACvB,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ;KAChC,CAAC,CAAA;IAEF,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IAEnC,MAAM,IAAA,oBAAS,EAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACnE,kBAAG,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,kBAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,6CAA6C,CAAC,CAAA;AAC3G,CAAC","sourcesContent":["import { readFile, writeFile } from \"fs/promises\"\nimport { log } from \"builder-util\"\nimport { NtExecutable, NtExecutableResource, Resource } from \"resedit\"\nimport { AsarIntegrity } from \"../asar/integrity\"\n\n/** @internal */\nexport async function addWinAsarIntegrity(executablePath: string, asarIntegrity: AsarIntegrity) {\n const buffer = await readFile(executablePath)\n const executable = NtExecutable.from(buffer)\n const resource = NtExecutableResource.from(executable)\n\n const versionInfo = Resource.VersionInfo.fromEntries(resource.entries)\n if (versionInfo.length !== 1) {\n throw new Error(`Failed to parse version info in ${executablePath}`)\n }\n\n const languages = versionInfo[0].getAllLanguagesForStringValues()\n if (languages.length !== 1) {\n throw new Error(`Failed to locate languages in ${executablePath}`)\n }\n\n // See: https://github.com/electron/packager/blob/00d20b99cf4aa4621103dbbd09ff7de7d2f7f539/src/resedit.ts#L124\n const integrityList = Array.from(Object.entries(asarIntegrity)).map(([file, { algorithm: alg, hash: value }]) => ({\n file,\n alg,\n value,\n }))\n\n resource.entries.push({\n type: \"INTEGRITY\",\n id: \"ELECTRONASAR\",\n bin: Buffer.from(JSON.stringify(integrityList)),\n lang: languages[0].lang,\n codepage: languages[0].codepage,\n })\n\n resource.outputResource(executable)\n\n await writeFile(executablePath, Buffer.from(executable.generate()))\n log.info({ executablePath: log.filePath(executablePath) }, \"updating asar integrity executable resource\")\n}\n"]}
@@ -22,7 +22,7 @@ const copyFFMPEG = (targetPath, platform) => (sourcePath) => {
22
22
  }
23
23
  const libPath = path.resolve(sourcePath, fileName);
24
24
  const libTargetPath = path.resolve(targetPath, fileName);
25
- builder_util_1.log.info({ lib: libPath, target: libTargetPath }, "copying non-proprietary FFMPEG");
25
+ builder_util_1.log.info({ lib: builder_util_1.log.filePath(libPath), target: builder_util_1.log.filePath(libTargetPath) }, "copying non-proprietary FFMPEG");
26
26
  // If the source doesn't exist we have a problem
27
27
  if (!fs.existsSync(libPath)) {
28
28
  throw new Error(`Failed to find FFMPEG library file at path: ${libPath}`);
@@ -1 +1 @@
1
- {"version":3,"file":"injectFFMPEG.js","sourceRoot":"","sources":["../../src/electron/injectFFMPEG.ts"],"names":[],"mappings":";;AAyCA,+BAOC;AAhDD,yBAAwB;AACxB,6BAA4B;AAG5B,+CAAkC;AAClC,gDAAuC;AAGvC,qJAAqJ;AACrJ,MAAM,cAAc,GAAG,KAAK,EAAE,eAAuB,EAAE,QAA8B,EAAE,IAAY,EAAE,EAAE;IACrG,MAAM,cAAc,GAAG,WAAW,e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SAAwB,YAAY,CAAC,OAAgD,EAAE,gBAAwB;IAC7G,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,IAAI,OAAO,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,oFAAoF,CAAC,CAAA;IACjI,CAAC;IAED,OAAO,cAAc,CAAC,gBAAgB,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;AAC7H,CAAC","sourcesContent":["import * as fs from \"fs\"\nimport * as path from \"path\"\nimport { ElectronPlatformName } from \"./ElectronFramework\"\n\nimport { log } from \"builder-util\"\nimport { getBin } from \"../binDownload\"\nimport { PrepareApplicationStageDirectoryOptions } from \"../Framework\"\n\n// NOTE: Adapted from https://github.com/MarshallOfSound/electron-packager-plugin-non-proprietary-codecs-ffmpeg to resolve dependency vulnerabilities\nconst downloadFFMPEG = async (electronVersion: string, platform: ElectronPlatformName, arch: string) => {\n const ffmpegFileName = `ffmpeg-v${electronVersion}-${platform}-${arch}.zip`\n const url = `https://github.com/electron/electron/releases/download/v${electronVersion}/${ffmpegFileName}`\n\n log.info({ file: ffmpegFileName }, \"downloading non-proprietary FFMPEG\")\n return getBin(ffmpegFileName, url)\n}\n\nconst copyFFMPEG = (targetPath: string, platform: ElectronPlatformName) => (sourcePath: string) => {\n let fileName = \"ffmpeg.dll\"\n if ([\"darwin\", \"mas\"].includes(platform)) {\n fileName = \"libffmpeg.dylib\"\n } else if (platform === \"linux\") {\n fileName = \"libffmpeg.so\"\n }\n\n const libPath = path.resolve(sourcePath, fileName)\n const libTargetPath = path.resolve(targetPath, fileName)\n log.info({ lib: libPath, target: libTargetPath }, \"copying non-proprietary FFMPEG\")\n\n // If the source doesn't exist we have a problem\n if (!fs.existsSync(libPath)) {\n throw new Error(`Failed to find FFMPEG library file at path: ${libPath}`)\n }\n\n // If we are copying to the source we can stop immediately\n if (libPath !== libTargetPath) {\n fs.copyFileSync(libPath, libTargetPath)\n }\n return libTargetPath\n}\n\nexport default function injectFFMPEG(options: PrepareApplicationStageDirectoryOptions, electrionVersion: string) {\n let libPath = options.appOutDir\n if (options.platformName === \"darwin\") {\n libPath = path.resolve(options.appOutDir, \"Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries\")\n }\n\n return downloadFFMPEG(electrionVersion, options.platformName, options.arch).then(copyFFMPEG(libPath, options.platformName))\n}\n"]}
1
+ {"version":3,"file":"injectFFMPEG.js","sourceRoot":"","sources":["../../src/electron/injectFFMPEG.ts"],"names":[],"mappings":";;AAyCA,+BAOC;AAhDD,yBAAwB;AACxB,6BAA4B;AAG5B,+CAAkC;AAClC,gDAAuC;AAGvC,qJAAqJ;AACrJ,MAAM,cAAc,GAAG,KAAK,EAAE,eAAuB,EAAE,QAA8B,EAAE,IAAY,EAAE,EAAE;IACrG,MAAM,cAAc,GAAG,WAAW,eAAe,IAAI,QAAQ,IAAI,IAAI,MAAM,CAAA;IAC3E,MAAM,GAAG,GAAG,2DAA2D,eAAe,IAAI,cAAc,EAAE,CAAA;IAE1G,kBAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,oCAAoC,CAAC,CAAA;IACxE,OAAO,IAAA,oBAAM,EAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAE,QAA8B,EAAE,EAAE,CAAC,CAAC,UAAkB,EAAE,EAAE;IAChG,IAAI,QAAQ,GAAG,YAAY,CAAA;IAC3B,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,QAAQ,GAAG,iBAAiB,CAAA;IAC9B,CAAC;SAAM,IAAI,QAAQ,K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\n\nimport { log } from \"builder-util\"\nimport { getBin } from \"../binDownload\"\nimport { PrepareApplicationStageDirectoryOptions } from \"../Framework\"\n\n// NOTE: Adapted from https://github.com/MarshallOfSound/electron-packager-plugin-non-proprietary-codecs-ffmpeg to resolve dependency vulnerabilities\nconst downloadFFMPEG = async (electronVersion: string, platform: ElectronPlatformName, arch: string) => {\n const ffmpegFileName = `ffmpeg-v${electronVersion}-${platform}-${arch}.zip`\n const url = `https://github.com/electron/electron/releases/download/v${electronVersion}/${ffmpegFileName}`\n\n log.info({ file: ffmpegFileName }, \"downloading non-proprietary FFMPEG\")\n return getBin(ffmpegFileName, url)\n}\n\nconst copyFFMPEG = (targetPath: string, platform: ElectronPlatformName) => (sourcePath: string) => {\n let fileName = \"ffmpeg.dll\"\n if ([\"darwin\", \"mas\"].includes(platform)) {\n fileName = \"libffmpeg.dylib\"\n } else if (platform === \"linux\") {\n fileName = \"libffmpeg.so\"\n }\n\n const libPath = path.resolve(sourcePath, fileName)\n const libTargetPath = path.resolve(targetPath, fileName)\n log.info({ lib: log.filePath(libPath), target: log.filePath(libTargetPath) }, \"copying non-proprietary FFMPEG\")\n\n // If the source doesn't exist we have a problem\n if (!fs.existsSync(libPath)) {\n throw new Error(`Failed to find FFMPEG library file at path: ${libPath}`)\n }\n\n // If we are copying to the source we can stop immediately\n if (libPath !== libTargetPath) {\n fs.copyFileSync(libPath, libTargetPath)\n }\n return libTargetPath\n}\n\nexport default function injectFFMPEG(options: PrepareApplicationStageDirectoryOptions, electrionVersion: string) {\n let libPath = options.appOutDir\n if (options.platformName === \"darwin\") {\n libPath = path.resolve(options.appOutDir, \"Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries\")\n }\n\n return downloadFFMPEG(electrionVersion, options.platformName, options.arch).then(copyFFMPEG(libPath, options.platformName))\n}\n"]}