electron-osx-sign/README.md

374 строки
9.6 KiB
Markdown
Исходник Обычный вид История

2016-03-05 06:21:29 +03:00
# electron-osx-sign [![npm][npm_img]][npm_url] [![Build Status][travis_img]][travis_url]
2015-12-21 18:46:36 +03:00
2016-03-05 09:19:11 +03:00
Code-signing for packaged Electron OS X apps.
2015-12-21 18:46:36 +03:00
2016-03-05 09:19:11 +03:00
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`.
2016-02-19 10:25:36 +03:00
2016-02-24 10:15:06 +03:00
*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).*
2016-02-11 17:05:08 +03:00
2016-03-04 12:13:13 +03:00
### An [OPEN Open Source Project](http://openopensource.org/)
2016-02-29 12:46:58 +03:00
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.
2015-12-21 18:46:36 +03:00
## Installation
```sh
2015-12-22 08:54:17 +03:00
# For use in npm scripts
2016-05-31 08:42:22 +03:00
npm install --save electron-osx-sign
2015-12-22 08:54:17 +03:00
```
2015-12-21 18:46:36 +03:00
2015-12-22 08:54:17 +03:00
```sh
# For use from CLI
2016-05-31 08:42:22 +03:00
npm install -g electron-osx-sign
2015-12-21 18:46:36 +03:00
```
2016-05-31 08:42:22 +03:00
*Note: `electron-osx-sign` is a dependency of `electron-packager` as of 6.0.0 for signing apps on OS X. However, feel free to install this package globally for more customization beyond specifying identity and entitlements.*
2015-12-21 18:46:36 +03:00
## Usage
2016-02-15 12:41:10 +03:00
### electron-osx-sign
#### From the Command Line
2015-12-21 18:46:36 +03:00
```sh
2016-02-13 10:39:56 +03:00
electron-osx-sign <app> [additional-binaries...] [--options...]
2015-12-21 18:46:36 +03:00
```
Example:
```sh
electron-osx-sign path/to/my.app
```
2016-02-29 12:46:58 +03:00
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).
2015-12-21 18:46:36 +03:00
2016-02-15 12:41:10 +03:00
#### From the API
2015-12-21 18:46:36 +03:00
```javascript
2015-12-21 22:02:51 +03:00
var sign = require('electron-osx-sign')
2016-02-15 12:49:31 +03:00
sign(opts[, function done (err) {}])
2015-12-21 18:46:36 +03:00
```
Example:
2015-12-21 18:46:36 +03:00
```javascript
var sign = require('electron-osx-sign')
sign({
app: 'path/to/my.app'
2016-02-15 12:49:31 +03:00
}, function done (err) {
if (err) {
2016-05-31 08:42:22 +03:00
// Application signed
return;
}
2016-05-31 08:42:22 +03:00
// Regular finishing
})
```
From release {Next Release}, [Bluebird](https://github.com/petkaantonov/bluebird) promises are introduced for better async method calls; the following is also available for use.
```javascript
var signAsync = require('electron-osx-sign').signAsync
signAsync(opts)
[.then(function () {})
[.catch(function (err) {})]]
```
Example:
```javascript
var signAsync = require('electron-osx-sign').signAsync
signAsync({
app: 'path/to/my.app'
})
2016-05-31 08:42:22 +03:00
.then(function () {
// Application signed
})
.catch(function (err) {
// Handle the error
})
```
2015-12-21 18:46:36 +03:00
2016-05-31 08:42:22 +03:00
###### opts - Options
2015-12-21 18:46:36 +03:00
**Required**
`app` - *String*
Path to the application package.
2016-02-15 12:41:10 +03:00
Needs file extension `.app`.
2015-12-21 18:46:36 +03:00
**Optional**
2016-02-13 10:39:56 +03:00
`binaries` - *Array*
Path to additional binaries that will be signed along with built-ins of Electron.
Default to `null`.
2015-12-21 18:46:36 +03:00
`entitlements` - *String*
2016-03-04 06:18:31 +03:00
Path to entitlements file for signing the app.
See [default.mas.entitlements](https://github.com/electron-userland/electron-osx-sign/blob/master/default.mas.entitlements) or [default.darwin.entitlements](https://github.com/electron-userland/electron-osx-sign/blob/master/default.darwin.entitlements) for default.
2015-12-21 18:46:36 +03:00
`entitlements-inherit` - *String*
2015-12-22 08:54:17 +03:00
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.*
2016-03-04 06:18:31 +03:00
See [default.mas.inherit.entitlements](https://github.com/electron-userland/electron-osx-sign/blob/master/default.mas.inherit.entitlements) or [default.darwin.inherit.entitlements](https://github.com/electron-userland/electron-osx-sign/blob/master/default.darwin.inherit.entitlements) for default.
2015-12-21 18:46:36 +03:00
`identity` - *String*
Name of certificate to use when signing.
2016-04-25 09:31:27 +03:00
Default to retrieve from `opts.keychain` (see below) or system default keychain.
2015-12-21 18:46:36 +03:00
2016-02-26 07:41:15 +03:00
Signing platform `mas` will look for `3rd Party Mac Developer Application: * (*)`, and platform `darwin` will look for `Developer ID Application: * (*)` by default.
2015-12-22 08:54:17 +03:00
2016-04-25 09:31:27 +03:00
`keychain` - *String*
The keychain name.
2016-05-31 08:42:22 +03:00
Default to system default keychain.
2016-04-25 09:31:27 +03:00
`ignore` - *String*
Regex or function that signals ignoring a file before signing.
Default to undefined.
2015-12-21 18:46:36 +03:00
`platform` - *String*
Build platform of Electron.
2015-12-22 08:54:17 +03:00
Allowed values: `darwin`, `mas`.
2016-05-31 08:42:22 +03:00
Default to auto detect by presence of `Squirrel.framework` within the application bundle.
2015-12-21 18:46:36 +03:00
2016-05-31 08:42:22 +03:00
###### cb - Callback
2016-02-15 12:41:10 +03:00
`err` - *Error*
### electron-osx-flat
#### From the Command Line
```sh
electron-osx-flat <app> [--options...]
```
Example:
```sh
electron-osx-flat path/to/my.app
```
2016-02-29 12:46:58 +03:00
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).
2016-02-15 12:41:10 +03:00
#### From the API
```javascript
var flat = require('electron-osx-sign').flat
flat(opts[, function done (err) {}])
```
Example:
```javascript
var flat = require('electron-osx-sign').flat
flat({
app: 'path/to/my.app'
}, function done (err) {
if (err) {
// Handle the error
return;
}
2016-05-31 08:42:22 +03:00
// Application flattened
})
```
From release {Next Release}, [Bluebird](https://github.com/petkaantonov/bluebird) promises are introduced for better async method calls; the following is also available for use.
```javascript
var flatAsync = require('electron-osx-sign').flatAsync
flatAsync(opts)
[.then(function () {})
[.catch(function (err) {})]]
```
Example:
```javascript
var flatAsync = require('electron-osx-sign').flatAsync
flatAsync({
app: 'path/to/my.app'
2016-02-15 12:41:10 +03:00
})
2016-05-31 08:42:22 +03:00
.then(function () {
// Application flattened
})
.catch(function (err) {
// Handle the error
})
2016-02-15 12:41:10 +03:00
```
2016-05-31 08:42:22 +03:00
###### opts - Options
2016-02-15 12:41:10 +03:00
**Required**
`app` - *String*
2016-05-31 08:42:22 +03:00
Path to the application bundle.
2016-02-15 12:41:10 +03:00
Needs file extension `.app`.
**Optional**
`identity` - *String*
Name of certificate to use when flattening.
2016-04-25 09:31:27 +03:00
Default to retrieve from `opts.keychain`(see below) or system default keychain.
2016-02-15 12:41:10 +03:00
2016-02-26 07:41:15 +03:00
Flattening platform `mas` will look for `3rd Party Mac Developer Installer: * (*)`, and platform `darwin` will look for `Developer ID Installer: * (*)` by default.
2016-02-15 12:41:10 +03:00
`install` - *String*
Path to install for the bundle.
Default to `/Applications`.
2016-04-25 09:31:27 +03:00
`keychain` - *String*
The keychain name.
2016-05-31 08:42:22 +03:00
Default to system default keychain.
2016-04-25 09:31:27 +03:00
2016-02-15 12:41:10 +03:00
`platform` - *String*
Build platform of Electron. Allowed values: `darwin`, `mas`.
2016-05-31 08:42:22 +03:00
Default to auto detect by presence of `Squirrel.framework` within the application bundle.
2016-02-15 12:41:10 +03:00
`pkg` - *String*
Path to the output flattened package.
2016-02-24 10:15:06 +03:00
Needs file extension `.pkg`.
2016-02-15 12:41:10 +03:00
2016-05-31 08:42:22 +03:00
###### cb - Callback
2015-12-21 18:46:36 +03:00
`err` - *Error*
## Debug
As of release v0.3.1, external module `debug` is used to display logs and messages; remember to `export DEBUG=electron-osx-sign*` when necessary.
2015-12-21 18:46:36 +03:00
## Test
As developer certificates are required for `codesign` in OS X, this module may not be tested via online build services. If you wish to test out this module, enter:
```
npm test
```
from the dev directory, and tell us if all tests should pass.
When this command is fun for the first time: `electron-download` will download all major releases of Electron available for OS X from 0.24.0, and save to `~/.electron/`, which might take up less than 1GB of disk space.
A successful testing should look something like:
```
$ npm test
2016-05-01 16:32:09 +03:00
> electron-osx-sign@0.3.1 pretest electron-osx-sign
2016-02-24 10:38:45 +03:00
> rimraf test/work
2016-05-01 16:32:09 +03:00
> electron-osx-sign@0.3.1 test electron-osx-sign
> standard && tape test
Calling electron-download before running tests...
Running tests...
TAP version 13
# setup
# defaults-test:v0.24.0-darwin-x64
ok 1 app signed
2016-02-15 12:41:10 +03:00
ok 2 app flattened
# defaults-test:v0.25.3-darwin-x64
ok 3 app signed
2016-02-15 12:41:10 +03:00
ok 4 app flattened
# defaults-test:v0.26.1-darwin-x64
2016-02-15 12:41:10 +03:00
ok 5 app signed
ok 6 app flattened
# defaults-test:v0.27.3-darwin-x64
2016-02-15 12:41:10 +03:00
ok 7 app signed
ok 8 app flattened
# defaults-test:v0.28.3-darwin-x64
2016-02-15 12:41:10 +03:00
ok 9 app signed
ok 10 app flattened
# defaults-test:v0.29.2-darwin-x64
2016-02-15 12:41:10 +03:00
ok 11 app signed
ok 12 app flattened
# defaults-test:v0.30.8-darwin-x64
2016-02-15 12:41:10 +03:00
ok 13 app signed
ok 14 app flattened
# defaults-test:v0.31.2-darwin-x64
2016-02-15 12:41:10 +03:00
ok 15 app signed
ok 16 app flattened
# defaults-test:v0.32.3-darwin-x64
2016-02-15 12:41:10 +03:00
ok 17 app signed
ok 18 app flattened
# defaults-test:v0.33.9-darwin-x64
2016-02-15 12:41:10 +03:00
ok 19 app signed
ok 20 app flattened
# defaults-test:v0.34.5-darwin-x64
2016-02-15 12:41:10 +03:00
ok 21 app signed
ok 22 app flattened
# defaults-test:v0.34.5-mas-x64
2016-02-15 12:41:10 +03:00
ok 23 app signed
ok 24 app flattened
# defaults-test:v0.35.6-darwin-x64
2016-02-15 12:41:10 +03:00
ok 25 app signed
ok 26 app flattened
# defaults-test:v0.35.6-mas-x64
2016-02-15 12:41:10 +03:00
ok 27 app signed
ok 28 app flattened
# defaults-test:v0.36.12-darwin-x64
2016-02-15 12:41:10 +03:00
ok 29 app signed
ok 30 app flattened
# defaults-test:v0.36.12-mas-x64
2016-02-15 12:41:10 +03:00
ok 31 app signed
ok 32 app flattened
# defaults-test:v0.37.8-darwin-x64
ok 33 app signed
ok 34 app flattened
# defaults-test:v0.37.8-mas-x64
ok 35 app signed
ok 36 app flattened
# defaults-test:v1.0.2-darwin-x64
ok 37 app signed
ok 38 app flattened
# defaults-test:v1.0.2-mas-x64
ok 39 app signed
ok 40 app flattened
# defaults-test:v1.1.3-darwin-x64
ok 41 app signed
ok 42 app flattened
# defaults-test:v1.1.3-mas-x64
ok 43 app signed
ok 44 app flattened
# defaults-test:v1.2.0-darwin-x64
ok 45 app signed
ok 46 app flattened
# defaults-test:v1.2.0-mas-x64
ok 47 app signed
ok 48 app flattened
# teardown
1..48
# tests 48
# pass 48
# ok
```
2016-01-22 19:25:12 +03:00
## Collaborators
2016-02-10 21:24:22 +03:00
Thanks to [seanchas116](https://github.com/seanchas116), and [jasonhinkle](https://github.com/jasonhinkle) for improving the usability of this project implementation.
2016-01-22 19:25:12 +03:00
2015-12-21 18:46:36 +03:00
## Related
2016-03-05 09:19:11 +03:00
- [electron-packager] - package your electron app in OS executables (.app, .exe, etc) via JS or CLI
2015-12-22 09:28:58 +03:00
[npm_img]: https://img.shields.io/npm/v/electron-osx-sign.svg
[npm_url]: https://npmjs.org/package/electron-osx-sign
2016-03-05 06:21:29 +03:00
[travis_img]: https://travis-ci.org/electron-userland/electron-osx-sign.svg?branch=master
[travis_url]: https://travis-ci.org/electron-userland/electron-osx-sign
2016-03-05 09:19:11 +03:00
[electron-packager]: https://github.com/electron-userland/electron-packager