Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

applesign

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

applesign - npm Package Compare versions

Comparing version 0.8.0 to 0.8.2

34

bin/ipa-resign.js

@@ -7,3 +7,14 @@ #!/usr/bin/env node

const conf = require('minimist')(process.argv.slice(2), {
boolean: ['r', 'replace', 'L', 'identities', 'v', 'verifyTwice', 'f', 'without-fairplay', 'p', 'parallel', 'w', 'without-watchapp']
boolean: [
'r', 'replace',
'L', 'identities',
'v', 'verify-twice',
'E', 'entry-entitlement',
'f', 'without-fairplay',
'p', 'parallel',
'w', 'without-watchapp',
'u', 'unfair',
'f', 'force-family',
's', 'single'
]
});

@@ -15,2 +26,3 @@

entitlement: conf.entitlement || conf.e,
entry: conf['entry-entitlement'] || conf.E,
bundleid: conf.bundleid || conf.b,

@@ -24,3 +36,5 @@ identity: conf.identity || conf.i,

verifyTwice: conf.verifyTwice || !!conf.v,
unfairPlay: conf['without-fairplay'] || conf.f
unfairPlay: conf.unfair || conf.u,
forceFamily: conf['force-family'] || conf.f,
single: conf.single || conf.s
};

@@ -53,5 +67,6 @@

-b, --bundleid [BUNDLEID] Change the bundleid when repackaging
-b, --bundleid [BUNDLEID] Change the bundleid when repackaging (EXPERIMENTAL)
-e, --entitlements [ENTITL] Specify entitlements file (EXPERIMENTAL)
-f, --without-fairplay Resign encrypted applications
-E, --entry-entitlement Use generic entitlement (EXPERIMENTAL)
-f, --force-family Force UIDeviceFamily in Info.plist to be iPhone
-i, --identity [1C4D1A..] Specify hash-id of the identity to use

@@ -64,2 +79,3 @@ -k, --keychain [KEYCHAIN] Specify alternative keychain file

-r, --replace Replace the input IPA file with the resigned one
-u, --unfair Resign encrypted applications
-v, --verify-twice Verify after signing every file and at the end

