vue-cli-plugin-electron-builder-notarize 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/entitlements.mac.inherit.plist +12 -0
- package/index.js +101 -0
- package/license +9 -0
- package/package.json +39 -0
- package/readme.md +86 -0
- package/validate.js +66 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>com.apple.security.cs.allow-jit</key>
|
6
|
+
<true/>
|
7
|
+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
8
|
+
<true/>
|
9
|
+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
10
|
+
<true/>
|
11
|
+
</dict>
|
12
|
+
</plist>
|
package/index.js
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
require('dotenv').config();
|
4
|
+
|
5
|
+
const path = require('path');
|
6
|
+
const fs = require('fs');
|
7
|
+
const readPkgUp = require('read-pkg-up');
|
8
|
+
const { notarize } = require('@electron/notarize');
|
9
|
+
const yaml = require('js-yaml');
|
10
|
+
const util = require('builder-util');
|
11
|
+
const getAuthCreds = require('./validate');
|
12
|
+
|
13
|
+
const isEnvTrue = value => {
|
14
|
+
if (value !== null) {
|
15
|
+
value = value.trim();
|
16
|
+
}
|
17
|
+
|
18
|
+
return value === 'true' || value === '' || value === '1';
|
19
|
+
};
|
20
|
+
|
21
|
+
const getAppId = params => {
|
22
|
+
const { packager, outDir } = params;
|
23
|
+
|
24
|
+
// Try getting appId from the packager object
|
25
|
+
const config = packager.info._configuration;
|
26
|
+
const appId = config && config.appId;
|
27
|
+
|
28
|
+
if (appId) {
|
29
|
+
return appId;
|
30
|
+
}
|
31
|
+
|
32
|
+
// Try getting appId from the `builder-effective-config.yml`
|
33
|
+
const effectiveConfigPath = path.join(outDir, 'builder-effective-config.yaml');
|
34
|
+
// This doesn't exist in CI
|
35
|
+
if (fs.existsSync(effectiveConfigPath)) {
|
36
|
+
const buildConfig = fs.readFileSync(effectiveConfigPath);
|
37
|
+
const { appId } = yaml.safeLoad(buildConfig);
|
38
|
+
return appId;
|
39
|
+
}
|
40
|
+
|
41
|
+
// Try getting appId from `package.json` or from an env var
|
42
|
+
const { packageJson } = readPkgUp.sync();
|
43
|
+
return (packageJson.build && packageJson.build.appId) || process.env.APP_ID;
|
44
|
+
};
|
45
|
+
|
46
|
+
module.exports = async params => {
|
47
|
+
if (params.electronPlatformName !== 'darwin') {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
|
51
|
+
// https://github.com/electron-userland/electron-builder/blob/c11fa1f1033aeb7c378856d7db93369282d363f5/packages/app-builder-lib/src/codeSign/macCodeSign.ts#L22-L49
|
52
|
+
if (util.isPullRequest()) {
|
53
|
+
if (!isEnvTrue(process.env.CSC_FOR_PULL_REQUEST)) {
|
54
|
+
console.log('Skipping notarizing, since app was not signed.');
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// Read and validate auth information from environment variables
|
60
|
+
let authInfo;
|
61
|
+
try {
|
62
|
+
authInfo = await getAuthCreds();
|
63
|
+
} catch (error) {
|
64
|
+
console.log(`Skipping notarization: ${error.message}`);
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
const appId = getAppId(params);
|
69
|
+
|
70
|
+
if (!appId) {
|
71
|
+
throw new Error('`appId` was not found');
|
72
|
+
}
|
73
|
+
|
74
|
+
const appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);
|
75
|
+
|
76
|
+
const notarizeOptions = {
|
77
|
+
...authInfo,
|
78
|
+
appPath,
|
79
|
+
appBundleId: appId
|
80
|
+
};
|
81
|
+
|
82
|
+
console.log(`📦 Start notarizing ${appId} found at ${appPath}`);
|
83
|
+
|
84
|
+
try {
|
85
|
+
const res = await notarize(notarizeOptions);
|
86
|
+
|
87
|
+
if (!res) {
|
88
|
+
console.log(`🌟 Notarizing ${appId} successfully !`);
|
89
|
+
}
|
90
|
+
} catch (error) {
|
91
|
+
const error1048Str = 'You must first sign the relevant contracts online. (1048)';
|
92
|
+
|
93
|
+
if (String(error).includes(error1048Str)) {
|
94
|
+
throw new Error('📃 Error(1048): You must first sign the relevant contracts online');
|
95
|
+
}
|
96
|
+
|
97
|
+
fs.writeFileSync('notarization-error.log', error.message);
|
98
|
+
|
99
|
+
throw new Error('❌ Notarization Error,please check notarization-error.log');
|
100
|
+
}
|
101
|
+
};
|
package/license
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) George Karagkiaouris <karaggeorge0@gmail.com> (gkaragkiaouris.tech)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"name": "vue-cli-plugin-electron-builder-notarize",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Notarize Electron applications using electron-builder",
|
5
|
+
"license": "MIT",
|
6
|
+
"repository": "https://github.com/hn-failte/electron-builder-notarize",
|
7
|
+
"author": {
|
8
|
+
"name": "George Karagkiaouris",
|
9
|
+
"email": "karaggeorge0@gmail.com",
|
10
|
+
"url": "https://gkaragkiaouris.tech"
|
11
|
+
},
|
12
|
+
"peerDependencies": {
|
13
|
+
"electron-builder": ">= 20.44.4"
|
14
|
+
},
|
15
|
+
"engines": {
|
16
|
+
"node": ">=8"
|
17
|
+
},
|
18
|
+
"scripts": {},
|
19
|
+
"files": [
|
20
|
+
"index.js",
|
21
|
+
"validate.js",
|
22
|
+
"entitlements.mac.inherit.plist"
|
23
|
+
],
|
24
|
+
"keywords": [
|
25
|
+
"electron",
|
26
|
+
"notarize",
|
27
|
+
"apple",
|
28
|
+
"id",
|
29
|
+
"builder"
|
30
|
+
],
|
31
|
+
"dependencies": {
|
32
|
+
"@electron/notarize": "^2.5.0",
|
33
|
+
"builder-util": "^22.10.5",
|
34
|
+
"dotenv": "^8.2.0",
|
35
|
+
"js-yaml": "^3.14.0",
|
36
|
+
"read-pkg-up": "^7.0.0"
|
37
|
+
},
|
38
|
+
"devDependencies": {}
|
39
|
+
}
|
package/readme.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# electron-builder-notarize
|
2
|
+
|
3
|
+
> Notarize Electron applications using electron-builder
|
4
|
+
|
5
|
+
For more details regarding the options and functionality: https://github.com/electron/@electron/notarize
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
```
|
10
|
+
# npm
|
11
|
+
npm i electron-builder-notarize --save-dev
|
12
|
+
|
13
|
+
# yarn
|
14
|
+
yarn add electron-builder-notarize --dev
|
15
|
+
```
|
16
|
+
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
In your electron-builder config:
|
21
|
+
|
22
|
+
```json
|
23
|
+
{
|
24
|
+
...
|
25
|
+
"afterSign": "electron-builder-notarize",
|
26
|
+
"mac": {
|
27
|
+
...
|
28
|
+
"hardenedRuntime": true,
|
29
|
+
"entitlements": "./node_modules/electron-builder-notarize/entitlements.mac.inherit.plist",
|
30
|
+
}
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
You can replace the entitlements file with your own, as long as those properties are included as well.
|
35
|
+
|
36
|
+
You will also need to authenticate yourself, either with your Apple ID or using an API key. This is done by setting the corresponding environment variables.
|
37
|
+
|
38
|
+
If for some reason the script can't locate your project's `appId`, you can specify it using the `APP_ID` environment variable.
|
39
|
+
|
40
|
+
### Using `notarytool`
|
41
|
+
|
42
|
+
In order to use `notarytool` for notarization, XCode 13 or later is required
|
43
|
+
|
44
|
+
Authentication methods:
|
45
|
+
- username and password
|
46
|
+
- `APPLE_ID` String - The username of your apple developer account
|
47
|
+
- `APPLE_ID_PASSWORD` String - The [app-specific password](https://support.apple.com/HT204397) (not your Apple ID password).
|
48
|
+
- `APPLE_TEAM_ID` String - The team ID you want to notarize under.
|
49
|
+
- apiKey with apiIssuer:
|
50
|
+
- `APPLE_API_KEY` String - Required for JWT authentication. See Note on JWT authentication below.
|
51
|
+
- `APPLE_API_KEY_ID` String - Required for JWT authentication. See Note on JWT authentication below.
|
52
|
+
- `APPLE_API_KEY_ISSUER` String - Issuer ID. Required if `APPLE_API_KEY` is specified.
|
53
|
+
- keychain with keychainProfile:
|
54
|
+
- `APPLE_KEYCHAIN` String - The name of the keychain or path to the keychain you stored notarization credentials in.
|
55
|
+
- `APPLE_KEYCHAIN_PROFILE` String - The name of the profile you provided when storing notarization credentials.
|
56
|
+
|
57
|
+
### Using Legacy
|
58
|
+
|
59
|
+
General options:
|
60
|
+
- `TEAM_SHORT_NAME` String - Your [Team Short Name](#notes-on-your-team-short-name).
|
61
|
+
|
62
|
+
Authentication methods:
|
63
|
+
- username and password
|
64
|
+
- `APPLE_ID` String - The username of your apple developer account
|
65
|
+
- `APPLE_ID_PASSWORD` String - The [app-specific password](https://support.apple.com/HT204397) (not your Apple ID password).
|
66
|
+
- apiKey with apiIssuer
|
67
|
+
- `APPLE_API_KEY` String - Required for JWT authentication. See Note on JWT authentication below.
|
68
|
+
- `APPLE_API_KEY_ISSUER` String - Issuer ID. Required if `APPLE_API_KEY` is specified.
|
69
|
+
|
70
|
+
### Multiple Teams
|
71
|
+
|
72
|
+
If your developer account is a member of multiple teams or organizations, you might see an error. In this case, you need to provide your [Team Short Name](https://github.com/electron/@electron/notarize#notes-on-your-team-short-name) as an environment variable:
|
73
|
+
|
74
|
+
```sh
|
75
|
+
export TEAM_SHORT_NAME=XXXXXXXXX
|
76
|
+
```
|
77
|
+
|
78
|
+
## Credits
|
79
|
+
|
80
|
+
This package is inspired by this [article](https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db)
|
81
|
+
|
82
|
+
The library used for notarization: https://github.com/electron/@electron/notarize
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
MIT
|
package/validate.js
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
const { isNotaryToolAvailable } = require('@electron/notarize/lib/notarytool');
|
2
|
+
const {
|
3
|
+
validateNotaryToolAuthorizationArgs,
|
4
|
+
validateLegacyAuthorizationArgs
|
5
|
+
} = require('@electron/notarize/lib/validate-args');
|
6
|
+
|
7
|
+
function getAuthInfo() {
|
8
|
+
const {
|
9
|
+
APPLE_ID: appleId,
|
10
|
+
APPLE_ID_PASSWORD: appleIdPassword,
|
11
|
+
APPLE_API_KEY: appleApiKey,
|
12
|
+
APPLE_API_KEY_ID: appleApiKeyId,
|
13
|
+
APPLE_API_ISSUER: appleApiIssuer,
|
14
|
+
API_KEY_ID: legacyApiKey,
|
15
|
+
API_KEY_ISSUER_ID: legacyApiIssuer,
|
16
|
+
TEAM_SHORT_NAME: teamShortName,
|
17
|
+
APPLE_TEAM_ID: teamId,
|
18
|
+
APPLE_KEYCHAIN: keychain,
|
19
|
+
APPLE_KEYCHAIN_PROFILE: keychainProfile
|
20
|
+
} = process.env;
|
21
|
+
|
22
|
+
return {
|
23
|
+
appleId,
|
24
|
+
appleIdPassword,
|
25
|
+
appleApiKey,
|
26
|
+
appleApiKeyId,
|
27
|
+
appleApiIssuer,
|
28
|
+
teamShortName,
|
29
|
+
teamId,
|
30
|
+
keychain,
|
31
|
+
keychainProfile,
|
32
|
+
legacyApiIssuer,
|
33
|
+
legacyApiKey
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
37
|
+
module.exports = async () => {
|
38
|
+
const options = getAuthInfo();
|
39
|
+
|
40
|
+
if (!options.legacyApiIssuer && !options.legacyApiKey && await isNotaryToolAvailable()) {
|
41
|
+
try {
|
42
|
+
const creds = validateNotaryToolAuthorizationArgs(options);
|
43
|
+
return {
|
44
|
+
...creds,
|
45
|
+
tool: 'notarytool'
|
46
|
+
};
|
47
|
+
} catch (e) {
|
48
|
+
console.error(e);
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
console.log('notarytool not found, trying legacy.');
|
52
|
+
}
|
53
|
+
|
54
|
+
const creds = validateLegacyAuthorizationArgs({
|
55
|
+
...options,
|
56
|
+
// Backwards compatibility
|
57
|
+
appleApiKey: options.appleApiKey || options.legacyApiKey,
|
58
|
+
appleApiIssuer: options.appleApiIssuer || options.legacyApiIssuer
|
59
|
+
});
|
60
|
+
|
61
|
+
return {
|
62
|
+
...creds,
|
63
|
+
tool: 'legacy',
|
64
|
+
ascProvider: options.teamShortName
|
65
|
+
};
|
66
|
+
};
|