vlt
Version:
The vlt CLI
90 lines (87 loc) • 2.39 kB
JavaScript
var global = globalThis;
import {Buffer} from "node:buffer";
import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers";
import {createRequire as _vlt_createRequire} from "node:module";
var require = _vlt_createRequire(import.meta.filename);
import {
commandUsage
} from "./chunk-2Y5QRO5N.js";
import {
deleteToken,
setToken
} from "./chunk-QAFV2NQX.js";
import "./chunk-VYJVN3B6.js";
import "./chunk-GADRCS54.js";
import "./chunk-GY4L7O2Y.js";
import "./chunk-3HSZY4YW.js";
import "./chunk-6YRWYWZQ.js";
import "./chunk-TJHWNOOA.js";
import "./chunk-3RABDTYN.js";
import "./chunk-X4RDKJKD.js";
import "./chunk-BNCOU5ZT.js";
import {
error
} from "./chunk-RV3EHS4P.js";
import "./chunk-AECDW3EJ.js";
// ../../src/cli-sdk/src/read-password.ts
var readPassword = async (prompt, { stdin, stdout } = process) => {
let input = "";
stdout.write(prompt);
stdin.setRawMode(true);
await new Promise((res, rej) => {
stdin.on("data", (c) => {
if (c.length === 1 && c[0] === 127) {
input = input.substring(0, input.length - 1);
stdout.write("\x1B[1D \x1B[1D");
return;
}
input += String(c);
if (/\r|\n|\x04|\x03/.test(input)) {
input = input.replace(/(\r|\n|\x04|\x03)/g, "");
stdin.setRawMode(false);
stdin.pause();
if (c[c.length - 1] === 3) {
rej(error("canceled", { signal: "SIGINT" }));
} else res();
} else {
stdout.write("*".repeat(c.length));
}
});
});
return input;
};
// ../../src/cli-sdk/src/commands/token.ts
var usage = () => commandUsage({
command: "token",
usage: ["add", "rm"],
description: `Explicitly add or remove tokens in the vlt keychain`
});
var command = async (conf) => {
const reg = new URL(conf.options.registry).origin;
switch (conf.positionals[0]) {
case "add": {
await setToken(
reg,
`Bearer ${await readPassword("Paste bearer token: ")}`,
conf.options.identity
);
break;
}
case "rm": {
await deleteToken(reg, conf.options.identity);
break;
}
default: {
throw error("Invalid token subcommand", {
found: conf.positionals[0],
validOptions: ["add", "rm"],
code: "EUSAGE"
});
}
}
};
export {
command,
usage
};
//# sourceMappingURL=token-XJUTLIIW.js.map