-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add spctl and codesign verificatin prior to stapling
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as path from 'path'; | ||
|
||
import { spawn } from './spawn'; | ||
import type { NotarizeStapleOptions } from './types'; | ||
import debug from 'debug'; | ||
const d = debug('electron-notarize'); | ||
|
||
const spctl = async (opts: NotarizeStapleOptions) => { | ||
d('attempting to spctl asses app:', opts.appPath); | ||
const result = await spawn('spctl', ['-vvv', '--assess', path.basename(opts.appPath)], { | ||
cwd: path.dirname(opts.appPath), | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
const codesign = async (opts: NotarizeStapleOptions) => { | ||
d('attempting to check codesign of app:', opts.appPath); | ||
const result = await spawn( | ||
'codesign', | ||
['-vvv', '--deep', '--strict', path.basename(opts.appPath)], | ||
{ | ||
cwd: path.dirname(opts.appPath), | ||
}, | ||
); | ||
|
||
return result; | ||
}; | ||
export async function checkSignatures(opts: NotarizeStapleOptions): Promise<void> { | ||
const codesignResult = await codesign(opts); | ||
const spctlResult = await spctl(opts); | ||
|
||
let error = ''; | ||
|
||
if (spctlResult.code !== 0) { | ||
d('spctl asses failed'); | ||
error = `Failed to spctl asses your application with code: ${spctlResult.code}\n\n${spctlResult.output}\n`; | ||
} | ||
if (codesignResult.code !== 0) { | ||
d('codesign check failed'); | ||
error += `Failed to codesign your application with code: ${spctlResult.code}\n\n${spctlResult.output}`; | ||
} | ||
|
||
if (error) { | ||
throw new Error(error); | ||
} | ||
d('codesign and spctl asses succeeded'); | ||
} |
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