[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:
parent
e0ae1bb738
commit
4c5a46ce13
|
@ -60,7 +60,7 @@ export default class CommandsBackground {
|
|||
await this.openPopup();
|
||||
break;
|
||||
case "lock_vault":
|
||||
await this.vaultTimeoutService.lock(true);
|
||||
await this.vaultTimeoutService.lock();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -48,7 +48,7 @@ export default class IdleBackground {
|
|||
if (action === "logOut") {
|
||||
await this.vaultTimeoutService.logOut();
|
||||
} else {
|
||||
await this.vaultTimeoutService.lock(true);
|
||||
await this.vaultTimeoutService.lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ export class SettingsComponent implements OnInit {
|
|||
}
|
||||
|
||||
async lock() {
|
||||
await this.vaultTimeoutService.lock(true);
|
||||
await this.vaultTimeoutService.lock();
|
||||
}
|
||||
|
||||
async logOut() {
|
||||
|
|
|
@ -323,7 +323,6 @@ export class Main {
|
|||
this.apiService,
|
||||
this.i18nService,
|
||||
this.collectionService,
|
||||
this.platformUtilsService,
|
||||
this.cryptoService
|
||||
);
|
||||
this.exportService = new ExportService(
|
||||
|
|
|
@ -7,7 +7,6 @@ import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
|||
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import.service";
|
||||
|
||||
import { LooseComponentsModule, SharedModule } from "../../../shared";
|
||||
|
@ -29,7 +28,6 @@ import { OrganizationImportComponent } from "./org-import.component";
|
|||
ApiService,
|
||||
I18nService,
|
||||
CollectionService,
|
||||
PlatformUtilsService,
|
||||
CryptoService,
|
||||
],
|
||||
},
|
||||
|
|
|
@ -7,7 +7,6 @@ import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
|||
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import.service";
|
||||
|
||||
import { LooseComponentsModule, SharedModule } from "../../shared";
|
||||
|
@ -29,7 +28,6 @@ import { ImportComponent } from "./import.component";
|
|||
ApiService,
|
||||
I18nService,
|
||||
CollectionService,
|
||||
PlatformUtilsService,
|
||||
CryptoService,
|
||||
],
|
||||
},
|
||||
|
|
|
@ -6,7 +6,6 @@ import { CollectionService } from "@bitwarden/common/abstractions/collection.ser
|
|||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { BitwardenPasswordProtectedImporter } from "@bitwarden/common/importers/bitwardenPasswordProtectedImporter";
|
||||
import { Importer } from "@bitwarden/common/importers/importer";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
|
@ -19,7 +18,6 @@ describe("ImportService", () => {
|
|||
let apiService: SubstituteOf<ApiService>;
|
||||
let i18nService: SubstituteOf<I18nService>;
|
||||
let collectionService: SubstituteOf<CollectionService>;
|
||||
let platformUtilsService: SubstituteOf<PlatformUtilsService>;
|
||||
let cryptoService: SubstituteOf<CryptoService>;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -28,7 +26,6 @@ describe("ImportService", () => {
|
|||
apiService = Substitute.for<ApiService>();
|
||||
i18nService = Substitute.for<I18nService>();
|
||||
collectionService = Substitute.for<CollectionService>();
|
||||
platformUtilsService = Substitute.for<PlatformUtilsService>();
|
||||
cryptoService = Substitute.for<CryptoService>();
|
||||
|
||||
importService = new ImportService(
|
||||
|
@ -37,7 +34,6 @@ describe("ImportService", () => {
|
|||
apiService,
|
||||
i18nService,
|
||||
collectionService,
|
||||
platformUtilsService,
|
||||
cryptoService
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue