11import BluebirdPromise from "bluebird-lst"
2- import { createHash } from "crypto"
32import { Arch , Platform , PlatformSpecificBuildOptions , Target } from "electron-builder-core"
43import { CancellationToken } from "electron-builder-http/out/CancellationToken"
54import { BintrayOptions , GenericServerOptions , GithubOptions , githubUrl , PublishConfiguration , PublishProvider , S3Options , s3Url , UpdateInfo , VersionInfo } from "electron-builder-http/out/publishOptions"
@@ -10,7 +9,7 @@ import { HttpPublisher, PublishContext, Publisher, PublishOptions } from "electr
109import { BintrayPublisher } from "electron-publish/out/BintrayPublisher"
1110import { GitHubPublisher } from "electron-publish/out/gitHubPublisher"
1211import { MultiProgress } from "electron-publish/out/multiProgress"
13- import { createReadStream , ensureDir , outputJson , writeFile } from "fs-extra-p"
12+ import { ensureDir , outputJson , writeFile } from "fs-extra-p"
1413import isCi from "is-ci"
1514import { safeDump } from "js-yaml"
1615import * as path from "path"
@@ -21,6 +20,7 @@ import { Packager } from "../packager"
2120import { ArtifactCreated , BuildInfo } from "../packagerApi"
2221import { PlatformPackager } from "../platformPackager"
2322import { WinPackager } from "../winPackager"
23+ import { hashFile } from "asar-integrity"
2424
2525const publishForPrWarning = "There are serious security concerns with PUBLISH_FOR_PULL_REQUEST=true (see the CircleCI documentation (https://circleci.com/docs/1.0/fork-pr-builds/) for details)" +
2626 "\nIf you have SSH keys, sensitive env vars or AWS credentials stored in your project settings and untrusted forks can make pull requests against your repo, then this option isn't for you."
@@ -247,8 +247,8 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
247247 }
248248
249249 const version = packager . appInfo . version
250- let sha2 = new Lazy ( ( ) => hash ( event . file ! , "sha256" ) )
251- let sha512 = new Lazy ( ( ) => hash ( event . file ! , "sha512" ) )
250+ let sha2 = new Lazy ( ( ) => hashFile ( event . file ! , "sha256" ) )
251+ let sha512 = new Lazy ( ( ) => hashFile ( event . file ! , "sha512" ) )
252252 const isMac = packager . platform === Platform . MAC
253253
254254 for ( const publishConfig of publishConfigs ) {
@@ -421,23 +421,6 @@ export async function getPublishConfigs(packager: PlatformPackager<any>, targetS
421421 return await ( < Promise < Array < PublishConfiguration > > > BluebirdPromise . map ( asArray ( publishers ) , it => getResolvedPublishConfig ( packager , typeof it === "string" ? { provider : it } : it , arch ) ) )
422422}
423423
424- function hash ( file : string , algorithm : string ) {
425- return new BluebirdPromise < string > ( ( resolve , reject ) => {
426- const hash = createHash ( algorithm )
427- hash
428- . on ( "error" , reject )
429- . setEncoding ( "hex" )
430-
431- createReadStream ( file )
432- . on ( "error" , reject )
433- . on ( "end" , ( ) => {
434- hash . end ( )
435- resolve ( < string > hash . read ( ) )
436- } )
437- . pipe ( hash , { end : false } )
438- } )
439- }
440-
441424function isSuitableWindowsTarget ( target : Target ) {
442425 return target . name === "nsis" || target . name . startsWith ( "nsis-" )
443426}
0 commit comments