iframer-cli 1.0.4 → 2.0.1
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/{cli.cjs → cli.js} +32 -105
- package/mcp-server.cjs +28715 -0
- package/package.json +7 -25
- package/bun.lock +0 -195
- package/index.js +0 -633
package/{cli.cjs → cli.js}
RENAMED
|
@@ -404,111 +404,6 @@ async function main() {
|
|
|
404
404
|
break;
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
// ─── Proxy tunnel ───────────────────────────────────────────────
|
|
408
|
-
|
|
409
|
-
case "proxy": {
|
|
410
|
-
const token = requireToken();
|
|
411
|
-
const server = getServer();
|
|
412
|
-
const wsUrl = server.replace(/^http/, "ws") + "/proxy/tunnel?token=" + token;
|
|
413
|
-
|
|
414
|
-
let WebSocket;
|
|
415
|
-
try {
|
|
416
|
-
WebSocket = require("ws");
|
|
417
|
-
} catch {
|
|
418
|
-
console.error(" ws package required. Run: npm install -g ws");
|
|
419
|
-
console.error(" Or: bun add ws");
|
|
420
|
-
process.exit(1);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const net = require("net");
|
|
424
|
-
const ws = new WebSocket(wsUrl);
|
|
425
|
-
const connections = new Map();
|
|
426
|
-
|
|
427
|
-
console.log("\n Connecting to server...");
|
|
428
|
-
|
|
429
|
-
ws.on("open", () => {
|
|
430
|
-
console.log(" Connected! Your browser sessions will route through this machine.");
|
|
431
|
-
console.log(" Keep this running. Press Ctrl+C to stop.\n");
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
ws.on("message", (msg) => {
|
|
435
|
-
if (Buffer.isBuffer(msg) && msg.length > 4) {
|
|
436
|
-
// Binary data frame: first 4 bytes = connId
|
|
437
|
-
const connId = msg.readUInt32BE(0);
|
|
438
|
-
const data = msg.slice(4);
|
|
439
|
-
const socket = connections.get(connId);
|
|
440
|
-
if (socket && !socket.destroyed) {
|
|
441
|
-
socket.write(data);
|
|
442
|
-
}
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
try {
|
|
447
|
-
const data = JSON.parse(msg.toString());
|
|
448
|
-
|
|
449
|
-
if (data.type === "ready") {
|
|
450
|
-
console.log(` Proxy tunnel active (server port ${data.port})`);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (data.type === "connect") {
|
|
454
|
-
const { id, host, port } = data;
|
|
455
|
-
const socket = net.createConnection({ host, port }, () => {
|
|
456
|
-
ws.send(JSON.stringify({ type: "connected", id }));
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
socket.on("data", (chunk) => {
|
|
460
|
-
const header = Buffer.alloc(4);
|
|
461
|
-
header.writeUInt32BE(id);
|
|
462
|
-
if (ws.readyState === 1) ws.send(Buffer.concat([header, chunk]));
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
socket.on("end", () => {
|
|
466
|
-
ws.send(JSON.stringify({ type: "close", id }));
|
|
467
|
-
connections.delete(id);
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
socket.on("error", (err) => {
|
|
471
|
-
ws.send(JSON.stringify({ type: "error", id, message: err.message }));
|
|
472
|
-
connections.delete(id);
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
connections.set(id, socket);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (data.type === "close") {
|
|
479
|
-
const socket = connections.get(data.id);
|
|
480
|
-
if (socket) {
|
|
481
|
-
socket.destroy();
|
|
482
|
-
connections.delete(data.id);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
} catch {}
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
ws.on("close", () => {
|
|
489
|
-
console.log("\n Disconnected from server.");
|
|
490
|
-
process.exit(0);
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
ws.on("error", (err) => {
|
|
494
|
-
console.error(` Connection error: ${err.message}`);
|
|
495
|
-
process.exit(1);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
process.on("SIGINT", () => {
|
|
499
|
-
console.log("\n Stopping proxy tunnel...");
|
|
500
|
-
for (const [, socket] of connections) {
|
|
501
|
-
try { socket.destroy(); } catch {}
|
|
502
|
-
}
|
|
503
|
-
ws.close();
|
|
504
|
-
process.exit(0);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
// Block forever
|
|
508
|
-
await new Promise(() => {});
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
407
|
// ─── Screenshot ────────────────────────────────────────────────
|
|
513
408
|
|
|
514
409
|
case "screenshot": {
|
|
@@ -606,6 +501,9 @@ async function main() {
|
|
|
606
501
|
case "recaptcha-info":
|
|
607
502
|
action = { type: "recaptcha-info" };
|
|
608
503
|
break;
|
|
504
|
+
case "recaptcha-solve-auto":
|
|
505
|
+
action = { type: "recaptcha-solve-auto" };
|
|
506
|
+
break;
|
|
609
507
|
default:
|
|
610
508
|
console.error(` Unknown action: ${actionType}`);
|
|
611
509
|
process.exit(1);
|
|
@@ -616,6 +514,34 @@ async function main() {
|
|
|
616
514
|
break;
|
|
617
515
|
}
|
|
618
516
|
|
|
517
|
+
// ─── Install MCP ──────────────────────────────────────────────
|
|
518
|
+
|
|
519
|
+
case "install-mcp": {
|
|
520
|
+
const mcpServerPath = path.join(__dirname, "mcp-server.cjs");
|
|
521
|
+
if (!fs.existsSync(mcpServerPath)) {
|
|
522
|
+
console.error(" MCP server bundle not found. Try reinstalling: npm install -g iframer-cli");
|
|
523
|
+
process.exit(1);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const claudeConfigPath = path.join(require("os").homedir(), ".claude.json");
|
|
527
|
+
let config = {};
|
|
528
|
+
try {
|
|
529
|
+
config = JSON.parse(fs.readFileSync(claudeConfigPath, "utf8"));
|
|
530
|
+
} catch {}
|
|
531
|
+
|
|
532
|
+
if (!config.mcpServers) config.mcpServers = {};
|
|
533
|
+
config.mcpServers.iframer = {
|
|
534
|
+
command: "node",
|
|
535
|
+
args: [mcpServerPath],
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
fs.writeFileSync(claudeConfigPath, JSON.stringify(config, null, 2));
|
|
539
|
+
console.log("\n iframer MCP installed!");
|
|
540
|
+
console.log(` Config written to: ${claudeConfigPath}`);
|
|
541
|
+
console.log("\n Restart Claude Code to activate the iframer tools.\n");
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
|
|
619
545
|
// ─── Help ──────────────────────────────────────────────────────
|
|
620
546
|
|
|
621
547
|
default:
|
|
@@ -626,6 +552,7 @@ async function main() {
|
|
|
626
552
|
login Authenticate with the server
|
|
627
553
|
logout Remove saved credentials
|
|
628
554
|
status Show current auth status
|
|
555
|
+
install-mcp Install the iframer MCP into Claude Code
|
|
629
556
|
|
|
630
557
|
Credentials:
|
|
631
558
|
credentials add <domain> Store login credentials (encrypted, server-side)
|