1
0
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:
Kyle Spearrin
2018-07-05 23:38:27 -04:00
parent ed93fa9ea3
commit a600c4a539
5 changed files with 23 additions and 6 deletions

View File

@@ -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

View File

@@ -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; }>(