app-builder-lib 27.0.0-alpha.12 → 27.0.0-alpha.13
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.
- package/dist/asar/asarUtil.js +1 -1
- package/dist/asar/asarUtil.js.map +1 -1
- package/dist/codeSign/certInfo.d.ts +4 -1
- package/dist/codeSign/certInfo.d.ts.map +1 -1
- package/dist/codeSign/certInfo.js +5 -3
- package/dist/codeSign/certInfo.js.map +1 -1
- package/dist/codeSign/forceCodeSigning.d.ts +22 -0
- package/dist/codeSign/forceCodeSigning.d.ts.map +1 -0
- package/dist/codeSign/forceCodeSigning.js +18 -0
- package/dist/codeSign/forceCodeSigning.js.map +1 -0
- package/dist/codeSign/mac/macCodeSign.d.ts +13 -1
- package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
- package/dist/codeSign/mac/macCodeSign.js +29 -2
- package/dist/codeSign/mac/macCodeSign.js.map +1 -1
- package/dist/codeSign/mac/macSignatureVerifier.d.ts +23 -0
- package/dist/codeSign/mac/macSignatureVerifier.d.ts.map +1 -0
- package/dist/codeSign/mac/macSignatureVerifier.js +96 -0
- package/dist/codeSign/mac/macSignatureVerifier.js.map +1 -0
- package/dist/codeSign/win/authenticodeSignature.d.ts +14 -2
- package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -1
- package/dist/codeSign/win/authenticodeSignature.js +78 -30
- package/dist/codeSign/win/authenticodeSignature.js.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.js +4 -3
- package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
- package/dist/codeSign/win/publisherName.d.ts +31 -0
- package/dist/codeSign/win/publisherName.d.ts.map +1 -0
- package/dist/codeSign/win/publisherName.js +78 -0
- package/dist/codeSign/win/publisherName.js.map +1 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts +16 -9
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.js +46 -35
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
- package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -1
- package/dist/codeSign/win/verifyUpdatePublisher.js +7 -4
- package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.js +24 -6
- package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
- package/dist/configuration.d.ts +46 -3
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/electron/mac/asarIntegrityDigest.js +2 -2
- package/dist/electron/mac/asarIntegrityDigest.js.map +1 -1
- package/dist/electron/mac/electronMacUtils.d.ts +3 -2
- package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
- package/dist/electron/mac/electronMacUtils.js +3 -2
- package/dist/electron/mac/electronMacUtils.js.map +1 -1
- package/dist/fileMatcher.d.ts.map +1 -1
- package/dist/fileMatcher.js +4 -2
- package/dist/fileMatcher.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +7 -2
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +6 -2
- package/dist/indexInternal.js.map +1 -1
- package/dist/linuxPackager.js +1 -1
- package/dist/linuxPackager.js.map +1 -1
- package/dist/macPackager.d.ts +26 -0
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +168 -12
- package/dist/macPackager.js.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.d.ts +15 -12
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/SquirrelWindowsOptions.d.ts +3 -0
- package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
- package/dist/options/SquirrelWindowsOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +7 -2
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +61 -15
- package/dist/options/winOptions.d.ts.map +1 -1
- package/dist/options/winOptions.js +20 -0
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +1 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +7 -2
- package/dist/packager.js.map +1 -1
- package/dist/platformPackager.d.ts +14 -5
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +44 -13
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +3 -0
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +50 -16
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/manifestUploadCheck.d.ts +10 -0
- package/dist/publish/manifestUploadCheck.d.ts.map +1 -0
- package/dist/publish/manifestUploadCheck.js +75 -0
- package/dist/publish/manifestUploadCheck.js.map +1 -0
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +51 -17
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/publish/updateManifestVerifier.d.ts +22 -0
- package/dist/publish/updateManifestVerifier.d.ts.map +1 -0
- package/dist/publish/updateManifestVerifier.js +65 -0
- package/dist/publish/updateManifestVerifier.js.map +1 -0
- package/dist/targets/ArchiveTarget.d.ts.map +1 -1
- package/dist/targets/ArchiveTarget.js +6 -2
- package/dist/targets/ArchiveTarget.js.map +1 -1
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +3 -3
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/linux/FlatpakTarget.js +5 -5
- package/dist/targets/linux/FlatpakTarget.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +10 -7
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.js +6 -1
- package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
- package/dist/targets/linux/appimage/appImageUtil.js +9 -9
- package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
- package/dist/targets/linux/flatpakBundle.d.ts.map +1 -1
- package/dist/targets/linux/flatpakBundle.js +25 -20
- package/dist/targets/linux/flatpakBundle.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +22 -6
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/linux/snap/snapPlugs.d.ts +2 -2
- package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapPlugs.js +1 -1
- package/dist/targets/linux/snap/snapPlugs.js.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.js +19 -17
- package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +15 -3
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +96 -13
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +7 -5
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +8 -2
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.d.ts +1 -1
- package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
- package/dist/toolsets/nsis.js +1 -1
- package/dist/toolsets/nsis.js.map +1 -1
- package/dist/toolsets/wine.d.ts +3 -0
- package/dist/toolsets/wine.d.ts.map +1 -1
- package/dist/toolsets/wine.js +14 -5
- package/dist/toolsets/wine.js.map +1 -1
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +9 -3
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/buildOutputVerifier.d.ts +40 -0
- package/dist/util/buildOutputVerifier.d.ts.map +1 -0
- package/dist/util/buildOutputVerifier.js +420 -0
- package/dist/util/buildOutputVerifier.js.map +1 -0
- package/dist/util/config/fileOptions.js +2 -2
- package/dist/util/config/fileOptions.js.map +1 -1
- package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
- package/dist/util/config/legacyConfigGuard.js +2 -2
- package/dist/util/config/legacyConfigGuard.js.map +1 -1
- package/dist/util/config/legacyOptions.d.ts +9 -2
- package/dist/util/config/legacyOptions.d.ts.map +1 -1
- package/dist/util/config/legacyOptions.js +8 -2
- package/dist/util/config/legacyOptions.js.map +1 -1
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +3 -1
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +3 -9
- package/dist/util/flags.js.map +1 -1
- package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
- package/dist/util/mac/macosIconComposer.js +6 -5
- package/dist/util/mac/macosIconComposer.js.map +1 -1
- package/dist/util/macroExpander.js +1 -1
- package/dist/util/macroExpander.js.map +1 -1
- package/dist/util/nativeBinaryVerifier.d.ts.map +1 -1
- package/dist/util/nativeBinaryVerifier.js +3 -1
- package/dist/util/nativeBinaryVerifier.js.map +1 -1
- package/dist/util/packageMetadata.js +1 -1
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/util/removedEnvVars.d.ts +2 -0
- package/dist/util/removedEnvVars.d.ts.map +1 -1
- package/dist/util/removedEnvVars.js +15 -1
- package/dist/util/removedEnvVars.js.map +1 -1
- package/dist/util/streamSpawnToFile.d.ts +3 -1
- package/dist/util/streamSpawnToFile.d.ts.map +1 -1
- package/dist/util/streamSpawnToFile.js +6 -2
- package/dist/util/streamSpawnToFile.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/vm/ParallelsVm.d.ts +10 -0
- package/dist/vm/ParallelsVm.d.ts.map +1 -1
- package/dist/vm/ParallelsVm.js +22 -8
- package/dist/vm/ParallelsVm.js.map +1 -1
- package/dist/vm/PwshVm.d.ts +0 -1
- package/dist/vm/PwshVm.d.ts.map +1 -1
- package/dist/vm/PwshVm.js +10 -15
- package/dist/vm/PwshVm.js.map +1 -1
- package/dist/vm/WineVm.d.ts.map +1 -1
- package/dist/vm/WineVm.js +4 -4
- package/dist/vm/WineVm.js.map +1 -1
- package/dist/vm/vm.d.ts +9 -3
- package/dist/vm/vm.d.ts.map +1 -1
- package/dist/vm/vm.js +40 -32
- package/dist/vm/vm.js.map +1 -1
- package/dist/winPackager.d.ts +16 -1
- package/dist/winPackager.d.ts.map +1 -1
- package/dist/winPackager.js +77 -19
- package/dist/winPackager.js.map +1 -1
- package/package.json +9 -9
- package/scheme.json +497 -23
- package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +14 -9
- package/dist/vm/MonoVm.d.ts +0 -9
- package/dist/vm/MonoVm.d.ts.map +0 -1
- package/dist/vm/MonoVm.js +0 -16
- package/dist/vm/MonoVm.js.map +0 -1
package/dist/asar/asarUtil.js
CHANGED
|
@@ -68,7 +68,7 @@ export function orderAsarStreams(streams, orderingLines) {
|
|
|
68
68
|
const missing = [...rank.keys()];
|
|
69
69
|
return { streams: [...directories, ...listed.map(it => it.stream), ...rest], listed: listed.length + missing.length, matched: listed.length, missing };
|
|
70
70
|
}
|
|
71
|
-
const ASAR_ORDERING_MIGRATION_URL = "https://www.electron.build/docs/migration/v27-
|
|
71
|
+
const ASAR_ORDERING_MIGRATION_URL = "https://www.electron.build/docs/migration/v27-build-changes#asar-ordering-is-now-applied";
|
|
72
72
|
/**
|
|
73
73
|
* Resolves `asar.ordering` like other build resources (build resources directory first, then the project directory),
|
|
74
74
|
* applies it to `streams` and announces the v27 behaviour change once per process.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asarUtil.js","sourceRoot":"","sources":["../../src/asar/asarUtil.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,yBAAyB,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAG5B,OAAO,EAAmB,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAA;AAEvB,gBAAgB;AAChB,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACvD,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA8B,EAC9B,aAA4B;IAE5B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAA;IACtC,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;QACpC,8FAA8F;QAC9F,IAA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CAAC,CAAC,CAAC,CAAC,CAAA;QACvB,CAAC,CAAC,CAAA;QAEF,IAAI,gBAA0D,CAAA;QAC9D,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC7B,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAA;YAE5B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAA;YAC1C,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE,CAAC;gBACjE,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;YAClC,CAAC;YAED,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBACzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;gBACvC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAA;gBAC5F,CAAC;gBACD,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;QAED,OAAO;YACL,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;YAChD,gBAAgB;SACjB,CAAA;IACH,CAAC;CACF","sourcesContent":["import type { AsarStreamType, AsarDirectory } from \"@electron/asar\"\nimport { Filter, FilterStats, InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { dynamicImport } from \"../util/dynamicImport.js\"\nimport fs from \"fs-extra\"\n\nimport * as path from \"path\"\nimport { AsarOptions } from \"../options/PlatformSpecificBuildOptions.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { ResolvedFileSet, getDestinationPath } from \"../util/appFileCopier.js\"\nimport { detectUnpackedDirs } from \"./unpackDetector.js\"\nimport { alignAsarContent } from \"./asarAlign.js\"\nimport { assertSourceFileInTrustedRoots, getTrustedSourceRoots } from \"../util/trustedSourceRoots.js\"\nimport { Readable } from \"stream\"\nconst { readlink } = fs\n\n/** @internal */\nexport function isPathInside(root: string, target: string): boolean {\n return target === root || target.startsWith(root + path.sep)\n}\n\n/**\n * Applies an asar ordering file (`asar.ordering`) to the stream list `@electron/asar` packs: directory entries move to\n * the front in their original relative order (they hold no data), the listed files follow in the order of the file,\n * then everything else in its original order. Lines use the same syntax `@electron/asar` accepts — a path relative to\n * the app root, optionally prefixed with `/` or with a `<anything>:` prefix (e.g. a load counter) — blank lines are\n * ignored and `\\` separators are accepted. Lines naming a directory are ignored; files listed but not present are\n * counted in `listed`, reported in `missing` and skipped.\n */\nexport function orderAsarStreams(\n streams: Array<AsarStreamType>,\n orderingLines: Array<string>\n): { streams: Array<AsarStreamType>; listed: number; matched: number; missing: Array<string> } {\n const rank = new Map<string, number>()\n for (const rawLine of orderingLines) {\n // ordering files written on Windows use `\\` — convert it so they match on macOS and Linux too\n let line = rawLine\n .slice(rawLine.lastIndexOf(\":\") + 1)\n .trim()\n .replace(/\\\\/g, \"/\")\n if (line.length === 0) {\n continue\n }\n if (line.startsWith(\"/\")) {\n line = line.slice(1)\n }\n // `path.normalize` keeps a trailing separator (\"src/\") that directory stream paths lack; a bare \"/\" is left alone\n const key = path.normalize(line).replace(/(?<=.)[/\\\\]+$/, \"\")\n if (!rank.has(key)) {\n rank.set(key, rank.size)\n }\n }\n if (rank.size === 0) {\n return { streams, listed: 0, matched: 0, missing: [] }\n }\n const directories: Array<AsarStreamType> = []\n const listed: Array<{ stream: AsarStreamType; rank: number }> = []\n const rest: Array<AsarStreamType> = []\n // entries are removed from `rank` as they are consumed, so what is left at the end is missing from the archive\n for (const stream of streams) {\n const key = path.normalize(stream.path)\n if (stream.type === \"directory\") {\n directories.push(stream)\n // a line naming a directory orders nothing (directories hold no data), so it is neither listed nor missing\n rank.delete(key)\n continue\n }\n const position = rank.get(key)\n if (position == null) {\n rest.push(stream)\n } else {\n rank.delete(key)\n listed.push({ stream, rank: position })\n }\n }\n listed.sort((a, b) => a.rank - b.rank)\n const missing = [...rank.keys()]\n return { streams: [...directories, ...listed.map(it => it.stream), ...rest], listed: listed.length + missing.length, matched: listed.length, missing }\n}\n\ntype AsarOrderingPackager = Pick<PlatformPackager<any>, \"getResource\" | \"buildResourcesDir\" | \"projectDir\">\n\nconst ASAR_ORDERING_MIGRATION_URL = \"https://www.electron.build/docs/migration/v27-breaking-changes#asar-ordering-is-now-applied\"\n\n/**\n * Resolves `asar.ordering` like other build resources (build resources directory first, then the project directory),\n * applies it to `streams` and announces the v27 behaviour change once per process.\n * @internal\n */\nexport async function applyAsarOrdering(packager: AsarOrderingPackager, ordering: string, streams: Array<AsarStreamType>): Promise<Array<AsarStreamType>> {\n const orderingFile = await resolveAsarOrderingFile(packager, ordering)\n const { streams: ordered, listed, matched, missing } = orderAsarStreams(streams, (await fs.readFile(orderingFile, \"utf8\")).split(/\\r?\\n/))\n const orderingPath = log.filePath(orderingFile)\n log\n .once(\"asar-ordering-applied\")\n .warn(\n { ordering: orderingPath },\n \"asar.ordering is now applied to app.asar (electron-builder v26 and earlier silently ignored it): the listed files are packed first, \" +\n \"ahead of the default dependencies-first layout, which can increase differential update download size. \" +\n `Remove the option to keep the default layout. See ${ASAR_ORDERING_MIGRATION_URL}`\n )\n log.once(\"asar-ordering\", packager).info({ ordering: orderingPath, matched: `${matched}/${listed}` }, \"applied asar ordering\")\n if (missing.length > 0) {\n log.debug({ ordering: orderingPath, missing: missing.length, first: missing.slice(0, 5).join(\", \") }, \"asar ordering lists files that are not in the archive\")\n }\n return ordered\n}\n\nasync function resolveAsarOrderingFile(packager: AsarOrderingPackager, ordering: string): Promise<string> {\n try {\n return (await packager.getResource(ordering))!\n } catch (e: any) {\n if (!(e instanceof InvalidConfigurationError)) {\n throw e\n }\n const candidates = [...new Set([path.resolve(packager.buildResourcesDir, ordering), path.resolve(packager.projectDir, ordering)])]\n throw new InvalidConfigurationError(\n `asar.ordering file \"${ordering}\" was not found at ${candidates.join(\" or \")} ` +\n \"(the path resolves relative to the build resources directory, then the project directory). \" +\n \"electron-builder v27 applies the ordering file to app.asar (v26 and earlier ignored the option), so it must exist; fix the path or remove the option to keep the default layout. \" +\n `See ${ASAR_ORDERING_MIGRATION_URL}`\n )\n }\n}\n\n/** @internal */\nexport async function withElectronAsarLogging<T>(task: () => Promise<T>): Promise<T> {\n // override logger temporarily to clean up console (electron/asar does some internal logging that blogs up the default electron-builder logs)\n const consoleLogger = console.log\n console.log = (...args) => {\n if (args[0] === \"Ordering file has 100% coverage.\") {\n return // no need to log, this means our ordering logic is working correctly\n }\n log.info({ args }, \"logging @electron/asar\")\n }\n try {\n return await task()\n } finally {\n console.log = consoleLogger\n }\n}\n\n/** @internal */\nexport class AsarPackager {\n private readonly outFile: string\n\n constructor(\n readonly packager: PlatformPackager<any>,\n private readonly config: {\n defaultDestination: string\n resourcePath: string\n options: AsarOptions\n unpackPattern: Filter | undefined\n }\n ) {\n this.outFile = path.join(config.resourcePath, `app.asar`)\n }\n\n async pack(fileSets: Array<ResolvedFileSet>) {\n const orderedFileSets = [\n // Write dependencies first to minimize offset changes to asar header\n ...fileSets.slice(1),\n\n // Finish with the app files that change most often\n fileSets[0],\n ].map(set => this.orderFileSet(set))\n\n let streams = await this.processFileSets(orderedFileSets)\n const ordering = this.config.options.ordering\n if (!isEmptyOrSpaces(ordering)) {\n streams = await applyAsarOrdering(this.packager, ordering, streams)\n }\n await this.executeElectronAsar(streams)\n\n const contentAlignment = this.config.options.contentAlignment\n if (contentAlignment != null && contentAlignment !== 0) {\n await alignAsarContent(this.outFile, contentAlignment)\n }\n }\n\n private async executeElectronAsar(streams: AsarStreamType[]) {\n await withElectronAsarLogging(async () => {\n const { createPackageFromStreams } = await dynamicImport<typeof import(\"@electron/asar\")>(\"@electron/asar\")\n await createPackageFromStreams(this.outFile, streams)\n })\n }\n\n private async processFileSets(fileSets: ResolvedFileSet[]): Promise<AsarStreamType[]> {\n const unpackedPaths = new Set<string>()\n if (this.config.options.smartUnpack !== false) {\n for (const fileSet of fileSets) {\n detectUnpackedDirs(fileSet, unpackedPaths)\n }\n }\n\n const resultsMap = new Map<string, AsarStreamType>()\n const streamOrdering: string[] = []\n const normalizedUnpackedPaths = Array.from(unpackedPaths).map(p => path.normalize(p))\n\n // Check whether a file or directory should be unpacked, using pre-normalized unpacked paths and early returns\n const isUnpacked = (dir: string, file?: string, stat?: FilterStats): boolean => {\n const normalizedDir = path.normalize(dir)\n\n // Check file pattern first (most specific)\n if (!isEmptyOrSpaces(file) && stat && this.config.unpackPattern?.(file, stat)) {\n return true\n }\n\n // Check if path is within any unpacked directory\n for (const unpackedPath of normalizedUnpackedPaths) {\n if (normalizedDir === unpackedPath || normalizedDir.startsWith(unpackedPath + path.sep)) {\n return true\n }\n }\n\n return false\n }\n\n // First pass: process all files in order, ensuring parent directories exist\n for (const fileSet of fileSets) {\n // Don't use Promise.all, we need to retain order of execution/iteration through the already-ordered fileset\n for (const [index, file] of fileSet.files.entries()) {\n const transformedData = fileSet.transformedFiles?.get(index)\n const stat = fileSet.metadata.get(file)!\n const destination = path.relative(this.config.defaultDestination, getDestinationPath(file, fileSet))\n\n // Ensure parent directories exist before processing file\n this.ensureParentDirectories(destination, resultsMap, streamOrdering)\n\n const result = await this.processFileOrSymlink({\n file,\n destination,\n fileSet,\n transformedData,\n stat,\n isUnpacked,\n })\n\n if (result && !resultsMap.has(result.path)) {\n resultsMap.set(result.path, result)\n streamOrdering.push(result.path)\n }\n }\n }\n\n // Second pass: propagate unpacked flag to parent directories\n for (const entry of resultsMap.values()) {\n if (entry.unpacked) {\n this.markParentDirectoriesAsUnpacked(entry.path, resultsMap, isUnpacked)\n }\n }\n\n // Build final results array maintaining processing order\n return streamOrdering.reduce<AsarStreamType[]>((streams, path) => {\n const stream = resultsMap.has(path) ? resultsMap.get(path) : null\n if (stream != null) {\n streams.push(stream)\n }\n return streams\n }, [])\n }\n\n private ensureParentDirectories(destination: string, resultsMap: Map<string, AsarStreamType>, streamOrdering: string[]): void {\n const parents: string[] = []\n let current = path.dirname(path.normalize(destination))\n\n // Collect all parent directories from deepest to root\n while (current !== \".\") {\n parents.unshift(current)\n current = path.dirname(current)\n }\n\n // Add parent directories in order (root to deepest)\n for (const parentPath of parents) {\n if (!resultsMap.has(parentPath)) {\n const dir: AsarDirectory = {\n type: \"directory\",\n path: parentPath,\n unpacked: false, // Updated in second pass if needed\n }\n resultsMap.set(parentPath, dir)\n streamOrdering.push(parentPath)\n }\n }\n }\n\n private markParentDirectoriesAsUnpacked(destination: string, resultsMap: Map<string, AsarStreamType>, isUnpacked: (path: string) => boolean): void {\n let current = path.dirname(path.normalize(destination))\n\n while (current !== \".\") {\n const entry = resultsMap.get(current)\n if (entry && isUnpacked(current)) {\n entry.unpacked = true\n }\n current = path.dirname(current)\n }\n }\n\n private async processFileOrSymlink(options: {\n file: string\n destination: string\n stat: fs.Stats\n fileSet: ResolvedFileSet\n transformedData: string | Buffer | undefined\n isUnpacked: (dir: string, file?: string, stat?: FilterStats) => boolean\n }): Promise<AsarStreamType> {\n const { isUnpacked, transformedData, file, destination, stat } = options\n const unpacked = isUnpacked(destination, file, stat)\n\n // Handle directories\n if (!stat.isFile() && !stat.isSymbolicLink()) {\n return { path: destination, unpacked, type: \"directory\" }\n }\n\n // verify that the file is not a direct link or symlinked to a file outside the workspace and the package-manager store,\n // before any content is used: the transformer (e.g. for a node_modules package.json) reads the file through its symlinks too\n await assertSourceFileInTrustedRoots(file, await getTrustedSourceRoots(this.packager), await this.packager.getExternalLinkPolicy())\n\n // Handle transformed data (pre-processed content)\n if (transformedData != null) {\n const size = Buffer.byteLength(transformedData)\n return {\n path: destination,\n streamGenerator: () =>\n new Readable({\n read() {\n this.push(transformedData)\n this.push(null)\n },\n }),\n unpacked,\n type: \"file\",\n stat: { mode: stat.mode, size },\n }\n }\n\n const baseConfig = {\n path: destination,\n streamGenerator: () => fs.createReadStream(file),\n unpacked,\n stat,\n }\n\n // Handle regular files\n if (!stat.isSymbolicLink()) {\n return { ...baseConfig, type: \"file\" }\n }\n\n // Handle symlinks - make relative to source location\n let link = await readlink(file)\n if (path.isAbsolute(link)) {\n link = path.relative(path.dirname(file), link)\n }\n\n return {\n ...baseConfig,\n type: \"link\",\n symlink: link,\n }\n }\n\n private orderFileSet(fileSet: ResolvedFileSet): ResolvedFileSet {\n const sortedFileEntries = Array.from(fileSet.files.entries())\n\n sortedFileEntries.sort(([, a], [, b]) => {\n if (a === b) {\n return 0\n }\n\n // Place addons last because their signature changes per build\n const isAAddon = a.endsWith(\".node\")\n const isBAddon = b.endsWith(\".node\")\n if (isAAddon && !isBAddon) {\n return 1\n }\n if (isBAddon && !isAAddon) {\n return -1\n }\n\n // Otherwise order by name\n return a < b ? -1 : 1\n })\n\n let transformedFiles: Map<number, string | Buffer> | undefined\n if (fileSet.transformedFiles) {\n transformedFiles = new Map()\n\n const indexMap = new Map<number, number>()\n for (const [newIndex, [oldIndex]] of sortedFileEntries.entries()) {\n indexMap.set(oldIndex, newIndex)\n }\n\n for (const [oldIndex, value] of fileSet.transformedFiles) {\n const newIndex = indexMap.get(oldIndex)\n if (newIndex === undefined) {\n throw new Error(`Internal error: ${fileSet.files[oldIndex]} was lost while ordering asar`)\n }\n transformedFiles.set(newIndex, value)\n }\n }\n\n return {\n src: fileSet.src,\n destination: fileSet.destination,\n metadata: fileSet.metadata,\n files: sortedFileEntries.map(([, file]) => file),\n transformedFiles,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"asarUtil.js","sourceRoot":"","sources":["../../src/asar/asarUtil.ts"],"names":[],"mappings":"A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E,CAAC;gBACjE,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;YAClC,CAAC;YAED,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBACzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;gBACvC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAA;gBAC5F,CAAC;gBACD,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;QAED,OAAO;YACL,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;YAChD,gBAAgB;SACjB,CAAA;IACH,CAAC;CACF","sourcesContent":["import type { AsarStreamType, AsarDirectory } from \"@electron/asar\"\nimport { Filter, FilterStats, InvalidConfigurationError, isEmptyOrSpaces, log } from \"builder-util\"\nimport { dynamicImport } from \"../util/dynamicImport.js\"\nimport fs from \"fs-extra\"\n\nimport * as path from \"path\"\nimport { AsarOptions } from \"../options/PlatformSpecificBuildOptions.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { ResolvedFileSet, getDestinationPath } from \"../util/appFileCopier.js\"\nimport { detectUnpackedDirs } from \"./unpackDetector.js\"\nimport { alignAsarContent } from \"./asarAlign.js\"\nimport { assertSourceFileInTrustedRoots, getTrustedSourceRoots } from \"../util/trustedSourceRoots.js\"\nimport { Readable } from \"stream\"\nconst { readlink } = fs\n\n/** @internal */\nexport function isPathInside(root: string, target: string): boolean {\n return target === root || target.startsWith(root + path.sep)\n}\n\n/**\n * Applies an asar ordering file (`asar.ordering`) to the stream list `@electron/asar` packs: directory entries move to\n * the front in their original relative order (they hold no data), the listed files follow in the order of the file,\n * then everything else in its original order. Lines use the same syntax `@electron/asar` accepts — a path relative to\n * the app root, optionally prefixed with `/` or with a `<anything>:` prefix (e.g. a load counter) — blank lines are\n * ignored and `\\` separators are accepted. Lines naming a directory are ignored; files listed but not present are\n * counted in `listed`, reported in `missing` and skipped.\n */\nexport function orderAsarStreams(\n streams: Array<AsarStreamType>,\n orderingLines: Array<string>\n): { streams: Array<AsarStreamType>; listed: number; matched: number; missing: Array<string> } {\n const rank = new Map<string, number>()\n for (const rawLine of orderingLines) {\n // ordering files written on Windows use `\\` — convert it so they match on macOS and Linux too\n let line = rawLine\n .slice(rawLine.lastIndexOf(\":\") + 1)\n .trim()\n .replace(/\\\\/g, \"/\")\n if (line.length === 0) {\n continue\n }\n if (line.startsWith(\"/\")) {\n line = line.slice(1)\n }\n // `path.normalize` keeps a trailing separator (\"src/\") that directory stream paths lack; a bare \"/\" is left alone\n const key = path.normalize(line).replace(/(?<=.)[/\\\\]+$/, \"\")\n if (!rank.has(key)) {\n rank.set(key, rank.size)\n }\n }\n if (rank.size === 0) {\n return { streams, listed: 0, matched: 0, missing: [] }\n }\n const directories: Array<AsarStreamType> = []\n const listed: Array<{ stream: AsarStreamType; rank: number }> = []\n const rest: Array<AsarStreamType> = []\n // entries are removed from `rank` as they are consumed, so what is left at the end is missing from the archive\n for (const stream of streams) {\n const key = path.normalize(stream.path)\n if (stream.type === \"directory\") {\n directories.push(stream)\n // a line naming a directory orders nothing (directories hold no data), so it is neither listed nor missing\n rank.delete(key)\n continue\n }\n const position = rank.get(key)\n if (position == null) {\n rest.push(stream)\n } else {\n rank.delete(key)\n listed.push({ stream, rank: position })\n }\n }\n listed.sort((a, b) => a.rank - b.rank)\n const missing = [...rank.keys()]\n return { streams: [...directories, ...listed.map(it => it.stream), ...rest], listed: listed.length + missing.length, matched: listed.length, missing }\n}\n\ntype AsarOrderingPackager = Pick<PlatformPackager<any>, \"getResource\" | \"buildResourcesDir\" | \"projectDir\">\n\nconst ASAR_ORDERING_MIGRATION_URL = \"https://www.electron.build/docs/migration/v27-build-changes#asar-ordering-is-now-applied\"\n\n/**\n * Resolves `asar.ordering` like other build resources (build resources directory first, then the project directory),\n * applies it to `streams` and announces the v27 behaviour change once per process.\n * @internal\n */\nexport async function applyAsarOrdering(packager: AsarOrderingPackager, ordering: string, streams: Array<AsarStreamType>): Promise<Array<AsarStreamType>> {\n const orderingFile = await resolveAsarOrderingFile(packager, ordering)\n const { streams: ordered, listed, matched, missing } = orderAsarStreams(streams, (await fs.readFile(orderingFile, \"utf8\")).split(/\\r?\\n/))\n const orderingPath = log.filePath(orderingFile)\n log\n .once(\"asar-ordering-applied\")\n .warn(\n { ordering: orderingPath },\n \"asar.ordering is now applied to app.asar (electron-builder v26 and earlier silently ignored it): the listed files are packed first, \" +\n \"ahead of the default dependencies-first layout, which can increase differential update download size. \" +\n `Remove the option to keep the default layout. See ${ASAR_ORDERING_MIGRATION_URL}`\n )\n log.once(\"asar-ordering\", packager).info({ ordering: orderingPath, matched: `${matched}/${listed}` }, \"applied asar ordering\")\n if (missing.length > 0) {\n log.debug({ ordering: orderingPath, missing: missing.length, first: missing.slice(0, 5).join(\", \") }, \"asar ordering lists files that are not in the archive\")\n }\n return ordered\n}\n\nasync function resolveAsarOrderingFile(packager: AsarOrderingPackager, ordering: string): Promise<string> {\n try {\n return (await packager.getResource(ordering))!\n } catch (e: any) {\n if (!(e instanceof InvalidConfigurationError)) {\n throw e\n }\n const candidates = [...new Set([path.resolve(packager.buildResourcesDir, ordering), path.resolve(packager.projectDir, ordering)])]\n throw new InvalidConfigurationError(\n `asar.ordering file \"${ordering}\" was not found at ${candidates.join(\" or \")} ` +\n \"(the path resolves relative to the build resources directory, then the project directory). \" +\n \"electron-builder v27 applies the ordering file to app.asar (v26 and earlier ignored the option), so it must exist; fix the path or remove the option to keep the default layout. \" +\n `See ${ASAR_ORDERING_MIGRATION_URL}`\n )\n }\n}\n\n/** @internal */\nexport async function withElectronAsarLogging<T>(task: () => Promise<T>): Promise<T> {\n // override logger temporarily to clean up console (electron/asar does some internal logging that blogs up the default electron-builder logs)\n const consoleLogger = console.log\n console.log = (...args) => {\n if (args[0] === \"Ordering file has 100% coverage.\") {\n return // no need to log, this means our ordering logic is working correctly\n }\n log.info({ args }, \"logging @electron/asar\")\n }\n try {\n return await task()\n } finally {\n console.log = consoleLogger\n }\n}\n\n/** @internal */\nexport class AsarPackager {\n private readonly outFile: string\n\n constructor(\n readonly packager: PlatformPackager<any>,\n private readonly config: {\n defaultDestination: string\n resourcePath: string\n options: AsarOptions\n unpackPattern: Filter | undefined\n }\n ) {\n this.outFile = path.join(config.resourcePath, `app.asar`)\n }\n\n async pack(fileSets: Array<ResolvedFileSet>) {\n const orderedFileSets = [\n // Write dependencies first to minimize offset changes to asar header\n ...fileSets.slice(1),\n\n // Finish with the app files that change most often\n fileSets[0],\n ].map(set => this.orderFileSet(set))\n\n let streams = await this.processFileSets(orderedFileSets)\n const ordering = this.config.options.ordering\n if (!isEmptyOrSpaces(ordering)) {\n streams = await applyAsarOrdering(this.packager, ordering, streams)\n }\n await this.executeElectronAsar(streams)\n\n const contentAlignment = this.config.options.contentAlignment\n if (contentAlignment != null && contentAlignment !== 0) {\n await alignAsarContent(this.outFile, contentAlignment)\n }\n }\n\n private async executeElectronAsar(streams: AsarStreamType[]) {\n await withElectronAsarLogging(async () => {\n const { createPackageFromStreams } = await dynamicImport<typeof import(\"@electron/asar\")>(\"@electron/asar\")\n await createPackageFromStreams(this.outFile, streams)\n })\n }\n\n private async processFileSets(fileSets: ResolvedFileSet[]): Promise<AsarStreamType[]> {\n const unpackedPaths = new Set<string>()\n if (this.config.options.smartUnpack !== false) {\n for (const fileSet of fileSets) {\n detectUnpackedDirs(fileSet, unpackedPaths)\n }\n }\n\n const resultsMap = new Map<string, AsarStreamType>()\n const streamOrdering: string[] = []\n const normalizedUnpackedPaths = Array.from(unpackedPaths).map(p => path.normalize(p))\n\n // Check whether a file or directory should be unpacked, using pre-normalized unpacked paths and early returns\n const isUnpacked = (dir: string, file?: string, stat?: FilterStats): boolean => {\n const normalizedDir = path.normalize(dir)\n\n // Check file pattern first (most specific)\n if (!isEmptyOrSpaces(file) && stat && this.config.unpackPattern?.(file, stat)) {\n return true\n }\n\n // Check if path is within any unpacked directory\n for (const unpackedPath of normalizedUnpackedPaths) {\n if (normalizedDir === unpackedPath || normalizedDir.startsWith(unpackedPath + path.sep)) {\n return true\n }\n }\n\n return false\n }\n\n // First pass: process all files in order, ensuring parent directories exist\n for (const fileSet of fileSets) {\n // Don't use Promise.all, we need to retain order of execution/iteration through the already-ordered fileset\n for (const [index, file] of fileSet.files.entries()) {\n const transformedData = fileSet.transformedFiles?.get(index)\n const stat = fileSet.metadata.get(file)!\n const destination = path.relative(this.config.defaultDestination, getDestinationPath(file, fileSet))\n\n // Ensure parent directories exist before processing file\n this.ensureParentDirectories(destination, resultsMap, streamOrdering)\n\n const result = await this.processFileOrSymlink({\n file,\n destination,\n fileSet,\n transformedData,\n stat,\n isUnpacked,\n })\n\n if (result && !resultsMap.has(result.path)) {\n resultsMap.set(result.path, result)\n streamOrdering.push(result.path)\n }\n }\n }\n\n // Second pass: propagate unpacked flag to parent directories\n for (const entry of resultsMap.values()) {\n if (entry.unpacked) {\n this.markParentDirectoriesAsUnpacked(entry.path, resultsMap, isUnpacked)\n }\n }\n\n // Build final results array maintaining processing order\n return streamOrdering.reduce<AsarStreamType[]>((streams, path) => {\n const stream = resultsMap.has(path) ? resultsMap.get(path) : null\n if (stream != null) {\n streams.push(stream)\n }\n return streams\n }, [])\n }\n\n private ensureParentDirectories(destination: string, resultsMap: Map<string, AsarStreamType>, streamOrdering: string[]): void {\n const parents: string[] = []\n let current = path.dirname(path.normalize(destination))\n\n // Collect all parent directories from deepest to root\n while (current !== \".\") {\n parents.unshift(current)\n current = path.dirname(current)\n }\n\n // Add parent directories in order (root to deepest)\n for (const parentPath of parents) {\n if (!resultsMap.has(parentPath)) {\n const dir: AsarDirectory = {\n type: \"directory\",\n path: parentPath,\n unpacked: false, // Updated in second pass if needed\n }\n resultsMap.set(parentPath, dir)\n streamOrdering.push(parentPath)\n }\n }\n }\n\n private markParentDirectoriesAsUnpacked(destination: string, resultsMap: Map<string, AsarStreamType>, isUnpacked: (path: string) => boolean): void {\n let current = path.dirname(path.normalize(destination))\n\n while (current !== \".\") {\n const entry = resultsMap.get(current)\n if (entry && isUnpacked(current)) {\n entry.unpacked = true\n }\n current = path.dirname(current)\n }\n }\n\n private async processFileOrSymlink(options: {\n file: string\n destination: string\n stat: fs.Stats\n fileSet: ResolvedFileSet\n transformedData: string | Buffer | undefined\n isUnpacked: (dir: string, file?: string, stat?: FilterStats) => boolean\n }): Promise<AsarStreamType> {\n const { isUnpacked, transformedData, file, destination, stat } = options\n const unpacked = isUnpacked(destination, file, stat)\n\n // Handle directories\n if (!stat.isFile() && !stat.isSymbolicLink()) {\n return { path: destination, unpacked, type: \"directory\" }\n }\n\n // verify that the file is not a direct link or symlinked to a file outside the workspace and the package-manager store,\n // before any content is used: the transformer (e.g. for a node_modules package.json) reads the file through its symlinks too\n await assertSourceFileInTrustedRoots(file, await getTrustedSourceRoots(this.packager), await this.packager.getExternalLinkPolicy())\n\n // Handle transformed data (pre-processed content)\n if (transformedData != null) {\n const size = Buffer.byteLength(transformedData)\n return {\n path: destination,\n streamGenerator: () =>\n new Readable({\n read() {\n this.push(transformedData)\n this.push(null)\n },\n }),\n unpacked,\n type: \"file\",\n stat: { mode: stat.mode, size },\n }\n }\n\n const baseConfig = {\n path: destination,\n streamGenerator: () => fs.createReadStream(file),\n unpacked,\n stat,\n }\n\n // Handle regular files\n if (!stat.isSymbolicLink()) {\n return { ...baseConfig, type: \"file\" }\n }\n\n // Handle symlinks - make relative to source location\n let link = await readlink(file)\n if (path.isAbsolute(link)) {\n link = path.relative(path.dirname(file), link)\n }\n\n return {\n ...baseConfig,\n type: \"link\",\n symlink: link,\n }\n }\n\n private orderFileSet(fileSet: ResolvedFileSet): ResolvedFileSet {\n const sortedFileEntries = Array.from(fileSet.files.entries())\n\n sortedFileEntries.sort(([, a], [, b]) => {\n if (a === b) {\n return 0\n }\n\n // Place addons last because their signature changes per build\n const isAAddon = a.endsWith(\".node\")\n const isBAddon = b.endsWith(\".node\")\n if (isAAddon && !isBAddon) {\n return 1\n }\n if (isBAddon && !isAAddon) {\n return -1\n }\n\n // Otherwise order by name\n return a < b ? -1 : 1\n })\n\n let transformedFiles: Map<number, string | Buffer> | undefined\n if (fileSet.transformedFiles) {\n transformedFiles = new Map()\n\n const indexMap = new Map<number, number>()\n for (const [newIndex, [oldIndex]] of sortedFileEntries.entries()) {\n indexMap.set(oldIndex, newIndex)\n }\n\n for (const [oldIndex, value] of fileSet.transformedFiles) {\n const newIndex = indexMap.get(oldIndex)\n if (newIndex === undefined) {\n throw new Error(`Internal error: ${fileSet.files[oldIndex]} was lost while ordering asar`)\n }\n transformedFiles.set(newIndex, value)\n }\n }\n\n return {\n src: fileSet.src,\n destination: fileSet.destination,\n metadata: fileSet.metadata,\n files: sortedFileEntries.map(([, file]) => file),\n transformedFiles,\n }\n }\n}\n"]}
|
|
@@ -28,7 +28,8 @@ declare function pkcs12PasswordToUtf16(password: string): Buffer;
|
|
|
28
28
|
* Mirrors the `certificate-info` subcommand of app-builder-bin.
|
|
29
29
|
* https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go
|
|
30
30
|
*
|
|
31
|
-
* Returns { commonName, bloodyMicrosoftSubjectDn } on success.
|
|
31
|
+
* Returns { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn } on success. `windowsSubjectDn` is the subject in the
|
|
32
|
+
* format Windows reports it (`X509Certificate2.Subject`), which electron-updater matches publisherName against.
|
|
32
33
|
*
|
|
33
34
|
* Known divergences from the Go binary:
|
|
34
35
|
* - No OpenSSL fallback when the pure PKCS#12 decoder fails for a non-password reason.
|
|
@@ -40,6 +41,7 @@ declare function pkcs12PasswordToUtf16(password: string): Buffer;
|
|
|
40
41
|
export declare function readCertInfo(file: string, password: string): Promise<{
|
|
41
42
|
commonName: string;
|
|
42
43
|
bloodyMicrosoftSubjectDn: string;
|
|
44
|
+
windowsSubjectDn: string;
|
|
43
45
|
}>;
|
|
44
46
|
/**
|
|
45
47
|
* Reads certificate info from a plain X.509 certificate file (.crt / .cer).
|
|
@@ -54,6 +56,7 @@ export declare function readCertInfo(file: string, password: string): Promise<{
|
|
|
54
56
|
export declare function readCertInfoFromX509(file: string): Promise<{
|
|
55
57
|
commonName: string;
|
|
56
58
|
bloodyMicrosoftSubjectDn: string;
|
|
59
|
+
windowsSubjectDn: string;
|
|
57
60
|
} | null>;
|
|
58
61
|
/**
|
|
59
62
|
* Internal functions exported exclusively for unit testing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certInfo.d.ts","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"certInfo.d.ts","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"AAyHA;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA0E3F;AAqBD;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAqElH;AAED;;;;GAIG;AACH,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASvD;AAyCD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC,CAuI9J;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAyC3J;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;CAKxB,CAAA"}
|
|
@@ -4,6 +4,7 @@ import * as pkijs from "pkijs";
|
|
|
4
4
|
import { Crypto as PeculiarCrypto } from "@peculiar/webcrypto";
|
|
5
5
|
import { log } from "builder-util";
|
|
6
6
|
import _fsExtra from "fs-extra";
|
|
7
|
+
import { formatWindowsSubjectDn } from "./win/authenticodeSignature.js";
|
|
7
8
|
const { readFile } = _fsExtra;
|
|
8
9
|
// OID for codeSigning extended key usage
|
|
9
10
|
const CODE_SIGNING_OID = "1.3.6.1.5.5.7.3.3";
|
|
@@ -317,7 +318,8 @@ function decryptLegacyPkcs12Pbe(algId, algParams, encContent, password) {
|
|
|
317
318
|
* Mirrors the `certificate-info` subcommand of app-builder-bin.
|
|
318
319
|
* https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go
|
|
319
320
|
*
|
|
320
|
-
* Returns { commonName, bloodyMicrosoftSubjectDn } on success.
|
|
321
|
+
* Returns { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn } on success. `windowsSubjectDn` is the subject in the
|
|
322
|
+
* format Windows reports it (`X509Certificate2.Subject`), which electron-updater matches publisherName against.
|
|
321
323
|
*
|
|
322
324
|
* Known divergences from the Go binary:
|
|
323
325
|
* - No OpenSSL fallback when the pure PKCS#12 decoder fails for a non-password reason.
|
|
@@ -444,7 +446,7 @@ export async function readCertInfo(file, password) {
|
|
|
444
446
|
return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`;
|
|
445
447
|
})
|
|
446
448
|
.join(",");
|
|
447
|
-
return { commonName, bloodyMicrosoftSubjectDn };
|
|
449
|
+
return { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn: formatWindowsSubjectDn(signingCert.subject) };
|
|
448
450
|
}
|
|
449
451
|
/**
|
|
450
452
|
* Reads certificate info from a plain X.509 certificate file (.crt / .cer).
|
|
@@ -493,7 +495,7 @@ export async function readCertInfoFromX509(file) {
|
|
|
493
495
|
return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`;
|
|
494
496
|
})
|
|
495
497
|
.join(",");
|
|
496
|
-
return { commonName, bloodyMicrosoftSubjectDn };
|
|
498
|
+
return { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn: formatWindowsSubjectDn(cert.subject) };
|
|
497
499
|
}
|
|
498
500
|
/**
|
|
499
501
|
* Internal functions exported exclusively for unit testing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certInfo.js","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAE9D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAA;AAE7B,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C,2CAA2C;AAC3C,MAAM,YAAY,GAAG,4BAA4B,CAAA;AAEjD,wDAAwD;AACx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YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC9H,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAA;IAC1E,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAExD,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc;SACzD,GAAG,CAAC,CAAC,CAAC,EAAE;QACP,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAA;QACvD,OAAO,GAAG,QAAQ,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;IACzE,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;IAEZ,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,qBAAqB;IACrB,aAAa;IACb,yBAAyB;CAC1B,CAAA","sourcesContent":["import { createDecipheriv, createHash } from \"crypto\"\nimport * as asn1js from \"asn1js\"\nimport * as pkijs from \"pkijs\"\nimport { Crypto as PeculiarCrypto } from \"@peculiar/webcrypto\"\n\nimport { log } from \"builder-util\"\nimport _fsExtra from \"fs-extra\"\nconst { readFile } = _fsExtra\n\n// OID for codeSigning extended key usage\nconst CODE_SIGNING_OID = \"1.3.6.1.5.5.7.3.3\"\n\n// OID for the PKCS#12 certificate bag type\nconst CERT_BAG_OID = \"1.2.840.113549.1.12.10.1.3\"\n\n// Maps certificate attribute OIDs to their short names.\n// Matches the attributeTypeNames map in the Go reference implementation exactly:\n// https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\nconst ATTRIBUTE_TYPE_NAMES: Record<string, string> = {\n \"2.5.4.6\": \"C\",\n \"2.5.4.10\": \"O\",\n \"2.5.4.11\": \"OU\",\n \"2.5.4.3\": \"CN\",\n \"2.5.4.5\": \"SERIALNUMBER\",\n \"2.5.4.7\": \"L\",\n \"2.5.4.8\": \"ST\",\n \"2.5.4.9\": \"STREET\",\n \"2.5.4.17\": \"POSTALCODE\",\n}\n\n// Characters that must be quoted in a DN value to match Go binary BloodyMsString output\nconst NEEDS_DN_ESCAPING = /[,+\"\\\\<>;]/\n\nfunction escapeDnValue(value: string): string {\n if (NEEDS_DN_ESCAPING.test(value)) {\n // Escape embedded double-quotes by doubling them, then wrap entire value in quotes\n return `\"${value.replace(/\"/g, '\"\"')}\"`\n }\n return value\n}\n\n// Set up the pkijs WebCrypto engine once. @peculiar/webcrypto supports legacy cipher suites\n// (RC2, 3DES) used by real-world CA-issued PFX files, unlike native Node.js WebCrypto.\nconst peculiarCrypto = new PeculiarCrypto()\npkijs.setEngine(\"peculiar\", new pkijs.CryptoEngine({ name: \"peculiar\", crypto: peculiarCrypto, subtle: peculiarCrypto.subtle }) as any)\n\nfunction toArrayBuffer(buf: Buffer): ArrayBuffer {\n const ab = new ArrayBuffer(buf.byteLength)\n new Uint8Array(ab).set(buf)\n return ab\n}\n\n// ── PKCS#12 legacy PBE support (RFC 7292 Appendix B) ───────────────────────\n//\n// pkijs's CryptoEngine.decryptEncryptedContentInfo only handles PBES2\n// (OID 1.2.840.113549.1.5.13). Many real-world PFX files use the older\n// pkcs-12PbeIds ciphers (SHA1+3DES, SHA1+2DES, SHA1+RC2-128, SHA1+RC2-40).\n// We implement 3DES/2DES using Node.js's built-in `crypto` module and RC2\n// with a pure-TypeScript RFC 2268 implementation — RC2 was moved to\n// OpenSSL 3's legacy provider (not loaded by default) and is unavailable\n// via `createDecipheriv` in Node.js 22+.\n\n// ── RFC 2268 RC2-CBC implementation ─────────────────────────────────────────\n\n/** Permutation table from RFC 2268. */\nconst RC2_PITABLE = Uint8Array.from([\n 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d, 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44,\n 0x8b, 0xfb, 0xa2, 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32, 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95,\n 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82, 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc, 0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4,\n 0xd1, 0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26, 0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57, 0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03, 0xf8, 0x11, 0xc7, 0xf6,\n 0x90, 0xef, 0x3e, 0xe7, 0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7, 0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7, 0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a, 0x96,\n 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74, 0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec, 0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc, 0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4,\n 0x70, 0x39, 0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a, 0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31, 0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae, 0x05, 0xdf, 0x29,\n 0x10, 0x67, 0x6c, 0xba, 0xc9, 0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c, 0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9, 0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0,\n 0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e, 0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad,\n])\n\n/** Rotation amounts for R[0], R[1], R[2], R[3] in each mix round. */\nconst RC2_ROT = [1, 2, 3, 5] as const\n\n/**\n * Expand a variable-length key to 64 sixteen-bit subkeys (RFC 2268 Section 2).\n * `effectiveBits` controls the effective key length for export-grade keys\n * (40 = RC2-40, 128 = RC2-128).\n */\nfunction rc2ExpandKey(key: Buffer, effectiveBits: number): number[] {\n // Guard: effectiveBits = 0 causes T8 = 0, making L[128-0] = L[128] an OOB\n // access on a 128-element Uint8Array (silently returns undefined, producing\n // a wrong key schedule). Values > 1024 exceed the RFC 2268 key schedule table.\n if (!Number.isInteger(effectiveBits) || effectiveBits < 1 || effectiveBits > 1024) {\n throw new Error(`rc2ExpandKey: effectiveBits must be an integer in [1, 1024], got ${effectiveBits}`)\n }\n const T = key.length\n const T8 = Math.ceil(effectiveBits / 8)\n // 0xff >> (effectiveBits & 7) gives 0xff for multiples-of-8 effective lengths\n // (no masking), and a smaller mask for non-multiples.\n const TM = 0xff >> (effectiveBits & 7)\n const L = new Uint8Array(128)\n for (let i = 0; i < T; i++) {\n L[i] = key[i]\n }\n for (let i = T; i < 128; i++) {\n L[i] = RC2_PITABLE[(L[i - 1] + L[i - T]) & 0xff]\n }\n L[128 - T8] = RC2_PITABLE[L[128 - T8] & TM]\n for (let i = 127 - T8; i >= 0; i--) {\n L[i] = RC2_PITABLE[L[i + 1] ^ L[i + T8]]\n }\n const K: number[] = new Array(64)\n for (let i = 0; i < 64; i++) {\n K[i] = L[2 * i] | (L[2 * i + 1] << 8)\n }\n return K\n}\n\n/** Rotate a 16-bit word right by `bits` positions. */\nfunction ror16(word: number, bits: number): number {\n return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff)\n}\n\n/**\n * Decrypt `data` using RC2-CBC with PKCS#7 padding removal (RFC 2268).\n *\n * Used for pbeWithSHAAnd40BitRC2CBC (OID 1.2.840.113549.1.12.1.6) and\n * pbeWithSHAAnd128BitRC2CBC (OID 1.2.840.113549.1.12.1.5).\n *\n * These OIDs are commonly used to encrypt certificate bags in PKCS#12\n * files produced by OpenSSL and Windows with default settings. Node.js 22+\n * (OpenSSL 3 default provider) does not support RC2 via `createDecipheriv`.\n */\nfunction rc2CbcDecrypt(key: Buffer, iv: Buffer, data: Buffer, effectiveBits: number): Buffer {\n // Guard: a non-multiple-of-8 ciphertext causes the last partial block to be\n // processed with `undefined` bytes. In JS, `undefined | (undefined << 8)`\n // produces NaN, and `NaN & 0xffff` produces 0 — so partial blocks silently\n // produce garbage output rather than throwing.\n if (data.length === 0 || data.length % 8 !== 0) {\n throw new Error(`rc2CbcDecrypt: ciphertext length ${data.length} is not a positive multiple of the 8-byte RC2 block size`)\n }\n if (iv.length !== 8) {\n throw new Error(`rc2CbcDecrypt: IV must be exactly 8 bytes, got ${iv.length}`)\n }\n const K = rc2ExpandKey(key, effectiveBits)\n const out = Buffer.alloc(data.length)\n const prev = Buffer.from(iv) // CBC running state; starts as the IV\n\n for (let offset = 0; offset < data.length; offset += 8) {\n const ct = data.subarray(offset, offset + 8)\n // Parse ciphertext block as four little-endian 16-bit words\n const R = [(ct[0] | (ct[1] << 8)) & 0xffff, (ct[2] | (ct[3] << 8)) & 0xffff, (ct[4] | (ct[5] << 8)) & 0xffff, (ct[6] | (ct[7] << 8)) & 0xffff]\n\n // Reverse the encryption round plan [5 mix, 1 mash, 6 mix, 1 mash, 5 mix].\n // For decryption j starts at 63 and decrements in each reverse-mix step.\n let j = 63\n\n const rMix = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = ror16(R[i], RC2_ROT[i])\n const r3 = R[(i + 3) % 4]\n R[i] = (R[i] - K[j] - (r3 & R[(i + 2) % 4]) - (~r3 & 0xffff & R[(i + 1) % 4])) & 0xffff\n j--\n }\n }\n\n const rMash = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = (R[i] - K[R[(i + 3) % 4] & 63]) & 0xffff\n }\n }\n\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 6; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n\n // XOR decrypted words with previous ciphertext block (CBC mode)\n for (let i = 0; i < 4; i++) {\n out[offset + i * 2] = (R[i] & 0xff) ^ prev[i * 2]\n out[offset + i * 2 + 1] = (R[i] >> 8) ^ prev[i * 2 + 1]\n }\n // Advance CBC state to current ciphertext block\n ct.copy(prev)\n }\n\n // Validate and strip PKCS#7 padding.\n // Without this guard, padLen = 0 silently returns the full buffer (no stripping)\n // and padLen > 8 causes Buffer.subarray(0, negative) → empty buffer, both\n // silently. A wrong key/IV produces decrypted bytes that fail this check.\n const padLen = out[out.length - 1]\n if (padLen < 1 || padLen > 8) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 pad byte 0x${padLen.toString(16).padStart(2, \"0\")} — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n for (let i = out.length - padLen; i < out.length; i++) {\n if (out[i] !== padLen) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 padding — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n }\n return out.subarray(0, out.length - padLen)\n}\n\n/** PKCS#12 legacy PBE OIDs (pkcs-12PbeIds) and their cipher parameters. */\nconst PKCS12_PBE_ALGOS: Record<string, { cipher: string; keyLen: number; ivLen: number; rc2Bits?: number }> = {\n \"1.2.840.113549.1.12.1.3\": { cipher: \"des-ede3-cbc\", keyLen: 24, ivLen: 8 }, // pbeWithSHAAnd3KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.4\": { cipher: \"des-ede-cbc\", keyLen: 16, ivLen: 8 }, // pbeWithSHAAnd2KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.5\": { cipher: \"rc2-cbc\", keyLen: 16, ivLen: 8, rc2Bits: 128 }, // pbeWithSHAAnd128BitRC2CBC\n \"1.2.840.113549.1.12.1.6\": { cipher: \"rc2-cbc\", keyLen: 5, ivLen: 8, rc2Bits: 40 }, // pbeWithSHAAnd40BitRC2CBC\n}\n\n/**\n * Maximum PKCS#12 PBE iteration count accepted.\n *\n * A maliciously crafted PFX can set iterations to Number.MAX_SAFE_INTEGER,\n * causing the SHA-1 loop to run for an arbitrary amount of time (DoS).\n * Real-world PFX files use 1 000–50 000 iterations; this cap is generous\n * enough to accommodate even unusually high-security certs while blocking\n * obviously hostile inputs.\n */\nconst MAX_PKCS12_PBE_ITERATIONS = 300_000\n\n/**\n * PKCS#12 key/IV derivation function from RFC 7292 Appendix B (SHA-1 variant).\n * id = 1 to derive a key, id = 2 to derive an IV.\n *\n * Throws if `iterations` is outside [1, MAX_PKCS12_PBE_ITERATIONS] to prevent\n * CPU exhaustion from a crafted PFX file.\n */\nfunction pkcs12PbeDeriveKey(password: Buffer, salt: Buffer, iterations: number, id: number, length: number): Buffer {\n if (!Number.isInteger(iterations) || iterations < 1 || iterations > MAX_PKCS12_PBE_ITERATIONS) {\n throw new Error(\n `PKCS#12 PBE iteration count ${iterations} is outside safe range [1, ${MAX_PKCS12_PBE_ITERATIONS}]; refusing to process — the file may be crafted to exhaust CPU`\n )\n }\n // A crafted PFX could supply a multi-megabyte salt, causing Buffer.alloc(sLen) inside\n // the KDF to allocate gigabytes (sLen = ceil(salt.length / 64) * 64).\n const MAX_SALT_BYTES = 4096\n if (salt.length > MAX_SALT_BYTES) {\n throw new Error(`PKCS#12 PBE salt length ${salt.length} exceeds the safe maximum of ${MAX_SALT_BYTES} bytes — the file may be crafted to exhaust memory`)\n }\n\n const u = 20 // SHA-1 output bytes\n const v = 64 // SHA-1 block bytes\n\n // Step 1: D = ID byte repeated v times\n const D = Buffer.alloc(v, id)\n\n // Step 2: S = salt bytes repeated to fill ceil(salt.length / v) * v bytes\n const sLen = salt.length > 0 ? Math.ceil(salt.length / v) * v : 0\n const S = Buffer.alloc(sLen)\n for (let i = 0; i < sLen; i++) {\n S[i] = salt[i % salt.length]\n }\n\n // Step 3: P = password bytes repeated to fill ceil(password.length / v) * v bytes\n const pLen = password.length > 0 ? Math.ceil(password.length / v) * v : 0\n const P = Buffer.alloc(pLen)\n for (let i = 0; i < pLen; i++) {\n P[i] = password[i % password.length]\n }\n\n // Step 4: I = S || P (mutable, updated in step 6C)\n const I = new Uint8Array(Buffer.concat([S, P]))\n\n const c = Math.ceil(length / u)\n const result = Buffer.alloc(c * u)\n\n for (let i = 0; i < c; i++) {\n // Step 6A: A_i = H^iterations(D || I)\n let Ai: Buffer = createHash(\"sha1\").update(D).update(Buffer.from(I)).digest()\n for (let j = 1; j < iterations; j++) {\n Ai = createHash(\"sha1\").update(Ai).digest()\n }\n Ai.copy(result, i * u)\n\n // Step 6B: B = A_i repeated to fill v bytes\n const B = new Uint8Array(v)\n for (let j = 0; j < v; j++) {\n B[j] = Ai[j % u]\n }\n\n // Step 6C: each v-byte block of I is incremented by (B + 1) mod 2^(v*8)\n const blockCount = Math.ceil(I.length / v)\n for (let j = 0; j < blockCount; j++) {\n let carry = 1\n for (let b = v - 1; b >= 0; b--) {\n const idx = j * v + b\n if (idx < I.length) {\n const sum = I[idx] + B[b] + carry\n I[idx] = sum & 0xff\n carry = sum >> 8\n }\n }\n }\n }\n\n return result.subarray(0, length)\n}\n\n/**\n * Encode a password as UTF-16 Big Endian with a null terminator, which is the\n * format required by PKCS#12 PBE key derivation (RFC 7292).\n * An empty string yields [0x00, 0x00] (just the null terminator).\n */\nfunction pkcs12PasswordToUtf16(password: string): Buffer {\n const buf = Buffer.alloc((password.length + 1) * 2)\n for (let i = 0; i < password.length; i++) {\n const code = password.charCodeAt(i)\n buf[i * 2] = (code >> 8) & 0xff\n buf[i * 2 + 1] = code & 0xff\n }\n // Last two bytes are already 0x00 0x00 (null terminator) from Buffer.alloc.\n return buf\n}\n\n/**\n * Decrypt PKCS#12 legacy PBE encrypted content using Node.js crypto.\n *\n * @param algId - OID from PKCS12_PBE_ALGOS\n * @param algParams - asn1js object for PKCS12PBEParams (SEQUENCE { OCTET STRING, INTEGER })\n * @param encContent - asn1js object for the encrypted content (Constructed or Primitive [0] IMPLICIT)\n * @param password - plain-text password string\n */\nfunction decryptLegacyPkcs12Pbe(algId: string, algParams: any, encContent: any, password: string): Buffer {\n const algo = PKCS12_PBE_ALGOS[algId]\n\n // PKCS12PBEParams ::= SEQUENCE { salt OCTET STRING, iterations INTEGER }\n const salt = Buffer.from(algParams.valueBlock.value[0].valueBlock.valueHexView)\n const iterations = Number(algParams.valueBlock.value[1].valueBlock.valueDec)\n\n const pwdBytes = pkcs12PasswordToUtf16(password)\n const key = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 1, algo.keyLen)\n const iv = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 2, algo.ivLen)\n\n // Extract raw encrypted bytes from the [0] IMPLICIT OCTET STRING.\n // The encryptedContent field can be a Constructed (fragmented) or Primitive tag.\n let encBytes: Buffer\n if (encContent.idBlock?.isConstructed) {\n encBytes = Buffer.concat((encContent.valueBlock.value as any[]).map((p: any) => Buffer.from(p.valueBlock.valueHexView)))\n } else {\n encBytes = Buffer.from(encContent.valueBlock.valueHexView)\n }\n\n if (algo.rc2Bits != null) {\n // RC2 is not available in Node.js 22+ via createDecipheriv (OpenSSL 3 moved\n // it to the legacy provider which is not loaded by default). Use our pure-TS\n // RFC 2268 implementation instead.\n return rc2CbcDecrypt(key, iv, encBytes, algo.rc2Bits)\n }\n\n const decipher = createDecipheriv(algo.cipher, key, iv)\n return Buffer.concat([decipher.update(encBytes), decipher.final()])\n}\n\n/**\n * Reads certificate info from a PKCS#12 (.pfx) file using pkijs (unobfuscated TypeScript).\n * Mirrors the `certificate-info` subcommand of app-builder-bin.\n * https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\n *\n * Returns { commonName, bloodyMicrosoftSubjectDn } on success.\n *\n * Known divergences from the Go binary:\n * - No OpenSSL fallback when the pure PKCS#12 decoder fails for a non-password reason.\n * - Unknown OIDs are rendered using the raw numeric OID as the type name (e.g. `2.5.4.100=value`); Go uses `OID=#hexbytes` when ASN.1 marshal succeeds.\n * - RDN ordering uses DER order; Go normalizes via pkix.Name.ToRDNSequence then reverses via\n * BloodyMsString. These coincide for pkijs-generated certs (CN-first DER) but may\n * differ for real CA-issued certs stored in traditional C-first DER order.\n */\nexport async function readCertInfo(file: string, password: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string }> {\n const pfxDer = await readFile(file)\n\n // asn1js requires a plain ArrayBuffer\n const pfxBuf = toArrayBuffer(pfxDer)\n let asn1: ReturnType<typeof asn1js.fromBER>\n try {\n asn1 = asn1js.fromBER(pfxBuf)\n if (asn1.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n } catch (err) {\n throw new Error(`PKCS#12 file \"${file}\" contains invalid ASN.1/DER data: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const pfx = new pkijs.PFX({ schema: asn1.result })\n const pwBuf = toArrayBuffer(Buffer.from(password, \"utf-8\"))\n\n // Step 1: Verify MAC (or signature) integrity and parse the AuthenticatedSafe container.\n // pkijs throws \"Integrity for the PKCS#12 data is broken!\" on wrong password.\n try {\n await pfx.parseInternalValues({ password: pwBuf, checkIntegrity: true })\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err)\n const lower = detail.toLowerCase()\n if (lower.includes(\"integrity\") || lower.includes(\"mac\") || lower.includes(\"password\") || lower.includes(\"pkcs#12\")) {\n throw new Error(`password incorrect for certificate file \"${file}\" — verify the password matches the PFX. pkijs detail: ${detail}`)\n }\n log.debug({ file, error: detail }, \"pkijs failed to decode PKCS#12; no OpenSSL fallback available in Node.js\")\n throw new Error(`Failed to decode PKCS#12 file \"${file}\" — the file may be corrupt, use an unsupported cipher, or require OpenSSL. pkijs detail: ${detail}`)\n }\n\n const authSafe = pfx.parsedValue?.authenticatedSafe\n if (authSafe == null) {\n throw new Error(`Failed to parse AuthenticatedSafe in PKCS#12 file \"${file}\"`)\n }\n\n // Step 2: Iterate over the authenticated-safe ContentInfos and extract all certificates.\n //\n // We do NOT call authSafe.parseInternalValues() because pkijs's CryptoEngine only handles\n // PBES2 (OID 1.2.840.113549.1.5.13) for EncryptedData. Real-world PFX files (including\n // CA-issued and electron-builder-generated certs) often use the older pkcs-12PbeIds ciphers\n // (e.g. pbeWithSHAAnd3KeyTripleDESCBC). We handle those with our own Node.js crypto path.\n const certs: pkijs.Certificate[] = []\n\n for (const ci of authSafe.safeContents) {\n let safeBER: ArrayBuffer\n\n if (ci.contentType === pkijs.id_ContentType_Data) {\n // Data: content is an OCTET STRING containing DER-encoded SafeContents.\n safeBER = (ci.content as asn1js.OctetString).getValue()\n } else if (ci.contentType === pkijs.id_ContentType_EncryptedData) {\n // EncryptedData: decrypt the SafeContents, routing by algorithm OID.\n const encData = new pkijs.EncryptedData({ schema: ci.content })\n const algId = encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId\n\n if (Object.prototype.hasOwnProperty.call(PKCS12_PBE_ALGOS, algId)) {\n // Legacy PKCS#12 PBE (pbeWithSHAAnd*) — use our RFC 7292 implementation.\n const decrypted = decryptLegacyPkcs12Pbe(\n algId,\n encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams,\n encData.encryptedContentInfo.encryptedContent,\n password\n )\n safeBER = toArrayBuffer(decrypted)\n } else {\n // PBES2 or other modern OID — delegate to the pkijs engine.\n safeBER = await encData.decrypt({ password: pwBuf })\n }\n } else {\n // EnvelopedData or other types — skip (not needed for cert extraction).\n continue\n }\n\n // Parse SafeContents and collect X.509 certificates from cert bags.\n const sc = pkijs.SafeContents.fromBER(safeBER)\n for (const bag of sc.safeBags) {\n if (bag.bagId === CERT_BAG_OID) {\n const certBag = bag.bagValue as pkijs.CertBag\n if (certBag.parsedValue instanceof pkijs.Certificate) {\n certs.push(certBag.parsedValue)\n }\n }\n }\n }\n\n if (certs.length === 0) {\n throw new Error(`No certificates found in PKCS#12 file \"${file}\" — the file may be a key-only PFX or be empty`)\n }\n\n // Find the certificate with the codeSigning Extended Key Usage.\n // pkijs auto-parses known extensions via ExtensionValueFactory (registered at module init).\n const signingCert = certs.find(cert => {\n const ekuExt = cert.extensions?.find(e => e.extnID === pkijs.id_ExtKeyUsage)\n if (ekuExt == null) {\n return false\n }\n if (ekuExt.parsedValue instanceof pkijs.ExtKeyUsage) {\n return ekuExt.parsedValue.keyPurposes.includes(CODE_SIGNING_OID)\n }\n // Fallback: manually parse the extension OctetString value.\n try {\n const inner = asn1js.fromBER(ekuExt.extnValue.valueBlock.valueHexView)\n if (inner.offset === -1) {\n return false\n }\n const eku = new pkijs.ExtKeyUsage({ schema: inner.result })\n return eku.keyPurposes.includes(CODE_SIGNING_OID)\n } catch {\n return false\n }\n })\n\n if (signingCert == null) {\n throw new Error(\n `No certificate with ExtKeyUsageCodeSigning found in \"${file}\" — ${certs.length} certificate(s) present but none have the codeSigning extended key usage. ` +\n `Ensure the PFX contains a code-signing certificate, not just a CA or TLS certificate.`\n )\n }\n\n const cnAttr = signingCert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n const commonName = String(cnAttr?.value.valueBlock.value ?? \"\")\n\n // Format DN as \"CN=X,O=X,...\" matching Go's BloodyMsString output.\n // Uses ATTRIBUTE_TYPE_NAMES to mirror Go's attributeTypeNames map exactly, so STREET,\n // POSTALCODE, and SERIALNUMBER (present in EV code-signing certs) are handled correctly.\n // Unknown OIDs fall back to the bare OID string as the type name.\n const bloodyMicrosoftSubjectDn = signingCert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn }\n}\n\n/**\n * Reads certificate info from a plain X.509 certificate file (.crt / .cer).\n * Accepts both PEM (base64 with -----BEGIN CERTIFICATE----- headers) and DER (raw binary) encoding.\n *\n * Unlike `readCertInfo`, this does not require a password and does not parse PKCS#12.\n * Used when HSM mode supplies a public-cert-only file alongside /csp + /kc or pkcs11Module.\n *\n * Returns `null` when the publisher name cannot be determined (e.g. no CN attribute), so\n * callers should fall back to requiring an explicit `publisherName` in that case.\n */\nexport async function readCertInfoFromX509(file: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string } | null> {\n const raw = await readFile(file)\n\n // Support PEM (ASCII armor) and DER (raw binary) encoding.\n let derBytes: Buffer\n const pemContent = raw.toString(\"ascii\")\n if (pemContent.includes(\"-----BEGIN CERTIFICATE-----\")) {\n const b64 = pemContent\n .replace(/-----BEGIN CERTIFICATE-----/g, \"\")\n .replace(/-----END CERTIFICATE-----/g, \"\")\n .replace(/\\s+/g, \"\")\n derBytes = Buffer.from(b64, \"base64\")\n } else {\n derBytes = raw\n }\n\n let cert: pkijs.Certificate\n try {\n const asn1Result = asn1js.fromBER(toArrayBuffer(derBytes))\n if (asn1Result.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n cert = new pkijs.Certificate({ schema: asn1Result.result })\n } catch (err) {\n throw new Error(`X.509 certificate file \"${file}\" could not be parsed: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const cnAttr = cert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n if (cnAttr == null) {\n return null\n }\n const commonName = String(cnAttr.value.valueBlock.value)\n\n const bloodyMicrosoftSubjectDn = cert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn }\n}\n\n/**\n * Internal functions exported exclusively for unit testing.\n * Not part of the public API — do not use outside of test files.\n */\nexport const _testingOnly = {\n pkcs12PbeDeriveKey,\n pkcs12PasswordToUtf16,\n rc2CbcDecrypt,\n MAX_PKCS12_PBE_ITERATIONS,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"certInfo.js","sourceRoot":"","sources":["../../src/codeSign/certInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACrD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAE9D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAA;AAE7B,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C,2CAA2C;AAC3C,MAAM,YAAY,GAAG,4BAA4B,CAAA;AAEjD,wDAAwD;AACxD,iFAAiF;AACjF,yEAAyE;AACzE,MAAM,oBAAoB,GAA2B;IACnD,SAAS,EAAE,GAAG;IACd,UAAU,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C,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC9H,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAA;IAC1E,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAExD,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc;SACzD,GAAG,CAAC,CAAC,CAAC,EAAE;QACP,MAAM,QAAQ,GAAG,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAA;QACvD,OAAO,GAAG,QAAQ,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;IACzE,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;IAEZ,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAA;AACzG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,qBAAqB;IACrB,aAAa;IACb,yBAAyB;CAC1B,CAAA","sourcesContent":["import { createDecipheriv, createHash } from \"crypto\"\nimport * as asn1js from \"asn1js\"\nimport * as pkijs from \"pkijs\"\nimport { Crypto as PeculiarCrypto } from \"@peculiar/webcrypto\"\n\nimport { log } from \"builder-util\"\nimport _fsExtra from \"fs-extra\"\nimport { formatWindowsSubjectDn } from \"./win/authenticodeSignature.js\"\nconst { readFile } = _fsExtra\n\n// OID for codeSigning extended key usage\nconst CODE_SIGNING_OID = \"1.3.6.1.5.5.7.3.3\"\n\n// OID for the PKCS#12 certificate bag type\nconst CERT_BAG_OID = \"1.2.840.113549.1.12.10.1.3\"\n\n// Maps certificate attribute OIDs to their short names.\n// Matches the attributeTypeNames map in the Go reference implementation exactly:\n// https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\nconst ATTRIBUTE_TYPE_NAMES: Record<string, string> = {\n \"2.5.4.6\": \"C\",\n \"2.5.4.10\": \"O\",\n \"2.5.4.11\": \"OU\",\n \"2.5.4.3\": \"CN\",\n \"2.5.4.5\": \"SERIALNUMBER\",\n \"2.5.4.7\": \"L\",\n \"2.5.4.8\": \"ST\",\n \"2.5.4.9\": \"STREET\",\n \"2.5.4.17\": \"POSTALCODE\",\n}\n\n// Characters that must be quoted in a DN value to match Go binary BloodyMsString output\nconst NEEDS_DN_ESCAPING = /[,+\"\\\\<>;]/\n\nfunction escapeDnValue(value: string): string {\n if (NEEDS_DN_ESCAPING.test(value)) {\n // Escape embedded double-quotes by doubling them, then wrap entire value in quotes\n return `\"${value.replace(/\"/g, '\"\"')}\"`\n }\n return value\n}\n\n// Set up the pkijs WebCrypto engine once. @peculiar/webcrypto supports legacy cipher suites\n// (RC2, 3DES) used by real-world CA-issued PFX files, unlike native Node.js WebCrypto.\nconst peculiarCrypto = new PeculiarCrypto()\npkijs.setEngine(\"peculiar\", new pkijs.CryptoEngine({ name: \"peculiar\", crypto: peculiarCrypto, subtle: peculiarCrypto.subtle }) as any)\n\nfunction toArrayBuffer(buf: Buffer): ArrayBuffer {\n const ab = new ArrayBuffer(buf.byteLength)\n new Uint8Array(ab).set(buf)\n return ab\n}\n\n// ── PKCS#12 legacy PBE support (RFC 7292 Appendix B) ───────────────────────\n//\n// pkijs's CryptoEngine.decryptEncryptedContentInfo only handles PBES2\n// (OID 1.2.840.113549.1.5.13). Many real-world PFX files use the older\n// pkcs-12PbeIds ciphers (SHA1+3DES, SHA1+2DES, SHA1+RC2-128, SHA1+RC2-40).\n// We implement 3DES/2DES using Node.js's built-in `crypto` module and RC2\n// with a pure-TypeScript RFC 2268 implementation — RC2 was moved to\n// OpenSSL 3's legacy provider (not loaded by default) and is unavailable\n// via `createDecipheriv` in Node.js 22+.\n\n// ── RFC 2268 RC2-CBC implementation ─────────────────────────────────────────\n\n/** Permutation table from RFC 2268. */\nconst RC2_PITABLE = Uint8Array.from([\n 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d, 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44,\n 0x8b, 0xfb, 0xa2, 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32, 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95,\n 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82, 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc, 0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4,\n 0xd1, 0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26, 0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57, 0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03, 0xf8, 0x11, 0xc7, 0xf6,\n 0x90, 0xef, 0x3e, 0xe7, 0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7, 0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7, 0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a, 0x96,\n 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74, 0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec, 0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc, 0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4,\n 0x70, 0x39, 0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a, 0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31, 0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae, 0x05, 0xdf, 0x29,\n 0x10, 0x67, 0x6c, 0xba, 0xc9, 0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c, 0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9, 0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0,\n 0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e, 0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad,\n])\n\n/** Rotation amounts for R[0], R[1], R[2], R[3] in each mix round. */\nconst RC2_ROT = [1, 2, 3, 5] as const\n\n/**\n * Expand a variable-length key to 64 sixteen-bit subkeys (RFC 2268 Section 2).\n * `effectiveBits` controls the effective key length for export-grade keys\n * (40 = RC2-40, 128 = RC2-128).\n */\nfunction rc2ExpandKey(key: Buffer, effectiveBits: number): number[] {\n // Guard: effectiveBits = 0 causes T8 = 0, making L[128-0] = L[128] an OOB\n // access on a 128-element Uint8Array (silently returns undefined, producing\n // a wrong key schedule). Values > 1024 exceed the RFC 2268 key schedule table.\n if (!Number.isInteger(effectiveBits) || effectiveBits < 1 || effectiveBits > 1024) {\n throw new Error(`rc2ExpandKey: effectiveBits must be an integer in [1, 1024], got ${effectiveBits}`)\n }\n const T = key.length\n const T8 = Math.ceil(effectiveBits / 8)\n // 0xff >> (effectiveBits & 7) gives 0xff for multiples-of-8 effective lengths\n // (no masking), and a smaller mask for non-multiples.\n const TM = 0xff >> (effectiveBits & 7)\n const L = new Uint8Array(128)\n for (let i = 0; i < T; i++) {\n L[i] = key[i]\n }\n for (let i = T; i < 128; i++) {\n L[i] = RC2_PITABLE[(L[i - 1] + L[i - T]) & 0xff]\n }\n L[128 - T8] = RC2_PITABLE[L[128 - T8] & TM]\n for (let i = 127 - T8; i >= 0; i--) {\n L[i] = RC2_PITABLE[L[i + 1] ^ L[i + T8]]\n }\n const K: number[] = new Array(64)\n for (let i = 0; i < 64; i++) {\n K[i] = L[2 * i] | (L[2 * i + 1] << 8)\n }\n return K\n}\n\n/** Rotate a 16-bit word right by `bits` positions. */\nfunction ror16(word: number, bits: number): number {\n return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff)\n}\n\n/**\n * Decrypt `data` using RC2-CBC with PKCS#7 padding removal (RFC 2268).\n *\n * Used for pbeWithSHAAnd40BitRC2CBC (OID 1.2.840.113549.1.12.1.6) and\n * pbeWithSHAAnd128BitRC2CBC (OID 1.2.840.113549.1.12.1.5).\n *\n * These OIDs are commonly used to encrypt certificate bags in PKCS#12\n * files produced by OpenSSL and Windows with default settings. Node.js 22+\n * (OpenSSL 3 default provider) does not support RC2 via `createDecipheriv`.\n */\nfunction rc2CbcDecrypt(key: Buffer, iv: Buffer, data: Buffer, effectiveBits: number): Buffer {\n // Guard: a non-multiple-of-8 ciphertext causes the last partial block to be\n // processed with `undefined` bytes. In JS, `undefined | (undefined << 8)`\n // produces NaN, and `NaN & 0xffff` produces 0 — so partial blocks silently\n // produce garbage output rather than throwing.\n if (data.length === 0 || data.length % 8 !== 0) {\n throw new Error(`rc2CbcDecrypt: ciphertext length ${data.length} is not a positive multiple of the 8-byte RC2 block size`)\n }\n if (iv.length !== 8) {\n throw new Error(`rc2CbcDecrypt: IV must be exactly 8 bytes, got ${iv.length}`)\n }\n const K = rc2ExpandKey(key, effectiveBits)\n const out = Buffer.alloc(data.length)\n const prev = Buffer.from(iv) // CBC running state; starts as the IV\n\n for (let offset = 0; offset < data.length; offset += 8) {\n const ct = data.subarray(offset, offset + 8)\n // Parse ciphertext block as four little-endian 16-bit words\n const R = [(ct[0] | (ct[1] << 8)) & 0xffff, (ct[2] | (ct[3] << 8)) & 0xffff, (ct[4] | (ct[5] << 8)) & 0xffff, (ct[6] | (ct[7] << 8)) & 0xffff]\n\n // Reverse the encryption round plan [5 mix, 1 mash, 6 mix, 1 mash, 5 mix].\n // For decryption j starts at 63 and decrements in each reverse-mix step.\n let j = 63\n\n const rMix = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = ror16(R[i], RC2_ROT[i])\n const r3 = R[(i + 3) % 4]\n R[i] = (R[i] - K[j] - (r3 & R[(i + 2) % 4]) - (~r3 & 0xffff & R[(i + 1) % 4])) & 0xffff\n j--\n }\n }\n\n const rMash = () => {\n for (let i = 3; i >= 0; i--) {\n R[i] = (R[i] - K[R[(i + 3) % 4] & 63]) & 0xffff\n }\n }\n\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 6; n++) {\n rMix()\n }\n rMash()\n for (let n = 0; n < 5; n++) {\n rMix()\n }\n\n // XOR decrypted words with previous ciphertext block (CBC mode)\n for (let i = 0; i < 4; i++) {\n out[offset + i * 2] = (R[i] & 0xff) ^ prev[i * 2]\n out[offset + i * 2 + 1] = (R[i] >> 8) ^ prev[i * 2 + 1]\n }\n // Advance CBC state to current ciphertext block\n ct.copy(prev)\n }\n\n // Validate and strip PKCS#7 padding.\n // Without this guard, padLen = 0 silently returns the full buffer (no stripping)\n // and padLen > 8 causes Buffer.subarray(0, negative) → empty buffer, both\n // silently. A wrong key/IV produces decrypted bytes that fail this check.\n const padLen = out[out.length - 1]\n if (padLen < 1 || padLen > 8) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 pad byte 0x${padLen.toString(16).padStart(2, \"0\")} — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n for (let i = out.length - padLen; i < out.length; i++) {\n if (out[i] !== padLen) {\n throw new Error(`rc2CbcDecrypt: invalid PKCS#7 padding — the ciphertext is corrupt or the wrong key/IV was used`)\n }\n }\n return out.subarray(0, out.length - padLen)\n}\n\n/** PKCS#12 legacy PBE OIDs (pkcs-12PbeIds) and their cipher parameters. */\nconst PKCS12_PBE_ALGOS: Record<string, { cipher: string; keyLen: number; ivLen: number; rc2Bits?: number }> = {\n \"1.2.840.113549.1.12.1.3\": { cipher: \"des-ede3-cbc\", keyLen: 24, ivLen: 8 }, // pbeWithSHAAnd3KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.4\": { cipher: \"des-ede-cbc\", keyLen: 16, ivLen: 8 }, // pbeWithSHAAnd2KeyTripleDESCBC\n \"1.2.840.113549.1.12.1.5\": { cipher: \"rc2-cbc\", keyLen: 16, ivLen: 8, rc2Bits: 128 }, // pbeWithSHAAnd128BitRC2CBC\n \"1.2.840.113549.1.12.1.6\": { cipher: \"rc2-cbc\", keyLen: 5, ivLen: 8, rc2Bits: 40 }, // pbeWithSHAAnd40BitRC2CBC\n}\n\n/**\n * Maximum PKCS#12 PBE iteration count accepted.\n *\n * A maliciously crafted PFX can set iterations to Number.MAX_SAFE_INTEGER,\n * causing the SHA-1 loop to run for an arbitrary amount of time (DoS).\n * Real-world PFX files use 1 000–50 000 iterations; this cap is generous\n * enough to accommodate even unusually high-security certs while blocking\n * obviously hostile inputs.\n */\nconst MAX_PKCS12_PBE_ITERATIONS = 300_000\n\n/**\n * PKCS#12 key/IV derivation function from RFC 7292 Appendix B (SHA-1 variant).\n * id = 1 to derive a key, id = 2 to derive an IV.\n *\n * Throws if `iterations` is outside [1, MAX_PKCS12_PBE_ITERATIONS] to prevent\n * CPU exhaustion from a crafted PFX file.\n */\nfunction pkcs12PbeDeriveKey(password: Buffer, salt: Buffer, iterations: number, id: number, length: number): Buffer {\n if (!Number.isInteger(iterations) || iterations < 1 || iterations > MAX_PKCS12_PBE_ITERATIONS) {\n throw new Error(\n `PKCS#12 PBE iteration count ${iterations} is outside safe range [1, ${MAX_PKCS12_PBE_ITERATIONS}]; refusing to process — the file may be crafted to exhaust CPU`\n )\n }\n // A crafted PFX could supply a multi-megabyte salt, causing Buffer.alloc(sLen) inside\n // the KDF to allocate gigabytes (sLen = ceil(salt.length / 64) * 64).\n const MAX_SALT_BYTES = 4096\n if (salt.length > MAX_SALT_BYTES) {\n throw new Error(`PKCS#12 PBE salt length ${salt.length} exceeds the safe maximum of ${MAX_SALT_BYTES} bytes — the file may be crafted to exhaust memory`)\n }\n\n const u = 20 // SHA-1 output bytes\n const v = 64 // SHA-1 block bytes\n\n // Step 1: D = ID byte repeated v times\n const D = Buffer.alloc(v, id)\n\n // Step 2: S = salt bytes repeated to fill ceil(salt.length / v) * v bytes\n const sLen = salt.length > 0 ? Math.ceil(salt.length / v) * v : 0\n const S = Buffer.alloc(sLen)\n for (let i = 0; i < sLen; i++) {\n S[i] = salt[i % salt.length]\n }\n\n // Step 3: P = password bytes repeated to fill ceil(password.length / v) * v bytes\n const pLen = password.length > 0 ? Math.ceil(password.length / v) * v : 0\n const P = Buffer.alloc(pLen)\n for (let i = 0; i < pLen; i++) {\n P[i] = password[i % password.length]\n }\n\n // Step 4: I = S || P (mutable, updated in step 6C)\n const I = new Uint8Array(Buffer.concat([S, P]))\n\n const c = Math.ceil(length / u)\n const result = Buffer.alloc(c * u)\n\n for (let i = 0; i < c; i++) {\n // Step 6A: A_i = H^iterations(D || I)\n let Ai: Buffer = createHash(\"sha1\").update(D).update(Buffer.from(I)).digest()\n for (let j = 1; j < iterations; j++) {\n Ai = createHash(\"sha1\").update(Ai).digest()\n }\n Ai.copy(result, i * u)\n\n // Step 6B: B = A_i repeated to fill v bytes\n const B = new Uint8Array(v)\n for (let j = 0; j < v; j++) {\n B[j] = Ai[j % u]\n }\n\n // Step 6C: each v-byte block of I is incremented by (B + 1) mod 2^(v*8)\n const blockCount = Math.ceil(I.length / v)\n for (let j = 0; j < blockCount; j++) {\n let carry = 1\n for (let b = v - 1; b >= 0; b--) {\n const idx = j * v + b\n if (idx < I.length) {\n const sum = I[idx] + B[b] + carry\n I[idx] = sum & 0xff\n carry = sum >> 8\n }\n }\n }\n }\n\n return result.subarray(0, length)\n}\n\n/**\n * Encode a password as UTF-16 Big Endian with a null terminator, which is the\n * format required by PKCS#12 PBE key derivation (RFC 7292).\n * An empty string yields [0x00, 0x00] (just the null terminator).\n */\nfunction pkcs12PasswordToUtf16(password: string): Buffer {\n const buf = Buffer.alloc((password.length + 1) * 2)\n for (let i = 0; i < password.length; i++) {\n const code = password.charCodeAt(i)\n buf[i * 2] = (code >> 8) & 0xff\n buf[i * 2 + 1] = code & 0xff\n }\n // Last two bytes are already 0x00 0x00 (null terminator) from Buffer.alloc.\n return buf\n}\n\n/**\n * Decrypt PKCS#12 legacy PBE encrypted content using Node.js crypto.\n *\n * @param algId - OID from PKCS12_PBE_ALGOS\n * @param algParams - asn1js object for PKCS12PBEParams (SEQUENCE { OCTET STRING, INTEGER })\n * @param encContent - asn1js object for the encrypted content (Constructed or Primitive [0] IMPLICIT)\n * @param password - plain-text password string\n */\nfunction decryptLegacyPkcs12Pbe(algId: string, algParams: any, encContent: any, password: string): Buffer {\n const algo = PKCS12_PBE_ALGOS[algId]\n\n // PKCS12PBEParams ::= SEQUENCE { salt OCTET STRING, iterations INTEGER }\n const salt = Buffer.from(algParams.valueBlock.value[0].valueBlock.valueHexView)\n const iterations = Number(algParams.valueBlock.value[1].valueBlock.valueDec)\n\n const pwdBytes = pkcs12PasswordToUtf16(password)\n const key = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 1, algo.keyLen)\n const iv = pkcs12PbeDeriveKey(pwdBytes, salt, iterations, 2, algo.ivLen)\n\n // Extract raw encrypted bytes from the [0] IMPLICIT OCTET STRING.\n // The encryptedContent field can be a Constructed (fragmented) or Primitive tag.\n let encBytes: Buffer\n if (encContent.idBlock?.isConstructed) {\n encBytes = Buffer.concat((encContent.valueBlock.value as any[]).map((p: any) => Buffer.from(p.valueBlock.valueHexView)))\n } else {\n encBytes = Buffer.from(encContent.valueBlock.valueHexView)\n }\n\n if (algo.rc2Bits != null) {\n // RC2 is not available in Node.js 22+ via createDecipheriv (OpenSSL 3 moved\n // it to the legacy provider which is not loaded by default). Use our pure-TS\n // RFC 2268 implementation instead.\n return rc2CbcDecrypt(key, iv, encBytes, algo.rc2Bits)\n }\n\n const decipher = createDecipheriv(algo.cipher, key, iv)\n return Buffer.concat([decipher.update(encBytes), decipher.final()])\n}\n\n/**\n * Reads certificate info from a PKCS#12 (.pfx) file using pkijs (unobfuscated TypeScript).\n * Mirrors the `certificate-info` subcommand of app-builder-bin.\n * https://github.com/develar/app-builder/blob/master/pkg/codesign/p12.go\n *\n * Returns { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn } on success. `windowsSubjectDn` is the subject in the\n * format Windows reports it (`X509Certificate2.Subject`), which electron-updater matches publisherName against.\n *\n * Known divergences from the Go binary:\n * - No OpenSSL fallback when the pure PKCS#12 decoder fails for a non-password reason.\n * - Unknown OIDs are rendered using the raw numeric OID as the type name (e.g. `2.5.4.100=value`); Go uses `OID=#hexbytes` when ASN.1 marshal succeeds.\n * - RDN ordering uses DER order; Go normalizes via pkix.Name.ToRDNSequence then reverses via\n * BloodyMsString. These coincide for pkijs-generated certs (CN-first DER) but may\n * differ for real CA-issued certs stored in traditional C-first DER order.\n */\nexport async function readCertInfo(file: string, password: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string; windowsSubjectDn: string }> {\n const pfxDer = await readFile(file)\n\n // asn1js requires a plain ArrayBuffer\n const pfxBuf = toArrayBuffer(pfxDer)\n let asn1: ReturnType<typeof asn1js.fromBER>\n try {\n asn1 = asn1js.fromBER(pfxBuf)\n if (asn1.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n } catch (err) {\n throw new Error(`PKCS#12 file \"${file}\" contains invalid ASN.1/DER data: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const pfx = new pkijs.PFX({ schema: asn1.result })\n const pwBuf = toArrayBuffer(Buffer.from(password, \"utf-8\"))\n\n // Step 1: Verify MAC (or signature) integrity and parse the AuthenticatedSafe container.\n // pkijs throws \"Integrity for the PKCS#12 data is broken!\" on wrong password.\n try {\n await pfx.parseInternalValues({ password: pwBuf, checkIntegrity: true })\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err)\n const lower = detail.toLowerCase()\n if (lower.includes(\"integrity\") || lower.includes(\"mac\") || lower.includes(\"password\") || lower.includes(\"pkcs#12\")) {\n throw new Error(`password incorrect for certificate file \"${file}\" — verify the password matches the PFX. pkijs detail: ${detail}`)\n }\n log.debug({ file, error: detail }, \"pkijs failed to decode PKCS#12; no OpenSSL fallback available in Node.js\")\n throw new Error(`Failed to decode PKCS#12 file \"${file}\" — the file may be corrupt, use an unsupported cipher, or require OpenSSL. pkijs detail: ${detail}`)\n }\n\n const authSafe = pfx.parsedValue?.authenticatedSafe\n if (authSafe == null) {\n throw new Error(`Failed to parse AuthenticatedSafe in PKCS#12 file \"${file}\"`)\n }\n\n // Step 2: Iterate over the authenticated-safe ContentInfos and extract all certificates.\n //\n // We do NOT call authSafe.parseInternalValues() because pkijs's CryptoEngine only handles\n // PBES2 (OID 1.2.840.113549.1.5.13) for EncryptedData. Real-world PFX files (including\n // CA-issued and electron-builder-generated certs) often use the older pkcs-12PbeIds ciphers\n // (e.g. pbeWithSHAAnd3KeyTripleDESCBC). We handle those with our own Node.js crypto path.\n const certs: pkijs.Certificate[] = []\n\n for (const ci of authSafe.safeContents) {\n let safeBER: ArrayBuffer\n\n if (ci.contentType === pkijs.id_ContentType_Data) {\n // Data: content is an OCTET STRING containing DER-encoded SafeContents.\n safeBER = (ci.content as asn1js.OctetString).getValue()\n } else if (ci.contentType === pkijs.id_ContentType_EncryptedData) {\n // EncryptedData: decrypt the SafeContents, routing by algorithm OID.\n const encData = new pkijs.EncryptedData({ schema: ci.content })\n const algId = encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId\n\n if (Object.prototype.hasOwnProperty.call(PKCS12_PBE_ALGOS, algId)) {\n // Legacy PKCS#12 PBE (pbeWithSHAAnd*) — use our RFC 7292 implementation.\n const decrypted = decryptLegacyPkcs12Pbe(\n algId,\n encData.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams,\n encData.encryptedContentInfo.encryptedContent,\n password\n )\n safeBER = toArrayBuffer(decrypted)\n } else {\n // PBES2 or other modern OID — delegate to the pkijs engine.\n safeBER = await encData.decrypt({ password: pwBuf })\n }\n } else {\n // EnvelopedData or other types — skip (not needed for cert extraction).\n continue\n }\n\n // Parse SafeContents and collect X.509 certificates from cert bags.\n const sc = pkijs.SafeContents.fromBER(safeBER)\n for (const bag of sc.safeBags) {\n if (bag.bagId === CERT_BAG_OID) {\n const certBag = bag.bagValue as pkijs.CertBag\n if (certBag.parsedValue instanceof pkijs.Certificate) {\n certs.push(certBag.parsedValue)\n }\n }\n }\n }\n\n if (certs.length === 0) {\n throw new Error(`No certificates found in PKCS#12 file \"${file}\" — the file may be a key-only PFX or be empty`)\n }\n\n // Find the certificate with the codeSigning Extended Key Usage.\n // pkijs auto-parses known extensions via ExtensionValueFactory (registered at module init).\n const signingCert = certs.find(cert => {\n const ekuExt = cert.extensions?.find(e => e.extnID === pkijs.id_ExtKeyUsage)\n if (ekuExt == null) {\n return false\n }\n if (ekuExt.parsedValue instanceof pkijs.ExtKeyUsage) {\n return ekuExt.parsedValue.keyPurposes.includes(CODE_SIGNING_OID)\n }\n // Fallback: manually parse the extension OctetString value.\n try {\n const inner = asn1js.fromBER(ekuExt.extnValue.valueBlock.valueHexView)\n if (inner.offset === -1) {\n return false\n }\n const eku = new pkijs.ExtKeyUsage({ schema: inner.result })\n return eku.keyPurposes.includes(CODE_SIGNING_OID)\n } catch {\n return false\n }\n })\n\n if (signingCert == null) {\n throw new Error(\n `No certificate with ExtKeyUsageCodeSigning found in \"${file}\" — ${certs.length} certificate(s) present but none have the codeSigning extended key usage. ` +\n `Ensure the PFX contains a code-signing certificate, not just a CA or TLS certificate.`\n )\n }\n\n const cnAttr = signingCert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n const commonName = String(cnAttr?.value.valueBlock.value ?? \"\")\n\n // Format DN as \"CN=X,O=X,...\" matching Go's BloodyMsString output.\n // Uses ATTRIBUTE_TYPE_NAMES to mirror Go's attributeTypeNames map exactly, so STREET,\n // POSTALCODE, and SERIALNUMBER (present in EV code-signing certs) are handled correctly.\n // Unknown OIDs fall back to the bare OID string as the type name.\n const bloodyMicrosoftSubjectDn = signingCert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn: formatWindowsSubjectDn(signingCert.subject) }\n}\n\n/**\n * Reads certificate info from a plain X.509 certificate file (.crt / .cer).\n * Accepts both PEM (base64 with -----BEGIN CERTIFICATE----- headers) and DER (raw binary) encoding.\n *\n * Unlike `readCertInfo`, this does not require a password and does not parse PKCS#12.\n * Used when HSM mode supplies a public-cert-only file alongside /csp + /kc or pkcs11Module.\n *\n * Returns `null` when the publisher name cannot be determined (e.g. no CN attribute), so\n * callers should fall back to requiring an explicit `publisherName` in that case.\n */\nexport async function readCertInfoFromX509(file: string): Promise<{ commonName: string; bloodyMicrosoftSubjectDn: string; windowsSubjectDn: string } | null> {\n const raw = await readFile(file)\n\n // Support PEM (ASCII armor) and DER (raw binary) encoding.\n let derBytes: Buffer\n const pemContent = raw.toString(\"ascii\")\n if (pemContent.includes(\"-----BEGIN CERTIFICATE-----\")) {\n const b64 = pemContent\n .replace(/-----BEGIN CERTIFICATE-----/g, \"\")\n .replace(/-----END CERTIFICATE-----/g, \"\")\n .replace(/\\s+/g, \"\")\n derBytes = Buffer.from(b64, \"base64\")\n } else {\n derBytes = raw\n }\n\n let cert: pkijs.Certificate\n try {\n const asn1Result = asn1js.fromBER(toArrayBuffer(derBytes))\n if (asn1Result.offset === -1) {\n throw new Error(\"offset -1: invalid BER encoding\")\n }\n cert = new pkijs.Certificate({ schema: asn1Result.result })\n } catch (err) {\n throw new Error(`X.509 certificate file \"${file}\" could not be parsed: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n const cnAttr = cert.subject.typesAndValues.find(a => a.type === \"2.5.4.3\")\n if (cnAttr == null) {\n return null\n }\n const commonName = String(cnAttr.value.valueBlock.value)\n\n const bloodyMicrosoftSubjectDn = cert.subject.typesAndValues\n .map(a => {\n const typeName = ATTRIBUTE_TYPE_NAMES[a.type] ?? a.type\n return `${typeName}=${escapeDnValue(String(a.value.valueBlock.value))}`\n })\n .join(\",\")\n\n return { commonName, bloodyMicrosoftSubjectDn, windowsSubjectDn: formatWindowsSubjectDn(cert.subject) }\n}\n\n/**\n * Internal functions exported exclusively for unit testing.\n * Not part of the public API — do not use outside of test files.\n */\nexport const _testingOnly = {\n pkcs12PbeDeriveKey,\n pkcs12PasswordToUtf16,\n rc2CbcDecrypt,\n MAX_PKCS12_PBE_ITERATIONS,\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InvalidConfigurationError } from "builder-util";
|
|
2
|
+
/** Explains what `forceCodeSigning` enforces; every error it raises links here. */
|
|
3
|
+
export declare const FORCE_CODE_SIGNING_DOCS = "https://www.electron.build/docs/migration/v27-build-changes#forcecodesigning-covers-notarization-and-update-manifests";
|
|
4
|
+
/** Error code of a signature that was produced (or shipped) but does not verify. */
|
|
5
|
+
export declare const VERIFICATION_FAILED_ERROR_CODE = "ERR_ELECTRON_BUILDER_VERIFICATION_FAILED";
|
|
6
|
+
/** An error raised because `forceCodeSigning` is enabled; the docs link is appended to `message`. */
|
|
7
|
+
export declare function forceCodeSigningError(message: string, code?: string): InvalidConfigurationError;
|
|
8
|
+
/** The parts of a platform packager {@link forceCodeSigningOverrideHint} reads. */
|
|
9
|
+
export interface ForceCodeSigningSource {
|
|
10
|
+
readonly platformOptions: {
|
|
11
|
+
readonly forceCodeSigning?: boolean | null;
|
|
12
|
+
};
|
|
13
|
+
readonly platform: {
|
|
14
|
+
readonly buildConfigurationKey: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `-c` override that turns `forceCodeSigning` off for this build. A platform-level value wins over the root one,
|
|
19
|
+
* so when the platform block sets it, only `-c.<platform>.forceCodeSigning=false` overrides it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function forceCodeSigningOverrideHint(packager: ForceCodeSigningSource): string;
|
|
22
|
+
//# sourceMappingURL=forceCodeSigning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forceCodeSigning.d.ts","sourceRoot":"","sources":["../../src/codeSign/forceCodeSigning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAGxD,mFAAmF;AACnF,eAAO,MAAM,uBAAuB,0HAAmF,CAAA;AAEvH,oFAAoF;AACpF,eAAO,MAAM,8BAA8B,6CAA6C,CAAA;AAExF,qGAAqG;AACrG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,yBAAyB,CAE/F;AAED,mFAAmF;AACnF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,eAAe,EAAE;QAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAA;IACxE,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9D;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,CAErF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InvalidConfigurationError } from "builder-util";
|
|
2
|
+
import { BUILD_CHANGES_URL } from "../util/config/legacyOptions.js";
|
|
3
|
+
/** Explains what `forceCodeSigning` enforces; every error it raises links here. */
|
|
4
|
+
export const FORCE_CODE_SIGNING_DOCS = `${BUILD_CHANGES_URL}#forcecodesigning-covers-notarization-and-update-manifests`;
|
|
5
|
+
/** Error code of a signature that was produced (or shipped) but does not verify. */
|
|
6
|
+
export const VERIFICATION_FAILED_ERROR_CODE = "ERR_ELECTRON_BUILDER_VERIFICATION_FAILED";
|
|
7
|
+
/** An error raised because `forceCodeSigning` is enabled; the docs link is appended to `message`. */
|
|
8
|
+
export function forceCodeSigningError(message, code) {
|
|
9
|
+
return new InvalidConfigurationError(`${message} See ${FORCE_CODE_SIGNING_DOCS}`, code);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `-c` override that turns `forceCodeSigning` off for this build. A platform-level value wins over the root one,
|
|
13
|
+
* so when the platform block sets it, only `-c.<platform>.forceCodeSigning=false` overrides it.
|
|
14
|
+
*/
|
|
15
|
+
export function forceCodeSigningOverrideHint(packager) {
|
|
16
|
+
return packager.platformOptions.forceCodeSigning == null ? "-c.forceCodeSigning=false" : `-c.${packager.platform.buildConfigurationKey}.forceCodeSigning=false`;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=forceCodeSigning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forceCodeSigning.js","sourceRoot":"","sources":["../../src/codeSign/forceCodeSigning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEnE,mFAAmF;AACnF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,iBAAiB,4DAA4D,CAAA;AAEvH,oFAAoF;AACpF,MAAM,CAAC,MAAM,8BAA8B,GAAG,0CAA0C,CAAA;AAExF,qGAAqG;AACrG,MAAM,UAAU,qBAAqB,CAAC,OAAe,EAAE,IAAa;IAClE,OAAO,IAAI,yBAAyB,CAAC,GAAG,OAAO,QAAQ,uBAAuB,EAAE,EAAE,IAAI,CAAC,CAAA;AACzF,CAAC;AAQD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAgC;IAC3E,OAAO,QAAQ,CAAC,eAAe,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,qBAAqB,yBAAyB,CAAA;AACjK,CAAC","sourcesContent":["import { InvalidConfigurationError } from \"builder-util\"\nimport { BUILD_CHANGES_URL } from \"../util/config/legacyOptions.js\"\n\n/** Explains what `forceCodeSigning` enforces; every error it raises links here. */\nexport const FORCE_CODE_SIGNING_DOCS = `${BUILD_CHANGES_URL}#forcecodesigning-covers-notarization-and-update-manifests`\n\n/** Error code of a signature that was produced (or shipped) but does not verify. */\nexport const VERIFICATION_FAILED_ERROR_CODE = \"ERR_ELECTRON_BUILDER_VERIFICATION_FAILED\"\n\n/** An error raised because `forceCodeSigning` is enabled; the docs link is appended to `message`. */\nexport function forceCodeSigningError(message: string, code?: string): InvalidConfigurationError {\n return new InvalidConfigurationError(`${message} See ${FORCE_CODE_SIGNING_DOCS}`, code)\n}\n\n/** The parts of a platform packager {@link forceCodeSigningOverrideHint} reads. */\nexport interface ForceCodeSigningSource {\n readonly platformOptions: { readonly forceCodeSigning?: boolean | null }\n readonly platform: { readonly buildConfigurationKey: string }\n}\n\n/**\n * The `-c` override that turns `forceCodeSigning` off for this build. A platform-level value wins over the root one,\n * so when the platform block sets it, only `-c.<platform>.forceCodeSigning=false` overrides it.\n */\nexport function forceCodeSigningOverrideHint(packager: ForceCodeSigningSource): string {\n return packager.platformOptions.forceCodeSigning == null ? \"-c.forceCodeSigning=false\" : `-c.${packager.platform.buildConfigurationKey}.forceCodeSigning=false`\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SignOptions } from "@electron/osx-sign";
|
|
2
|
-
import { TmpDir } from "builder-util";
|
|
2
|
+
import { InvalidConfigurationError, TmpDir } from "builder-util";
|
|
3
3
|
import { Nullish } from "builder-util-runtime";
|
|
4
4
|
export declare const appleCertificatePrefixes: string[];
|
|
5
5
|
export type CertType = "Developer ID Application" | "Developer ID Installer" | "3rd Party Mac Developer Application" | "3rd Party Mac Developer Installer" | "Mac Developer" | "Apple Development" | "Apple Distribution";
|
|
@@ -7,6 +7,12 @@ export interface CodeSigningInfo {
|
|
|
7
7
|
keychainFile?: string | null;
|
|
8
8
|
}
|
|
9
9
|
export declare function isSignAllowed(isPrintWarn?: boolean): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The error for a `forceCodeSigning` build that cannot sign `subject` here — the two cases {@link isSignAllowed} skips
|
|
12
|
+
* signing for: a host other than macOS, and a pull-request build without `CSC_FOR_PULL_REQUEST`. `null` when signing
|
|
13
|
+
* is possible. `overrideHint` is the `-c` option that turns `forceCodeSigning` off (see `forceCodeSigningOverrideHint`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function macSigningUnavailableError(subject: string, overrideHint: string): InvalidConfigurationError | null;
|
|
10
16
|
export declare function reportError(isMas: boolean, certificateTypes: CertType[], qualifier: string | Nullish, keychainFile: string | Nullish, isForceCodeSigning: boolean): Promise<void>;
|
|
11
17
|
export interface CreateKeychainOptions {
|
|
12
18
|
tmpDir: TmpDir;
|
|
@@ -18,6 +24,12 @@ export interface CreateKeychainOptions {
|
|
|
18
24
|
}
|
|
19
25
|
export declare function removeKeychain(keychainFile: string, printWarn?: boolean): Promise<any>;
|
|
20
26
|
export declare function createKeychain({ tmpDir, cscLink, cscKeyPassword, cscILink, cscIKeyPassword, currentDir }: CreateKeychainOptions): Promise<CodeSigningInfo>;
|
|
27
|
+
/**
|
|
28
|
+
* The programs the imported signing keys may be used by without a prompt (`security import -T`): the codesign and productbuild
|
|
29
|
+
* that electron-builder starts (from `toolsets.executables` or their default locations), and /usr/bin/codesign, which
|
|
30
|
+
* @electron/osx-sign starts by name.
|
|
31
|
+
*/
|
|
32
|
+
export declare function keychainTrustedApplications(): Array<string>;
|
|
21
33
|
export declare function sign(opts: SignOptions): Promise<void>;
|
|
22
34
|
export declare let findIdentityRawResult: Promise<Array<string>> | null;
|
|
23
35
|
export declare class Identity {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macCodeSign.d.ts","sourceRoot":"","sources":["../../../src/codeSign/mac/macCodeSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,
|
|
1
|
+
{"version":3,"file":"macCodeSign.d.ts","sourceRoot":"","sources":["../../../src/codeSign/mac/macCodeSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAuC,yBAAyB,EAAsD,MAAM,EAAkB,MAAM,cAAc,CAAA;AACzK,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAY9C,eAAO,MAAM,wBAAwB,UAAyI,CAAA;AAE9K,MAAM,MAAM,QAAQ,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,qCAAqC,GACrC,mCAAmC,GACnC,eAAe,GACf,mBAAmB,GACnB,oBAAoB,CAAA;AAExB,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,wBAAgB,aAAa,CAAC,WAAW,UAAO,GAAG,OAAO,CA6BzD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,yBAAyB,GAAG,IAAI,CAelH;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,SAAS,E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