mirror of
https://github.com/bitwarden/browser
synced 2026-01-03 09:03:32 +00:00
org import and collection encrypt function
This commit is contained in:
@@ -318,8 +318,8 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return this.send('POST', '/ciphers/import', request, true, false);
|
||||
}
|
||||
|
||||
postImportOrganizationCiphers(request: ImportOrganizationCiphersRequest): Promise<any> {
|
||||
return this.send('POST', '/ciphers/import-organization', request, true, false);
|
||||
postImportOrganizationCiphers(organizationId: string, request: ImportOrganizationCiphersRequest): Promise<any> {
|
||||
return this.send('POST', '/ciphers/import-organization?organizationId=' + organizationId, request, true, false);
|
||||
}
|
||||
|
||||
// Attachments APIs
|
||||
|
||||
@@ -25,6 +25,22 @@ export class CollectionService implements CollectionServiceAbstraction {
|
||||
this.decryptedCollectionCache = null;
|
||||
}
|
||||
|
||||
async encrypt(model: CollectionView): Promise<Collection> {
|
||||
if (model.organizationId == null) {
|
||||
throw new Error('Collection has no organization id.');
|
||||
}
|
||||
const key = await this.cryptoService.getOrgKey(model.organizationId);
|
||||
if (key == null) {
|
||||
throw new Error('No key for this collection\'s organization.');
|
||||
}
|
||||
const collection = new Collection();
|
||||
collection.id = model.id;
|
||||
collection.organizationId = model.organizationId;
|
||||
collection.readOnly = model.readOnly;
|
||||
collection.name = await this.cryptoService.encrypt(model.name, key);
|
||||
return collection;
|
||||
}
|
||||
|
||||
async get(id: string): Promise<Collection> {
|
||||
const userId = await this.userService.getUserId();
|
||||
const collections = await this.storageService.get<{ [id: string]: CollectionData; }>(
|
||||
|
||||
Reference in New Issue
Block a user