app-builder-lib 26.18.0 → 26.18.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.
@@ -56,3 +56,14 @@ export declare class WindowsSignToolManager implements SignManager {
56
56
  getToolPath(isWin?: boolean): Promise<ToolInfo>;
57
57
  doSign(configuration: CustomWindowsSignTaskConfiguration, packager: WinPackager): Promise<void>;
58
58
  }
59
+ /**
60
+ * The hash algorithms to sign `filePath` with, one signing pass each.
61
+ *
62
+ * - `.msi` holds a single signature, so it is signed once: with `sha256` unless `sha1` is the only algorithm requested.
63
+ * - `.appx`, `.msix` and `.msixbundle` are always `sha256`.
64
+ * - Everything else uses the configured list, defaulting to dual signing with `sha1` then `sha256`.
65
+ *
66
+ * Extensions are matched case-insensitively (`app.MSI` is an MSI). An empty list is a configuration error: it would
67
+ * run no signing pass while the file is still reported as signed.
68
+ */
69
+ export declare function resolveSigningHashAlgorithms(filePath: string, configured: Array<"sha1" | "sha256"> | "sha1" | "sha256" | null | undefined): Array<"sha1" | "sha256">;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WindowsSignToolManager = void 0;
4
+ exports.resolveSigningHashAlgorithms = resolveSigningHashAlgorithms;
4
5
  const builder_util_1 = require("builder-util");
5
6
  const builder_util_runtime_1 = require("builder-util-runtime");
6
7
  const fs_extra_1 = require("fs-extra");
@@ -113,20 +114,7 @@ class WindowsSignToolManager {
113
114
  }
114
115
  async signFile(options) {
115
116
  var _a, _b;
116
- let hashes = (_a = options.options.signtoolOptions) === null || _a === void 0 ? void 0 : _a.signingHashAlgorithms;
117
- // msi does not support dual-signing
118
- if (options.path.endsWith(".msi")) {
119
- hashes = [hashes != null && !hashes.includes("sha1") ? "sha256" : "sha1"];
120
- }
121
- else if (options.path.endsWith(".appx")) {
122
- hashes = ["sha256"];
123
- }
124
- else if (hashes == null) {
125
- hashes = ["sha1", "sha256"];
126
- }
127
- else {
128
- hashes = Array.isArray(hashes) ? hashes : [hashes];
129
- }
117
+ const hashes = resolveSigningHashAlgorithms(options.path, (_a = options.options.signtoolOptions) === null || _a === void 0 ? void 0 : _a.signingHashAlgorithms);
130
118
  const name = this.packager.appInfo.productName;
131
119
  const site = await this.packager.appInfo.computePackageUrl();
132
120
  const customSign = await (0, resolve_1.resolveFunction)(this.packager.appInfo.type, (_b = options.options.signtoolOptions) === null || _b === void 0 ? void 0 : _b.sign, "sign", await this.packager.info.getWorkspaceRoot());
@@ -376,4 +364,28 @@ class WindowsSignToolManager {
376
364
  }
377
365
  }
378
366
  exports.WindowsSignToolManager = WindowsSignToolManager;
367
+ /**
368
+ * The hash algorithms to sign `filePath` with, one signing pass each.
369
+ *
370
+ * - `.msi` holds a single signature, so it is signed once: with `sha256` unless `sha1` is the only algorithm requested.
371
+ * - `.appx`, `.msix` and `.msixbundle` are always `sha256`.
372
+ * - Everything else uses the configured list, defaulting to dual signing with `sha1` then `sha256`.
373
+ *
374
+ * Extensions are matched case-insensitively (`app.MSI` is an MSI). An empty list is a configuration error: it would
375
+ * run no signing pass while the file is still reported as signed.
376
+ */
377
+ function resolveSigningHashAlgorithms(filePath, configured) {
378
+ const requested = configured == null ? null : (0, builder_util_1.asArray)(configured);
379
+ if (requested != null && requested.length === 0) {
380
+ throw new builder_util_1.InvalidConfigurationError(`win.signtoolOptions.signingHashAlgorithms is an empty list, so no signing pass would run. List at least one of "sha1" or "sha256", or remove the option to use the default ["sha1", "sha256"].`);
381
+ }
382
+ const ext = path.extname(filePath).toLowerCase();
383
+ if (ext === ".msi") {
384
+ return [requested != null && !requested.includes("sha256") ? "sha1" : "sha256"];
385
+ }
386
+ if (ext === ".appx" || ext === ".msix" || ext === ".msixbundle") {
387
+ return ["sha256"];
388
+ }
389
+ return requested !== null && requested !== void 0 ? requested : ["sha1", "sha256"];
390
+ }
379
391
  //# sourceMappingURL=windowsSignToolManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"windows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QACzF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAA;QAC1B,IAAI,eAAe,EAAE,CAAC;YACpB,EAAE,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAA;YAC5B,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QAC3D,CAAC;aAAM,CAAC;YACN,EAAE,GAAG,IAAI,cAAS,EAAE,CAAA;YACpB,IAAI,GAAG,aAAa,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;QACjD,CAAC;QAED,MAAM,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE;YACpG,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,CAAC,CAAM,EAAE,EAAE;gBACtB,IACE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,2CAA2C,CAAC;oBAC/D,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,4DAA4D,CAAC;oBAChF,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,6DAA6D,CAAC,EACjF,CAAC;oBACD,kBAAG,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;oBACjG,OAAO,IAAI,CAAA;gBACb,CAAC;gBACD,OAAO,KAAK,CAAA;YACd,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAzZD,wDAyZC","sourcesContent":["import { asArray, InvalidConfigurationError, log, retry } from \"builder-util\"\nimport { MemoLazy, parseDn } from \"builder-util-runtime\"\nimport { rename } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../core\"\nimport { WindowsConfiguration } from \"../options/winOptions\"\nimport AppXTarget from \"../targets/AppxTarget\"\nimport { getSignToolPath } from \"../toolsets/windows\"\nimport { ToolInfo } from \"../util/bundledTool\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { readCertInfo } from \"./certInfo\"\nimport { VmManager } from \"../vm/vm\"\nimport { WinPackager } from \"../winPackager\"\nimport { importCertificate } from \"./codesign\"\nimport { SignManager } from \"./signManager\"\nimport { WindowsSignOptions } from \"./windowsCodeSign\"\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 implements SignManager {\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 = this.platformSpecificBuildOptions.signtoolOptions?.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 = platformSpecificBuildOptions.signtoolOptions?.certificateSubjectName\n const shaType = platformSpecificBuildOptions.signtoolOptions?.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 (platformSpecificBuildOptions.signtoolOptions?.sign == null) {\n throw e\n } else {\n log.debug({ error: e }, \"getCertificateFromStoreInfo error\")\n return null\n }\n })\n }\n\n const certificateFile = platformSpecificBuildOptions.signtoolOptions?.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 initialize(): Promise<void> {\n return Promise.resolve()\n }\n\n // https://github.com/electron-userland/electron-builder/issues/2108#issuecomment-333200711\n async computePublisherName(target: Target, publisherName: string) {\n if (target instanceof AppXTarget && (await this.cscInfo.value) == null) {\n log.info({ reason: \"Windows Store only build\" }, \"AppX is not signed\")\n return publisherName || \"CN=ms\"\n }\n\n const certInfo = await this.lazyCertInfo.value\n const publisher = publisherName || (certInfo == null ? null : certInfo.bloodyMicrosoftSubjectDn)\n if (publisher == null) {\n throw new Error(\"Internal error: cannot compute subject using certificate info\")\n }\n return publisher\n }\n\n async signFile(options: WindowsSignOptions): Promise<boolean> {\n let hashes = options.options.signtoolOptions?.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 name = this.packager.appInfo.productName\n const site = await this.packager.appInfo.computePackageUrl()\n\n const customSign = await resolveFunction(this.packager.appInfo.type, options.options.signtoolOptions?.sign, \"sign\", await this.packager.info.getWorkspaceRoot())\n\n const cscInfo = await this.cscInfo.value\n if (cscInfo) {\n if (!customSign) {\n log.info({ path: log.filePath(options.path) }, \"signing with signtool.exe\")\n }\n let logInfo: any = {\n file: log.filePath(options.path),\n }\n if (\"file\" in cscInfo) {\n logInfo = {\n ...logInfo,\n certificateFile: cscInfo.file,\n }\n } else {\n logInfo = {\n ...logInfo,\n subject: cscInfo.subject,\n thumbprint: cscInfo.thumbprint,\n store: cscInfo.store,\n user: cscInfo.isLocalMachineStore ? \"local machine\" : \"current user\",\n }\n }\n log.info(logInfo, \"signing\")\n } else if (!customSign) {\n log.info({ path: log.filePath(options.path) }, \"no code signing certificate configured, signing is skipped\")\n return false\n }\n\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 const errorMessagePrefix = \"Cannot extract publisher name from code signing certificate. As workaround, set win.publisherName. Error: \"\n try {\n return await readCertInfo(file, password)\n } catch (e: any) {\n throw new InvalidConfigurationError(`${errorMessagePrefix}${e.message || e}`)\n }\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 return isWin ? this.computeWindowsSignArgs(options, vm) : this.computeOsslsigncodeArgs(options, vm)\n }\n\n private computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const inputFile = vm.toVmFile(options.path)\n const args = [\"sign\"]\n\n // Timestamping\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const isRfc3161 = options.isNest || options.hash === \"sha256\"\n args.push(isRfc3161 ? \"/tr\" : \"/t\")\n\n const timestampUrl = isRfc3161\n ? options.options.signtoolOptions?.rfc3161TimeStampServer || \"http://timestamp.digicert.com\"\n : options.options.signtoolOptions?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(timestampUrl)\n }\n\n // Certificate\n this.addCertificateArgs(args, options, vm, true)\n\n // Hash algorithm\n const isLegacyToolset = this.packager.config.toolsets?.winCodeSign === \"0.0.0\" || this.packager.config.toolsets?.winCodeSign == null\n if (isLegacyToolset) {\n // Legacy || v0.0.0: Only add /fd for non-SHA1 (original behavior)\n if (options.hash !== \"sha1\") {\n args.push(\"/fd\", options.hash)\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n args.push(\"/td\", \"sha256\")\n }\n }\n } else {\n // Modern: Always add /fd (required by new Windows Kits)\n args.push(\"/fd\", options.hash.toLowerCase())\n // Only add /td for RFC3161 timestamps (incompatible with /t)\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\" && (options.isNest || options.hash === \"sha256\")) {\n args.push(\"/td\", \"sha256\")\n }\n }\n\n // Optional parameters\n this.addCommonSigningArgs(args, options, vm, true)\n\n // Windows-specific\n args.push(\"/debug\")\n args.push(inputFile) // Must be last\n\n return args\n }\n\n private computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const inputFile = vm.toVmFile(options.path)\n const outputPath = this.getOutputPath(inputFile, options.hash)\n options.resultOutputPath = outputPath\n\n const args = [\"sign\", \"-in\", inputFile, \"-out\", outputPath]\n\n // Timestamping\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const timestampUrl = options.options.signtoolOptions?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(\"-t\", timestampUrl)\n }\n\n // Certificate\n this.addCertificateArgs(args, options, vm, false)\n\n // Hash algorithm\n args.push(\"-h\", options.hash.toLowerCase())\n\n // Optional parameters\n this.addCommonSigningArgs(args, options, vm, false)\n\n // Proxy support\n const httpsProxy = process.env.HTTPS_PROXY\n if (httpsProxy?.length) {\n args.push(\"-p\", httpsProxy)\n }\n\n return args\n }\n\n private addCertificateArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean): void {\n if (options.cscInfo == null) {\n throw new Error(\"No code signing certificate configured. Provide certificateFile, certificateSha1, or certificateSubjectName.\")\n }\n const certificateFile = (options.cscInfo as FileCodeSigningInfo).file\n\n if (certificateFile == null) {\n // Certificate from store (Windows only)\n if (!isWin) {\n throw new Error(\"certificateSha1/certificateSubjectName supported only on Windows\")\n }\n\n const cscInfo = options.cscInfo as CertificateFromStoreInfo\n args.push(\"/sha1\", cscInfo.thumbprint)\n args.push(\"/s\", cscInfo.store)\n if (cscInfo.isLocalMachineStore) {\n args.push(\"/sm\")\n }\n } else {\n // Certificate file\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\n private addCommonSigningArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean): void {\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 if (options.isNest) {\n args.push(isWin ? \"/as\" : \"-nest\")\n }\n\n const password = (options.cscInfo as FileCodeSigningInfo)?.password\n if (password) {\n args.push(isWin ? \"/p\" : \"-pass\", password)\n }\n\n const additionalCert = options.options.signtoolOptions?.additionalCertificateFile\n if (additionalCert) {\n args.push(isWin ? \"/ac\" : \"-ac\", vm.toVmFile(additionalCert))\n }\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 async getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {\n const certificateSubjectName = options.signtoolOptions?.certificateSubjectName\n const certificateSha1 = options.signtoolOptions?.certificateSha1?.toUpperCase()\n\n const ps = await vm.powershellCommand.value\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 getToolPath(isWin = process.platform === \"win32\"): Promise<ToolInfo> {\n return getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin)\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 vm: VmManager\n const useVmIfNotOnWin = configuration.path.endsWith(\".appx\") || !(\"file\" in configuration.cscInfo!) /* certificateSubjectName and other such options */\n const isWin = process.platform === \"win32\" || useVmIfNotOnWin\n const toolInfo = await getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin)\n const tool = toolInfo.path\n if (useVmIfNotOnWin) {\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 }\n\n await retry(() => vm.exec(tool, args, { timeout, env: { ...process.env, ...(toolInfo.env || {}) } }), {\n retries: 2,\n interval: 15000,\n backoff: 10000,\n shouldRetry: (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\") ||\n 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"]}
