traforo 0.0.3 → 0.0.5

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/README CHANGED
@@ -30,7 +30,7 @@ Run a command and tunnel it:
30
30
 
31
31
  The tunnel URL will be:
32
32
 
33
- https://{tunnel-id}-tunnel.kimaki.xyz
33
+ https://{tunnel-id}-tunnel.traforo.dev
34
34
 
35
35
 
36
36
  OPTIONS
@@ -39,7 +39,8 @@ OPTIONS
39
39
  -p, --port <port> Local port to expose (required)
40
40
  -t, --tunnel-id [id] Tunnel ID (random if omitted)
41
41
  -h, --host [host] Local host (default: localhost)
42
- -s, --server [url] Custom tunnel server URL
42
+ -d, --domain [domain] Base domain (default: traforo.dev)
43
+ -s, --server [url] Custom tunnel server URL (overrides domain)
43
44
  --help Show help
44
45
  --version Show version
45
46
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { cac } from 'cac';
2
+ import { cac } from '@xmorse/cac';
3
3
  import { CLI_NAME, runTunnel, parseCommandFromArgv } from './run-tunnel.js';
4
4
  const { command, argv } = parseCommandFromArgv(process.argv);
5
5
  const cli = cac(CLI_NAME);
@@ -8,11 +8,13 @@ cli
8
8
  .option('-p, --port <port>', 'Local port to expose (required)')
9
9
  .option('-t, --tunnel-id [id]', 'Tunnel ID (random if omitted)')
10
10
  .option('-h, --host [host]', 'Local host (default: localhost)')
11
- .option('-s, --server [url]', 'Tunnel server URL')
11
+ .option('-d, --domain [domain]', 'Base domain (default: kimaki.xyz)')
12
+ .option('-s, --server [url]', 'Tunnel server URL (overrides domain)')
12
13
  .example(`${CLI_NAME} -p 3000`)
13
14
  .example(`${CLI_NAME} -p 3000 -- next start`)
14
15
  .example(`${CLI_NAME} -p 3000 -- pnpm dev`)
15
16
  .example(`${CLI_NAME} -p 5173 -t my-app -- vite`)
17
+ .example(`${CLI_NAME} -p 3000 -d traforo.dev -- pnpm dev`)
16
18
  .action(async (options) => {
17
19
  if (!options.port) {
18
20
  console.error('Error: --port is required');
@@ -28,6 +30,7 @@ cli
28
30
  port,
29
31
  tunnelId: options.tunnelId,
30
32
  localHost: options.host,
33
+ baseDomain: options.domain,
31
34
  serverUrl: options.server,
32
35
  command: command.length > 0 ? command : undefined,
33
36
  });
package/dist/client.d.ts CHANGED
@@ -6,7 +6,9 @@ type TunnelClientOptions = {
6
6
  localPort: number;
7
7
  /** Local host (default: localhost) */
8
8
  localHost?: string;
9
- /** Tunnel server URL (default: wss://{tunnelId}-tunnel.kimaki.xyz) */
9
+ /** Base domain for tunnel URLs (default: kimaki.xyz) */
10
+ baseDomain?: string;
11
+ /** Tunnel server URL (default: wss://{tunnelId}-tunnel.{baseDomain}) */
10
12
  serverUrl?: string;
11
13
  /** Tunnel ID */
12
14
  tunnelId: string;
package/dist/client.js CHANGED
@@ -8,9 +8,11 @@ export class TunnelClient {
8
8
  localWsConnections = new Map();
9
9
  closed = false;
10
10
  constructor(options) {
11
+ const baseDomain = options.baseDomain || 'traforo.dev';
11
12
  this.options = {
12
13
  localHost: 'localhost',
13
- serverUrl: `wss://${options.tunnelId}-tunnel.kimaki.xyz`,
14
+ baseDomain,
15
+ serverUrl: `wss://${options.tunnelId}-tunnel.${baseDomain}`,
14
16
  localHttps: false,
15
17
  autoReconnect: true,
16
18
  reconnectDelay: 3000,
@@ -18,18 +20,18 @@ export class TunnelClient {
18
20
  };
19
21
  }
20
22
  get url() {
21
- return `https://${this.options.tunnelId}-tunnel.kimaki.xyz`;
23
+ return `https://${this.options.tunnelId}-tunnel.${this.options.baseDomain}`;
22
24
  }
23
25
  async connect() {
24
26
  if (this.closed) {
25
27
  throw new Error('Client is closed');
26
28
  }
27
29
  const wsUrl = `${this.options.serverUrl}/traforo-upstream?_tunnelId=${this.options.tunnelId}`;
28
- console.log(`Connecting to ${wsUrl}...`);
30
+ // console.log(`Connecting to ${wsUrl}...`)
29
31
  return new Promise((resolve, reject) => {
30
32
  this.ws = new WebSocket(wsUrl);
31
33
  this.ws.on('open', () => {
32
- console.log(`Connected! Tunnel URL: ${this.url}`);
34
+ console.log(`Connected with Traforo! Tunnel URL: ${this.url}`);
33
35
  resolve();
34
36
  });
35
37
  this.ws.on('error', (err) => {
@@ -3,6 +3,7 @@ export type RunTunnelOptions = {
3
3
  port: number;
4
4
  tunnelId?: string;
5
5
  localHost?: string;
6
+ baseDomain?: string;
6
7
  serverUrl?: string;
7
8
  command?: string[];
8
9
  };
@@ -93,6 +93,7 @@ export async function runTunnel(options) {
93
93
  localPort: port,
94
94
  tunnelId,
95
95
  localHost,
96
+ ...(options.baseDomain && { baseDomain: options.baseDomain }),
96
97
  ...(options.serverUrl && { serverUrl: options.serverUrl }),
97
98
  });
98
99
  // Handle shutdown
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "traforo",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "HTTP tunnel via Cloudflare Durable Objects and WebSockets",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "repository": "https://github.com/remorses/kimaki",
7
+ "repository": "https://github.com/remorses/traforo",
8
8
  "engines": {
9
9
  "node": ">=18.0.0"
10
10
  },
@@ -38,7 +38,8 @@
38
38
  "wrangler": "^4.24.3"
39
39
  },
40
40
  "dependencies": {
41
- "cac": "^6.7.14",
41
+ "@xmorse/cac": "^6.0.7",
42
+ "string-dedent": "^3.0.2",
42
43
  "ws": "^8.19.0"
43
44
  },
44
45
  "scripts": {