1
1
import BluebirdPromise from "bluebird-lst"
2
- import { createHash } from "crypto"
3
2
import { Arch , Platform , PlatformSpecificBuildOptions , Target } from "electron-builder-core"
4
3
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
5
4
import { 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
10
9
import { BintrayPublisher } from "electron-publish/out/BintrayPublisher"
11
10
import { GitHubPublisher } from "electron-publish/out/gitHubPublisher"
12
11
import { 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"
14
13
import isCi from "is-ci"
15
14
import { safeDump } from "js-yaml"
16
15
import * as path from "path"
@@ -21,6 +20,7 @@ import { Packager } from "../packager"
21
20
import { ArtifactCreated , BuildInfo } from "../packagerApi"
22
21
import { PlatformPackager } from "../platformPackager"
23
22
import { WinPackager } from "../winPackager"
23
+ import { hashFile } from "asar-integrity"
24
24
25
25
const 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)" +
26
26
"\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
247
247
}
248
248
249
249
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" ) )
252
252
const isMac = packager . platform === Platform . MAC
253
253
254
254
for ( const publishConfig of publishConfigs ) {
@@ -421,23 +421,6 @@ export async function getPublishConfigs(packager: PlatformPackager<any>, targetS
421
421
return await ( < Promise < Array < PublishConfiguration > > > BluebirdPromise . map ( asArray ( publishers ) , it => getResolvedPublishConfig ( packager , typeof it === "string" ? { provider : it } : it , arch ) ) )
422
422
}
423
423
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
-
441
424
function isSuitableWindowsTarget ( target : Target ) {
442
425
return target . name === "nsis" || target . name . startsWith ( "nsis-" )
443
426
}
0 commit comments