@@ -75,3 +91,5 @@ -w, --without-watchapp Remove the WatchApp from the IPA before resigning

} else {
cs.signIPA(options.file, (error, data) => {
const target = (conf.s || conf.single) ? 'signFile' : 'signIPA';
console.log(options.entry);
const session = cs[target](options.file, (error, data) => {
if (error) {

@@ -81,8 +99,10 @@ console.error(error, data);

}
console.log('IPA is now signed.');
console.log('Target is now signed:', session.config.outfile || options.file);
}).on('message', (msg) => {
console.log(colors.msg(msg));
}).on('warning', (msg) => {
console.log(colors.error('error'), msg);
console.error(colors.error('error'), msg);
}).on('error', (msg) => {
console.error(colors.msg(msg));
});
}

@@ -24,2 +24,3 @@ 'use strict';

entitlement: opt.entitlement || undefined,
entry: opt.entry || undefined,
bundleid: opt.bundleid || undefined,

@@ -30,2 +31,3 @@ identity: opt.identity || undefined,

mobileprovision: opt.mobileprovision || undefined,
forceFamily: opt.forceFamily || false,
parallel: opt.parallel || false,

@@ -47,2 +49,7 @@ verifyTwice: opt.verifyTwice || false,

signFile (file, cb) {
const s = new ApplesignSession(this.config);
return s.signFile(file, cb);
}
signXCarchive (file, cb) {

@@ -49,0 +56,0 @@ const ipaFile = file + '.ipa';

@@ -66,3 +66,3 @@ {

"name": "applesign",
"version": "0.8.0"
"version": "0.8.2"
}

@@ -15,2 +15,32 @@ 'use strict';

const entitlementTemplate = `
<?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>application-identifier</key>
<string>FILLME.APPID</string>
<key>com.apple.developer.team-identifier</key>
<string>FILLME</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>FILLME.APPID</string>
</array>
</dict>
</plist>
`;
function defaultEntitlements (appid, devid) {
const ent = plist.parse(entitlementTemplate);
console.log('appid', appid);
console.log('devid', devid);
//const appid = devid + bundleid;
ent['application-identifier'] = appid;
ent['com.apple.developer.team-identifier'] = devid
ent['keychain-access-groups'] = [ appid ];
return plistBuild(ent).toString();
}
function getResignedFilename (path) {

@@ -192,5 +222,13 @@ if (!path) return null;

});
if (changed) {
entMacho['keychain-access-groups'][0] = entMobProv['application-identifier'];
if (changed || this.config.entry) {
const newEntitlementsFile = file + '.entitlements';
fs.writeFileSync(newEntitlementsFile, plistBuild(entMacho).toString());
const appid = entMobProv['application-identifier'];
const devid = entMobProv['com.apple.developer.team-identifier'];
let newEntitlements = (appid && devid && this.config.entry)
? defaultEntitlements(appid, devid)
: (this.config.entitlement)
? fs.readFileSync(this.config.entitlement)
: plistBuild(entMacho).toString();
fs.writeFileSync(newEntitlementsFile, newEntitlements);
this.emit('message', 'Updated binary entitlements' + newEntitlementsFile);

@@ -204,5 +242,12 @@ this.config.entitlement = newEntitlementsFile;

if (!this.config.mobileprovision) {
return next();
const pathToProvision = path.join(this.config.appdir, 'embedded.mobileprovision');
tools.getEntitlementsFromMobileProvision(pathToProvision, (error, newEntitlements) => {
if (error) {
return next();
}
this.emit('message', 'Grabbing entitlements from mobileprovision');
return this.adjustEntitlements(file, newEntitlements, next);
});
return;
}
this.emit('message', 'Grabbing entitlements from mobileprovision');
tools.getEntitlementsFromMobileProvision(this.config.mobileprovision, (error, newEntitlements) => {

@@ -225,7 +270,35 @@ if (error) {

}
let changed = false;
const data = plist.readFileSync(file);
if (this.config.forceFamily) {
const oldSupportedDevices = data['UISupportedDevices'];
if (oldSupportedDevices) {
this.emit('message', 'Empty UISupportedDevices');
delete data['UISupportedDevices'];
changed = true;
}
const oldFamily = +data['UIDeviceFamily'];
if (oldFamily === 2) {
this.emit('message', 'UIDeviceFamily forced to iPhone');
data['UIDeviceFamily'] = 1;
changed = true;
}
}
if (bundleid) {
const data = plist.readFileSync(file);
const oldBundleID = data['CFBundleIdentifier'];
this.emit('message', 'Rebundle ' + file + ' : ' + oldBundleID + ' into ' + bundleid);
data['CFBundleIdentifier'] = bundleid;
const oldBundleId = data['CFBundleIdentifier'];
this.emit('message', 'Rebundle ' + file + ' : ' + oldBundleId + ' into ' + bundleid);
if (oldBundleId) {
data['CFBundleIdentifier'] = bundleid;
}
if (data['basebundleidentifier']) {
data['basebundleidentifier'] = bundleid;
}
try {
data['CFBundleURLTypes'][0]['CFBundleURLName'] = bundleid;
} catch (e) {
/* do nothing */
}
changed = true;
}
if (changed) {
plist.writeFileSync(file, data);

@@ -243,4 +316,4 @@ }

}
this.emit('message', 'Sign ' + file);
tools.codesign(this.config.identity, this.config.entitlement, this.config.keychain, file, (error, stdout, stderr) => {
this.emit('message', 'Signed ' + file);
if (error && codesignHasFailed(this.config, error, stderr)) {

@@ -264,2 +337,3 @@ return this.emit('end', error, next);

});
return this;
}

@@ -266,0 +340,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc