zerobyte/app/server/cli/index.ts
Jakub Trávník a4d0c7b0c9 feat: add two-factor authentication (TOTP) support
- Add 2FA endpoints for setup, enable, disable, and verify
- Encrypt TOTP secrets with AES-256-GCM before storing
- Require password for both enabling and disabling 2FA
- Invalidate all sessions when 2FA status changes
- Add QR code display using qrcode.react (client-side)
- Add 2FA verification step in login flow
- Add CLI recovery command: 2fa disable -u <username>
- Add success variant to Badge component
- Update README with 2FA documentation
2026-01-03 00:19:04 +01:00

39 lines
911 B
TypeScript

import { Command } from "commander";
import { resetPasswordCommand } from "./commands/reset-password";
import { twoFactorCommand } from "./commands/2fa";
const program = new Command();
program.name("zerobyte").description("Zerobyte CLI - Backup automation tool built on top of Restic").version("1.0.0");
program.addCommand(resetPasswordCommand);
program.addCommand(twoFactorCommand);
export async function runCLI(argv: string[]): Promise<boolean> {
const args = argv.slice(2);
const isCLIMode = process.env.ZEROBYTE_CLI === "1";
if (args.length === 0) {
if (isCLIMode) {
program.help();
return true;
}
return false;
}
if (!isCLIMode && args[0].startsWith("-")) {
return false;
}
await program.parseAsync(argv).catch((err) => {
if (err.message.includes("SIGINT")) {
process.exit(0);
}
console.error(err.message);
process.exit(1);
});
return true;
}
export { program };