1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 05:13:29 +00:00

[deps] Vault: Update commander to v11 (#7329)

* [deps] Vault: Update commander to v11

* [deps] Vault: Update commander to v11

* [deps] Vault: Update commander to v11

* [deps] Vault: Update commander to v11

* removed unused interfaces

* fix shell completions (#7756)

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: gbubemismith <gsmithwalter@gmail.com>
Co-authored-by: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com>
Co-authored-by: SmithThe4th <gsmith@bitwarden.com>
This commit is contained in:
renovate[bot]
2024-01-31 17:17:04 -05:00
committed by GitHub
parent 01781848f3
commit 83812d471c
15 changed files with 152 additions and 212 deletions

View File

@@ -53,7 +53,7 @@
"big-integer": "1.6.51", "big-integer": "1.6.51",
"browser-hrtime": "1.1.8", "browser-hrtime": "1.1.8",
"chalk": "4.1.2", "chalk": "4.1.2",
"commander": "7.2.0", "commander": "11.1.0",
"form-data": "4.0.0", "form-data": "4.0.0",
"https-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.2",
"inquirer": "8.2.6", "inquirer": "8.2.6",

View File

@@ -1,6 +1,6 @@
import * as http from "http"; import * as http from "http";
import * as program from "commander"; import { OptionValues } from "commander";
import * as inquirer from "inquirer"; import * as inquirer from "inquirer";
import Separator from "inquirer/lib/objects/separator"; import Separator from "inquirer/lib/objects/separator";
import { firstValueFrom } from "rxjs"; import { firstValueFrom } from "rxjs";
@@ -47,7 +47,7 @@ export class LoginCommand {
protected email: string; protected email: string;
private ssoRedirectUri: string = null; private ssoRedirectUri: string = null;
private options: program.OptionValues; private options: OptionValues;
constructor( constructor(
protected authService: AuthService, protected authService: AuthService,
@@ -68,7 +68,7 @@ export class LoginCommand {
protected logoutCallback: () => Promise<void>, protected logoutCallback: () => Promise<void>,
) {} ) {}
async run(email: string, password: string, options: program.OptionValues) { async run(email: string, password: string, options: OptionValues) {
this.options = options; this.options = options;
this.email = email; this.email = email;

View File

@@ -1,7 +1,7 @@
import * as fs from "fs"; import * as fs from "fs";
import * as path from "path"; import * as path from "path";
import * as program from "commander"; import { program } from "commander";
import * as jsdom from "jsdom"; import * as jsdom from "jsdom";
import { PinCryptoServiceAbstraction, PinCryptoService } from "@bitwarden/auth/common"; import { PinCryptoServiceAbstraction, PinCryptoService } from "@bitwarden/auth/common";

View File

@@ -1,25 +1,12 @@
import * as program from "commander"; import { program, OptionValues, Command } from "commander";
import { Response } from "../models/response"; import { Response } from "../models/response";
import { MessageResponse } from "../models/response/message.response"; import { MessageResponse } from "../models/response/message.response";
interface IOption {
long?: string;
short?: string;
description: string;
}
interface ICommand {
commands?: ICommand[];
options?: IOption[];
_name: string;
_description: string;
}
const validShells = ["zsh"]; const validShells = ["zsh"];
export class CompletionCommand { export class CompletionCommand {
async run(options: program.OptionValues) { async run(options: OptionValues) {
const shell: (typeof validShells)[number] = options.shell; const shell: (typeof validShells)[number] = options.shell;
if (!shell) { if (!shell) {
@@ -33,14 +20,14 @@ export class CompletionCommand {
let content = ""; let content = "";
if (shell === "zsh") { if (shell === "zsh") {
content = this.zshCompletion("bw", program as any as ICommand).render(); content = this.zshCompletion("bw", program).render();
} }
const res = new MessageResponse(content, null); const res = new MessageResponse(content, null);
return Response.success(res); return Response.success(res);
} }
private zshCompletion(rootName: string, rootCommand: ICommand) { private zshCompletion(rootName: string, rootCommand: Command) {
return { return {
render: () => { render: () => {
return [ return [
@@ -52,7 +39,7 @@ export class CompletionCommand {
}; };
} }
private renderCommandBlock(name: string, command: ICommand): string { private renderCommandBlock(name: string, command: Command): string {
const { commands = [], options = [] } = command; const { commands = [], options = [] } = command;
const hasOptions = options.length > 0; const hasOptions = options.length > 0;
const hasCommands = commands.length > 0; const hasCommands = commands.length > 0;
@@ -89,18 +76,19 @@ export class CompletionCommand {
cmnds) cmnds)
commands=( commands=(
${commands ${commands
.map(({ _name, _description }) => `"${_name}:${_description}"`) .map((command) => `"${command.name().split(" ")[0]}:${command.description()}"`)
.join("\n ")} .join("\n ")}
) )
_describe "command" commands _describe "command" commands
;; ;;\n esac
esac
case "$words[1]" in case "$words[1]" in
${commands ${commands
.map(({ _name }) => [`${_name})`, `_${name}_${_name}`, ";;"].join("\n ")) .map((command) => {
.join("\n ")} const commandName = command.name().split(" ")[0];
esac`, return [`${commandName})`, `_${name}_${commandName}`, ";;"].join("\n ");
})
.join("\n ")}\n esac`,
); );
} }
@@ -110,7 +98,7 @@ export class CompletionCommand {
if (hasCommands) { if (hasCommands) {
commandBlocParts.push( commandBlocParts.push(
commands.map((c) => this.renderCommandBlock(`${name}_${c._name}`, c)).join("\n\n"), commands.map((c) => this.renderCommandBlock(`${name}_${c.name()}`, c)).join("\n\n"),
); );
} }

View File

@@ -1,4 +1,4 @@
import * as program from "commander"; import { OptionValues } from "commander";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
@@ -9,7 +9,7 @@ import { StringResponse } from "../models/response/string.response";
export class ConfigCommand { export class ConfigCommand {
constructor(private environmentService: EnvironmentService) {} constructor(private environmentService: EnvironmentService) {}
async run(setting: string, value: string, options: program.OptionValues): Promise<Response> { async run(setting: string, value: string, options: OptionValues): Promise<Response> {
setting = setting.toLowerCase(); setting = setting.toLowerCase();
switch (setting) { switch (setting) {
case "server": case "server":
@@ -19,7 +19,7 @@ export class ConfigCommand {
} }
} }
private async getOrSetServer(url: string, options: program.OptionValues): Promise<Response> { private async getOrSetServer(url: string, options: OptionValues): Promise<Response> {
if ( if (
(url == null || url.trim() === "") && (url == null || url.trim() === "") &&
!options.webVault && !options.webVault &&

View File

@@ -1,6 +1,6 @@
import * as koaMulter from "@koa/multer"; import * as koaMulter from "@koa/multer";
import * as koaRouter from "@koa/router"; import * as koaRouter from "@koa/router";
import * as program from "commander"; import { OptionValues } from "commander";
import * as koa from "koa"; import * as koa from "koa";
import * as koaBodyParser from "koa-bodyparser"; import * as koaBodyParser from "koa-bodyparser";
import * as koaJson from "koa-json"; import * as koaJson from "koa-json";
@@ -164,7 +164,7 @@ export class ServeCommand {
); );
} }
async run(options: program.OptionValues) { async run(options: OptionValues) {
const protectOrigin = !options.disableOriginProtection; const protectOrigin = !options.disableOriginProtection;
const port = options.port || 8087; const port = options.port || 8087;
const hostname = options.hostname || "localhost"; const hostname = options.hostname || "localhost";

View File

@@ -1,5 +1,5 @@
import * as chalk from "chalk"; import * as chalk from "chalk";
import * as program from "commander"; import { program, Command, OptionValues } from "commander";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
@@ -135,7 +135,7 @@ export class Program {
writeLn(" bw login --sso"); writeLn(" bw login --sso");
writeLn("", true); writeLn("", true);
}) })
.action(async (email: string, password: string, options: program.OptionValues) => { .action(async (email: string, password: string, options: OptionValues) => {
if (!options.check) { if (!options.check) {
await this.exitIfAuthed(); await this.exitIfAuthed();
const command = new LoginCommand( const command = new LoginCommand(
@@ -427,7 +427,7 @@ export class Program {
writeLn(" bw completion --shell zsh"); writeLn(" bw completion --shell zsh");
writeLn("", true); writeLn("", true);
}) })
.action(async (options: program.OptionValues, cmd: program.Command) => { .action(async (options: OptionValues, cmd: Command) => {
const command = new CompletionCommand(); const command = new CompletionCommand();
const response = await command.run(options); const response = await command.run(options);
this.processResponse(response); this.processResponse(response);

View File

@@ -1,4 +1,4 @@
import * as program from "commander"; import { OptionValues } from "commander";
import * as inquirer from "inquirer"; import * as inquirer from "inquirer";
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
@@ -22,7 +22,7 @@ export class ExportCommand {
private eventCollectionService: EventCollectionService, private eventCollectionService: EventCollectionService,
) {} ) {}
async run(options: program.OptionValues): Promise<Response> { async run(options: OptionValues): Promise<Response> {
if ( if (
options.organizationid == null && options.organizationid == null &&
(await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport)) (await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport))
@@ -79,7 +79,7 @@ export class ExportCommand {
private async saveFile( private async saveFile(
exportContent: string, exportContent: string,
options: program.OptionValues, options: OptionValues,
format: ExportFormat, format: ExportFormat,
): Promise<Response> { ): Promise<Response> {
try { try {

View File

@@ -1,4 +1,4 @@
import * as program from "commander"; import { OptionValues } from "commander";
import * as inquirer from "inquirer"; import * as inquirer from "inquirer";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
@@ -16,11 +16,7 @@ export class ImportCommand {
private syncService: SyncService, private syncService: SyncService,
) {} ) {}
async run( async run(format: ImportType, filepath: string, options: OptionValues): Promise<Response> {
format: ImportType,
filepath: string,
options: program.OptionValues,
): Promise<Response> {
const organizationId = options.organizationid; const organizationId = options.organizationid;
if (organizationId != null) { if (organizationId != null) {
const organization = await this.organizationService.getFromState(organizationId); const organization = await this.organizationService.getFromState(organizationId);

View File

@@ -1,4 +1,4 @@
import * as program from "commander"; import { OptionValues } from "commander";
import { SearchService } from "@bitwarden/common/abstractions/search.service"; import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
@@ -21,7 +21,7 @@ export class SendGetCommand extends DownloadCommand {
super(cryptoService); super(cryptoService);
} }
async run(id: string, options: program.OptionValues) { async run(id: string, options: OptionValues) {
const serveCommand = process.env.BW_SERVE === "true"; const serveCommand = process.env.BW_SERVE === "true";
if (serveCommand && !Utils.isGuid(id)) { if (serveCommand && !Utils.isGuid(id)) {
return Response.badRequest("`" + id + "` is not a GUID."); return Response.badRequest("`" + id + "` is not a GUID.");

View File

@@ -1,4 +1,4 @@
import * as program from "commander"; import { OptionValues } from "commander";
import * as inquirer from "inquirer"; import * as inquirer from "inquirer";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
@@ -36,7 +36,7 @@ export class SendReceiveCommand extends DownloadCommand {
super(cryptoService); super(cryptoService);
} }
async run(url: string, options: program.OptionValues): Promise<Response> { async run(url: string, options: OptionValues): Promise<Response> {
this.canInteract = process.env.BW_NOINTERACTION !== "true"; this.canInteract = process.env.BW_NOINTERACTION !== "true";
let urlObject: URL; let urlObject: URL;

View File

@@ -2,7 +2,7 @@ import * as fs from "fs";
import * as path from "path"; import * as path from "path";
import * as chalk from "chalk"; import * as chalk from "chalk";
import * as program from "commander"; import { program, Command, OptionValues } from "commander";
import { Utils } from "@bitwarden/common/platform/misc/utils"; import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type"; import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
@@ -39,14 +39,11 @@ export class SendProgram extends Program {
program.addCommand(this.receiveCommand()); program.addCommand(this.receiveCommand());
} }
private sendCommand(): program.Command { private sendCommand(): Command {
return new program.Command("send") return new Command("send")
.arguments("<data>") .argument("<data>", "The data to Send. Specify as a filepath with the --file option")
.description( .description(
"Work with Bitwarden sends. A Send can be quickly created using this command or subcommands can be used to fine-tune the Send", "Work with Bitwarden sends. A Send can be quickly created using this command or subcommands can be used to fine-tune the Send",
{
data: "The data to Send. Specify as a filepath with the --file option",
},
) )
.option("-f, --file", "Specifies that <data> is a filepath") .option("-f, --file", "Specifies that <data> is a filepath")
.option( .option(
@@ -73,7 +70,7 @@ export class SendProgram extends Program {
.addCommand(this.editCommand()) .addCommand(this.editCommand())
.addCommand(this.removePasswordCommand()) .addCommand(this.removePasswordCommand())
.addCommand(this.deleteCommand()) .addCommand(this.deleteCommand())
.action(async (data: string, options: program.OptionValues) => { .action(async (data: string, options: OptionValues) => {
const encodedJson = this.makeSendJson(data, options); const encodedJson = this.makeSendJson(data, options);
let response: Response; let response: Response;
@@ -87,8 +84,8 @@ export class SendProgram extends Program {
}); });
} }
private receiveCommand(): program.Command { private receiveCommand(): Command {
return new program.Command("receive") return new Command("receive")
.arguments("<url>") .arguments("<url>")
.description("Access a Bitwarden Send from a url") .description("Access a Bitwarden Send from a url")
.option("--password <password>", "Password needed to access the Send.") .option("--password <password>", "Password needed to access the Send.")
@@ -106,7 +103,7 @@ export class SendProgram extends Program {
); );
writeLn("", true); writeLn("", true);
}) })
.action(async (url: string, options: program.OptionValues) => { .action(async (url: string, options: OptionValues) => {
const cmd = new SendReceiveCommand( const cmd = new SendReceiveCommand(
this.main.apiService, this.main.apiService,
this.main.cryptoService, this.main.cryptoService,
@@ -120,14 +117,14 @@ export class SendProgram extends Program {
}); });
} }
private listCommand(): program.Command { private listCommand(): Command {
return new program.Command("list") return new Command("list")
.description("List all the Sends owned by you") .description("List all the Sends owned by you")
.on("--help", () => { .on("--help", () => {
writeLn(chalk("This is in the list command")); writeLn(chalk("This is in the list command"));
}) })
.action(async (options: program.OptionValues) => { .action(async (options: OptionValues) => {
await this.exitIfLocked(); await this.exitIfLocked();
const cmd = new SendListCommand( const cmd = new SendListCommand(
this.main.sendService, this.main.sendService,
@@ -139,12 +136,10 @@ export class SendProgram extends Program {
}); });
} }
private templateCommand(): program.Command { private templateCommand(): Command {
return new program.Command("template") return new Command("template")
.arguments("<object>") .argument("<object>", "Valid objects are: send.text, send.file")
.description("Get json templates for send objects", { .description("Get json templates for send objects")
object: "Valid objects are: send.text, send.file",
})
.action(async (object) => { .action(async (object) => {
const cmd = new GetCommand( const cmd = new GetCommand(
this.main.cipherService, this.main.cipherService,
@@ -164,8 +159,8 @@ export class SendProgram extends Program {
}); });
} }
private getCommand(): program.Command { private getCommand(): Command {
return new program.Command("get") return new Command("get")
.arguments("<id>") .arguments("<id>")
.description("Get Sends owned by you.") .description("Get Sends owned by you.")
.option("--output <output>", "Output directory or filename for attachment.") .option("--output <output>", "Output directory or filename for attachment.")
@@ -189,7 +184,7 @@ export class SendProgram extends Program {
writeLn(" bw send get searchText --file --raw"); writeLn(" bw send get searchText --file --raw");
writeLn("", true); writeLn("", true);
}) })
.action(async (id: string, options: program.OptionValues) => { .action(async (id: string, options: OptionValues) => {
await this.exitIfLocked(); await this.exitIfLocked();
const cmd = new SendGetCommand( const cmd = new SendGetCommand(
this.main.sendService, this.main.sendService,
@@ -202,12 +197,10 @@ export class SendProgram extends Program {
}); });
} }
private createCommand(): program.Command { private createCommand(): Command {
return new program.Command("create") return new Command("create")
.arguments("[encodedJson]") .argument("[encodedJson]", "JSON object to upload. Can also be piped in through stdin.")
.description("create a Send", { .description("create a Send")
encodedJson: "JSON object to upload. Can also be piped in through stdin.",
})
.option("--file <path>", "file to Send. Can also be specified in parent's JSON.") .option("--file <path>", "file to Send. Can also be specified in parent's JSON.")
.option("--text <text>", "text to Send. Can also be specified in parent's JSON.") .option("--text <text>", "text to Send. Can also be specified in parent's JSON.")
.option("--hidden", "text hidden flag. Valid only with the --text option.") .option("--hidden", "text hidden flag. Valid only with the --text option.")
@@ -221,34 +214,28 @@ export class SendProgram extends Program {
writeLn(" Options specified in JSON take precedence over command options"); writeLn(" Options specified in JSON take precedence over command options");
writeLn("", true); writeLn("", true);
}) })
.action( .action(async (encodedJson: string, options: OptionValues, args: { parent: Command }) => {
async ( // Work-around to support `--fullObject` option for `send create --fullObject`
encodedJson: string, // Calling `option('--fullObject', ...)` above won't work due to Commander doesn't like same option
options: program.OptionValues, // to be defind on both parent-command and sub-command
args: { parent: program.Command }, const { fullObject = false } = args.parent.opts();
) => { const mergedOptions = {
// Work-around to support `--fullObject` option for `send create --fullObject` ...options,
// Calling `option('--fullObject', ...)` above won't work due to Commander doesn't like same option fullObject: fullObject,
// to be defind on both parent-command and sub-command };
const { fullObject = false } = args.parent.opts();
const mergedOptions = {
...options,
fullObject: fullObject,
};
const response = await this.runCreate(encodedJson, mergedOptions); const response = await this.runCreate(encodedJson, mergedOptions);
this.processResponse(response); this.processResponse(response);
}, });
);
} }
private editCommand(): program.Command { private editCommand(): Command {
return new program.Command("edit") return new Command("edit")
.arguments("[encodedJson]") .argument(
.description("edit a Send", { "[encodedJson]",
encodedJson: "Updated JSON object to save. If not provided, encodedJson is read from stdin.",
"Updated JSON object to save. If not provided, encodedJson is read from stdin.", )
}) .description("edit a Send")
.option("--itemid <itemid>", "Overrides the itemId provided in [encodedJson]") .option("--itemid <itemid>", "Overrides the itemId provided in [encodedJson]")
.on("--help", () => { .on("--help", () => {
writeLn(""); writeLn("");
@@ -256,7 +243,7 @@ export class SendProgram extends Program {
writeLn(" You cannot update a File-type Send's file. Just delete and remake it"); writeLn(" You cannot update a File-type Send's file. Just delete and remake it");
writeLn("", true); writeLn("", true);
}) })
.action(async (encodedJson: string, options: program.OptionValues) => { .action(async (encodedJson: string, options: OptionValues) => {
await this.exitIfLocked(); await this.exitIfLocked();
const getCmd = new SendGetCommand( const getCmd = new SendGetCommand(
this.main.sendService, this.main.sendService,
@@ -275,12 +262,10 @@ export class SendProgram extends Program {
}); });
} }
private deleteCommand(): program.Command { private deleteCommand(): Command {
return new program.Command("delete") return new Command("delete")
.arguments("<id>") .argument("<id>", "The id of the Send to delete.")
.description("delete a Send", { .description("delete a Send")
id: "The id of the Send to delete.",
})
.action(async (id: string) => { .action(async (id: string) => {
await this.exitIfLocked(); await this.exitIfLocked();
const cmd = new SendDeleteCommand(this.main.sendService, this.main.sendApiService); const cmd = new SendDeleteCommand(this.main.sendService, this.main.sendApiService);
@@ -289,12 +274,10 @@ export class SendProgram extends Program {
}); });
} }
private removePasswordCommand(): program.Command { private removePasswordCommand(): Command {
return new program.Command("remove-password") return new Command("remove-password")
.arguments("<id>") .argument("<id>", "The id of the Send to alter.")
.description("removes the saved password from a Send.", { .description("removes the saved password from a Send.")
id: "The id of the Send to alter.",
})
.action(async (id: string) => { .action(async (id: string) => {
await this.exitIfLocked(); await this.exitIfLocked();
const cmd = new SendRemovePasswordCommand( const cmd = new SendRemovePasswordCommand(
@@ -307,7 +290,7 @@ export class SendProgram extends Program {
}); });
} }
private makeSendJson(data: string, options: program.OptionValues) { private makeSendJson(data: string, options: OptionValues) {
let sendFile = null; let sendFile = null;
let sendText = null; let sendText = null;
let name = Utils.newGuid(); let name = Utils.newGuid();
@@ -336,7 +319,7 @@ export class SendProgram extends Program {
return Buffer.from(JSON.stringify(template), "utf8").toString("base64"); return Buffer.from(JSON.stringify(template), "utf8").toString("base64");
} }
private async runCreate(encodedJson: string, options: program.OptionValues) { private async runCreate(encodedJson: string, options: OptionValues) {
await this.exitIfLocked(); await this.exitIfLocked();
const cmd = new SendCreateCommand( const cmd = new SendCreateCommand(
this.main.sendService, this.main.sendService,

View File

@@ -1,4 +1,4 @@
import * as program from "commander"; import { program, Command } from "commander";
import { ConfirmCommand } from "./admin-console/commands/confirm.command"; import { ConfirmCommand } from "./admin-console/commands/confirm.command";
import { ShareCommand } from "./admin-console/commands/share.command"; import { ShareCommand } from "./admin-console/commands/share.command";
@@ -54,7 +54,7 @@ export class VaultProgram extends Program {
return success; return success;
} }
private listCommand(): program.Command { private listCommand(): Command {
const listObjects = [ const listObjects = [
"items", "items",
"folders", "folders",
@@ -64,11 +64,9 @@ export class VaultProgram extends Program {
"organizations", "organizations",
]; ];
return new program.Command("list") return new Command("list")
.arguments("<object>") .argument("<object>", "Valid objects are: " + listObjects.join(", "))
.description("List an array of objects from the vault.", { .description("List an array of objects from the vault.")
object: "Valid objects are: " + listObjects.join(", "),
})
.option("--search <search>", "Perform a search on the listed objects.") .option("--search <search>", "Perform a search on the listed objects.")
.option("--url <url>", "Filter items of type login with a url-match search.") .option("--url <url>", "Filter items of type login with a url-match search.")
.option("--folderid <folderid>", "Filter items by folder id.") .option("--folderid <folderid>", "Filter items by folder id.")
@@ -125,7 +123,7 @@ export class VaultProgram extends Program {
}); });
} }
private getCommand(): program.Command { private getCommand(): Command {
const getObjects = [ const getObjects = [
"item", "item",
"username", "username",
@@ -143,12 +141,10 @@ export class VaultProgram extends Program {
"fingerprint", "fingerprint",
"send", "send",
]; ];
return new program.Command("get") return new Command("get")
.arguments("<object> <id>") .argument("<object>", "Valid objects are: " + getObjects.join(", "))
.description("Get an object from the vault.", { .argument("<id>", "Search term or object's globally unique `id`.")
object: "Valid objects are: " + getObjects.join(", "), .description("Get an object from the vault.")
id: "Search term or object's globally unique `id`.",
})
.option("--itemid <itemid>", "Attachment's item id.") .option("--itemid <itemid>", "Attachment's item id.")
.option("--output <output>", "Output directory or filename for attachment.") .option("--output <output>", "Output directory or filename for attachment.")
.option("--organizationid <organizationid>", "Organization id for an organization object.") .option("--organizationid <organizationid>", "Organization id for an organization object.")
@@ -200,12 +196,13 @@ export class VaultProgram extends Program {
private createCommand() { private createCommand() {
const createObjects = ["item", "attachment", "folder", "org-collection"]; const createObjects = ["item", "attachment", "folder", "org-collection"];
return new program.Command("create") return new Command("create")
.arguments("<object> [encodedJson]") .argument("<object>", "Valid objects are: " + createObjects.join(", "))
.description("Create an object in the vault.", { .argument(
object: "Valid objects are: " + createObjects.join(", "), "[encodedJson]",
encodedJson: "Encoded json of the object to create. Can also be piped into stdin.", "Encoded json of the object to create. Can also be piped into stdin.",
}) )
.description("Create an object in the vault.")
.option("--file <file>", "Path to file for attachment.") .option("--file <file>", "Path to file for attachment.")
.option("--itemid <itemid>", "Attachment's item id.") .option("--itemid <itemid>", "Attachment's item id.")
.option("--organizationid <organizationid>", "Organization id for an organization object.") .option("--organizationid <organizationid>", "Organization id for an organization object.")
@@ -239,15 +236,16 @@ export class VaultProgram extends Program {
}); });
} }
private editCommand(): program.Command { private editCommand(): Command {
const editObjects = ["item", "item-collections", "folder", "org-collection"]; const editObjects = ["item", "item-collections", "folder", "org-collection"];
return new program.Command("edit") return new Command("edit")
.arguments("<object> <id> [encodedJson]") .argument("<object>", "Valid objects are: " + editObjects.join(", "))
.description("Edit an object from the vault.", { .argument("<id>", "Object's globally unique `id`.")
object: "Valid objects are: " + editObjects.join(", "), .argument(
id: "Object's globally unique `id`.", "[encodedJson]",
encodedJson: "Encoded json of the object to create. Can also be piped into stdin.", "Encoded json of the object to create. Can also be piped into stdin.",
}) )
.description("Edit an object from the vault.")
.option("--organizationid <organizationid>", "Organization id for an organization object.") .option("--organizationid <organizationid>", "Organization id for an organization object.")
.on("--help", () => { .on("--help", () => {
writeLn("\n Examples:"); writeLn("\n Examples:");
@@ -283,14 +281,12 @@ export class VaultProgram extends Program {
}); });
} }
private deleteCommand(): program.Command { private deleteCommand(): Command {
const deleteObjects = ["item", "attachment", "folder", "org-collection"]; const deleteObjects = ["item", "attachment", "folder", "org-collection"];
return new program.Command("delete") return new Command("delete")
.arguments("<object> <id>") .argument("<object>", "Valid objects are: " + deleteObjects.join(", "))
.description("Delete an object from the vault.", { .argument("<id>", "Object's globally unique `id`.")
object: "Valid objects are: " + deleteObjects.join(", "), .description("Delete an object from the vault.")
id: "Object's globally unique `id`.",
})
.option("--itemid <itemid>", "Attachment's item id.") .option("--itemid <itemid>", "Attachment's item id.")
.option("--organizationid <organizationid>", "Organization id for an organization object.") .option("--organizationid <organizationid>", "Organization id for an organization object.")
.option( .option(
@@ -326,14 +322,12 @@ export class VaultProgram extends Program {
}); });
} }
private restoreCommand(): program.Command { private restoreCommand(): Command {
const restoreObjects = ["item"]; const restoreObjects = ["item"];
return new program.Command("restore") return new Command("restore")
.arguments("<object> <id>") .argument("<object>", "Valid objects are: " + restoreObjects.join(", "))
.description("Restores an object from the trash.", { .argument("<id>", "Object's globally unique `id`.")
object: "Valid objects are: " + restoreObjects.join(", "), .description("Restores an object from the trash.")
id: "Object's globally unique `id`.",
})
.on("--help", () => { .on("--help", () => {
writeLn("\n Examples:"); writeLn("\n Examples:");
writeLn(""); writeLn("");
@@ -352,14 +346,15 @@ export class VaultProgram extends Program {
}); });
} }
private shareCommand(commandName: string, deprecated: boolean): program.Command { private shareCommand(commandName: string, deprecated: boolean): Command {
return new program.Command(commandName) return new Command(commandName)
.arguments("<id> <organizationId> [encodedJson]") .argument("<id>", "Object's globally unique `id`.")
.description((deprecated ? "--DEPRECATED-- " : "") + "Move an item to an organization.", { .argument("<organizationId>", "Organization's globally unique `id`.")
id: "Object's globally unique `id`.", .argument(
organizationId: "Organization's globally unique `id`.", "[encodedJson]",
encodedJson: "Encoded json of an array of collection ids. Can also be piped into stdin.", "Encoded json of an array of collection ids. Can also be piped into stdin.",
}) )
.description((deprecated ? "--DEPRECATED-- " : "") + "Move an item to an organization.")
.on("--help", () => { .on("--help", () => {
writeLn("\n Examples:"); writeLn("\n Examples:");
writeLn(""); writeLn("");
@@ -389,14 +384,12 @@ export class VaultProgram extends Program {
}); });
} }
private confirmCommand(): program.Command { private confirmCommand(): Command {
const confirmObjects = ["org-member"]; const confirmObjects = ["org-member"];
return new program.Command("confirm") return new Command("confirm")
.arguments("<object> <id>") .argument("<object>", "Valid objects are: " + confirmObjects.join(", "))
.description("Confirm an object to the organization.", { .argument("<id>", "Object's globally unique `id`.")
object: "Valid objects are: " + confirmObjects.join(", "), .description("Confirm an object to the organization.")
id: "Object's globally unique `id`.",
})
.option("--organizationid <organizationid>", "Organization id for an organization object.") .option("--organizationid <organizationid>", "Organization id for an organization object.")
.on("--help", () => { .on("--help", () => {
writeLn("\n Examples:"); writeLn("\n Examples:");
@@ -423,13 +416,11 @@ export class VaultProgram extends Program {
}); });
} }
private importCommand(): program.Command { private importCommand(): Command {
return new program.Command("import") return new Command("import")
.arguments("[format] [input]") .argument("[format]", "The format of [input]")
.description("Import vault data from a file.", { .argument("[input]", "Filepath to data to import")
format: "The format of [input]", .description("Import vault data from a file.")
input: "Filepath to data to import",
})
.option("--formats", "List formats") .option("--formats", "List formats")
.option("--organizationid <organizationid>", "ID of the organization to import to.") .option("--organizationid <organizationid>", "ID of the organization to import to.")
.on("--help", () => { .on("--help", () => {
@@ -454,9 +445,9 @@ export class VaultProgram extends Program {
}); });
} }
private exportCommand(): program.Command { private exportCommand(): Command {
return new program.Command("export") return new Command("export")
.description("Export vault data to a CSV or JSON file.", {}) .description("Export vault data to a CSV or JSON file.")
.option("--output <output>", "Output directory or filename.") .option("--output <output>", "Output directory or filename.")
.option("--format <format>", "Export file format.") .option("--format <format>", "Export file format.")
.option( .option(

30
package-lock.json generated
View File

@@ -36,7 +36,7 @@
"braintree-web-drop-in": "1.42.0", "braintree-web-drop-in": "1.42.0",
"bufferutil": "4.0.8", "bufferutil": "4.0.8",
"chalk": "4.1.2", "chalk": "4.1.2",
"commander": "7.2.0", "commander": "11.1.0",
"core-js": "3.34.0", "core-js": "3.34.0",
"duo_web_sdk": "github:duosecurity/duo_web_sdk", "duo_web_sdk": "github:duosecurity/duo_web_sdk",
"form-data": "4.0.0", "form-data": "4.0.0",
@@ -207,7 +207,7 @@
"big-integer": "1.6.51", "big-integer": "1.6.51",
"browser-hrtime": "1.1.8", "browser-hrtime": "1.1.8",
"chalk": "4.1.2", "chalk": "4.1.2",
"commander": "7.2.0", "commander": "11.1.0",
"form-data": "4.0.0", "form-data": "4.0.0",
"https-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.2",
"inquirer": "8.2.6", "inquirer": "8.2.6",
@@ -5075,15 +5075,6 @@
"balanced-match": "^1.0.0" "balanced-match": "^1.0.0"
} }
}, },
"node_modules/@compodoc/compodoc/node_modules/commander": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"dev": true,
"engines": {
"node": ">=16"
}
},
"node_modules/@compodoc/compodoc/node_modules/cosmiconfig": { "node_modules/@compodoc/compodoc/node_modules/cosmiconfig": {
"version": "8.3.6", "version": "8.3.6",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz",
@@ -17429,11 +17420,11 @@
} }
}, },
"node_modules/commander": { "node_modules/commander": {
"version": "7.2.0", "version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"engines": { "engines": {
"node": ">= 10" "node": ">=16"
} }
}, },
"node_modules/common-tags": { "node_modules/common-tags": {
@@ -27342,15 +27333,6 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "url": "https://github.com/chalk/chalk?sponsor=1"
} }
}, },
"node_modules/lint-staged/node_modules/commander": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"dev": true,
"engines": {
"node": ">=16"
}
},
"node_modules/lint-staged/node_modules/execa": { "node_modules/lint-staged/node_modules/execa": {
"version": "8.0.1", "version": "8.0.1",
"resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz",

View File

@@ -171,7 +171,7 @@
"braintree-web-drop-in": "1.42.0", "braintree-web-drop-in": "1.42.0",
"bufferutil": "4.0.8", "bufferutil": "4.0.8",
"chalk": "4.1.2", "chalk": "4.1.2",
"commander": "7.2.0", "commander": "11.1.0",
"core-js": "3.34.0", "core-js": "3.34.0",
"duo_web_sdk": "github:duosecurity/duo_web_sdk", "duo_web_sdk": "github:duosecurity/duo_web_sdk",
"form-data": "4.0.0", "form-data": "4.0.0",