From 12d439ff9fcfbc2ebf4718207feccea159ed7b6c Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Wed, 5 Jul 2023 16:50:15 -0400 Subject: [PATCH] update pinLockType states and add jsdocs --- libs/angular/src/auth/components/lock.component.ts | 7 +++---- .../vaultTimeout/vaultTimeoutSettings.service.ts | 11 ++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/angular/src/auth/components/lock.component.ts b/libs/angular/src/auth/components/lock.component.ts index c047e4a219..f0385a00db 100644 --- a/libs/angular/src/auth/components/lock.component.ts +++ b/libs/angular/src/auth/components/lock.component.ts @@ -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 = diff --git a/libs/common/src/services/vaultTimeout/vaultTimeoutSettings.service.ts b/libs/common/src/services/vaultTimeout/vaultTimeoutSettings.service.ts index a5fc9d6c93..68a92ddd87 100644 --- a/libs/common/src/services/vaultTimeout/vaultTimeoutSettings.service.ts +++ b/libs/common/src/services/vaultTimeout/vaultTimeoutSettings.service.ts @@ -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"; }