1
+ {"version":3,"file":"windowsSignToolManager.js","sourceRoot":"","sources":["../../src/codeSign/windowsSignToolManager.ts"],"names":[],"mappings":";;;AAydA,oEAeC;AAxeD,+CAA6E;AAC7E,+DAAwD;AACxD,uCAAiC;AACjC,uCAA+B;AAC/B,6BAA4B;AAG5B,sDAA8C;AAC9C,iDAAqD;AAErD,6CAAiD;AACjD,yCAAyC;AACzC,iCAAoC;AAEpC,yCAA8C;AAgD9C,MAAa,sBAAsB;IAGjC,YAA6B,QAAqB;QAArB,aAAQ,GAAR,QAAQ,CAAa;QAIzC,0BAAqB,GAAG,IAAI,eAAI,CAAuB,KAAK,IAAI,EAAE;;YACzE,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,4BAA4B,CAAC,eAAe,0CAAE,aAAa,CAAA;YACtF,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAA;YACb,CAAC;iBAAM,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBACjC,OAAO,IAAA,sBAAO,EAAC,aAAa,CAAC,CAAA;YAC/B,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAA;YAC9C,OAAO,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;QAEO,iBAAY,GAAG,IAAI,+BAAQ,CAClC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAClB,KAAK,EAA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AChD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACjF,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;QAChE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import { asArray, InvalidConfigurationError, log, retry } from \"builder-util\"\nimport { MemoLazy, parseDn } from \"builder-util-runtime\"\nimport { rename } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../core\"\nimport { WindowsConfiguration } from \"../options/winOptions\"\nimport AppXTarget from \"../targets/AppxTarget\"\nimport { getSignToolPath } from \"../toolsets/windows\"\nimport { ToolInfo } from \"../util/bundledTool\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { readCertInfo } from \"./certInfo\"\nimport { VmManager } from \"../vm/vm\"\nimport { WinPackager } from \"../winPackager\"\nimport { importCertificate } from \"./codesign\"\nimport { SignManager } from \"./signManager\"\nimport { WindowsSignOptions } from \"./windowsCodeSign\"\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 implements SignManager {\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 = this.platformSpecificBuildOptions.signtoolOptions?.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 = platformSpecificBuildOptions.signtoolOptions?.certificateSubjectName\n const shaType = platformSpecificBuildOptions.signtoolOptions?.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 (platformSpecificBuildOptions.signtoolOptions?.sign == null) {\n throw e\n } else {\n log.debug({ error: e }, \"getCertificateFromStoreInfo error\")\n return null\n }\n })\n }\n\n const certificateFile = platformSpecificBuildOptions.signtoolOptions?.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 initialize(): Promise<void> {\n return Promise.resolve()\n }\n\n // https://github.com/electron-userland/electron-builder/issues/2108#issuecomment-333200711\n async computePublisherName(target: Target, publisherName: string) {\n if (target instanceof AppXTarget && (await this.cscInfo.value) == null) {\n log.info({ reason: \"Windows Store only build\" }, \"AppX is not signed\")\n return publisherName || \"CN=ms\"\n }\n\n const certInfo = await this.lazyCertInfo.value\n const publisher = publisherName || (certInfo == null ? null : certInfo.bloodyMicrosoftSubjectDn)\n if (publisher == null) {\n throw new Error(\"Internal error: cannot compute subject using certificate info\")\n }\n return publisher\n }\n\n async signFile(options: WindowsSignOptions): Promise<boolean> {\n const hashes = resolveSigningHashAlgorithms(options.path, options.options.signtoolOptions?.signingHashAlgorithms)\n\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, options.options.signtoolOptions?.sign, \"sign\", await this.packager.info.getWorkspaceRoot())\n\n const cscInfo = await this.cscInfo.value\n if (cscInfo) {\n if (!customSign) {\n log.info({ path: log.filePath(options.path) }, \"signing with signtool.exe\")\n }\n let logInfo: any = {\n file: log.filePath(options.path),\n }\n if (\"file\" in cscInfo) {\n logInfo = {\n ...logInfo,\n certificateFile: cscInfo.file,\n }\n } else {\n logInfo = {\n ...logInfo,\n subject: cscInfo.subject,\n thumbprint: cscInfo.thumbprint,\n store: cscInfo.store,\n user: cscInfo.isLocalMachineStore ? \"local machine\" : \"current user\",\n }\n }\n log.info(logInfo, \"signing\")\n } else if (!customSign) {\n log.info({ path: log.filePath(options.path) }, \"no code signing certificate configured, signing is skipped\")\n return false\n }\n\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 const errorMessagePrefix = \"Cannot extract publisher name from code signing certificate. As workaround, set win.publisherName. Error: \"\n try {\n return await readCertInfo(file, password)\n } catch (e: any) {\n throw new InvalidConfigurationError(`${errorMessagePrefix}${e.message || e}`)\n }\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 return isWin ? this.computeWindowsSignArgs(options, vm) : this.computeOsslsigncodeArgs(options, vm)\n }\n\n private computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const inputFile = vm.toVmFile(options.path)\n const args = [\"sign\"]\n\n // Timestamping\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const isRfc3161 = options.isNest || options.hash === \"sha256\"\n args.push(isRfc3161 ? \"/tr\" : \"/t\")\n\n const timestampUrl = isRfc3161\n ? options.options.signtoolOptions?.rfc3161TimeStampServer || \"http://timestamp.digicert.com\"\n : options.options.signtoolOptions?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(timestampUrl)\n }\n\n // Certificate\n this.addCertificateArgs(args, options, vm, true)\n\n // Hash algorithm\n const isLegacyToolset = this.packager.config.toolsets?.winCodeSign === \"0.0.0\" || this.packager.config.toolsets?.winCodeSign == null\n if (isLegacyToolset) {\n // Legacy || v0.0.0: Only add /fd for non-SHA1 (original behavior)\n if (options.hash !== \"sha1\") {\n args.push(\"/fd\", options.hash)\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n args.push(\"/td\", \"sha256\")\n }\n }\n } else {\n // Modern: Always add /fd (required by new Windows Kits)\n args.push(\"/fd\", options.hash.toLowerCase())\n // Only add /td for RFC3161 timestamps (incompatible with /t)\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\" && (options.isNest || options.hash === \"sha256\")) {\n args.push(\"/td\", \"sha256\")\n }\n }\n\n // Optional parameters\n this.addCommonSigningArgs(args, options, vm, true)\n\n // Windows-specific\n args.push(\"/debug\")\n args.push(inputFile) // Must be last\n\n return args\n }\n\n private computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const inputFile = vm.toVmFile(options.path)\n const outputPath = this.getOutputPath(inputFile, options.hash)\n options.resultOutputPath = outputPath\n\n const args = [\"sign\", \"-in\", inputFile, \"-out\", outputPath]\n\n // Timestamping\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const timestampUrl = options.options.signtoolOptions?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(\"-t\", timestampUrl)\n }\n\n // Certificate\n this.addCertificateArgs(args, options, vm, false)\n\n // Hash algorithm\n args.push(\"-h\", options.hash.toLowerCase())\n\n // Optional parameters\n this.addCommonSigningArgs(args, options, vm, false)\n\n // Proxy support\n const httpsProxy = process.env.HTTPS_PROXY\n if (httpsProxy?.length) {\n args.push(\"-p\", httpsProxy)\n }\n\n return args\n }\n\n private addCertificateArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean): void {\n if (options.cscInfo == null) {\n throw new Error(\"No code signing certificate configured. Provide certificateFile, certificateSha1, or certificateSubjectName.\")\n }\n const certificateFile = (options.cscInfo as FileCodeSigningInfo).file\n\n if (certificateFile == null) {\n // Certificate from store (Windows only)\n if (!isWin) {\n throw new Error(\"certificateSha1/certificateSubjectName supported only on Windows\")\n }\n\n const cscInfo = options.cscInfo as CertificateFromStoreInfo\n args.push(\"/sha1\", cscInfo.thumbprint)\n args.push(\"/s\", cscInfo.store)\n if (cscInfo.isLocalMachineStore) {\n args.push(\"/sm\")\n }\n } else {\n // Certificate file\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\n private addCommonSigningArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean): void {\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 if (options.isNest) {\n args.push(isWin ? \"/as\" : \"-nest\")\n }\n\n const password = (options.cscInfo as FileCodeSigningInfo)?.password\n if (password) {\n args.push(isWin ? \"/p\" : \"-pass\", password)\n }\n\n const additionalCert = options.options.signtoolOptions?.additionalCertificateFile\n if (additionalCert) {\n args.push(isWin ? \"/ac\" : \"-ac\", vm.toVmFile(additionalCert))\n }\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 async getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {\n const certificateSubjectName = options.signtoolOptions?.certificateSubjectName\n const certificateSha1 = options.signtoolOptions?.certificateSha1?.toUpperCase()\n\n const ps = await vm.powershellCommand.value\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 getToolPath(isWin = process.platform === \"win32\"): Promise<ToolInfo> {\n return getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin)\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 vm: VmManager\n const useVmIfNotOnWin = configuration.path.endsWith(\".appx\") || !(\"file\" in configuration.cscInfo!) /* certificateSubjectName and other such options */\n const isWin = process.platform === \"win32\" || useVmIfNotOnWin\n const toolInfo = await getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin)\n const tool = toolInfo.path\n if (useVmIfNotOnWin) {\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 }\n\n await retry(() => vm.exec(tool, args, { timeout, env: { ...process.env, ...(toolInfo.env || {}) } }), {\n retries: 2,\n interval: 15000,\n backoff: 10000,\n shouldRetry: (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\") ||\n 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\n/**\n * The hash algorithms to sign `filePath` with, one signing pass each.\n *\n * - `.msi` holds a single signature, so it is signed once: with `sha256` unless `sha1` is the only algorithm requested.\n * - `.appx`, `.msix` and `.msixbundle` are always `sha256`.\n * - Everything else uses the configured list, defaulting to dual signing with `sha1` then `sha256`.\n *\n * Extensions are matched case-insensitively (`app.MSI` is an MSI). An empty list is a configuration error: it would\n * run no signing pass while the file is still reported as signed.\n */\nexport function resolveSigningHashAlgorithms(filePath: string, configured: Array<\"sha1\" | \"sha256\"> | \"sha1\" | \"sha256\" | null | undefined): Array<\"sha1\" | \"sha256\"> {\n const requested = configured == null ? null : asArray(configured)\n if (requested != null && requested.length === 0) {\n throw new InvalidConfigurationError(\n `win.signtoolOptions.signingHashAlgorithms is an empty list, so no signing pass would run. List at least one of \"sha1\" or \"sha256\", or remove the option to use the default [\"sha1\", \"sha256\"].`\n )\n }\n const ext = path.extname(filePath).toLowerCase()\n if (ext === \".msi\") {\n return [requested != null && !requested.includes(\"sha256\") ? \"sha1\" : \"sha256\"]\n }\n if (ext === \".appx\" || ext === \".msix\" || ext === \".msixbundle\") {\n return [\"sha256\"]\n }\n return requested ?? [\"sha1\", \"sha256\"]\n}\n"]}
@@ -13,6 +13,21 @@ export interface ElectronBrandingOptions {
13
13
  productName?: string;
14
14
  }
15
15
  export declare function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions>;
16
+ /**
17
+ * Electron 45 ships `electron_wer.dll`, a Windows Error Reporting runtime exception helper that captures crashes which never reach
18
+ * Crashpad's in-process handler, such as `__fastfail` (https://github.com/electron/electron/pull/53802). Electron looks the helper up
19
+ * as `<executable name>_wer.dll` next to the executable, so it has to be renamed together with the executable.
20
+ * The check is on the semver major so 45 prereleases are covered as well.
21
+ */
22
+ export declare const FIRST_ELECTRON_MAJOR_WITH_WER_HELPER = 45;
23
+ /**
24
+ * Renames `<projectName>_wer.dll` to `<productFilename>_wer.dll` for Electron 45 and later. Does nothing for older Electron versions,
25
+ * unparseable versions or when the DLL is absent (a custom Electron distribution may omit it to opt out of WER crash capture).
26
+ *
27
+ * Exported for unit testing.
28
+ */
29
+ export declare function renameWindowsWerHelperIfNeeded(appOutDir: string, projectName: string, productFilename: string, electronVersion: string): Promise<void>;
30
+ export declare function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions, electronVersion: string): Promise<void>;
16
31
  export declare function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions): Promise<void>;
17
32
  export declare function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework>;
18
33
  export declare function cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean): Promise<[void, void, void]>;
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FIRST_ELECTRON_MAJOR_WITH_WER_HELPER = void 0;
3
4
  exports.createBrandingOpts = createBrandingOpts;
5
+ exports.renameWindowsWerHelperIfNeeded = renameWindowsWerHelperIfNeeded;
6
+ exports.beforeCopyExtraFiles = beforeCopyExtraFiles;
4
7
  exports.removeUnusedLanguagesIfNeeded = removeUnusedLanguagesIfNeeded;
5
8
  exports.createElectronFrameworkSupport = createElectronFrameworkSupport;
6
9
  exports.cleanupAfterUnpack = cleanupAfterUnpack;
7
10
  const builder_util_1 = require("builder-util");
8
11
  const fs_extra_1 = require("fs-extra");
9
12
  const path = require("path");
13
+ const semver = require("semver");
10
14
  const tiny_async_pool_1 = require("tiny-async-pool");
11
15
  const index_1 = require("../index");
12
16
  const pathManager_1 = require("../util/pathManager");
@@ -37,7 +41,36 @@ function createDownloadOpts(opts, platform, arch, electronVersion) {
37
41
  }
38
42
  return { ...base, ...dl };
39
43
  }
