mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
magical black-box key retrieval is slow, due to needing to repeatedly resolve (and potentially decrypt) keys. Doing the work up front is both more explicit and much faster. It would be preferable to move OrganizationId to an opaque type in the models, but that has rippling effects all over the place and ultimately is stopped by vault filtering on strings rather than ids, but still calling the property `organizationId`, we need to fix that first.
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import Domain from "../../../platform/models/domain/domain-base";
|
|
import { EncString } from "../../../platform/models/domain/enc-string";
|
|
import { OrgKey } from "../../../types/key";
|
|
import { CollectionData } from "../data/collection.data";
|
|
import { CollectionView } from "../view/collection.view";
|
|
|
|
export class Collection extends Domain {
|
|
id: string;
|
|
organizationId: string;
|
|
name: EncString;
|
|
externalId: string;
|
|
readOnly: boolean;
|
|
hidePasswords: boolean;
|
|
manage: boolean;
|
|
|
|
constructor(obj?: CollectionData) {
|
|
super();
|
|
if (obj == null) {
|
|
return;
|
|
}
|
|
|
|
this.buildDomainModel(
|
|
this,
|
|
obj,
|
|
{
|
|
id: null,
|
|
organizationId: null,
|
|
name: null,
|
|
externalId: null,
|
|
readOnly: null,
|
|
hidePasswords: null,
|
|
manage: null,
|
|
},
|
|
["id", "organizationId", "externalId", "readOnly", "hidePasswords", "manage"],
|
|
);
|
|
}
|
|
|
|
decrypt(orgKey: OrgKey): Promise<CollectionView> {
|
|
return this.decryptObj(
|
|
new CollectionView(this),
|
|
{
|
|
name: null,
|
|
},
|
|
this.organizationId,
|
|
orgKey,
|
|
);
|
|
}
|
|
}
|