Skip to content

Commit

Permalink
feat: remove restart functionality from vault service
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgeron committed Apr 18, 2024
1 parent 2a42b91 commit 04c21a8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/app/src/systems/CRX/background/services/VaultService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -39,12 +38,9 @@ export class VaultService extends VaultServer {
return dbLoadedCorrectly && (!isLocked || !!(secret && isLocked));
}

async unlock({
password,
shouldSave = true,
}: { password: string; shouldSave?: boolean }): Promise<void> {
async unlock({ password }: { password: string }): Promise<void> {
await super.unlock({ password });
shouldSave && saveSecret(password, AUTO_LOCK_IN_MINUTES);
saveSecret(password, AUTO_LOCK_IN_MINUTES);
}

async lock(): Promise<void> {
Expand All @@ -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()) {
Expand All @@ -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 });
}
}

Expand Down

0 comments on commit 04c21a8

Please sign in to comment.