mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-20 02:01:47 +01:00
Add encKey validation for org import/export (#392)
This commit is contained in:
parent
6fbe33043b
commit
dddcc2bc93
@ -38,8 +38,9 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
|
|||||||
|
|
||||||
private async parseEncrypted() {
|
private async parseEncrypted() {
|
||||||
if (this.results.encKeyValidation_DO_NOT_EDIT != null) {
|
if (this.results.encKeyValidation_DO_NOT_EDIT != null) {
|
||||||
|
const orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||||
const encKeyValidation = new EncString(this.results.encKeyValidation_DO_NOT_EDIT);
|
const encKeyValidation = new EncString(this.results.encKeyValidation_DO_NOT_EDIT);
|
||||||
const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(encKeyValidation);
|
const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(encKeyValidation, orgKey);
|
||||||
if (encKeyValidationDecrypt === null) {
|
if (encKeyValidationDecrypt === null) {
|
||||||
this.result.success = false;
|
this.result.success = false;
|
||||||
this.result.errorMessage = this.i18nService.t('importEncKeyError');
|
this.result.errorMessage = this.i18nService.t('importEncKeyError');
|
||||||
|
@ -289,8 +289,12 @@ export class ExportService implements ExportServiceAbstraction {
|
|||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
||||||
|
const orgKey = await this.cryptoService.getOrgKey(organizationId);
|
||||||
|
const encKeyValidation = await this.cryptoService.encrypt(Utils.newGuid(), orgKey);
|
||||||
|
|
||||||
const jsonDoc: any = {
|
const jsonDoc: any = {
|
||||||
encrypted: true,
|
encrypted: true,
|
||||||
|
encKeyValidation_DO_NOT_EDIT: encKeyValidation.encryptedString,
|
||||||
collections: [],
|
collections: [],
|
||||||
items: [],
|
items: [],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user