From 29d538c3e64d70dc19343c1e0c95f169a695dfd2 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 7 Jun 2021 14:50:56 -0400 Subject: [PATCH 1/8] Include main process source maps for debugging --- webpack.main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webpack.main.js b/webpack.main.js index ad101bcefa..2261069320 100644 --- a/webpack.main.js +++ b/webpack.main.js @@ -28,7 +28,9 @@ const common = { output: { filename: '[name].js', path: path.resolve(__dirname, 'build'), + devtoolModuleFilenameTemplate: '[absolute-resource-path]', }, + devtool: 'cheap-source-map' }; const main = { From 05e9419d658c014a31ac2f374a62c4e80cec4bd9 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Mon, 7 Jun 2021 17:16:45 -0400 Subject: [PATCH 2/8] Request biometrically secured stored key --- src/main.ts | 3 ++- src/services/nativeMessaging.service.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 01e044e6f8..aff61bc02a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -109,7 +109,6 @@ export class Main { this.messagingMain.onMessage(message); }); - this.keytarStorageListener = new KeytarStorageListener('Bitwarden'); if (process.platform === 'win32') { const BiometricWindowsMain = require('jslib-electron/biometric.windows.main').default; @@ -119,6 +118,8 @@ export class Main { this.biometricMain = new BiometricDarwinMain(this.storageService, this.i18nService); } + this.keytarStorageListener = new KeytarStorageListener('Bitwarden', this.biometricMain); + this.nativeMessagingMain = new NativeMessagingMain(this.logService, this.windowMain, app.getPath('userData'), app.getPath('exe')); } diff --git a/src/services/nativeMessaging.service.ts b/src/services/nativeMessaging.service.ts index 6e0d6b4585..b63f5695da 100644 --- a/src/services/nativeMessaging.service.ts +++ b/src/services/nativeMessaging.service.ts @@ -102,11 +102,12 @@ export class NativeMessagingService { }); } - const response = await this.platformUtilService.authenticateBiometric(); - if (response) { - this.send({command: 'biometricUnlock', response: 'unlocked', keyB64: (await this.cryptoService.getKey()).keyB64}, appId); + const keyB64 = await (await this.cryptoService.getKey('biometric')).keyB64; + + if (keyB64 != null) { + this.send({ command: 'biometricUnlock', response: 'unlocked', keyB64: keyB64 }, appId); } else { - this.send({command: 'biometricUnlock', response: 'canceled'}, appId); + this.send({ command: 'biometricUnlock', response: 'canceled' }, appId); } break; From ecd22e4d4588d8fae56418e88d2e543f44184ac9 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 9 Jun 2021 16:56:12 -0400 Subject: [PATCH 3/8] Update jslib --- jslib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jslib b/jslib index fdc6f7b1d2..5ba1416679 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit fdc6f7b1d234c72724db47cbea6c94bff7ec0106 +Subproject commit 5ba1416679f112e42e4b5dbd5c47949dcd8d0b56 From e751d24b3579e3da067bbf307d716242c60abdbe Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Thu, 10 Jun 2021 12:50:59 -0400 Subject: [PATCH 4/8] Supply main sourcemaps only in dev builds --- package.json | 7 +++++-- webpack.main.js | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cb5675c0b3..a66ba4a342 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,13 @@ "lint": "tslint 'src/**/*.ts'", "lint:fix": "tslint 'src/**/*.ts' --fix", "build": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main\" \"npm run build:renderer\"", + "build:dev": "NODE_ENV='development' npm run build", "build:main": "webpack --config webpack.main.js", + "build:main:dev": "NODE_ENV='development' npm run build:main", "build:renderer": "gulp prebuild:renderer && webpack --config webpack.renderer.js", - "build:renderer:watch": "gulp prebuild:renderer && webpack --config webpack.renderer.js --watch", - "electron": "npm run build:main && concurrently -k -n Main,Rend -c yellow,cyan \"electron --inspect=5858 ./build --watch\" \"npm run build:renderer:watch\"", + "build:renderer:dev": "NODE_ENV='development' npm run build:renderer", + "build:renderer:watch": "NODE_ENV='development' gulp prebuild:renderer && webpack --config webpack.renderer.js --watch", + "electron": "npm run build:main:dev && concurrently -k -n Main,Rend -c yellow,cyan \"electron --inspect=5858 ./build --watch\" \"npm run build:renderer:watch\"", "clean:dist": "rimraf ./dist/*", "clean:l10n": "git push origin --delete l10n_master", "pack:dir": "npm run clean:dist && electron-builder --dir -p never", diff --git a/webpack.main.js b/webpack.main.js index 2261069320..79ed96eba6 100644 --- a/webpack.main.js +++ b/webpack.main.js @@ -5,6 +5,8 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const nodeExternals = require('webpack-node-externals'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); +const NODE_ENV = process.env.NODE_ENV == null ? 'production' : process.env.NODE_ENV; + const common = { module: { rules: [ @@ -25,16 +27,26 @@ const common = { extensions: ['.tsx', '.ts', '.js'], plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.json' })] }, +}; + +const prod = { + output: { + filename: '[name].js', + path: path.resolve(__dirname, 'build'), + }, +}; + +const dev = { output: { filename: '[name].js', path: path.resolve(__dirname, 'build'), devtoolModuleFilenameTemplate: '[absolute-resource-path]', }, devtool: 'cheap-source-map' -}; +} const main = { - mode: 'production', + mode: NODE_ENV, target: 'electron-main', node: { __dirname: false, @@ -67,4 +79,4 @@ const main = { externals: [nodeExternals()], }; -module.exports = merge(common, main); +module.exports = merge(common, NODE_ENV === 'development' ? dev : prod, main); From fc015bd4cb4123aab308e5eec8fc44f27a9a4794 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Thu, 10 Jun 2021 15:37:39 -0400 Subject: [PATCH 5/8] Default to development environment settings --- package.json | 12 ++++++------ webpack.main.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a66ba4a342..50d5ef35af 100644 --- a/package.json +++ b/package.json @@ -30,12 +30,12 @@ "lint": "tslint 'src/**/*.ts'", "lint:fix": "tslint 'src/**/*.ts' --fix", "build": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main\" \"npm run build:renderer\"", - "build:dev": "NODE_ENV='development' npm run build", - "build:main": "webpack --config webpack.main.js", - "build:main:dev": "NODE_ENV='development' npm run build:main", - "build:renderer": "gulp prebuild:renderer && webpack --config webpack.renderer.js", - "build:renderer:dev": "NODE_ENV='development' npm run build:renderer", - "build:renderer:watch": "NODE_ENV='development' gulp prebuild:renderer && webpack --config webpack.renderer.js --watch", + "build:dev": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main:dev\" \"npm run build:renderer:dev\"", + "build:main": "cross-env NODE_ENV=production webpack --config webpack.main.js", + "build:main:dev": "cross-env NODE_ENV=development webpack --config webpack.main.js", + "build:renderer": "gulp prebuild:renderer && cross-env NODE_ENV=production webpack --config webpack.renderer.js", + "build:renderer:dev": "gulp prebuild:renderer && cross-env NODE_ENV=development webpack --config webpack.renderer.js", + "build:renderer:watch": "gulp prebuild:renderer && cross-env NODE_ENV=development webpack --config webpack.renderer.js --watch", "electron": "npm run build:main:dev && concurrently -k -n Main,Rend -c yellow,cyan \"electron --inspect=5858 ./build --watch\" \"npm run build:renderer:watch\"", "clean:dist": "rimraf ./dist/*", "clean:l10n": "git push origin --delete l10n_master", diff --git a/webpack.main.js b/webpack.main.js index 79ed96eba6..ad667b2ade 100644 --- a/webpack.main.js +++ b/webpack.main.js @@ -5,7 +5,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const nodeExternals = require('webpack-node-externals'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); -const NODE_ENV = process.env.NODE_ENV == null ? 'production' : process.env.NODE_ENV; +const NODE_ENV = process.env.NODE_ENV == null ? 'development' : process.env.NODE_ENV; const common = { module: { From 1b96afe28380c18116a2b62433e925bd0f56ef6c Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Fri, 11 Jun 2021 13:17:31 -0400 Subject: [PATCH 6/8] Cache npm directory and always run `npm ci` --- .github/workflows/build.yml | 60 +++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d37d9b665..1261bea47d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Cache npm + id: npm-cache + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + with: + path: '.npm' + key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Set Node options run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV @@ -71,8 +78,7 @@ jobs: shell: pwsh - name: Install Node dependencies - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm install + run: npm ci --cache .npm - name: Run linter run: npm run lint @@ -139,6 +145,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Cache npm + id: npm-cache + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + with: + path: '.npm' + key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Set Node options run: echo "NODE_OPTIONS=--max_old_space_size=4096" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append shell: pwsh @@ -185,8 +198,7 @@ jobs: shell: pwsh - name: Install Node dependencies - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm install + run: npm ci --cache .npm - name: Run linter run: npm run lint @@ -285,6 +297,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Cache npm + id: npm-cache + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + with: + path: '.npm' + key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Set Node options run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV @@ -345,8 +364,7 @@ jobs: shell: pwsh - name: Install Node dependencies - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm install + run: npm ci --cache .npm - name: Run linter run: npm run lint @@ -389,6 +407,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Cache npm + id: npm-cache + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + with: + path: '.npm' + key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Set Node options run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV @@ -449,8 +474,7 @@ jobs: shell: pwsh - name: NPM install - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm install + run: npm ci --cache .npm - name: Build if: steps.build-cache.outputs.cache-hit != 'true' @@ -520,6 +544,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Cache npm + id: npm-cache + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + with: + path: '.npm' + key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Set Node options run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV @@ -580,8 +611,7 @@ jobs: shell: pwsh - name: NPM install - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm install + run: npm ci --cache .npm - name: Build if: steps.build-cache.outputs.cache-hit != 'true' @@ -646,6 +676,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} + - name: Cache npm + id: npm-cache + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + with: + path: '.npm' + key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Set Node options run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV @@ -706,8 +743,7 @@ jobs: shell: pwsh - name: NPM install - if: steps.node-modules-cache.outputs.cache-hit != 'true' - run: npm install + run: npm ci --cache .npm - name: Build if: steps.build-cache.outputs.cache-hit != 'true' From 1fc8c0257907e29c7c9b481abf81089a81263f8b Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Fri, 11 Jun 2021 13:34:17 -0400 Subject: [PATCH 7/8] Remove node_modules cache `npm ci` deletes node_modules as a first step, so makes no sense to cache --- .github/workflows/build.yml | 42 ------------------------------------- 1 file changed, 42 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1261bea47d..7ff05c582b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,13 +34,6 @@ jobs: with: node-version: '14' - - name: Cache Node Modules - id: node-modules-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 - with: - path: '**/node_modules' - key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} - - name: Cache npm id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 @@ -138,13 +131,6 @@ jobs: with: node-version: '14' - - name: Cache Node Modules - id: node-modules-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 - with: - path: '**/node_modules' - key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} - - name: Cache npm id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 @@ -290,13 +276,6 @@ jobs: with: node-version: '14' - - name: Cache Node Modules - id: node-modules-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 - with: - path: '**/node_modules' - key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} - - name: Cache npm id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 @@ -400,13 +379,6 @@ jobs: with: node-version: '14' - - name: Cache Node Modules - id: node-modules-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 - with: - path: '**/node_modules' - key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} - - name: Cache npm id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 @@ -537,13 +509,6 @@ jobs: with: node-version: '14' - - name: Cache Node Modules - id: node-modules-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 - with: - path: '**/node_modules' - key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} - - name: Cache npm id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 @@ -669,13 +634,6 @@ jobs: with: node-version: '14' - - name: Cache Node Modules - id: node-modules-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 - with: - path: '**/node_modules' - key: ${{ runner.os }}-${{ github.run_id }}-node-${{ hashFiles('**/package-lock.json') }} - - name: Cache npm id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 From db688d208d136a45d2df8365a47d2933c26c19cd Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Fri, 11 Jun 2021 14:05:28 -0400 Subject: [PATCH 8/8] Use default cache directory --- .github/workflows/build.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ff05c582b..4298a7ff62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '.npm' + path: '~/.npm' key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set Node options @@ -71,7 +71,7 @@ jobs: shell: pwsh - name: Install Node dependencies - run: npm ci --cache .npm + run: npm ci - name: Run linter run: npm run lint @@ -135,7 +135,7 @@ jobs: id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '.npm' + path: '%AppData%/npm-cache' key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set Node options @@ -184,7 +184,7 @@ jobs: shell: pwsh - name: Install Node dependencies - run: npm ci --cache .npm + run: npm ci - name: Run linter run: npm run lint @@ -280,7 +280,7 @@ jobs: id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '.npm' + path: '~/.npm' key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set Node options @@ -343,7 +343,7 @@ jobs: shell: pwsh - name: Install Node dependencies - run: npm ci --cache .npm + run: npm ci - name: Run linter run: npm run lint @@ -383,7 +383,7 @@ jobs: id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '.npm' + path: '~/.npm' key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set Node options @@ -446,7 +446,7 @@ jobs: shell: pwsh - name: NPM install - run: npm ci --cache .npm + run: npm ci - name: Build if: steps.build-cache.outputs.cache-hit != 'true' @@ -513,7 +513,7 @@ jobs: id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '.npm' + path: '~/.npm' key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set Node options @@ -576,7 +576,7 @@ jobs: shell: pwsh - name: NPM install - run: npm ci --cache .npm + run: npm ci - name: Build if: steps.build-cache.outputs.cache-hit != 'true' @@ -638,7 +638,7 @@ jobs: id: npm-cache uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '.npm' + path: '~/.npm' key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set Node options @@ -701,7 +701,7 @@ jobs: shell: pwsh - name: NPM install - run: npm ci --cache .npm + run: npm ci - name: Build if: steps.build-cache.outputs.cache-hit != 'true'