asyx 0.1.3 → 0.2.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/README.md CHANGED
@@ -34,13 +34,51 @@ npm uninstall -g asyx
34
34
  - Captures a minimal hardware fingerprint, hashes it locally (SHA-256 with public salt), and shares only the hash so the Asyx backend can verify the CLI is on the authorized device.
35
35
  - Certificates are single-device: copying them to another machine fails policy checks, so re-run `asyx setup` on every host.
36
36
 
37
+ ### 🎮 Sharing Your Minecraft Server (Super Easy!)
38
+
39
+ Want to share your Minecraft server with friends? It's literally one command:
40
+
41
+ ```bash
42
+ # 1. Start your local Minecraft server (on port 25565)
43
+ # 2. Run this:
44
+ asyx tunnel --minecraft
45
+
46
+ # 3. Share the hostname shown (e.g., example.tunnel.asyx.ai)
47
+ # Your friends connect using just the hostname—no port needed!
48
+ ```
49
+
50
+ That's it! No firewall configuration, no port forwarding, no DNS setup. The `--minecraft` verb handles everything automatically, including creating the SRV record that lets Minecraft clients discover the port automatically.
51
+
37
52
  2. **Open a tunnel**
53
+
54
+ **HTTP tunnel:**
38
55
  ```bash
39
56
  asyx tunnel --http --port 3000
40
57
  ```
41
- - Creates a forward-only HTTP tunnel bound to your issued client ID.
42
- - Automatically refreshes JWTs over the Asyx messaging pipeline and keeps the session alive while traffic is flowing.
43
- - HTTP tunneling is the only supported protocol in this release; TCP access is planned for a future update.
58
+ - Creates a forward-only HTTP tunnel bound to your issued client ID.
59
+ - Automatically refreshes JWTs over the Asyx messaging pipeline and keeps the session alive while traffic is flowing.
60
+
61
+ **Minecraft tunnel (easiest way to share your server):**
62
+ ```bash
63
+ asyx tunnel --minecraft
64
+ ```
65
+ - **One command** to expose your local Minecraft server to the internet.
66
+ - Automatically configures port 25565 (override with `--port` if needed).
67
+ - Creates an SRV record so players can connect using just the hostname—**no port number needed**.
68
+ - **Example**: Run `asyx tunnel --minecraft`, then share `example.tunnel.asyx.ai` with your friends. They connect in Minecraft using just that hostname.
69
+ - Optional `--name` flag for a custom subdomain (e.g., `--name my-server` → `my-server.example.tunnel.asyx.ai`).
70
+ - That's it! No firewall rules, no port forwarding, no DNS configuration.
71
+
72
+ **TCP tunnel (for other services):**
73
+ ```bash
74
+ asyx tunnel --tcp --port <localPort> [--name <service>]
75
+ ```
76
+ - Creates a TCP tunnel for raw TCP connections (e.g., game servers, databases, SSH).
77
+ - `--port`: Local target port on `127.0.0.1` (e.g., `25565` for Minecraft on `127.0.0.1:25565`).
78
+ - `--name`: Optional service name; if provided, creates a CNAME alias `<name>.<subdomain>.tunnel.asyx.ai`; otherwise only `host:port` form is used.
79
+ - The CLI prints the assignment: `fqdn:publicPort` (alias if `--name` provided, otherwise `host:port`).
80
+ - Uses Asyx binary framing over WebSocket (no user action needed; handled automatically).
81
+ - The relay URL in assignments uses `/tcp` endpoint (configured automatically).
44
82
 
45
83
  3. **Clean up (optional)**
46
84
  ```bash
@@ -48,22 +86,34 @@ npm uninstall -g asyx
48
86
  ```
49
87
  Removes local device material; re-run `asyx setup` afterwards to restore access.
50
88
 
89
+ ## What's New in v0.2.1
90
+
91
+ - **Minecraft tunnels made easy**: New `--minecraft` verb—just run `asyx tunnel --minecraft` and share your server instantly. No port numbers, no configuration, no hassle.
92
+ - **SRV record support**: Minecraft clients automatically discover the correct port via DNS SRV records—players just enter the hostname.
93
+ - **TCP tunnel support**: Expose raw TCP services (game servers, databases, SSH) with `asyx tunnel --tcp --port <n>`
94
+ - **Asyx binary framing**: Automatic protocol handling for multi-stream TCP tunneling
95
+ - **Coordinator-based assignments**: TCP tunnels use the same assignment system as HTTP tunnels; no additional configuration needed
96
+ - **Service aliases**: Optional `--name` flag for friendly service names (when aliases are provisioned)
97
+
51
98
  ## Why Asyx
52
99
 
53
100
  - **Device-bound identity** – Every `setup` run issues a unique certificate and uuLID. Asyx backend policies reject duplicate usage, preventing credential theft or relocation.
