MCPcopy Create free account
hub / github.com/bitwarden/clients / makeSendJson

Method makeSendJson

apps/cli/src/tools/send/send.program.ts:318–346  ·  view source on GitHub ↗
(data: string, options: OptionValues)

Source from the content-addressed store, hash-verified

316 }
317
318 private makeSendJson(data: string, options: OptionValues) {
319 let sendFile = null;
320 let sendText = null;
321 let name = Utils.newGuid();
322 let type: SendType = SendType.Text;
323 if (options.file != null) {
324 data = path.resolve(data);
325 if (!fs.existsSync(data)) {
326 return Response.badRequest("data path does not exist");
327 }
328
329 sendFile = SendFileResponse.template(data);
330 name = path.basename(data);
331 type = SendType.File;
332 } else {
333 sendText = SendTextResponse.template(data, options.hidden);
334 }
335
336 const template = Utils.assign(SendResponse.template(null, options.deleteInDays), {
337 name: options.name ?? name,
338 notes: options.notes,
339 file: sendFile,
340 text: sendText,
341 type: type,
342 emails: options.emails ?? undefined,
343 });
344
345 return Buffer.from(JSON.stringify(template), "utf8").toString("base64");
346 }
347
348 private async runCreate(encodedJson: string, options: OptionValues) {
349 await this.exitIfLocked();

Callers 1

sendCommandMethod · 0.95

Calls 7

newGuidMethod · 0.80
badRequestMethod · 0.80
toStringMethod · 0.65
resolveMethod · 0.45
templateMethod · 0.45
assignMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected