asyx 0.2.4 → 0.3.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 +112 -237
- package/package.json +10 -3
- package/src/commands/setup.js +23 -2
- package/src/commands/tunnel.js +1215 -40
- package/src/commands/validate-target-host.js +68 -0
- package/src/lib/device.js +26 -1
- package/src/lib/jwt-verifier.js +260 -0
- package/src/mqtt/events/handlers.js +80 -13
- package/src/mqtt/events/index.js +203 -0
- package/src/state/assignment.js +139 -35
- package/src/state/instance-registry.js +130 -0
- package/src/tunnel/http-tunnel.js +20 -15
- package/src/tunnel/udp-tunnel.js +648 -0
- package/src/udp-v1/framing.js +203 -0
package/README.md
CHANGED
|
@@ -1,276 +1,151 @@
|
|
|
1
1
|
# Asyx CLI
|
|
2
2
|
|
|
3
|
-
Secure tunnels
|
|
3
|
+
Secure, device-bound tunnels for HTTP, TCP, and UDP. The CLI handles device auth, JWT refresh, and resilient control-plane connectivity so you can expose local services without managing relay infrastructure.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> Beta access is invitation-only while we scale capacity.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
+
## 0. Install & Update
|
|
9
10
|
```bash
|
|
10
|
-
npm install -g asyx
|
|
11
|
+
npm install -g asyx # install
|
|
12
|
+
npm update -g asyx # upgrade
|
|
13
|
+
npm uninstall -g asyx # remove
|
|
11
14
|
```
|
|
15
|
+
- Node.js 18.17+ recommended. Prefer `npx asyx <cmd>` if you cannot install globally.
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
- Installs the `asyx` binary globally so it is available in your `PATH`.
|
|
15
|
-
- Prefer `npx asyx <cmd>` if you cannot install globally.
|
|
16
|
-
|
|
17
|
-
### Updating / Removing
|
|
17
|
+
---
|
|
18
18
|
|
|
19
|
+
## 1. Set up the device (once per host)
|
|
19
20
|
```bash
|
|
20
|
-
|
|
21
|
-
npm uninstall -g asyx
|
|
21
|
+
asyx setup
|
|
22
22
|
```
|
|
23
|
+
- Opens a browser for passwordless approval and lets you choose `<subdomain>.tunnel.asyx.ai`.
|
|
24
|
+
- Provisions a device certificate and client ID under `~/.asyx/certs/<clientId>/`.
|
|
25
|
+
- Hardware fingerprint is hashed locally; raw attributes never leave the device.
|
|
26
|
+
- Certificates are single-device; run `asyx setup` on each host.
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
1. **Authorize the client**
|
|
28
|
-
```bash
|
|
29
|
-
asyx setup
|
|
30
|
-
```
|
|
31
|
-
- **Opens your default browser** to complete device authorization—you'll need to approve the connection in your browser.
|
|
32
|
-
- Completes CLI registration on the Asyx website after passwordless magic-link authentication.
|
|
33
|
-
- Lets you pick a personal `<subdomain>.tunnel.asyx.ai` address (fixed for now; choose carefully) that is covered by the Asyx-managed wildcard TLS certificate.
|
|
34
|
-
- Provisions an Asyx-issued client certificate and unique client identifier (stored under `~/.asyx/certs/<clientId>/`).
|
|
35
|
-
- 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.
|
|
36
|
-
- Certificates are single-device: copying them to another machine fails policy checks, so re-run `asyx setup` on every host.
|
|
37
|
-
|
|
38
|
-
### 🎮 Sharing Your Minecraft Server (Super Easy!)
|
|
28
|
+
---
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
## 2. Open tunnels
|
|
31
|
+
All tunnels are loopback-only. The CLI never binds your app port; it forwards to your existing listener. Public port comes from your tenant’s 10-port block (auto-assigned unless you request one with `--external-port`).
|
|
41
32
|
|
|
33
|
+
### HTTP
|
|
42
34
|
```bash
|
|
43
|
-
|
|
44
|
-
# 2. Run this:
|
|
45
|
-
asyx tunnel --minecraft
|
|
46
|
-
|
|
47
|
-
# 3. Share the hostname shown (e.g., example.tunnel.asyx.ai)
|
|
48
|
-
# Your friends connect using just the hostname—no port needed!
|
|
35
|
+
asyx tunnel --http --port 3000
|
|
49
36
|
```
|
|
37
|
+
- Forwards HTTP traffic to `127.0.0.1:3000`.
|
|
38
|
+
- Forward-only proxy; automatic JWT refresh.
|
|
50
39
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
2. **Open a tunnel**
|
|
54
|
-
|
|
55
|
-
**HTTP tunnel:**
|
|
56
|
-
```bash
|
|
57
|
-
asyx tunnel --http --port 3000
|
|
58
|
-
```
|
|
59
|
-
- Creates a forward-only HTTP tunnel bound to your issued client ID.
|
|
60
|
-
- Automatically refreshes JWTs over the Asyx messaging pipeline and keeps the session alive while traffic is flowing.
|
|
61
|
-
|
|
62
|
-
**Minecraft tunnel (easiest way to share your server):**
|
|
63
|
-
```bash
|
|
64
|
-
asyx tunnel --minecraft
|
|
65
|
-
```
|
|
66
|
-
- **One command** to expose your local Minecraft server to the internet.
|
|
67
|
-
- Automatically configures port 25565 (override with `--port` if needed).
|
|
68
|
-
- Creates an SRV record so players can connect using just the hostname—**no port number needed**.
|
|
69
|
-
- **Example**: Run `asyx tunnel --minecraft`, then share `example.tunnel.asyx.ai` with your friends. They connect in Minecraft using just that hostname.
|
|
70
|
-
- Optional `--name` flag for a custom subdomain (e.g., `--name my-server` → `my-server.example.tunnel.asyx.ai`).
|
|
71
|
-
- That's it! No firewall rules, no port forwarding, no DNS configuration.
|
|
72
|
-
|
|
73
|
-
**TCP tunnel (for other services):**
|
|
74
|
-
```bash
|
|
75
|
-
asyx tunnel --tcp --port <localPort> [--name <service>]
|
|
76
|
-
```
|
|
77
|
-
- Creates a TCP tunnel for raw TCP connections (e.g., game servers, databases, SSH).
|
|
78
|
-
- `--port`: Local target port on `127.0.0.1` (e.g., `25565` for Minecraft on `127.0.0.1:25565`).
|
|
79
|
-
- `--name`: Optional service name; if provided, creates a CNAME alias `<name>.<subdomain>.tunnel.asyx.ai`; otherwise only `host:port` form is used.
|
|
80
|
-
- The CLI prints the assignment: `fqdn:publicPort` (alias if `--name` provided, otherwise `host:port`).
|
|
81
|
-
- Uses Asyx binary framing over WebSocket (no user action needed; handled automatically).
|
|
82
|
-
- The relay URL in assignments uses `/tcp` endpoint (configured automatically).
|
|
83
|
-
|
|
84
|
-
3. **Clean up (optional)**
|
|
85
|
-
```bash
|
|
86
|
-
rm -rf ~/.asyx/certs/<clientId>
|
|
87
|
-
```
|
|
88
|
-
Removes local device material; re-run `asyx setup` afterwards to restore access.
|
|
89
|
-
|
|
90
|
-
## What's New in v0.2.3
|
|
91
|
-
|
|
92
|
-
- **Minecraft tunnels made easy**: New `--minecraft` verb—just run `asyx tunnel --minecraft` and share your server instantly. No port numbers, no configuration, no hassle.
|
|
93
|
-
- **SRV record support**: Minecraft clients automatically discover the correct port via DNS SRV records—players just enter the hostname.
|
|
94
|
-
- **TCP tunnel support**: Expose raw TCP services (game servers, databases, SSH) with `asyx tunnel --tcp --port <n>`
|
|
95
|
-
- **Asyx binary framing**: Automatic protocol handling for multi-stream TCP tunneling
|
|
96
|
-
- **Coordinator-based assignments**: TCP tunnels use the same assignment system as HTTP tunnels; no additional configuration needed
|
|
97
|
-
- **Service aliases**: Optional `--name` flag for friendly service names (when aliases are provisioned)
|
|
98
|
-
|
|
99
|
-
## Why Asyx
|
|
100
|
-
|
|
101
|
-
- **Device-bound identity** – Every `setup` run issues a unique certificate and uuLID. Asyx backend policies reject duplicate usage, preventing credential theft or relocation.
|
|
102
|
-
- **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.
|
|
103
|
-
- **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.
|
|
104
|
-
- **Zero manual relay config** – Asyx backend assignments route traffic for you; no hostnames, firewall poking, or manual DNS updates required.
|
|
105
|
-
- **Multi-protocol support** – HTTP and TCP tunnels share the same assignment system; choose the protocol that fits your service.
|
|
106
|
-
- **Secure proxy architecture** – Forward-only mode avoids local port binding conflicts and keeps user services isolated from the CLI process.
|
|
107
|
-
- **Observability-first UX** – Friendly error messages, deterministic exit codes, and optional debug traces make support straightforward.
|
|
108
|
-
- **Future-ready auth** – Today's magic-link flow will extend to tunnel sharing with Asyx Quickpass, delivering passwordless approvals for downstream users.
|
|
109
|
-
|
|
110
|
-
## Command Reference
|
|
111
|
-
|
|
40
|
+
### TCP
|
|
112
41
|
```bash
|
|
113
|
-
asyx
|
|
114
|
-
asyx tunnel --http --port <n> # Start HTTP tunnel for local port <n>
|
|
115
|
-
asyx tunnel --minecraft # Start Minecraft tunnel (easiest way!)
|
|
116
|
-
asyx tunnel --minecraft --name <svc> # Start Minecraft tunnel with custom name
|
|
117
|
-
asyx tunnel --tcp --port <n> [--name <service>] # Start TCP tunnel for local port <n>
|
|
42
|
+
asyx tunnel --tcp --port <targetPort> [--name <alias>] [--external-port <publicPort>]
|
|
118
43
|
```
|
|
44
|
+
- For raw TCP services (databases, SSH, games).
|
|
45
|
+
- `--port`: local app port on loopback.
|
|
46
|
+
- `--name` (optional): CNAME alias `<name>.<subdomain>.tunnel.asyx.ai`; otherwise use `fqdn:publicPort`.
|
|
47
|
+
- `--external-port` (optional): must be inside your tenant block; otherwise rejected.
|
|
48
|
+
- Uses tcpWs transport; guests connect with native TCP on the public port.
|
|
119
49
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
Control CLI verbosity with the `ASYX_LOG_LEVEL` environment variable:
|
|
125
|
-
|
|
50
|
+
### UDP
|
|
51
|
+
```bash
|
|
52
|
+
asyx tunnel --udp --port <targetPort> [--external-port <publicPort>]
|
|
126
53
|
```
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
54
|
+
- For UDP services (games, realtime apps).
|
|
55
|
+
- `--port`: local app port on loopback.
|
|
56
|
+
- `--external-port`: optional request within your tenant block.
|
|
57
|
+
- CLI uses an **ephemeral** socket; it never claims your service port. Forwards to your app.
|
|
58
|
+
- Loopback-only is enforced by CLI and relay.
|
|
59
|
+
- Uses udpWs transport; guests send native UDP to the public port.
|
|
60
|
+
|
|
61
|
+
### Minecraft (shortcut)
|
|
62
|
+
```bash
|
|
63
|
+
asyx tunnel --minecraft [--port <localPort>] [--name <alias>]
|
|
131
64
|
```
|
|
65
|
+
- One command to share a Minecraft server (defaults to 25565).
|
|
66
|
+
- SRV record created so players use the hostname only (no port needed).
|
|
132
67
|
|
|
133
|
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
|
|
137
|
-
## Heartbeat Behavior
|
|
138
|
-
|
|
139
|
-
The CLI manages heartbeats automatically to keep idle sessions stable without user tuning.
|
|
140
|
-
|
|
141
|
-
- Heartbeats pause whenever HTTP traffic is flowing and resume only when idle.
|
|
142
|
-
- Intervals are controlled server-side to prevent abuse and excessive reconnects.
|
|
143
|
-
- Heartbeat stops when the tunnel exits or errors.
|
|
144
|
-
- Use `ASYX_DEBUG=1` if you need to trace heartbeat activity for support purposes.
|
|
145
|
-
|
|
146
|
-
## Security Groups
|
|
68
|
+
After a tunnel opens, the CLI prints:
|
|
69
|
+
- `fqdn` and `fqdn:publicPort` for guests.
|
|
70
|
+
- Target shown as `tcp://127.0.0.1:<port>` or `udp://127.0.0.1:<port>` so you know your app keeps the port.
|
|
147
71
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
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.
|
|
151
|
-
|
|
152
|
-
### TCP Tunnels
|
|
153
|
-
|
|
154
|
-
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:
|
|
155
|
-
|
|
156
|
-
**Minecraft Tunnels (v0.2.3+):**
|
|
157
|
-
|
|
158
|
-
The `--minecraft` verb makes sharing your Minecraft server incredibly simple:
|
|
72
|
+
---
|
|
159
73
|
|
|
74
|
+
## 3. Command quick reference
|
|
160
75
|
```bash
|
|
161
|
-
#
|
|
162
|
-
asyx tunnel --
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
76
|
+
asyx setup # Provision device cert & client ID
|
|
77
|
+
asyx tunnel --http --port <n> # HTTP tunnel
|
|
78
|
+
asyx tunnel --tcp --port <n> [--name <alias>] [--external-port <p>]
|
|
79
|
+
asyx tunnel --udp --port <n> [--external-port <p>]
|
|
80
|
+
asyx tunnel --minecraft [--port <n>] [--name <alias>]
|
|
166
81
|
```
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
**
|
|
82
|
+
- Targets are loopback-only; non-loopback hosts are rejected.
|
|
83
|
+
- `--external-port` must be inside your assigned block; omit to auto-assign blockStart.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 4. Protocol details (high level)
|
|
88
|
+
- **Transport**: TCP/UDP tunnels use WebSocket to the relay (tcpWs/udpWs); guests see native TCP/UDP on the public port.
|
|
89
|
+
- **Assignments**: Coordinator returns `fqdn`, `publicPort`, `relayUrl`, and JWT. CLI validates JWT via JWKS before connecting.
|
|
90
|
+
- **Aliases & SRV**: TCP can create CNAME aliases via `--name`; Minecraft auto-provisions SRV so players use the hostname only.
|
|
91
|
+
- **Loopback-only**: CLI validates; relay enforces at admission/binding. Targets must resolve to loopback.
|
|
92
|
+
- **Owner-only auth**: HTTP can use Quickpass groups; TCP/UDP are owner-authenticated via JWT (no per-guest auth in v4.1).
|
|
93
|
+
|
|
94
|
+
### Quickpass (HTTP guest access control)
|
|
95
|
+
- Passwordless guest access: invite guests into a **security group** and run `asyx tunnel --http --port <n> --secgroup <slug>`.
|
|
96
|
+
- Relay-enforced: guests must present a valid Quickpass cookie; unauthorized requests are rejected at the relay (no app changes).
|
|
97
|
+
- Perfect for sharing dashboards/dev tools without opening them publicly; no VPN, no basic auth.
|
|
98
|
+
- Zero extra infra: no DNS edits, no reverse proxies; the relay does the policy check.
|
|
99
|
+
- Coming extensions: the same flow will back future sharing for TCP/UDP when per-guest auth is added.
|
|
100
|
+
- TCP/UDP today remain owner-only via JWT (no per-guest auth in v4.1).
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 5. Logging
|
|
105
|
+
Set verbosity with `ASYX_LOG_LEVEL` (`error|warn|info|debug`, default `info`):
|
|
174
106
|
```bash
|
|
175
|
-
asyx tunnel --
|
|
176
|
-
# Share: my-server.example.tunnel.asyx.ai
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
**Technical details:**
|
|
180
|
-
- **SRV-aware clients (Minecraft)**: Use the hostname directly (with or without `--name`). The Minecraft launcher automatically discovers the port via the SRV record.
|
|
181
|
-
- **Non-SRV-aware clients**: Use the `hostname:port` format (e.g., `example.tunnel.asyx.ai:10000`).
|
|
182
|
-
- **SRV record format**: `_minecraft._tcp.<host>` → target `<fqdn>`, port `<publicPort>`
|
|
183
|
-
- With `--name`: `_minecraft._tcp.<name>.<subdomain>.tunnel.asyx.ai`
|
|
184
|
-
- Without `--name`: `_minecraft._tcp.<subdomain>.tunnel.asyx.ai`
|
|
185
|
-
- **TTL**: 60 seconds (low TTL for agility)
|
|
186
|
-
- **Best-effort design**: SRV provisioning failures don't block tunnel creation; the tunnel still works with `hostname:port` format.
|
|
187
|
-
- **No default alias**: CNAME aliases are only created if you provide `--name`.
|
|
188
|
-
- **Connection limits**: Maximum concurrent connections per lease
|
|
189
|
-
- **Rate limits**: Bandwidth and connection rate throttling
|
|
190
|
-
- **Idle timeouts**: Automatic connection closure after inactivity
|
|
191
|
-
|
|
192
|
-
Future TCP guard/securing features are planned but out of scope for v4.1.
|
|
193
|
-
|
|
194
|
-
## Troubleshooting
|
|
195
|
-
|
|
196
|
-
### TCP Tunnel Issues
|
|
197
|
-
|
|
198
|
-
**Alias unavailable:**
|
|
199
|
-
- If the Coordinator returns a warning that an alias is unavailable, use the `fqdn:publicPort` format shown in the CLI output.
|
|
200
|
-
- This is normal during validation phases; `host:port` always works.
|
|
201
|
-
|
|
202
|
-
**Local service not accessible:**
|
|
203
|
-
- Ensure your local service is running on `127.0.0.1:<port>` on the CLI machine.
|
|
204
|
-
- The tunnel forwards connections from the relay to `127.0.0.1:<localPort>`.
|
|
205
|
-
|
|
206
|
-
**Connection timeouts:**
|
|
207
|
-
- If external connections to `fqdn:publicPort` time out, check firewall/port exposure at the relay.
|
|
208
|
-
- The relay must have the `publicPort` open in its security group/firewall rules.
|
|
209
|
-
- Verify the relay is operational and the TCP tunnel is active (check CLI logs).
|
|
210
|
-
|
|
211
|
-
### MQTT Connection Issues (Windows)
|
|
212
|
-
|
|
213
|
-
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.
|
|
214
|
-
|
|
215
|
-
**Solution**: Rerun `asyx setup` to regenerate keys in the correct format. The CLI will automatically convert existing PKCS#8 keys to PKCS#1 format (required for Windows TLS compatibility).
|
|
216
|
-
|
|
217
|
-
**Manual workaround** (if you cannot rerun setup):
|
|
218
|
-
```javascript
|
|
219
|
-
const crypto = require('crypto');
|
|
220
|
-
const fs = require('fs');
|
|
221
|
-
const keyPath = '~/.asyx/certs/<clientId>/private.pem.key';
|
|
222
|
-
|
|
223
|
-
const keyPem = fs.readFileSync(keyPath, 'utf8');
|
|
224
|
-
const privateKey = crypto.createPrivateKey({ key: keyPem, format: 'pem' });
|
|
225
|
-
const pkcs1Pem = privateKey.export({ type: 'pkcs1', format: 'pem' });
|
|
226
|
-
fs.writeFileSync(keyPath, pkcs1Pem, { mode: 0o600 });
|
|
107
|
+
ASYX_LOG_LEVEL=debug asyx tunnel --tcp --port 25565
|
|
227
108
|
```
|
|
109
|
+
Structured logs go to stdout/stderr; user banners remain.
|
|
228
110
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
## Security
|
|
232
|
-
|
|
233
|
-
Asyx tunnels are designed with security-first principles to protect both your local services and the tunnel infrastructure. Every active tunnel operates with **per-tunnel cryptographic isolation**, short-lived JWT credentials, and in-band credential refresh to achieve zero-downtime, zero-trust operation.
|
|
234
|
-
|
|
235
|
-
### Zero Public Exposure
|
|
236
|
-
- **Local services remain private**: Your services never expose ports directly to the internet. All traffic flows through Asyx's cloud-managed relay infrastructure with TLS encryption end-to-end.
|
|
237
|
-
- **No manual firewall rules**: The tunnel architecture eliminates the need to open ports or configure NAT, reducing attack surface.
|
|
111
|
+
---
|
|
238
112
|
|
|
239
|
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
113
|
+
## 6. Behavior notes
|
|
114
|
+
- Short-lived JWTs with in-band refresh; tunnels stay up without reconnecting.
|
|
115
|
+
- MQTT/JWT control plane is shared across HTTP/TCP/UDP.
|
|
116
|
+
- CLI never binds your app port (TCP/UDP); it forwards to it.
|
|
117
|
+
- Loopback-only enforcement at both CLI and relay.
|
|
118
|
+
- Idle/heartbeat handled automatically; no tuning needed.
|
|
243
119
|
|
|
244
|
-
|
|
245
|
-
- **Unique per-device credentials**: Each `asyx setup` run provisions a unique device certificate and client identifier. Certificates cannot be copied or reused on other machines—policy checks reject duplicate usage.
|
|
246
|
-
- **Hardware attestation without PII**: The CLI derives a hashed hardware fingerprint locally using safe, non-sensitive attributes. Raw hardware data never leaves your device; only a SHA-256 hash (with public salt) is shared for device verification.
|
|
247
|
-
- **Web-based pairing**: CLI installation and pairing occur over HTTPS, binding user identity and device fingerprint to tenant ownership.
|
|
120
|
+
---
|
|
248
121
|
|
|
249
|
-
|
|
250
|
-
- **
|
|
251
|
-
- **
|
|
252
|
-
- **
|
|
253
|
-
- **
|
|
122
|
+
## 7. Why Asyx
|
|
123
|
+
- **Device-bound identity**: Each `setup` issues a unique cert + uuLID per host; backend rejects duplicates to prevent credential reuse.
|
|
124
|
+
- **Hardware attestation without PII**: Fingerprint is hashed locally from safe fields; raw hardware data never leaves the device.
|
|
125
|
+
- **Resilient control plane**: In-band JWT refresh, bounded reconnects, and structured logs (`ASYX_LOG_LEVEL`, `ASYX_DEBUG`) keep long sessions stable.
|
|
126
|
+
- **Zero manual relay config**: Assignments route traffic for you—no DNS edits, firewall poking, or relay setup.
|
|
127
|
+
- **Multi-protocol, one system**: HTTP, TCP, and UDP share the same assignment/JWT/MQTT fabric; pick the protocol that fits your service.
|
|
128
|
+
- **Secure proxy architecture**: Forward-only; avoids local port conflicts and isolates your app from the CLI process.
|
|
129
|
+
- **Observability-first UX**: Clear errors, deterministic exits, optional debug traces.
|
|
130
|
+
- **Future-ready auth**: Today’s magic-link flow extends to sharing via Asyx Quickpass (passwordless downstream approvals).
|
|
254
131
|
|
|
255
|
-
|
|
256
|
-
- **Cryptographic presence monitoring**: Only active relays can receive new assignments, preventing stale routing and unauthorized access.
|
|
257
|
-
- **Event-driven orchestration**: Verifiable routing for DNS assignment, relay control, and session lifecycle via secure cloud events.
|
|
258
|
-
- **Session-level audit trail**: Token issuance (JTI), timestamps, and validation context are logged for complete traceability.
|
|
259
|
-
- **Dynamic access control**: Tunnels can be reassigned or closed in real time based on usage patterns or detected anomalies.
|
|
132
|
+
---
|
|
260
133
|
|
|
261
|
-
|
|
262
|
-
- **
|
|
263
|
-
- **
|
|
264
|
-
- **
|
|
134
|
+
## 7. Troubleshooting (quick)
|
|
135
|
+
- **External port rejected**: ensure `--external-port` is inside your 10-port block.
|
|
136
|
+
- **Relay unavailable**: check network/WSS reachability; see logs for `...RELAY_UNAVAILABLE`.
|
|
137
|
+
- **No traffic to app**: confirm your service is listening on `127.0.0.1:<port>` and the tunnel is active; for UDP ensure the WS is still connected.
|
|
138
|
+
- **Windows MQTT handshake issues**: rerun `asyx setup` to regenerate keys (PKCS#1).
|
|
265
139
|
|
|
266
|
-
|
|
267
|
-
- **Open-source CLI**: The CLI client is open source, allowing independent audit and transparency, reinforcing trust and security posture.
|
|
268
|
-
- **Comprehensive telemetry**: Structured logs for authentication, policy, and reauth events form a complete trust graph for security analysis.
|
|
140
|
+
---
|
|
269
141
|
|
|
270
|
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
142
|
+
## 8. Security (brief)
|
|
143
|
+
- Device-bound identity per host; hardware fingerprint hashed locally.
|
|
144
|
+
- Mutual TLS to control plane; RS256 JWTs validated via JWKS.
|
|
145
|
+
- Forward-only proxy: your app remains isolated; no direct inbound to your host.
|
|
146
|
+
- Report issues: [security@asyx.ai](mailto:security@asyx.ai) (no public issues for security).
|
|
273
147
|
|
|
274
|
-
|
|
148
|
+
---
|
|
275
149
|
|
|
276
|
-
|
|
150
|
+
## 9. License
|
|
151
|
+
[Apache-2.0](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asyx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Asyx Command Line Interface",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"relay"
|
|
21
21
|
],
|
|
22
22
|
"bin": {
|
|
23
|
-
"asyx": "
|
|
23
|
+
"asyx": "bin/asyx.js"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=18.17"
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"src/commands/setup.js",
|
|
36
36
|
"src/commands/sts.js",
|
|
37
37
|
"src/commands/tunnel.js",
|
|
38
|
+
"src/commands/validate-target-host.js",
|
|
38
39
|
"src/control-plane/MqttControlPlaneClient.js",
|
|
39
40
|
"src/control-plane/MqttControlPlaneTransport.js",
|
|
40
41
|
"src/lib/.gitkeep",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"src/lib/device.js",
|
|
44
45
|
"src/lib/fingerprint.js",
|
|
45
46
|
"src/lib/ids.js",
|
|
47
|
+
"src/lib/jwt-verifier.js",
|
|
46
48
|
"src/lib/logger.js",
|
|
47
49
|
"src/lib/pairing.js",
|
|
48
50
|
"src/lib/shared-transport.js",
|
|
@@ -53,10 +55,13 @@
|
|
|
53
55
|
"src/mqtt/events/schemas.js",
|
|
54
56
|
"src/mqtt/ingress.js",
|
|
55
57
|
"src/state/assignment.js",
|
|
58
|
+
"src/state/instance-registry.js",
|
|
56
59
|
"src/tcp-v1/framing.js",
|
|
57
60
|
"src/tunnel/http-tunnel.js",
|
|
58
61
|
"src/tunnel/tcp-tunnel.js",
|
|
62
|
+
"src/tunnel/udp-tunnel.js",
|
|
59
63
|
"src/tunnel/ws-control.js",
|
|
64
|
+
"src/udp-v1/framing.js",
|
|
60
65
|
"LICENSE",
|
|
61
66
|
"README.md",
|
|
62
67
|
"SECURITY.md"
|
|
@@ -70,6 +75,7 @@
|
|
|
70
75
|
"asyx": "^0.1.3",
|
|
71
76
|
"chalk": "^5.3.0",
|
|
72
77
|
"hw-fingerprint": "^3.2.0",
|
|
78
|
+
"jose": "^5.10.0",
|
|
73
79
|
"node-fetch": "^3.3.2",
|
|
74
80
|
"open": "^9.1.0",
|
|
75
81
|
"ulid": "^2.4.0",
|
|
@@ -81,8 +87,9 @@
|
|
|
81
87
|
"postinstall": "node -e \"console.log('✅ asyx installed')\"",
|
|
82
88
|
"check": "node ./src/main.js --version",
|
|
83
89
|
"test": "NODE_OPTIONS=\"--experimental-vm-modules --max-old-space-size=8192\" jest --runInBand",
|
|
90
|
+
"test:ci": "NODE_OPTIONS=\"--experimental-vm-modules --max-old-space-size=8192\" jest --runInBand --forceExit",
|
|
84
91
|
"pack:verify": "node scripts/pack-verify.mjs",
|
|
85
|
-
"prepublishOnly": "npm test && npm run pack:verify",
|
|
92
|
+
"prepublishOnly": "npm run test:ci && npm run pack:verify",
|
|
86
93
|
"prepack": "node scripts/prepack.mjs",
|
|
87
94
|
"postpack": "node scripts/postpack.mjs"
|
|
88
95
|
},
|
package/src/commands/setup.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
6
|
import { ensureKeyAndCsr } from '../lib/csr.js';
|
|
7
|
-
import { loadOrCreateClientId } from '../lib/device.js';
|
|
7
|
+
import { loadOrCreateClientId, resetClientId } from '../lib/device.js';
|
|
8
8
|
|
|
9
9
|
const CONSOLE_URL = process.env.ASYX_CONSOLE_URL || 'https://www.asyx.ai/console/tunnel';
|
|
10
10
|
const STS_URL = process.env.ASYX_STS_URL || 'https://www.asyx.ai/www/sts';
|
|
@@ -19,7 +19,28 @@ function isJsonResponse(res) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export default async function cmdSetup(argv = process.argv.slice(2)) {
|
|
22
|
-
|
|
22
|
+
let clientId = loadOrCreateClientId();
|
|
23
|
+
|
|
24
|
+
// Check if there are existing certs that might belong to another user
|
|
25
|
+
// On Windows, multiple users can share the same home directory structure,
|
|
26
|
+
// so we automatically regenerate clientId if existing certs are found
|
|
27
|
+
const certsDir = path.join(os.homedir(), '.asyx', 'certs', clientId);
|
|
28
|
+
try {
|
|
29
|
+
const manifestPath = path.join(certsDir, 'manifest.json');
|
|
30
|
+
if (await fs.access(manifestPath).then(() => true).catch(() => false)) {
|
|
31
|
+
// Existing certs found - regenerate clientId to avoid subdomain mismatch
|
|
32
|
+
// This fixes the Windows multi-user issue where another user's clientId
|
|
33
|
+
// would be reused, causing subdomain mismatch
|
|
34
|
+
console.log(`⚠️ Found existing setup for clientId ${clientId}`);
|
|
35
|
+
console.log(`🔄 Regenerating clientId to ensure correct subdomain assignment...\n`);
|
|
36
|
+
resetClientId();
|
|
37
|
+
clientId = loadOrCreateClientId();
|
|
38
|
+
console.log(` New clientId: ${clientId}\n`);
|
|
39
|
+
}
|
|
40
|
+
} catch (e) {
|
|
41
|
+
// No existing certs, proceed normally
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
if (!/^cli_[A-F0-9]{12}$/.test(clientId)) {
|
|
24
45
|
console.error('Invalid clientId format (expected cli_[A-F0-9]{12})');
|
|
25
46
|
process.exit(2);
|