From 04c21a8245fe863ea94a516ed33af250c12dec36 Mon Sep 17 00:00:00 2001 From: Arthur Geron <3487334+arthurgeron@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:56:11 -0300 Subject: [PATCH] feat: remove restart functionality from vault service --- .../systems/CRX/background/services/VaultService.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/app/src/systems/CRX/background/services/VaultService.ts b/packages/app/src/systems/CRX/background/services/VaultService.ts index 940ef8ca3..606507094 100644 --- a/packages/app/src/systems/CRX/background/services/VaultService.ts +++ b/packages/app/src/systems/CRX/background/services/VaultService.ts @@ -20,7 +20,6 @@ import type { CommunicationProtocol } from './CommunicationProtocol'; export class VaultService extends VaultServer { readonly communicationProtocol: CommunicationProtocol; - private autoLockInterval?: NodeJS.Timeout; constructor(communicationProtocol: CommunicationProtocol) { super(); @@ -39,12 +38,9 @@ export class VaultService extends VaultServer { return dbLoadedCorrectly && (!isLocked || !!(secret && isLocked)); } - async unlock({ - password, - shouldSave = true, - }: { password: string; shouldSave?: boolean }): Promise { + async unlock({ password }: { password: string }): Promise { await super.unlock({ password }); - shouldSave && saveSecret(password, AUTO_LOCK_IN_MINUTES); + saveSecret(password, AUTO_LOCK_IN_MINUTES); } async lock(): Promise { @@ -67,7 +63,7 @@ export class VaultService extends VaultServer { async autoLock() { // Check every second if the timer has expired // If so, clear the secret and lock the vault - this.autoLockInterval = setInterval(async () => { + setInterval(async () => { const timer = await getTimer(); if (timer === 0) return; if (timer < Date.now()) { @@ -81,7 +77,7 @@ export class VaultService extends VaultServer { const secret = await loadSecret(); if (secret) { // Unlock vault directly without saving a new timestamp - await this.unlock({ password: secret, shouldSave: false }); + await super.unlock({ password: secret }); } }