1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 13:40:06 +00:00

PM-919 download a file using get send

This commit is contained in:
voommen-livefront
2025-03-04 15:04:13 -06:00
parent 56c8c2ccc8
commit 07f119d003
3 changed files with 46 additions and 1 deletions

View File

@@ -164,6 +164,10 @@ export class OssServeConfigurator {
this.serviceContainer.searchService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.platformUtilsService,
this.serviceContainer.keyService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.sendApiService,
);
this.sendEditCommand = new SendEditCommand(
this.serviceContainer.sendService,

View File

@@ -6,15 +6,22 @@ import { firstValueFrom } from "rxjs";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
import { KeyService } from "@bitwarden/key-management";
import { DownloadCommand } from "../../../commands/download.command";
import { Response } from "../../../models/response";
import { SendResponse } from "../models/send.response";
import { SendReceiveCommand } from "./receive.command";
export class SendGetCommand extends DownloadCommand {
constructor(
private sendService: SendService,
@@ -22,6 +29,10 @@ export class SendGetCommand extends DownloadCommand {
private searchService: SearchService,
encryptService: EncryptService,
apiService: ApiService,
private platformUtilsService: PlatformUtilsService,
private keyService: KeyService,
private cryptoFunctionService: CryptoFunctionService,
private sendApiService: SendApiService,
) {
super(encryptService, apiService);
}
@@ -67,6 +78,20 @@ export class SendGetCommand extends DownloadCommand {
}
}
if (options?.file || options?.output || options?.raw) {
const sendWithUrl = new SendResponse(sends, webVaultUrl);
const receiveCommand = new SendReceiveCommand(
this.keyService,
this.encryptService,
this.cryptoFunctionService,
this.platformUtilsService,
this.environmentService,
this.sendApiService,
this.apiService,
);
return await receiveCommand.run(sendWithUrl.accessUrl, options);
}
return selector(sends);
}

View File

@@ -163,7 +163,15 @@ export class SendProgram extends BaseProgram {
return new Command("get")
.arguments("<id>")
.description("Get Sends owned by you.")
.option("--output <output>", "Output directory or filename for attachment.")
.option("--file", "Specifies to return the file content of a Send")
.option("--password <password>", "Password needed to access the Send.")
.option("--passwordenv <passwordenv>", "Environment variable storing the Send's password")
.option(
"--passwordfile <passwordfile>",
"Path to a file containing the Sends password as its first line",
)
.option("--obj", "Return the Send's json object rather than the Send's content")
.option("--output <location>", "Specify a file path to save a File-type Send to")
.option("--text", "Specifies to return the text content of a Send")
.on("--help", () => {
writeLn("");
@@ -192,6 +200,10 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.searchService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.platformUtilsService,
this.serviceContainer.keyService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.sendApiService,
);
const response = await cmd.run(id, options);
this.processResponse(response);
@@ -252,6 +264,10 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.searchService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
this.serviceContainer.platformUtilsService,
this.serviceContainer.keyService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.sendApiService,
);
const cmd = new SendEditCommand(
this.serviceContainer.sendService,