diff --git a/src/services/desktopStorage.service.ts b/src/services/desktopStorage.service.ts index b6cdd137d0..ee615adadd 100644 --- a/src/services/desktopStorage.service.ts +++ b/src/services/desktopStorage.service.ts @@ -1,8 +1,23 @@ -import { StorageService } from 'jslib/abstractions'; +import { StorageService } from 'jslib/abstractions/storage.service'; + +import { ConstantsService } from 'jslib/services/constants.service'; // tslint:disable-next-line const Store = require('electron-store'); -const store = new Store(); + +const storeConfig: any = { + defaults: {} as any, + name: 'bitwarden-data', +}; + +// Default lock options to "on restart". +storeConfig.defaults[ConstantsService.lockOptionKey] = -1; +// Portable builds should not use app data +if (process.env.PORTABLE_EXECUTABLE_DIR != null) { + storeConfig.cwd = process.env.PORTABLE_EXECUTABLE_DIR; +} + +const store = new Store(storeConfig); export class DesktopStorageService implements StorageService { get(key: string): Promise {