40
- async function beforeCopyExtraFiles(options) {
44
+ /**
45
+ * Electron 45 ships `electron_wer.dll`, a Windows Error Reporting runtime exception helper that captures crashes which never reach
46
+ * Crashpad's in-process handler, such as `__fastfail` (https://github.com/electron/electron/pull/53802). Electron looks the helper up
47
+ * as `<executable name>_wer.dll` next to the executable, so it has to be renamed together with the executable.
48
+ * The check is on the semver major so 45 prereleases are covered as well.
49
+ */
50
+ exports.FIRST_ELECTRON_MAJOR_WITH_WER_HELPER = 45;
51
+ /**
52
+ * Renames `<projectName>_wer.dll` to `<productFilename>_wer.dll` for Electron 45 and later. Does nothing for older Electron versions,
53
+ * unparseable versions or when the DLL is absent (a custom Electron distribution may omit it to opt out of WER crash capture).
54
+ *
55
+ * Exported for unit testing.
56
+ */
57
+ async function renameWindowsWerHelperIfNeeded(appOutDir, projectName, productFilename, electronVersion) {
58
+ const coerced = semver.coerce(electronVersion);
59
+ if (coerced == null || semver.major(coerced) < exports.FIRST_ELECTRON_MAJOR_WITH_WER_HELPER) {
60
+ return;
61
+ }
62
+ const source = `${projectName}_wer.dll`;
63
+ const destination = `${productFilename}_wer.dll`;
64
+ if (source === destination) {
65
+ return;
66
+ }
67
+ const renamed = await (0, builder_util_1.orIfFileNotExist)((0, fs_extra_1.rename)(path.join(appOutDir, source), path.join(appOutDir, destination)).then(() => true), false);
68
+ if (renamed) {
69
+ builder_util_1.log.debug({ from: source, to: destination }, "renamed Windows Error Reporting helper to match the executable name");
70
+ }
71
+ }
72
+ // exported for unit testing
73
+ async function beforeCopyExtraFiles(options, electronVersion) {
41
74
  const { appOutDir, packager } = options;
42
75
  const electronBranding = createBrandingOpts(packager.config);
43
76
  if (packager.platform === index_1.Platform.LINUX) {
@@ -48,6 +81,7 @@ async function beforeCopyExtraFiles(options) {
48
81
  else if (packager.platform === index_1.Platform.WINDOWS) {
49
82
  const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`);
50
83
  await (0, fs_extra_1.rename)(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable);
84
+ await renameWindowsWerHelperIfNeeded(appOutDir, electronBranding.projectName, packager.appInfo.productFilename, electronVersion);
51
85
  if (options.asarIntegrity) {
52
86
  await (0, electronWin_1.addWinAsarIntegrity)(executable, options.asarIntegrity);
53
87
  }
@@ -141,7 +175,7 @@ class ElectronFramework {
141
175
  }
142
176
  }
143
177
  beforeCopyExtraFiles(options) {
144
- return beforeCopyExtraFiles(options);
178
+ return beforeCopyExtraFiles(options, this.version);
145
179
  }
146
180
  }
147
181
  async function createElectronFrameworkSupport(configuration, packager) {
@@ -1 +1 @@
1
- {"version":3,"file":"ElectronFramework.js","sourceRoot":"","sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;AA6BA,gDAKC;AAmCD,sEAsDC;AA8CD,wEAiBC;AA+ED,gDAUC;AAnRD,+CAA6J;AAC7J,uCAAwD;AACxD,6BAA4B;AAC5B,qDAAuC;AAGvC,oCAA6C;AAG7C,qDAAqD;AACrD,6CAAiD;AACjD,qDAA8H;AAE9H,+CAA4C;AAC5C,uDAA2F;AAC3F,+CAAmD;AACnD,iDAA+C;AAa/C,SAAgB,kBAAkB,CAAC,IAAmB;;IACpD,OAAO;QACL,WAAW,EAAE,CAAA,MAAA,IAAI,C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ir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { downloadElectronArtifactZip, ElectronDownloadOptions, ElectronGetOptions, extractArchive } from \"../util/electronGet\"\nexport { ElectronDownloadOptions }\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport { FFMPEGInjector } from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n projectName?: string\n productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n return {\n projectName: opts.electronBranding?.projectName || \"electron\",\n productName: opts.electronBranding?.productName || \"Electron\",\n }\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n const base: ElectronDownloadOptions = { platform, arch, version: electronVersion }\n const dl = opts.electronDownload\n if (dl == null) {\n return base\n }\n if (Object.hasOwnProperty.call(dl, \"mirrorOptions\")) {\n // ElectronGetOptions: flatten mirrorOptions.mirror for the app-builder binary\n const { mirrorOptions } = dl as ElectronGetOptions\n return { ...base, mirror: mirrorOptions?.mirror ?? undefined }\n }\n return { ...base, ...dl }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const { appOutDir, packager } = options\n const electronBranding = createBrandingOpts(packager.config)\n if (packager.platform === Platform.LINUX) {\n const linuxPackager = packager as LinuxPackager\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, electronBranding.projectName), executable)\n } else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n if (options.asarIntegrity) {\n await addWinAsarIntegrity(executable, options.asarIntegrity)\n }\n } else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n }\n await removeUnusedLanguagesIfNeeded(options)\n}\n\nexport async function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n const { packager, appOutDir } = options\n const { config, platformSpecificBuildOptions, platform } = packager\n\n const getLocalesConfig = () => {\n if (platform === Platform.MAC) {\n return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n }\n return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n }\n\n // case-insensitive, treating \"-\" and \"_\" as the same separator\n const normalizeLocale = (locale: string) => locale.trim().toLowerCase().replace(/_/g, \"-\")\n const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n .map(normalizeLocale)\n .filter(it => it.length > 0)\n if (!wantedLanguages.length) {\n return\n }\n\n // bare wanted \"en\" keeps \"en-US.pak\"; region-qualified wanted \"en-US\" keeps mac's bare \"en.lproj\"\n const isLocaleMatch = (wanted: string, language: string) => wanted === language || language.startsWith(`${wanted}-`) || wanted.startsWith(`${language}-`)\n\n const { dirs, langFileExt } = getLocalesConfig()\n const matchedWantedLanguages = new Set<string>()\n const filesToDelete: string[] = []\n for (const dir of dirs) {\n const localeFiles = (await readdir(dir)).filter(file => path.extname(file) === langFileExt)\n const unwantedFiles: string[] = []\n for (const file of localeFiles) {\n const language = normalizeLocale(path.basename(file, langFileExt))\n const matches = wantedLanguages.filter(wanted => isLocaleMatch(wanted, language))\n if (matches.length === 0) {\n unwantedFiles.push(path.join(dir, file))\n } else {\n matches.forEach(it => matchedWantedLanguages.add(it))\n }\n }\n if (localeFiles.length > 0 && unwantedFiles.length === localeFiles.length) {\n // an empty locales dir produces an app that crashes at startup (https://github.com/electron/electron/issues/52307)\n log.warn(\n { electronLanguages: wantedLanguages, dir },\n \"electronLanguages doesn't match any locale in this directory, skipping cleanup to avoid packaging an app without locales\"\n )\n continue\n }\n filesToDelete.push(...unwantedFiles)\n }\n\n const unmatchedLanguages = wantedLanguages.filter(it => !matchedWantedLanguages.has(it))\n if (unmatchedLanguages.length > 0) {\n log.warn({ electronLanguages: unmatchedLanguages }, \"some electronLanguages don't match any locale, they may be misspelled or unavailable on this platform\")\n }\n await asyncPool(MAX_FILE_REQUESTS, filesToDelete, file => rm(file, { recursive: true, force: true }))\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(\n readonly name: string,\n readonly version: string,\n readonly macOsProductName: string\n ) {}\n\n get distMacOsAppName(): string {\n return `${this.macOsProductName}.app`\n }\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n } else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n if (options.packager.config.downloadAlternateFFmpeg) {\n const injector = new FFMPEGInjector(options, this.version, createBrandingOpts(options.packager.config))\n await injector.inject()\n }\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n } else {\n version = await computeElectronVersion(packager.projectDir)\n }\n configuration.electronVersion = version\n }\n\n const branding = createBrandingOpts(configuration)\n return new ElectronFramework(branding.projectName, version, branding.productName)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, _distMacOsAppName: string): Promise<boolean> {\n async function selectElectron(filepath: string) {\n const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath)\n\n const electronDistStats = await statOrNull(resolvedDist)\n if (!electronDistStats) {\n throw new Error(\n `The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`\n )\n }\n\n if (resolvedDist.endsWith(\".zip\")) {\n log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n await extractArchive(resolvedDist, appOutDir)\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n\n if (electronDistStats.isDirectory()) {\n // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n const files = await readdir(resolvedDist)\n if (files.includes(defaultZipName)) {\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n await extractArchive(path.join(resolvedDist, defaultZipName), appOutDir)\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n // e.g. we treat it as a custom already-unpacked Electron distribution\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom unpacked Electron distribution\")\n const source = packager.getElectronSrcDir(resolvedDist)\n const destination = packager.getElectronDestinationDir(prepareOptions.appOutDir)\n log.info({ source, destination }, \"copying unpacked Electron\")\n await emptyDir(prepareOptions.appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n return false\n }\n throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n }\n\n const { packager, appOutDir, platformName } = prepareOptions\n const { version, arch } = downloadOptions\n const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n const electronDist = packager.config.electronDist\n if (typeof electronDist === \"string\" && !isEmptyOrSpaces(electronDist)) {\n return selectElectron(electronDist)\n }\n\n let resolvedDist: string | null = null\n try {\n const electronDistHook: any = await resolveFunction(packager.appInfo.type, electronDist, \"electronDist\", await packager.info.getWorkspaceRoot())\n resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n } catch (error: any) {\n log.warn({ error }, \"Failed to resolve electronDist, using default unpack logic\")\n }\n\n if (resolvedDist == null) {\n // if no custom electronDist is provided, use the default unpack logic\n log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n const zipPath = await downloadElectronArtifactZip({\n electronDownload: downloadOptions,\n artifactName: \"electron\",\n platformName: downloadOptions.platform ?? prepareOptions.platformName,\n arch: downloadOptions.arch ?? prepareOptions.arch,\n version: downloadOptions.version ?? prepareOptions.version,\n })\n await extractArchive(zipPath, appOutDir)\n log.info({ output: appOutDir }, \"downloaded electron zip extracted successfully\")\n return true // indicates that we should clean up after unpacking\n }\n return selectElectron(resolvedDist)\n}\n\nexport function cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n retainElectronLicenseFiles(out, resourcesPath, isMac),\n ])\n}\n\n/**\n * The Electron dist ships Electron's own `LICENSE` and Chromium's `LICENSES.chromium.html` next to the binary, and both licenses require them to be\n * retained in distributables. On win/linux they stay next to the executable, but on macOS they sit outside the `.app` bundle, which is the only thing\n * packaged into the artifacts, so move them into `Contents/Resources`. See https://github.com/electron-userland/electron-builder/issues/9407\n */\nasync function retainElectronLicenseFiles(appOutDir: string, resourcesPath: string, isMac: boolean) {\n const destinationDir = isMac ? resourcesPath : appOutDir\n // a custom Electron distribution may not ship license files, so only a missing source file is tolerated; any other error propagates\n const move = (name: string, newName: string = name) => orIfFileNotExist(rename(path.join(appOutDir, name), path.join(destinationDir, newName)), undefined)\n await Promise.all([move(\"LICENSE\", \"LICENSE.electron.txt\"), ...(isMac ? [move(\"LICENSES.chromium.html\")] : [])])\n}\n"]}
1
+ {"version":3,"file":"ElectronFramework.js","sourceRoot":"","sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;;AA8BA,gDAKC;AA8BD,wEAiBC;AAGD,oDAkBC;AAED,sEAsDC;AA8CD,wEAiBC;AA+ED,gDAUC;AAvTD,+CAA6J;AAC7J,uCAAwD;AACxD,6BAA4B;AAC5B,iCAAgC;AAChC,qDAAuC;AAGvC,oCAA6C;AAG7C,qDAAqD;AACrD,6CAAiD;AACjD,qDAA8H;AAE9H,+CAA4C;AAC5C,uDAA2F;AAC3F,+CAAmD;AACnD,iDAA+C;AAa/C,SAAgB,kBAAkB,CAAC,IAAmB;;IACpD,OAAO;QACL,WAAW,EAAE,CA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AC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAChG,aAAa,CAAC,CAAC,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7E,0BAA0B,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,CAAC;KACtD,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,0BAA0B,CAAC,SAAiB,EAAE,aAAqB,EAAE,KAAc;IAChG,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAA;IACxD,oIAAoI;IACpI,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,UAAkB,IAAI,EAAE,EAAE,CAAC,IAAA,+BAAgB,EAAC,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;IAC1J,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAClH,CAAC","sourcesContent":["import { asArray, copyDir, DO_NOT_USE_HARD_LINKS, isEmptyOrSpaces, log, MAX_FILE_REQUESTS, orIfFileNotExist, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { emptyDir, readdir, rename, rm } from \"fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport asyncPool from \"tiny-async-pool\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { MacPackager } from \"../macPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { resolveFunction } from \"../util/resolve\"\nimport { downloadElectronArtifactZip, ElectronDownloadOptions, ElectronGetOptions, extractArchive } from \"../util/electronGet\"\nexport { ElectronDownloadOptions }\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\nimport { addWinAsarIntegrity } from \"./electronWin\"\nimport { FFMPEGInjector } from \"./injectFFMPEG\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\n/**\n * Electron distributables branding options.\n * @see [Electron BRANDING.json](https://github.com/electron/electron/blob/master/shell/app/BRANDING.json).\n */\nexport interface ElectronBrandingOptions {\n projectName?: string\n productName?: string\n}\n\nexport function createBrandingOpts(opts: Configuration): Required<ElectronBrandingOptions> {\n return {\n projectName: opts.electronBranding?.projectName || \"electron\",\n productName: opts.electronBranding?.productName || \"Electron\",\n }\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n const base: ElectronDownloadOptions = { platform, arch, version: electronVersion }\n const dl = opts.electronDownload\n if (dl == null) {\n return base\n }\n if (Object.hasOwnProperty.call(dl, \"mirrorOptions\")) {\n // ElectronGetOptions: flatten mirrorOptions.mirror for the app-builder binary\n const { mirrorOptions } = dl as ElectronGetOptions\n return { ...base, mirror: mirrorOptions?.mirror ?? undefined }\n }\n return { ...base, ...dl }\n}\n\n/**\n * Electron 45 ships `electron_wer.dll`, a Windows Error Reporting runtime exception helper that captures crashes which never reach\n * Crashpad's in-process handler, such as `__fastfail` (https://github.com/electron/electron/pull/53802). Electron looks the helper up\n * as `<executable name>_wer.dll` next to the executable, so it has to be renamed together with the executable.\n * The check is on the semver major so 45 prereleases are covered as well.\n */\nexport const FIRST_ELECTRON_MAJOR_WITH_WER_HELPER = 45\n\n/**\n * Renames `<projectName>_wer.dll` to `<productFilename>_wer.dll` for Electron 45 and later. Does nothing for older Electron versions,\n * unparseable versions or when the DLL is absent (a custom Electron distribution may omit it to opt out of WER crash capture).\n *\n * Exported for unit testing.\n */\nexport async function renameWindowsWerHelperIfNeeded(appOutDir: string, projectName: string, productFilename: string, electronVersion: string): Promise<void> {\n const coerced = semver.coerce(electronVersion)\n if (coerced == null || semver.major(coerced) < FIRST_ELECTRON_MAJOR_WITH_WER_HELPER) {\n return\n }\n const source = `${projectName}_wer.dll`\n const destination = `${productFilename}_wer.dll`\n if (source === destination) {\n return\n }\n const renamed = await orIfFileNotExist(\n rename(path.join(appOutDir, source), path.join(appOutDir, destination)).then(() => true),\n false\n )\n if (renamed) {\n log.debug({ from: source, to: destination }, \"renamed Windows Error Reporting helper to match the executable name\")\n }\n}\n\n// exported for unit testing\nexport async function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions, electronVersion: string) {\n const { appOutDir, packager } = options\n const electronBranding = createBrandingOpts(packager.config)\n if (packager.platform === Platform.LINUX) {\n const linuxPackager = packager as LinuxPackager\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, electronBranding.projectName), executable)\n } else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable)\n await renameWindowsWerHelperIfNeeded(appOutDir, electronBranding.projectName, packager.appInfo.productFilename, electronVersion)\n if (options.asarIntegrity) {\n await addWinAsarIntegrity(executable, options.asarIntegrity)\n }\n } else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n }\n await removeUnusedLanguagesIfNeeded(options)\n}\n\nexport async function removeUnusedLanguagesIfNeeded(options: BeforeCopyExtraFilesOptions) {\n const { packager, appOutDir } = options\n const { config, platformSpecificBuildOptions, platform } = packager\n\n const getLocalesConfig = () => {\n if (platform === Platform.MAC) {\n return { dirs: [packager.getResourcesDir(appOutDir), packager.getMacOsElectronFrameworkResourcesDir(appOutDir)], langFileExt: \".lproj\" }\n }\n return { dirs: [path.join(packager.getResourcesDir(appOutDir), \"..\", \"locales\")], langFileExt: \".pak\" }\n }\n\n // case-insensitive, treating \"-\" and \"_\" as the same separator\n const normalizeLocale = (locale: string) => locale.trim().toLowerCase().replace(/_/g, \"-\")\n const wantedLanguages = asArray(platformSpecificBuildOptions.electronLanguages || config.electronLanguages)\n .map(normalizeLocale)\n .filter(it => it.length > 0)\n if (!wantedLanguages.length) {\n return\n }\n\n // bare wanted \"en\" keeps \"en-US.pak\"; region-qualified wanted \"en-US\" keeps mac's bare \"en.lproj\"\n const isLocaleMatch = (wanted: string, language: string) => wanted === language || language.startsWith(`${wanted}-`) || wanted.startsWith(`${language}-`)\n\n const { dirs, langFileExt } = getLocalesConfig()\n const matchedWantedLanguages = new Set<string>()\n const filesToDelete: string[] = []\n for (const dir of dirs) {\n const localeFiles = (await readdir(dir)).filter(file => path.extname(file) === langFileExt)\n const unwantedFiles: string[] = []\n for (const file of localeFiles) {\n const language = normalizeLocale(path.basename(file, langFileExt))\n const matches = wantedLanguages.filter(wanted => isLocaleMatch(wanted, language))\n if (matches.length === 0) {\n unwantedFiles.push(path.join(dir, file))\n } else {\n matches.forEach(it => matchedWantedLanguages.add(it))\n }\n }\n if (localeFiles.length > 0 && unwantedFiles.length === localeFiles.length) {\n // an empty locales dir produces an app that crashes at startup (https://github.com/electron/electron/issues/52307)\n log.warn(\n { electronLanguages: wantedLanguages, dir },\n \"electronLanguages doesn't match any locale in this directory, skipping cleanup to avoid packaging an app without locales\"\n )\n continue\n }\n filesToDelete.push(...unwantedFiles)\n }\n\n const unmatchedLanguages = wantedLanguages.filter(it => !matchedWantedLanguages.has(it))\n if (unmatchedLanguages.length > 0) {\n log.warn({ electronLanguages: unmatchedLanguages }, \"some electronLanguages don't match any locale, they may be misspelled or unavailable on this platform\")\n }\n await asyncPool(MAX_FILE_REQUESTS, filesToDelete, file => rm(file, { recursive: true, force: true }))\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(\n readonly name: string,\n readonly version: string,\n readonly macOsProductName: string\n ) {}\n\n get distMacOsAppName(): string {\n return `${this.macOsProductName}.app`\n }\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n } else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n const downloadOptions = createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version)\n const shouldCleanup = await unpack(options, downloadOptions, this.distMacOsAppName)\n await cleanupAfterUnpack(options, this.distMacOsAppName, shouldCleanup)\n if (options.packager.config.downloadAlternateFFmpeg) {\n const injector = new FFMPEGInjector(options, this.version, createBrandingOpts(options.packager.config))\n await injector.inject()\n }\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options, this.version)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n } else {\n version = await computeElectronVersion(packager.projectDir)\n }\n configuration.electronVersion = version\n }\n\n const branding = createBrandingOpts(configuration)\n return new ElectronFramework(branding.projectName, version, branding.productName)\n}\n\n/**\n * Unpacks a custom or default Electron distribution into the app output directory.\n */\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, downloadOptions: ElectronDownloadOptions, _distMacOsAppName: string): Promise<boolean> {\n async function selectElectron(filepath: string) {\n const resolvedDist = path.isAbsolute(filepath) ? filepath : path.resolve(packager.projectDir, filepath)\n\n const electronDistStats = await statOrNull(resolvedDist)\n if (!electronDistStats) {\n throw new Error(\n `The specified electronDist does not exist: ${resolvedDist}. Please provide a valid path to the Electron zip file, cache directory, or electron build directory.`\n )\n }\n\n if (resolvedDist.endsWith(\".zip\")) {\n log.info({ zipFile: resolvedDist }, \"using custom electronDist zip file\")\n await extractArchive(resolvedDist, appOutDir)\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n\n if (electronDistStats.isDirectory()) {\n // backward compatibility: if electronDist is a directory, check for the default zip file inside it\n const files = await readdir(resolvedDist)\n if (files.includes(defaultZipName)) {\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom electronDist directory\")\n await extractArchive(path.join(resolvedDist, defaultZipName), appOutDir)\n return false // do not clean up after unpacking, it's a custom bundle and we should respect its configuration/contents as required\n }\n // if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file\n // e.g. we treat it as a custom already-unpacked Electron distribution\n log.info({ electronDist: log.filePath(resolvedDist) }, \"using custom unpacked Electron distribution\")\n const source = packager.getElectronSrcDir(resolvedDist)\n const destination = packager.getElectronDestinationDir(prepareOptions.appOutDir)\n log.info({ source, destination }, \"copying unpacked Electron\")\n await emptyDir(prepareOptions.appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n return false\n }\n throw new Error(`The specified electronDist is neither a zip file nor a directory: ${resolvedDist}. Please provide a valid path to the Electron zip file or cache directory.`)\n }\n\n const { packager, appOutDir, platformName } = prepareOptions\n const { version, arch } = downloadOptions\n const defaultZipName = `electron-v${version}-${platformName}-${arch}.zip`\n\n const electronDist = packager.config.electronDist\n if (typeof electronDist === \"string\" && !isEmptyOrSpaces(electronDist)) {\n return selectElectron(electronDist)\n }\n\n let resolvedDist: string | null = null\n try {\n const electronDistHook: any = await resolveFunction(packager.appInfo.type, electronDist, \"electronDist\", await packager.info.getWorkspaceRoot())\n resolvedDist = typeof electronDistHook === \"function\" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook\n } catch (error: any) {\n log.warn({ error }, \"Failed to resolve electronDist, using default unpack logic\")\n }\n\n if (resolvedDist == null) {\n // if no custom electronDist is provided, use the default unpack logic\n log.debug(null, \"no custom electronDist provided, unpacking default Electron distribution\")\n const zipPath = await downloadElectronArtifactZip({\n electronDownload: downloadOptions,\n artifactName: \"electron\",\n platformName: downloadOptions.platform ?? prepareOptions.platformName,\n arch: downloadOptions.arch ?? prepareOptions.arch,\n version: downloadOptions.version ?? prepareOptions.version,\n })\n await extractArchive(zipPath, appOutDir)\n log.info({ output: appOutDir }, \"downloaded electron zip extracted successfully\")\n return true // indicates that we should clean up after unpacking\n }\n return selectElectron(resolvedDist)\n}\n\nexport function cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n retainElectronLicenseFiles(out, resourcesPath, isMac),\n ])\n}\n\n/**\n * The Electron dist ships Electron's own `LICENSE` and Chromium's `LICENSES.chromium.html` next to the binary, and both licenses require them to be\n * retained in distributables. On win/linux they stay next to the executable, but on macOS they sit outside the `.app` bundle, which is the only thing\n * packaged into the artifacts, so move them into `Contents/Resources`. See https://github.com/electron-userland/electron-builder/issues/9407\n */\nasync function retainElectronLicenseFiles(appOutDir: string, resourcesPath: string, isMac: boolean) {\n const destinationDir = isMac ? resourcesPath : appOutDir\n // a custom Electron distribution may not ship license files, so only a missing source file is tolerated; any other error propagates\n const move = (name: string, newName: string = name) => orIfFileNotExist(rename(path.join(appOutDir, name), path.join(destinationDir, newName)), undefined)\n await Promise.all([move(\"LICENSE\", \"LICENSE.electron.txt\"), ...(isMac ? [move(\"LICENSES.chromium.html\")] : [])])\n}\n"]}
@@ -9,6 +9,7 @@ const appInfo_1 = require("../appInfo");
9
9
  const platformPackager_1 = require("../platformPackager");
10
10
  const plist_1 = require("../util/plist");
11
11
  const ElectronFramework_1 = require("./ElectronFramework");
12
+ const electronMacUtils_1 = require("./electronMacUtils");
12
13
  function doRename(basePath, oldName, newName) {
13
14
  return (0, promises_1.rename)(path.join(basePath, oldName), path.join(basePath, newName));
14
15
  }
@@ -94,7 +95,7 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
94
95
  await packager.applyCommonInfo(appPlist, contentsPath);
95
96
  // required for electron-updater proxy
96
97
  if (!isMas) {
97
- configureLocalhostAts(appPlist);
98
+ (0, electronMacUtils_1.configureLocalhostAts)(appPlist);
98
99
  }
99
100
  if (helperPlist != null) {
100
101
  helperPlist.CFBundleExecutable = `${appFilename} Helper`;
@@ -228,31 +229,4 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
228
229
  const now = Date.now() / 1000;
229
230
  await (0, promises_1.utimes)(appPath, now, now);
230
231
  }
231
- function configureLocalhostAts(appPlist) {
232
- // https://bencoding.com/2015/07/20/app-transport-security-and-localhost/
233
- let ats = appPlist.NSAppTransportSecurity;
234
- if (ats == null) {
235
- ats = {};
236
- appPlist.NSAppTransportSecurity = ats;
237
- }
238
- ats.NSAllowsLocalNetworking = true;
239
- // https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814
240
- ats.NSAllowsArbitraryLoads = true;
241
- let exceptionDomains = ats.NSExceptionDomains;
242
- if (exceptionDomains == null) {
243
- exceptionDomains = {};
244
- ats.NSExceptionDomains = exceptionDomains;
245
- }
246
- if (exceptionDomains.localhost == null) {
247
- const allowHttp = {
248
- NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,
249
- NSIncludesSubdomains: false,
250
- NSTemporaryExceptionAllowsInsecureHTTPLoads: true,
251
- NSTemporaryExceptionMinimumTLSVersion: "1.0",
252
- NSTemporaryExceptionRequiresForwardSecrecy: false,
253
- };
254
- exceptionDomains.localhost = allowHttp;
255
- exceptionDomains["127.0.0.1"] = allowHttp;
256
- }
257
- }
258
232
  //# sourceMappingURL=electronMac.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"electronMac.js","sourceRoot":"","sources":["../../src/electron/electronMac.ts"],"names":[],"mappings":";;AAmDA,oCAwOC;AA3RD,+CAA+G;AAC/G,0CAA4C;AAC5C,6BAA4B;AAC5B,yBAAwB;AACxB,wCAAqD;AAGrD,0DAAkD;AAClD,yCAAsF;AACtF,2DAAwD;AAExD,SAAS,QAAQ,CAAC,QAAgB,EAAE,OAAe,EAAE,OAAe;IAClE,OAAO,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AAC3E,CAAC;AAED,SAAS,WAAW,CAAC,cAA6B,EAAE,cAAsB,EAAE,OAAe,EAAE,MAAc;IACzG,OAAO,OAAO,CAAC,GAAG,CAChB,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,MAAM,GAAG,MAAM,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QACnG,OAAO,QAAQ,CAAC,kBAAkB,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,CAA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,GAAG,CAAA;IACvC,CAAC;IAED,GAAG,CAAC,uBAAuB,GAAG,IAAI,CAAA;IAClC,2FAA2F;IAC3F,GAAG,CAAC,sBAAsB,GAAG,IAAI,CAAA;IAEjC,IAAI,gBAAgB,GAAG,GAAG,CAAC,kBAAkB,CAAA;IAC7C,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;QAC7B,gBAAgB,GAAG,EAAE,CAAA;QACrB,GAAG,CAAC,kBAAkB,GAAG,gBAAgB,CAAA;IAC3C,CAAC;IAED,IAAI,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG;YAChB,4CAA4C,EAAE,KAAK;YACnD,oBAAoB,EAAE,KAAK;YAC3B,2CAA2C,EAAE,IAAI;YACjD,qCAAqC,EAAE,KAAK;YAC5C,0CAA0C,EAAE,KAAK;SAClD,CAAA;QACD,gBAAgB,CAAC,SAAS,GAAG,SAAS,CAAA;QACtC,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,CAAA;IAC3C,CAAC;AACH,CAAC","sourcesContent":["import { asArray, copyOrLinkFile, getPlatformIconFileName, InvalidConfigurationError, log } from \"builder-util\"\nimport { rename, utimes } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { AsarIntegrity } from \"../asar/integrity\"\nimport { MacPackager } from \"../macPackager\"\nimport { normalizeExt } from \"../platformPackager\"\nimport { savePlistFile, parsePlistFile, PlistObject, PlistValue } from \"../util/plist\"\nimport { createBrandingOpts } from \"./ElectronFramework\"\n\nfunction doRename(basePath: string, oldName: string, newName: string) {\n return rename(path.join(basePath, oldName), path.join(basePath, newName))\n}\n\nfunction moveHelpers(helperSuffixes: Array<string>, frameworksPath: string, appName: string, prefix: string): Promise<any> {\n return Promise.all(\n helperSuffixes.map(suffix => {\n const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix).then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`))\n })\n )\n}\n\nfunction getAvailableHelperSuffixes(\n helperEHPlist: PlistObject | null,\n helperNPPlist: PlistObject | null,\n helperRendererPlist: PlistObject | null,\n helperPluginPlist: PlistObject | null,\n helperGPUPlist: PlistObject | null\n) {\n const result = [\" Helper\"]\n if (helperEHPlist != null) {\n result.push(\" Helper EH\")\n }\n if (helperNPPlist != null) {\n result.push(\" Helper NP\")\n }\n if (helperRendererPlist != null) {\n result.push(\" Helper (Renderer)\")\n }\n if (helperPluginPlist != null) {\n result.push(\" Helper (Plugin)\")\n }\n if (helperGPUPlist != null) {\n result.push(\" Helper (GPU)\")\n }\n return result\n}\n\n/** @internal */\nexport async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null, isMas: boolean) {\n const appInfo = packager.appInfo\n // Electon uses the application name (CFBundleName) to resolve helper apps\n // https://github.com/electron/electron/blob/main/shell/app/electron_main_delegate_mac.mm\n // https://github.com/electron-userland/electron-builder/issues/6962\n const appFilename = appInfo.sanitizedProductName\n const electronBranding = createBrandingOpts(packager.config)\n\n const contentsPath = path.join(appOutDir, packager.info.framework.distMacOsAppName, \"Contents\")\n const frameworksPath = path.join(contentsPath, \"Frameworks\")\n const loginItemPath = path.join(contentsPath, \"Library\", \"LoginItems\")\n\n const appPlistFilename = path.join(contentsPath, \"Info.plist\")\n const helperPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper.app`, \"Contents\", \"Info.plist\")\n const helperEHPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper EH.app`, \"Contents\", \"Info.plist\")\n const helperNPPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper NP.app`, \"Contents\", \"Info.plist\")\n const helperRendererPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Renderer).app`, \"Contents\", \"Info.plist\")\n const helperPluginPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Plugin).app`, \"Contents\", \"Info.plist\")\n const helperGPUPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (GPU).app`, \"Contents\", \"Info.plist\")\n const helperLoginPlistFilename = path.join(loginItemPath, `${electronBranding.productName} Login Helper.app`, \"Contents\", \"Info.plist\")\n\n const safeParsePlistFile = async (filePath: string): Promise<PlistObject | null> => {\n if (!fs.existsSync(filePath)) {\n return null\n }\n return await parsePlistFile(filePath)\n }\n\n const appPlist = (await safeParsePlistFile(appPlistFilename))!\n if (appPlist == null) {\n throw new Error(\"corrupted Electron dist\")\n }\n\n // Replace the multiple parsePlistFile calls with:\n const helperPlist = await safeParsePlistFile(helperPlistFilename)\n const helperEHPlist = await safeParsePlistFile(helperEHPlistFilename)\n const helperNPPlist = await safeParsePlistFile(helperNPPlistFilename)\n const helperRendererPlist = await safeParsePlistFile(helperRendererPlistFilename)\n const helperPluginPlist = await safeParsePlistFile(helperPluginPlistFilename)\n const helperGPUPlist = await safeParsePlistFile(helperGPUPlistFilename)\n const helperLoginPlist = await safeParsePlistFile(helperLoginPlistFilename)\n\n const buildMetadata = packager.config\n\n /**\n * Configure bundleIdentifier for the generic Electron Helper process\n *\n * This was the only Helper in Electron 5 and before. Allow users to configure\n * the bundleIdentifier for continuity.\n */\n\n const oldHelperBundleId = (buildMetadata as any)[\"helper-bundle-id\"]\n if (oldHelperBundleId != null) {\n log.warn(\"build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId\")\n }\n\n const defaultAppId = packager.platformSpecificBuildOptions.appId\n const cfBundleIdentifier = filterCFBundleIdentifier((isMas ? packager.config.mas?.appId : defaultAppId) || defaultAppId || appInfo.macBundleIdentifier)\n\n const defaultHelperId = packager.platformSpecificBuildOptions.helperBundleId\n const helperBundleIdentifier = filterCFBundleIdentifier(\n (isMas ? packager.config.mas?.helperBundleId : defaultHelperId) || defaultHelperId || oldHelperBundleId || `${cfBundleIdentifier}.helper`\n )\n\n appPlist.CFBundleIdentifier = cfBundleIdentifier\n\n await packager.applyCommonInfo(appPlist, contentsPath)\n\n // required for electron-updater proxy\n if (!isMas) {\n configureLocalhostAts(appPlist)\n }\n\n if (helperPlist != null) {\n helperPlist.CFBundleExecutable = `${appFilename} Helper`\n helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`\n helperPlist.CFBundleIdentifier = helperBundleIdentifier\n helperPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n /**\n * Configure bundleIdentifier for Electron 5+ Helper processes\n *\n * In Electron 6, parts of the generic Electron Helper process were split into\n * individual helper processes. Allow users to configure the bundleIdentifiers\n * for continuity, specifically because macOS keychain access relies on\n * bundleIdentifiers not changing (i.e. across versions of Electron).\n */\n\n function configureHelper(helper: any, postfix: string, userProvidedBundleIdentifier?: string | null) {\n helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`\n helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`\n helper.CFBundleIdentifier = userProvidedBundleIdentifier\n ? filterCFBundleIdentifier(userProvidedBundleIdentifier)\n : filterCFBundleIdentifier(`${helperBundleIdentifier}.${postfix}`)\n helper.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n if (helperRendererPlist != null) {\n configureHelper(helperRendererPlist, \"(Renderer)\", packager.platformSpecificBuildOptions.helperRendererBundleId)\n }\n if (helperPluginPlist != null) {\n configureHelper(helperPluginPlist, \"(Plugin)\", packager.platformSpecificBuildOptions.helperPluginBundleId)\n }\n if (helperGPUPlist != null) {\n configureHelper(helperGPUPlist, \"(GPU)\", packager.platformSpecificBuildOptions.helperGPUBundleId)\n }\n if (helperEHPlist != null) {\n configureHelper(helperEHPlist, \"EH\", packager.platformSpecificBuildOptions.helperEHBundleId)\n }\n if (helperNPPlist != null) {\n configureHelper(helperNPPlist, \"NP\", packager.platformSpecificBuildOptions.helperNPBundleId)\n }\n if (helperLoginPlist != null) {\n helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`\n helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`\n // noinspection SpellCheckingInspection\n helperLoginPlist.CFBundleIdentifier = `${cfBundleIdentifier}.loginhelper`\n helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))\n if (protocols.length > 0) {\n appPlist.CFBundleURLTypes = protocols.map(protocol => {\n const schemes = asArray(protocol.schemes)\n if (schemes.length === 0) {\n throw new InvalidConfigurationError(`Protocol \"${protocol.name}\": must be at least one scheme specified`)\n }\n return {\n CFBundleURLName: protocol.name,\n CFBundleTypeRole: protocol.role || \"Editor\",\n CFBundleURLSchemes: schemes.slice(),\n }\n })\n }\n\n const fileAssociations = packager.fileAssociations\n if (fileAssociations.length > 0) {\n const documentTypes = await Promise.all(\n fileAssociations.map(async fileAssociation => {\n const extensions = asArray(fileAssociation.ext).map(normalizeExt)\n const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)\n let iconFile = appPlist.CFBundleIconFile\n if (customIcon != null) {\n iconFile = path.basename(customIcon)\n await copyOrLinkFile(customIcon, path.join(path.join(contentsPath, \"Resources\"), iconFile))\n }\n\n const result = {\n CFBundleTypeExtensions: extensions,\n CFBundleTypeName: fileAssociation.name || extensions[0],\n CFBundleTypeRole: fileAssociation.role || \"Editor\",\n LSHandlerRank: fileAssociation.rank || \"Default\",\n CFBundleTypeIconFile: iconFile,\n } as any\n\n if (fileAssociation.isPackage) {\n result.LSTypeIsPackage = true\n }\n return result\n })\n )\n\n // `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case\n appPlist.CFBundleDocumentTypes = [...((appPlist.CFBundleDocumentTypes as PlistValue[]) || []), ...documentTypes]\n }\n\n const toPlistObject = (asarIntegrity: AsarIntegrity): PlistObject => {\n const result: PlistObject = {}\n for (const [filePath, headerHash] of Object.entries(asarIntegrity)) {\n result[filePath] = {\n algorithm: headerHash.algorithm,\n hash: headerHash.hash,\n }\n }\n return result\n }\n\n if (asarIntegrity != null) {\n appPlist.ElectronAsarIntegrity = toPlistObject(asarIntegrity)\n }\n\n if (helperEHPlist != null) {\n await savePlistFile(helperEHPlistFilename, helperEHPlist)\n }\n\n if (helperNPPlist != null) {\n await savePlistFile(helperNPPlistFilename, helperNPPlist)\n }\n\n if (helperRendererPlist != null) {\n await savePlistFile(helperRendererPlistFilename, helperRendererPlist)\n }\n\n if (helperPluginPlist != null) {\n await savePlistFile(helperPluginPlistFilename, helperPluginPlist)\n }\n\n if (helperGPUPlist != null) {\n await savePlistFile(helperGPUPlistFilename, helperGPUPlist)\n }\n\n if (helperLoginPlist != null) {\n await savePlistFile(helperLoginPlistFilename, helperLoginPlist)\n }\n\n await savePlistFile(appPlistFilename, appPlist)\n if (helperPlist != null) {\n await savePlistFile(helperPlistFilename, helperPlist)\n }\n\n await doRename(path.join(contentsPath, \"MacOS\"), electronBranding.productName, appPlist.CFBundleExecutable as string)\n\n await moveHelpers(\n getAvailableHelperSuffixes(helperEHPlist, helperNPPlist, helperRendererPlist, helperPluginPlist, helperGPUPlist),\n frameworksPath,\n appFilename,\n electronBranding.productName\n )\n\n if (helperLoginPlist != null) {\n const prefix = electronBranding.productName\n const suffix = \" Login Helper\"\n const executableBasePath = path.join(loginItemPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix).then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`))\n }\n\n const appPath = path.join(appOutDir, `${appInfo.productFilename}.app`)\n await rename(path.dirname(contentsPath), appPath)\n // https://github.com/electron-userland/electron-builder/issues/840\n const now = Date.now() / 1000\n await utimes(appPath, now, now)\n}\n\nfunction configureLocalhostAts(appPlist: any) {\n // https://bencoding.com/2015/07/20/app-transport-security-and-localhost/\n let ats = appPlist.NSAppTransportSecurity\n if (ats == null) {\n ats = {}\n appPlist.NSAppTransportSecurity = ats\n }\n\n ats.NSAllowsLocalNetworking = true\n // https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814\n ats.NSAllowsArbitraryLoads = true\n\n let exceptionDomains = ats.NSExceptionDomains\n if (exceptionDomains == null) {\n exceptionDomains = {}\n ats.NSExceptionDomains = exceptionDomains\n }\n\n if (exceptionDomains.localhost == null) {\n const allowHttp = {\n NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,\n NSIncludesSubdomains: false,\n NSTemporaryExceptionAllowsInsecureHTTPLoads: true,\n NSTemporaryExceptionMinimumTLSVersion: \"1.0\",\n NSTemporaryExceptionRequiresForwardSecrecy: false,\n }\n exceptionDomains.localhost = allowHttp\n exceptionDomains[\"127.0.0.1\"] = allowHttp\n }\n}\n"]}
