48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
import { Command } from "commander";
|
|
import { rollServerKeysChainCommand } from "../commands/keys/keys-chain.js";
|
|
import { promptForNewPassword, promptForPassword } from "../prompt/prompt.js";
|
|
import { runFunction } from "../run-function/run-function.js";
|
|
|
|
const program = new Command()
|
|
.name("roll-server-keys-chain")
|
|
.description("Rotate a chained server keychain to currentVersion + 1")
|
|
.requiredOption(
|
|
"-r, --root-vault <path>",
|
|
"Path to root vault",
|
|
"./keys/root.vault"
|
|
)
|
|
.requiredOption(
|
|
"-v, --current-version <number>",
|
|
"Current server keychain version",
|
|
Number.parseInt
|
|
)
|
|
.option("-o, --output <dir>", "Output directory", "./keys")
|
|
.action(
|
|
(options: {
|
|
rootVault: string;
|
|
currentVersion: number;
|
|
output: string;
|
|
}) =>
|
|
runFunction("roll-server-keys-chain", async (signal) => {
|
|
const rootPassword = await promptForPassword(
|
|
"Enter root vault password"
|
|
);
|
|
const serverPassword = await promptForNewPassword(
|
|
"Enter password for the new server vault"
|
|
);
|
|
await rollServerKeysChainCommand(
|
|
options.rootVault,
|
|
rootPassword,
|
|
serverPassword,
|
|
options.currentVersion,
|
|
{
|
|
output: options.output,
|
|
...(signal !== undefined ? { signal } : {}),
|
|
}
|
|
);
|
|
})
|
|
);
|
|
|
|
program.parse();
|