asyx 0.10.0 → 0.11.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.
Files changed (93) hide show
  1. package/AGENTS.md +42 -0
  2. package/bin/asyx.js +1 -1
  3. package/package.json +6 -3
  4. package/src/commands/account.js +80 -71
  5. package/src/commands/app.js +317 -151
  6. package/src/commands/in-use-messages.js +47 -48
  7. package/src/commands/mqtt-broker.js +36 -49
  8. package/src/commands/mqtt.js +111 -149
  9. package/src/commands/name.js +24 -22
  10. package/src/commands/reject-messages.js +123 -123
  11. package/src/commands/setup.js +107 -131
  12. package/src/commands/sts.js +45 -61
  13. package/src/commands/tunnel.js +853 -931
  14. package/src/commands/validate-target-host.js +36 -59
  15. package/src/lib/aws-iot-config.js +30 -0
  16. package/src/lib/certs.js +15 -18
  17. package/src/lib/csr.js +107 -182
  18. package/src/lib/device.js +26 -37
  19. package/src/lib/ids.js +1 -2
  20. package/src/lib/naming.js +74 -68
  21. package/src/lib/pairing.js +10 -11
  22. package/src/lib/shared-transport.js +5 -9
  23. package/src/main.js +63 -53
  24. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneClient.js +25 -287
  25. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneTransport.js +0 -72
  26. package/vendor/tunnel-core/dist/control-plane/session.js +0 -20
  27. package/vendor/tunnel-core/dist/errors.js +0 -19
  28. package/vendor/tunnel-core/dist/flows/account.js +1 -6
  29. package/vendor/tunnel-core/dist/flows/goodbye.js +0 -4
  30. package/vendor/tunnel-core/dist/flows/http.js +24 -112
  31. package/vendor/tunnel-core/dist/flows/identity.js +11 -10
  32. package/vendor/tunnel-core/dist/flows/in-use.js +0 -6
  33. package/vendor/tunnel-core/dist/flows/reopen.js +0 -4
  34. package/vendor/tunnel-core/dist/flows/tcp.js +18 -84
  35. package/vendor/tunnel-core/dist/flows/udp.js +15 -52
  36. package/vendor/tunnel-core/dist/lib/fingerprint.js +38 -42
  37. package/vendor/tunnel-core/dist/lib/jwt-verifier.js +14 -67
  38. package/vendor/tunnel-core/dist/lib/logger.js +1 -9
  39. package/vendor/tunnel-core/dist/lib/refresh-helpers.js +1 -22
  40. package/vendor/tunnel-core/dist/lifecycle.js +1 -8
  41. package/vendor/tunnel-core/dist/mqtt/awaiter-map.js +1 -53
  42. package/vendor/tunnel-core/dist/mqtt/events/handlers.js +10 -64
  43. package/vendor/tunnel-core/dist/mqtt/events/index.js +3 -36
  44. package/vendor/tunnel-core/dist/mqtt/events/schemas.js +0 -1
  45. package/vendor/tunnel-core/dist/mqtt/ingress.js +0 -60
  46. package/vendor/tunnel-core/dist/state/assignment.js +6 -122
  47. package/vendor/tunnel-core/dist/state/instance-registry.js +0 -63
  48. package/vendor/tunnel-core/dist/tcp-v1/framing.js +2 -64
  49. package/vendor/tunnel-core/dist/tunnel/http-tunnel.js +64 -331
  50. package/vendor/tunnel-core/dist/tunnel/httpws-constants.js +5 -14
  51. package/vendor/tunnel-core/dist/tunnel/reconnect.js +10 -50
  52. package/vendor/tunnel-core/dist/tunnel/request-sink.js +0 -16
  53. package/vendor/tunnel-core/dist/tunnel/tcp-tunnel.js +32 -195
  54. package/vendor/tunnel-core/dist/tunnel/udp-tunnel.js +28 -153
  55. package/vendor/tunnel-core/dist/tunnel/ws-control.js +4 -39
  56. package/vendor/tunnel-core/dist/types.js +0 -2
  57. package/vendor/tunnel-core/dist/udp-v1/framing.js +2 -64
  58. package/vendor/tunnel-core/package.json +0 -25
  59. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneClient.d.ts +0 -273
  60. package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneTransport.d.ts +0 -79
  61. package/vendor/tunnel-core/dist/control-plane/session.d.ts +0 -55
  62. package/vendor/tunnel-core/dist/errors.d.ts +0 -49
  63. package/vendor/tunnel-core/dist/flows/account.d.ts +0 -24
  64. package/vendor/tunnel-core/dist/flows/goodbye.d.ts +0 -10
  65. package/vendor/tunnel-core/dist/flows/http.d.ts +0 -61
  66. package/vendor/tunnel-core/dist/flows/identity.d.ts +0 -23
  67. package/vendor/tunnel-core/dist/flows/in-use.d.ts +0 -27
  68. package/vendor/tunnel-core/dist/flows/reopen.d.ts +0 -9
  69. package/vendor/tunnel-core/dist/flows/tcp.d.ts +0 -85
  70. package/vendor/tunnel-core/dist/flows/udp.d.ts +0 -52
  71. package/vendor/tunnel-core/dist/lib/adapt-logger.d.ts +0 -2
  72. package/vendor/tunnel-core/dist/lib/fingerprint.d.ts +0 -145
  73. package/vendor/tunnel-core/dist/lib/jwt-verifier.d.ts +0 -27
  74. package/vendor/tunnel-core/dist/lib/logger.d.ts +0 -9
  75. package/vendor/tunnel-core/dist/lib/refresh-helpers.d.ts +0 -16
  76. package/vendor/tunnel-core/dist/lifecycle.d.ts +0 -24
  77. package/vendor/tunnel-core/dist/mqtt/awaiter-map.d.ts +0 -56
  78. package/vendor/tunnel-core/dist/mqtt/events/handlers.d.ts +0 -60
  79. package/vendor/tunnel-core/dist/mqtt/events/index.d.ts +0 -1
  80. package/vendor/tunnel-core/dist/mqtt/events/schemas.d.ts +0 -498
  81. package/vendor/tunnel-core/dist/mqtt/ingress.d.ts +0 -63
  82. package/vendor/tunnel-core/dist/state/assignment.d.ts +0 -136
  83. package/vendor/tunnel-core/dist/state/instance-registry.d.ts +0 -88
  84. package/vendor/tunnel-core/dist/tcp-v1/framing.d.ts +0 -43
  85. package/vendor/tunnel-core/dist/tunnel/http-tunnel.d.ts +0 -140
  86. package/vendor/tunnel-core/dist/tunnel/httpws-constants.d.ts +0 -13
  87. package/vendor/tunnel-core/dist/tunnel/reconnect.d.ts +0 -76
  88. package/vendor/tunnel-core/dist/tunnel/request-sink.d.ts +0 -40
  89. package/vendor/tunnel-core/dist/tunnel/tcp-tunnel.d.ts +0 -92
  90. package/vendor/tunnel-core/dist/tunnel/udp-tunnel.d.ts +0 -93
  91. package/vendor/tunnel-core/dist/tunnel/ws-control.d.ts +0 -22
  92. package/vendor/tunnel-core/dist/types.d.ts +0 -24
  93. package/vendor/tunnel-core/dist/udp-v1/framing.d.ts +0 -41
