electron-osx-sign
Advanced tools
Comparing version 0.3.0-beta to 0.3.0
89
index.js
@@ -77,2 +77,12 @@ var fs = require('fs') | ||
function isFileBinary (filePath) { | ||
var buf = fs.readFileSync(filePath) | ||
for (var i = 0, l = buf.length; i < l; i++) { | ||
if (buf[i] > 127) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
function walkSync (dirPath) { | ||
@@ -85,9 +95,4 @@ fs.readdirSync(dirPath).forEach(function (name) { | ||
case '': // binary | ||
var baseName = path.basename(filePath) | ||
switch (baseName) { | ||
case 'PkgInfo': | ||
return // ignore files | ||
default: | ||
if (baseName[0] === '.') return // reject hidden files | ||
} | ||
if (path.basename(filePath)[0] === '.') break // reject hidden file | ||
if (!isFileBinary(filePath)) break // reject non-binary file | ||
childPaths.push(filePath) | ||
@@ -100,3 +105,3 @@ break | ||
operations.push(function (cb) { | ||
fs.unlink(filePath, (err) => { | ||
fs.unlink(filePath, function (err) { | ||
if (err) return cb(err) | ||
@@ -111,2 +116,3 @@ cb() | ||
// Still consider the file as binary if extension seems invalid | ||
if (!isFileBinary(filePath)) break // reject non-binary file | ||
childPaths.push(filePath) | ||
@@ -117,5 +123,4 @@ } | ||
switch (path.basename(filePath)) { | ||
case '_CodeSignature': | ||
case 'node_modules': | ||
return // ignore directories | ||
break // ignore directory | ||
} | ||
@@ -138,19 +143,4 @@ walkSync(filePath) | ||
if (opts.entitlements) { | ||
if (opts.platform === 'mas') { | ||
// Sign with entitlements | ||
childPaths.forEach(function (filePath) { | ||
operations.push(function (cb) { | ||
child.exec([ | ||
'codesign', | ||
'-s', '"' + opts.identity + '"', | ||
'-fv', | ||
'--entitlements', '"' + opts['entitlements-inherit'] + '"', | ||
'"' + filePath.replace(/"/g, '\\"') + '"' | ||
].join(' '), function (err, stdout, stderr) { | ||
if (err) return cb(err) | ||
cb() | ||
}) | ||
if (opts.verbose) console.log('Signing...', filePath) | ||
}) | ||
}) | ||
// Sign with entitlements | ||
childPaths.forEach(function (filePath) { | ||
operations.push(function (cb) { | ||
@@ -161,4 +151,4 @@ child.exec([ | ||
'-fv', | ||
'--entitlements', '"' + opts.entitlements + '"', | ||
'"' + opts.app.replace(/"/g, '\\"') + '"' | ||
'--entitlements', '"' + opts['entitlements-inherit'] + '"', | ||
'"' + filePath.replace(/"/g, '\\"') + '"' | ||
].join(' '), function (err, stdout, stderr) { | ||
@@ -168,7 +158,18 @@ if (err) return cb(err) | ||
}) | ||
if (opts.verbose) console.log('Signing...', opts.app) | ||
if (opts.verbose) console.log('Signing...', filePath) | ||
}) | ||
} else if (opts.platform === 'darwin') { | ||
// TODO: Signing darwin builds with entitlements | ||
} | ||
}) | ||
operations.push(function (cb) { | ||
child.exec([ | ||
'codesign', | ||
'-s', '"' + opts.identity + '"', | ||
'-fv', | ||
'--entitlements', '"' + opts.entitlements + '"', | ||
'"' + opts.app.replace(/"/g, '\\"') + '"' | ||
].join(' '), function (err, stdout, stderr) { | ||
if (err) return cb(err) | ||
cb() | ||
}) | ||
if (opts.verbose) console.log('Signing...', opts.app) | ||
}) | ||
} else { | ||
@@ -258,3 +259,3 @@ // Otherwise normally | ||
if (!opts.platform) { | ||
if (opts.verbose) console.warn('No `platform` passed in arguments, cheking Electron platform...') | ||
if (opts.verbose) console.warn('No `platform` passed in arguments, checking Electron platform...') | ||
detectElectronPlatform(opts) | ||
@@ -271,11 +272,23 @@ } | ||
if (opts.verbose) console.warn('No `entitlements` passed in arguments, will fallback to default settings.') | ||
opts.entitlements = path.join(__dirname, 'mas.default.entitlements') | ||
opts.entitlements = path.join(__dirname, 'default.mas.entitlements') | ||
} | ||
if (!opts['entitlements-inherit']) { | ||
if (opts.verbose) console.warn('No `entitlements-inherit` passed in arguments, will fallback to default settings.') | ||
opts['entitlements-inherit'] = path.join(__dirname, 'mas.inherit.default.entitlements') | ||
opts['entitlements-inherit'] = path.join(__dirname, 'default.mas.inherit.entitlements') | ||
} | ||
} else if (opts.platform === 'darwin') { | ||
// Not necessary to have entitlements for non Mac App Store distribution | ||
if (opts.entitlements && opts.verbose) return cb(new Error('Unable to sign for darwin platform with entitlements.')) | ||
if (!opts.entitlements) { | ||
if (opts.verbose) console.warn('No `entitlements` passed in arguments, will not sign with entitlements.') | ||
} else { | ||
// If entitlements is provided as a flag, fallback to default | ||
if (opts.entitlements === true) { | ||
if (opts.verbose) console.warn('`entitlements` not specified in arguments, will fallback to default settings.') | ||
opts.entitlements = path.join(__dirname, 'default.mas.entitlements') | ||
} | ||
if (!opts['entitlements-inherit']) { | ||
if (opts.verbose) console.warn('No `entitlements-inherit` passed in arguments, will fallback to default settings.') | ||
opts['entitlements-inherit'] = path.join(__dirname, 'default.darwin.inherit.entitlements') | ||
} | ||
} | ||
} else { | ||
@@ -347,3 +360,3 @@ return cb(new Error('Only platform `darwin` and `mas` are supported.')) | ||
if (!opts.platform) { | ||
if (opts.verbose) console.warn('No `platform` passed in arguments, cheking Electron platform...') | ||
if (opts.verbose) console.warn('No `platform` passed in arguments, checking Electron platform...') | ||
detectElectronPlatform(opts) | ||
@@ -350,0 +363,0 @@ } else if (opts.platform !== 'mas' && opts.platform !== 'darwin') { |
{ | ||
"name": "electron-osx-sign", | ||
"version": "0.3.0-beta", | ||
"version": "0.3.0", | ||
"description": "Code-signing for Electron-packed OS X apps.", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/sethlu/electron-osx-sign.git" | ||
"url": "git+https://github.com/electron-userland/electron-osx-sign.git" | ||
}, | ||
@@ -18,5 +18,5 @@ "author": "sethlu", | ||
"bugs": { | ||
"url": "https://github.com/sethlu/electron-osx-sign/issues" | ||
"url": "https://github.com/electron-userland/electron-osx-sign/issues" | ||
}, | ||
"homepage": "https://github.com/sethlu/electron-osx-sign", | ||
"homepage": "https://github.com/electron-userland/electron-osx-sign", | ||
"dependencies": { | ||
@@ -23,0 +23,0 @@ "minimist": "^1.1.1", |
@@ -5,6 +5,10 @@ # electron-osx-sign [![npm][npm_img]][npm_url] | ||
Please visit our [Wiki](https://github.com/sethlu/electron-osx-sign/wiki) hosted here on GitHub for walk-throughs and notes from past projects shipped with `electron-packager` and `electron-osx-sign`. | ||
Please visit our [Wiki](https://github.com/electron-userland/electron-osx-sign/wiki) hosted here on GitHub for walk-throughs and notes from past projects shipped with `electron-packager` and `electron-osx-sign`. | ||
*Note: The signing procedure implemented in this package is based on what described in [Mac App Store Submission Guide](https://github.com/atom/electron/blob/master/docs/tutorial/mac-app-store-submission-guide.md).* | ||
## An [OPEN Open Source Project](http://openopensource.org/) | ||
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. | ||
## Installation | ||
@@ -40,3 +44,3 @@ | ||
For details on the optional flags, run `electron-osx-sign --help` or see [electron-osx-sign-usage.txt](https://github.com/sethlu/electron-osx-sign/blob/master/bin/electron-osx-sign-usage.txt). | ||
For details on the optional flags, run `electron-osx-sign --help` or see [electron-osx-sign-usage.txt](https://github.com/electron-userland/electron-osx-sign/blob/master/bin/electron-osx-sign-usage.txt). | ||
@@ -86,3 +90,3 @@ #### From the API | ||
Path to entitlements file for signing Mac App Store application. | ||
See [mas.default.entitlements](https://github.com/sethlu/electron-osx-sign/blob/master/mas.default.entitlements) for default. | ||
See [mas.default.entitlements](https://github.com/electron-userland/electron-osx-sign/blob/master/mas.default.entitlements) for default. | ||
@@ -92,3 +96,3 @@ `entitlements-inherit` - *String* | ||
Path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. *This option only applies when signing with `entitlements` provided, or for a `mas` platform version.* | ||
See [mas.inherit.default.entitlements](https://github.com/sethlu/electron-osx-sign/blob/master/mas.inherit.default.entitlements) for default. | ||
See [mas.inherit.default.entitlements](https://github.com/electron-userland/electron-osx-sign/blob/master/mas.inherit.default.entitlements) for default. | ||
@@ -100,3 +104,3 @@ `identity` - *String* | ||
Signing platform `mas` will look for `3rd Party Mac Developer Application: * <*>`, and platform `darwin` will look for `Developer ID Application: * <*>` by default. | ||
Signing platform `mas` will look for `3rd Party Mac Developer Application: * (*)`, and platform `darwin` will look for `Developer ID Application: * (*)` by default. | ||
@@ -132,3 +136,3 @@ `platform` - *String* | ||
For details on the optional flags, run `electron-osx-flat --help` or see [electron-osx-flat-usage.txt](https://github.com/sethlu/electron-osx-sign/blob/master/bin/electron-osx-flat-usage.txt). | ||
For details on the optional flags, run `electron-osx-flat --help` or see [electron-osx-flat-usage.txt](https://github.com/electron-userland/electron-osx-sign/blob/master/bin/electron-osx-flat-usage.txt). | ||
@@ -175,2 +179,4 @@ #### From the API | ||
Flattening platform `mas` will look for `3rd Party Mac Developer Installer: * (*)`, and platform `darwin` will look for `Developer ID Installer: * (*)` by default. | ||
`install` - *String* | ||
@@ -216,3 +222,6 @@ | ||
> electron-osx-sign@0.3.0-beta test electron-osx-sign | ||
> electron-osx-sign@0.3.0 pretest electron-osx-sign | ||
> rimraf test/work | ||
> electron-osx-sign@0.3.0 test electron-osx-sign | ||
> standard && tape test | ||
@@ -287,5 +296,5 @@ | ||
- [electron-packager](https://github.com/maxogden/electron-packager) - package your electron app in OS executables (.app, .exe, etc) via JS or CLI | ||
- [electron-packager](https://github.com/electron-userland/electron-packager) - package your electron app in OS executables (.app, .exe, etc) via JS or CLI | ||
[npm_img]: https://img.shields.io/npm/v/electron-osx-sign.svg | ||
[npm_url]: https://npmjs.org/package/electron-osx-sign |
@@ -18,3 +18,3 @@ { | ||
], | ||
"verbose": true | ||
"verbose": false | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30573
18
539
292
1