diff --git a/.changeset/dirty-rats-happen.md b/.changeset/dirty-rats-happen.md
index 39c7e60fbc3..2918c1036b6 100644
--- a/.changeset/dirty-rats-happen.md
+++ b/.changeset/dirty-rats-happen.md
@@ -2,4 +2,4 @@
"app-builder-lib": minor
---
-feat: add disableSanityCheckPackage to allow encrypted asars
+feat: add disableSanityCheckAsar to allow encrypted asars
diff --git a/.changeset/mighty-spies-knock.md b/.changeset/mighty-spies-knock.md
new file mode 100644
index 00000000000..6cf92ad168c
--- /dev/null
+++ b/.changeset/mighty-spies-knock.md
@@ -0,0 +1,5 @@
+---
+"app-builder-lib": patch
+---
+
+fix: move `disableSanityCheckPackage` to within `checkFileInPackage` to not bypass non-asar usage
diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md
index 458c8fd19f6..f45ce5b3fcc 100644
--- a/docs/configuration/configuration.md
+++ b/docs/configuration/configuration.md
@@ -188,7 +188,7 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com
removePackageKeywords
= true
Boolean - Whether to remove keywords
field from package.json
files.
-disableSanityCheckPackage
= false
Boolean - Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)
+disableSanityCheckAsar
= false
Boolean - Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)
diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json
index d299ec33ca3..48365e49971 100644
--- a/packages/app-builder-lib/scheme.json
+++ b/packages/app-builder-lib/scheme.json
@@ -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"
diff --git a/packages/app-builder-lib/src/configuration.ts b/packages/app-builder-lib/src/configuration.ts
index b86a24dca32..e472602e228 100644
--- a/packages/app-builder-lib/src/configuration.ts
+++ b/packages/app-builder-lib/src/configuration.ts
@@ -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 {
diff --git a/packages/app-builder-lib/src/platformPackager.ts b/packages/app-builder-lib/src/platformPackager.ts
index 2f9b5403190..6ebed64b2e9 100644
--- a/packages/app-builder-lib/src/platformPackager.ts
+++ b/packages/app-builder-lib/src/platformPackager.ts
@@ -316,9 +316,7 @@ export abstract class PlatformPackager
}
const isAsar = asarOptions != null
- if (!this.config.disableSanityCheckPackage) {
- await this.sanityCheckPackage(appOutDir, isAsar, framework)
- }
+ await this.sanityCheckPackage(appOutDir, isAsar, framework, !!this.config.disableSanityCheckAsar)
if (sign) {
await this.doSignAfterPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets)
}
@@ -510,7 +508,10 @@ export abstract class PlatformPackager
return path.join(appOutDir, `${this.appInfo.productFilename}.app`, "Contents", "Resources")
}
- private async checkFileInPackage(resourcesDir: string, file: string, messagePrefix: string, isAsar: boolean) {
+ 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))
if (isAsar) {
await checkFileInArchive(path.join(resourcesDir, "app.asar"), relativeFile, messagePrefix)
@@ -548,7 +549,7 @@ export abstract class PlatformPackager
}
}
- private async sanityCheckPackage(appOutDir: string, isAsar: boolean, framework: Framework): Promise {
+ private async sanityCheckPackage(appOutDir: string, isAsar: boolean, framework: Framework, disableSanityCheckAsar: boolean): Promise {
const outStat = await statOrNull(appOutDir)
if (outStat == null) {
throw new Error(`Output directory "${appOutDir}" does not exist. Seems like a wrong configuration.`)
@@ -561,8 +562,8 @@ export abstract class PlatformPackager
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)
- await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar)
+ 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