diff --git a/jslib b/jslib index d68c1dafaf..e4cd0af2f9 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit d68c1dafaf0528f5323dd595773b0fa122403d0d +Subproject commit e4cd0af2f9ae924f9b749fefe3695f7c69135bf6 diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 68e30aed15..e49dc8c431 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -5,6 +5,7 @@ import { BroadcasterMessagingService } from "../../services/broadcasterMessaging import { HtmlStorageService } from "../../services/htmlStorage.service"; import { I18nService } from "../../services/i18n.service"; import { MemoryStorageService } from "../../services/memoryStorage.service"; +import { StateService } from "../../services/state.service"; import { WebPlatformUtilsService } from "../../services/webPlatformUtils.service"; import { EventService } from "./event.service"; @@ -43,6 +44,7 @@ import { MessagingService as MessagingServiceAbstraction } from "jslib-common/ab import { NotificationsService as NotificationsServiceAbstraction } from "jslib-common/abstractions/notifications.service"; import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "jslib-common/abstractions/platformUtils.service"; import { StateService as StateServiceAbstraction } from "jslib-common/abstractions/state.service"; +import { StateMigrationService as StateMigrationServiceAbstraction } from "jslib-common/abstractions/stateMigration.service"; import { StorageService as StorageServiceAbstraction } from "jslib-common/abstractions/storage.service"; import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "jslib-common/abstractions/vaultTimeout.service"; @@ -172,6 +174,16 @@ export function initFactory( StateServiceAbstraction, ], }, + { + provide: StateServiceAbstraction, + useClass: StateService, + deps: [ + StorageServiceAbstraction, + "SECURE_STORAGE", + LogService, + StateMigrationServiceAbstraction, + ], + }, ], }) export class ServicesModule {} diff --git a/src/models/account.ts b/src/models/account.ts new file mode 100644 index 0000000000..b45c40b1ad --- /dev/null +++ b/src/models/account.ts @@ -0,0 +1,20 @@ +import { + Account as BaseAccount, + AccountSettings as BaseAccountSettings, +} from "jslib-common/models/domain/account"; + +export class AccountSettings extends BaseAccountSettings { + vaultTimeout: number = process.env.NODE_ENV === "development" ? null : 15; +} + +export class Account extends BaseAccount { + settings?: AccountSettings = new AccountSettings(); + + constructor(init: Partial) { + super(init); + Object.assign(this.settings, { + ...new AccountSettings(), + ...this.settings, + }); + } +} diff --git a/src/services/state.service.ts b/src/services/state.service.ts new file mode 100644 index 0000000000..a46a7fe5a2 --- /dev/null +++ b/src/services/state.service.ts @@ -0,0 +1,13 @@ +import { StateService as BaseStateService } from "jslib-common/services/state.service"; + +import { Account } from "../models/account"; + +import { StateService as StateServiceAbstraction } from "jslib-common/abstractions/state.service"; + +export class StateService extends BaseStateService implements StateServiceAbstraction { + async addAccount(account: Account) { + // Apply web overides to default account values + account = new Account(account); + await super.addAccount(account); + } +} diff --git a/tsconfig.json b/tsconfig.json index 3066090912..5993e136b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,5 +20,5 @@ "preserveWhitespaces": true }, "files": ["src/app/polyfills.ts", "src/app/main.ts", "bitwarden_license/src/app/main.ts"], - "include": ["src/connectors/*.ts"] + "include": ["src/connectors/*.ts", "src/models/*.ts", "src/services/*.ts"] }