asyx 0.2.1 → 0.2.2

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
@@ -23,6 +23,7 @@ npm uninstall -g asyx
23
23
 
24
24
  ## Quick Start
25
25
 
26
+
26
27
  1. **Authorize the client**
27
28
  ```bash
28
29
  asyx setup
@@ -86,7 +87,7 @@ That's it! No firewall configuration, no port forwarding, no DNS setup. The `--m
86
87
  ```
87
88
  Removes local device material; re-run `asyx setup` afterwards to restore access.
88
89
 
89
- ## What's New in v0.2.1
90
+ ## What's New in v0.2.2
90
91
 
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.
92
93
  - **SRV record support**: Minecraft clients automatically discover the correct port via DNS SRV records—players just enter the hostname.
@@ -152,7 +153,7 @@ HTTP tunnels support per-guest authentication via Asyx Quickpass security groups
152
153
 
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:
154
155
 
155
- **Minecraft Tunnels (v0.2.1+):**
156
+ **Minecraft Tunnels (v0.2.2+):**
156
157
 
157
158
  The `--minecraft` verb makes sharing your Minecraft server incredibly simple:
158
159
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asyx",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Asyx Command Line Interface",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -957,7 +957,7 @@ async function httpTunnel(localPort, secGroupSlug) {
957
957
  }
958
958
  }
959
959
 
960
- async function connectToRelay(
960
+ export async function connectToRelay(
961
961
  assignment,
962
962
  deviceId,
963
963
  localPort,
@@ -1019,6 +1019,26 @@ async function connectToRelay(
1019
1019
  // TCP-S4: Skip refresh scheduling for TCP tunnels (refresh not implemented yet)
1020
1020
  // HTTP tunnels continue to schedule refresh as before
1021
1021
  // Note: This is a temporary limitation until TCP refresh is implemented
1022
+ if (mqttClient && assignment.jwt && assignment.leaseId) {
1023
+ try {
1024
+ // Decode JWT to get expiration timestamp (assignment doesn't store exp, must decode JWT)
1025
+ const parts = assignment.jwt.split('.');
1026
+ if (parts.length === 3) {
1027
+ const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'));
1028
+ const expMs = payload.exp ? payload.exp * 1000 : null;
1029
+ if (expMs) {
1030
+ mqttClient.scheduleRefresh(expMs, assignment.leaseId);
1031
+ logger.debug('jwt.refresh.initial_scheduled', { expMs, leaseId: assignment.leaseId });
1032
+ } else {
1033
+ logger.warn('jwt.refresh.initial_failed', { reason: 'no_exp_in_jwt' });
1034
+ }
1035
+ } else {
1036
+ logger.warn('jwt.refresh.initial_failed', { reason: 'invalid_jwt_format' });
1037
+ }
1038
+ } catch (error) {
1039
+ logger.warn('jwt.refresh.initial_failed', { reason: 'jwt_decode_error', error: error.message });
1040
+ }
1041
+ }
1022
1042
 
1023
1043
  // QPA-CLI-11: Vault UX messaging - Final tunnel live message
1024
1044
  const leaseMinutes = Math.floor(assignment.leaseMs / 60000);