mirror of
https://github.com/bitwarden/jslib
synced 2025-12-23 03:33:29 +00:00
Remove folder service from importers as it's no longer needed
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute";
|
import { Substitute, SubstituteOf } from "@fluffy-spoon/substitute";
|
||||||
|
|
||||||
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
|
||||||
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
||||||
import { BitwardenJsonImporter } from "jslib-common/importers/bitwardenJsonImporter";
|
import { BitwardenJsonImporter } from "jslib-common/importers/bitwardenJsonImporter";
|
||||||
|
|
||||||
@@ -11,14 +10,12 @@ describe("bitwarden json importer", () => {
|
|||||||
let sut: BitwardenJsonImporter;
|
let sut: BitwardenJsonImporter;
|
||||||
let cryptoService: SubstituteOf<CryptoService>;
|
let cryptoService: SubstituteOf<CryptoService>;
|
||||||
let i18nService: SubstituteOf<I18nService>;
|
let i18nService: SubstituteOf<I18nService>;
|
||||||
let folderService: SubstituteOf<FolderService>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cryptoService = Substitute.for<CryptoService>();
|
cryptoService = Substitute.for<CryptoService>();
|
||||||
i18nService = Substitute.for<I18nService>();
|
i18nService = Substitute.for<I18nService>();
|
||||||
folderService = Substitute.for<FolderService>();
|
|
||||||
|
|
||||||
sut = new BitwardenJsonImporter(cryptoService, i18nService, folderService);
|
sut = new BitwardenJsonImporter(cryptoService, i18nService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail if password is needed", async () => {
|
it("should fail if password is needed", async () => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import Substitute, { Arg, SubstituteOf } from "@fluffy-spoon/substitute";
|
import Substitute, { Arg, SubstituteOf } from "@fluffy-spoon/substitute";
|
||||||
|
|
||||||
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
|
||||||
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
||||||
import { KdfType } from "jslib-common/enums/kdfType";
|
import { KdfType } from "jslib-common/enums/kdfType";
|
||||||
import { BitwardenPasswordProtectedImporter } from "jslib-common/importers/bitwardenPasswordProtectedImporter";
|
import { BitwardenPasswordProtectedImporter } from "jslib-common/importers/bitwardenPasswordProtectedImporter";
|
||||||
@@ -14,7 +13,6 @@ describe("BitwardenPasswordProtectedImporter", () => {
|
|||||||
let importer: BitwardenPasswordProtectedImporter;
|
let importer: BitwardenPasswordProtectedImporter;
|
||||||
let cryptoService: SubstituteOf<CryptoService>;
|
let cryptoService: SubstituteOf<CryptoService>;
|
||||||
let i18nService: SubstituteOf<I18nService>;
|
let i18nService: SubstituteOf<I18nService>;
|
||||||
let folderService: SubstituteOf<FolderService>;
|
|
||||||
const password = Utils.newGuid();
|
const password = Utils.newGuid();
|
||||||
const result = new ImportResult();
|
const result = new ImportResult();
|
||||||
let jDoc: {
|
let jDoc: {
|
||||||
@@ -30,7 +28,6 @@ describe("BitwardenPasswordProtectedImporter", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cryptoService = Substitute.for<CryptoService>();
|
cryptoService = Substitute.for<CryptoService>();
|
||||||
i18nService = Substitute.for<I18nService>();
|
i18nService = Substitute.for<I18nService>();
|
||||||
folderService = Substitute.for<FolderService>();
|
|
||||||
|
|
||||||
jDoc = {
|
jDoc = {
|
||||||
encrypted: true,
|
encrypted: true,
|
||||||
@@ -43,12 +40,7 @@ describe("BitwardenPasswordProtectedImporter", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
result.success = true;
|
result.success = true;
|
||||||
importer = new BitwardenPasswordProtectedImporter(
|
importer = new BitwardenPasswordProtectedImporter(cryptoService, i18nService, password);
|
||||||
cryptoService,
|
|
||||||
i18nService,
|
|
||||||
folderService,
|
|
||||||
password
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Required Json Data", () => {
|
describe("Required Json Data", () => {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
|
||||||
import { FolderView } from "jslib-common/models/view/folderView";
|
import { FolderView } from "jslib-common/models/view/folderView";
|
||||||
|
|
||||||
import { CryptoService } from "../abstractions/crypto.service";
|
import { CryptoService } from "../abstractions/crypto.service";
|
||||||
@@ -16,11 +15,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
|
|||||||
private results: any;
|
private results: any;
|
||||||
private result: ImportResult;
|
private result: ImportResult;
|
||||||
|
|
||||||
constructor(
|
constructor(protected cryptoService: CryptoService, protected i18nService: I18nService) {
|
||||||
protected cryptoService: CryptoService,
|
|
||||||
protected i18nService: I18nService,
|
|
||||||
private folderService: FolderService
|
|
||||||
) {
|
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
|
||||||
|
|
||||||
import { CryptoService } from "../abstractions/crypto.service";
|
import { CryptoService } from "../abstractions/crypto.service";
|
||||||
import { I18nService } from "../abstractions/i18n.service";
|
import { I18nService } from "../abstractions/i18n.service";
|
||||||
import { KdfType } from "../enums/kdfType";
|
import { KdfType } from "../enums/kdfType";
|
||||||
@@ -23,13 +21,8 @@ interface BitwardenPasswordProtectedFileFormat {
|
|||||||
export class BitwardenPasswordProtectedImporter extends BitwardenJsonImporter implements Importer {
|
export class BitwardenPasswordProtectedImporter extends BitwardenJsonImporter implements Importer {
|
||||||
private key: SymmetricCryptoKey;
|
private key: SymmetricCryptoKey;
|
||||||
|
|
||||||
constructor(
|
constructor(cryptoService: CryptoService, i18nService: I18nService, private password: string) {
|
||||||
cryptoService: CryptoService,
|
super(cryptoService, i18nService);
|
||||||
i18nService: I18nService,
|
|
||||||
folderService: FolderService,
|
|
||||||
private password: string
|
|
||||||
) {
|
|
||||||
super(cryptoService, i18nService, folderService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async parse(data: string): Promise<ImportResult> {
|
async parse(data: string): Promise<ImportResult> {
|
||||||
|
|||||||
@@ -163,12 +163,11 @@ export class ImportService implements ImportServiceAbstraction {
|
|||||||
case "bitwardencsv":
|
case "bitwardencsv":
|
||||||
return new BitwardenCsvImporter();
|
return new BitwardenCsvImporter();
|
||||||
case "bitwardenjson":
|
case "bitwardenjson":
|
||||||
return new BitwardenJsonImporter(this.cryptoService, this.i18nService, this.folderService);
|
return new BitwardenJsonImporter(this.cryptoService, this.i18nService);
|
||||||
case "bitwardenpasswordprotected":
|
case "bitwardenpasswordprotected":
|
||||||
return new BitwardenPasswordProtectedImporter(
|
return new BitwardenPasswordProtectedImporter(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.folderService,
|
|
||||||
password
|
password
|
||||||
);
|
);
|
||||||
case "lastpasscsv":
|
case "lastpasscsv":
|
||||||
|
|||||||
Reference in New Issue
Block a user