1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-11 22:13:32 +00:00

feat: use after-sign to avoid issues

Electron builder modifies the .plist in the extension which causes issues with the signing process. Copying and re-signing manually avoids this because it bypasses the electron builder for the extension
This commit is contained in:
Andreas Coroiu
2024-07-01 11:24:03 +02:00
parent f4949ed7fd
commit 6d01fbe71d
2 changed files with 35 additions and 26 deletions

View File

@@ -38,13 +38,6 @@
"hardenedRuntime": true,
"entitlements": "resources/entitlements.mac.plist",
"entitlementsInherit": "resources/entitlements.mac.plist",
"extraFiles": [
{
"from": "macos/build/Release/autofill-extension.appex",
"to": "PlugIns/autofill-extension.appex"
}
],
"x64ArchFiles": "**/autofill-extension.appex/**/*",
"extendInfo": {
"ITSAppUsesNonExemptEncryption": false,
"CFBundleLocalizations": [

View File

@@ -15,9 +15,22 @@ async function run(context) {
const appName = context.packager.appInfo.productFilename;
const appPath = `${context.appOutDir}/${appName}.app`;
const macBuild = context.electronPlatformName === "darwin";
const copyPlugIn = ["darwin", "mas"].includes(context.electronPlatformName);
const copySafariExtension = ["darwin", "mas"].includes(context.electronPlatformName);
const copyAutofillExtension = ["mas"].includes(context.electronPlatformName);
if (copyPlugIn) {
let shouldResign = false;
// cannot use extraFiles instead
if (copyAutofillExtension) {
const extensionPath = path.join(__dirname, "../macos/build/Release/autofill-extension.appex");
if (fse.existsSync(extensionPath)) {
fse.mkdirSync(path.join(appPath, "Contents/PlugIns"));
fse.copySync(extensionPath, path.join(appPath, "Contents/PlugIns/autofill-extension.appex"));
}
shouldResign = true;
}
if (copySafariExtension) {
// Copy Safari plugin to work-around https://github.com/electron-userland/electron-builder/issues/5552
const plugIn = path.join(__dirname, "../PlugIns");
if (fse.existsSync(plugIn)) {
@@ -26,25 +39,28 @@ async function run(context) {
path.join(plugIn, "safari.appex"),
path.join(appPath, "Contents/PlugIns/safari.appex"),
);
shouldResign = true;
}
}
// Resign to sign safari extension
if (context.electronPlatformName === "mas") {
const masBuildOptions = deepAssign(
{},
context.packager.platformSpecificBuildOptions,
context.packager.config.mas,
);
if (context.targets.some((e) => e.name === "mas-dev")) {
deepAssign(masBuildOptions, {
type: "development",
});
}
if (context.packager.packagerOptions.prepackaged == null) {
await context.packager.sign(appPath, context.appOutDir, masBuildOptions, context.arch);
}
} else {
await context.packager.signApp(context, true);
if (shouldResign) {
// Resign to sign safari extension
if (context.electronPlatformName === "mas") {
const masBuildOptions = deepAssign(
{},
context.packager.platformSpecificBuildOptions,
context.packager.config.mas,
);
if (context.targets.some((e) => e.name === "mas-dev")) {
deepAssign(masBuildOptions, {
type: "development",
});
}
if (context.packager.packagerOptions.prepackaged == null) {
await context.packager.sign(appPath, context.appOutDir, masBuildOptions, context.arch);
}
} else {
await context.packager.signApp(context, true);
}
}