-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
validate.js
66 lines (60 loc) · 1.48 KB
/
validate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const {isNotaryToolAvailable} = require('electron-notarize/lib/notarytool');
const {
validateNotaryToolAuthorizationArgs,
validateLegacyAuthorizationArgs
} = require('electron-notarize/lib/validate-args');
function getAuthInfo() {
const {
APPLE_ID: appleId,
APPLE_ID_PASSWORD: appleIdPassword,
APPLE_API_KEY: appleApiKey,
APPLE_API_KEY_ID: appleApiKeyId,
APPLE_API_KEY_ISSUER: appleApiIssuer,
API_KEY_ID: legacyApiKey,
API_KEY_ISSUER_ID: legacyApiIssuer,
TEAM_SHORT_NAME: teamShortName,
APPLE_TEAM_ID: teamId,
APPLE_KEYCHAIN: keychain,
APPLE_KEYCHAIN_PROFILE: keychainProfile
} = process.env;
return {
appleId,
appleIdPassword,
appleApiKey,
appleApiKeyId,
appleApiIssuer,
teamShortName,
teamId,
keychain,
keychainProfile,
legacyApiIssuer,
legacyApiKey
};
}
module.exports = async () => {
const options = getAuthInfo();
if (!options.legacyApiIssuer && !options.legacyApiKey && await isNotaryToolAvailable()) {
try {
const creds = validateNotaryToolAuthorizationArgs(options);
return {
...creds,
tool: 'notarytool'
};
} catch (e) {
console.error(e);
}
} else {
console.log('notarytool not found, trying legacy.');
}
const creds = validateLegacyAuthorizationArgs({
...options,
// Backwards compatibility
appleApiKey: options.appleApiKey || options.legacyApiKey,
appleApiIssuer: options.appleApiIssuer || options.legacyApiIssuer
});
return {
...creds,
tool: 'legacy',
ascProvider: options.teamShortName
};
};