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

Merge branch 'main' into tools/generator/organize-types-and-data

This commit is contained in:
✨ Audrey ✨
2025-01-06 15:36:08 -05:00
283 changed files with 8988 additions and 13084 deletions

View File

@@ -1,5 +1,5 @@
import { mock, MockProxy } from "jest-mock-extended";
import { BehaviorSubject } from "rxjs";
import { BehaviorSubject, of } from "rxjs";
import { PinServiceAbstraction } from "@bitwarden/auth/common";
import { AccountInfo, AccountService } from "@bitwarden/common/auth/abstractions/account.service";
@@ -178,8 +178,8 @@ describe("VaultExportService", () => {
const activeAccount = { id: userId, ...accountInfo };
accountService.activeAccount$ = new BehaviorSubject(activeAccount);
folderService.getAllDecryptedFromState.mockResolvedValue(UserFolderViews);
folderService.getAllFromState.mockResolvedValue(UserFolders);
folderService.folderViews$.mockReturnValue(of(UserFolderViews));
folderService.folders$.mockReturnValue(of(UserFolders));
kdfConfigService.getKdfConfig.mockResolvedValue(DEFAULT_KDF_CONFIG);
encryptService.encrypt.mockResolvedValue(new EncString("encrypted"));
@@ -295,7 +295,7 @@ describe("VaultExportService", () => {
it("exported unencrypted object contains folders", async () => {
cipherService.getAllDecrypted.mockResolvedValue(UserCipherViews.slice(0, 1));
await folderService.getAllDecryptedFromState();
folderService.folderViews$.mockReturnValue(of(UserFolderViews));
const actual = await exportService.getExport("json");
expectEqualFolderViews(UserFolderViews, actual);
@@ -303,7 +303,7 @@ describe("VaultExportService", () => {
it("exported encrypted json contains folders", async () => {
cipherService.getAll.mockResolvedValue(UserCipherDomains.slice(0, 1));
await folderService.getAllFromState();
folderService.folders$.mockReturnValue(of(UserFolders));
const actual = await exportService.getExport("encrypted_json");
expectEqualFolders(UserFolders, actual);

View File

@@ -32,6 +32,8 @@ export class IndividualVaultExportService
extends BaseVaultExportService
implements IndividualVaultExportServiceAbstraction
{
private activeUserId$ = this.accountService.activeAccount$.pipe(map((a) => a?.id));
constructor(
private folderService: FolderService,
private cipherService: CipherService,
@@ -61,9 +63,10 @@ export class IndividualVaultExportService
let decFolders: FolderView[] = [];
let decCiphers: CipherView[] = [];
const promises = [];
const activeUserId = await firstValueFrom(this.activeUserId$);
promises.push(
this.folderService.getAllDecryptedFromState().then((folders) => {
firstValueFrom(this.folderService.folderViews$(activeUserId)).then((folders) => {
decFolders = folders;
}),
);
@@ -87,9 +90,10 @@ export class IndividualVaultExportService
let folders: Folder[] = [];
let ciphers: Cipher[] = [];
const promises = [];
const activeUserId = await firstValueFrom(this.activeUserId$);
promises.push(
this.folderService.getAllFromState().then((f) => {
firstValueFrom(this.folderService.folders$(activeUserId)).then((f) => {
folders = f;
}),
);
@@ -102,10 +106,9 @@ export class IndividualVaultExportService
await Promise.all(promises);
const activeUserId = await firstValueFrom(
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
const userKey = await this.keyService.getUserKeyWithLegacySupport(
await firstValueFrom(this.activeUserId$),
);
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeUserId);
const encKeyValidation = await this.encryptService.encrypt(Utils.newGuid(), userKey);
const jsonDoc: BitwardenEncryptedIndividualJsonExport = {

View File

@@ -1,5 +1,5 @@
import { mock, MockProxy } from "jest-mock-extended";
import { BehaviorSubject } from "rxjs";
import { BehaviorSubject, of } from "rxjs";
import { PinServiceAbstraction } from "@bitwarden/auth/common";
import { AccountInfo, AccountService } from "@bitwarden/common/auth/abstractions/account.service";
@@ -168,8 +168,8 @@ describe("VaultExportService", () => {
kdfConfigService = mock<KdfConfigService>();
folderService.getAllDecryptedFromState.mockResolvedValue(UserFolderViews);
folderService.getAllFromState.mockResolvedValue(UserFolders);
folderService.folderViews$.mockReturnValue(of(UserFolderViews));
folderService.folders$.mockReturnValue(of(UserFolders));
kdfConfigService.getKdfConfig.mockResolvedValue(DEFAULT_KDF_CONFIG);
encryptService.encrypt.mockResolvedValue(new EncString("encrypted"));
keyService.userKey$.mockReturnValue(new BehaviorSubject("mockOriginalUserKey" as any));
@@ -294,7 +294,7 @@ describe("VaultExportService", () => {
it("exported unencrypted object contains folders", async () => {
cipherService.getAllDecrypted.mockResolvedValue(UserCipherViews.slice(0, 1));
await folderService.getAllDecryptedFromState();
const actual = await exportService.getExport("json");
expectEqualFolderViews(UserFolderViews, actual);
@@ -302,7 +302,7 @@ describe("VaultExportService", () => {
it("exported encrypted json contains folders", async () => {
cipherService.getAll.mockResolvedValue(UserCipherDomains.slice(0, 1));
await folderService.getAllFromState();
const actual = await exportService.getExport("encrypted_json");
expectEqualFolders(UserFolders, actual);

View File

@@ -14,7 +14,6 @@
[queryParams]="{ sendId: send.id, type: send.type }"
appStopClick
type="button"
class="tw-pb-1"
>
<i
slot="start"