1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-30 08:10:34 +01:00
bitwarden-browser/apps/cli/src/commands/encode.command.ts

16 lines
505 B
TypeScript
Raw Normal View History

import { Response } from "../models/response";
import { StringResponse } from "../models/response/string.response";
2021-12-20 18:04:00 +01:00
import { CliUtils } from "../utils";
2018-05-14 23:13:57 +02:00
export class EncodeCommand {
2021-12-20 18:04:00 +01:00
async run(): Promise<Response> {
if (process.stdin.isTTY) {
return Response.badRequest("No stdin was piped in.");
2018-05-14 23:13:57 +02:00
}
2021-12-20 18:04:00 +01:00
const input = await CliUtils.readStdin();
const b64 = Buffer.from(input, "utf8").toString("base64");
const res = new StringResponse(b64);
return Response.success(res);
}
2018-05-14 23:13:57 +02:00
}