mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[Auto-Logout] Implement Vault Timeout Options (#1194)
* Update jslib31a2574->28e3fff* Initial commit for vault timeout * Updated timeout/action retrieval in idle.background * Cycle saved for idle check * Await async calls for lock/logout in idle bg * Updated lock vs log out conditional Co-authored-by: Vincent Salucci <vsalucci@bitwarden.com>
This commit is contained in:
@@ -11,13 +11,13 @@ import {
|
||||
CryptoService,
|
||||
EnvironmentService,
|
||||
FolderService,
|
||||
LockService,
|
||||
PasswordGenerationService,
|
||||
SettingsService,
|
||||
SyncService,
|
||||
TokenService,
|
||||
TotpService,
|
||||
UserService,
|
||||
VaultTimeoutService,
|
||||
} from 'jslib/services';
|
||||
import { EventService } from 'jslib/services/event.service';
|
||||
import { ExportService } from 'jslib/services/export.service';
|
||||
@@ -37,7 +37,6 @@ import {
|
||||
EnvironmentService as EnvironmentServiceAbstraction,
|
||||
FolderService as FolderServiceAbstraction,
|
||||
I18nService as I18nServiceAbstraction,
|
||||
LockService as LockServiceAbstraction,
|
||||
MessagingService as MessagingServiceAbstraction,
|
||||
PasswordGenerationService as PasswordGenerationServiceAbstraction,
|
||||
PlatformUtilsService as PlatformUtilsServiceAbstraction,
|
||||
@@ -47,6 +46,7 @@ import {
|
||||
TokenService as TokenServiceAbstraction,
|
||||
TotpService as TotpServiceAbstraction,
|
||||
UserService as UserServiceAbstraction,
|
||||
VaultTimeoutService as VaultTimeoutServiceAbstraction,
|
||||
} from 'jslib/abstractions';
|
||||
import { EventService as EventServiceAbstraction } from 'jslib/abstractions/event.service';
|
||||
import { ExportService as ExportServiceAbstraction } from 'jslib/abstractions/export.service';
|
||||
@@ -94,7 +94,7 @@ export default class MainBackground {
|
||||
cipherService: CipherServiceAbstraction;
|
||||
folderService: FolderServiceAbstraction;
|
||||
collectionService: CollectionServiceAbstraction;
|
||||
lockService: LockServiceAbstraction;
|
||||
vaultTimeoutService: VaultTimeoutServiceAbstraction;
|
||||
syncService: SyncServiceAbstraction;
|
||||
passwordGenerationService: PasswordGenerationServiceAbstraction;
|
||||
totpService: TotpServiceAbstraction;
|
||||
@@ -156,9 +156,9 @@ export default class MainBackground {
|
||||
this.i18nService);
|
||||
this.searchService = new SearchService(this.cipherService, this.platformUtilsService);
|
||||
this.policyService = new PolicyService(this.userService, this.storageService);
|
||||
this.lockService = new LockService(this.cipherService, this.folderService, this.collectionService,
|
||||
this.cryptoService, this.platformUtilsService, this.storageService, this.messagingService,
|
||||
this.searchService, this.userService, async () => {
|
||||
this.vaultTimeoutService = new VaultTimeoutService(this.cipherService, this.folderService,
|
||||
this.collectionService, this.cryptoService, this.platformUtilsService, this.storageService,
|
||||
this.messagingService, this.searchService, this.userService, async () => {
|
||||
if (this.notificationsService != null) {
|
||||
this.notificationsService.updateConnection(false);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ export default class MainBackground {
|
||||
this.systemService.startProcessReload();
|
||||
await this.systemService.clearPendingClipboard();
|
||||
}
|
||||
});
|
||||
}, async () => await this.logout(false));
|
||||
this.syncService = new SyncService(this.userService, this.apiService, this.settingsService,
|
||||
this.folderService, this.cipherService, this.cryptoService, this.collectionService,
|
||||
this.storageService, this.messagingService, this.policyService,
|
||||
@@ -184,12 +184,12 @@ export default class MainBackground {
|
||||
this.auditService = new AuditService(cryptoFunctionService, this.apiService);
|
||||
this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService);
|
||||
this.notificationsService = new NotificationsService(this.userService, this.syncService, this.appIdService,
|
||||
this.apiService, this.lockService, () => this.logout(true));
|
||||
this.apiService, this.vaultTimeoutService, () => this.logout(true));
|
||||
this.environmentService = new EnvironmentService(this.apiService, this.storageService,
|
||||
this.notificationsService);
|
||||
this.analytics = new Analytics(window, () => BrowserApi.gaFilter(), this.platformUtilsService,
|
||||
this.storageService, this.appIdService);
|
||||
this.systemService = new SystemService(this.storageService, this.lockService,
|
||||
this.systemService = new SystemService(this.storageService, this.vaultTimeoutService,
|
||||
this.messagingService, this.platformUtilsService, () => {
|
||||
const forceWindowReload = this.platformUtilsService.isSafari() ||
|
||||
this.platformUtilsService.isFirefox() || this.platformUtilsService.isOpera();
|
||||
@@ -205,18 +205,19 @@ export default class MainBackground {
|
||||
// Background
|
||||
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
||||
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
|
||||
this.analytics, this.notificationsService, this.systemService, this.lockService);
|
||||
this.analytics, this.notificationsService, this.systemService, this.vaultTimeoutService);
|
||||
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService,
|
||||
this.platformUtilsService, this.analytics, this.lockService);
|
||||
this.platformUtilsService, this.analytics, this.vaultTimeoutService);
|
||||
|
||||
if (!this.isSafari) {
|
||||
this.tabsBackground = new TabsBackground(this);
|
||||
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
|
||||
this.passwordGenerationService, this.analytics, this.platformUtilsService, this.lockService,
|
||||
this.passwordGenerationService, this.analytics, this.platformUtilsService, this.vaultTimeoutService,
|
||||
this.eventService, this.totpService);
|
||||
this.idleBackground = new IdleBackground(this.lockService, this.storageService, this.notificationsService);
|
||||
this.idleBackground = new IdleBackground(this.vaultTimeoutService, this.storageService,
|
||||
this.notificationsService);
|
||||
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService,
|
||||
this.lockService);
|
||||
this.vaultTimeoutService);
|
||||
this.windowsBackground = new WindowsBackground(this);
|
||||
}
|
||||
}
|
||||
@@ -226,7 +227,7 @@ export default class MainBackground {
|
||||
this.analytics.ga('send', 'pageview', '/background.html');
|
||||
this.containerService.attachToWindow(window);
|
||||
|
||||
await (this.lockService as LockService).init(true);
|
||||
await (this.vaultTimeoutService as VaultTimeoutService).init(true);
|
||||
await (this.i18nService as I18nService).init();
|
||||
await (this.eventService as EventService).init(true);
|
||||
await this.runtimeBackground.init();
|
||||
@@ -258,7 +259,7 @@ export default class MainBackground {
|
||||
}
|
||||
|
||||
const isAuthenticated = await this.userService.isAuthenticated();
|
||||
const locked = await this.lockService.isLocked();
|
||||
const locked = await this.vaultTimeoutService.isLocked();
|
||||
|
||||
let suffix = '';
|
||||
if (!isAuthenticated) {
|
||||
@@ -311,7 +312,7 @@ export default class MainBackground {
|
||||
this.collectionService.clear(userId),
|
||||
this.policyService.clear(userId),
|
||||
this.passwordGenerationService.clear(),
|
||||
this.lockService.clear(),
|
||||
this.vaultTimeoutService.clear(),
|
||||
]);
|
||||
|
||||
this.searchService.clearIndex();
|
||||
@@ -330,7 +331,7 @@ export default class MainBackground {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await this.lockService.isLocked()) {
|
||||
if (await this.vaultTimeoutService.isLocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -378,8 +379,8 @@ export default class MainBackground {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentLockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
||||
if (currentLockOption == null) {
|
||||
const currentVaultTimeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
|
||||
if (currentVaultTimeout == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -482,7 +483,7 @@ export default class MainBackground {
|
||||
this.actionSetBadgeBackgroundColor(this.sidebarAction);
|
||||
|
||||
this.menuOptionsLoaded = [];
|
||||
const locked = await this.lockService.isLocked();
|
||||
const locked = await this.vaultTimeoutService.isLocked();
|
||||
if (!locked) {
|
||||
try {
|
||||
const ciphers = await this.cipherService.getAllDecryptedForUrl(url);
|
||||
|
||||
Reference in New Issue
Block a user