Skip to content

Commit c1ca5a4

Browse files
committed
Added afterPack script for Ad-hoc signing and verification of macOS applications.
Trying to get rid of ““API Key Health Checker.app” is damaged and can’t be opened. You should move it to the Trash.”
1 parent 1f8dc4e commit c1ca5a4

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

build/afterPack.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-disable no-console */
2+
const { execFileSync } = require("child_process");
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
exports.default = async function afterPack(context) {
7+
if (context.electronPlatformName !== "darwin") return;
8+
9+
const appOutDir = context.appOutDir;
10+
const appName = fs.readdirSync(appOutDir).find((f) => f.endsWith(".app"));
11+
if (!appName) throw new Error(`No .app found in ${appOutDir}`);
12+
13+
const appPath = path.join(appOutDir, appName);
14+
15+
console.log(`Ad-hoc signing app bundle: ${appPath}`);
16+
17+
// Re-sign the whole bundle to generate CodeResources and clear "no resources" errors.
18+
execFileSync("/usr/bin/codesign", ["--force", "--deep", "--sign", "-", appPath], {
19+
stdio: "inherit",
20+
});
21+
22+
// Verify signature integrity after re-signing.
23+
execFileSync("/usr/bin/codesign", ["--verify", "--deep", "--strict", "--verbose=4", appPath], {
24+
stdio: "inherit",
25+
});
26+
27+
// Gatekeeper will likely reject ad-hoc signatures; this is expected.
28+
try {
29+
execFileSync("/usr/sbin/spctl", ["-a", "-vv", appPath], { stdio: "inherit" });
30+
} catch {
31+
console.log("spctl rejected (expected for ad-hoc / unsigned).");
32+
}
33+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api-key-health-checker",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Desktop app to validate API keys for OpenAI, Gemini, YouTube, and custom endpoints with batch checks, rate limits, and reports.",
55
"license": "BSD-3-Clause",
66
"author": "nbox (https://github.com/nbox)",
@@ -35,6 +35,7 @@
3535
"build": {
3636
"appId": "com.nbox",
3737
"productName": "API Key Health Checker",
38+
"afterPack": "build/afterPack.cjs",
3839
"mac": {
3940
"artifactName": "API Key Health Checker-${version}-${arch}.${ext}",
4041
"icon": "resources/icon.icns",

0 commit comments

Comments
 (0)