1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-28 17:27:50 +01:00

[bug] Add defaults for vault timeout (#1365)

* [bug] Add state defaults for vault timeout

* [chore] Update jslib
This commit is contained in:
Addison Beck 2022-01-04 11:15:58 -05:00 committed by GitHub
parent d0e661b84b
commit d066e0586a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 2 deletions

2
jslib

@ -1 +1 @@
Subproject commit d68c1dafaf0528f5323dd595773b0fa122403d0d
Subproject commit e4cd0af2f9ae924f9b749fefe3695f7c69135bf6

View File

@ -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 {}

20
src/models/account.ts Normal file
View File

@ -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<Account>) {
super(init);
Object.assign(this.settings, {
...new AccountSettings(),
...this.settings,
});
}
}

View File

@ -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<Account> implements StateServiceAbstraction {
async addAccount(account: Account) {
// Apply web overides to default account values
account = new Account(account);
await super.addAccount(account);
}
}

View File

@ -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"]
}