Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next2d/builder",
"version": "0.5.25",
"version": "0.5.26",
"description": "A multiplatform builder for the Next2d Framework. It supports exporting to a variety of platforms, including Steam, macOS, Windows, Linux, iOS, Android, Xbox, Nintendo Switch, and the web (HTML).",
"author": "Toshiyuki Ienaga <ienaga@next2d.app>",
"license": "MIT",
Expand Down
6 changes: 4 additions & 2 deletions src/electron-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ export const readElectronConfig = (root: string): IElectronConfig => {
* Electron fuses for a packaged game (names of @electron/fuses FuseV1Options).
* ASAR integrity validation exists on macOS and Windows only.
*/
export const createElectronFuses = (platform: string, arch: string): {
export const createElectronFuses = (platform: string, arch: string, universalSlice = false): {
resetAdHocDarwinSignature: boolean;
options: Record<string, boolean>;
} => ({
// Changing the binary invalidates the ad-hoc signature Apple silicon requires; a real signature replaces it later.
"resetAdHocDarwinSignature": platform === "darwin" && arch === "arm64",
// Not for the slices of a universal build: the deep re-sign adds _CodeSignature files to the arm64 slice only,
// and @electron/universal refuses to merge slices whose files differ. The merged app is signed instead.
"resetAdHocDarwinSignature": platform === "darwin" && arch === "arm64" && !universalSlice,
"options": {
"RunAsNode": false,
"EnableNodeOptionsEnvironmentVariable": false,
Expand Down
9 changes: 8 additions & 1 deletion src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const buildElectron = async (): Promise<void> => {
// from being replaced or bypassed: Electron validates it against the hash the packager embeds in
// the executable, loads the app only from it, and ignores the switches that run other code.
const lockRuntime = async ({ buildPath, platform, arch }: { buildPath: string; platform: string; arch: string }): Promise<void> => {
const fuses = createElectronFuses(platform, arch);
const fuses = createElectronFuses(platform, arch, target.arch === "universal");
const electron = path.join(buildPath, platform === "darwin" ? "Electron.app" : platform === "win32" ? "electron.exe" : "electron");
await flipFuses(electron, {
"version": FuseVersion.V1,
Expand All @@ -99,6 +99,13 @@ export const buildElectron = async (): Promise<void> => {
"prune": false
}) as string[]);
}, `${os}-${target.arch}`);
// The slices of a universal build skip the ad-hoc re-sign (see createElectronFuses). Without a real
// signature the merged app would carry an invalid one that Apple silicon refuses to launch.
if (target.platform === "darwin" && target.arch === "universal" && !config.macos.sign && process.env.NEXT2D_STEAM_RELEASE !== "1") {
for (const content of outputPaths) {
await run("codesign", ["--sign", "-", "--force", "--deep", path.join(content, `${config.appName}.app`)], root);
}
}
if (steam) {
for (const content of outputPaths) {
recordSteamPackage(content, ctx.platform, target.arch, config, version);
Expand Down
2 changes: 2 additions & 0 deletions tests/integrity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ test("packaged Electron runtimes load only the validated ASAR and ignore switche
]) {
const fuses = createElectronFuses(platform, arch);
assert.equal(fuses.resetAdHocDarwinSignature, adHoc);
// The slices of a universal build are merged first and signed afterwards
assert.equal(createElectronFuses(platform, arch, true).resetAdHocDarwinSignature, false);
assert.deepEqual(fuses.options, {
RunAsNode: false,
EnableNodeOptionsEnvironmentVariable: false,
Expand Down
Loading