1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 02:33:46 +00:00

Browser <-> desktop communication (#185)

* Add electron constant for browser integration

* Add constant for browser biometrics. Ensure biometry is locked on lock.

* Avoid saving keys outside desktop

* Fix eslint warning

* Add supportsSecureStorage helper to platformUtils to improve readability
This commit is contained in:
Oscar Hinton
2020-11-18 22:10:57 +01:00
committed by GitHub
parent f44e99d74d
commit 9e4d000b4d
8 changed files with 19 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import { ProfileOrganizationResponse } from '../models/response/profileOrganizat
import { CryptoService as CryptoServiceAbstraction } from '../abstractions/crypto.service';
import { CryptoFunctionService } from '../abstractions/cryptoFunction.service';
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
import { StorageService } from '../abstractions/storage.service';
import { ConstantsService } from './constants.service';
@@ -36,14 +37,14 @@ export class CryptoService implements CryptoServiceAbstraction {
private orgKeys: Map<string, SymmetricCryptoKey>;
constructor(private storageService: StorageService, private secureStorageService: StorageService,
private cryptoFunctionService: CryptoFunctionService) { }
private cryptoFunctionService: CryptoFunctionService, private platformUtilService: PlatformUtilsService) { }
async setKey(key: SymmetricCryptoKey): Promise<any> {
this.key = key;
const option = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
const biometric = await this.storageService.get<boolean>(ConstantsService.biometricUnlockKey);
if (option != null && !biometric) {
if (option != null && !(biometric && this.platformUtilService.supportsSecureStorage())) {
// if we have a lock option set, we do not store the key
return;
}
@@ -293,7 +294,7 @@ export class CryptoService implements CryptoServiceAbstraction {
const key = await this.getKey();
const option = await this.storageService.get(ConstantsService.vaultTimeoutKey);
const biometric = await this.storageService.get(ConstantsService.biometricUnlockKey);
if (!biometric && (option != null || option === 0)) {
if ((!biometric && this.platformUtilService.supportsSecureStorage()) && (option != null || option === 0)) {
// if we have a lock option set, clear the key
await this.clearKey();
this.key = key;