mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
This reverts commit bba2812fdd.
This commit is contained in:
@@ -13,6 +13,10 @@ export abstract class PlatformUtilsService {
|
||||
isIE: () => boolean;
|
||||
isMacAppStore: () => boolean;
|
||||
isViewOpen: () => Promise<boolean>;
|
||||
/**
|
||||
* @deprecated This only ever returns null. Pull from your platform's storage using ConstantsService.vaultTimeoutKey
|
||||
*/
|
||||
lockTimeout: () => number;
|
||||
launchUri: (uri: string, options?: any) => void;
|
||||
saveFile: (win: Window, blobData: any, blobOptions: any, fileName: string) => void;
|
||||
getApplicationVersion: () => Promise<string>;
|
||||
|
||||
@@ -9,7 +9,6 @@ export abstract class VaultTimeoutService {
|
||||
lock: (allowSoftLock?: boolean) => Promise<void>;
|
||||
logOut: () => Promise<void>;
|
||||
setVaultTimeoutOptions: (vaultTimeout: number, vaultTimeoutAction: string) => Promise<void>;
|
||||
getVaultTimeout: () => Promise<number>;
|
||||
isPinLockSet: () => Promise<[boolean, boolean]>;
|
||||
isBiometricLockSet: () => Promise<boolean>;
|
||||
clear: () => Promise<any>;
|
||||
|
||||
@@ -8,5 +8,4 @@ export enum PolicyType {
|
||||
DisableSend = 6, // Disables the ability to create and edit Bitwarden Sends
|
||||
SendOptions = 7, // Sets restrictions or defaults for Bitwarden Sends
|
||||
ResetPassword = 8, // Allows orgs to use reset password : also can enable auto-enrollment during invite flow
|
||||
MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout
|
||||
}
|
||||
|
||||
@@ -6,14 +6,12 @@ import { CryptoService } from '../abstractions/crypto.service';
|
||||
import { FolderService } from '../abstractions/folder.service';
|
||||
import { MessagingService } from '../abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
|
||||
import { PolicyService } from '../abstractions/policy.service';
|
||||
import { SearchService } from '../abstractions/search.service';
|
||||
import { StorageService } from '../abstractions/storage.service';
|
||||
import { TokenService } from '../abstractions/token.service';
|
||||
import { UserService } from '../abstractions/user.service';
|
||||
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from '../abstractions/vaultTimeout.service';
|
||||
|
||||
import { PolicyType } from '../enums/policyType';
|
||||
import { EncString } from '../models/domain/encString';
|
||||
|
||||
export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
|
||||
@@ -27,7 +25,7 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
|
||||
private collectionService: CollectionService, private cryptoService: CryptoService,
|
||||
protected platformUtilsService: PlatformUtilsService, private storageService: StorageService,
|
||||
private messagingService: MessagingService, private searchService: SearchService,
|
||||
private userService: UserService, private tokenService: TokenService, private policyService: PolicyService,
|
||||
private userService: UserService, private tokenService: TokenService,
|
||||
private lockedCallback: () => Promise<void> = null, private loggedOutCallback: () => Promise<void> = null) {
|
||||
}
|
||||
|
||||
@@ -73,7 +71,12 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
|
||||
return;
|
||||
}
|
||||
|
||||
const vaultTimeout = await this.getVaultTimeout();
|
||||
// This has the potential to be removed. Evaluate after all platforms complete with auto-logout
|
||||
let vaultTimeout = this.platformUtilsService.lockTimeout();
|
||||
if (vaultTimeout == null) {
|
||||
vaultTimeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
|
||||
}
|
||||
|
||||
if (vaultTimeout == null || vaultTimeout < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -138,29 +141,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
|
||||
return await this.storageService.get<boolean>(ConstantsService.biometricUnlockKey);
|
||||
}
|
||||
|
||||
async getVaultTimeout(): Promise<number> {
|
||||
const vaultTimeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
|
||||
|
||||
if (await this.policyService.policyAppliesToUser(PolicyType.MaximumVaultTimeout)) {
|
||||
const policy = await this.policyService.getAll(PolicyType.MaximumVaultTimeout);
|
||||
// Remove negative values, and ensure it's smaller than maximum allowed value according to policy
|
||||
let timeout = Math.min(vaultTimeout, policy[0].data.minutes);
|
||||
|
||||
if (vaultTimeout == null || timeout < 0) {
|
||||
timeout = policy[0].data.minutes;
|
||||
}
|
||||
|
||||
// We really shouldn't need to set the value here, but multiple services relies on this value being correct.
|
||||
if (vaultTimeout !== timeout) {
|
||||
await this.storageService.save(ConstantsService.vaultTimeoutKey, timeout);
|
||||
}
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
return vaultTimeout;
|
||||
}
|
||||
|
||||
clear(): Promise<any> {
|
||||
this.everBeenUnlocked = false;
|
||||
this.pinProtectedKey = null;
|
||||
|
||||
Reference in New Issue
Block a user