@maxoperf/tunnel 0.1.0

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.md ADDED
@@ -0,0 +1,67 @@
1
+ # @maxoperf/tunnel
2
+
3
+ Expose a local port on a public, TLS-terminated `https://tunnel-<name>.maxoperf.com`
4
+ URL — MaxoPerf reverse tunnels, like ngrok but free.
5
+
6
+ ## Quick start
7
+
8
+ Zero signup — a guest tunnel with a stable auto-generated subdomain:
9
+
10
+ ```bash
11
+ npx @maxoperf/tunnel http 3000
12
+ ```
13
+
14
+ ```
15
+ ✔ guest tunnel online https://tunnel-swift-otter-7f3.maxoperf.com → http://127.0.0.1:3000
16
+ ↑ sign up for a named subdomain, more tunnels, access controls & capture: https://maxoperf.com/signup
17
+ 12:00:01 GET /api/users 200 12ms 1.2kB
18
+ ```
19
+
20
+ The guest identity is saved to `~/.maxoperf/tunnel.json` (mode `0600`), so every
21
+ later run reuses **the same URL**.
22
+
23
+ Authenticated (named) tunnel — create one in the console / API / MCP, then run it
24
+ with its one-time client token:
25
+
26
+ ```bash
27
+ npx @maxoperf/tunnel http 3000 --token mptt_… --name myapp
28
+ ```
29
+
30
+ ```
31
+ ✔ tunnel online https://tunnel-myapp.maxoperf.com → http://127.0.0.1:3000
32
+ ```
33
+
34
+ ## Options
35
+
36
+ | Flag / env | Purpose |
37
+ | --- | --- |
38
+ | `--token <mptt_…>` / `MAXOPERF_TUNNEL_TOKEN` | Tunnel client token. Omit for a guest tunnel. |
39
+ | `--name <name>` | Preferred subdomain label (informational — the URL is set server-side). |
40
+ | `--server <host:port>` / `MAXOPERF_TUNNEL_SERVER` | gRPC gateway (default `app.maxoperf.com:443`, TLS auto-detected). |
41
+ | `--api-url <url>` / `MAXOPERF_API_URL` | Platform API origin for guest tunnels (default `https://app.maxoperf.com`). |
42
+ | `--local-host <host>` | Local host to forward to (default `127.0.0.1`). |
43
+
44
+ Credential resolution order: `--token` → `MAXOPERF_TUNNEL_TOKEN` → config-file
45
+ account token → config-file guest token → mint a new guest.
46
+
47
+ WebSocket and SSE pass straight through. `Ctrl-C` closes the session cleanly so
48
+ the tunnel flips offline immediately. The client reconnects automatically with
49
+ backoff if the connection drops. It never prints or logs your token.
50
+
51
+ ## Programmatic use
52
+
53
+ ```ts
54
+ import { runTunnelClient } from '@maxoperf/tunnel';
55
+
56
+ const tunnel = runTunnelClient({
57
+ port: 3000,
58
+ server: 'app.maxoperf.com:443',
59
+ token: 'mptt_…', // omit for a guest tunnel
60
+ onEvent: (e) => console.log(e),
61
+ });
62
+
63
+ const url = await tunnel.url; // public URL, once online
64
+ // … later …
65
+ await tunnel.close(); // graceful shutdown
66
+ const exitCode = await tunnel.done;
67
+ ```