icoa-cli 2.19.6 → 2.19.8

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.
@@ -1,5 +1,4 @@
1
1
  import chalk from 'chalk';
2
- import { createInterface } from 'node:readline';
3
2
  import { CTFdClient } from '../lib/ctfd-client.js';
4
3
  import { getConfig, saveConfig, getBudget } from '../lib/config.js';
5
4
  import { logCommand, logSubmission } from '../lib/logger.js';
@@ -30,45 +29,45 @@ export function registerCtfCommands(program) {
30
29
  logCommand(`ctf join ${url}`);
31
30
  console.log();
32
31
  printInfo(`Connecting to ${chalk.bold(url)}`);
33
- // Use native readline to avoid REPL conflict
34
- const username = await new Promise((resolve) => {
35
- process.stdout.write(chalk.white(' Username: '));
36
- const rl = createInterface({ input: process.stdin, output: process.stdout });
37
- rl.once('line', (line) => { rl.close(); resolve(line.trim()); });
38
- });
39
- const password = await new Promise((resolve) => {
40
- process.stdout.write(chalk.white(' Password: '));
41
- if (process.stdin.isTTY)
42
- process.stdin.setRawMode?.(true);
43
- let pw = '';
44
- const onData = (ch) => {
45
- const c = ch.toString();
46
- if (c === '\n' || c === '\r') {
47
- if (process.stdin.isTTY)
48
- process.stdin.setRawMode?.(false);
49
- process.stdin.removeListener('data', onData);
50
- process.stdout.write('\n');
51
- resolve(pw);
52
- }
53
- else if (c === '\x7f' || c === '\b') {
54
- if (pw.length > 0) {
55
- pw = pw.slice(0, -1);
56
- process.stdout.write('\b \b');
32
+ // Read username and password using raw stdin (avoids REPL readline conflict)
33
+ function rawInput(prompt, mask) {
34
+ return new Promise((resolve) => {
35
+ process.stdout.write(chalk.white(prompt));
36
+ if (process.stdin.isTTY)
37
+ process.stdin.setRawMode?.(true);
38
+ let buf = '';
39
+ const onData = (ch) => {
40
+ const c = ch.toString();
41
+ if (c === '\n' || c === '\r') {
42
+ if (process.stdin.isTTY)
43
+ process.stdin.setRawMode?.(false);
44
+ process.stdin.removeListener('data', onData);
45
+ process.stdout.write('\n');
46
+ resolve(buf);
57
47
  }
58
- }
59
- else if (c === '\x03') {
60
- if (process.stdin.isTTY)
61
- process.stdin.setRawMode?.(false);
62
- process.stdin.removeListener('data', onData);
63
- resolve('');
64
- }
65
- else {
66
- pw += c;
67
- process.stdout.write('*');
68
- }
69
- };
70
- process.stdin.on('data', onData);
71
- });
48
+ else if (c === '\x7f' || c === '\b') {
49
+ if (buf.length > 0) {
50
+ buf = buf.slice(0, -1);
51
+ process.stdout.write('\b \b');
52
+ }
53
+ }
54
+ else if (c === '\x03') {
55
+ if (process.stdin.isTTY)
56
+ process.stdin.setRawMode?.(false);
57
+ process.stdin.removeListener('data', onData);
58
+ process.stdout.write('\n');
59
+ resolve('');
60
+ }
61
+ else {
62
+ buf += c;
63
+ process.stdout.write(mask || c);
64
+ }
65
+ };
66
+ process.stdin.on('data', onData);
67
+ });
68
+ }
69
+ const username = await rawInput(' Username: ');
70
+ const password = await rawInput(' Password: ', '*');
72
71
  let token = '';
73
72
  let sessionCookie = '';
74
73
  let csrfNonce = '';
package/dist/repl.js CHANGED
@@ -594,6 +594,10 @@ export async function startRepl(program, resumeMode) {
594
594
  }
595
595
  processing = true;
596
596
  const args = mapCommand(input);
597
+ // Pause REPL readline for commands that read stdin (join)
598
+ const needsPause = args[0] === 'ctf' && args[1] === 'join';
599
+ if (needsPause)
600
+ rl.pause();
597
601
  process.exit = (() => {
598
602
  throw new Error(INTERCEPT);
599
603
  });
@@ -618,6 +622,8 @@ export async function startRepl(program, resumeMode) {
618
622
  finally {
619
623
  process.exit = realExit;
620
624
  processing = false;
625
+ if (needsPause)
626
+ rl.resume();
621
627
  }
622
628
  // Switch prompt if entering chat/challenge mode
623
629
  if (isChatActive()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.6",
3
+ "version": "2.19.8",
4
4
  "description": "ICOA CLI — The world's first CLI-native CTF competition terminal",
5
5
  "type": "module",
6
6
  "bin": {