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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user