forked from CringeStudios/element-desktop
Rely on @electron/universal for macOS ASAR integrity
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
a546b28c62
commit
cf59556fd0
@ -1,10 +1,6 @@
|
|||||||
import * as os from "node:os";
|
import * as os from "node:os";
|
||||||
import * as fs from "node:fs";
|
import * as fs from "node:fs";
|
||||||
import * as path from "node:path";
|
import { Configuration as BaseConfiguration } from "electron-builder";
|
||||||
import * as plist from "plist";
|
|
||||||
import { AfterPackContext, Arch, Configuration as BaseConfiguration, Platform } from "electron-builder";
|
|
||||||
import { computeData } from "app-builder-lib/out/asar/integrity";
|
|
||||||
import { readFile, writeFile } from "node:fs/promises";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This script has different outputs depending on your os platform.
|
* This script has different outputs depending on your os platform.
|
||||||
@ -46,26 +42,6 @@ interface Configuration extends BaseConfiguration {
|
|||||||
} & BaseConfiguration["deb"];
|
} & BaseConfiguration["deb"];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function injectAsarIntegrity(context: AfterPackContext) {
|
|
||||||
const packager = context.packager;
|
|
||||||
|
|
||||||
// We only need to re-generate asar on universal Mac builds, due to https://github.com/electron/universal/issues/116
|
|
||||||
if (packager.platform !== Platform.MAC || context.arch !== Arch.universal) return;
|
|
||||||
|
|
||||||
const resourcesPath = packager.getResourcesDir(context.appOutDir);
|
|
||||||
const asarIntegrity = await computeData({
|
|
||||||
resourcesPath,
|
|
||||||
resourcesRelativePath: "Resources",
|
|
||||||
resourcesDestinationPath: resourcesPath,
|
|
||||||
extraResourceMatchers: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const plistPath = path.join(resourcesPath, "..", "Info.plist");
|
|
||||||
const data = plist.parse(await readFile(plistPath, "utf8")) as unknown as Writable<plist.PlistObject>;
|
|
||||||
data["ElectronAsarIntegrity"] = asarIntegrity as unknown as Writable<plist.PlistValue>;
|
|
||||||
await writeFile(plistPath, plist.build(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('electron-builder').Configuration}
|
* @type {import('electron-builder').Configuration}
|
||||||
* @see https://www.electron.build/configuration/configuration
|
* @see https://www.electron.build/configuration/configuration
|
||||||
@ -90,9 +66,6 @@ const config: Omit<Writable<Configuration>, "electronFuses"> & {
|
|||||||
loadBrowserProcessSpecificV8Snapshot: false,
|
loadBrowserProcessSpecificV8Snapshot: false,
|
||||||
enableEmbeddedAsarIntegrityValidation: true,
|
enableEmbeddedAsarIntegrityValidation: true,
|
||||||
},
|
},
|
||||||
afterPack: async (context: AfterPackContext) => {
|
|
||||||
await injectAsarIntegrity(context);
|
|
||||||
},
|
|
||||||
files: [
|
files: [
|
||||||
"package.json",
|
"package.json",
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,6 @@
|
|||||||
"matrix-web-i18n": "^3.2.1",
|
"matrix-web-i18n": "^3.2.1",
|
||||||
"mkdirp": "^3.0.0",
|
"mkdirp": "^3.0.0",
|
||||||
"pacote": "^21.0.0",
|
"pacote": "^21.0.0",
|
||||||
"plist": "^3.1.0",
|
|
||||||
"prettier": "^3.0.0",
|
"prettier": "^3.0.0",
|
||||||
"rimraf": "^6.0.0",
|
"rimraf": "^6.0.0",
|
||||||
"tar": "^7.0.0",
|
"tar": "^7.0.0",
|
||||||
@ -115,6 +114,7 @@
|
|||||||
"keytar": "^7.9.0"
|
"keytar": "^7.9.0"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
"@electron/universal": "2.0.2",
|
||||||
"@types/node": "18.19.76",
|
"@types/node": "18.19.76",
|
||||||
"config-file-ts": "0.2.8-rc1"
|
"config-file-ts": "0.2.8-rc1"
|
||||||
}
|
}
|
||||||
|
14
yarn.lock
14
yarn.lock
@ -978,7 +978,7 @@
|
|||||||
ajv "^6.12.0"
|
ajv "^6.12.0"
|
||||||
ajv-keywords "^3.4.1"
|
ajv-keywords "^3.4.1"
|
||||||
|
|
||||||
"@electron/asar@3.2.18", "@electron/asar@^3.2.7":
|
"@electron/asar@3.2.18":
|
||||||
version "3.2.18"
|
version "3.2.18"
|
||||||
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.2.18.tgz#fa607f829209bab8b9e0ce6658d3fe81b2cba517"
|
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.2.18.tgz#fa607f829209bab8b9e0ce6658d3fe81b2cba517"
|
||||||
integrity sha512-2XyvMe3N3Nrs8cV39IKELRHTYUWFKrmqqSY1U+GMlc0jvqjIVnoxhNd2H4JolWQncbJi1DCvb5TNxZuI2fEjWg==
|
integrity sha512-2XyvMe3N3Nrs8cV39IKELRHTYUWFKrmqqSY1U+GMlc0jvqjIVnoxhNd2H4JolWQncbJi1DCvb5TNxZuI2fEjWg==
|
||||||
@ -987,7 +987,7 @@
|
|||||||
glob "^7.1.6"
|
glob "^7.1.6"
|
||||||
minimatch "^3.0.4"
|
minimatch "^3.0.4"
|
||||||
|
|
||||||
"@electron/asar@3.3.1", "@electron/asar@^3.2.1":
|
"@electron/asar@3.3.1", "@electron/asar@^3.2.1", "@electron/asar@^3.3.1":
|
||||||
version "3.3.1"
|
version "3.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.3.1.tgz#cd14e897770d9844673dd7c1dc8944e086e1e0ea"
|
resolved "https://registry.yarnpkg.com/@electron/asar/-/asar-3.3.1.tgz#cd14e897770d9844673dd7c1dc8944e086e1e0ea"
|
||||||
integrity sha512-WtpC/+34p0skWZiarRjLAyqaAX78DofhDxnREy/V5XHfu1XEXbFCSSMcDQ6hNCPJFaPy8/NnUgYuf9uiCkvKPg==
|
integrity sha512-WtpC/+34p0skWZiarRjLAyqaAX78DofhDxnREy/V5XHfu1XEXbFCSSMcDQ6hNCPJFaPy8/NnUgYuf9uiCkvKPg==
|
||||||
@ -1076,12 +1076,12 @@
|
|||||||
tar "^6.0.5"
|
tar "^6.0.5"
|
||||||
yargs "^17.0.1"
|
yargs "^17.0.1"
|
||||||
|
|
||||||
"@electron/universal@2.0.1":
|
"@electron/universal@2.0.1", "@electron/universal@2.0.2":
|
||||||
version "2.0.1"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-2.0.1.tgz#7b070ab355e02957388f3dbd68e2c3cd08c448ae"
|
resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-2.0.2.tgz#834466e6b117fdb94048bcbde5c91d2d4571e718"
|
||||||
integrity sha512-fKpv9kg4SPmt+hY7SVBnIYULE9QJl8L3sCfcBsnqbJwwBwAeTLokJ9TRt9y7bK0JAzIW2y78TVVjvnQEms/yyA==
|
integrity sha512-mqY1szx5/d5YLvfCDWWoJdkSIjIz+NdWN4pN0r78lYiE7De+slLpuF3lVxIT+hlJnwk5sH2wFRMl6/oUgUVO3A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@electron/asar" "^3.2.7"
|
"@electron/asar" "^3.3.1"
|
||||||
"@malept/cross-spawn-promise" "^2.0.0"
|
"@malept/cross-spawn-promise" "^2.0.0"
|
||||||
debug "^4.3.1"
|
debug "^4.3.1"
|
||||||
dir-compare "^4.2.0"
|
dir-compare "^4.2.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user