From 016786a04e51162ea7a4b096201a78b908b14494 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 30 Mar 2026 13:55:47 +0200 Subject: [PATCH 1/2] Remove unreachable workdir check in unzipIPA --- index.ts | 10 +++++----- lib/version.ts | 2 +- test/test.ts | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/index.ts b/index.ts index d8cce57..92a859f 100644 --- a/index.ts +++ b/index.ts @@ -876,17 +876,17 @@ class Applesign { } } - async unzipIPA(file: any, workdir: any): Promise { + async unzipIPA(file: string, workdir: string): Promise { fchk(arguments, ["string", "string"]); - if (!file || !workdir) { - throw new Error("No output specified"); + if (!file) { + throw new Error("No input file specified"); } if (!workdir) { - throw new Error("Invalid output directory"); + throw new Error("No output directory specified"); } await this.cleanup(); this.events.emit("message", "Unzipping " + file); - return tools.unzip(file, workdir); + await tools.unzip(file, workdir); } /* Event Wrapper API with cb support */ diff --git a/lib/version.ts b/lib/version.ts index 3ea0bcc..8b9e1eb 100644 --- a/lib/version.ts +++ b/lib/version.ts @@ -1,2 +1,2 @@ -const version = "5.0.1"; +const version = "6.0.0"; export default version; diff --git a/test/test.ts b/test/test.ts index 63f7314..fa99f3b 100644 --- a/test/test.ts +++ b/test/test.ts @@ -3,6 +3,7 @@ import { spawn } from "node:child_process"; import * as path from "node:path"; import * as fs from "node:fs"; import { describe, it } from "mocha"; +import Applesign from "../index.js"; const mochaTimeout = 15000; const developerCertificate = process.env.DEVCERT; @@ -25,6 +26,26 @@ describe("API", () => { }); */ +describe("API", () => { + describe("unzipIPA", () => { + it("should fail when the input file is missing", async () => { + const applesign = new Applesign({}); + await assert.rejects( + applesign.unzipIPA("", "tmp"), + /No input file specified/, + ); + }); + + it("should fail when the output directory is missing", async () => { + const applesign = new Applesign({}); + await assert.rejects( + applesign.unzipIPA("test.ipa", ""), + /No output directory specified/, + ); + }); + }); +}); + describe("Commandline", () => { describe("dist/bin/applesign.js", () => { it("should fail when applesign cannot be executed", (done) => { From f0839daeadc88fa3c6a717036c9d4755f35ae8a0 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 30 Mar 2026 15:01:46 +0200 Subject: [PATCH 2/2] fixes --- index.ts | 8 ++++---- lib/tools.ts | 2 +- tsconfig.json | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index 92a859f..2cdca82 100644 --- a/index.ts +++ b/index.ts @@ -351,7 +351,7 @@ class Applesign { } addEntitlementsSync(orig: any) { - if (this.config.addEntitlements === undefined) { + if (!this.config.addEntitlements) { return orig; } this.emit("message", "Adding entitlements from file"); @@ -480,7 +480,7 @@ class Applesign { additionalKeychainGroups.push(this.config.customKeychainGroup); } const infoPlist = path.join(this.config.appdir, "Info.plist"); - const plistData = plist.readFileSync(infoPlist); + const plistData = plist.readFileSync(infoPlist) as Record; if (this.config.bundleIdKeychainGroup) { if (typeof this.config.bundleid === "string") { additionalKeychainGroups.push(this.config.bundleid); @@ -513,7 +513,7 @@ class Applesign { : this.config.entitlement ? fs.readFileSync(this.config.entitlement).toString() : plistBuild(entMacho).toString(); - const ent = plist.parse(newEntitlements.trim()); + const ent = plist.parse(newEntitlements.trim()) as Record; const shouldRenameGroups = !this.config.mobileprovision && !this.config.cloneEntitlements; if (shouldRenameGroups && ent["com.apple.security.application-groups"]) { @@ -926,7 +926,7 @@ function getExecutable(appdir: string) { } const plistPath = path.join(appdir, "Info.plist"); try { - const plistData = plist.readFileSync(plistPath); + const plistData = plist.readFileSync(plistPath) as Record; const cfBundleExecutable = plistData.CFBundleExecutable; if (cfBundleExecutable) { return cfBundleExecutable; diff --git a/lib/tools.ts b/lib/tools.ts index d52a95e..d7c580d 100644 --- a/lib/tools.ts +++ b/lib/tools.ts @@ -203,7 +203,7 @@ async function getMobileProvisionPlist(file: string) { const args = ["cms", "-D", "-i", file]; res = await execProgram(getTool("security")!, args); } - return plist.parse(res.stdout); + return plist.parse(res.stdout) as Record; } async function getEntitlementsFromMobileProvision( diff --git a/tsconfig.json b/tsconfig.json index b836bec..a658f8d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "ts-node": { "esm": true }, + "files": ["lib/types.d.ts"], "include": [ // include both JS and TS sources for migration "lib/**/*",