mirror of
https://github.com/S2-/gitlit
synced 2025-08-03 12:50:04 +02:00
packager
This commit is contained in:
242
app/node_modules/electron-osx-sign/.eslintrc.json
generated
vendored
Normal file
242
app/node_modules/electron-osx-sign/.eslintrc.json
generated
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
{
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"accessor-pairs": 2,
|
||||
"array-bracket-spacing": [
|
||||
2,
|
||||
"never"
|
||||
],
|
||||
"array-callback-return": 2,
|
||||
"arrow-body-style": 2,
|
||||
"arrow-parens": 2,
|
||||
"arrow-spacing": 2,
|
||||
"block-scoped-var": 2,
|
||||
"block-spacing": 2,
|
||||
"brace-style": [
|
||||
2,
|
||||
"1tbs"
|
||||
],
|
||||
"callback-return": 0,
|
||||
"camelcase": 2,
|
||||
"comma-spacing": [
|
||||
2,
|
||||
{
|
||||
"after": true,
|
||||
"before": false
|
||||
}
|
||||
],
|
||||
"comma-style": [
|
||||
2,
|
||||
"last"
|
||||
],
|
||||
"complexity": 2,
|
||||
"computed-property-spacing": [
|
||||
2,
|
||||
"never"
|
||||
],
|
||||
"consistent-return": 0,
|
||||
"consistent-this": 2,
|
||||
"curly": 0,
|
||||
"default-case": 0,
|
||||
"dot-location": [
|
||||
2,
|
||||
"property"
|
||||
],
|
||||
"dot-notation": [
|
||||
2,
|
||||
{
|
||||
"allowKeywords": true
|
||||
}
|
||||
],
|
||||
"eol-last": 2,
|
||||
"func-names": 0,
|
||||
"func-style": [
|
||||
2,
|
||||
"declaration"
|
||||
],
|
||||
"generator-star-spacing": 2,
|
||||
"global-require": 2,
|
||||
"guard-for-in": 2,
|
||||
"handle-callback-err": 0,
|
||||
"id-blacklist": 2,
|
||||
"id-length": 0,
|
||||
"id-match": 2,
|
||||
"indent": 0,
|
||||
"init-declarations": 0,
|
||||
"jsx-quotes": 2,
|
||||
"key-spacing": 2,
|
||||
"keyword-spacing": [
|
||||
2,
|
||||
{
|
||||
"after": true,
|
||||
"before": true
|
||||
}
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"unix"
|
||||
],
|
||||
"lines-around-comment": 2,
|
||||
"max-depth": 2,
|
||||
"max-len": 0,
|
||||
"max-nested-callbacks": 2,
|
||||
"max-params": 2,
|
||||
"new-cap": 2,
|
||||
"new-parens": 2,
|
||||
"newline-after-var": 0,
|
||||
"newline-per-chained-call": 0,
|
||||
"no-alert": 2,
|
||||
"no-array-constructor": 2,
|
||||
"no-bitwise": 2,
|
||||
"no-caller": 2,
|
||||
"no-console": [
|
||||
"error",
|
||||
{
|
||||
"allow": [
|
||||
"log",
|
||||
"warn",
|
||||
"error"
|
||||
]
|
||||
}
|
||||
],
|
||||
"no-catch-shadow": 2,
|
||||
"no-confusing-arrow": 2,
|
||||
"no-continue": 2,
|
||||
"no-div-regex": 2,
|
||||
"no-else-return": 0,
|
||||
"no-eq-null": 0,
|
||||
"no-eval": 2,
|
||||
"no-extend-native": 2,
|
||||
"no-extra-bind": 2,
|
||||
"no-extra-label": 2,
|
||||
"no-extra-parens": 2,
|
||||
"no-floating-decimal": 2,
|
||||
"no-implicit-coercion": 2,
|
||||
"no-implicit-globals": 2,
|
||||
"no-implied-eval": 2,
|
||||
"no-inline-comments": 0,
|
||||
"no-inner-declarations": [
|
||||
2,
|
||||
"functions"
|
||||
],
|
||||
"no-invalid-this": 2,
|
||||
"no-iterator": 2,
|
||||
"no-label-var": 2,
|
||||
"no-labels": 2,
|
||||
"no-lone-blocks": 2,
|
||||
"no-lonely-if": 2,
|
||||
"no-loop-func": 2,
|
||||
"no-magic-numbers": 0,
|
||||
"no-mixed-requires": 2,
|
||||
"no-multi-spaces": 2,
|
||||
"no-multi-str": 2,
|
||||
"no-multiple-empty-lines": 2,
|
||||
"no-native-reassign": 2,
|
||||
"no-negated-condition": 0,
|
||||
"no-nested-ternary": 2,
|
||||
"no-new": 2,
|
||||
"no-new-func": 2,
|
||||
"no-new-object": 2,
|
||||
"no-new-require": 2,
|
||||
"no-new-wrappers": 2,
|
||||
"no-octal-escape": 2,
|
||||
"no-param-reassign": 0,
|
||||
"no-path-concat": 2,
|
||||
"no-plusplus": [
|
||||
2,
|
||||
{
|
||||
"allowForLoopAfterthoughts": true
|
||||
}
|
||||
],
|
||||
"no-process-env": 2,
|
||||
"no-process-exit": 2,
|
||||
"no-proto": 2,
|
||||
"no-restricted-imports": 2,
|
||||
"no-restricted-modules": 2,
|
||||
"no-restricted-syntax": 2,
|
||||
"no-return-assign": 2,
|
||||
"no-script-url": 2,
|
||||
"no-self-compare": 2,
|
||||
"no-sequences": 2,
|
||||
"no-shadow": 0,
|
||||
"no-shadow-restricted-names": 2,
|
||||
"no-spaced-func": 2,
|
||||
"no-sync": 0,
|
||||
"no-ternary": 0,
|
||||
"no-throw-literal": 2,
|
||||
"no-trailing-spaces": 2,
|
||||
"no-undef-init": 2,
|
||||
"no-undefined": 2,
|
||||
"no-underscore-dangle": 0,
|
||||
"no-unmodified-loop-condition": 2,
|
||||
"no-unneeded-ternary": 2,
|
||||
"no-unused-expressions": 2,
|
||||
"no-use-before-define": 0,
|
||||
"no-useless-call": 2,
|
||||
"no-useless-concat": 2,
|
||||
"no-useless-constructor": 2,
|
||||
"no-var": 0,
|
||||
"no-void": 2,
|
||||
"no-warning-comments": 0,
|
||||
"no-whitespace-before-property": 2,
|
||||
"no-with": 2,
|
||||
"object-curly-spacing": 2,
|
||||
"object-shorthand": 2,
|
||||
"one-var": 0,
|
||||
"one-var-declaration-per-line": 2,
|
||||
"operator-assignment": 2,
|
||||
"operator-linebreak": 2,
|
||||
"padded-blocks": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"prefer-const": 0,
|
||||
"prefer-reflect": 2,
|
||||
"prefer-rest-params": 2,
|
||||
"prefer-spread": 2,
|
||||
"prefer-template": 0,
|
||||
"quote-props": 2,
|
||||
"quotes": 0,
|
||||
"radix": 2,
|
||||
"require-jsdoc": 0,
|
||||
"require-yield": 2,
|
||||
"semi": 0,
|
||||
"semi-spacing": [
|
||||
2,
|
||||
{
|
||||
"after": true,
|
||||
"before": false
|
||||
}
|
||||
],
|
||||
"sort-imports": 2,
|
||||
"sort-vars": 2,
|
||||
"space-before-blocks": 2,
|
||||
"space-before-function-paren": 2,
|
||||
"space-in-parens": [
|
||||
2,
|
||||
"never"
|
||||
],
|
||||
"space-infix-ops": 2,
|
||||
"space-unary-ops": 2,
|
||||
"spaced-comment": [
|
||||
2,
|
||||
"always"
|
||||
],
|
||||
"strict": 0,
|
||||
"template-curly-spacing": 2,
|
||||
"valid-jsdoc": 2,
|
||||
"vars-on-top": 0,
|
||||
"wrap-iife": 2,
|
||||
"wrap-regex": 2,
|
||||
"yield-star-spacing": 2,
|
||||
"yoda": [
|
||||
2,
|
||||
"never"
|
||||
]
|
||||
}
|
||||
}
|
15
app/node_modules/electron-osx-sign/.gitattributes
generated
vendored
Normal file
15
app/node_modules/electron-osx-sign/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
.gitattributes text
|
||||
.gitignore text
|
||||
.gitconfig text
|
||||
|
||||
*.md text
|
||||
LICENSE text
|
||||
AUTHORS text
|
||||
|
||||
*.js text
|
||||
*.json text
|
||||
*.entitlements text
|
||||
*.txt text
|
4
app/node_modules/electron-osx-sign/.npmignore
generated
vendored
Normal file
4
app/node_modules/electron-osx-sign/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
test/work
|
||||
.idea/
|
||||
yarn.lock
|
8
app/node_modules/electron-osx-sign/.travis.yml
generated
vendored
Normal file
8
app/node_modules/electron-osx-sign/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "7"
|
||||
- "6"
|
||||
- "4.1"
|
||||
- "4.0"
|
||||
|
||||
script: npm run-script code-standard
|
23
app/node_modules/electron-osx-sign/LICENSE
generated
vendored
Normal file
23
app/node_modules/electron-osx-sign/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright (c) 2015-2016 Zhuo Lu, Jason Hinkle, et al.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
473
app/node_modules/electron-osx-sign/README.md
generated
vendored
Normal file
473
app/node_modules/electron-osx-sign/README.md
generated
vendored
Normal file
@@ -0,0 +1,473 @@
|
||||
# electron-osx-sign [![npm][npm_img]][npm_url] [![Build Status][travis_img]][travis_url]
|
||||
|
||||
Codesign Electron macOS apps
|
||||
|
||||
## About
|
||||
|
||||
[`electron-osx-sign`][electron-osx-sign] minimizes the extra work needed to eventually prepare your apps for shipping, providing the most basic tools and assets. Note that the bare necessities here are sufficient for enabling app sandbox, yet other configurations for network access etc. require additional work.
|
||||
|
||||
Check out [`electron-osx-sign` guide](https://mintkit.net/electron-userland/electron-osx-sign/guide/) for suggestions on setting up your environment and workflow for distribution or development.
|
||||
|
||||
Please visit our [wiki](https://github.com/electron-userland/electron-osx-sign/wiki) for walk-throughs, notes and [frequently asked questions](https://github.com/electron-userland/electron-osx-sign/wiki/FAQ) from past projects shipped with [`electron-packager`][electron-packager] and [`electron-osx-sign`][electron-osx-sign].
|
||||
|
||||
*NB: Since [`electron-osx-sign`][electron-osx-sign] injects the entry `com.apple.security.application-groups` into the entitlements file as part of the pre-signing process, this would reportedly limit app transfer on iTunes Connect (see [#150](https://github.com/electron-userland/electron-osx-sign/issues/150)). However, opting out entitlements automation `opts['pre-auto-entitlements'] === false` may result in worse graphics performance.*
|
||||
|
||||
*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).*
|
||||
|
||||
### [Electron]
|
||||
|
||||
It is worth noting as well that starting from [Electron] v1.1.1, a new mechanism was introduced to allow IPC in App Sandbox (see [electron#5601](https://github.com/electron/electron/pull/5601)); wish to have full support of legacy Electron versions, please utilize `opts.version`, which option brings less hassle with making default settings among Electron builds.
|
||||
|
||||
We are trying to keep updated to the latest [Electron] specs; please [file us an issue](https://github.com/electron-userland/electron-osx-sign/issues/new) if having any suggestions or experiencing difficulties code signing your products.
|
||||
|
||||
### 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.
|
||||
|
||||
### Collaborators
|
||||
|
||||
Thanks to [seanchas116](https://github.com/seanchas116), [jasonhinkle](https://github.com/jasonhinkle), and [develar](https://github.com/develar) for improving the usability of this project implementation.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
# For use in npm scripts
|
||||
npm install --save electron-osx-sign
|
||||
```
|
||||
|
||||
```sh
|
||||
# For use from CLI
|
||||
npm install -g electron-osx-sign
|
||||
```
|
||||
|
||||
*Note: `electron-osx-sign` is a dependency of `electron-packager` as of 6.0.0 for signing apps on macOS. However, feel free to install this package globally for more customization beyond specifying identity and entitlements.*
|
||||
|
||||
## Usage
|
||||
|
||||
### electron-osx-sign
|
||||
|
||||
#### From the Command Line
|
||||
|
||||
```sh
|
||||
electron-osx-sign app [embedded-binary ...] [options ...]
|
||||
```
|
||||
|
||||
##### Examples
|
||||
|
||||
Since `electron-osx-sign` adds the entry `com.apple.developer.team-identifier` to a temporary copy of the specified entitlements file (with the default option `--pre-auto-entitlements`) distribution builds can no longer be run directly. To run the app codesigned for distribution locally after codesigning, you may manually add `ElectronTeamID` in your `Info.plist` and `com.apple.security.application-groups` in the entitlements file, and provide the flag `--no-pre-auto-entitlements` for `electron-osx-sign` to avoid this extra bit. Note that "certain features are only allowed across apps whose team-identifier value match" ([Technical Note TN2415](https://developer.apple.com/library/content/technotes/tn2415/_index.html#//apple_ref/doc/uid/DTS40016427-CH1-ENTITLEMENTSLIST)).
|
||||
|
||||
The examples below assume that `--pre-auto-entitlements` is enabled.
|
||||
|
||||
- To sign a distribution version by default:
|
||||
```sh
|
||||
electron-osx-sign path/to/my.app
|
||||
```
|
||||
For distribution in the Mac App Store: Have the provisioning profile for distribution placed in the current working directory and the signing identity installed in the default keychain. *The app is not expected to run after codesigning since there is no provisioned device, and it is intended only for submission to iTunes Connect.*
|
||||
For distribution outside the Mac App Store: Have the signing identity for distribution installed in the default keychain and optionally place the provisioning profile in the current working directory. By default App Sandbox is not enabled. *The app should run on all devices.*
|
||||
|
||||
- To sign development version:
|
||||
```sh
|
||||
electron-osx-sign path/to/my.app --type=development
|
||||
```
|
||||
For testing Mac App Store builds: Have the provisioning profile for development placed in the current working directory and the signing identity installed in the default keychain. *The app will only run on provisioned devices.*
|
||||
For testing apps for distribution outside the Mac App Store, have the signing identity for development installed in the default keychain and optionally the provisioning profile placed in the current working directory. *The app will only run on provisioned devices.* However, you may prefer to just go with signing a distribution version because the app is expected to launch properly after codesigned.
|
||||
|
||||
- It is recommended to place the provisioning profile(s) under the working directory for `electron-osx-sign` to pick up automatically; however, to specify provisioning profile to be embedded explicitly:
|
||||
```sh
|
||||
electron-osx-sign path/to/my.app --provisioning-profile=path/to/my.provisionprofile
|
||||
```
|
||||
|
||||
- To specify the entitlements file:
|
||||
```sh
|
||||
electron-osx-sign path/to/my.app --entitlements=path/to/my.entitlements
|
||||
```
|
||||
|
||||
- It is recommended to make use of `--version` while signing legacy versions of Electron:
|
||||
```sh
|
||||
electron-osx-sign path/to/my.app --version=0.34.0
|
||||
```
|
||||
|
||||
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) for CLI-specific options.
|
||||
|
||||
#### From the API
|
||||
|
||||
```javascript
|
||||
var sign = require('electron-osx-sign')
|
||||
sign(opts[, function done (err) {}])
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
var sign = require('electron-osx-sign')
|
||||
sign({
|
||||
app: 'path/to/my.app'
|
||||
}, function done (err) {
|
||||
if (err) {
|
||||
// Handle the error
|
||||
return;
|
||||
}
|
||||
// Application signed
|
||||
})
|
||||
```
|
||||
|
||||
From release v0.4.0-beta, [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'
|
||||
})
|
||||
.then(function () {
|
||||
// Application signed
|
||||
})
|
||||
.catch(function (err) {
|
||||
// Handle the error
|
||||
})
|
||||
```
|
||||
|
||||
###### opts - Options
|
||||
|
||||
**Required**
|
||||
|
||||
`app` - *String*
|
||||
|
||||
Path to the application package.
|
||||
Needs file extension `.app`.
|
||||
|
||||
**Optional**
|
||||
|
||||
`binaries` - *Array*
|
||||
|
||||
Path to additional binaries that will be signed along with built-ins of Electron.
|
||||
Default to `undefined`.
|
||||
|
||||
`entitlements` - *String*
|
||||
|
||||
Path to entitlements file for signing the app.
|
||||
Default to built-in entitlements file, Sandbox enabled for Mac App Store platform.
|
||||
See [default.entitlements.mas.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.plist) or [default.entitlements.darwin.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.darwin.plist) with respect to your platform.
|
||||
|
||||
`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.*
|
||||
See [default.entitlements.mas.inherit.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.inherit.plist) or [default.entitlements.darwin.inherit.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.darwin.inherit.plist) with respect to your platform.
|
||||
|
||||
`gatekeeper-assess` - *Boolean*
|
||||
|
||||
Flag to enable/disable Gatekeeper assessment after signing the app. Disabling it is useful for signing with self-signed certificates.
|
||||
Gatekeeper assessment is enabled by default on `darwin` platform.
|
||||
Default to `true`.
|
||||
|
||||
`identity` - *String*
|
||||
|
||||
Name of certificate to use when signing.
|
||||
Default to be selected with respect to `provisioning-profile` and `platform` from `keychain` or keychain by system default.
|
||||
|
||||
Signing platform `mas` will look for `3rd Party Mac Developer Application: * (*)`, and platform `darwin` will look for `Developer ID Application: * (*)` by default.
|
||||
|
||||
`identity-validation` - *Boolean*
|
||||
|
||||
Flag to enable/disable validation for the signing identity. If enabled, the `identity` provided will be validated in the `keychain` specified.
|
||||
Default to `true`.
|
||||
|
||||
`keychain` - *String*
|
||||
|
||||
The keychain name.
|
||||
Default to system default keychain.
|
||||
|
||||
`ignore` - *RegExp|Function|Array.<(RegExp|Function)>*
|
||||
|
||||
Regex, function or an array of regex's and functions that signal skipping signing a file.
|
||||
Elements of other types are treated as `RegExp`.
|
||||
Default to `undefined`.
|
||||
|
||||
`platform` - *String*
|
||||
|
||||
Build platform of Electron.
|
||||
Allowed values: `darwin`, `mas`.
|
||||
Default to auto detect by presence of `Squirrel.framework` within the application bundle.
|
||||
|
||||
`pre-auto-entitlements` - *Boolean*
|
||||
|
||||
Flag to enable/disable automation of `com.apple.security.application-groups` in entitlements file and update `Info.plist` with `ElectronTeamID`.
|
||||
Default to `true`.
|
||||
|
||||
`pre-embed-provisioning-profile` - *Boolean*
|
||||
|
||||
Flag to enable/disable embedding of provisioning profile in the current working directory.
|
||||
Default to `true`.
|
||||
|
||||
`provisioning-profile` - *String*
|
||||
|
||||
Path to provisioning profile.
|
||||
|
||||
`requirements` - *String*
|
||||
|
||||
Specify the criteria that you recommend to be used to evaluate the code signature.
|
||||
See more info from https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html
|
||||
Default to `undefined`.
|
||||
|
||||
`strict-verify` - *Boolean|String|Array.<String>*
|
||||
|
||||
Flag to enable/disable `--strict` flag when verifying the signed application bundle.
|
||||
If provided as a string, each component should be separated with comma (`,`).
|
||||
If provided as an array, each item should be a string corresponding to a component.
|
||||
Default to `true`.
|
||||
|
||||
`timestamp` - *String*
|
||||
|
||||
Specify the URL of the timestamp authority server, default to server provided by Apple. Please note that this default server may not support signatures not furnished by Apple.
|
||||
Disable the timestamp service with `none`.
|
||||
|
||||
`type` - *String*
|
||||
|
||||
Specify whether to sign app for development or for distribution.
|
||||
Allowed values: `development`, `distribution`.
|
||||
Default to `distribution`.
|
||||
|
||||
`version` - *String*
|
||||
|
||||
Build version of Electron.
|
||||
Values may be like: `1.1.1`, `1.2.0`.
|
||||
Default to latest Electron version.
|
||||
|
||||
It is recommended to utilize this option for best support of specific Electron versions. This may trigger pre/post operations for signing: For example, automation of setting `com.apple.security.application-groups` in entitlements file and of updating `Info.plist` with `ElectronTeamID` is enabled for all versions starting from `1.1.1`; set `pre-auto-entitlements` option to `false` to disable this feature.
|
||||
|
||||
###### cb - Callback
|
||||
|
||||
`err` - *Error*
|
||||
|
||||
### electron-osx-flat
|
||||
|
||||
#### From the Command Line
|
||||
|
||||
```sh
|
||||
electron-osx-flat app [options ...]
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
electron-osx-flat path/to/my.app
|
||||
```
|
||||
|
||||
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) for CLI-specific options.
|
||||
|
||||
#### 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;
|
||||
}
|
||||
// Application flattened
|
||||
})
|
||||
```
|
||||
|
||||
From release v0.4.0-beta, [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'
|
||||
})
|
||||
.then(function () {
|
||||
// Application flattened
|
||||
})
|
||||
.catch(function (err) {
|
||||
// Handle the error
|
||||
})
|
||||
```
|
||||
|
||||
###### opts - Options
|
||||
|
||||
**Required**
|
||||
|
||||
`app` - *String*
|
||||
|
||||
Path to the application bundle.
|
||||
Needs file extension `.app`.
|
||||
|
||||
**Optional**
|
||||
|
||||
`identity` - *String*
|
||||
|
||||
Name of certificate to use when signing.
|
||||
Default to be selected with respect to `platform` from `keychain` or keychain by system default.
|
||||
|
||||
Flattening platform `mas` will look for `3rd Party Mac Developer Installer: * (*)`, and platform `darwin` will look for `Developer ID Installer: * (*)` by default.
|
||||
|
||||
`identity-validation` - *Boolean*
|
||||
|
||||
Flag to enable/disable validation for signing identity. If enabled, the `identity` provided will be validated in the `keychain` specified.
|
||||
Default to `true`.
|
||||
|
||||
`install` - *String*
|
||||
|
||||
Path to install the bundle.
|
||||
Default to `/Applications`.
|
||||
|
||||
`keychain` - *String*
|
||||
|
||||
The keychain name.
|
||||
Default to system default keychain.
|
||||
|
||||
`platform` - *String*
|
||||
|
||||
Build platform of Electron. Allowed values: `darwin`, `mas`.
|
||||
Default to auto detect by presence of `Squirrel.framework` within the application bundle.
|
||||
|
||||
`pkg` - *String*
|
||||
|
||||
Path to the output the flattened package.
|
||||
Needs file extension `.pkg`.
|
||||
|
||||
`scripts` - *String*
|
||||
Path to a directory containing pre and/or post install scripts.
|
||||
|
||||
###### cb - Callback
|
||||
|
||||
`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.
|
||||
|
||||
## Test
|
||||
|
||||
As developer certificates are required for `codesign` on macOS, this module is difficult to 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 macOS 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
|
||||
|
||||
> electron-osx-sign@0.4.10 pretest electron-osx-sign
|
||||
> rimraf test/work
|
||||
|
||||
> electron-osx-sign@0.4.10 test electron-osx-sign
|
||||
> standard && tape test
|
||||
|
||||
Calling electron-download before running tests...
|
||||
Running tests...
|
||||
TAP version 13
|
||||
# setup
|
||||
# defaults-test:v0.29.2-darwin-x64
|
||||
ok 1 app signed
|
||||
# defaults-test:v0.30.8-darwin-x64
|
||||
ok 2 app signed
|
||||
# defaults-test:v0.31.2-darwin-x64
|
||||
ok 3 app signed
|
||||
# defaults-test:v0.32.3-darwin-x64
|
||||
ok 4 app signed
|
||||
# defaults-test:v0.33.9-darwin-x64
|
||||
ok 5 app signed
|
||||
# defaults-test:v0.34.5-darwin-x64
|
||||
ok 6 app signed
|
||||
# defaults-test:v0.34.5-mas-x64
|
||||
ok 7 app signed
|
||||
# defaults-test:v0.35.6-darwin-x64
|
||||
ok 8 app signed
|
||||
# defaults-test:v0.35.6-mas-x64
|
||||
ok 9 app signed
|
||||
# defaults-test:v0.36.12-darwin-x64
|
||||
ok 10 app signed
|
||||
# defaults-test:v0.36.12-mas-x64
|
||||
ok 11 app signed
|
||||
# defaults-test:v0.37.8-darwin-x64
|
||||
ok 12 app signed
|
||||
# defaults-test:v0.37.8-mas-x64
|
||||
ok 13 app signed
|
||||
# defaults-test:v1.0.2-darwin-x64
|
||||
ok 14 app signed
|
||||
# defaults-test:v1.0.2-mas-x64
|
||||
ok 15 app signed
|
||||
# defaults-test:v1.1.3-darwin-x64
|
||||
ok 16 app signed
|
||||
# defaults-test:v1.1.3-mas-x64
|
||||
ok 17 app signed
|
||||
# defaults-test:v1.2.8-darwin-x64
|
||||
ok 18 app signed
|
||||
# defaults-test:v1.2.8-mas-x64
|
||||
ok 19 app signed
|
||||
# defaults-test:v1.3.7-darwin-x64
|
||||
ok 20 app signed
|
||||
# defaults-test:v1.3.7-mas-x64
|
||||
ok 21 app signed
|
||||
# defaults-test:v1.4.15-darwin-x64
|
||||
ok 22 app signed
|
||||
# defaults-test:v1.4.15-mas-x64
|
||||
ok 23 app signed
|
||||
# defaults-test:v1.6.17-darwin-x64
|
||||
ok 24 app signed
|
||||
# defaults-test:v1.6.17-mas-x64
|
||||
ok 25 app signed
|
||||
# defaults-test:v1.7.12-darwin-x64
|
||||
ok 26 app signed
|
||||
# defaults-test:v1.7.12-mas-x64
|
||||
ok 27 app signed
|
||||
# defaults-test:v1.8.3-darwin-x64
|
||||
ok 28 app signed
|
||||
# defaults-test:v1.8.3-mas-x64
|
||||
ok 29 app signed
|
||||
# teardown
|
||||
|
||||
1..29
|
||||
# tests 29
|
||||
# pass 29
|
||||
|
||||
# ok
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [electron-packager] - Package your electron app in OS executables (.app, .exe, etc) via JS or CLI
|
||||
- [electron-builder] - A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
|
||||
|
||||
[Bluebird]: https://github.com/petkaantonov/bluebird
|
||||
[Electron]: https://github.com/electron/electron
|
||||
[electron-builder]: https://github.com/electron-userland/electron-builder
|
||||
[electron-packager]: https://github.com/electron-userland/electron-packager
|
||||
[electron-osx-sign]: https://github.com/electron-userland/electron-osx-sign
|
||||
[npm_img]: https://img.shields.io/npm/v/electron-osx-sign.svg
|
||||
[npm_url]: https://npmjs.org/package/electron-osx-sign
|
||||
[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
|
41
app/node_modules/electron-osx-sign/bin/electron-osx-flat-usage.txt
generated
vendored
Normal file
41
app/node_modules/electron-osx-sign/bin/electron-osx-flat-usage.txt
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
NAME
|
||||
electron-osx-flat -- product building for Electron apps
|
||||
|
||||
SYNOPSIS
|
||||
electron-osx-flat app [options ...]
|
||||
|
||||
DESCRIPTION
|
||||
app
|
||||
Path to the application package.
|
||||
Needs file extension ``.app''.
|
||||
|
||||
--help
|
||||
Flag to display all commands.
|
||||
|
||||
--identity=identity
|
||||
Name of certificate to use when signing.
|
||||
Default to selected with respect to --platform from --keychain specified or keychain by system default.
|
||||
|
||||
--identity-validation, --no-identity-validation
|
||||
Flag to enable/disable validation for the signing identity.
|
||||
|
||||
--install=install-path
|
||||
Path to install the bundle.
|
||||
Default to ``/Applications''.
|
||||
|
||||
--keychain=keychain
|
||||
The keychain name.
|
||||
Default to system default keychain.
|
||||
|
||||
--platform=platform
|
||||
Build platform of Electron.
|
||||
Allowed values: ``darwin'', ``mas''.
|
||||
Default to auto detect from application bundle.
|
||||
|
||||
--pkg
|
||||
Path to the output the flattened package.
|
||||
Needs file extension ``.pkg''.
|
||||
|
||||
--scripts
|
||||
Path to a directory containing pre and/or post install scripts.
|
34
app/node_modules/electron-osx-sign/bin/electron-osx-flat.js
generated
vendored
Normal file
34
app/node_modules/electron-osx-sign/bin/electron-osx-flat.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var args = require('minimist')(process.argv.slice(2), {
|
||||
'boolean': [
|
||||
'help'
|
||||
]
|
||||
})
|
||||
var usage = fs.readFileSync(path.join(__dirname, 'electron-osx-flat-usage.txt')).toString()
|
||||
var flat = require('../').flat
|
||||
|
||||
args.app = args._.shift()
|
||||
|
||||
if (!args.app || args.help) {
|
||||
console.log(usage)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
// Remove excess arguments
|
||||
delete args._
|
||||
delete args.help
|
||||
|
||||
flat(args, function done (err) {
|
||||
if (err) {
|
||||
console.error('Flat failed:')
|
||||
if (err.message) console.error(err.message)
|
||||
else if (err.stack) console.error(err.stack)
|
||||
else console.log(err)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Application flattened, saved to:', args.pkg)
|
||||
process.exit(0)
|
||||
})
|
79
app/node_modules/electron-osx-sign/bin/electron-osx-sign-usage.txt
generated
vendored
Normal file
79
app/node_modules/electron-osx-sign/bin/electron-osx-sign-usage.txt
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
NAME
|
||||
electron-osx-sign -- code signing for Electron apps
|
||||
|
||||
SYNOPSIS
|
||||
electron-osx-sign app [embedded-binary ...] [options ...]
|
||||
|
||||
DESCRIPTION
|
||||
app
|
||||
Path to the application package.
|
||||
Needs file extension ``.app''.
|
||||
|
||||
embedded-binary ...
|
||||
Path to additional binaries that will be signed along with built-ins of Electron, spaced.
|
||||
|
||||
--entitlements=file
|
||||
Path to entitlements file for signing the app.
|
||||
Default to built-in entitlements file, Sandbox enabled for Mac App Store platform.
|
||||
|
||||
--entitlements-inherit=file
|
||||
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.
|
||||
|
||||
--gatekeeper-assess, --no-gatekeeper-assess
|
||||
Flag to enable/disable Gatekeeper assessment after signing the app. Disabling it is useful for signing with self-signed certificates.
|
||||
Gatekeeper assessment is enabled by default on ``darwin'' platform.
|
||||
|
||||
--help
|
||||
Flag to display all commands.
|
||||
|
||||
--identity=identity
|
||||
Name of certificate to use when signing.
|
||||
Default to selected with respect to --provisioning-profile and --platform from --keychain specified or keychain by system default.
|
||||
|
||||
--identity-validation, --no-identity-validation
|
||||
Flag to enable/disable validation for the signing identity.
|
||||
|
||||
--ignore=path
|
||||
Path to skip signing. The string will be treated as a regular expression when used to match the file paths.
|
||||
|
||||
--keychain=keychain
|
||||
The keychain name.
|
||||
Default to system default keychain.
|
||||
|
||||
--platform=platform
|
||||
Build platform of Electron.
|
||||
Allowed values: ``darwin'', ``mas''.
|
||||
Default to auto detect from application bundle.
|
||||
|
||||
--pre-auto-entitlements, --no-pre-auto-entitlements
|
||||
Flag to enable/disable automation of entitlements file and Info.plist.
|
||||
|
||||
--pre-embed-provisioning-profile, --no-pre-embed-provisioning-profile
|
||||
Flag to enable/disable embedding of provisioning profile.
|
||||
|
||||
--provisioning-profile=file
|
||||
Path to provisioning profile.
|
||||
|
||||
--requirements=requirements
|
||||
Specify the criteria that you recommend to be used to evaluate the code signature.
|
||||
|
||||
--strict-verify, --strict-verify=options, --no-strict-verify
|
||||
Flag to enable/disable ``--strict'' flag when verifying the signed application bundle.
|
||||
Each component should be separated in ``options'' with comma (``,'').
|
||||
Enabled by default.
|
||||
|
||||
--timestamp=timestamp
|
||||
Specify the URL of the timestamp authority server, default to server provided by Apple.
|
||||
Disable the timestamp service with ``none''.
|
||||
|
||||
--type=type
|
||||
Specify whether to sign app for development or for distribution.
|
||||
Allowed values: ``development'', ``distribution''.
|
||||
Default to ``distribution''.
|
||||
|
||||
--version=version
|
||||
Build version of Electron.
|
||||
Values may be: ``1.2.0''.
|
||||
Default to latest Electron version.
|
43
app/node_modules/electron-osx-sign/bin/electron-osx-sign.js
generated
vendored
Normal file
43
app/node_modules/electron-osx-sign/bin/electron-osx-sign.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var args = require('minimist')(process.argv.slice(2), {
|
||||
'boolean': [
|
||||
'help',
|
||||
'pre-auto-entitlements',
|
||||
'pre-embed-provisioning-profile',
|
||||
'gatekeeper-assess'
|
||||
],
|
||||
'default': {
|
||||
'pre-auto-entitlements': true,
|
||||
'pre-embed-provisioning-profile': true,
|
||||
'gatekeeper-assess': true
|
||||
}
|
||||
})
|
||||
var usage = fs.readFileSync(path.join(__dirname, 'electron-osx-sign-usage.txt')).toString()
|
||||
var sign = require('../').sign
|
||||
|
||||
args.app = args._.shift()
|
||||
args.binaries = args._
|
||||
|
||||
if (!args.app || args.help) {
|
||||
console.log(usage)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
// Remove excess arguments
|
||||
delete args._
|
||||
delete args.help
|
||||
|
||||
sign(args, function done (err) {
|
||||
if (err) {
|
||||
console.error('Sign failed:')
|
||||
if (err.message) console.error(err.message)
|
||||
else if (err.stack) console.error(err.stack)
|
||||
else console.log(err)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Application signed:', args.app)
|
||||
process.exit(0)
|
||||
})
|
6
app/node_modules/electron-osx-sign/default.entitlements.darwin.inherit.plist
generated
vendored
Normal file
6
app/node_modules/electron-osx-sign/default.entitlements.darwin.inherit.plist
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?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>
|
||||
</dict>
|
||||
</plist>
|
6
app/node_modules/electron-osx-sign/default.entitlements.darwin.plist
generated
vendored
Normal file
6
app/node_modules/electron-osx-sign/default.entitlements.darwin.plist
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?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>
|
||||
</dict>
|
||||
</plist>
|
10
app/node_modules/electron-osx-sign/default.entitlements.mas.inherit.plist
generated
vendored
Normal file
10
app/node_modules/electron-osx-sign/default.entitlements.mas.inherit.plist
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?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>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.inherit</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
8
app/node_modules/electron-osx-sign/default.entitlements.mas.plist
generated
vendored
Normal file
8
app/node_modules/electron-osx-sign/default.entitlements.mas.plist
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?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>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
155
app/node_modules/electron-osx-sign/flat.js
generated
vendored
Normal file
155
app/node_modules/electron-osx-sign/flat.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* @module flat
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const Promise = require('bluebird')
|
||||
|
||||
const pkg = require('./package.json')
|
||||
const util = require('./util')
|
||||
const debuglog = util.debuglog
|
||||
const debugwarn = util.debugwarn
|
||||
const execFileAsync = util.execFileAsync
|
||||
const validateOptsAppAsync = util.validateOptsAppAsync
|
||||
const validateOptsPlatformAsync = util.validateOptsPlatformAsync
|
||||
const Identity = require('./util-identities').findIdentitiesAsync
|
||||
const findIdentitiesAsync = require('./util-identities').findIdentitiesAsync
|
||||
|
||||
/**
|
||||
* This function returns a promise validating all options passed in opts.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
function validateFlatOptsAsync (opts) {
|
||||
if (opts.pkg) {
|
||||
if (typeof opts.pkg !== 'string') return Promise.reject(new Error('`pkg` must be a string.'))
|
||||
if (path.extname(opts.pkg) !== '.pkg') return Promise.reject(new Error('Extension of output package must be `.pkg`.'))
|
||||
} else {
|
||||
debugwarn('No `pkg` passed in arguments, will fallback to default inferred from the given application.')
|
||||
opts.pkg = path.join(path.dirname(opts.app), path.basename(opts.app, '.app') + '.pkg')
|
||||
}
|
||||
|
||||
if (opts.install) {
|
||||
if (typeof opts.install !== 'string') return Promise.reject(new Error('`install` must be a string.'))
|
||||
} else {
|
||||
debugwarn('No `install` passed in arguments, will fallback to default `/Applications`.')
|
||||
opts.install = '/Applications'
|
||||
}
|
||||
|
||||
return Promise.map([
|
||||
validateOptsAppAsync,
|
||||
validateOptsPlatformAsync
|
||||
], function (validate) {
|
||||
return validate(opts)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise flattening the application.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
function flatApplicationAsync (opts) {
|
||||
var args = [
|
||||
'--component', opts.app, opts.install,
|
||||
'--sign', opts.identity.name,
|
||||
opts.pkg
|
||||
]
|
||||
if (opts.keychain) {
|
||||
args.unshift('--keychain', opts.keychain)
|
||||
}
|
||||
if (opts.scripts) {
|
||||
args.unshift('--scripts', opts.scripts)
|
||||
}
|
||||
|
||||
debuglog('Flattening... ' + opts.app)
|
||||
return execFileAsync('productbuild', args)
|
||||
.thenReturn(undefined)
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is exported and returns a promise flattening the application.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
var flatAsync = module.exports.flatAsync = function (opts) {
|
||||
debuglog('electron-osx-sign@%s', pkg.version)
|
||||
return validateFlatOptsAsync(opts)
|
||||
.then(function () {
|
||||
var promise
|
||||
if (opts.identity) {
|
||||
debuglog('`identity` passed in arguments.')
|
||||
if (opts['identity-validation'] === false || opts.identity instanceof Identity) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
promise = findIdentitiesAsync(opts, opts.identity)
|
||||
} else {
|
||||
debugwarn('No `identity` passed in arguments...')
|
||||
if (opts.platform === 'mas') {
|
||||
debuglog('Finding `3rd Party Mac Developer Installer` certificate for flattening app distribution in the Mac App Store...')
|
||||
promise = findIdentitiesAsync(opts, '3rd Party Mac Developer Installer:')
|
||||
} else {
|
||||
debuglog('Finding `Developer ID Application` certificate for distribution outside the Mac App Store...')
|
||||
promise = findIdentitiesAsync(opts, 'Developer ID Installer:')
|
||||
}
|
||||
}
|
||||
return promise
|
||||
.then(function (identities) {
|
||||
if (identities.length > 0) {
|
||||
// Provisioning profile(s) found
|
||||
if (identities.length > 1) {
|
||||
debugwarn('Multiple identities found, will use the first discovered.')
|
||||
} else {
|
||||
debuglog('Found 1 identity.')
|
||||
}
|
||||
opts.identity = identities[0]
|
||||
} else {
|
||||
// No identity found
|
||||
return Promise.reject(new Error('No identity found for signing.'))
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(function () {
|
||||
// Pre-flat operations
|
||||
})
|
||||
.then(function () {
|
||||
debuglog('Flattening application...', '\n',
|
||||
'> Application:', opts.app, '\n',
|
||||
'> Package output:', opts.pkg, '\n',
|
||||
'> Install path:', opts.install, '\n',
|
||||
'> Identity:', opts.identity, '\n',
|
||||
'> Scripts:', opts.scripts)
|
||||
return flatApplicationAsync(opts)
|
||||
})
|
||||
.then(function () {
|
||||
// Post-flat operations
|
||||
debuglog('Application flattened.')
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is exported with normal callback implementation.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @param {RequestCallback} cb - Callback.
|
||||
*/
|
||||
module.exports.flat = function (opts, cb) {
|
||||
flatAsync(opts)
|
||||
.then(function () {
|
||||
debuglog('Application flattened, saved to: ' + opts.app)
|
||||
if (cb) cb()
|
||||
})
|
||||
.catch(function (err) {
|
||||
debuglog('Flat failed:')
|
||||
if (err.message) debuglog(err.message)
|
||||
else if (err.stack) debuglog(err.stack)
|
||||
else debuglog(err)
|
||||
if (cb) cb(err)
|
||||
})
|
||||
}
|
37
app/node_modules/electron-osx-sign/index.d.ts
generated
vendored
Normal file
37
app/node_modules/electron-osx-sign/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
declare module "electron-osx-sign" {
|
||||
interface BaseSignOptions {
|
||||
app: string;
|
||||
identity?: string;
|
||||
platform?: string;
|
||||
keychain?: string;
|
||||
}
|
||||
|
||||
interface SignOptions extends BaseSignOptions {
|
||||
binaries?: string[];
|
||||
entitlements?: string;
|
||||
'entitlements-inherit'?: string;
|
||||
'gatekeeper-assess'?: boolean;
|
||||
ignore?: string;
|
||||
'pre-auto-entitlements'?: boolean;
|
||||
'pre-embed-provisioning-profile'?: boolean;
|
||||
'provisioning-profile'?: string;
|
||||
'requirements'?: string;
|
||||
'type'?: string;
|
||||
version?: string;
|
||||
'identity-validation'?: boolean;
|
||||
}
|
||||
|
||||
export function sign(opts: SignOptions, callback: (error: Error) => void): void;
|
||||
|
||||
export function signAsync(opts: SignOptions): Promise<any>;
|
||||
|
||||
interface FlatOptions extends BaseSignOptions {
|
||||
install?: string;
|
||||
pkg?: string;
|
||||
scripts?: string;
|
||||
}
|
||||
|
||||
export function flat(opts: FlatOptions, callback: (error: Error) => void): void;
|
||||
|
||||
export function flatAsync(opts: FlatOptions): Promise<any>;
|
||||
}
|
47
app/node_modules/electron-osx-sign/index.js
generated
vendored
Normal file
47
app/node_modules/electron-osx-sign/index.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @module electron-osx-sign
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const sign = require('./sign')
|
||||
const flat = require('./flat')
|
||||
|
||||
/**
|
||||
* This function is a normal callback implementation.
|
||||
* @param {Object} opts - Options.
|
||||
* @param {RequestCallback} cb - Callback.
|
||||
*/
|
||||
module.exports = sign.sign // Aliasing
|
||||
|
||||
/**
|
||||
* This function is a normal callback implementation.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @param {RequestCallback} cb - Callback.
|
||||
*/
|
||||
module.exports.sign = sign.sign
|
||||
|
||||
/**
|
||||
* This function returns a promise signing the application.
|
||||
* @function
|
||||
* @param {mixed} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.signAsync = sign.signAsync
|
||||
|
||||
/**
|
||||
* This function is exported with normal callback implementation.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @param {RequestCallback} cb - Callback.
|
||||
*/
|
||||
module.exports.flat = flat.flat
|
||||
|
||||
/**
|
||||
* This function is exported and returns a promise flattening the application.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.flatAsync = flat.flatAsync
|
80
app/node_modules/electron-osx-sign/package.json
generated
vendored
Normal file
80
app/node_modules/electron-osx-sign/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"_from": "electron-osx-sign@^0.4.1",
|
||||
"_id": "electron-osx-sign@0.4.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-vk87ibKnWh3F8eckkIGrKSnKOiY=",
|
||||
"_location": "/electron-osx-sign",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "electron-osx-sign@^0.4.1",
|
||||
"name": "electron-osx-sign",
|
||||
"escapedName": "electron-osx-sign",
|
||||
"rawSpec": "^0.4.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.4.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/electron-packager"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/electron-osx-sign/-/electron-osx-sign-0.4.10.tgz",
|
||||
"_shasum": "be4f3b89b2a75a1dc5f1e7249081ab2929ca3a26",
|
||||
"_spec": "electron-osx-sign@^0.4.1",
|
||||
"_where": "E:\\projects\\p\\gitlit\\app\\node_modules\\electron-packager",
|
||||
"author": {
|
||||
"name": "sethlu"
|
||||
},
|
||||
"bin": {
|
||||
"electron-osx-flat": "bin/electron-osx-flat.js",
|
||||
"electron-osx-sign": "bin/electron-osx-sign.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/electron-userland/electron-osx-sign/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"bluebird": "^3.5.0",
|
||||
"compare-version": "^0.1.2",
|
||||
"debug": "^2.6.8",
|
||||
"isbinaryfile": "^3.0.2",
|
||||
"minimist": "^1.2.0",
|
||||
"plist": "^2.1.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Codesign Electron macOS apps",
|
||||
"devDependencies": {
|
||||
"electron-download": "^4.1.0",
|
||||
"eslint": "^4.2.0",
|
||||
"eslint-config-eslint": "^4.0.0",
|
||||
"extract-zip": "^1.6.5",
|
||||
"mkdirp": "^0.5.1",
|
||||
"rimraf": "^2.6.1",
|
||||
"run-series": "^1.1.4",
|
||||
"run-waterfall": "^1.1.3",
|
||||
"standard": "^10.0.2",
|
||||
"tape": "^4.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/electron-userland/electron-osx-sign",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "index.js",
|
||||
"name": "electron-osx-sign",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/electron-userland/electron-osx-sign.git"
|
||||
},
|
||||
"scripts": {
|
||||
"code-standard": "standard",
|
||||
"pretest": "rimraf test/work",
|
||||
"test": "standard && tape test"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"test/work"
|
||||
]
|
||||
},
|
||||
"version": "0.4.10"
|
||||
}
|
378
app/node_modules/electron-osx-sign/sign.js
generated
vendored
Normal file
378
app/node_modules/electron-osx-sign/sign.js
generated
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
/**
|
||||
* @module sign
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const compareVersion = require('compare-version')
|
||||
|
||||
const pkg = require('./package.json')
|
||||
const util = require('./util')
|
||||
const debuglog = util.debuglog
|
||||
const debugwarn = util.debugwarn
|
||||
const getAppContentsPath = util.getAppContentsPath
|
||||
const execFileAsync = util.execFileAsync
|
||||
const validateOptsAppAsync = util.validateOptsAppAsync
|
||||
const validateOptsPlatformAsync = util.validateOptsPlatformAsync
|
||||
const walkAsync = util.walkAsync
|
||||
const Identity = require('./util-identities').Identity
|
||||
const findIdentitiesAsync = require('./util-identities').findIdentitiesAsync
|
||||
const ProvisioningProfile = require('./util-provisioning-profiles').ProvisioningProfile
|
||||
const preEmbedProvisioningProfile = require('./util-provisioning-profiles').preEmbedProvisioningProfile
|
||||
const preAutoEntitlements = require('./util-entitlements').preAutoEntitlements
|
||||
|
||||
/**
|
||||
* This function returns a promise validating opts.binaries, the additional binaries to be signed along with the discovered enclosed components.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
function validateOptsBinariesAsync (opts) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (opts.binaries) {
|
||||
if (!Array.isArray(opts.binaries)) {
|
||||
reject(new Error('Additional binaries should be an Array.'))
|
||||
return
|
||||
}
|
||||
// TODO: Presence check for binary files, reject if any does not exist
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise validating all options passed in opts.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
function validateSignOptsAsync (opts) {
|
||||
if (opts.ignore && !(opts.ignore instanceof Array)) {
|
||||
opts.ignore = [opts.ignore]
|
||||
}
|
||||
|
||||
if (opts['provisioning-profile']) {
|
||||
if (typeof opts['provisioning-profile'] !== 'string' && !(opts['provisioning-profile'] instanceof ProvisioningProfile)) return Promise.reject(new Error('Path to provisioning profile should be a string or a ProvisioningProfile object.'))
|
||||
}
|
||||
|
||||
if (opts['type']) {
|
||||
if (opts['type'] !== 'development' && opts['type'] !== 'distribution') return Promise.reject(new Error('Type must be either `development` or `distribution`.'))
|
||||
} else {
|
||||
opts['type'] = 'distribution'
|
||||
}
|
||||
|
||||
return Promise.map([
|
||||
validateOptsAppAsync,
|
||||
validateOptsPlatformAsync,
|
||||
validateOptsBinariesAsync
|
||||
], function (validate) {
|
||||
return validate(opts)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise verifying the code sign of application bundle.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise resolving output.
|
||||
*/
|
||||
function verifySignApplicationAsync (opts) {
|
||||
// Verify with codesign
|
||||
var compareVersion = require('compare-version')
|
||||
var osRelease = require('os').release()
|
||||
debuglog('Verifying application bundle with codesign...')
|
||||
|
||||
var promise = execFileAsync('codesign', [
|
||||
'--verify',
|
||||
'--deep'
|
||||
]
|
||||
.concat(
|
||||
opts['strict-verify'] !== false &&
|
||||
compareVersion(osRelease, '15.0.0') >= 0 // Only pass strict flag in El Capitan and later
|
||||
? ['--strict' +
|
||||
(opts['strict-verify']
|
||||
? '=' + opts['strict-verify'] // Array should be converted to a comma separated string
|
||||
: '')]
|
||||
: [],
|
||||
['--verbose=2', opts.app]))
|
||||
|
||||
// Additionally test Gatekeeper acceptance for darwin platform
|
||||
if (opts.platform === 'darwin' && opts['gatekeeper-assess'] !== false) {
|
||||
promise = promise
|
||||
.then(function () {
|
||||
debuglog('Verifying Gatekeeper acceptance for darwin platform...')
|
||||
return execFileAsync('spctl', [
|
||||
'--assess',
|
||||
'--type', 'execute',
|
||||
'--verbose',
|
||||
'--ignore-cache',
|
||||
'--no-cache',
|
||||
opts.app
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
return promise
|
||||
.thenReturn()
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise codesigning only.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
function signApplicationAsync (opts) {
|
||||
return walkAsync(getAppContentsPath(opts))
|
||||
.then(function (childPaths) {
|
||||
function ignoreFilePath (opts, filePath) {
|
||||
if (opts.ignore) {
|
||||
return opts.ignore.some(function (ignore) {
|
||||
if (typeof ignore === 'function') {
|
||||
return ignore(filePath)
|
||||
}
|
||||
return filePath.match(ignore)
|
||||
})
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if (opts.binaries) childPaths = childPaths.concat(opts.binaries)
|
||||
|
||||
var args = [
|
||||
'--sign', opts.identity.hash || opts.identity.name,
|
||||
'--force'
|
||||
]
|
||||
if (opts.keychain) {
|
||||
args.push('--keychain', opts.keychain)
|
||||
}
|
||||
if (opts.requirements) {
|
||||
args.push('--requirements', opts.requirements)
|
||||
}
|
||||
if (opts.timestamp) {
|
||||
args.push('--timestamp=' + opts.timestamp)
|
||||
}
|
||||
|
||||
var promise
|
||||
if (opts.entitlements) {
|
||||
// Sign with entitlements
|
||||
promise = Promise.mapSeries(childPaths, function (filePath) {
|
||||
if (ignoreFilePath(opts, filePath)) {
|
||||
debuglog('Skipped... ' + filePath)
|
||||
return
|
||||
}
|
||||
debuglog('Signing... ' + filePath)
|
||||
return execFileAsync('codesign', args.concat('--entitlements', opts['entitlements-inherit'], filePath))
|
||||
})
|
||||
.then(function () {
|
||||
debuglog('Signing... ' + opts.app)
|
||||
return execFileAsync('codesign', args.concat('--entitlements', opts.entitlements, opts.app))
|
||||
})
|
||||
} else {
|
||||
// Otherwise normally
|
||||
promise = Promise.mapSeries(childPaths, function (filePath) {
|
||||
if (ignoreFilePath(opts, filePath)) {
|
||||
debuglog('Skipped... ' + filePath)
|
||||
return
|
||||
}
|
||||
debuglog('Signing... ' + filePath)
|
||||
return execFileAsync('codesign', args.concat(filePath))
|
||||
})
|
||||
.then(function () {
|
||||
debuglog('Signing... ' + opts.app)
|
||||
return execFileAsync('codesign', args.concat(opts.app))
|
||||
})
|
||||
}
|
||||
|
||||
return promise
|
||||
.then(function () {
|
||||
// Verify code sign
|
||||
debuglog('Verifying...')
|
||||
var promise = verifySignApplicationAsync(opts)
|
||||
.then(function (result) {
|
||||
debuglog('Verified.')
|
||||
})
|
||||
|
||||
// Check entitlements if applicable
|
||||
if (opts.entitlements) {
|
||||
promise = promise
|
||||
.then(function () {
|
||||
debuglog('Displaying entitlements...')
|
||||
return execFileAsync('codesign', [
|
||||
'--display',
|
||||
'--entitlements', ':-', // Write to standard output and strip off the blob header
|
||||
opts.app
|
||||
])
|
||||
})
|
||||
.then(function (result) {
|
||||
debuglog('Entitlements:', '\n',
|
||||
result)
|
||||
})
|
||||
}
|
||||
|
||||
return promise
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise signing the application.
|
||||
* @function
|
||||
* @param {mixed} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
var signAsync = module.exports.signAsync = function (opts) {
|
||||
debuglog('electron-osx-sign@%s', pkg.version)
|
||||
return validateSignOptsAsync(opts)
|
||||
.then(function () {
|
||||
// Determine identity for signing
|
||||
var promise
|
||||
if (opts.identity) {
|
||||
debuglog('`identity` passed in arguments.')
|
||||
if (opts['identity-validation'] === false) {
|
||||
if (!(opts.identity instanceof Identity)) {
|
||||
opts.identity = new Identity(opts.identity)
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
promise = findIdentitiesAsync(opts, opts.identity)
|
||||
} else {
|
||||
debugwarn('No `identity` passed in arguments...')
|
||||
if (opts.platform === 'mas') {
|
||||
if (opts.type === 'distribution') {
|
||||
debuglog('Finding `3rd Party Mac Developer Application` certificate for signing app distribution in the Mac App Store...')
|
||||
promise = findIdentitiesAsync(opts, '3rd Party Mac Developer Application:')
|
||||
} else {
|
||||
debuglog('Finding `Mac Developer` certificate for signing app in development for the Mac App Store signing...')
|
||||
promise = findIdentitiesAsync(opts, 'Mac Developer:')
|
||||
}
|
||||
} else {
|
||||
debuglog('Finding `Developer ID Application` certificate for distribution outside the Mac App Store...')
|
||||
promise = findIdentitiesAsync(opts, 'Developer ID Application:')
|
||||
}
|
||||
}
|
||||
return promise
|
||||
.then(function (identities) {
|
||||
if (identities.length > 0) {
|
||||
// Identity(/ies) found
|
||||
if (identities.length > 1) {
|
||||
debugwarn('Multiple identities found, will use the first discovered.')
|
||||
} else {
|
||||
debuglog('Found 1 identity.')
|
||||
}
|
||||
opts.identity = identities[0]
|
||||
} else {
|
||||
// No identity found
|
||||
return Promise.reject(new Error('No identity found for signing.'))
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(function () {
|
||||
// Determine entitlements for code signing
|
||||
var filePath
|
||||
if (opts.platform === 'mas') {
|
||||
// To sign apps for Mac App Store, an entitlements file is required, especially for app sandboxing (as well some other services).
|
||||
// Fallback entitlements for sandboxing by default: Note this may cause troubles while running an signed app due to missing keys special to the project.
|
||||
// Further reading: https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html
|
||||
if (!opts.entitlements) {
|
||||
filePath = path.join(__dirname, 'default.entitlements.mas.plist')
|
||||
debugwarn('No `entitlements` passed in arguments:', '\n',
|
||||
'* Sandbox entitlements are required for Mac App Store distribution, your codesign entitlements file is default to:', filePath)
|
||||
opts.entitlements = filePath
|
||||
}
|
||||
if (!opts['entitlements-inherit']) {
|
||||
filePath = path.join(__dirname, 'default.entitlements.mas.inherit.plist')
|
||||
debugwarn('No `entitlements-inherit` passed in arguments:', '\n',
|
||||
'* Sandbox entitlements file for enclosing app files is default to:', filePath)
|
||||
opts['entitlements-inherit'] = filePath
|
||||
}
|
||||
} else {
|
||||
// Not necessary to have entitlements for non Mac App Store distribution
|
||||
if (!opts.entitlements) {
|
||||
debugwarn('No `entitlements` passed in arguments:', '\n',
|
||||
'* Provide `entitlements` to specify entitlements file for codesign.')
|
||||
} else {
|
||||
// If entitlements is provided as a flag, fallback to default
|
||||
if (opts.entitlements === true) {
|
||||
filePath = path.join(__dirname, 'default.entitlements.darwin.plist')
|
||||
debugwarn('`entitlements` not specified in arguments:', '\n',
|
||||
'* Provide `entitlements` to specify entitlements file for codesign.', '\n',
|
||||
'* Sandbox entitlements file for enclosing app files is default to:', filePath)
|
||||
opts.entitlements = filePath
|
||||
}
|
||||
if (!opts['entitlements-inherit']) {
|
||||
filePath = path.join(__dirname, 'default.entitlements.darwin.inherit.plist')
|
||||
debugwarn('No `entitlements-inherit` passed in arguments:', '\n',
|
||||
'* Sandbox entitlements file for enclosing app files is default to:', filePath)
|
||||
opts['entitlements-inherit'] = filePath
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
// Pre-sign operations
|
||||
var preSignOperations = []
|
||||
|
||||
if (opts['pre-embed-provisioning-profile'] === false) {
|
||||
debugwarn('Pre-sign operation disabled for provisioning profile embedding:', '\n',
|
||||
'* Enable by setting `pre-embed-provisioning-profile` to `true`.')
|
||||
} else {
|
||||
debuglog('Pre-sign operation enabled for provisioning profile:', '\n',
|
||||
'* Disable by setting `pre-embed-previsioning-profile` to `false`.')
|
||||
preSignOperations.push(preEmbedProvisioningProfile)
|
||||
}
|
||||
|
||||
if (opts['pre-auto-entitlements'] === false) {
|
||||
debugwarn('Pre-sign operation disabled for entitlements automation.')
|
||||
} else {
|
||||
debuglog('Pre-sign operation enabled for entitlements automation with versions >= `1.1.1`:', '\n',
|
||||
'* Disable by setting `pre-auto-entitlements` to `false`.')
|
||||
if (opts.entitlements && (!opts.version || compareVersion(opts.version, '1.1.1') >= 0)) {
|
||||
// Enable Mac App Store sandboxing without using temporary-exception, introduced in Electron v1.1.1. Relates to electron#5601
|
||||
preSignOperations.push(preAutoEntitlements)
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.mapSeries(preSignOperations, function (preSignOperation) {
|
||||
return preSignOperation(opts)
|
||||
})
|
||||
})
|
||||
.then(function () {
|
||||
debuglog('Signing application...', '\n',
|
||||
'> Application:', opts.app, '\n',
|
||||
'> Platform:', opts.platform, '\n',
|
||||
'> Entitlements:', opts.entitlements, '\n',
|
||||
'> Child entitlements:', opts['entitlements-inherit'], '\n',
|
||||
'> Additional binaries:', opts.binaries, '\n',
|
||||
'> Identity:', opts.identity)
|
||||
return signApplicationAsync(opts)
|
||||
})
|
||||
.then(function () {
|
||||
// Post-sign operations
|
||||
debuglog('Application signed.')
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is a normal callback implementation.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @param {RequestCallback} cb - Callback.
|
||||
*/
|
||||
module.exports.sign = function (opts, cb) {
|
||||
signAsync(opts)
|
||||
.then(function () {
|
||||
debuglog('Application signed: ' + opts.app)
|
||||
if (cb) cb()
|
||||
})
|
||||
.catch(function (err) {
|
||||
debuglog('Sign failed:')
|
||||
if (err.message) debuglog(err.message)
|
||||
else if (err.stack) debuglog(err.stack)
|
||||
else debuglog(err)
|
||||
if (cb) cb(err)
|
||||
})
|
||||
}
|
29
app/node_modules/electron-osx-sign/test/basic.js
generated
vendored
Normal file
29
app/node_modules/electron-osx-sign/test/basic.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
var sign = require('..')
|
||||
|
||||
var waterfall = require('run-waterfall')
|
||||
|
||||
var config = require('./config')
|
||||
var util = require('./util')
|
||||
|
||||
function createDefaultsTest (release) {
|
||||
return function (t) {
|
||||
t.timeoutAfter(config.timeout)
|
||||
|
||||
var opts = {
|
||||
app: util.generateAppPath(release)
|
||||
} // test with no other options for self discovery
|
||||
|
||||
waterfall([
|
||||
function (cb) {
|
||||
sign(Object.create(opts), cb)
|
||||
}, function (cb) {
|
||||
t.pass('app signed')
|
||||
cb()
|
||||
}
|
||||
], function (err) {
|
||||
t.end(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
util.testAllReleases('defaults-test', createDefaultsTest)
|
23
app/node_modules/electron-osx-sign/test/config.json
generated
vendored
Normal file
23
app/node_modules/electron-osx-sign/test/config.json
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"_comment": "File last updated: 2018-03-06 08:47 UTC",
|
||||
"timeout": 60000,
|
||||
"versions": [
|
||||
"0.29.2",
|
||||
"0.30.8",
|
||||
"0.31.2",
|
||||
"0.32.3",
|
||||
"0.33.9",
|
||||
"0.34.5",
|
||||
"0.35.6",
|
||||
"0.36.12",
|
||||
"0.37.8",
|
||||
"1.0.2",
|
||||
"1.1.3",
|
||||
"1.2.8",
|
||||
"1.3.7",
|
||||
"1.4.15",
|
||||
"1.6.17",
|
||||
"1.7.12",
|
||||
"1.8.3"
|
||||
]
|
||||
}
|
28
app/node_modules/electron-osx-sign/test/index.js
generated
vendored
Normal file
28
app/node_modules/electron-osx-sign/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
var child = require('child_process')
|
||||
|
||||
var series = require('run-series')
|
||||
|
||||
var util = require('./util')
|
||||
|
||||
series([
|
||||
function (cb) {
|
||||
child.exec('which codesign', cb)
|
||||
},
|
||||
function (cb) {
|
||||
console.log('Calling electron-download before running tests...')
|
||||
util.downloadElectrons(cb)
|
||||
}
|
||||
], function (err) {
|
||||
if (err) {
|
||||
console.error('Test failed.')
|
||||
if (err.message) console.error(err.message)
|
||||
else console.error(err, err.stack)
|
||||
return
|
||||
}
|
||||
console.log('Running tests...')
|
||||
if (process.platform !== 'darwin') {
|
||||
console.error('Unable to perform tests on non-darwin platforms.')
|
||||
process.exit(1)
|
||||
}
|
||||
require('./basic')
|
||||
})
|
90
app/node_modules/electron-osx-sign/test/util.js
generated
vendored
Normal file
90
app/node_modules/electron-osx-sign/test/util.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
var path = require('path')
|
||||
var test = require('tape')
|
||||
|
||||
var download = require('electron-download')
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var series = require('run-series')
|
||||
var compareVersion = require('compare-version')
|
||||
var extract = require('extract-zip')
|
||||
|
||||
var config = require('./config')
|
||||
|
||||
var ORIGINAL_CWD = process.cwd()
|
||||
var WORK_CWD = path.join(__dirname, 'work')
|
||||
|
||||
var versions = config.versions
|
||||
var archs = ['x64']
|
||||
var platforms = ['darwin', 'mas']
|
||||
var slice = Array.prototype.slice
|
||||
|
||||
var releases = []
|
||||
versions.forEach(function (version) {
|
||||
archs.forEach(function (arch) {
|
||||
platforms.forEach(function (platform) {
|
||||
// Only versions later than 0.34.0 offer mas builds
|
||||
if (platform !== 'mas' || compareVersion(version, '0.34.0') >= 0) {
|
||||
releases.push({
|
||||
arch: arch,
|
||||
platform: platform,
|
||||
version: version
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
exports.generateReleaseName = function getExtractName (release) {
|
||||
return 'v' + release.version + '-' + release.platform + '-' + release.arch
|
||||
}
|
||||
|
||||
exports.generateAppPath = function getExtractName (release) {
|
||||
return path.join(exports.generateReleaseName(release), 'Electron.app')
|
||||
}
|
||||
|
||||
exports.downloadElectrons = function downloadElectrons (callback) {
|
||||
series(releases.map(function (release) {
|
||||
return function (cb) {
|
||||
download(release, function (err, zipPath) {
|
||||
if (err) return callback(err)
|
||||
extract(zipPath, {dir: path.join(WORK_CWD, exports.generateReleaseName(release))}, cb)
|
||||
})
|
||||
}
|
||||
}), callback)
|
||||
}
|
||||
|
||||
exports.setup = function setup () {
|
||||
test('setup', function (t) {
|
||||
mkdirp(WORK_CWD, function (err) {
|
||||
if (err) {
|
||||
t.end(err)
|
||||
} else {
|
||||
process.chdir(WORK_CWD)
|
||||
t.end()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.teardown = function teardown () {
|
||||
test('teardown', function (t) {
|
||||
process.chdir(ORIGINAL_CWD)
|
||||
rimraf(WORK_CWD, function (err) {
|
||||
t.end(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.forEachRelease = function forEachRelease (cb) {
|
||||
releases.forEach(cb)
|
||||
}
|
||||
|
||||
exports.testAllReleases = function testAllReleases (name, createTest /*, ...createTestArgs */) {
|
||||
var args = slice.call(arguments, 2)
|
||||
exports.setup()
|
||||
exports.forEachRelease(function (release) {
|
||||
test(name + ':' + exports.generateReleaseName(release),
|
||||
createTest.apply(null, [release].concat(args)))
|
||||
})
|
||||
exports.teardown()
|
||||
}
|
102
app/node_modules/electron-osx-sign/util-entitlements.js
generated
vendored
Normal file
102
app/node_modules/electron-osx-sign/util-entitlements.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @module util-entitlements
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
|
||||
const plist = require('plist')
|
||||
|
||||
const util = require('./util')
|
||||
const debuglog = util.debuglog
|
||||
const getAppContentsPath = util.getAppContentsPath
|
||||
const readFileAsync = util.readFileAsync
|
||||
const writeFileAsync = util.writeFileAsync
|
||||
|
||||
let tmpFileCounter = 0
|
||||
|
||||
/**
|
||||
* This function returns a promise completing the entitlements automation: The process includes checking in `Info.plist` for `ElectronTeamID` or setting parsed value from identity, and checking in entitlements file for `com.apple.security.application-groups` or inserting new into array. A temporary entitlements file may be created to replace the input for any changes introduced.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.preAutoEntitlements = function (opts) {
|
||||
// If entitlements file not provided, default will be used. Fixes #41
|
||||
var appInfoPath = path.join(getAppContentsPath(opts), 'Info.plist')
|
||||
var appInfo
|
||||
var entitlements
|
||||
|
||||
debuglog('Automating entitlement app group...', '\n',
|
||||
'> Info.plist:', appInfoPath, '\n',
|
||||
'> Entitlements:', opts.entitlements)
|
||||
return readFileAsync(opts.entitlements, 'utf8')
|
||||
.then(function (result) {
|
||||
entitlements = plist.parse(result)
|
||||
if (!entitlements['com.apple.security.app-sandbox']) {
|
||||
// Only automate when app sandbox enabled by user
|
||||
return
|
||||
}
|
||||
|
||||
return readFileAsync(appInfoPath, 'utf8')
|
||||
.then(function (result) {
|
||||
appInfo = plist.parse(result)
|
||||
// Use ElectronTeamID in Info.plist if already specified
|
||||
if (appInfo.ElectronTeamID) {
|
||||
debuglog('`ElectronTeamID` found in `Info.plist`: ' + appInfo.ElectronTeamID)
|
||||
} else {
|
||||
// The team identifier in signing identity should not be trusted
|
||||
if (opts['provisioning-profile']) {
|
||||
appInfo.ElectronTeamID = opts['provisioning-profile'].message.Entitlements['com.apple.developer.team-identifier']
|
||||
debuglog('`ElectronTeamID` not found in `Info.plist`, use parsed from provisioning profile: ' + appInfo.ElectronTeamID)
|
||||
} else {
|
||||
appInfo.ElectronTeamID = opts.identity.name.substring(opts.identity.name.indexOf('(') + 1, opts.identity.name.lastIndexOf(')'))
|
||||
debuglog('`ElectronTeamID` not found in `Info.plist`, use parsed from signing identity: ' + appInfo.ElectronTeamID)
|
||||
}
|
||||
return writeFileAsync(appInfoPath, plist.build(appInfo), 'utf8')
|
||||
.then(function () {
|
||||
debuglog('`Info.plist` updated:', '\n',
|
||||
'> Info.plist:', appInfoPath)
|
||||
})
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
var appIdentifier = appInfo.ElectronTeamID + '.' + appInfo.CFBundleIdentifier
|
||||
// Insert application identifier if not exists
|
||||
if (entitlements['com.apple.application-identifier']) {
|
||||
debuglog('`com.apple.application-identifier` found in entitlements file: ' + entitlements['com.apple.application-identifier'])
|
||||
} else {
|
||||
debuglog('`com.apple.application-identifier` not found in entitlements file, new inserted: ' + appIdentifier)
|
||||
entitlements['com.apple.application-identifier'] = appIdentifier
|
||||
}
|
||||
// Insert developer team identifier if not exists
|
||||
if (entitlements['com.apple.developer.team-identifier']) {
|
||||
debuglog('`com.apple.developer.team-identifier` found in entitlements file: ' + entitlements['com.apple.developer.team-identifier'])
|
||||
} else {
|
||||
debuglog('`com.apple.developer.team-identifier` not found in entitlements file, new inserted: ' + appInfo.ElectronTeamID)
|
||||
entitlements['com.apple.developer.team-identifier'] = appInfo.ElectronTeamID
|
||||
}
|
||||
// Init entitlements app group key to array if not exists
|
||||
if (!entitlements['com.apple.security.application-groups']) {
|
||||
entitlements['com.apple.security.application-groups'] = []
|
||||
}
|
||||
// Insert app group if not exists
|
||||
if (Array.isArray(entitlements['com.apple.security.application-groups']) && entitlements['com.apple.security.application-groups'].indexOf(appIdentifier) === -1) {
|
||||
debuglog('`com.apple.security.application-groups` not found in entitlements file, new inserted: ' + appIdentifier)
|
||||
entitlements['com.apple.security.application-groups'].push(appIdentifier)
|
||||
} else {
|
||||
debuglog('`com.apple.security.application-groups` found in entitlements file: ' + appIdentifier)
|
||||
}
|
||||
// Create temporary entitlements file
|
||||
const entitlementsPath = path.join(os.tmpdir(), `tmp-entitlements-${process.pid.toString(16)}-${(tmpFileCounter++).toString(16)}.plist`)
|
||||
opts.entitlements = entitlementsPath
|
||||
return writeFileAsync(entitlementsPath, plist.build(entitlements), 'utf8')
|
||||
.then(function () {
|
||||
debuglog('Entitlements file updated:', '\n',
|
||||
'> Entitlements:', entitlementsPath)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
55
app/node_modules/electron-osx-sign/util-identities.js
generated
vendored
Normal file
55
app/node_modules/electron-osx-sign/util-identities.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @module util-identities
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const util = require('./util')
|
||||
const debuglog = util.debuglog
|
||||
const flatList = util.flatList
|
||||
const execFileAsync = util.execFileAsync
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string} name - Name of the signing identity.
|
||||
* @param {String} hash - SHA-1 hash of the identity.
|
||||
*/
|
||||
var Identity = module.exports.Identity = function (name, hash) {
|
||||
this.name = name
|
||||
this.hash = hash
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise checking the indentity proposed and updates the identity option to a exact finding from results.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @param {string} identity - The proposed identity.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.findIdentitiesAsync = function (opts, identity) {
|
||||
// Only to look for valid identities, excluding those flagged with
|
||||
// CSSMERR_TP_CERT_EXPIRED or CSSMERR_TP_NOT_TRUSTED. Fixes #9
|
||||
|
||||
var args = [
|
||||
'find-identity',
|
||||
'-v'
|
||||
]
|
||||
if (opts.keychain) {
|
||||
args.push(opts.keychain)
|
||||
}
|
||||
|
||||
return execFileAsync('security', args)
|
||||
.then(function (result) {
|
||||
return result.split('\n').map(function (line) {
|
||||
if (line.indexOf(identity) >= 0) {
|
||||
var identityFound = line.substring(line.indexOf('"') + 1, line.lastIndexOf('"'))
|
||||
var identityHashFound = line.substring(line.indexOf(')') + 2, line.indexOf('"') - 1)
|
||||
debuglog('Identity:', '\n',
|
||||
'> Name:', identityFound, '\n',
|
||||
'> Hash:', identityHashFound)
|
||||
return new Identity(identityFound, identityHashFound)
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(flatList)
|
||||
}
|
173
app/node_modules/electron-osx-sign/util-provisioning-profiles.js
generated
vendored
Normal file
173
app/node_modules/electron-osx-sign/util-provisioning-profiles.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* @module util-provisioning-profiles
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const plist = require('plist')
|
||||
|
||||
const util = require('./util')
|
||||
const debuglog = util.debuglog
|
||||
const debugwarn = util.debugwarn
|
||||
const getAppContentsPath = util.getAppContentsPath
|
||||
const flatList = util.flatList
|
||||
const copyFileAsync = util.copyFileAsync
|
||||
const execFileAsync = util.execFileAsync
|
||||
const lstatAsync = util.lstatAsync
|
||||
const readdirAsync = util.readdirAsync
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string} filePath - Path to provisioning profile.
|
||||
* @param {Object} message - Decoded message in provisioning profile.
|
||||
*/
|
||||
var ProvisioningProfile = module.exports.ProvisioningProfile = function (filePath, message) {
|
||||
this.filePath = filePath
|
||||
this.message = message
|
||||
}
|
||||
|
||||
Object.defineProperty(ProvisioningProfile.prototype, 'name', {
|
||||
get: function () {
|
||||
return this.message['Name']
|
||||
}
|
||||
})
|
||||
|
||||
Object.defineProperty(ProvisioningProfile.prototype, 'platforms', {
|
||||
get: function () {
|
||||
if ('ProvisionsAllDevices' in this.message) return ['darwin'] // Developer ID
|
||||
else if (this.type === 'distribution') return ['mas'] // Mac App Store
|
||||
else return ['darwin', 'mas'] // Mac App Development
|
||||
}
|
||||
})
|
||||
|
||||
Object.defineProperty(ProvisioningProfile.prototype, 'type', {
|
||||
get: function () {
|
||||
if ('ProvisionedDevices' in this.message) return 'development' // Mac App Development
|
||||
else return 'distribution' // Developer ID or Mac App Store
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Returns a promise resolving to a ProvisioningProfile instance based on file.
|
||||
* @function
|
||||
* @param {string} filePath - Path to provisioning profile.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
var getProvisioningProfileAsync = module.exports.getProvisioningProfileAsync = function (filePath) {
|
||||
return execFileAsync('security', [
|
||||
'cms',
|
||||
'-D', // Decode a CMS message
|
||||
'-i', filePath // Use infile as source of data
|
||||
])
|
||||
.then(function (result) {
|
||||
var provisioningProfile = new ProvisioningProfile(filePath, plist.parse(result))
|
||||
debuglog('Provisioning profile:', '\n',
|
||||
'> Name:', provisioningProfile.name, '\n',
|
||||
'> Platforms:', provisioningProfile.platforms, '\n',
|
||||
'> Type:', provisioningProfile.type, '\n',
|
||||
'> Path:', provisioningProfile.filePath, '\n',
|
||||
'> Message:', provisioningProfile.message)
|
||||
return provisioningProfile
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a promise resolving to a list of suitable provisioning profile within the current working directory.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
var findProvisioningProfilesAsync = module.exports.findProvisioningProfilesAsync = function (opts) {
|
||||
return Promise.map([
|
||||
process.cwd() // Current working directory
|
||||
], function (dirPath) {
|
||||
return readdirAsync(dirPath)
|
||||
.map(function (name) {
|
||||
var filePath = path.join(dirPath, name)
|
||||
return lstatAsync(filePath)
|
||||
.then(function (stat) {
|
||||
if (stat.isFile()) {
|
||||
switch (path.extname(filePath)) {
|
||||
case '.provisionprofile':
|
||||
return filePath
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(flatList)
|
||||
.map(function (filePath) {
|
||||
return getProvisioningProfileAsync(filePath)
|
||||
.then(function (provisioningProfile) {
|
||||
if (provisioningProfile.platforms.indexOf(opts.platform) >= 0 && provisioningProfile.type === opts.type) return provisioningProfile
|
||||
debugwarn('Provisioning profile above ignored, not for ' + opts.platform + ' ' + opts.type + '.')
|
||||
return undefined
|
||||
})
|
||||
})
|
||||
.then(flatList)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a promise embedding the provisioning profile in the app Contents folder.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.preEmbedProvisioningProfile = function (opts) {
|
||||
function embedProvisioningProfile () {
|
||||
if (opts['provisioning-profile']) {
|
||||
debuglog('Looking for existing provisioning profile...')
|
||||
var embeddedFilePath = path.join(getAppContentsPath(opts), 'embedded.provisionprofile')
|
||||
return lstatAsync(embeddedFilePath)
|
||||
.then(function (stat) {
|
||||
debuglog('Found embedded provisioning profile:', '\n',
|
||||
'* Please manually remove the existing file if not wanted.', '\n',
|
||||
'* Current file at:', embeddedFilePath)
|
||||
})
|
||||
.catch(function (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
// File does not exist
|
||||
debuglog('Embedding provisioning profile...')
|
||||
return copyFileAsync(opts['provisioning-profile'].filePath, embeddedFilePath)
|
||||
} else throw err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (opts['provisioning-profile']) {
|
||||
// User input provisioning profile
|
||||
debuglog('`provisioning-profile` passed in arguments.')
|
||||
if (opts['provisioning-profile'] instanceof ProvisioningProfile) {
|
||||
return embedProvisioningProfile()
|
||||
} else {
|
||||
return getProvisioningProfileAsync(opts['provisioning-profile'])
|
||||
.then(function (provisioningProfile) {
|
||||
opts['provisioning-profile'] = provisioningProfile
|
||||
})
|
||||
.then(embedProvisioningProfile)
|
||||
}
|
||||
} else {
|
||||
// Discover provisioning profile
|
||||
debuglog('No `provisioning-profile` passed in arguments, will find in current working directory and in user library...')
|
||||
return findProvisioningProfilesAsync(opts)
|
||||
.then(function (provisioningProfiles) {
|
||||
if (provisioningProfiles.length > 0) {
|
||||
// Provisioning profile(s) found
|
||||
if (provisioningProfiles.length > 1) {
|
||||
debuglog('Multiple provisioning profiles found, will use the first discovered.')
|
||||
} else {
|
||||
debuglog('Found 1 provisioning profile.')
|
||||
}
|
||||
opts['provisioning-profile'] = provisioningProfiles[0]
|
||||
} else {
|
||||
// No provisioning profile found
|
||||
debuglog('No provisioning profile found, will not embed profile in app contents.')
|
||||
}
|
||||
})
|
||||
.then(embedProvisioningProfile)
|
||||
}
|
||||
}
|
260
app/node_modules/electron-osx-sign/util.js
generated
vendored
Normal file
260
app/node_modules/electron-osx-sign/util.js
generated
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
/**
|
||||
* @module util
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const child = require('child_process')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const debug = require('debug')
|
||||
|
||||
/**
|
||||
* This callback is used across signing and flattening.
|
||||
* @callback RequestCallback
|
||||
* @param {?Error} err
|
||||
*/
|
||||
|
||||
/** @function */
|
||||
const debuglog = module.exports.debuglog = debug('electron-osx-sign')
|
||||
debuglog.log = console.log.bind(console)
|
||||
|
||||
/** @function */
|
||||
const debugwarn = module.exports.debugwarn = debug('electron-osx-sign:warn')
|
||||
debugwarn.log = console.warn.bind(console)
|
||||
|
||||
/** @function */
|
||||
const isBinaryFileAsync = module.exports.isBinaryFileAsync = Promise.promisify(require('isbinaryfile'))
|
||||
|
||||
/** @function */
|
||||
const removePassword = function (input) {
|
||||
return input.replace(/(-P |pass:|\/p|-pass )([^ ]+)/, function (match, p1, p2) {
|
||||
return `${p1}***`
|
||||
})
|
||||
}
|
||||
|
||||
/** @function */
|
||||
module.exports.execFileAsync = function (file, args, options) {
|
||||
if (debuglog.enabled) {
|
||||
debuglog('Executing...', file, args && Array.isArray(args) ? removePassword(args.join(' ')) : '')
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
child.execFile(file, args, options, function (err, stdout, stderr) {
|
||||
if (err) {
|
||||
debuglog('Error executing file:', '\n',
|
||||
'> Stdout:', stdout, '\n',
|
||||
'> Stderr:', stderr)
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
resolve(stdout)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** @function */
|
||||
const lstatAsync = module.exports.lstatAsync = Promise.promisify(fs.lstat)
|
||||
|
||||
/** @function */
|
||||
const readdirAsync = module.exports.readdirAsync = Promise.promisify(fs.readdir)
|
||||
|
||||
/** @function */
|
||||
module.exports.readFileAsync = Promise.promisify(fs.readFile)
|
||||
|
||||
/** @function */
|
||||
module.exports.writeFileAsync = Promise.promisify(fs.writeFile)
|
||||
|
||||
/**
|
||||
* This function returns a flattened list of elements from an array of lists.
|
||||
* @function
|
||||
* @param {*} list - List.
|
||||
* @returns Flattened list.
|
||||
*/
|
||||
var flatList = module.exports.flatList = function (list) {
|
||||
function populateResult (list) {
|
||||
if (!Array.isArray(list)) {
|
||||
result.push(list)
|
||||
} else if (list.length > 0) {
|
||||
for (let item of list) if (item) populateResult(item)
|
||||
}
|
||||
}
|
||||
|
||||
var result = []
|
||||
populateResult(list)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the path to app contents.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {string} App contents path.
|
||||
*/
|
||||
var getAppContentsPath = module.exports.getAppContentsPath = function (opts) {
|
||||
return path.join(opts.app, 'Contents')
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the path to app frameworks within contents.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {string} App frameworks path.
|
||||
*/
|
||||
var getAppFrameworksPath = module.exports.getAppFrameworksPath = function (opts) {
|
||||
return path.join(getAppContentsPath(opts), 'Frameworks')
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise copying a file from the source to the target.
|
||||
* @function
|
||||
* @param {string} source - Source path.
|
||||
* @param {string} target - Target path.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.copyFileAsync = function (source, target) {
|
||||
debuglog('Copying file...', '\n',
|
||||
'> Source:', source, '\n',
|
||||
'> Target:', target)
|
||||
return new Promise(function (resolve, reject) {
|
||||
var readStream = fs.createReadStream(source)
|
||||
readStream.on('error', reject)
|
||||
var writeStream = fs.createWriteStream(target)
|
||||
writeStream.on('error', reject)
|
||||
writeStream.on('close', resolve)
|
||||
readStream.pipe(writeStream)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise with platform resolved.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise resolving platform.
|
||||
*/
|
||||
var detectElectronPlatformAsync = module.exports.detectElectronPlatformAsync = function (opts) {
|
||||
return new Promise(function (resolve) {
|
||||
var appFrameworksPath = getAppFrameworksPath(opts)
|
||||
// The presence of Squirrel.framework identifies a Mac App Store build as used in https://github.com/atom/electron/blob/master/docs/tutorial/mac-app-store-submission-guide.md
|
||||
return lstatAsync(path.join(appFrameworksPath, 'Squirrel.framework'))
|
||||
.then(function () {
|
||||
resolve('darwin')
|
||||
})
|
||||
.catch(function () {
|
||||
resolve('mas')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise resolving the file path if file binary.
|
||||
* @function
|
||||
* @param {string} filePath - Path to file.
|
||||
* @returns {Promise} Promise resolving file path or undefined.
|
||||
*/
|
||||
var getFilePathIfBinaryAsync = module.exports.getFilePathIfBinaryAsync = function (filePath) {
|
||||
return isBinaryFileAsync(filePath)
|
||||
.then(function (isBinary) {
|
||||
return isBinary ? filePath : undefined
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise validating opts.app, the application to be signed or flattened.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.validateOptsAppAsync = function (opts) {
|
||||
if (!opts.app) {
|
||||
return Promise.reject(new Error('Path to aplication must be specified.'))
|
||||
}
|
||||
if (path.extname(opts.app) !== '.app') {
|
||||
return Promise.reject(new Error('Extension of application must be `.app`.'))
|
||||
}
|
||||
return lstatAsync(opts.app)
|
||||
.thenReturn()
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise validating opts.platform, the platform of Electron build. It allows auto-discovery if no opts.platform is specified.
|
||||
* @function
|
||||
* @param {Object} opts - Options.
|
||||
* @returns {Promise} Promise.
|
||||
*/
|
||||
module.exports.validateOptsPlatformAsync = function (opts) {
|
||||
if (opts.platform) {
|
||||
if (opts.platform === 'mas' || opts.platform === 'darwin') {
|
||||
return Promise.resolve()
|
||||
} else {
|
||||
debugwarn('`platform` passed in arguments not supported, checking Electron platform...')
|
||||
}
|
||||
} else {
|
||||
debugwarn('No `platform` passed in arguments, checking Electron platform...')
|
||||
}
|
||||
|
||||
return detectElectronPlatformAsync(opts)
|
||||
.then(function (platform) {
|
||||
opts.platform = platform
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a promise resolving all child paths within the directory specified.
|
||||
* @function
|
||||
* @param {string} dirPath - Path to directory.
|
||||
* @returns {Promise} Promise resolving child paths needing signing in order.
|
||||
*/
|
||||
module.exports.walkAsync = function (dirPath) {
|
||||
debuglog('Walking... ' + dirPath)
|
||||
|
||||
var unlinkAsync = Promise.promisify(fs.unlink)
|
||||
|
||||
function _walkAsync (dirPath) {
|
||||
return readdirAsync(dirPath)
|
||||
.then(function (names) {
|
||||
return Promise.map(names, function (name) {
|
||||
var filePath = path.join(dirPath, name)
|
||||
return lstatAsync(filePath)
|
||||
.then(function (stat) {
|
||||
if (stat.isFile()) {
|
||||
switch (path.extname(filePath)) {
|
||||
case '': // Binary
|
||||
if (path.basename(filePath)[0] !== '.') {
|
||||
return getFilePathIfBinaryAsync(filePath)
|
||||
} // Else reject hidden file
|
||||
break
|
||||
case '.dylib': // Dynamic library
|
||||
case '.node': // Native node addon
|
||||
return filePath
|
||||
case '.cstemp': // Temporary file generated from past codesign
|
||||
debuglog('Removing... ' + filePath)
|
||||
return unlinkAsync(filePath)
|
||||
.thenReturn(undefined)
|
||||
default:
|
||||
if (path.extname(filePath).indexOf(' ') >= 0) {
|
||||
// Still consider the file as binary if extension seems invalid
|
||||
return getFilePathIfBinaryAsync(filePath)
|
||||
}
|
||||
}
|
||||
} else if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
||||
return _walkAsync(filePath)
|
||||
.then(function (result) {
|
||||
switch (path.extname(filePath)) {
|
||||
case '.app': // Application
|
||||
case '.framework': // Framework
|
||||
result.push(filePath)
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return _walkAsync(dirPath)
|
||||
.then(flatList)
|
||||
}
|
Reference in New Issue
Block a user