@within-7/jetr 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +29 -26
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -493,32 +493,7 @@ program.command("login").description("Login with username and password").argumen
|
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
495
|
if (!password) {
|
|
496
|
-
|
|
497
|
-
process.stdout.write("Password: ");
|
|
498
|
-
const stdin = process.stdin;
|
|
499
|
-
const wasRaw = stdin.isRaw;
|
|
500
|
-
if (stdin.isTTY) stdin.setRawMode(true);
|
|
501
|
-
password = await new Promise((res) => {
|
|
502
|
-
let buf = "";
|
|
503
|
-
const onData = (ch) => {
|
|
504
|
-
const c = ch.toString();
|
|
505
|
-
if (c === "\n" || c === "\r" || c === "") {
|
|
506
|
-
if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
|
|
507
|
-
stdin.removeListener("data", onData);
|
|
508
|
-
process.stdout.write("\n");
|
|
509
|
-
rl.close();
|
|
510
|
-
res(buf);
|
|
511
|
-
} else if (c === "") {
|
|
512
|
-
if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
|
|
513
|
-
process.exit(1);
|
|
514
|
-
} else if (c === "\x7F" || c === "\b") {
|
|
515
|
-
buf = buf.slice(0, -1);
|
|
516
|
-
} else {
|
|
517
|
-
buf += c;
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
stdin.on("data", onData);
|
|
521
|
-
});
|
|
496
|
+
password = await readSecret("Password: ");
|
|
522
497
|
}
|
|
523
498
|
if (!user || !password) {
|
|
524
499
|
console.error(chalk2.red("Username and password required"));
|
|
@@ -693,6 +668,34 @@ tokenCmd.command("revoke").description("Revoke a share token").argument("<site>"
|
|
|
693
668
|
process.exit(1);
|
|
694
669
|
}
|
|
695
670
|
});
|
|
671
|
+
function readSecret(prompt) {
|
|
672
|
+
return new Promise((resolve3) => {
|
|
673
|
+
process.stdout.write(prompt);
|
|
674
|
+
const stdin = process.stdin;
|
|
675
|
+
stdin.resume();
|
|
676
|
+
stdin.setRawMode(true);
|
|
677
|
+
stdin.setEncoding("utf8");
|
|
678
|
+
let buf = "";
|
|
679
|
+
const onData = (ch) => {
|
|
680
|
+
if (ch === "\n" || ch === "\r" || ch === "") {
|
|
681
|
+
stdin.setRawMode(false);
|
|
682
|
+
stdin.pause();
|
|
683
|
+
stdin.removeListener("data", onData);
|
|
684
|
+
process.stdout.write("\n");
|
|
685
|
+
resolve3(buf);
|
|
686
|
+
} else if (ch === "") {
|
|
687
|
+
stdin.setRawMode(false);
|
|
688
|
+
process.stdout.write("\n");
|
|
689
|
+
process.exit(1);
|
|
690
|
+
} else if (ch === "\x7F" || ch === "\b") {
|
|
691
|
+
buf = buf.slice(0, -1);
|
|
692
|
+
} else {
|
|
693
|
+
buf += ch;
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
stdin.on("data", onData);
|
|
697
|
+
});
|
|
698
|
+
}
|
|
696
699
|
function formatBytes(bytes) {
|
|
697
700
|
if (bytes === 0) return "0 B";
|
|
698
701
|
const units = ["B", "KB", "MB", "GB"];
|