1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[PM-13374] Update all SDK uuids (#14962)

* fix: broken SDK interface

* Fix all compile errors related to uuids

* Fix browser desktop

* Fix tests

---------

Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
This commit is contained in:
Oscar Hinton
2025-08-29 19:09:33 +02:00
committed by GitHub
parent d57d653551
commit e0da2671b4
31 changed files with 133 additions and 93 deletions

View File

@@ -23,6 +23,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { CipherId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherType } from "@bitwarden/common/vault/enums";
@@ -321,7 +322,7 @@ export class VaultListItemsContainerComponent implements AfterViewInit {
}
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
await this.cipherService.updateLastLaunchedDate(cipher.id!, activeUserId);
await this.cipherService.updateLastLaunchedDate(uuidAsString(cipher.id!), activeUserId);
await BrowserApi.createNewTab(launchURI);
@@ -338,7 +339,7 @@ export class VaultListItemsContainerComponent implements AfterViewInit {
// When only the `CipherListView` is available, fetch the full cipher details
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
const _cipher = await this.cipherService.get(cipher.id!, activeUserId);
const _cipher = await this.cipherService.get(uuidAsString(cipher.id!), activeUserId);
const cipherView = await this.cipherService.decrypt(_cipher, activeUserId);
await this.vaultPopupAutofillService.doAutofill(cipherView);

View File

@@ -8,6 +8,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { ProductTierType } from "@bitwarden/common/billing/enums";
import { uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SyncService } from "@bitwarden/common/platform/sync";
import { ObservableTracker, mockAccountServiceWith } from "@bitwarden/common/spec";
@@ -102,7 +103,7 @@ describe("VaultPopupItemsService", () => {
searchService.searchCiphers.mockImplementation(async (userId, _, __, ciphers) => ciphers);
cipherServiceMock.filterCiphersForUrl.mockImplementation(async (ciphers) =>
ciphers.filter((c) => ["0", "1"].includes(c.id)),
ciphers.filter((c) => ["0", "1"].includes(uuidAsString(c.id))),
);
vaultSettingsServiceMock.showCardsCurrentTab$ = new BehaviorSubject(false);
vaultSettingsServiceMock.showIdentitiesCurrentTab$ = new BehaviorSubject(false);

View File

@@ -14,6 +14,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { ProductTierType } from "@bitwarden/common/billing/enums";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { asUuid } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { StateProvider } from "@bitwarden/common/platform/state";
import { mockAccountServiceWith } from "@bitwarden/common/spec";
import { UserId } from "@bitwarden/common/types/guid";
@@ -514,8 +515,17 @@ describe("VaultPopupListFiltersService", () => {
describe("filterFunction$", () => {
const ciphers = [
{ type: CipherType.Login, collectionIds: [], organizationId: null },
{ type: CipherType.Card, collectionIds: ["1234"], organizationId: "8978" },
{ type: CipherType.Identity, collectionIds: [], folderId: "5432", organizationId: null },
{
type: CipherType.Card,
collectionIds: [asUuid("cbcae898-9f9a-48eb-863e-edf92e3ad7e0")],
organizationId: "8978" as any,
},
{
type: CipherType.Identity,
collectionIds: [],
folderId: "5432" as any,
organizationId: null,
},
{ type: CipherType.SecureNote, collectionIds: [], organizationId: null },
] as CipherView[];
@@ -529,7 +539,7 @@ describe("VaultPopupListFiltersService", () => {
});
it("filters by collection", (done) => {
const collection = { id: "1234" } as CollectionView;
const collection = { id: "cbcae898-9f9a-48eb-863e-edf92e3ad7e0" } as CollectionView;
service.filterFunction$.subscribe((filterFunction) => {
expect(filterFunction(ciphers)).toEqual([ciphers[1]]);

View File

@@ -28,6 +28,7 @@ import { ProductTierType } from "@bitwarden/common/billing/enums";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { asUuid } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import {
KeyDefinition,
@@ -236,7 +237,10 @@ export class VaultPopupListFiltersService {
return false;
}
if (filters.collection && !cipher.collectionIds?.includes(filters.collection.id!)) {
if (
filters.collection &&
!cipher.collectionIds?.includes(asUuid(filters.collection.id!))
) {
return false;
}

View File

@@ -7,6 +7,7 @@ import { distinctUntilChanged, debounceTime } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { VaultItemsComponent as BaseVaultItemsComponent } from "@bitwarden/angular/vault/components/vault-items.component";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SearchService } from "@bitwarden/common/vault/abstractions/search.service";
import { RestrictedItemTypesService } from "@bitwarden/common/vault/services/restricted-item-types.service";
@@ -43,6 +44,6 @@ export class VaultItemsV2Component<C extends CipherViewLike> extends BaseVaultIt
}
trackByFn(index: number, c: C): string {
return c.id!;
return uuidAsString(c.id!);
}
}

View File

@@ -3,6 +3,8 @@
import { Component, Input } from "@angular/core";
import { CollectionView } from "@bitwarden/admin-console/common";
import { uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { CollectionId } from "@bitwarden/sdk-internal";
import { SharedModule } from "../../../../shared/shared.module";
import { GetCollectionNameFromIdPipe } from "../pipes";
@@ -13,11 +15,11 @@ import { GetCollectionNameFromIdPipe } from "../pipes";
imports: [SharedModule, GetCollectionNameFromIdPipe],
})
export class CollectionNameBadgeComponent {
@Input() collectionIds: string[];
@Input() collectionIds: CollectionId[] | string[];
@Input() collections: CollectionView[];
get shownCollections(): string[] {
return this.showXMore ? this.collectionIds.slice(0, 2) : this.collectionIds;
return (this.showXMore ? this.collectionIds.slice(0, 2) : this.collectionIds).map(uuidAsString);
}
get showXMore(): boolean {

View File

@@ -310,7 +310,7 @@ export class VaultItemsComponent<C extends CipherViewLike> {
const orgCollections = this.allCollections.filter((c) => c.organizationId === org.id);
for (const collection of orgCollections) {
if (vaultItem.cipher.collectionIds.includes(collection.id) && collection.manage) {
if (vaultItem.cipher.collectionIds.includes(collection.id as any) && collection.manage) {
return true;
}
}
@@ -364,7 +364,7 @@ export class VaultItemsComponent<C extends CipherViewLike> {
}
return this.allCollections
.filter((c) => cipher.collectionIds.includes(c.id))
.filter((c) => cipher.collectionIds.includes(c.id as any))
.some((collection) => collection.manage);
}

View File

@@ -8,6 +8,7 @@ import { AvatarService } from "@bitwarden/common/auth/abstractions/avatar.servic
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { OrganizationId } from "@bitwarden/sdk-internal";
@Component({
selector: "app-org-badge",
@@ -15,7 +16,7 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
standalone: false,
})
export class OrganizationNameBadgeComponent implements OnChanges {
@Input() organizationId?: string;
@Input() organizationId?: OrganizationId | string;
@Input() organizationName: string;
@Input() disabled: boolean;

View File

@@ -1,6 +1,7 @@
import { Pipe, PipeTransform } from "@angular/core";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { OrganizationId } from "@bitwarden/sdk-internal";
@Pipe({
name: "orgNameFromId",
@@ -8,7 +9,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
standalone: false,
})
export class GetOrgNameFromIdPipe implements PipeTransform {
transform(value: string, organizations: Organization[]) {
transform(value: string | OrganizationId, organizations: Organization[]) {
const orgName = organizations?.find((o) => o.id === value)?.name;
return orgName;
}

View File

@@ -69,7 +69,7 @@ export function createFilterFunction(filter: RoutedVaultFilterModel): FilterFunc
filter.collectionId !== undefined &&
filter.collectionId !== All &&
filter.collectionId !== Unassigned &&
(cipher.collectionIds == null || !cipher.collectionIds.includes(filter.collectionId))
(cipher.collectionIds == null || !cipher.collectionIds.includes(filter.collectionId as any))
) {
return false;
}

View File

@@ -56,6 +56,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { uuidAsString } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SyncService } from "@bitwarden/common/platform/sync";
import { CipherId, CollectionId, OrganizationId, UserId } from "@bitwarden/common/types/guid";
@@ -678,7 +679,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
return;
} else if (cipher.organizationId != null) {
const org = await firstValueFrom(
this.organizations$.pipe(getOrganizationById(cipher.organizationId)),
this.organizations$.pipe(getOrganizationById(uuidAsString(cipher.organizationId))),
);
if (org != null && (org.maxStorageGb == null || org.maxStorageGb === 0)) {
this.messagingService.send("upgradeOrganization", {
@@ -775,7 +776,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
}
async editCipher(cipher: CipherView | CipherListView, cloneMode?: boolean) {
return this.editCipherId(cipher?.id, cloneMode);
return this.editCipherId(uuidAsString(cipher?.id), cloneMode);
}
/**
@@ -1044,7 +1045,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
try {
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
await this.cipherService.restoreWithServer(c.id, activeUserId);
await this.cipherService.restoreWithServer(uuidAsString(c.id), activeUserId);
this.toastService.showToast({
variant: "success",
title: null,
@@ -1066,7 +1067,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
return;
}
const selectedCipherIds = ciphers.map((cipher) => cipher.id);
const selectedCipherIds = ciphers.map((cipher) => uuidAsString(cipher.id));
if (selectedCipherIds.length === 0) {
this.toastService.showToast({
variant: "error",
@@ -1128,7 +1129,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
try {
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
await this.deleteCipherWithServer(c.id, activeUserId, permanent);
await this.deleteCipherWithServer(uuidAsString(c.id), activeUserId, permanent);
this.toastService.showToast({
variant: "success",
@@ -1168,7 +1169,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
const dialog = openBulkDeleteDialog(this.dialogService, {
data: {
permanent: this.filter.type === "trash",
cipherIds: ciphers.map((c) => c.id),
cipherIds: ciphers.map((c) => uuidAsString(c.id)),
organizations: organizations,
collections: collections,
},
@@ -1185,7 +1186,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
return;
}
const selectedCipherIds = ciphers.map((cipher) => cipher.id);
const selectedCipherIds = ciphers.map((cipher) => uuidAsString(cipher.id));
if (selectedCipherIds.length === 0) {
this.toastService.showToast({
variant: "error",
@@ -1261,11 +1262,14 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
});
if (field === "password") {
await this.eventCollectionService.collect(EventType.Cipher_ClientCopiedPassword, cipher.id);
await this.eventCollectionService.collect(
EventType.Cipher_ClientCopiedPassword,
uuidAsString(cipher.id),
);
} else if (field === "totp") {
await this.eventCollectionService.collect(
EventType.Cipher_ClientCopiedHiddenField,
cipher.id,
uuidAsString(cipher.id),
);
}
}
@@ -1324,7 +1328,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
}
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
const _cipher = await this.cipherService.get(cipher.id, activeUserId);
const _cipher = await this.cipherService.get(uuidAsString(cipher.id), activeUserId);
const cipherView = await this.cipherService.decrypt(_cipher, activeUserId);
return cipherView.login?.password;
}