1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-22 12:24:01 +00:00

Merge remote-tracking branch 'origin/main' into ac/strong-typed-guids

This commit is contained in:
Thomas Rittson
2025-07-25 14:22:44 +10:00
588 changed files with 20565 additions and 9808 deletions

View File

@@ -100,6 +100,7 @@ const safeProviders: SafeProvider[] = [
PinServiceAbstraction,
AccountService,
SdkService,
RestrictedItemTypesService,
],
}),
];
@@ -299,7 +300,7 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
// Retrieve all organizations a user is a member of and has collections they can manage
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
this.organizations$ = this.organizationService.memberOrganizations$(userId).pipe(
combineLatestWith(this.collectionService.decryptedCollections$),
combineLatestWith(this.collectionService.decryptedCollections$(userId)),
map(([organizations, collections]) =>
organizations
.filter((org) => collections.some((c) => c.organizationId === org.id && c.manage))
@@ -317,15 +318,15 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
}
if (value) {
this.collections$ = Utils.asyncToObservable(() =>
this.collectionService
.getAllDecrypted()
.then((decryptedCollections) =>
this.collections$ = this.collectionService
.decryptedCollections$(userId)
.pipe(
map((decryptedCollections) =>
decryptedCollections
.filter((c2) => c2.organizationId === value && c2.manage)
.sort(Utils.getSortFunction(this.i18nService, "name")),
),
);
);
}
});
this.formGroup.controls.vaultSelector.setValue("myVault");

View File

@@ -321,12 +321,6 @@ export abstract class BaseImporter {
} else {
cipher.notes = cipher.notes.trim();
}
if (cipher.fields != null && cipher.fields.length === 0) {
cipher.fields = null;
}
if (cipher.passwordHistory != null && cipher.passwordHistory.length === 0) {
cipher.passwordHistory = null;
}
}
protected processKvp(

View File

@@ -67,7 +67,7 @@ describe("Keeper CSV Importer", () => {
expect(result != null).toBe(true);
const cipher = result.ciphers.shift();
expect(cipher.fields).toBeNull();
expect(cipher.fields.length).toBe(0);
const cipher2 = result.ciphers.shift();
expect(cipher2.fields.length).toBe(2);

View File

@@ -40,7 +40,7 @@ describe("Keeper Json Importer", () => {
expect(cipher3.login.username).toEqual("someUserName");
expect(cipher3.login.password).toEqual("w4k4k1wergf$^&@#*%2");
expect(cipher3.notes).toBeNull();
expect(cipher3.fields).toBeNull();
expect(cipher3.fields.length).toBe(0);
expect(cipher3.login.uris.length).toEqual(1);
const uriView3 = cipher3.login.uris.shift();
expect(uriView3.uri).toEqual("https://example.com");

View File

@@ -14,6 +14,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { RestrictedItemTypesService } from "@bitwarden/common/vault/services/restricted-item-types.service";
import { KeyService } from "@bitwarden/key-management";
import { BitwardenPasswordProtectedImporter } from "../importers/bitwarden/bitwarden-password-protected-importer";
@@ -35,6 +36,7 @@ describe("ImportService", () => {
let pinService: MockProxy<PinServiceAbstraction>;
let accountService: MockProxy<AccountService>;
let sdkService: MockSdkService;
let restrictedItemTypesService: MockProxy<RestrictedItemTypesService>;
beforeEach(() => {
cipherService = mock<CipherService>();
@@ -46,6 +48,7 @@ describe("ImportService", () => {
encryptService = mock<EncryptService>();
pinService = mock<PinServiceAbstraction>();
sdkService = new MockSdkService();
restrictedItemTypesService = mock<RestrictedItemTypesService>();
importService = new ImportService(
cipherService,
@@ -58,6 +61,7 @@ describe("ImportService", () => {
pinService,
accountService,
sdkService,
restrictedItemTypesService,
);
});

View File

@@ -27,6 +27,7 @@ import { CipherRequest } from "@bitwarden/common/vault/models/request/cipher.req
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { RestrictedItemTypesService } from "@bitwarden/common/vault/services/restricted-item-types.service";
import { KeyService } from "@bitwarden/key-management";
import {
@@ -120,6 +121,7 @@ export class ImportService implements ImportServiceAbstraction {
private pinService: PinServiceAbstraction,
private accountService: AccountService,
private sdkService: SdkService,
private restrictedItemTypesService: RestrictedItemTypesService,
) {}
getImportOptions(): ImportOption[] {
@@ -167,6 +169,17 @@ export class ImportService implements ImportServiceAbstraction {
}
}
const restrictedItemTypes = await firstValueFrom(
this.restrictedItemTypesService.restricted$.pipe(
map((restrictedItemTypes) => restrictedItemTypes.map((r) => r.cipherType)),
),
);
// Filter out restricted item types from the import result
importResult.ciphers = importResult.ciphers.filter(
(cipher) => !restrictedItemTypes.includes(cipher.type),
);
if (organizationId && !selectedImportTarget && !canAccessImportExport) {
const hasUnassignedCollections =
importResult.collectionRelationships.length < importResult.ciphers.length;
@@ -397,7 +410,7 @@ export class ImportService implements ImportServiceAbstraction {
if (importResult.collections != null) {
for (let i = 0; i < importResult.collections.length; i++) {
importResult.collections[i].organizationId = organizationId;
const c = await this.collectionService.encrypt(importResult.collections[i]);
const c = await this.collectionService.encrypt(importResult.collections[i], activeUserId);
request.collections.push(new CollectionWithIdRequest(c));
}
}