Skip to content

TagSpaces is an offline, open source, document manager with tagging support

feat: adding notarization for macos

Ilian Sapundshievc5cc3e7cafdc
diff --git a/package.json b/package.json
index 05b36a655..68772cefa 100644
--- a/package.json
+++ b/package.json
@@ -277,6 +277,7 @@
"electron": "17.1.2",
"electron-builder": "^22.14.7",
"electron-devtools-installer": "^3.2.0",
+ "electron-notarize": "^1.2.1",
"enzyme": "^2.8.2",
"enzyme-to-json": "^1.5.1",
"eslint": "^6.8.0",
diff --git a/resources/builder.json b/resources/builder.json
index 27b10ba92..2f3e3bdba 100644
--- a/resources/builder.json
+++ b/resources/builder.json
@@ -2,6 +2,7 @@
"appId": "org.tagspaces.desktopapp",
"asar": true,
"asarUnpack": "**/node_modules/sharp/**/*",
+ "afterSign": "scripts/afterSign.js",
"includeSubNodeModules": true,
"files": [
"dist/",
@@ -18,6 +19,9 @@
],
"copyright": "Copyright © 2022 TagSpaces UG (haftungsbeschraenkt)",
"artifactName": "${name}-${os}-${arch}-${version}.${ext}",
+ "dmg": {
+ "sign": false
+ },
"win": {
"target": [
"nsis",
@@ -28,6 +32,10 @@
},
"mac": {
"target": ["zip", "dmg"],
+ "hardenedRuntime": true,
+ "gatekeeperAssess": false,
+ "entitlements": "resources/entitlements.mac.plist",
+ "entitlementsInherit": "resources/entitlements.mac.plist",
"icon": "resources/icon.icns"
},
"linux": {
diff --git a/resources/entitlements.mac.plist b/resources/entitlements.mac.plist
new file mode 100644
index 000000000..eef1fe686
--- /dev/null
+++ b/resources/entitlements.mac.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
+ <true/>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ </dict>
+</plist>
\ No newline at end of file
diff --git a/scripts/afterSign.js b/scripts/afterSign.js
new file mode 100644
index 000000000..0c767ef78
--- /dev/null
+++ b/scripts/afterSign.js
@@ -0,0 +1,41 @@
+// "afterSign": "./afterSignHook.js",
+
+require('dotenv').config();
+console.log(process.env);
+const fs = require('fs');
+const path = require('path');
+var electron_notarize = require('electron-notarize');
+
+module.exports = async function(params) {
+ if (process.platform !== 'darwin') {
+ return;
+ }
+
+ console.log('afterSign hook triggered', params);
+
+ let appId = 'org.tagspaces.desktopapp';
+
+ let appPath = path.join(
+ params.appOutDir,
+ `${params.packager.appInfo.productFilename}.app`
+ );
+ if (!fs.existsSync(appPath)) {
+ console.log('skip');
+ return;
+ }
+
+ console.log(`Notarizing ${appId} found at ${appPath}`);
+
+ try {
+ await electron_notarize.notarize({
+ appBundleId: appId,
+ appPath: appPath,
+ appleId: process.env.APPLE_ID,
+ appleIdPassword: process.env.APPLE_ID_PASSWORD
+ });
+ } catch (error) {
+ console.error(error);
+ }
+
+ console.log(`Done notarizing ${appId}`);
+};