mirror of
https://github.com/bitwarden/browser
synced 2026-01-06 02:23:44 +00:00
support for unlocking with PIN code
This commit is contained in:
@@ -18,6 +18,7 @@ export class ConstantsService {
|
||||
static readonly dontShowCardsCurrentTab: string = 'dontShowCardsCurrentTab';
|
||||
static readonly dontShowIdentitiesCurrentTab: string = 'dontShowIdentitiesCurrentTab';
|
||||
static readonly defaultUriMatch: string = 'defaultUriMatch';
|
||||
static readonly pinProtectedKey: string = 'pinProtectedKey';
|
||||
|
||||
readonly environmentUrlsKey: string = ConstantsService.environmentUrlsKey;
|
||||
readonly disableGaKey: string = ConstantsService.disableGaKey;
|
||||
@@ -37,4 +38,5 @@ export class ConstantsService {
|
||||
readonly dontShowCardsCurrentTab: string = ConstantsService.dontShowCardsCurrentTab;
|
||||
readonly dontShowIdentitiesCurrentTab: string = ConstantsService.dontShowIdentitiesCurrentTab;
|
||||
readonly defaultUriMatch: string = ConstantsService.defaultUriMatch;
|
||||
readonly pinProtectedKey: string = ConstantsService.pinProtectedKey;
|
||||
}
|
||||
|
||||
@@ -266,6 +266,10 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
return this.storageService.remove(Keys.encOrgKeys);
|
||||
}
|
||||
|
||||
clearPinProtectedKey(): Promise<any> {
|
||||
return this.storageService.remove(ConstantsService.pinProtectedKey);
|
||||
}
|
||||
|
||||
clearKeys(): Promise<any> {
|
||||
return Promise.all([
|
||||
this.clearKey(),
|
||||
@@ -273,6 +277,7 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
this.clearOrgKeys(),
|
||||
this.clearEncKey(),
|
||||
this.clearKeyPair(),
|
||||
this.clearPinProtectedKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -319,6 +324,11 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
return [publicB64, privateEnc];
|
||||
}
|
||||
|
||||
async makePinKey(pin: string, salt: string): Promise<SymmetricCryptoKey> {
|
||||
const pinKey = await this.makeKey(pin, salt, KdfType.PBKDF2_SHA256, 100000);
|
||||
return await this.stretchKey(pinKey);
|
||||
}
|
||||
|
||||
async hashPassword(password: string, key: SymmetricCryptoKey): Promise<string> {
|
||||
if (key == null) {
|
||||
key = await this.getKey();
|
||||
|
||||
@@ -87,4 +87,9 @@ export class LockService implements LockServiceAbstraction {
|
||||
await this.storageService.save(ConstantsService.lockOptionKey, lockOption);
|
||||
await this.cryptoService.toggleKey();
|
||||
}
|
||||
|
||||
async isPinLockSet(): Promise<boolean> {
|
||||
const pinProtectedKey = await this.storageService.get<string>(ConstantsService.pinProtectedKey);
|
||||
return pinProtectedKey != null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user