asyx 0.1.1 → 0.1.3
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 +50 -0
- package/package.json +6 -1
- package/src/commands/tunnel.js +603 -86
- package/src/control-plane/MqttControlPlaneClient.js +1145 -0
- package/src/control-plane/MqttControlPlaneTransport.js +150 -0
- package/src/lib/csr.js +32 -12
- package/src/lib/logger.js +8 -4
- package/src/mqtt/awaiter-map.js +92 -2
- package/src/mqtt/events/handlers.js +50 -9
- package/src/mqtt/ingress.js +11 -1
- package/src/state/assignment.js +1 -0
- package/src/tunnel/http-tunnel.js +219 -20
package/README.md
CHANGED
|
@@ -83,6 +83,34 @@ ASYX_LOG_LEVEL=debug asyx tunnel --http --port 3000 # full verbosity for engine
|
|
|
83
83
|
- Structured logs (JSON) are emitted to stdout/stderr; by default, debug is suppressed.
|
|
84
84
|
- User-facing banners remain visible regardless of log level.
|
|
85
85
|
|
|
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
|
+
|
|
86
114
|
## Heartbeat Behavior
|
|
87
115
|
|
|
88
116
|
The CLI manages heartbeats automatically to keep idle sessions stable without user tuning.
|
|
@@ -92,6 +120,28 @@ The CLI manages heartbeats automatically to keep idle sessions stable without us
|
|
|
92
120
|
- Heartbeat stops when the tunnel exits or errors.
|
|
93
121
|
- Use `ASYX_DEBUG=1` if you need to trace heartbeat activity for support purposes.
|
|
94
122
|
|
|
123
|
+
## Troubleshooting
|
|
124
|
+
|
|
125
|
+
### MQTT Connection Issues (Windows)
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
**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).
|
|
130
|
+
|
|
131
|
+
**Manual workaround** (if you cannot rerun setup):
|
|
132
|
+
```javascript
|
|
133
|
+
const crypto = require('crypto');
|
|
134
|
+
const fs = require('fs');
|
|
135
|
+
const keyPath = '~/.asyx/certs/<clientId>/private.pem.key';
|
|
136
|
+
|
|
137
|
+
const keyPem = fs.readFileSync(keyPath, 'utf8');
|
|
138
|
+
const privateKey = crypto.createPrivateKey({ key: keyPem, format: 'pem' });
|
|
139
|
+
const pkcs1Pem = privateKey.export({ type: 'pkcs1', format: 'pem' });
|
|
140
|
+
fs.writeFileSync(keyPath, pkcs1Pem, { mode: 0o600 });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This issue is fixed in version 0.1.2+ where keys are automatically generated in PKCS#1 format for Windows compatibility.
|
|
144
|
+
|
|
95
145
|
## Security
|
|
96
146
|
|
|
97
147
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asyx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Asyx Command Line Interface",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"src/commands/setup.js",
|
|
36
36
|
"src/commands/sts.js",
|
|
37
37
|
"src/commands/tunnel.js",
|
|
38
|
+
"src/control-plane/MqttControlPlaneClient.js",
|
|
39
|
+
"src/control-plane/MqttControlPlaneTransport.js",
|
|
38
40
|
"src/lib/.gitkeep",
|
|
39
41
|
"src/lib/certs.js",
|
|
40
42
|
"src/lib/csr.js",
|
|
@@ -58,14 +60,17 @@
|
|
|
58
60
|
"SECURITY.md"
|
|
59
61
|
],
|
|
60
62
|
"dependencies": {
|
|
63
|
+
"-": "^0.0.1",
|
|
61
64
|
"@asyx/mqtt-broker-aws": "^0.1.0",
|
|
62
65
|
"@asyx/mqtt-client": "^0.1.0",
|
|
63
66
|
"@peculiar/webcrypto": "^1.5.0",
|
|
64
67
|
"@peculiar/x509": "^1.14.0",
|
|
68
|
+
"asyx": "^0.1.3",
|
|
65
69
|
"chalk": "^5.3.0",
|
|
66
70
|
"hw-fingerprint": "^3.2.0",
|
|
67
71
|
"node-fetch": "^3.3.2",
|
|
68
72
|
"open": "^9.1.0",
|
|
73
|
+
"ulid": "^2.4.0",
|
|
69
74
|
"ws": "^8.14.2",
|
|
70
75
|
"zod": "3.23.8"
|
|
71
76
|
},
|