Skip to content

Commit

Permalink
feat: asar integrity: add externalAllowed option
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 4, 2017
1 parent df1feb5 commit e0d7974
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ matrix:
env: TEST_FILES=BuildTest,extraMetadataTest,globTest,filesTest,ignoreTest,linux.* NODE_VERSION=6 PUBLISH_TO_NPM=true

- os: osx
env: TEST_FILES=windows.*,mac.* NODE_VERSION=7
env: TEST_FILES=windows.*,mac.* NODE_VERSION=8

- os: osx
env: TEST_FILES=mac.* NODE_VERSION=6
Expand Down
4 changes: 2 additions & 2 deletions packages/asar-integrity/src/asarIntegrity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export interface AsarIntegrityOptions {
*
* @default false
*/
readonly externalAllowed: Boolean
readonly externalAllowed?: Boolean
}

export interface AsarIntegrity extends AsarIntegrityOptions {
checksums: { [key: string]: string; }
}

export async function computeData(resourcesPath: string, options?: AsarIntegrityOptions): Promise<AsarIntegrity> {
export async function computeData(resourcesPath: string, options?: AsarIntegrityOptions | null): Promise<AsarIntegrity> {
// sort to produce constant result
const names = (await readdir(resourcesPath)).filter(it => it.endsWith(".asar")).sort()
const checksums = await BluebirdPromise.map(names, it => hashFile(path.join(resourcesPath, it), "sha512", "base64"))
Expand Down
3 changes: 2 additions & 1 deletion packages/electron-builder-core/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AsarIntegrityOptions } from "asar-integrity"
import { Publish } from "electron-builder-http/out/publishOptions"

export enum Arch {
Expand Down Expand Up @@ -160,7 +161,7 @@ export interface FilePattern {
filter?: Array<string> | string
}

export interface AsarOptions {
export interface AsarOptions extends AsarIntegrityOptions {
smartUnpack?: boolean

ordering?: string | null
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/platformPackager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { computeData } from "asar-integrity"
import BluebirdPromise from "bluebird-lst"
import { Arch, AsarOptions, FileAssociation, getArchSuffix, Platform, PlatformSpecificBuildOptions, Target, TargetSpecificOptions } from "electron-builder-core"
import { asArray, debug, isEmptyOrSpaces, Lazy, use } from "electron-builder-util"
Expand All @@ -15,7 +16,6 @@ import { Config } from "./metadata"
import { unpackElectron, unpackMuon } from "./packager/dirPackager"
import { BuildInfo, PackagerOptions } from "./packagerApi"
import { readInstalled } from "./readInstalled"
import { computeData } from "asar-integrity"

export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions> {
readonly packagerOptions: PackagerOptions
Expand Down Expand Up @@ -209,7 +209,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
await BluebirdPromise.all(promises)

if (platformName === "darwin" || platformName === "mas") {
await (<any>require("./packager/mac")).createApp(this, appOutDir, asarOptions == null ? null : await computeData(resourcesPath))
await (<any>require("./packager/mac")).createApp(this, appOutDir, asarOptions == null ? null : await computeData(resourcesPath, asarOptions.externalAllowed ? {externalAllowed: true} : null))
}

await copyFiles(extraResourceMatchers)
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3349,8 +3349,8 @@ typical@^2.4.2, typical@^2.6.0, typical@^2.6.1:
resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d"

uglify-js@^2.6:
version "2.8.27"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.27.tgz#47787f912b0f242e5b984343be8e35e95f694c9c"
version "2.8.28"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.28.tgz#e335032df9bb20dcb918f164589d5af47f38834a"
dependencies:
source-map "~0.5.1"
yargs "~3.10.0"
Expand Down

0 comments on commit e0d7974

Please sign in to comment.