Skip to content

Commit

Permalink
update config name to be explicit about asar sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaietta committed Mar 11, 2024
1 parent fef15be commit 6722d1c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .changeset/dirty-rats-happen.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"app-builder-lib": minor
---

feat: add disableSanityCheckPackage to allow encrypted asars
feat: add disableSanityCheckAsar to allow encrypted asars
2 changes: 1 addition & 1 deletion docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com
<p><code id="Configuration-removePackageKeywords">removePackageKeywords</code> = <code>true</code> Boolean - Whether to remove <code>keywords</code> field from <code>package.json</code> files.</p>
</li>
<li>
<p><code id="Configuration-disableSanityCheckPackage">disableSanityCheckPackage</code> = <code>false</code> Boolean - Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)</p>
<p><code id="Configuration-disableSanityCheckAsar">disableSanityCheckAsar</code> = <code>false</code> Boolean - Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)</p>
</li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -6666,7 +6666,7 @@
}
]
},
"disableSanityCheckPackage": {
"disableSanityCheckAsar": {
"default": false,
"description": "Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)",
"type": "boolean"
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export interface Configuration extends PlatformSpecificBuildOptions {
* Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)
* @default false
*/
readonly disableSanityCheckPackage?: boolean
readonly disableSanityCheckAsar?: boolean
}

interface PackContext {
Expand Down
12 changes: 6 additions & 6 deletions packages/app-builder-lib/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
}

const isAsar = asarOptions != null
await this.sanityCheckPackage(appOutDir, isAsar, framework, !!this.config.disableSanityCheckPackage)
await this.sanityCheckPackage(appOutDir, isAsar, framework, !!this.config.disableSanityCheckAsar)
if (sign) {
await this.doSignAfterPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets)
}
Expand Down Expand Up @@ -508,8 +508,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
return path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents", "Resources")
}

private async checkFileInPackage(resourcesDir: string, file: string, messagePrefix: string, isAsar: boolean, disableSanityCheckPackage: boolean) {
if (isAsar && disableSanityCheckPackage) {
private async checkFileInPackage(resourcesDir: string, file: string, messagePrefix: string, isAsar: boolean, disableSanityCheckAsar: boolean) {
if (isAsar && disableSanityCheckAsar) {
return
}
const relativeFile = path.relative(this.info.appDir, path.resolve(this.info.appDir, file))
Expand Down Expand Up @@ -549,7 +549,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
}
}

private async sanityCheckPackage(appOutDir: string, isAsar: boolean, framework: Framework, disableSanityCheckPackage: boolean): Promise<any> {
private async sanityCheckPackage(appOutDir: string, isAsar: boolean, framework: Framework, disableSanityCheckAsar: boolean): Promise<any> {
const outStat = await statOrNull(appOutDir)
if (outStat == null) {
throw new Error(`Output directory "${appOutDir}" does not exist. Seems like a wrong configuration.`)
Expand All @@ -562,8 +562,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>

const resourcesDir = this.getResourcesDir(appOutDir)
const mainFile = (framework.getMainFile == null ? null : framework.getMainFile(this.platform)) || this.info.metadata.main || "index.js"
await this.checkFileInPackage(resourcesDir, mainFile, "Application entry file", isAsar, disableSanityCheckPackage)
await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar, disableSanityCheckPackage)
await this.checkFileInPackage(resourcesDir, mainFile, "Application entry file", isAsar, disableSanityCheckAsar)
await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar, disableSanityCheckAsar)
}

// tslint:disable-next-line:no-invalid-template-strings
Expand Down

0 comments on commit 6722d1c

Please sign in to comment.