54
101
  - **Hardware attestation without PII** – The CLI derives a hashed hardware fingerprint locally using the safe `hw-fingerprint` fields; raw hardware attributes never leave the device.
55
102
  - **Resilient control plane** – Automatic JWT refresh via the background messaging queue, bounded reconnects, and observable logging (`ASYX_DEBUG=1`) keep tunnels stable during long soaks.
56
103
  - **Zero manual relay config** – Asyx backend assignments route traffic for you; no hostnames, firewall poking, or manual DNS updates required.
57
- - **Secure HTTP proxy** – Forward-only mode avoids local port binding conflicts and keeps user services isolated from the CLI process.
104
+ - **Multi-protocol support** – HTTP and TCP tunnels share the same assignment system; choose the protocol that fits your service.
105
+ - **Secure proxy architecture** – Forward-only mode avoids local port binding conflicts and keeps user services isolated from the CLI process.
58
106
  - **Observability-first UX** – Friendly error messages, deterministic exit codes, and optional debug traces make support straightforward.
59
- - **Future-ready auth** – Today’s magic-link flow will extend to tunnel sharing with Asyx Quickpass, delivering passwordless approvals for downstream users.
107
+ - **Future-ready auth** – Today's magic-link flow will extend to tunnel sharing with Asyx Quickpass, delivering passwordless approvals for downstream users.
60
108
 
61
109
  ## Command Reference
62
110
 
63
111
  ```bash
64
- asyx setup # Provision device certificate and client identity
65
- asyx tunnel --http --port <n> # Start HTTP tunnel for local port <n>
66
- asyx mqtt ... # Development MQTT utilities (NODE_ENV=dev)
112
+ asyx setup # Provision device certificate and client identity
113
+ asyx tunnel --http --port <n> # Start HTTP tunnel for local port <n>
114
+ asyx tunnel --minecraft # Start Minecraft tunnel (easiest way!)
115
+ asyx tunnel --minecraft --name <svc> # Start Minecraft tunnel with custom name
116
+ asyx tunnel --tcp --port <n> [--name <service>] # Start TCP tunnel for local port <n>
67
117
  ```
68
118
 
69
119
  Use `asyx help` or `asyx <command> --help` for details.
@@ -83,34 +133,6 @@ ASYX_LOG_LEVEL=debug asyx tunnel --http --port 3000 # full verbosity for engine
83
133
  - Structured logs (JSON) are emitted to stdout/stderr; by default, debug is suppressed.
84
134
  - User-facing banners remain visible regardless of log level.
85
135
 
86
- ## MQTT Connection Mode
87
-
88
- Control MQTT client ID generation and reconnect behavior with the `ASYX_MQTT_CLIENTID_MODE` environment variable:
89
-
90
- ```
91
- # Modes: legacy | unique
92
- # Default: unique
93
- ASYX_MQTT_CLIENTID_MODE=unique asyx tunnel --http --port 3000 # unique client IDs, clean sessions (default)
94
- ASYX_MQTT_CLIENTID_MODE=legacy asyx tunnel --http --port 3000 # persistent client IDs, mqtt.js auto-reconnect
95
- ```
96
-
97
- **`unique` mode (default):**
98
- - Generates a unique client ID for each CLI invocation using ULID suffixes (e.g., `baseClientId_01ABC...XYZ`)
99
- - Uses clean MQTT sessions (`clean: true`) so AWS IoT doesn't retain session state between reconnects
100
- - Implements manual reconnect loop with jittered exponential backoff (300ms → 600ms → 1.2s → max 5s)
101
- - Immediately reconnects on `ECONNRESET` errors
102
- - Prevents "identifier in use" errors from lingering AWS IoT sessions
103
-
104
- **`legacy` mode:**
105
- - Uses persistent client ID from device configuration
106
- - Uses persistent MQTT sessions (`clean: false`) allowing AWS IoT to retain session state
107
- - Relies on mqtt.js built-in auto-reconnect behavior
108
- - Useful for compatibility with older deployments or debugging
109
-
110
- **When to use each mode:**
111
- - Use `unique` (default) for production deployments to avoid lingering session issues
112
- - Use `legacy` only if you need to maintain session state across reconnects or are debugging specific MQTT behavior
113
-
114
136
  ## Heartbeat Behavior
115
137
 
116
138
  The CLI manages heartbeats automatically to keep idle sessions stable without user tuning.
@@ -120,8 +142,71 @@ The CLI manages heartbeats automatically to keep idle sessions stable without us
120
142
  - Heartbeat stops when the tunnel exits or errors.
121
143
  - Use `ASYX_DEBUG=1` if you need to trace heartbeat activity for support purposes.
122
144
 
