diff --git a/src/commands/create.command.ts b/src/commands/create.command.ts index 71fe5ccda7..e8f01aecd3 100644 --- a/src/commands/create.command.ts +++ b/src/commands/create.command.ts @@ -8,7 +8,8 @@ import { FolderService } from 'jslib/abstractions/folder.service'; import { TokenService } from 'jslib/abstractions/token.service'; import { Response } from '../models/response'; -import { StringResponse } from '../models/response/stringResponse'; +import { CipherResponse } from '../models/response/cipherResponse'; +import { FolderResponse } from '../models/response/folderResponse'; import { Cipher } from '../models/cipher'; import { Folder } from '../models/folder'; @@ -54,7 +55,10 @@ export class CreateCommand { const cipher = await this.cipherService.encrypt(Cipher.toView(req)); try { await this.cipherService.saveWithServer(cipher); - return Response.success(new StringResponse(cipher.id)); + const newCipher = await this.cipherService.get(cipher.id); + const decCipher = await newCipher.decrypt(); + const res = new CipherResponse(decCipher); + return Response.success(res); } catch (e) { return Response.error(e); } @@ -92,7 +96,10 @@ export class CreateCommand { const fileBuf = fs.readFileSync(filePath); await this.cipherService.saveAttachmentRawWithServer(cipher, path.basename(filePath), new Uint8Array(fileBuf).buffer); - return Response.success(); + const updatedCipher = await this.cipherService.get(cipher.id); + const decCipher = await updatedCipher.decrypt(); + const res = new CipherResponse(decCipher); + return Response.success(res); } catch (e) { return Response.error(e); } @@ -102,7 +109,10 @@ export class CreateCommand { const folder = await this.folderService.encrypt(Folder.toView(req)); try { await this.folderService.saveWithServer(folder); - return Response.success(new StringResponse(folder.id)); + const newFolder = await this.folderService.get(folder.id); + const decFolder = await newFolder.decrypt(); + const res = new FolderResponse(decFolder); + return Response.success(res); } catch (e) { return Response.error(e); } diff --git a/src/commands/edit.command.ts b/src/commands/edit.command.ts index 1b58b58d71..58ee9e311f 100644 --- a/src/commands/edit.command.ts +++ b/src/commands/edit.command.ts @@ -4,6 +4,8 @@ import { CipherService } from 'jslib/abstractions/cipher.service'; import { FolderService } from 'jslib/services/folder.service'; import { Response } from '../models/response'; +import { CipherResponse } from '../models/response/cipherResponse'; +import { FolderResponse } from '../models/response/folderResponse'; import { Cipher } from '../models/cipher'; import { Folder } from '../models/folder'; @@ -55,7 +57,10 @@ export class EditCommand { const encCipher = await this.cipherService.encrypt(cipherView); try { await this.cipherService.saveWithServer(encCipher); - return Response.success(); + const updatedCipher = await this.cipherService.get(cipher.id); + const decCipher = await updatedCipher.decrypt(); + const res = new CipherResponse(decCipher); + return Response.success(res); } catch (e) { return Response.error(e); } @@ -72,7 +77,10 @@ export class EditCommand { const encFolder = await this.folderService.encrypt(folderView); try { await this.folderService.saveWithServer(encFolder); - return Response.success(); + const updatedFolder = await this.folderService.get(folder.id); + const decFolder = await updatedFolder.decrypt(); + const res = new FolderResponse(decFolder); + return Response.success(res); } catch (e) { return Response.error(e); }