1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

[PS 1624]CLI get and delete folder command, fails if using GUID and Session key (#4026)

* Resolve get&delete folder cmd on cli using GUID&Sessionkey

* Using the getFromState on the edit.command.ts

Co-authored-by: dynwee <onwudiweokeke@gmail.com>
This commit is contained in:
cyprain-okeke 2022-11-17 12:52:48 +01:00 committed by GitHub
parent cba0f31937
commit df0a148ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 3 deletions

View File

@ -88,7 +88,7 @@ export class DeleteCommand {
} }
private async deleteFolder(id: string) { private async deleteFolder(id: string) {
const folder = await this.folderService.get(id); const folder = await this.folderService.getFromState(id);
if (folder == null) { if (folder == null) {
return Response.notFound(); return Response.notFound();
} }

View File

@ -118,7 +118,7 @@ export class EditCommand {
} }
private async editFolder(id: string, req: FolderExport) { private async editFolder(id: string, req: FolderExport) {
const folder = await this.folderService.get(id); const folder = await this.folderService.getFromState(id);
if (folder == null) { if (folder == null) {
return Response.notFound(); return Response.notFound();
} }

View File

@ -353,7 +353,7 @@ export class GetCommand extends DownloadCommand {
private async getFolder(id: string) { private async getFolder(id: string) {
let decFolder: FolderView = null; let decFolder: FolderView = null;
if (Utils.isGuid(id)) { if (Utils.isGuid(id)) {
const folder = await this.folderService.get(id); const folder = await this.folderService.getFromState(id);
if (folder != null) { if (folder != null) {
decFolder = await folder.decrypt(); decFolder = await folder.decrypt();
} }

View File

@ -12,6 +12,10 @@ export abstract class FolderService {
clearCache: () => Promise<void>; clearCache: () => Promise<void>;
encrypt: (model: FolderView, key?: SymmetricCryptoKey) => Promise<Folder>; encrypt: (model: FolderView, key?: SymmetricCryptoKey) => Promise<Folder>;
get: (id: string) => Promise<Folder>; get: (id: string) => Promise<Folder>;
/**
* @deprecated Only use in CLI!
*/
getFromState: (id: string) => Promise<Folder>;
/** /**
* @deprecated Only use in CLI! * @deprecated Only use in CLI!
*/ */

View File

@ -64,6 +64,20 @@ export class FolderService implements InternalFolderServiceAbstraction {
return folders.find((folder) => folder.id === id); return folders.find((folder) => folder.id === id);
} }
/**
* @deprecated For the CLI only
* @param id id of the folder
*/
async getFromState(id: string): Promise<Folder> {
const foldersMap = await this.stateService.getEncryptedFolders();
const folder = foldersMap[id];
if (folder == null) {
return null;
}
return new Folder(folder);
}
/** /**
* @deprecated Only use in CLI! * @deprecated Only use in CLI!
*/ */