1
+ {"version":3,"file":"electronMac.js","sourceRoot":"","sources":["../../src/electron/electronMac.ts"],"names":[],"mappings":";;AAoDA,oCAwOC;AA5RD,+CAA+G;AAC/G,0CAA4C;AAC5C,6BAA4B;AAC5B,yBAAwB;AACxB,wCAAqD;AAGrD,0DAAkD;AAClD,yCAAsF;AACtF,2DAAwD;AACxD,yDAA0D;AAE1D,SAAS,QAAQ,CAAC,QAAgB,EAAE,OAAe,EAAE,OAAe;IAClE,OAAO,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AAC3E,CAAC;AAED,SAAS,WAAW,CAAC,cAA6B,EAAE,cAAsB,EAAE,OAAe,EAAE,MAAc;IACzG,OAAO,OAAO,CAAC,GAAG,CAChB,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,MAAM,GAAG,MAAM,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QACnG,OAAO,QAAQ,CAAC,kBAAkB,EAAE,GAAG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AAC,WAAW,EAAE,QAAQ,CAAC,kBAA4B,CAAC,CAAA;IAErH,MAAM,WAAW,CACf,0BAA0B,CAAC,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,CAAC,EAChH,cAAc,EACd,WAAW,EACX,gBAAgB,CAAC,WAAW,CAC7B,CAAA;IAED,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,CAAA;QAC3C,MAAM,MAAM,GAAG,eAAe,CAAA;QAC9B,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QAClG,MAAM,QAAQ,CAAC,kBAAkB,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,MAAM,EAAE,GAAG,WAAW,GAAG,MAAM,MAAM,CAAC,CAAC,CAAA;IAC7K,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,eAAe,MAAM,CAAC,CAAA;IACtE,MAAM,IAAA,iBAAM,EAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAA;IACjD,mEAAmE;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;IAC7B,MAAM,IAAA,iBAAM,EAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC","sourcesContent":["import { asArray, copyOrLinkFile, getPlatformIconFileName, InvalidConfigurationError, log } from \"builder-util\"\nimport { rename, utimes } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as fs from \"fs\"\nimport { filterCFBundleIdentifier } from \"../appInfo\"\nimport { AsarIntegrity } from \"../asar/integrity\"\nimport { MacPackager } from \"../macPackager\"\nimport { normalizeExt } from \"../platformPackager\"\nimport { savePlistFile, parsePlistFile, PlistObject, PlistValue } from \"../util/plist\"\nimport { createBrandingOpts } from \"./ElectronFramework\"\nimport { configureLocalhostAts } from \"./electronMacUtils\"\n\nfunction doRename(basePath: string, oldName: string, newName: string) {\n return rename(path.join(basePath, oldName), path.join(basePath, newName))\n}\n\nfunction moveHelpers(helperSuffixes: Array<string>, frameworksPath: string, appName: string, prefix: string): Promise<any> {\n return Promise.all(\n helperSuffixes.map(suffix => {\n const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix).then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`))\n })\n )\n}\n\nfunction getAvailableHelperSuffixes(\n helperEHPlist: PlistObject | null,\n helperNPPlist: PlistObject | null,\n helperRendererPlist: PlistObject | null,\n helperPluginPlist: PlistObject | null,\n helperGPUPlist: PlistObject | null\n) {\n const result = [\" Helper\"]\n if (helperEHPlist != null) {\n result.push(\" Helper EH\")\n }\n if (helperNPPlist != null) {\n result.push(\" Helper NP\")\n }\n if (helperRendererPlist != null) {\n result.push(\" Helper (Renderer)\")\n }\n if (helperPluginPlist != null) {\n result.push(\" Helper (Plugin)\")\n }\n if (helperGPUPlist != null) {\n result.push(\" Helper (GPU)\")\n }\n return result\n}\n\n/** @internal */\nexport async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null, isMas: boolean) {\n const appInfo = packager.appInfo\n // Electon uses the application name (CFBundleName) to resolve helper apps\n // https://github.com/electron/electron/blob/main/shell/app/electron_main_delegate_mac.mm\n // https://github.com/electron-userland/electron-builder/issues/6962\n const appFilename = appInfo.sanitizedProductName\n const electronBranding = createBrandingOpts(packager.config)\n\n const contentsPath = path.join(appOutDir, packager.info.framework.distMacOsAppName, \"Contents\")\n const frameworksPath = path.join(contentsPath, \"Frameworks\")\n const loginItemPath = path.join(contentsPath, \"Library\", \"LoginItems\")\n\n const appPlistFilename = path.join(contentsPath, \"Info.plist\")\n const helperPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper.app`, \"Contents\", \"Info.plist\")\n const helperEHPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper EH.app`, \"Contents\", \"Info.plist\")\n const helperNPPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper NP.app`, \"Contents\", \"Info.plist\")\n const helperRendererPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Renderer).app`, \"Contents\", \"Info.plist\")\n const helperPluginPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (Plugin).app`, \"Contents\", \"Info.plist\")\n const helperGPUPlistFilename = path.join(frameworksPath, `${electronBranding.productName} Helper (GPU).app`, \"Contents\", \"Info.plist\")\n const helperLoginPlistFilename = path.join(loginItemPath, `${electronBranding.productName} Login Helper.app`, \"Contents\", \"Info.plist\")\n\n const safeParsePlistFile = async (filePath: string): Promise<PlistObject | null> => {\n if (!fs.existsSync(filePath)) {\n return null\n }\n return await parsePlistFile(filePath)\n }\n\n const appPlist = (await safeParsePlistFile(appPlistFilename))!\n if (appPlist == null) {\n throw new Error(\"corrupted Electron dist\")\n }\n\n // Replace the multiple parsePlistFile calls with:\n const helperPlist = await safeParsePlistFile(helperPlistFilename)\n const helperEHPlist = await safeParsePlistFile(helperEHPlistFilename)\n const helperNPPlist = await safeParsePlistFile(helperNPPlistFilename)\n const helperRendererPlist = await safeParsePlistFile(helperRendererPlistFilename)\n const helperPluginPlist = await safeParsePlistFile(helperPluginPlistFilename)\n const helperGPUPlist = await safeParsePlistFile(helperGPUPlistFilename)\n const helperLoginPlist = await safeParsePlistFile(helperLoginPlistFilename)\n\n const buildMetadata = packager.config\n\n /**\n * Configure bundleIdentifier for the generic Electron Helper process\n *\n * This was the only Helper in Electron 5 and before. Allow users to configure\n * the bundleIdentifier for continuity.\n */\n\n const oldHelperBundleId = (buildMetadata as any)[\"helper-bundle-id\"]\n if (oldHelperBundleId != null) {\n log.warn(\"build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId\")\n }\n\n const defaultAppId = packager.platformSpecificBuildOptions.appId\n const cfBundleIdentifier = filterCFBundleIdentifier((isMas ? packager.config.mas?.appId : defaultAppId) || defaultAppId || appInfo.macBundleIdentifier)\n\n const defaultHelperId = packager.platformSpecificBuildOptions.helperBundleId\n const helperBundleIdentifier = filterCFBundleIdentifier(\n (isMas ? packager.config.mas?.helperBundleId : defaultHelperId) || defaultHelperId || oldHelperBundleId || `${cfBundleIdentifier}.helper`\n )\n\n appPlist.CFBundleIdentifier = cfBundleIdentifier\n\n await packager.applyCommonInfo(appPlist, contentsPath)\n\n // required for electron-updater proxy\n if (!isMas) {\n configureLocalhostAts(appPlist)\n }\n\n if (helperPlist != null) {\n helperPlist.CFBundleExecutable = `${appFilename} Helper`\n helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`\n helperPlist.CFBundleIdentifier = helperBundleIdentifier\n helperPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n /**\n * Configure bundleIdentifier for Electron 5+ Helper processes\n *\n * In Electron 6, parts of the generic Electron Helper process were split into\n * individual helper processes. Allow users to configure the bundleIdentifiers\n * for continuity, specifically because macOS keychain access relies on\n * bundleIdentifiers not changing (i.e. across versions of Electron).\n */\n\n function configureHelper(helper: any, postfix: string, userProvidedBundleIdentifier?: string | null) {\n helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`\n helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`\n helper.CFBundleIdentifier = userProvidedBundleIdentifier\n ? filterCFBundleIdentifier(userProvidedBundleIdentifier)\n : filterCFBundleIdentifier(`${helperBundleIdentifier}.${postfix}`)\n helper.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n if (helperRendererPlist != null) {\n configureHelper(helperRendererPlist, \"(Renderer)\", packager.platformSpecificBuildOptions.helperRendererBundleId)\n }\n if (helperPluginPlist != null) {\n configureHelper(helperPluginPlist, \"(Plugin)\", packager.platformSpecificBuildOptions.helperPluginBundleId)\n }\n if (helperGPUPlist != null) {\n configureHelper(helperGPUPlist, \"(GPU)\", packager.platformSpecificBuildOptions.helperGPUBundleId)\n }\n if (helperEHPlist != null) {\n configureHelper(helperEHPlist, \"EH\", packager.platformSpecificBuildOptions.helperEHBundleId)\n }\n if (helperNPPlist != null) {\n configureHelper(helperNPPlist, \"NP\", packager.platformSpecificBuildOptions.helperNPBundleId)\n }\n if (helperLoginPlist != null) {\n helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`\n helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`\n // noinspection SpellCheckingInspection\n helperLoginPlist.CFBundleIdentifier = `${cfBundleIdentifier}.loginhelper`\n helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion\n }\n\n const protocols = asArray(buildMetadata.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))\n if (protocols.length > 0) {\n appPlist.CFBundleURLTypes = protocols.map(protocol => {\n const schemes = asArray(protocol.schemes)\n if (schemes.length === 0) {\n throw new InvalidConfigurationError(`Protocol \"${protocol.name}\": must be at least one scheme specified`)\n }\n return {\n CFBundleURLName: protocol.name,\n CFBundleTypeRole: protocol.role || \"Editor\",\n CFBundleURLSchemes: schemes.slice(),\n }\n })\n }\n\n const fileAssociations = packager.fileAssociations\n if (fileAssociations.length > 0) {\n const documentTypes = await Promise.all(\n fileAssociations.map(async fileAssociation => {\n const extensions = asArray(fileAssociation.ext).map(normalizeExt)\n const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)\n let iconFile = appPlist.CFBundleIconFile\n if (customIcon != null) {\n iconFile = path.basename(customIcon)\n await copyOrLinkFile(customIcon, path.join(path.join(contentsPath, \"Resources\"), iconFile))\n }\n\n const result = {\n CFBundleTypeExtensions: extensions,\n CFBundleTypeName: fileAssociation.name || extensions[0],\n CFBundleTypeRole: fileAssociation.role || \"Editor\",\n LSHandlerRank: fileAssociation.rank || \"Default\",\n CFBundleTypeIconFile: iconFile,\n } as any\n\n if (fileAssociation.isPackage) {\n result.LSTypeIsPackage = true\n }\n return result\n })\n )\n\n // `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case\n appPlist.CFBundleDocumentTypes = [...((appPlist.CFBundleDocumentTypes as PlistValue[]) || []), ...documentTypes]\n }\n\n const toPlistObject = (asarIntegrity: AsarIntegrity): PlistObject => {\n const result: PlistObject = {}\n for (const [filePath, headerHash] of Object.entries(asarIntegrity)) {\n result[filePath] = {\n algorithm: headerHash.algorithm,\n hash: headerHash.hash,\n }\n }\n return result\n }\n\n if (asarIntegrity != null) {\n appPlist.ElectronAsarIntegrity = toPlistObject(asarIntegrity)\n }\n\n if (helperEHPlist != null) {\n await savePlistFile(helperEHPlistFilename, helperEHPlist)\n }\n\n if (helperNPPlist != null) {\n await savePlistFile(helperNPPlistFilename, helperNPPlist)\n }\n\n if (helperRendererPlist != null) {\n await savePlistFile(helperRendererPlistFilename, helperRendererPlist)\n }\n\n if (helperPluginPlist != null) {\n await savePlistFile(helperPluginPlistFilename, helperPluginPlist)\n }\n\n if (helperGPUPlist != null) {\n await savePlistFile(helperGPUPlistFilename, helperGPUPlist)\n }\n\n if (helperLoginPlist != null) {\n await savePlistFile(helperLoginPlistFilename, helperLoginPlist)\n }\n\n await savePlistFile(appPlistFilename, appPlist)\n if (helperPlist != null) {\n await savePlistFile(helperPlistFilename, helperPlist)\n }\n\n await doRename(path.join(contentsPath, \"MacOS\"), electronBranding.productName, appPlist.CFBundleExecutable as string)\n\n await moveHelpers(\n getAvailableHelperSuffixes(helperEHPlist, helperNPPlist, helperRendererPlist, helperPluginPlist, helperGPUPlist),\n frameworksPath,\n appFilename,\n electronBranding.productName\n )\n\n if (helperLoginPlist != null) {\n const prefix = electronBranding.productName\n const suffix = \" Login Helper\"\n const executableBasePath = path.join(loginItemPath, `${prefix}${suffix}.app`, \"Contents\", \"MacOS\")\n await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix).then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`))\n }\n\n const appPath = path.join(appOutDir, `${appInfo.productFilename}.app`)\n await rename(path.dirname(contentsPath), appPath)\n // https://github.com/electron-userland/electron-builder/issues/840\n const now = Date.now() / 1000\n await utimes(appPath, now, now)\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Adds the App Transport Security entries that electron-updater's local update proxy needs: local networking, and
3
+ * plain-HTTP exceptions for `localhost` and `127.0.0.1`.
4
+ *
5
+ * `NSAllowsArbitraryLoads` is set to `true` only when the app has not set it already, for example through
6
+ * `mac.extendInfo`, so an explicit `false` is kept.
7
+ */
8
+ export declare function configureLocalhostAts(appPlist: any): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureLocalhostAts = configureLocalhostAts;
4
+ /**
5
+ * Adds the App Transport Security entries that electron-updater's local update proxy needs: local networking, and
6
+ * plain-HTTP exceptions for `localhost` and `127.0.0.1`.
7
+ *
8
+ * `NSAllowsArbitraryLoads` is set to `true` only when the app has not set it already, for example through
9
+ * `mac.extendInfo`, so an explicit `false` is kept.
10
+ */
11
+ function configureLocalhostAts(appPlist) {
12
+ // https://bencoding.com/2015/07/20/app-transport-security-and-localhost/
13
+ let ats = appPlist.NSAppTransportSecurity;
14
+ if (ats == null) {
15
+ ats = {};
16
+ appPlist.NSAppTransportSecurity = ats;
17
+ }
18
+ ats.NSAllowsLocalNetworking = true;
19
+ // https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814
20
+ if (ats.NSAllowsArbitraryLoads == null) {
21
+ ats.NSAllowsArbitraryLoads = true;
22
+ }
23
+ let exceptionDomains = ats.NSExceptionDomains;
24
+ if (exceptionDomains == null) {
25
+ exceptionDomains = {};
26
+ ats.NSExceptionDomains = exceptionDomains;
27
+ }
28
+ if (exceptionDomains.localhost == null) {
29
+ const allowHttp = {
30
+ NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,
31
+ NSIncludesSubdomains: false,
32
+ NSTemporaryExceptionAllowsInsecureHTTPLoads: true,
33
+ NSTemporaryExceptionMinimumTLSVersion: "1.0",
34
+ NSTemporaryExceptionRequiresForwardSecrecy: false,
35
+ };
36
+ exceptionDomains.localhost = allowHttp;
37
+ exceptionDomains["127.0.0.1"] = allowHttp;
38
+ }
39
+ }
40
+ //# sourceMappingURL=electronMacUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronMacUtils.js","sourceRoot":"","sources":["../../src/electron/electronMacUtils.ts"],"names":[],"mappings":";;AAOA,sDA+BC;AAtCD;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,QAAa;IACjD,yEAAyE;IACzE,IAAI,GAAG,GAAG,QAAQ,CAAC,sBAAsB,CAAA;IACzC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,GAAG,GAAG,EAAE,CAAA;QACR,QAAQ,CAAC,sBAAsB,GAAG,GAAG,CAAA;IACvC,CAAC;IAED,GAAG,CAAC,uBAAuB,GAAG,IAAI,CAAA;IAClC,2FAA2F;IAC3F,IAAI,GAAG,CAAC,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACvC,GAAG,CAAC,sBAAsB,GAAG,IAAI,CAAA;IACnC,CAAC;IAED,IAAI,gBAAgB,GAAG,GAAG,CAAC,kBAAkB,CAAA;IAC7C,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;QAC7B,gBAAgB,GAAG,EAAE,CAAA;QACrB,GAAG,CAAC,kBAAkB,GAAG,gBAAgB,CAAA;IAC3C,CAAC;IAED,IAAI,gBAAgB,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG;YAChB,4CAA4C,EAAE,KAAK;YACnD,oBAAoB,EAAE,KAAK;YAC3B,2CAA2C,EAAE,IAAI;YACjD,qCAAqC,EAAE,KAAK;YAC5C,0CAA0C,EAAE,KAAK;SAClD,CAAA;QACD,gBAAgB,CAAC,SAAS,GAAG,SAAS,CAAA;QACtC,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,CAAA;IAC3C,CAAC;AACH,CAAC","sourcesContent":["/**\n * Adds the App Transport Security entries that electron-updater's local update proxy needs: local networking, and\n * plain-HTTP exceptions for `localhost` and `127.0.0.1`.\n *\n * `NSAllowsArbitraryLoads` is set to `true` only when the app has not set it already, for example through\n * `mac.extendInfo`, so an explicit `false` is kept.\n */\nexport function configureLocalhostAts(appPlist: any): void {\n // https://bencoding.com/2015/07/20/app-transport-security-and-localhost/\n let ats = appPlist.NSAppTransportSecurity\n if (ats == null) {\n ats = {}\n appPlist.NSAppTransportSecurity = ats\n }\n\n ats.NSAllowsLocalNetworking = true\n // https://github.com/electron-userland/electron-builder/issues/3377#issuecomment-446035814\n if (ats.NSAllowsArbitraryLoads == null) {\n ats.NSAllowsArbitraryLoads = true\n }\n\n let exceptionDomains = ats.NSExceptionDomains\n if (exceptionDomains == null) {\n exceptionDomains = {}\n ats.NSExceptionDomains = exceptionDomains\n }\n\n if (exceptionDomains.localhost == null) {\n const allowHttp = {\n NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,\n NSIncludesSubdomains: false,\n NSTemporaryExceptionAllowsInsecureHTTPLoads: true,\n NSTemporaryExceptionMinimumTLSVersion: \"1.0\",\n NSTemporaryExceptionRequiresForwardSecrecy: false,\n }\n exceptionDomains.localhost = allowHttp\n exceptionDomains[\"127.0.0.1\"] = allowHttp\n }\n}\n"]}
@@ -76,7 +76,8 @@ export interface WindowsSigntoolConfiguration {
76
76
  */
77
77
  readonly sign?: CustomWindowsSign | string | null;
78
78
  /**
79
- * Array of signing algorithms used. For AppX `sha256` is always used.
79
+ * Array of signing algorithms used. For AppX/MSIX `sha256` is always used. `.msi` cannot be dual-signed,
80
+ * so it is signed once, with `sha256` unless `sha1` is the only algorithm listed.
80
81
  * @default ['sha1', 'sha256']
81
82
  */
82
83
  readonly signingHashAlgorithms?: Array<"sha1" | "sha256"> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"winOptions.js","sourceRoot":"","sources":["../../src/options/winOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\nimport { CustomWindowsSign } from \"../codeSign/windowsSignToolManager\"\nimport { PlatformSpecificBuildOptions, TargetConfigType } from \"../index\"\n\nexport interface WindowsConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The target package type: list of `nsis`, `nsis-web` (Web installer), `portable` ([portable]https://www.electron.build/nsis#portable) app without installation), `appx`, `msi`, `msi-wrapped`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.\n * AppX package can be built only on Windows 10.\n *\n * To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.\n *\n * @default nsis\n */\n readonly target?: TargetConfigType\n\n /**\n * The path to application icon.\n * @default build/icon.ico\n */\n readonly icon?: string | null\n\n /**\n * The trademarks and registered trademarks.\n */\n readonly legalTrademarks?: string | null\n\n /**\n * Options for usage with signtool.exe\n * Cannot be used in conjunction with `azureSignOptions`, signing will default to Azure Trusted Signing\n */\n readonly signtoolOptions?: WindowsSigntoolConfiguration | null\n\n /**\n * Options for usage of Azure Trusted Signing service\n * Cannot be used in conjunction with `signtoolOptions`, signing will default to Azure Trusted Signing\n */\n readonly azureSignOptions?: WindowsAzureSigningConfiguration | null\n\n /**\n * Whether to verify the signature of an available update before installation.\n * The [publisher name](#publisherName) will be used for the signature verification.\n *\n * @default true\n */\n readonly verifyUpdateCodeSignature?: boolean\n\n /**\n * The [security level](https://msdn.microsoft.com/en-us/library/6ad1fshk.aspx#Anchor_9) at which the application requests to be executed.\n * Cannot be specified per target, allowed only in the `win`.\n * @default asInvoker\n */\n readonly requestedExecutionLevel?: RequestedExecutionLevel | null\n\n /**\n * Whether to sign and add metadata to executable via [`resedit`](https://www.npmjs.com/package/resedit).\n * Metadata includes information about the app name/description/version, publisher, copyright, etc.\n * This property also is responsible for adding the app icon and setting execution level.\n * Set to `false` only if you need to fully disable resedit-based resource editing.\n * To skip only code signing while keeping resource editing, use `signExecutable: false` instead.\n * @default true\n */\n readonly signAndEditExecutable?: boolean\n\n /**\n * Whether to sign Windows executables and any additional files matched by `signExts`.\n * Set to `false` to skip Windows code signing while still editing executable resources\n * (icon, metadata, etc. via [`resedit`](https://www.npmjs.com/package/resedit)).\n * This option is not limited to the main executable edit/sign flow and can also affect\n * signing of Windows installers or other artifacts that use the standard signing path.\n * @default true\n */\n readonly signExecutable?: boolean\n\n /**\n * Explicit file name/extensions (`str.endsWith`) to also sign. Advanced option.\n * Supports negative patterns, e.g. example that excludes `.appx` files: `[\"somefilename\", \".dll\", \"!.appx\"]`.\n * @see https://github.com/electron-userland/electron-builder/issues/7329\n * @default null\n */\n readonly signExts?: string[] | null\n}\n\nexport type RequestedExecutionLevel = \"asInvoker\" | \"highestAvailable\" | \"requireAdministrator\"\n\nexport interface WindowsSigntoolConfiguration {\n /**\n * The custom function (or path to file or module id) to sign Windows executables\n */\n readonly sign?: CustomWindowsSign | string | null\n\n /**\n * Array of signing algorithms used. For AppX `sha256` is always used.\n * @default ['sha1', 'sha256']\n */\n readonly signingHashAlgorithms?: Array<\"sha1\" | \"sha256\"> | null\n\n /**\n * 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.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificateFile?: string | null\n\n /**\n * 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.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificatePassword?: string | null\n\n /**\n * 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).\n */\n readonly certificateSubjectName?: string | null\n\n /**\n * 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).\n */\n readonly certificateSha1?: string | null\n\n /**\n * The path to an additional certificate file you want to add to the signature block.\n */\n readonly additionalCertificateFile?: string | null\n\n /**\n * The URL of the RFC 3161 time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly rfc3161TimeStampServer?: string | null\n\n /**\n * The URL of the time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly timeStampServer?: string | null\n\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n * Defaults to common name from your code signing certificate.\n */\n readonly publisherName?: string | Array<string> | null\n}\n\n// https://learn.microsoft.com/en-us/azure/trusted-signing/how-to-signing-integrations\nexport interface WindowsAzureSigningConfiguration {\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n */\n readonly publisherName: string\n /**\n * The Trusted Signing Account endpoint. The URI value must have a URI that aligns to the\n * region your Trusted Signing Account and Certificate Profile you are specifying were created\n * in during the setup of these resources.\n *\n * Translates to field: Endpoint\n *\n * Requires one of environment variable configurations for authenticating to Microsoft Entra ID per [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition)\n */\n readonly endpoint: string\n /**\n * The Certificate Profile name. Translates to field: CertificateProfileName\n */\n readonly certificateProfileName: string\n /**\n * The Code Signing Signing Account name. Translates to field: CodeSigningAccountName\n */\n readonly codeSigningAccountName: string\n /**\n * The File Digest for signing each file. Translates to field: FileDigest\n * @default SHA256\n */\n readonly fileDigest?: string\n /**\n * The Timestamp rfc3161 server. Translates to field: TimestampRfc3161\n * @default http://timestamp.acs.microsoft.com\n */\n readonly timestampRfc3161?: string\n /**\n * The Timestamp Digest. Translates to field: TimestampDigest\n * @default SHA256\n */\n readonly timestampDigest?: string\n /**\n * Allow other CLI parameters (verbatim case-sensitive) to `Invoke-TrustedSigning`\n * Note: Key-Value pairs with `undefined`/`null` value are filtered out of the command.\n */\n [k: string]: string | Nullish\n}\n"]}
1
+ {"version":3,"file":"winOptions.js","sourceRoot":"","sources":["../../src/options/winOptions.ts"],"names":[],"mappings":"","sourcesContent":["import { Nullish } from \"builder-util-runtime\"\nimport { CustomWindowsSign } from \"../codeSign/windowsSignToolManager\"\nimport { PlatformSpecificBuildOptions, TargetConfigType } from \"../index\"\n\nexport interface WindowsConfiguration extends PlatformSpecificBuildOptions {\n /**\n * The target package type: list of `nsis`, `nsis-web` (Web installer), `portable` ([portable]https://www.electron.build/nsis#portable) app without installation), `appx`, `msi`, `msi-wrapped`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`.\n * AppX package can be built only on Windows 10.\n *\n * To use Squirrel.Windows please install `electron-builder-squirrel-windows` dependency.\n *\n * @default nsis\n */\n readonly target?: TargetConfigType\n\n /**\n * The path to application icon.\n * @default build/icon.ico\n */\n readonly icon?: string | null\n\n /**\n * The trademarks and registered trademarks.\n */\n readonly legalTrademarks?: string | null\n\n /**\n * Options for usage with signtool.exe\n * Cannot be used in conjunction with `azureSignOptions`, signing will default to Azure Trusted Signing\n */\n readonly signtoolOptions?: WindowsSigntoolConfiguration | null\n\n /**\n * Options for usage of Azure Trusted Signing service\n * Cannot be used in conjunction with `signtoolOptions`, signing will default to Azure Trusted Signing\n */\n readonly azureSignOptions?: WindowsAzureSigningConfiguration | null\n\n /**\n * Whether to verify the signature of an available update before installation.\n * The [publisher name](#publisherName) will be used for the signature verification.\n *\n * @default true\n */\n readonly verifyUpdateCodeSignature?: boolean\n\n /**\n * The [security level](https://msdn.microsoft.com/en-us/library/6ad1fshk.aspx#Anchor_9) at which the application requests to be executed.\n * Cannot be specified per target, allowed only in the `win`.\n * @default asInvoker\n */\n readonly requestedExecutionLevel?: RequestedExecutionLevel | null\n\n /**\n * Whether to sign and add metadata to executable via [`resedit`](https://www.npmjs.com/package/resedit).\n * Metadata includes information about the app name/description/version, publisher, copyright, etc.\n * This property also is responsible for adding the app icon and setting execution level.\n * Set to `false` only if you need to fully disable resedit-based resource editing.\n * To skip only code signing while keeping resource editing, use `signExecutable: false` instead.\n * @default true\n */\n readonly signAndEditExecutable?: boolean\n\n /**\n * Whether to sign Windows executables and any additional files matched by `signExts`.\n * Set to `false` to skip Windows code signing while still editing executable resources\n * (icon, metadata, etc. via [`resedit`](https://www.npmjs.com/package/resedit)).\n * This option is not limited to the main executable edit/sign flow and can also affect\n * signing of Windows installers or other artifacts that use the standard signing path.\n * @default true\n */\n readonly signExecutable?: boolean\n\n /**\n * Explicit file name/extensions (`str.endsWith`) to also sign. Advanced option.\n * Supports negative patterns, e.g. example that excludes `.appx` files: `[\"somefilename\", \".dll\", \"!.appx\"]`.\n * @see https://github.com/electron-userland/electron-builder/issues/7329\n * @default null\n */\n readonly signExts?: string[] | null\n}\n\nexport type RequestedExecutionLevel = \"asInvoker\" | \"highestAvailable\" | \"requireAdministrator\"\n\nexport interface WindowsSigntoolConfiguration {\n /**\n * The custom function (or path to file or module id) to sign Windows executables\n */\n readonly sign?: CustomWindowsSign | string | null\n\n /**\n * Array of signing algorithms used. For AppX/MSIX `sha256` is always used. `.msi` cannot be dual-signed,\n * so it is signed once, with `sha256` unless `sha1` is the only algorithm listed.\n * @default ['sha1', 'sha256']\n */\n readonly signingHashAlgorithms?: Array<\"sha1\" | \"sha256\"> | null\n\n /**\n * 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.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificateFile?: string | null\n\n /**\n * 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.\n * Please see [Code Signing](https://www.electron.build/code-signing).\n */\n readonly certificatePassword?: string | null\n\n /**\n * 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).\n */\n readonly certificateSubjectName?: string | null\n\n /**\n * 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).\n */\n readonly certificateSha1?: string | null\n\n /**\n * The path to an additional certificate file you want to add to the signature block.\n */\n readonly additionalCertificateFile?: string | null\n\n /**\n * The URL of the RFC 3161 time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly rfc3161TimeStampServer?: string | null\n\n /**\n * The URL of the time stamp server.\n * @default http://timestamp.digicert.com\n */\n readonly timeStampServer?: string | null\n\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n * Defaults to common name from your code signing certificate.\n */\n readonly publisherName?: string | Array<string> | null\n}\n\n// https://learn.microsoft.com/en-us/azure/trusted-signing/how-to-signing-integrations\nexport interface WindowsAzureSigningConfiguration {\n /**\n * [The publisher name](https://github.com/electron-userland/electron-builder/issues/1187#issuecomment-278972073), exactly as in your code signed certificate. Several names can be provided.\n */\n readonly publisherName: string\n /**\n * The Trusted Signing Account endpoint. The URI value must have a URI that aligns to the\n * region your Trusted Signing Account and Certificate Profile you are specifying were created\n * in during the setup of these resources.\n *\n * Translates to field: Endpoint\n *\n * Requires one of environment variable configurations for authenticating to Microsoft Entra ID per [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/api/azure.identity.environmentcredential?view=azure-dotnet#definition)\n */\n readonly endpoint: string\n /**\n * The Certificate Profile name. Translates to field: CertificateProfileName\n */\n readonly certificateProfileName: string\n /**\n * The Code Signing Signing Account name. Translates to field: CodeSigningAccountName\n */\n readonly codeSigningAccountName: string\n /**\n * The File Digest for signing each file. Translates to field: FileDigest\n * @default SHA256\n */\n readonly fileDigest?: string\n /**\n * The Timestamp rfc3161 server. Translates to field: TimestampRfc3161\n * @default http://timestamp.acs.microsoft.com\n */\n readonly timestampRfc3161?: string\n /**\n * The Timestamp Digest. Translates to field: TimestampDigest\n * @default SHA256\n */\n readonly timestampDigest?: string\n /**\n * Allow other CLI parameters (verbatim case-sensitive) to `Invoke-TrustedSigning`\n * Note: Key-Value pairs with `undefined`/`null` value are filtered out of the command.\n */\n [k: string]: string | Nullish\n}\n"]}
@@ -14,6 +14,12 @@ export interface ArchiveOptions {
14
14
  */
15
15
  isArchiveHeaderCompressed?: boolean;
16
16
  dictSize?: number;
17
+ /**
18
+ * 7z only: LZMA2 block size in MB. Without it, 7-Zip splits LZMA2 into independent blocks only when it compresses with
19
+ * several block threads, so the archive bytes depend on the build host's CPU count. A fixed size makes them identical
20
+ * on any host. Ignored when storing, and when `method` names another codec.
21
+ */
22
+ blockSize?: number;
17
23
  excluded?: Array<string> | null;
18
24
  method?: "Copy" | "LZMA" | "Deflate" | "DEFAULT";
19
25
  isRegularFile?: boolean;
@@ -99,14 +99,24 @@ function compute7zCompressArgs(format, options = {}) {
99
99
  args.push("-mfb=258", "-mpass=15");
100
100
  }
101
101
  }
102
- if (options.dictSize != null) {
102
+ const { blockSize } = options;
103
+ const is7z = format === "7z" || format.endsWith(".7z");
104
+ // -mx=0 with an explicit -m0=LZMA2 would compress instead of store, so the block size is only pinned when compressing
105
+ const pinBlockSize = is7z && typeof blockSize === "number" && !storeOnly && compressionLevel !== "0" && (options.method == null || options.method === "DEFAULT");
106
+ if (pinBlockSize) {
107
+ if (!Number.isInteger(blockSize) || blockSize <= 0) {
108
+ throw new Error(`blockSize must be a positive integer (MB), got ${blockSize}`);
109
+ }
110
+ args.push(`-m0=LZMA2${options.dictSize != null ? `:d=${options.dictSize}m` : ""}:c=${blockSize}m`);
111
+ }
112
+ else if (options.dictSize != null) {
103
113
  args.push(`-md=${options.dictSize}m`);
104
114
  }
105
115
  // Disable NTFS timestamps for reproducible archives
106
116
  if (!options.isRegularFile) {
107
117
  args.push("-mtc=off");
108
118
  }
109
- if (format === "7z" || format.endsWith(".7z")) {
119
+ if (is7z) {
110
120
  if (options.solid === false) {
111
121
  args.push("-ms=off");
112
122
  }
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA+BA,kBAiCC;AAmED,wDAEC;AAkBD,sDA2EC;AAID,0BAoGC;AA1UD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,sGAAsG;AACtG,qGAAqG;AACrG,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1G,SAAS,wBAAwB,CAAC,KAAa;IAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wEAAwE,KAAK,GAAG,CAAC,CAAA;IACnG,CAAC;AACH,CAAC;AAWD,gBAAgB;AACT,KAAK,UAAU,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAa;IAC3G,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACpE,MAAM,OAAO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AO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\n// Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). \"OFF\" disables the\n// branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these\n// case-insensitively, so the value is canonicalized to uppercase before use.\nconst ALLOWED_7Z_FILTERS = new Set([\"OFF\", \"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n\n /**\n * Paths, relative to the archived directory, to append as uncompressed (`Copy`) members instead of\n * compressing them with the rest of the archive. Differential updates diff the *compressed* archive\n * with a content-defined blockmap, and a large compressed member (an asar) diverges wholesale from\n * its previous version on any change — storing it keeps unchanged regions byte-identical between\n * builds, so the delta stays proportional to what actually changed. The stored members are excluded\n * from the main (compressed) pass and appended in a second 7za invocation with `-mx=0`; the\n * `ELECTRON_BUILDER_COMPRESSION_LEVEL` override deliberately does not apply to them (byte-stability\n * is the point), while `preserveSymlinks` and `isArchiveHeaderCompressed` are mirrored into the\n * append pass. Paths that do not exist are skipped. Not supported by the native-zip NFD fallback.\n */\n storedPaths?: Array<string> | null\n\n /**\n * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can\n * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at\n * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping\n * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`\n * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to\n * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which\n * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.\n * @default false\n */\n installTimeDecodable?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\n/**\n * Builds the exclude switches for the given masks, rejecting any pattern that contains a path\n * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).\n */\nfunction buildExcludeArgs(excluded: Array<string> | null | undefined, prefix: string): Array<string> {\n if (excluded == null) {\n return []\n }\n return excluded.map(mask => {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n return `${prefix}${mask}`\n })\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored\n // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ\n // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on\n // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy\n // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable\n // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.\n if (options.installTimeDecodable) {\n if (!storeOnly) {\n args.push(\"-mf=BCJ\")\n }\n } else {\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n const canonicalFilter = sevenZFilter.toUpperCase()\n if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${canonicalFilter}`)\n }\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n // Resolve storedPaths before the main pass so they can be excluded from it. Member names are\n // native-separator, relative to the 7za cwd (which differs with withoutDir), so the same string\n // works as both the exact `-x!` exclude mask and the append argument.\n const storedMembers: Array<string> = []\n for (const storedPath of options.storedPaths ?? []) {\n if (storedPath.includes(\"..\")) {\n throw new Error(`Stored archive path contains path traversal sequence: \"${storedPath}\"`)\n }\n if (await exists(path.join(dirToArchive, storedPath))) {\n storedMembers.push(path.normalize(options.withoutDir ? storedPath : path.join(path.basename(dirToArchive), storedPath)))\n }\n }\n if (storedMembers.length > 0 && !use7z) {\n throw new Error(\"storedPaths is not supported with the native zip fallback\")\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-xr!\"))\n // `-x!` (exact, non-recursive) so only the member itself is skipped, never a same-named sibling\n args.push(...storedMembers.map(member => `-x!${member}`))\n\n const cwd = options.withoutDir ? dirToArchive : path.dirname(dirToArchive)\n try {\n await exec(await getPath7za(), args, { cwd }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n\n if (storedMembers.length > 0) {\n // Second pass: append the stored members with no compression. -mx=0 unconditionally — the\n // compression-level env override must not reach these members (see storedPaths docs). The\n // main pass's symlink, timestamp, and header-compression flags are mirrored so the option\n // stays generic: the append rewrites the archive header and may itself store a symlink.\n const appendArgs = debug7zArgs(\"a\")\n appendArgs.push(\"-mx=0\")\n if (options.preserveSymlinks) {\n appendArgs.push(\"-snl\")\n }\n if (!options.isRegularFile) {\n appendArgs.push(\"-mtc=off\")\n }\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.isArchiveHeaderCompressed === false) {\n appendArgs.push(\"-mhc=off\")\n }\n appendArgs.push(\"-mtm=off\", \"-mta=off\")\n } else if (format === \"zip\") {\n appendArgs.push(\"-mm=Copy\", \"-mcu\")\n }\n appendArgs.push(outFile, ...storedMembers)\n await exec(await getPath7za(), appendArgs, { cwd }, debug7z.enabled)\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-x\"))\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/targets/archive.ts"],"names":[],"mappings":";;AA+BA,kBAiCC;AA2ED,wDAEC;AAkBD,sDAoFC;AAID,0BAoGC;AA3VD,+CAAqF;AACrF,uCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAG5B,kCAAoD;AACpD,6CAA2D;AAC3D,4CAA6C;AAE7C,sGAAsG;AACtG,qGAAqG;AACrG,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1G,SAAS,wBAAwB,CAAC,KAAa;IAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wEAAwE,KAAK,GAAG,CAAC,CAAA;IACnG,CAAC;AACH,CAAC;AAWD,gBAAgB;AACT,KAAK,UAAU,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAa;IAC3G,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACpE,MAAM,OAAO,GAA+B;QAC1C,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I,CAAC,CAAA;QAC5D,CAAC;QACD,MAAM,IAAA,6BAAc,EAAC,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACtD,MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,sBAAO,CAAC,OAAO,CAAC,CAAA;IACnH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAkB;IACrC,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7B,IAAI,sBAAO,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { debug7z, exec, exists, log, statOrNull, unlinkIfExists } from \"builder-util\"\nimport { move } from \"fs-extra\"\nimport * as path from \"path\"\nimport { create } from \"tar\"\nimport { TarOptionsWithAliasesAsync } from \"tar/dist/commonjs/options\"\nimport { TmpDir } from \"temp-file\"\nimport { CompressionLevel, Platform } from \"../core\"\nimport { getLinuxToolsMacToolset } from \"../toolsets/linux\"\nimport { getPath7za } from \"../toolsets/7zip\"\n\n// Values accepted by ELECTRON_BUILDER_7Z_FILTER (passed through as `-mf=<value>`). \"OFF\" disables the\n// branch/exec filter entirely (plain LZMA2); the rest are 7-Zip branch converters. 7za matches these\n// case-insensitively, so the value is canonicalized to uppercase before use.\nconst ALLOWED_7Z_FILTERS = new Set([\"OFF\", \"BCJ\", \"BCJ2\", \"ARM\", \"ARMT\", \"IA64\", \"PPC\", \"SPARC\", \"DELTA\"])\n\nfunction validateCompressionLevel(level: string): void {\n if (!/^[0-9]$/.test(level)) {\n throw new Error(`ELECTRON_BUILDER_COMPRESSION_LEVEL must be a single digit 0-9, got: \"${level}\"`)\n }\n}\n\ntype TarConfig = {\n compression: CompressionLevel | null | undefined\n format: string\n outFile: string\n dirToArchive: string\n isMacApp: boolean\n tempDirManager: TmpDir\n}\n\n/** @internal */\nexport async function tar({ compression, format, outFile, dirToArchive, isMacApp, tempDirManager }: TarConfig): Promise<void> {\n const tarFile = await tempDirManager.getTempFile({ suffix: \".tar\" })\n const tarArgs: TarOptionsWithAliasesAsync = {\n file: tarFile,\n portable: true,\n cwd: dirToArchive,\n prefix: path.basename(outFile, `.${format}`),\n }\n let tarDirectory = \".\"\n if (isMacApp) {\n delete tarArgs.prefix\n tarArgs.cwd = path.dirname(dirToArchive)\n tarDirectory = path.basename(dirToArchive)\n }\n\n await Promise.all([\n create(tarArgs, [tarDirectory]),\n // remove file before - 7z doesn't overwrite file, but update\n unlinkIfExists(outFile),\n ])\n\n if (format === \"tar.lz\") {\n const lzipPath = process.platform === \"darwin\" ? (await getLinuxToolsMacToolset()).lzip : \"lzip\"\n await exec(lzipPath, [compression === \"store\" ? \"-1\" : \"-9\", \"--keep\" /* keep (don't delete) input files */, tarFile])\n // lzip creates the output file in the same directory as the input with a .lz suffix\n await move(`${tarFile}.lz`, outFile)\n return\n }\n\n const compressFormat = format === \"tar.xz\" ? \"xz\" : format === \"tar.bz2\" ? \"bzip2\" : \"gzip\"\n const args = compute7zCompressArgs(compressFormat, { isRegularFile: true, method: \"DEFAULT\", compression })\n args.push(outFile, tarFile)\n await exec(await getPath7za(), args, { cwd: path.dirname(dirToArchive) }, debug7z.enabled)\n}\n\nexport interface ArchiveOptions {\n compression?: CompressionLevel | null\n\n /**\n * @default false\n */\n withoutDir?: boolean\n\n /**\n * @default true\n */\n solid?: boolean\n\n /**\n * @default true\n */\n isArchiveHeaderCompressed?: boolean\n\n dictSize?: number\n\n /**\n * 7z only: LZMA2 block size in MB. Without it, 7-Zip splits LZMA2 into independent blocks only when it compresses with\n * several block threads, so the archive bytes depend on the build host's CPU count. A fixed size makes them identical\n * on any host. Ignored when storing, and when `method` names another codec.\n */\n blockSize?: number\n\n excluded?: Array<string> | null\n\n // DEFAULT allows to disable custom logic and do not pass method switch at all\n method?: \"Copy\" | \"LZMA\" | \"Deflate\" | \"DEFAULT\"\n\n isRegularFile?: boolean\n\n /**\n * Preserve symlinks (e.g. macOS .framework `Versions/Current`) instead of dereferencing them.\n * Passes `-snl` to 7za — modern 7-Zip derefs by default, which breaks bundle codesigning. See #9846.\n * @default false\n */\n preserveSymlinks?: boolean\n\n /**\n * Paths, relative to the archived directory, to append as uncompressed (`Copy`) members instead of\n * compressing them with the rest of the archive. Differential updates diff the *compressed* archive\n * with a content-defined blockmap, and a large compressed member (an asar) diverges wholesale from\n * its previous version on any change — storing it keeps unchanged regions byte-identical between\n * builds, so the delta stays proportional to what actually changed. The stored members are excluded\n * from the main (compressed) pass and appended in a second 7za invocation with `-mx=0`; the\n * `ELECTRON_BUILDER_COMPRESSION_LEVEL` override deliberately does not apply to them (byte-stability\n * is the point), while `preserveSymlinks` and `isArchiveHeaderCompressed` are mirrored into the\n * append pass. Paths that do not exist are skipped. Not supported by the native-zip NFD fallback.\n */\n storedPaths?: Array<string> | null\n\n /**\n * Restrict the 7z filter to one the install-time extractor (the self-vendored Nsis7z plugin) can\n * decode. Modern 7za (24.09) auto-applies a CPU branch converter to executable content at\n * `-mx>=1` — `BCJ2` on x86/x64 and `ARM64` on arm64 — which that decoder silently skips, dropping\n * every executable from the install. When set, the archive is pinned to the single-stream `BCJ`\n * filter while compressing (decodable, and the best-ratio filter that decoder supports) and to\n * plain `Copy` while storing. Deliberately NOT overridable by `ELECTRON_BUILDER_7Z_FILTER`, which\n * could otherwise reintroduce an unreadable archive. Only affects the 7z format. See #9983.\n * @default false\n */\n installTimeDecodable?: boolean\n}\n\n/**\n * Whether archives for the given target platform should preserve symlinks (i.e. pass `-snl`).\n * Non-Windows targets preserve them: macOS `.framework` bundles need them for codesigning (#9846)\n * and Linux bundles may legitimately contain them. Windows dereferences because restoring symlinks\n * there requires elevated privileges. Keyed on the target platform, not the build host.\n */\nexport function shouldPreserveSymlinks(platform: Platform): boolean {\n return platform !== Platform.WINDOWS\n}\n\n/**\n * Builds the exclude switches for the given masks, rejecting any pattern that contains a path\n * traversal sequence. `prefix` is the tool-specific flag (`-xr!` for 7za, `-x` for native zip).\n */\nfunction buildExcludeArgs(excluded: Array<string> | null | undefined, prefix: string): Array<string> {\n if (excluded == null) {\n return []\n }\n return excluded.map(mask => {\n if (mask.includes(\"..\")) {\n throw new Error(`Excluded archive pattern contains path traversal sequence: \"${mask}\"`)\n }\n return `${prefix}${mask}`\n })\n}\n\nexport function compute7zCompressArgs(format: string, options: ArchiveOptions = {}) {\n let storeOnly = options.compression === \"store\"\n const args = debug7zArgs(\"a\")\n\n const compressionLevel = process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL\n if (compressionLevel != null) {\n validateCompressionLevel(compressionLevel)\n storeOnly = false // env var overrides \"store\" config\n args.push(`-mx=${compressionLevel}`)\n } else if (storeOnly) {\n // -mx=0 is the universal \"no compression\" flag across all formats (zip, 7z, gzip, xz, bzip2).\n // -mm=Copy would only be valid for zip/7z and causes E_INVALIDARG on xz/gzip/bzip2.\n args.push(\"-mx=0\")\n } else {\n const isZip = format === \"zip\"\n // ZIP uses level 7 by default; everything else (7z, gzip, xz, bzip2) uses level 9\n args.push(\"-mx=\" + (isZip && options.compression !== \"maximum\" ? \"7\" : \"9\"))\n if (isZip && options.compression === \"maximum\") {\n // http://superuser.com/a/742034\n args.push(\"-mfb=258\", \"-mpass=15\")\n }\n }\n\n const { blockSize } = options\n const is7z = format === \"7z\" || format.endsWith(\".7z\")\n // -mx=0 with an explicit -m0=LZMA2 would compress instead of store, so the block size is only pinned when compressing\n const pinBlockSize = is7z && typeof blockSize === \"number\" && !storeOnly && compressionLevel !== \"0\" && (options.method == null || options.method === \"DEFAULT\")\n if (pinBlockSize) {\n if (!Number.isInteger(blockSize) || blockSize <= 0) {\n throw new Error(`blockSize must be a positive integer (MB), got ${blockSize}`)\n }\n args.push(`-m0=LZMA2${options.dictSize != null ? `:d=${options.dictSize}m` : \"\"}:c=${blockSize}m`)\n } else if (options.dictSize != null) {\n args.push(`-md=${options.dictSize}m`)\n }\n\n // Disable NTFS timestamps for reproducible archives\n if (!options.isRegularFile) {\n args.push(\"-mtc=off\")\n }\n\n if (is7z) {\n if (options.solid === false) {\n args.push(\"-ms=off\")\n }\n\n if (options.isArchiveHeaderCompressed === false) {\n args.push(\"-mhc=off\")\n }\n\n // Branch/exec filter selection. installTimeDecodable archives are unpacked by the self-vendored\n // Nsis7z extractor, whose decoder only understands plain LZMA2/Copy and the single-stream BCJ\n // filter — not the CPU branch converters modern 7za auto-applies (BCJ2 on x86/x64, ARM64 on\n // arm64). So pin them to BCJ while compressing (the best filter that decoder can read; Copy\n // needs none) and do not honor ELECTRON_BUILDER_7Z_FILTER, which could reintroduce an unreadable\n // archive. Any other 7z archive may use ELECTRON_BUILDER_7Z_FILTER, else 7za's auto-selection.\n if (options.installTimeDecodable) {\n if (!storeOnly) {\n args.push(\"-mf=BCJ\")\n }\n } else {\n const sevenZFilter = process.env.ELECTRON_BUILDER_7Z_FILTER\n if (sevenZFilter) {\n const canonicalFilter = sevenZFilter.toUpperCase()\n if (!ALLOWED_7Z_FILTERS.has(canonicalFilter)) {\n throw new Error(`ELECTRON_BUILDER_7Z_FILTER must be one of: ${[...ALLOWED_7Z_FILTERS].join(\", \")}`)\n }\n args.push(`-mf=${canonicalFilter}`)\n }\n }\n\n args.push(\"-mtm=off\", \"-mta=off\")\n }\n\n if (options.method != null && options.method !== \"DEFAULT\") {\n args.push(`-mm=${options.method}`)\n } else if (format === \"zip\") {\n // -mm is only set explicitly for zip (Deflate/Copy) and includes the UTF-8 flag.\n // For all other formats the codec is implicit from the output file extension.\n args.push(`-mm=${storeOnly ? \"Copy\" : \"Deflate\"}`)\n args.push(\"-mcu\")\n }\n\n return args\n}\n\n// 7z is very fast, so, use ultra compression\n/** @internal */\nexport async function archive(format: string, outFile: string, dirToArchive: string, options: ArchiveOptions = {}): Promise<string> {\n const outFileStat = await statOrNull(outFile)\n const dirStat = await statOrNull(dirToArchive)\n if (outFileStat && dirStat && outFileStat.mtime > dirStat.mtime) {\n log.info({ reason: \"Archive file is up to date\", outFile }, `skipped archiving`)\n return outFile\n }\n\n // Use 7za for all formats (matches pre-26.15 behavior). Native macOS `zip` is only a\n // fallback for NFD-normalized filenames, which 7za mangles.\n let use7z = true\n if (process.platform === \"darwin\" && format === \"zip\" && dirToArchive.normalize(\"NFC\") !== dirToArchive) {\n log.warn({ reason: \"7z doesn't support NFD-normalized filenames\" }, `using zip`)\n use7z = false\n }\n\n // Resolve storedPaths before the main pass so they can be excluded from it. Member names are\n // native-separator, relative to the 7za cwd (which differs with withoutDir), so the same string\n // works as both the exact `-x!` exclude mask and the append argument.\n const storedMembers: Array<string> = []\n for (const storedPath of options.storedPaths ?? []) {\n if (storedPath.includes(\"..\")) {\n throw new Error(`Stored archive path contains path traversal sequence: \"${storedPath}\"`)\n }\n if (await exists(path.join(dirToArchive, storedPath))) {\n storedMembers.push(path.normalize(options.withoutDir ? storedPath : path.join(path.basename(dirToArchive), storedPath)))\n }\n }\n if (storedMembers.length > 0 && !use7z) {\n throw new Error(\"storedPaths is not supported with the native zip fallback\")\n }\n\n if (use7z) {\n const args = compute7zCompressArgs(format, options)\n // Modern 7-Zip (24.09) dereferences symlinks by default; the 7-Zip 16.02 bundled before\n // 26.15 stored them as links. Without -snl, a macOS .framework `Versions/Current` extracts\n // as a real directory → codesign \"bundle format is ambiguous\" → breaks Squirrel.Mac\n // auto-update (#9846). Callers enable it for all non-Windows targets (see ArchiveTarget).\n if (options.preserveSymlinks) {\n args.push(\"-snl\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-xr!\"))\n // `-x!` (exact, non-recursive) so only the member itself is skipped, never a same-named sibling\n args.push(...storedMembers.map(member => `-x!${member}`))\n\n const cwd = options.withoutDir ? dirToArchive : path.dirname(dirToArchive)\n try {\n await exec(await getPath7za(), args, { cwd }, debug7z.enabled)\n } catch (e: any) {\n if (e.code === \"ENOENT\" && !(await exists(dirToArchive))) {\n throw new Error(`Cannot create archive: \"${dirToArchive}\" doesn't exist`)\n } else {\n throw e\n }\n }\n\n if (storedMembers.length > 0) {\n // Second pass: append the stored members with no compression. -mx=0 unconditionally — the\n // compression-level env override must not reach these members (see storedPaths docs). The\n // main pass's symlink, timestamp, and header-compression flags are mirrored so the option\n // stays generic: the append rewrites the archive header and may itself store a symlink.\n const appendArgs = debug7zArgs(\"a\")\n appendArgs.push(\"-mx=0\")\n if (options.preserveSymlinks) {\n appendArgs.push(\"-snl\")\n }\n if (!options.isRegularFile) {\n appendArgs.push(\"-mtc=off\")\n }\n if (format === \"7z\" || format.endsWith(\".7z\")) {\n if (options.isArchiveHeaderCompressed === false) {\n appendArgs.push(\"-mhc=off\")\n }\n appendArgs.push(\"-mtm=off\", \"-mta=off\")\n } else if (format === \"zip\") {\n appendArgs.push(\"-mm=Copy\", \"-mcu\")\n }\n appendArgs.push(outFile, ...storedMembers)\n await exec(await getPath7za(), appendArgs, { cwd }, debug7z.enabled)\n }\n } else {\n // macOS native zip (NFD fallback): -y preserves symlinks\n const args = [\"-q\", \"-r\", \"-y\"]\n if (debug7z.enabled) {\n args.push(\"-v\")\n }\n if (options.compression === \"store\") {\n args.push(\"-0\")\n } else {\n args.push(options.compression === \"maximum\" ? \"-9\" : \"-7\")\n }\n await unlinkIfExists(outFile)\n args.push(outFile, options.withoutDir ? \".\" : path.basename(dirToArchive))\n args.push(...buildExcludeArgs(options.excluded, \"-x\"))\n await exec(\"zip\", args, { cwd: options.withoutDir ? dirToArchive : path.dirname(dirToArchive) }, debug7z.enabled)\n }\n\n return outFile\n}\n\nfunction debug7zArgs(command: \"a\" | \"x\"): Array<string> {\n const args = [command, \"-bd\"]\n if (debug7z.enabled) {\n args.push(\"-bb\")\n }\n return args\n}\n"]}
@@ -125,6 +125,10 @@ function configureDifferentialAwareArchiveOptions(archiveOptions) {
125
125
 
126
126
  */
127
127
  archiveOptions.dictSize = 1;
128
+ // At these settings 7-Zip splits LZMA2 into 4 MB blocks only with 4+ threads and writes one solid stream with fewer,
129
+ // where any change rewrites everything after it (measured: a 6.7 MB update became 74 MB on a 2-thread host).
130
+ // Pinning the size it picks with 4+ threads keeps the bytes identical on every host.
131
+ archiveOptions.blockSize = 4;
128
132
  // solid compression leads to a lot of changed blocks
129
133
  archiveOptions.solid = false;
130
134
  // do not allow to change compression level to avoid different packages
@@ -1 +1 @@
1
- {"version":3,"file":"differentialUpdateInfoBuilder.js","sourceRoot":"","sources":["../../src/targets/differentialUpdateInfoBuilder.ts"],"names":[],"mappings":";;;AAiCA,8DAyBC;AAwBD,8CAEC;AAED,kFAsBC;AAED,4FA4BC;AAED,wCAGC;AAED,wCAmBC;AApKD,+CAA0C;AAE1C,6BAA4B;AAI5B,kDAAwG;AACxG,4DAA0H;AAE7G,QAAA,qBAAqB,GAAG,WAAW,CAAA;AAEhD;;;;;;;;;;GAUG;AACU,QAAA,qBAAqB,GAAkB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AAExF;;;;;;;;GAQG;AACI,KAAK,UAAU,yBAAyB,CAAC,QAAgB,EAAE,WAA0B;;IAC1F,MAAM,OAAO,GAA0B,EAAE,CAAA;IACzC,oGAAoG;IACpG,sGAAsG;IACtG,uFAAuF;IACvF,MAAM,kBAAkB,GAAG,IAAI,GAAG,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CAAC,EAAE,YAAY,EAAE,kBAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAA;IAC5E,MAAM,UAAU,GAAG,MAAM,IAAA,wBAAa,EAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;IAC3E,MAAM,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC;QAC7C,IAAI,EAAE,YAAY;QAClB,gBAAgB,EAAE,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,gBAAgB,GAAG,6BAAqB,EAAE;QACjG,MAAM;QACN,IAAI,EAAE,IAAI;QACV,QAAQ;QACR,UAAU;KACX,CAAC,CAAA;IACF,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { exists, log } from \"builder-util\"\nimport { BlockMapDataHolder, PackageFileInfo } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { Target } from \"../core\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { ArchiveOptions } from \"./archive\"\nimport { BlockMapRegion, buildBlockMap, BuildBlockMapOptions, ChunkerParams } from \"./blockmap/blockmap\"\nimport { findPreparedVerbatimRange, prepareVerbatimNeedle, VerbatimNeedle, VerbatimRange } from \"./blockmap/verbatimRange\"\n\nexport const BLOCK_MAP_FILE_SUFFIX = \".blockmap\"\n\n/**\n * Chunker parameters for a stored (`Copy`) archive member — e.g. `resources/app.asar` when\n * `nsis.differentialPackage` is `\"store-asar\"` — whose bytes sit verbatim in the artifact. Such a member\n * changes in small, localized ways between releases, so it is chunked finer than the surrounding\n * compressed streams to keep the differential download proportional to the change.\n *\n * Set by benchmark (`test/src/differentialOneLineBenchTest.ts`, 32 MB asar / 3,001 files): 4/8/16 KiB\n * minimizes download bytes + new-blockmap bytes for a one-line edit (−5 % same-length, −17 % length-changing\n * vs. the 8/16/32 default); anything finer is a net loss because the v2 blockmap (~22 B per block, re-downloaded\n * in full on every update) grows faster than the block savings. `avg` must stay a power of two.\n */\nexport const STORED_MEMBER_CHUNKER: ChunkerParams = { min: 4096, avg: 8192, max: 16384 }\n\n/**\n * Locates each of `memberFiles` (absolute paths of files stored verbatim inside `artifact`) and returns\n * a `STORED_MEMBER_CHUNKER` blockmap region per located file, sorted by offset. The regions never\n * overlap: byte-identical members (a pure-JS app packaged for x64 + arm64 has the same asar twice in\n * the universal installer) are each matched to their own copy, and a copy already claimed by an\n * earlier member is skipped. A member file that does not exist, or that cannot be found verbatim, is\n * logged at warn and skipped — the blockmap then falls back to the default chunker for those bytes;\n * it never fails the build.\n */\nexport async function locateStoredMemberRegions(artifact: string, memberFiles: Array<string>): Promise<Array<BlockMapRegion>> {\n const regions: Array<BlockMapRegion> = []\n // Byte-identical members have identical occurrences, and the copies are claimed in ascending order,\n // so the scan for the next member with the same content resumes where its previous copy ended instead\n // of rescanning (and re-confirming every earlier copy) from the start of the artifact.\n const resumeOffsetByHash = new Map<string, number>()\n for (const memberFile of memberFiles) {\n if (!(await exists(memberFile))) {\n log.warn({ artifact: log.filePath(artifact), member: log.filePath(memberFile) }, \"stored member file does not exist; no block map region for it\")\n continue\n }\n const needle = await prepareVerbatimNeedle(memberFile)\n const range = await findUnclaimedVerbatimRange(artifact, needle, regions, resumeOffsetByHash.get(needle.hash) ?? 0)\n if (range == null) {\n log.warn(\n { artifact: log.filePath(artifact), member: log.filePath(memberFile) },\n \"stored member not found verbatim in artifact; its bytes will be chunked with the default block map parameters\"\n )\n continue\n }\n resumeOffsetByHash.set(needle.hash, range.offset + range.size)\n log.info({ artifact: log.filePath(artifact), member: log.filePath(memberFile), offset: range.offset, size: range.size }, \"located stored member region for block map\")\n regions.push({ ...range, chunker: STORED_MEMBER_CHUNKER })\n }\n return regions.sort((a, b) => a.offset - b.offset)\n}\n\n/**\n * The first occurrence of `needle` in `artifact` at or after `startOffset` that does not overlap a\n * range in `claimed`. An occurrence that overlaps a claimed range is another member's copy (or part of\n * one), so the scan resumes right after that range — every candidate start before its end would\n * overlap it too.\n */\nasync function findUnclaimedVerbatimRange(artifact: string, needle: VerbatimNeedle, claimed: Array<BlockMapRegion>, startOffset: number): Promise<VerbatimRange | null> {\n for (;;) {\n const range = await findPreparedVerbatimRange(artifact, needle, startOffset)\n if (range == null) {\n return null\n }\n const rangeEnd = range.offset + range.size\n const clash = claimed.find(it => range.offset < it.offset + it.size && it.offset < rangeEnd)\n if (clash == null) {\n return range\n }\n startOffset = clash.offset + clash.size\n }\n}\n\n/** `BuildBlockMapOptions` for `regions`, or `undefined` when there are none so the default chunker path is taken unchanged. */\nexport function toBlockMapOptions(regions: Array<BlockMapRegion>): BuildBlockMapOptions | undefined {\n return regions.length === 0 ? undefined : { regions }\n}\n\nexport function createNsisWebDifferentialUpdateInfo(artifactPath: string, packageFiles: { [arch: string]: PackageFileInfo }) {\n if (packageFiles == null) {\n return null\n }\n\n const keys = Object.keys(packageFiles)\n if (keys.length <= 0) {\n return null\n }\n\n const packages: { [arch: string]: PackageFileInfo } = {}\n for (const arch of keys) {\n const packageFileInfo = packageFiles[arch]\n const file = path.basename(packageFileInfo.path)\n packages[arch] = {\n ...packageFileInfo,\n path: file,\n // https://github.com/electron-userland/electron-builder/issues/2583\n file,\n } as any\n }\n return { packages }\n}\n\nexport function configureDifferentialAwareArchiveOptions(archiveOptions: ArchiveOptions): ArchiveOptions {\n /*\n * dict size 64 MB: Full: 33,744.88 KB, To download: 17,630.3 KB (52%)\n * dict size 16 MB: Full: 33,936.84 KB, To download: 16,175.9 KB (48%)\n * dict size 8 MB: Full: 34,187.59 KB, To download: 8,229.9 KB (24%)\n * dict size 4 MB: Full: 34,628.73 KB, To download: 3,782.97 KB (11%)\n\n as we can see, if file changed in one place, all block is invalidated (and update size approximately equals to dict size)\n\n 1 MB is used:\n\n 1MB:\n\n 2018/01/11 11:54:41:0045 File has 59 changed blocks\n 2018/01/11 11:54:41:0050 Full: 71,588.59 KB, To download: 1,243.39 KB (2%)\n\n 4MB:\n\n 2018/01/11 11:31:43:0440 Full: 70,303.55 KB, To download: 4,843.27 KB (7%)\n 2018/01/11 11:31:43:0435 File has 234 changed blocks\n\n */\n archiveOptions.dictSize = 1\n // solid compression leads to a lot of changed blocks\n archiveOptions.solid = false\n // do not allow to change compression level to avoid different packages\n archiveOptions.compression = \"normal\"\n return archiveOptions\n}\n\nexport async function appendBlockmap(file: string, options?: BuildBlockMapOptions): Promise<BlockMapDataHolder> {\n log.info({ file: log.filePath(file) }, \"building embedded block map\")\n return buildBlockMap(file, \"deflate\", undefined, options)\n}\n\nexport async function createBlockmap(\n file: string,\n target: Target,\n packager: PlatformPackager<any>,\n safeArtifactName: string | null,\n options?: BuildBlockMapOptions\n): Promise<BlockMapDataHolder> {\n const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`\n log.info({ blockMapFile: log.filePath(blockMapFile) }, \"building block map\")\n const updateInfo = await buildBlockMap(file, \"gzip\", blockMapFile, options)\n await packager.info.emitArtifactBuildCompleted({\n file: blockMapFile,\n safeArtifactName: safeArtifactName == null ? null : `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,\n target,\n arch: null,\n packager,\n updateInfo,\n })\n return updateInfo\n}\n"]}
1
+ {"version":3,"file":"differentialUpdateInfoBuilder.js","sourceRoot":"","sources":["../../src/targets/differentialUpdateInfoBuilder.ts"],"names":[],"mappings":";;;AAiCA,8DAyBC;AAwBD,8CAEC;AAED,kFAsBC;AAED,4FAgCC;AAED,wCAGC;AAED,wCAmBC;AAxKD,+CAA0C;AAE1C,6BAA4B;AAI5B,kDAAwG;AACxG,4DAA0H;AAE7G,QAAA,qBAAqB,GAAG,WAAW,CAAA;AAEhD;;;;;;;;;;GAUG;AACU,QAAA,qBAAqB,GAAkB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AAExF;;;;;;;;GAQG;AACI,KAAK,UAAU,yBAAyB,CAAC,QAAgB,EAAE,WAA0B;;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AO,CAAC,CAAA;AAC3D,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,IAAY,EACZ,MAAc,EACd,QAA+B,EAC/B,gBAA+B,EAC/B,OAA8B;IAE9B,MAAM,YAAY,GAAG,GAAG,IAAI,GAAG,6BAAqB,EAAE,CAAA;IACtD,kBAAG,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,kBAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAA;IAC5E,MAAM,UAAU,GAAG,MAAM,IAAA,wBAAa,EAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;IAC3E,MAAM,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC;QAC7C,IAAI,EAAE,YAAY;QAClB,gBAAgB,EAAE,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,gBAAgB,GAAG,6BAAqB,EAAE;QACjG,MAAM;QACN,IAAI,EAAE,IAAI;QACV,QAAQ;QACR,UAAU;KACX,CAAC,CAAA;IACF,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { exists, log } from \"builder-util\"\nimport { BlockMapDataHolder, PackageFileInfo } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { Target } from \"../core\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { ArchiveOptions } from \"./archive\"\nimport { BlockMapRegion, buildBlockMap, BuildBlockMapOptions, ChunkerParams } from \"./blockmap/blockmap\"\nimport { findPreparedVerbatimRange, prepareVerbatimNeedle, VerbatimNeedle, VerbatimRange } from \"./blockmap/verbatimRange\"\n\nexport const BLOCK_MAP_FILE_SUFFIX = \".blockmap\"\n\n/**\n * Chunker parameters for a stored (`Copy`) archive member — e.g. `resources/app.asar` when\n * `nsis.differentialPackage` is `\"store-asar\"` — whose bytes sit verbatim in the artifact. Such a member\n * changes in small, localized ways between releases, so it is chunked finer than the surrounding\n * compressed streams to keep the differential download proportional to the change.\n *\n * Set by benchmark (`test/src/differentialOneLineBenchTest.ts`, 32 MB asar / 3,001 files): 4/8/16 KiB\n * minimizes download bytes + new-blockmap bytes for a one-line edit (−5 % same-length, −17 % length-changing\n * vs. the 8/16/32 default); anything finer is a net loss because the v2 blockmap (~22 B per block, re-downloaded\n * in full on every update) grows faster than the block savings. `avg` must stay a power of two.\n */\nexport const STORED_MEMBER_CHUNKER: ChunkerParams = { min: 4096, avg: 8192, max: 16384 }\n\n/**\n * Locates each of `memberFiles` (absolute paths of files stored verbatim inside `artifact`) and returns\n * a `STORED_MEMBER_CHUNKER` blockmap region per located file, sorted by offset. The regions never\n * overlap: byte-identical members (a pure-JS app packaged for x64 + arm64 has the same asar twice in\n * the universal installer) are each matched to their own copy, and a copy already claimed by an\n * earlier member is skipped. A member file that does not exist, or that cannot be found verbatim, is\n * logged at warn and skipped — the blockmap then falls back to the default chunker for those bytes;\n * it never fails the build.\n */\nexport async function locateStoredMemberRegions(artifact: string, memberFiles: Array<string>): Promise<Array<BlockMapRegion>> {\n const regions: Array<BlockMapRegion> = []\n // Byte-identical members have identical occurrences, and the copies are claimed in ascending order,\n // so the scan for the next member with the same content resumes where its previous copy ended instead\n // of rescanning (and re-confirming every earlier copy) from the start of the artifact.\n const resumeOffsetByHash = new Map<string, number>()\n for (const memberFile of memberFiles) {\n if (!(await exists(memberFile))) {\n log.warn({ artifact: log.filePath(artifact), member: log.filePath(memberFile) }, \"stored member file does not exist; no block map region for it\")\n continue\n }\n const needle = await prepareVerbatimNeedle(memberFile)\n const range = await findUnclaimedVerbatimRange(artifact, needle, regions, resumeOffsetByHash.get(needle.hash) ?? 0)\n if (range == null) {\n log.warn(\n { artifact: log.filePath(artifact), member: log.filePath(memberFile) },\n \"stored member not found verbatim in artifact; its bytes will be chunked with the default block map parameters\"\n )\n continue\n }\n resumeOffsetByHash.set(needle.hash, range.offset + range.size)\n log.info({ artifact: log.filePath(artifact), member: log.filePath(memberFile), offset: range.offset, size: range.size }, \"located stored member region for block map\")\n regions.push({ ...range, chunker: STORED_MEMBER_CHUNKER })\n }\n return regions.sort((a, b) => a.offset - b.offset)\n}\n\n/**\n * The first occurrence of `needle` in `artifact` at or after `startOffset` that does not overlap a\n * range in `claimed`. An occurrence that overlaps a claimed range is another member's copy (or part of\n * one), so the scan resumes right after that range — every candidate start before its end would\n * overlap it too.\n */\nasync function findUnclaimedVerbatimRange(artifact: string, needle: VerbatimNeedle, claimed: Array<BlockMapRegion>, startOffset: number): Promise<VerbatimRange | null> {\n for (;;) {\n const range = await findPreparedVerbatimRange(artifact, needle, startOffset)\n if (range == null) {\n return null\n }\n const rangeEnd = range.offset + range.size\n const clash = claimed.find(it => range.offset < it.offset + it.size && it.offset < rangeEnd)\n if (clash == null) {\n return range\n }\n startOffset = clash.offset + clash.size\n }\n}\n\n/** `BuildBlockMapOptions` for `regions`, or `undefined` when there are none so the default chunker path is taken unchanged. */\nexport function toBlockMapOptions(regions: Array<BlockMapRegion>): BuildBlockMapOptions | undefined {\n return regions.length === 0 ? undefined : { regions }\n}\n\nexport function createNsisWebDifferentialUpdateInfo(artifactPath: string, packageFiles: { [arch: string]: PackageFileInfo }) {\n if (packageFiles == null) {\n return null\n }\n\n const keys = Object.keys(packageFiles)\n if (keys.length <= 0) {\n return null\n }\n\n const packages: { [arch: string]: PackageFileInfo } = {}\n for (const arch of keys) {\n const packageFileInfo = packageFiles[arch]\n const file = path.basename(packageFileInfo.path)\n packages[arch] = {\n ...packageFileInfo,\n path: file,\n // https://github.com/electron-userland/electron-builder/issues/2583\n file,\n } as any\n }\n return { packages }\n}\n\nexport function configureDifferentialAwareArchiveOptions(archiveOptions: ArchiveOptions): ArchiveOptions {\n /*\n * dict size 64 MB: Full: 33,744.88 KB, To download: 17,630.3 KB (52%)\n * dict size 16 MB: Full: 33,936.84 KB, To download: 16,175.9 KB (48%)\n * dict size 8 MB: Full: 34,187.59 KB, To download: 8,229.9 KB (24%)\n * dict size 4 MB: Full: 34,628.73 KB, To download: 3,782.97 KB (11%)\n\n as we can see, if file changed in one place, all block is invalidated (and update size approximately equals to dict size)\n\n 1 MB is used:\n\n 1MB:\n\n 2018/01/11 11:54:41:0045 File has 59 changed blocks\n 2018/01/11 11:54:41:0050 Full: 71,588.59 KB, To download: 1,243.39 KB (2%)\n\n 4MB:\n\n 2018/01/11 11:31:43:0440 Full: 70,303.55 KB, To download: 4,843.27 KB (7%)\n 2018/01/11 11:31:43:0435 File has 234 changed blocks\n\n */\n archiveOptions.dictSize = 1\n // At these settings 7-Zip splits LZMA2 into 4 MB blocks only with 4+ threads and writes one solid stream with fewer,\n // where any change rewrites everything after it (measured: a 6.7 MB update became 74 MB on a 2-thread host).\n // Pinning the size it picks with 4+ threads keeps the bytes identical on every host.\n archiveOptions.blockSize = 4\n // solid compression leads to a lot of changed blocks\n archiveOptions.solid = false\n // do not allow to change compression level to avoid different packages\n archiveOptions.compression = \"normal\"\n return archiveOptions\n}\n\nexport async function appendBlockmap(file: string, options?: BuildBlockMapOptions): Promise<BlockMapDataHolder> {\n log.info({ file: log.filePath(file) }, \"building embedded block map\")\n return buildBlockMap(file, \"deflate\", undefined, options)\n}\n\nexport async function createBlockmap(\n file: string,\n target: Target,\n packager: PlatformPackager<any>,\n safeArtifactName: string | null,\n options?: BuildBlockMapOptions\n): Promise<BlockMapDataHolder> {\n const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`\n log.info({ blockMapFile: log.filePath(blockMapFile) }, \"building block map\")\n const updateInfo = await buildBlockMap(file, \"gzip\", blockMapFile, options)\n await packager.info.emitArtifactBuildCompleted({\n file: blockMapFile,\n safeArtifactName: safeArtifactName == null ? null : `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,\n target,\n arch: null,\n packager,\n updateInfo,\n })\n return updateInfo\n}\n"]}
package/out/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "26.18.0";
1
+ export declare const PACKAGE_VERSION = "26.18.1";
package/out/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = "26.18.0";
4
+ exports.PACKAGE_VERSION = "26.18.1";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,SAAS,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"26.18.0\"\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,SAAS,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"26.18.1\"\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "app-builder-lib",
3
3
  "description": "electron-builder lib",
4
- "version": "26.18.0",
4
+ "version": "26.18.1",
5
5
  "main": "out/index.js",
6
6
  "files": [
7
7
  "out",
@@ -85,9 +85,9 @@
85
85
  "tiny-async-pool": "1.3.0",
86
86
  "unzipper": "^0.12.3",
87
87
  "which": "^5.0.0",
88
- "builder-util": "26.16.0",
89
- "builder-util-runtime": "9.7.0",
90
- "electron-publish": "26.18.0"
88
+ "electron-publish": "26.18.1",
89
+ "builder-util": "26.18.1",
90
+ "builder-util-runtime": "9.7.1"
91
91
  },
92
92
  "///": "babel in devDependencies for proton tests",
93
93
  "devDependencies": {
@@ -123,12 +123,12 @@
123
123
  "@types/unzipper": "^0.10.11",
124
124
  "@types/which": "^3.0.4",
125
125
  "toml": "^3.0.0",
126
- "dmg-builder": "26.18.0",
127
- "electron-builder-squirrel-windows": "26.18.0"
126
+ "dmg-builder": "26.18.1",
127
+ "electron-builder-squirrel-windows": "26.18.1"
128
128
  },
129
129
  "peerDependencies": {
130
- "dmg-builder": "26.18.0",
131
- "electron-builder-squirrel-windows": "26.18.0"
130
+ "dmg-builder": "26.18.1",
131
+ "electron-builder-squirrel-windows": "26.18.1"
132
132
  },
133
133
  "//": "electron-builder-squirrel-windows and dmg-builder added as dev dep for tests (as otherwise `require` doesn't work using Yarn 2)",
134
134
  "typings": "./out/index.d.ts"
package/scheme.json CHANGED
@@ -8904,7 +8904,7 @@
8904
8904
  }
8905
8905
  ],
8906
8906
  "default": "['sha1', 'sha256']",
8907
- "description": "Array of signing algorithms used. For AppX `sha256` is always used."
8907
+ "description": "Array of signing algorithms used. For AppX/MSIX `sha256` is always used. `.msi` cannot be dual-signed,\nso it is signed once, with `sha256` unless `sha1` is the only algorithm listed."
8908
8908
  },
8909
8909
  "timeStampServer": {
8910
8910
  "default": "http://timestamp.digicert.com",