-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #4048
- Loading branch information
Showing
19 changed files
with
1,237 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
6 changes: 6 additions & 0 deletions
6
packages/app-builder-lib/electron-osx-sign/default.entitlements.darwin.inherit.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 6 additions & 0 deletions
6
packages/app-builder-lib/electron-osx-sign/default.entitlements.darwin.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 10 additions & 0 deletions
10
packages/app-builder-lib/electron-osx-sign/default.entitlements.mas.inherit.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 8 additions & 0 deletions
8
packages/app-builder-lib/electron-osx-sign/default.entitlements.mas.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/** | ||
* @module flat | ||
*/ | ||
|
||
'use strict' | ||
|
||
const path = require('path') | ||
|
||
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.all([ | ||
validateOptsAppAsync(opts), | ||
validateOptsPlatformAsync(opts), | ||
]) | ||
} | ||
|
||
/** | ||
* This function returns a promise flattening the application. | ||
* @function | ||
* @param {Object} opts - Options. | ||
* @returns {Promise} Promise. | ||
*/ | ||
function flatApplicationAsync (opts) { | ||
const 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. | ||
*/ | ||
module.exports.flatAsync = function (opts) { | ||
return validateFlatOptsAsync(opts) | ||
.then(function () { | ||
let 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) { | ||
module.exports.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) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
interface BaseSignOptions { | ||
app: string | ||
identity?: string | ||
platform?: string | ||
keychain?: string | ||
} | ||
|
||
interface SignOptions extends BaseSignOptions { | ||
binaries?: Array<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.