145
+ ## Security Groups
146
+
147
+ ### HTTP Tunnels with `--secgroup`
148
+
149
+ HTTP tunnels support per-guest authentication via Asyx Quickpass security groups. When you specify `--secgroup <slug>`, the tunnel enforces access control so only authorized guests (with valid Quickpass cookies) can access your service.
150
+
151
+ ### TCP Tunnels
152
+
153
+ TCP tunnels in v4.1 do not enforce per-guest authentication. Access is owner-only via JWT validation; guests connecting to the public port are anonymous (no per-connection auth). TCP tunnels honor relay-level limits:
154
+
155
+ **Minecraft Tunnels (v0.2.1+):**
156
+
157
+ The `--minecraft` verb makes sharing your Minecraft server incredibly simple:
158
+
159
+ ```bash
160
+ # Start your server, then run:
161
+ asyx tunnel --minecraft
162
+
163
+ # Share the hostname with friends (no port needed!)
164
+ # Example: example.tunnel.asyx.ai
165
+ ```
166
+
167
+ **How it works:**
168
+ - Asyx automatically provisions an SRV record (`_minecraft._tcp.<host>`) that tells Minecraft clients which port to use
169
+ - Players enter just the hostname in the Minecraft launcher—no port number required
170
+ - The Minecraft launcher automatically discovers the port via the SRV record
171
+
172
+ **With a custom name:**
173
+ ```bash
174
+ asyx tunnel --minecraft --name my-server
175
+ # Share: my-server.example.tunnel.asyx.ai
176
+ ```
177
+
178
+ **Technical details:**
179
+ - **SRV-aware clients (Minecraft)**: Use the hostname directly (with or without `--name`). The Minecraft launcher automatically discovers the port via the SRV record.
180
+ - **Non-SRV-aware clients**: Use the `hostname:port` format (e.g., `example.tunnel.asyx.ai:10000`).
181
+ - **SRV record format**: `_minecraft._tcp.<host>` → target `<fqdn>`, port `<publicPort>`
182
+ - With `--name`: `_minecraft._tcp.<name>.<subdomain>.tunnel.asyx.ai`
183
+ - Without `--name`: `_minecraft._tcp.<subdomain>.tunnel.asyx.ai`
184
+ - **TTL**: 60 seconds (low TTL for agility)
185
+ - **Best-effort design**: SRV provisioning failures don't block tunnel creation; the tunnel still works with `hostname:port` format.
186
+ - **No default alias**: CNAME aliases are only created if you provide `--name`.
187
+ - **Connection limits**: Maximum concurrent connections per lease
188
+ - **Rate limits**: Bandwidth and connection rate throttling
189
+ - **Idle timeouts**: Automatic connection closure after inactivity
190
+
191
+ Future TCP guard/securing features are planned but out of scope for v4.1.
192
+
123
193
  ## Troubleshooting
124
194
 
195
+ ### TCP Tunnel Issues
196
+
197
+ **Alias unavailable:**
198
+ - If the Coordinator returns a warning that an alias is unavailable, use the `fqdn:publicPort` format shown in the CLI output.
199
+ - This is normal during validation phases; `host:port` always works.
200
+
201
+ **Local service not accessible:**
202
+ - Ensure your local service is running on `127.0.0.1:<port>` on the CLI machine.
203
+ - The tunnel forwards connections from the relay to `127.0.0.1:<localPort>`.
204
+
205
+ **Connection timeouts:**
206
+ - If external connections to `fqdn:publicPort` time out, check firewall/port exposure at the relay.
207
+ - The relay must have the `publicPort` open in its security group/firewall rules.
208
+ - Verify the relay is operational and the TCP tunnel is active (check CLI logs).
209
+
125
210
  ### MQTT Connection Issues (Windows)
126
211
 
127
212
  If you experience issues where the CLI connects but never receives `open_ack` messages (especially on Windows after running `asyx setup` without OpenSSL), the private key may be in PKCS#8 format which Node's TLS stack on Windows rejects.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asyx",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "Asyx Command Line Interface",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -53,7 +53,9 @@
53
53
  "src/mqtt/events/schemas.js",
54
54
  "src/mqtt/ingress.js",
55
55
  "src/state/assignment.js",
56
+ "src/tcp-v1/framing.js",
56
57
  "src/tunnel/http-tunnel.js",
58
+ "src/tunnel/tcp-tunnel.js",
57
59
  "src/tunnel/ws-control.js",
58
60
  "LICENSE",
59
61
  "README.md",
@@ -75,9 +77,10 @@
75
77
  "zod": "3.23.8"
76
78
  },
77
79
  "scripts": {
80
+ "build": "npm install",
78
81
  "postinstall": "node -e \"console.log('✅ asyx installed')\"",
79
82
  "check": "node ./src/main.js --version",
80
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --runInBand",
83
+ "test": "NODE_OPTIONS=\"--experimental-vm-modules --max-old-space-size=8192\" jest --runInBand",
81
84
  "pack:verify": "node scripts/pack-verify.mjs",
82
85
  "prepublishOnly": "npm test && npm run pack:verify",
83
86
  "prepack": "node scripts/prepack.mjs",