Browse Source

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

* [bug] Add state defaults for vault timeout

* [chore] Update jslib
pull/1373/head
Addison Beck 4 years ago committed by GitHub
parent
commit
d066e0586a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      jslib
  2. 12
      src/app/services/services.module.ts
  3. 20
      src/models/account.ts
  4. 13
      src/services/state.service.ts
  5. 2
      tsconfig.json

2
jslib

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

12
src/app/services/services.module.ts

@ -5,6 +5,7 @@ import { BroadcasterMessagingService } from "../../services/broadcasterMessaging @@ -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 @@ -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( @@ -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

@ -0,0 +1,20 @@ @@ -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,
});
}
}

13
src/services/state.service.ts

@ -0,0 +1,13 @@ @@ -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);
}
}

2
tsconfig.json

@ -20,5 +20,5 @@ @@ -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"]
}

Loading…
Cancel
Save