From 2c6229a936425aa2cf2238895285a9a6b8c6f1e4 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 30 Sep 2019 09:29:12 -0400 Subject: [PATCH] sign safari app for mac and mas --- gulpfile.js | 70 ++++++++++++++++++++++++++++------------ scripts/safari-build.ps1 | 12 ++----- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 7477f9505b..9bf3564ba0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -41,29 +41,10 @@ function pkgMas(cb) { const appPath = paths.dist + 'mas/Bitwarden.app'; const pkgPath = paths.dist + 'mas/Bitwarden-mas.pkg'; const pkgSignedPath = paths.dist + 'mas/Bitwarden-mas-signed.pkg'; - const safariAppexPath = appPath + '/Contents/PlugIns/safari.appex'; - const safariAppexFrameworkPath = safariAppexPath + '/Contents/Frameworks/'; - const safariEntitlementsPath = paths.resources + 'safari.entitlements'; return del([paths.dist + 'mas/Bitwarden*.pkg']) .then(() => { - const libs = fs.readdirSync(safariAppexFrameworkPath).filter((p) => p.endsWith('.dylib')) - .map((p) => safariAppexFrameworkPath + p); - const allItems = libs.concat([safariAppexPath]); - const promises = []; - allItems.forEach((i) => { - const proc = child.spawn('codesign', [ - '--verbose', - '--force', - '--sign', - '3rd Party Mac Developer Application: 8bit Solutions LLC', - '--entitlements', - safariEntitlementsPath, - i]); - stdOutProc(proc); - promises.push(new Promise((resolve) => proc.on('close', resolve))); - }); - return Promise.all(promises); + return signLibs(cb, 'mas'); }).then(() => { const proc = child.spawn('productbuild', [ '--component', @@ -87,6 +68,54 @@ function pkgMas(cb) { }); } + +function signMac(cb) { + return signSafariExt(cb, 'mac'); +} + +function signSafariExt(cb, dir) { + const appPath = paths.dist + dir + '/Bitwarden.app'; + const safariAppexPath = appPath + '/Contents/PlugIns/safari.appex'; + const safariAppexFrameworkPath = safariAppexPath + '/Contents/Frameworks/'; + const safariEntitlementsPath = paths.resources + 'safari.entitlements'; + + const libs = fs.readdirSync(safariAppexFrameworkPath).filter((p) => p.endsWith('.dylib')) + .map((p) => safariAppexFrameworkPath + p); + const allItems = libs.concat([safariAppexPath]); + const promises = []; + allItems.forEach((i) => { + var args = dir === 'mas' ? + [ + '--verbose', + '--force', + '--sign', + '3rd Party Mac Developer Application: 8bit Solutions LLC', + '--entitlements', + safariEntitlementsPath, + i + ] : + [ + '--verbose', + '--force', + '-o', + 'runtime', + '--sign', + 'Developer ID Application: 8bit Solutions LLC', + '--entitlements', + safariEntitlementsPath, + i + ]; + const proc = child.spawn('codesign', args); + stdOutProc(proc); + promises.push(new Promise((resolve) => proc.on('close', resolve))); + }); + return Promise.all(promises).then(() => { + return cb; + }, () => { + return cb; + }); +} + function stdOutProc(proc) { proc.stdout.on('data', (data) => console.log(data.toString())); proc.stderr.on('data', (data) => console.error(data.toString())); @@ -98,4 +127,5 @@ exports.webfonts = gulp.series(clean, webfonts); exports['prebuild:renderer'] = gulp.parallel(webfonts, cleanupAotIssue); exports.fixSweetAlert = fixSweetAlert; exports.pkgMas = pkgMas; +exports.signMac = signMac; exports.postinstall = fixSweetAlert; diff --git a/scripts/safari-build.ps1 b/scripts/safari-build.ps1 index 11153f7333..1235d10db5 100644 --- a/scripts/safari-build.ps1 +++ b/scripts/safari-build.ps1 @@ -1,6 +1,5 @@ param ( - [string] $version, - [switch] $mas + [string] $version ) # Dependencies: @@ -13,8 +12,7 @@ $dir = Split-Path -Parent $MyInvocation.MyCommand.Path; $rootDir = $dir + "\.."; $distDir = $rootDir + "\dist"; $distSafariDir = $distDir + "\safari"; -$distSafariAppexDmg = $distSafariDir + "\browser\dist\Safari\dmg\build\Release\safari.appex"; -$distSafariAppexMas = $distSafariDir + "\browser\dist\Safari\mas\build\Release\safari.appex"; +$distSafariAppex = $distSafariDir + "\browser\dist\Safari\build\Release\safari.appex"; $pluginsAppex = $rootDir + "\PlugIns\safari.appex"; if(Test-Path -Path $distSafariDir) { @@ -37,9 +35,5 @@ if(-not ([string]::IsNullOrEmpty($version))) { npm i npm run dist:safari -if($mas) { - Copy-Item -Path $distSafariAppexMas -Destination $pluginsAppex –Recurse -} else { - Copy-Item -Path $distSafariAppexDmg -Destination $pluginsAppex –Recurse -} +Copy-Item -Path $distSafariAppex -Destination $pluginsAppex –Recurse cd $rootDir