@hmduc16031996/claude-mb-bridge 2.4.9 → 2.5.2
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/index.js +6 -12
- package/dist/tunnel.d.ts +1 -1
- package/dist/tunnel.js +2 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,8 +3,6 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { CloudflareTunnel } from './tunnel.js';
|
|
4
4
|
import { startTerminalServer } from './server.js';
|
|
5
5
|
const program = new Command();
|
|
6
|
-
const CLOUDFLARE_TUNNEL_TOKEN = 'eyJhIjoiZmM5YTQ4ZTU3NjY4NjI3MjY2OWE3YzBiMTliNTcyYzgiLCJ0IjoiMjgzM2E5NjMtNTBiYi00YThjLWJhMGMtNDI4NWE4ZTJkZmJjIiwicyI6IllqYzVaakF3T1RJdFpEWXdZeTAwWkRFNUxUZzVNR0l0WXpBeE1UazJNamc1T1dZeCJ9';
|
|
7
|
-
const CLOUDFLARE_PUBLIC_URL = 'https://mobileideforusers.kanddlabs.com';
|
|
8
6
|
program
|
|
9
7
|
.name('claude-mobile-bridge')
|
|
10
8
|
.description('Bridge Claude Code CLI to mobile via WebView')
|
|
@@ -14,10 +12,8 @@ program
|
|
|
14
12
|
.option('--path <path>', 'Working directory', process.cwd())
|
|
15
13
|
.option('--port <port>', 'Local port for terminal server', '38473')
|
|
16
14
|
.option('--ide <type>', 'IDE type: claude_code or cursor', 'claude_code')
|
|
17
|
-
.option('--tunnel-token <token>', 'Cloudflare Tunnel token (managed tunnel)', CLOUDFLARE_TUNNEL_TOKEN)
|
|
18
|
-
.option('--public-url <url>', 'Static public URL for the tunnel', CLOUDFLARE_PUBLIC_URL)
|
|
19
15
|
.action(async (options) => {
|
|
20
|
-
const { token, server, path, port, ide
|
|
16
|
+
const { token, server, path, port, ide } = options;
|
|
21
17
|
if (!token) {
|
|
22
18
|
console.error('Error: --token is required');
|
|
23
19
|
process.exit(1);
|
|
@@ -43,14 +39,12 @@ program
|
|
|
43
39
|
// 2. Start Cloudflare Tunnel
|
|
44
40
|
console.log('🌐 Establishing secure tunnel...');
|
|
45
41
|
const tunnel = new CloudflareTunnel();
|
|
46
|
-
const tunnelResult = await tunnel.start(actualPort
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!finalUrl) {
|
|
50
|
-
console.error('❌ Failed to establish secure tunnel.');
|
|
42
|
+
const tunnelResult = await tunnel.start(actualPort);
|
|
43
|
+
if (!tunnelResult.url) {
|
|
44
|
+
console.error('❌ Failed to start Cloudflare Tunnel.');
|
|
51
45
|
process.exit(1);
|
|
52
46
|
}
|
|
53
|
-
console.log(
|
|
47
|
+
console.log('✅ Secure tunnel established');
|
|
54
48
|
// 3. Validate token and report public URL to central server
|
|
55
49
|
console.log('🔑 Validating session token...');
|
|
56
50
|
try {
|
|
@@ -60,7 +54,7 @@ program
|
|
|
60
54
|
'Content-Type': 'application/json'
|
|
61
55
|
},
|
|
62
56
|
body: JSON.stringify({
|
|
63
|
-
public_url:
|
|
57
|
+
public_url: tunnelResult.url
|
|
64
58
|
})
|
|
65
59
|
});
|
|
66
60
|
if (!res.ok) {
|
package/dist/tunnel.d.ts
CHANGED
package/dist/tunnel.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
export class CloudflareTunnel {
|
|
3
3
|
process = null;
|
|
4
|
-
async start(port
|
|
4
|
+
async start(port) {
|
|
5
5
|
return new Promise((resolve) => {
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
8
|
-
? ['tunnel', 'run', '--token', token]
|
|
9
|
-
: ['tunnel', '--url', `http://localhost:${port}`];
|
|
10
|
-
const proc = spawn('cloudflared', args, {
|
|
7
|
+
const proc = spawn('cloudflared', ['tunnel', '--url', `http://localhost:${port}`], {
|
|
11
8
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
12
9
|
});
|
|
13
10
|
this.process = proc;
|
|
14
|
-
if (token) {
|
|
15
|
-
// For named tunnels, resolve immediately after a short delay
|
|
16
|
-
setTimeout(() => {
|
|
17
|
-
resolve({ url: null, cleanup: () => this.cleanup() });
|
|
18
|
-
}, 2000);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
11
|
let output = '';
|
|
22
12
|
const timeout = setTimeout(() => {
|
|
23
13
|
resolve({ url: null, cleanup: () => this.cleanup() });
|