diff --git a/app/background.html b/app/background.html index 447efa60e..6a0150579 100644 --- a/app/background.html +++ b/app/background.html @@ -6,7 +6,7 @@ - {{@if(it.useLavamoat)}} + {{@if(it.applyLavaMoat)}} diff --git a/app/home.html b/app/home.html index d44eb6663..97334c73c 100644 --- a/app/home.html +++ b/app/home.html @@ -12,7 +12,7 @@
- {{@if(it.useLavamoat)}} + {{@if(it.applyLavaMoat)}} diff --git a/app/notification.html b/app/notification.html index 1002a37ef..1f348f680 100644 --- a/app/notification.html +++ b/app/notification.html @@ -35,7 +35,7 @@
- {{@if(it.useLavamoat)}} + {{@if(it.applyLavaMoat)}} diff --git a/app/popup.html b/app/popup.html index e24978ad7..90117fc79 100644 --- a/app/popup.html +++ b/app/popup.html @@ -12,7 +12,7 @@
- {{@if(it.useLavamoat)}} + {{@if(it.applyLavaMoat)}} diff --git a/development/build/index.js b/development/build/index.js index 7e88bcfb2..fd6dd1b76 100755 --- a/development/build/index.js +++ b/development/build/index.js @@ -57,6 +57,7 @@ defineAndRunBuildTasks(); function defineAndRunBuildTasks() { const { + applyLavaMoat, buildType, entryTask, isLavaMoat, @@ -89,6 +90,7 @@ function defineAndRunBuildTasks() { const styleTasks = createStyleTasks({ livereload }); const scriptTasks = createScriptTasks({ + applyLavaMoat, browserPlatforms, buildType, ignoredFiles, @@ -170,6 +172,7 @@ function defineAndRunBuildTasks() { function parseArgv() { const NamedArgs = { + ApplyLavaMoat: 'apply-lavamoat', BuildType: 'build-type', BuildVersion: 'build-version', LintFenceFiles: 'lint-fence-files', @@ -180,6 +183,7 @@ function parseArgv() { const argv = minimist(process.argv.slice(2), { boolean: [ + NamedArgs.ApplyLavaMoat, NamedArgs.LintFenceFiles, NamedArgs.Lockdown, NamedArgs.PolicyOnly, @@ -187,6 +191,7 @@ function parseArgv() { ], string: [NamedArgs.BuildType, NamedArgs.BuildVersion], default: { + [NamedArgs.ApplyLavaMoat]: true, [NamedArgs.BuildType]: BuildType.main, [NamedArgs.BuildVersion]: '0', [NamedArgs.LintFenceFiles]: true, @@ -232,8 +237,11 @@ function parseArgv() { const version = getVersion(buildType, buildVersion); return { + // Should we apply LavaMoat to the build output? + applyLavaMoat: argv[NamedArgs.ApplyLavaMoat], buildType, entryTask, + // Is this process running in lavamoat-node? isLavaMoat: process.argv[0].includes('lavamoat'), policyOnly, shouldIncludeLockdown: argv[NamedArgs.Lockdown], diff --git a/development/build/scripts.js b/development/build/scripts.js index 515f9ac6e..4379e8348 100644 --- a/development/build/scripts.js +++ b/development/build/scripts.js @@ -183,6 +183,7 @@ const noopWriteStream = through.obj((_file, _fileEncoding, callback) => module.exports = createScriptTasks; function createScriptTasks({ + applyLavaMoat, browserPlatforms, buildType, ignoredFiles, @@ -223,6 +224,7 @@ function createScriptTasks({ const standardSubtask = createTask( `${taskPrefix}:standardEntryPoints`, createFactoredBuild({ + applyLavaMoat, browserPlatforms, buildType, devMode, @@ -363,6 +365,7 @@ function createScriptTasks({ } function createFactoredBuild({ + applyLavaMoat, browserPlatforms, buildType, devMode, @@ -493,21 +496,21 @@ function createFactoredBuild({ groupSet, commonSet, browserPlatforms, - useLavamoat: true, + applyLavaMoat, }); renderHtmlFile({ htmlName: 'notification', groupSet, commonSet, browserPlatforms, - useLavamoat: true, + applyLavaMoat, }); renderHtmlFile({ htmlName: 'home', groupSet, commonSet, browserPlatforms, - useLavamoat: true, + applyLavaMoat, }); break; } @@ -517,7 +520,7 @@ function createFactoredBuild({ groupSet, commonSet, browserPlatforms, - useLavamoat: true, + applyLavaMoat, }); break; } @@ -527,7 +530,7 @@ function createFactoredBuild({ groupSet, commonSet, browserPlatforms, - useLavamoat: false, + applyLavaMoat: false, }); break; } @@ -879,11 +882,11 @@ function renderHtmlFile({ groupSet, commonSet, browserPlatforms, - useLavamoat, + applyLavaMoat, }) { - if (useLavamoat === undefined) { + if (applyLavaMoat === undefined) { throw new Error( - 'build/scripts/renderHtmlFile - must specify "useLavamoat" option', + 'build/scripts/renderHtmlFile - must specify "applyLavaMoat" option', ); } const htmlFilePath = `./app/${htmlName}.html`; @@ -891,7 +894,7 @@ function renderHtmlFile({ const jsBundles = [...commonSet.values(), ...groupSet.values()].map( (label) => `./${label}.js`, ); - const htmlOutput = Sqrl.render(htmlTemplate, { jsBundles, useLavamoat }); + const htmlOutput = Sqrl.render(htmlTemplate, { jsBundles, applyLavaMoat }); browserPlatforms.forEach((platform) => { const dest = `./dist/${platform}/${htmlName}.html`; // we dont have a way of creating async events atm diff --git a/package.json b/package.json index e5b763215..a7e10f695 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ "scripts": { "setup": "yarn install && yarn setup:postinstall", "setup:postinstall": "yarn patch-package && yarn allow-scripts", - "start": "yarn build:dev dev", - "start:lavamoat": "yarn build dev", + "start": "yarn build:dev --apply-lavamoat=false", + "start:lavamoat": "yarn build:dev --apply-lavamoat=true", "dist": "yarn build prod", "build": "yarn lavamoat:build", - "build:dev": "node development/build/index.js", + "build:dev": "node development/build/index.js dev", "start:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' yarn build testDev", "benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/benchmark.js", "benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/benchmark.js",