1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-08 19:18:02 +01:00

update pinLockType states and add jsdocs

This commit is contained in:
Jacob Fink 2023-07-05 16:50:15 -04:00
parent 32867e9207
commit 12d439ff9f
No known key found for this signature in database
GPG Key ID: C2F7ACF05859D008
2 changed files with 11 additions and 7 deletions

View File

@ -157,13 +157,13 @@ export class LockComponent implements OnInit, OnDestroy {
let userKeyPin: EncString;
let oldPinProtected: EncString;
switch (this.pinStatus) {
case "ENABLED": {
case "PERSISTANT": {
userKeyPin = await this.stateService.getUserKeyPin();
const oldEncryptedKey = await this.stateService.getEncryptedPinProtected();
oldPinProtected = oldEncryptedKey ? new EncString(oldEncryptedKey) : undefined;
break;
}
case "ENABLED_WITH_MP_ON_RESET": {
case "TRANSIENT": {
userKeyPin = await this.stateService.getUserKeyPinEphemeral();
oldPinProtected = await this.stateService.getDecryptedPinProtected();
break;
@ -334,8 +334,7 @@ export class LockComponent implements OnInit, OnDestroy {
let ephemeralPinSet = await this.stateService.getUserKeyPinEphemeral();
ephemeralPinSet ||= await this.stateService.getDecryptedPinProtected();
this.pinEnabled =
(this.pinStatus === "ENABLED_WITH_MP_ON_RESET" && !!ephemeralPinSet) ||
this.pinStatus === "ENABLED";
(this.pinStatus === "TRANSIENT" && !!ephemeralPinSet) || this.pinStatus === "PERSISTANT";
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
this.biometricLock =

View File

@ -7,7 +7,12 @@ import { VaultTimeoutAction } from "../../enums/vault-timeout-action.enum";
import { CryptoService } from "../../platform/abstractions/crypto.service";
import { StateService } from "../../platform/abstractions/state.service";
export type PinLockType = "DISABLED" | "ENABLED" | "ENABLED_WITH_MP_ON_RESET";
/**
* - DISABLED: No Pin set
* - PERSISTENT: Pin is set and survives client reset
* - TRANSIENT: Pin is set and requires password unlock after client reset
*/
export type PinLockType = "DISABLED" | "PERSISTANT" | "TRANSIENT";
export class VaultTimeoutSettingsService implements VaultTimeoutSettingsServiceAbstraction {
constructor(
@ -55,9 +60,9 @@ export class VaultTimeoutSettingsService implements VaultTimeoutSettingsServiceA
const anOldUserKeyPinIsSet = !!(await this.stateService.getEncryptedPinProtected());
if (aUserKeyPinIsSet || anOldUserKeyPinIsSet) {
return "ENABLED";
return "PERSISTANT";
} else if (pinIsEnabled && !aUserKeyPinIsSet && !anOldUserKeyPinIsSet) {
return "ENABLED_WITH_MP_ON_RESET";
return "TRANSIENT";
} else {
return "DISABLED";
}