mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PS-1363] Tech debt and small refactorings (#3377)
* Remove cast to any as Utils.gobal got typed with #3131 * BitwardenFileUploadService: Remove unneeded dependency * Remove allowSoftLock from vaultTimeoutService * ImportService: Remove dependency on PlatformUtilsSvc
This commit is contained in:
committed by
GitHub
parent
e0ae1bb738
commit
4c5a46ce13
@@ -1,6 +1,6 @@
|
||||
export abstract class VaultTimeoutService {
|
||||
checkVaultTimeout: () => Promise<void>;
|
||||
lock: (allowSoftLock?: boolean, userId?: string) => Promise<void>;
|
||||
lock: (userId?: string) => Promise<void>;
|
||||
logOut: (userId?: string) => Promise<void>;
|
||||
setVaultTimeoutOptions: (vaultTimeout: number, vaultTimeoutAction: string) => Promise<void>;
|
||||
getVaultTimeout: () => Promise<number>;
|
||||
|
||||
@@ -72,7 +72,7 @@ export class Send extends Domain {
|
||||
const model = new SendView(this);
|
||||
|
||||
let cryptoService: CryptoService;
|
||||
const containerService = (Utils.global as any).bitwardenContainerService;
|
||||
const containerService = Utils.global.bitwardenContainerService;
|
||||
if (containerService) {
|
||||
cryptoService = containerService.getCryptoService();
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { Utils } from "../misc/utils";
|
||||
import { EncArrayBuffer } from "../models/domain/encArrayBuffer";
|
||||
|
||||
export class BitwardenFileUploadService {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async upload(
|
||||
encryptedFileName: string,
|
||||
encryptedFileData: EncArrayBuffer,
|
||||
|
||||
@@ -16,7 +16,7 @@ export class FileUploadService implements FileUploadServiceAbstraction {
|
||||
|
||||
constructor(private logService: LogService, private apiService: ApiService) {
|
||||
this.azureFileUploadService = new AzureFileUploadService(logService);
|
||||
this.bitwardenFileUploadService = new BitwardenFileUploadService(apiService);
|
||||
this.bitwardenFileUploadService = new BitwardenFileUploadService();
|
||||
}
|
||||
|
||||
async uploadSendFile(
|
||||
|
||||
@@ -26,7 +26,7 @@ export class FolderService implements InternalFolderServiceAbstraction {
|
||||
private stateService: StateService
|
||||
) {
|
||||
this.stateService.activeAccountUnlocked$.subscribe(async (unlocked) => {
|
||||
if ((Utils.global as any).bitwardenContainerService == null) {
|
||||
if (Utils.global.bitwardenContainerService == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { CryptoService } from "../abstractions/crypto.service";
|
||||
import { FolderService } from "../abstractions/folder/folder.service.abstraction";
|
||||
import { I18nService } from "../abstractions/i18n.service";
|
||||
import { ImportService as ImportServiceAbstraction } from "../abstractions/import.service";
|
||||
import { PlatformUtilsService } from "../abstractions/platformUtils.service";
|
||||
import { CipherType } from "../enums/cipherType";
|
||||
import {
|
||||
featuredImportOptions,
|
||||
@@ -93,7 +92,6 @@ export class ImportService implements ImportServiceAbstraction {
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private collectionService: CollectionService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private cryptoService: CryptoService
|
||||
) {}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async lock(allowSoftLock = false, userId?: string): Promise<void> {
|
||||
async lock(userId?: string): Promise<void> {
|
||||
const authed = await this.stateService.getIsAuthenticated({ userId: userId });
|
||||
if (!authed) {
|
||||
return;
|
||||
@@ -200,6 +200,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
|
||||
|
||||
private async executeTimeoutAction(userId: string): Promise<void> {
|
||||
const timeoutAction = await this.stateService.getVaultTimeoutAction({ userId: userId });
|
||||
timeoutAction === "logOut" ? await this.logOut(userId) : await this.lock(true, userId);
|
||||
timeoutAction === "logOut" ? await this.logOut(userId) : await this.lock(userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user