|
1 | 1 | import debug from 'debug'; |
2 | | -import * as path from 'path'; |
3 | 2 |
|
4 | | -import { spawn } from './spawn'; |
5 | | -import { withTempDir, makeSecret, parseNotarizationInfo, delay } from './helpers'; |
6 | | -import { validateLegacyAuthorizationArgs, isLegacyPasswordCredentials } from './validate-args'; |
7 | | -import { |
8 | | - NotarizeResult, |
9 | | - LegacyNotarizeStartOptions, |
10 | | - LegacyNotarizeWaitOptions, |
11 | | - LegacyNotarizeCredentials, |
12 | | -} from './types'; |
| 3 | +import { LegacyNotarizeStartOptions, LegacyNotarizeWaitOptions } from './types'; |
13 | 4 |
|
14 | 5 | const d = debug('electron-notarize:legacy'); |
15 | 6 |
|
16 | | -function authorizationArgs(rawOpts: LegacyNotarizeCredentials): string[] { |
17 | | - const opts = validateLegacyAuthorizationArgs(rawOpts); |
18 | | - if (isLegacyPasswordCredentials(opts)) { |
19 | | - return ['-u', makeSecret(opts.appleId), '-p', makeSecret(opts.appleIdPassword)]; |
20 | | - } else { |
21 | | - return [ |
22 | | - '--apiKey', |
23 | | - makeSecret(opts.appleApiKey), |
24 | | - '--apiIssuer', |
25 | | - makeSecret(opts.appleApiIssuer), |
26 | | - ]; |
27 | | - } |
28 | | -} |
29 | | - |
30 | | -export async function startLegacyNotarize( |
31 | | - opts: LegacyNotarizeStartOptions, |
32 | | -): Promise<NotarizeResult> { |
| 7 | +/** @deprecated */ |
| 8 | +export async function startLegacyNotarize(opts: LegacyNotarizeStartOptions): Promise<never> { |
33 | 9 | d('starting notarize process for app:', opts.appPath); |
34 | | - return await withTempDir<NotarizeResult>(async dir => { |
35 | | - const zipPath = path.resolve(dir, `${path.basename(opts.appPath, '.app')}.zip`); |
36 | | - d('zipping application to:', zipPath); |
37 | | - const zipResult = await spawn( |
38 | | - 'ditto', |
39 | | - ['-c', '-k', '--sequesterRsrc', '--keepParent', path.basename(opts.appPath), zipPath], |
40 | | - { |
41 | | - cwd: path.dirname(opts.appPath), |
42 | | - }, |
43 | | - ); |
44 | | - if (zipResult.code !== 0) { |
45 | | - throw new Error( |
46 | | - `Failed to zip application, exited with code: ${zipResult.code}\n\n${zipResult.output}`, |
47 | | - ); |
48 | | - } |
49 | | - d('zip succeeded, attempting to upload to Apple'); |
50 | | - |
51 | | - const notarizeArgs = [ |
52 | | - 'altool', |
53 | | - '--notarize-app', |
54 | | - '-f', |
55 | | - zipPath, |
56 | | - '--primary-bundle-id', |
57 | | - opts.appBundleId, |
58 | | - ...authorizationArgs(opts), |
59 | | - ]; |
60 | | - |
61 | | - if (opts.ascProvider) { |
62 | | - notarizeArgs.push('-itc_provider', opts.ascProvider); |
63 | | - } |
64 | | - |
65 | | - const result = await spawn('xcrun', notarizeArgs); |
66 | | - if (result.code !== 0) { |
67 | | - throw new Error(`Failed to upload app to Apple's notarization servers\n\n${result.output}`); |
68 | | - } |
69 | | - d('upload success'); |
70 | | - |
71 | | - const uuidMatch = /\nRequestUUID = (.+?)\n/g.exec(result.output); |
72 | | - if (!uuidMatch) { |
73 | | - throw new Error(`Failed to find request UUID in output:\n\n${result.output}`); |
74 | | - } |
75 | | - |
76 | | - d('found UUID:', uuidMatch[1]); |
77 | | - |
78 | | - return { |
79 | | - uuid: uuidMatch[1], |
80 | | - }; |
81 | | - }); |
| 10 | + throw new Error('Cannot start notarization. Legacy notarization (altool) is no longer available'); |
82 | 11 | } |
83 | 12 |
|
84 | | -export async function waitForLegacyNotarize(opts: LegacyNotarizeWaitOptions): Promise<void> { |
85 | | - d('checking notarization status:', opts.uuid); |
86 | | - const result = await spawn('xcrun', [ |
87 | | - 'altool', |
88 | | - '--notarization-info', |
89 | | - opts.uuid, |
90 | | - ...authorizationArgs(opts), |
91 | | - ]); |
92 | | - if (result.code !== 0) { |
93 | | - // These checks could fail for all sorts of reasons, including: |
94 | | - // * The status of a request isn't available as soon as the upload request returns, so |
95 | | - // it may just not be ready yet. |
96 | | - // * If using keychain password, user's mac went to sleep and keychain locked. |
97 | | - // * Regular old connectivity failure. |
98 | | - d( |
99 | | - `Failed to check status of notarization request, retrying in 30 seconds: ${opts.uuid}\n\n${result.output}`, |
100 | | - ); |
101 | | - await delay(30000); |
102 | | - return waitForLegacyNotarize(opts); |
103 | | - } |
104 | | - const notarizationInfo = parseNotarizationInfo(result.output); |
105 | | - |
106 | | - if (notarizationInfo.status === 'in progress') { |
107 | | - d('still in progress, waiting 30 seconds'); |
108 | | - await delay(30000); |
109 | | - return waitForLegacyNotarize(opts); |
110 | | - } |
111 | | - |
112 | | - d('notarzation done with info:', notarizationInfo); |
113 | | - |
114 | | - if (notarizationInfo.status === 'invalid') { |
115 | | - d('notarization failed'); |
116 | | - throw new Error(`Apple failed to notarize your application, check the logs for more info |
117 | | -
|
118 | | -Status Code: ${notarizationInfo.statusCode || 'No Code'} |
119 | | -Message: ${notarizationInfo.statusMessage || 'No Message'} |
120 | | -Logs: ${notarizationInfo.logFileUrl}`); |
121 | | - } |
122 | | - |
123 | | - if (notarizationInfo.status !== 'success') { |
124 | | - throw new Error(`Unrecognized notarization status: "${notarizationInfo.status}"`); |
125 | | - } |
126 | | - |
127 | | - d('notarization was successful'); |
128 | | - return; |
| 13 | +/** @deprecated */ |
| 14 | +export async function waitForLegacyNotarize(opts: LegacyNotarizeWaitOptions): Promise<never> { |
| 15 | + throw new Error( |
| 16 | + 'Cannot wait for notarization. Legacy notarization (altool) is no longer available', |
| 17 | + ); |
129 | 18 | } |
0 commit comments