@@ -1,93 +0,0 @@
1
- export class UdpTunnel {
2
- /** @returns {{ family: 'udp4' | 'udp6', address: string } | null} */
3
- static selectDial(targetHost: any): {
4
- family: "udp4" | "udp6";
5
- address: string;
6
- } | null;
7
- constructor({ relayUrl, jwt, deviceId, requestId, localPort, targetHost, targetPort, leaseId, relayId, log, coordinatorCore, coordinatorIngress, isControlPlaneConnected, waitForControlPlane, getLastMqttError, getForceReconnect, controlPlaneTimeoutMs, getJwt, reassign, exit, }: {
8
- relayUrl: any;
9
- jwt: any;
10
- deviceId: any;
11
- requestId: any;
12
- localPort?: any;
13
- targetHost: any;
14
- targetPort: any;
15
- leaseId: any;
16
- relayId: any;
17
- log: any;
18
- coordinatorCore: any;
19
- coordinatorIngress: any;
20
- isControlPlaneConnected?: () => boolean;
21
- waitForControlPlane?: () => Promise<void>;
22
- getLastMqttError?: () => any;
23
- getForceReconnect?: () => any;
24
- controlPlaneTimeoutMs?: number;
25
- getJwt?: any;
26
- reassign?: any;
27
- exit?: (code: number) => void;
28
- });
29
- relayUrl: any;
30
- jwt: any;
31
- getJwt: any;
32
- reassign: any;
33
- exit: (code: number) => void;
34
- deviceId: any;
35
- requestId: any;
36
- targetHost: any;
37
- targetPort: any;
38
- /** @type {'udp4' | 'udp6' | null} */
39
- dialFamily: "udp4" | "udp6" | null;
40
- dialAddress: string;
41
- leaseId: any;
42
- relayId: any;
43
- log: any;
44
- ws: WebSocket;
45
- coordinatorCore: any;
46
- coordinatorIngress: any;
47
- isControlPlaneConnected: () => boolean;
48
- waitForControlPlane: () => Promise<void>;
49
- getLastMqttError: () => any;
50
- getForceReconnect: () => any;
51
- controlPlaneTimeoutMs: number;
52
- flowMap: Map<any, any>;
53
- socketToFlowId: WeakMap<object, any>;
54
- frameBuffer: Buffer<ArrayBuffer>;
55
- protocolViolation: boolean;
56
- idleTimeoutMs: number;
57
- pingIntervalMs: number;
58
- pingTimer: NodeJS.Timeout;
59
- lastPongMs: number;
60
- flowIdleTimeoutMs: number;
61
- flowCleanupTimer: NodeJS.Timeout;
62
- closing: boolean;
63
- everOpened: boolean;
64
- lastInboundMs: number;
65
- reconnectEnabled: boolean;
66
- reconnector: Reconnector;
67
- open(): Promise<void>;
68
- _attemptConnect(): Promise<any>;
69
- verifiedJwt: any;
70
- _setupWebSocketConnection(wsUrl: any, resolve: any, reject: any): void;
71
- _onDropped(code: any, reasonStr: any): void;
72
- handleBinaryFrame(data: any): void;
73
- routeFrame(frame: any): void;
74
- handleProtocolViolation(error: any): void;
75
- handleUdpDatagram(frame: any): void;
76
- sendDatagramToApp(socket: any, flowId: any, payload: any): void;
77
- handleUdpClose(frame: any): void;
78
- handlePing(frame: any): void;
79
- handlePong(frame: any): void;
80
- handleLocalDatagram(msg: any, rinfo: any, flowId: any): void;
81
- startPingKeepalive(): void;
82
- stopPingKeepalive(): void;
83
- sendPing(): void;
84
- startFlowCleanup(): void;
85
- stopFlowCleanup(): void;
86
- closeAllFlowSockets(): void;
87
- close(): void;
88
- /** Story 3.13: the coordinator said this lease is closed (at renewal): reopen exactly as on a relay
89
- * close 4000 lease_closed (same port, new lease, then reconnect); resolves false when refused. */
90
- reopenAfterLeaseClosed(): Promise<boolean>;
91
- }
92
- import WebSocket from 'ws';
93
- import { Reconnector } from './reconnect.js';
@@ -1,22 +0,0 @@
1
- /**
2
- * CLI-REAUTH: Dispatch incoming control frames to waiting promises
3
- * Called from WebSocket message handler when a text frame matches control pattern
4
- *
5
- * @param {Object} frame - Parsed JSON control frame (must have 'op' field)
6
- */
7
- export function dispatchControlFrame(frame: any): boolean;
8
- /**
9
- * CLI-REAUTH: Cleanup all waiters (call on socket close to prevent leaks)
10
- * Rejects all pending waiters to ensure promises settle and don't linger in microtask queue
11
- */
12
- export function clearAllWaiters(): void;
13
- /**
14
- * CLI-REAUTH: Send control frame and wait for acknowledgment
15
- *
16
- * @param {import('ws').WebSocket} ws - WebSocket connection
17
- * @param {string} payloadJson - Serialized JSON payload to send
18
- * @param {string} expectedOp - Expected 'op' value in response (e.g., 'reauth_ack')
19
- * @param {number} timeoutMs - Timeout in milliseconds (default 3000)
20
- * @returns {Promise<Object>} Resolves with parsed control frame, or {status:'error', error:'timeout'} on timeout
21
- */
22
- export function sendControlAndWaitAck(ws: import("ws").WebSocket, payloadJson: string, expectedOp: string, timeoutMs?: number): Promise<any>;
@@ -1,24 +0,0 @@
1
- /** What the core logs through: message first, then structured fields. The caller supplies it. */
2
- export interface Logger {
3
- info(msg: string, fields?: Record<string, unknown>): void;
4
- warn(msg: string, fields?: Record<string, unknown>): void;
5
- error(msg: string, fields?: Record<string, unknown>): void;
6
- debug(msg: string, fields?: Record<string, unknown>): void;
7
- }
8
- /** The tunnel classes log as (fields, msg) or (msg, fields); see lib/adapt-logger. */
9
- export type LogFn = (msgOrFields: string | Record<string, unknown>, maybeFields?: string | Record<string, unknown>) => void;
10
- export interface ClassLogger {
11
- info: LogFn;
12
- warn: LogFn;
13
- error: LogFn;
14
- debug: LogFn;
15
- }
16
- /** The part of the MQTT core client the flows publish through. */
17
- export interface Publisher {
18
- publish(message: {
19
- topic: string;
20
- payload: string | Uint8Array;
21
- qos?: 0 | 1;
22
- retain?: boolean;
23
- }): Promise<unknown>;
24
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Encode a frame to binary format
3
- * @param {Object} frame - Frame object with type, flowId, and payload
4
- * @param {number} frame.type - Frame type (FrameType constant)
5
- * @param {number} frame.flowId - Flow ID (32-bit, 0 for PING/PONG)
6
- * @param {Buffer|Uint8Array} frame.payload - Frame payload (max 64 KiB)
7
- * @returns {Buffer} Encoded frame
8
- * @throws {UdpV1FramingError} If frame is invalid
9
- */
10
- export function encodeFrame(frame: {
11
- type: number;
12
- flowId: number;
13
- payload: Buffer | Uint8Array;
14
- }): Buffer;
15
- /**
16
- * Decode a frame from binary format
17
- * @param {Buffer|Uint8Array} data - Binary frame data
18
- * @param {number} [offset=0] - Offset to start reading from
19
- * @returns {Object} Decoded frame object with type, flowId, payload, and consumed bytes
20
- * @throws {UdpV1FramingError} If frame is invalid
21
- */
22
- export function decodeFrame(data: Buffer | Uint8Array, offset?: number): any;
23
- /**
24
- * Validate a frame for protocol violations
25
- * @param {Object} frame - Frame object to validate
26
- * @returns {void}
27
- * @throws {UdpV1FramingError} If frame is invalid
28
- */
29
- export function validateFrame(frame: any): void;
30
- export namespace FrameType {
31
- let UDP_DGRAM: number;
32
- let UDP_CLOSE: number;
33
- let PING: number;
34
- let PONG: number;
35
- }
36
- export const MAX_FRAME_PAYLOAD: number;
37
- export const FRAME_HEADER_SIZE: 9;
38
- export class UdpV1FramingError extends Error {
39
- constructor(message: any, code: any);
40
- code: any;
41
- }