asyx 0.5.9 → 0.6.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 +73 -9
- package/SECURITY.md +5 -3
- package/package.json +13 -23
- package/src/commands/name.js +23 -0
- package/src/commands/reject-messages.js +54 -0
- package/src/commands/setup.js +98 -102
- package/src/commands/tunnel.js +279 -2425
- package/src/lib/naming.js +81 -0
- package/src/main.js +9 -1
- package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneClient.d.ts +260 -0
- package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneClient.js +1088 -0
- package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneTransport.d.ts +79 -0
- package/vendor/tunnel-core/dist/control-plane/MqttControlPlaneTransport.js +138 -0
- package/vendor/tunnel-core/dist/control-plane/session.d.ts +50 -0
- package/vendor/tunnel-core/dist/control-plane/session.js +115 -0
- package/vendor/tunnel-core/dist/errors.d.ts +49 -0
- package/vendor/tunnel-core/dist/errors.js +53 -0
- package/vendor/tunnel-core/dist/flows/http.d.ts +50 -0
- package/vendor/tunnel-core/dist/flows/http.js +585 -0
- package/vendor/tunnel-core/dist/flows/tcp.d.ts +60 -0
- package/vendor/tunnel-core/dist/flows/tcp.js +546 -0
- package/vendor/tunnel-core/dist/flows/udp.d.ts +41 -0
- package/vendor/tunnel-core/dist/flows/udp.js +376 -0
- package/vendor/tunnel-core/dist/lib/adapt-logger.d.ts +2 -0
- package/vendor/tunnel-core/dist/lib/adapt-logger.js +6 -0
- package/vendor/tunnel-core/dist/lib/fingerprint.d.ts +13 -0
- package/vendor/tunnel-core/dist/lib/fingerprint.js +95 -0
- package/vendor/tunnel-core/dist/lib/jwt-verifier.d.ts +27 -0
- package/vendor/tunnel-core/dist/lib/jwt-verifier.js +230 -0
- package/vendor/tunnel-core/dist/lib/logger.d.ts +9 -0
- package/vendor/tunnel-core/dist/lib/logger.js +58 -0
- package/vendor/tunnel-core/dist/lib/refresh-helpers.d.ts +16 -0
- package/vendor/tunnel-core/dist/lib/refresh-helpers.js +66 -0
- package/vendor/tunnel-core/dist/lifecycle.d.ts +24 -0
- package/vendor/tunnel-core/dist/lifecycle.js +29 -0
- package/vendor/tunnel-core/dist/mqtt/awaiter-map.d.ts +56 -0
- package/vendor/tunnel-core/dist/mqtt/awaiter-map.js +227 -0
- package/vendor/tunnel-core/dist/mqtt/events/handlers.d.ts +58 -0
- package/vendor/tunnel-core/dist/mqtt/events/handlers.js +250 -0
- package/vendor/tunnel-core/dist/mqtt/events/index.d.ts +1 -0
- package/vendor/tunnel-core/dist/mqtt/events/index.js +191 -0
- package/vendor/tunnel-core/dist/mqtt/events/schemas.d.ts +498 -0
- package/vendor/tunnel-core/dist/mqtt/events/schemas.js +51 -0
- package/vendor/tunnel-core/dist/mqtt/ingress.d.ts +63 -0
- package/vendor/tunnel-core/dist/mqtt/ingress.js +170 -0
- package/vendor/tunnel-core/dist/state/assignment.d.ts +122 -0
- package/vendor/tunnel-core/dist/state/assignment.js +322 -0
- package/vendor/tunnel-core/dist/state/instance-registry.d.ts +88 -0
- package/{src → vendor/tunnel-core/dist}/state/instance-registry.js +38 -53
- package/vendor/tunnel-core/dist/tcp-v1/framing.d.ts +43 -0
- package/vendor/tunnel-core/dist/tcp-v1/framing.js +157 -0
- package/vendor/tunnel-core/dist/tunnel/http-tunnel.d.ts +137 -0
- package/vendor/tunnel-core/dist/tunnel/http-tunnel.js +1591 -0
- package/vendor/tunnel-core/dist/tunnel/httpws-constants.d.ts +13 -0
- package/{src → vendor/tunnel-core/dist}/tunnel/httpws-constants.js +5 -7
- package/vendor/tunnel-core/dist/tunnel/reconnect.d.ts +76 -0
- package/vendor/tunnel-core/dist/tunnel/reconnect.js +183 -0
- package/vendor/tunnel-core/dist/tunnel/request-sink.d.ts +40 -0
- package/vendor/tunnel-core/dist/tunnel/request-sink.js +39 -0
- package/vendor/tunnel-core/dist/tunnel/tcp-tunnel.d.ts +89 -0
- package/vendor/tunnel-core/dist/tunnel/tcp-tunnel.js +838 -0
- package/vendor/tunnel-core/dist/tunnel/udp-tunnel.d.ts +90 -0
- package/vendor/tunnel-core/dist/tunnel/udp-tunnel.js +737 -0
- package/vendor/tunnel-core/dist/tunnel/ws-control.d.ts +22 -0
- package/vendor/tunnel-core/dist/tunnel/ws-control.js +124 -0
- package/vendor/tunnel-core/dist/types.d.ts +24 -0
- package/vendor/tunnel-core/dist/types.js +2 -0
- package/vendor/tunnel-core/dist/udp-v1/framing.d.ts +41 -0
- package/vendor/tunnel-core/dist/udp-v1/framing.js +158 -0
- package/vendor/tunnel-core/package.json +34 -0
- package/src/control-plane/MqttControlPlaneClient.js +0 -1196
- package/src/control-plane/MqttControlPlaneTransport.js +0 -150
- package/src/lib/fingerprint.js +0 -115
- package/src/lib/jwt-verifier.js +0 -260
- package/src/lib/logger.js +0 -62
- package/src/mqtt/awaiter-map.js +0 -247
- package/src/mqtt/events/handlers.js +0 -300
- package/src/mqtt/events/index.js +0 -222
- package/src/mqtt/events/schemas.js +0 -58
- package/src/mqtt/ingress.js +0 -182
- package/src/state/assignment.js +0 -333
- package/src/tcp-v1/framing.js +0 -203
- package/src/tunnel/http-tunnel.js +0 -1738
- package/src/tunnel/reconnect.js +0 -182
- package/src/tunnel/tcp-tunnel.js +0 -944
- package/src/tunnel/udp-tunnel.js +0 -813
- package/src/tunnel/ws-control.js +0 -135
- package/src/udp-v1/framing.js +0 -203
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { parseAny, getHandler } from "./handlers.js";
|
|
2
|
+
import { getInstance, getAllInstances, resolveInstanceByRequestId } from "../../state/instance-registry.js";
|
|
3
|
+
import { resolveInstanceByLease, getAssignment } from "../../state/assignment.js";
|
|
4
|
+
import logger from "../../lib/logger.js";
|
|
5
|
+
// TPB-12: Track unmatched events to avoid log spam
|
|
6
|
+
let unmatchedEventLogged = false;
|
|
7
|
+
export async function dispatch(parsedMessage) {
|
|
8
|
+
// Extract the parsed payload from the message object
|
|
9
|
+
const payload = parsedMessage.payload;
|
|
10
|
+
if (!payload)
|
|
11
|
+
return; // No payload — ignore
|
|
12
|
+
// The payload is already parsed JSON, so we can use it directly
|
|
13
|
+
const evt = payload;
|
|
14
|
+
if (!evt.type)
|
|
15
|
+
return; // No type — ignore
|
|
16
|
+
// TPB-12: Route by instanceId/leaseId
|
|
17
|
+
const instanceId = evt.instanceId || evt.data?.instanceId || null;
|
|
18
|
+
const leaseId = evt.correlationId || evt.data?.leaseId || evt.data?.assignment?.leaseId || null;
|
|
19
|
+
let targetInstanceId = null;
|
|
20
|
+
let instanceContext = null;
|
|
21
|
+
// Routing logic:
|
|
22
|
+
// 1. If instanceId present: lookup instance registry
|
|
23
|
+
// 2. If instanceId unknown but leaseId present: try leaseId resolution (resilience for rotated clientIds)
|
|
24
|
+
// 3. If both present but mismatch: log mismatch, prefer instanceId if both resolve
|
|
25
|
+
// 4. If neither: try other fallbacks, then drop
|
|
26
|
+
if (instanceId) {
|
|
27
|
+
instanceContext = getInstance(instanceId);
|
|
28
|
+
if (instanceContext) {
|
|
29
|
+
targetInstanceId = instanceId;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// TPB-12: Don't early-drop on unknown instanceId - try multiple fallbacks
|
|
33
|
+
// This preserves resilience for rotated clientIds and initial connections
|
|
34
|
+
// Fallback 1: Try leaseId resolution (for rotated clientIds with existing assignments)
|
|
35
|
+
if (leaseId) {
|
|
36
|
+
const resolvedInstanceId = resolveInstanceByLease(leaseId);
|
|
37
|
+
if (resolvedInstanceId) {
|
|
38
|
+
instanceContext = getInstance(resolvedInstanceId);
|
|
39
|
+
if (instanceContext) {
|
|
40
|
+
targetInstanceId = resolvedInstanceId;
|
|
41
|
+
logger.debug('evt.routed.leaseid_fallback', {
|
|
42
|
+
unknownInstanceId: instanceId,
|
|
43
|
+
resolvedInstanceId,
|
|
44
|
+
leaseId,
|
|
45
|
+
eventType: evt.type,
|
|
46
|
+
requestId: evt.requestId,
|
|
47
|
+
note: 'Unknown instanceId; routed via leaseId (likely rotated clientId)'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Fallback 2: Try requestId resolution (for initial open_ack before assignment exists)
|
|
53
|
+
if (!targetInstanceId && evt.requestId) {
|
|
54
|
+
const preAssignmentInstanceId = resolveInstanceByRequestId(evt.requestId);
|
|
55
|
+
if (preAssignmentInstanceId) {
|
|
56
|
+
instanceContext = getInstance(preAssignmentInstanceId);
|
|
57
|
+
if (instanceContext) {
|
|
58
|
+
targetInstanceId = preAssignmentInstanceId;
|
|
59
|
+
logger.debug('evt.routed.requestid_fallback_unknown_instance', {
|
|
60
|
+
unknownInstanceId: instanceId,
|
|
61
|
+
resolvedInstanceId: targetInstanceId,
|
|
62
|
+
requestId: evt.requestId,
|
|
63
|
+
leaseId,
|
|
64
|
+
eventType: evt.type,
|
|
65
|
+
note: 'Unknown instanceId; routed via requestId (initial connection or rotated clientId)'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Defect 11.27: no fallback that matches a stored assignment's requestId here. The reply names
|
|
71
|
+
// an instance this process does not hold; every process of the device receives it, so it is
|
|
72
|
+
// used only for a request this process is still waiting for (fallback 2) or a lease it holds
|
|
73
|
+
// (fallback 1). Matching a stored requestId let one tunnel adopt another tunnel's lease when
|
|
74
|
+
// their renewal ids collided.
|
|
75
|
+
// Only log/drop if all fallbacks failed
|
|
76
|
+
if (!targetInstanceId) {
|
|
77
|
+
logger.warn('evt.instance.unknown', {
|
|
78
|
+
instanceId,
|
|
79
|
+
leaseId,
|
|
80
|
+
eventType: evt.type,
|
|
81
|
+
requestId: evt.requestId,
|
|
82
|
+
note: 'Event dropped - unknown instanceId and all fallbacks failed'
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (leaseId && !targetInstanceId) {
|
|
89
|
+
// Fallback to leaseId resolution when instanceId not present
|
|
90
|
+
const resolvedInstanceId = resolveInstanceByLease(leaseId);
|
|
91
|
+
if (resolvedInstanceId) {
|
|
92
|
+
instanceContext = getInstance(resolvedInstanceId);
|
|
93
|
+
if (instanceContext) {
|
|
94
|
+
targetInstanceId = resolvedInstanceId;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Check for mismatch
|
|
99
|
+
if (instanceId && leaseId && targetInstanceId) {
|
|
100
|
+
const leaseResolvedInstanceId = resolveInstanceByLease(leaseId);
|
|
101
|
+
if (leaseResolvedInstanceId && leaseResolvedInstanceId !== instanceId) {
|
|
102
|
+
logger.warn('evt.instance.lease_mismatch', {
|
|
103
|
+
instanceId,
|
|
104
|
+
leaseId,
|
|
105
|
+
leaseResolvedInstanceId,
|
|
106
|
+
preferredInstanceId: instanceId,
|
|
107
|
+
eventType: evt.type,
|
|
108
|
+
requestId: evt.requestId
|
|
109
|
+
});
|
|
110
|
+
// Prefer instanceId (already set above)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// TPB-12: Backcompat fallback - if no instanceId/leaseId, try pre-assignment requestId, then assignment requestId, then single-instance
|
|
114
|
+
if (!targetInstanceId) {
|
|
115
|
+
const allInstances = getAllInstances();
|
|
116
|
+
// Fallback 1: Pre-assignment requestId matching (for initial open_ack before assignment exists)
|
|
117
|
+
if (evt.requestId) {
|
|
118
|
+
const preAssignmentInstanceId = resolveInstanceByRequestId(evt.requestId);
|
|
119
|
+
if (preAssignmentInstanceId) {
|
|
120
|
+
instanceContext = getInstance(preAssignmentInstanceId);
|
|
121
|
+
if (instanceContext) {
|
|
122
|
+
targetInstanceId = preAssignmentInstanceId;
|
|
123
|
+
logger.debug('evt.routed.pre_assignment_requestid', {
|
|
124
|
+
instanceId: targetInstanceId,
|
|
125
|
+
eventType: evt.type,
|
|
126
|
+
requestId: evt.requestId,
|
|
127
|
+
note: 'No instanceId in event; routed by pre-assignment requestId (backcompat)'
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Fallback 2: Match by requestId in existing assignment (for refresh/reconnect)
|
|
133
|
+
if (!targetInstanceId && evt.requestId && allInstances.length > 0) {
|
|
134
|
+
// Try to find instance with matching requestId in assignment
|
|
135
|
+
for (const inst of allInstances) {
|
|
136
|
+
const assignment = getAssignment(inst.instanceId);
|
|
137
|
+
if (assignment && assignment.requestId === evt.requestId) {
|
|
138
|
+
instanceContext = inst;
|
|
139
|
+
targetInstanceId = inst.instanceId;
|
|
140
|
+
logger.debug('evt.routed.requestid_match', {
|
|
141
|
+
instanceId: targetInstanceId,
|
|
142
|
+
eventType: evt.type,
|
|
143
|
+
requestId: evt.requestId,
|
|
144
|
+
note: 'No instanceId in event; routed by requestId match in assignment (backcompat)'
|
|
145
|
+
});
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Fallback 3: Single registered instance (backcompat for TPB-13)
|
|
151
|
+
if (!targetInstanceId && allInstances.length === 1) {
|
|
152
|
+
instanceContext = allInstances[0];
|
|
153
|
+
targetInstanceId = instanceContext.instanceId;
|
|
154
|
+
logger.debug('evt.routed.single_instance_fallback', {
|
|
155
|
+
instanceId: targetInstanceId,
|
|
156
|
+
eventType: evt.type,
|
|
157
|
+
requestId: evt.requestId,
|
|
158
|
+
note: 'No instanceId in event; routed to single registered instance (backcompat)'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// If still no target, drop event
|
|
162
|
+
if (!targetInstanceId) {
|
|
163
|
+
if (!unmatchedEventLogged) {
|
|
164
|
+
logger.warn('evt.unmatched', {
|
|
165
|
+
instanceId,
|
|
166
|
+
leaseId,
|
|
167
|
+
eventType: evt.type,
|
|
168
|
+
requestId: evt.requestId,
|
|
169
|
+
registeredInstances: allInstances.length,
|
|
170
|
+
note: 'Event dropped - no matching instance. This may be normal for late/unknown events.'
|
|
171
|
+
});
|
|
172
|
+
unmatchedEventLogged = true;
|
|
173
|
+
// Reset after 60 seconds to allow occasional logging
|
|
174
|
+
// Store timeout handle for potential cleanup (though module-level cleanup is rare)
|
|
175
|
+
const timeoutHandle = setTimeout(() => { unmatchedEventLogged = false; }, 60000);
|
|
176
|
+
// In test mode, unref the timeout so it doesn't keep the process alive
|
|
177
|
+
if (process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === 'test') {
|
|
178
|
+
timeoutHandle.unref();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Attach instance context to event for handlers
|
|
185
|
+
evt._instanceId = targetInstanceId;
|
|
186
|
+
evt._instanceContext = instanceContext;
|
|
187
|
+
const handler = getHandler(evt.type);
|
|
188
|
+
if (!handler)
|
|
189
|
+
return; // Unknown type — ignore
|
|
190
|
+
return handler(evt);
|
|
191
|
+
}
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
export const Envelope: z.ZodObject<{
|
|
2
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
3
|
+
v: z.ZodLiteral<1>;
|
|
4
|
+
requestId: z.ZodString;
|
|
5
|
+
ts: z.ZodNumber;
|
|
6
|
+
data: z.ZodUnknown;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
requestId?: string;
|
|
9
|
+
type?: "setup_required" | "error" | "open_ack" | "open_reject";
|
|
10
|
+
v?: 1;
|
|
11
|
+
ts?: number;
|
|
12
|
+
data?: unknown;
|
|
13
|
+
}, {
|
|
14
|
+
requestId?: string;
|
|
15
|
+
type?: "setup_required" | "error" | "open_ack" | "open_reject";
|
|
16
|
+
v?: 1;
|
|
17
|
+
ts?: number;
|
|
18
|
+
data?: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
export const SetupRequired: z.ZodObject<z.objectUtil.extendShape<{
|
|
21
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
22
|
+
v: z.ZodLiteral<1>;
|
|
23
|
+
requestId: z.ZodString;
|
|
24
|
+
ts: z.ZodNumber;
|
|
25
|
+
data: z.ZodUnknown;
|
|
26
|
+
}, {
|
|
27
|
+
type: z.ZodLiteral<"setup_required">;
|
|
28
|
+
data: z.ZodObject<{
|
|
29
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
reason?: string;
|
|
32
|
+
}, {
|
|
33
|
+
reason?: string;
|
|
34
|
+
}>;
|
|
35
|
+
}>, "strip", z.ZodTypeAny, {
|
|
36
|
+
requestId?: string;
|
|
37
|
+
type?: "setup_required";
|
|
38
|
+
v?: 1;
|
|
39
|
+
ts?: number;
|
|
40
|
+
data?: {
|
|
41
|
+
reason?: string;
|
|
42
|
+
};
|
|
43
|
+
}, {
|
|
44
|
+
requestId?: string;
|
|
45
|
+
type?: "setup_required";
|
|
46
|
+
v?: 1;
|
|
47
|
+
ts?: number;
|
|
48
|
+
data?: {
|
|
49
|
+
reason?: string;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
export const OpenAck: z.ZodObject<z.objectUtil.extendShape<{
|
|
53
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
54
|
+
v: z.ZodLiteral<1>;
|
|
55
|
+
requestId: z.ZodString;
|
|
56
|
+
ts: z.ZodNumber;
|
|
57
|
+
data: z.ZodUnknown;
|
|
58
|
+
}, {
|
|
59
|
+
type: z.ZodLiteral<"open_ack">;
|
|
60
|
+
data: z.ZodObject<{
|
|
61
|
+
relayId: z.ZodString;
|
|
62
|
+
leaseMs: z.ZodNumber;
|
|
63
|
+
assignment: z.ZodObject<{
|
|
64
|
+
jwt: z.ZodString;
|
|
65
|
+
fqdn: z.ZodString;
|
|
66
|
+
proto: z.ZodString;
|
|
67
|
+
path: z.ZodString;
|
|
68
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
69
|
+
alg: z.ZodOptional<z.ZodString>;
|
|
70
|
+
exp: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
path?: string;
|
|
73
|
+
jwt?: string;
|
|
74
|
+
fqdn?: string;
|
|
75
|
+
proto?: string;
|
|
76
|
+
kid?: string;
|
|
77
|
+
alg?: string;
|
|
78
|
+
exp?: number;
|
|
79
|
+
}, {
|
|
80
|
+
path?: string;
|
|
81
|
+
jwt?: string;
|
|
82
|
+
fqdn?: string;
|
|
83
|
+
proto?: string;
|
|
84
|
+
kid?: string;
|
|
85
|
+
alg?: string;
|
|
86
|
+
exp?: number;
|
|
87
|
+
}>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
assignment?: {
|
|
90
|
+
path?: string;
|
|
91
|
+
jwt?: string;
|
|
92
|
+
fqdn?: string;
|
|
93
|
+
proto?: string;
|
|
94
|
+
kid?: string;
|
|
95
|
+
alg?: string;
|
|
96
|
+
exp?: number;
|
|
97
|
+
};
|
|
98
|
+
relayId?: string;
|
|
99
|
+
leaseMs?: number;
|
|
100
|
+
}, {
|
|
101
|
+
assignment?: {
|
|
102
|
+
path?: string;
|
|
103
|
+
jwt?: string;
|
|
104
|
+
fqdn?: string;
|
|
105
|
+
proto?: string;
|
|
106
|
+
kid?: string;
|
|
107
|
+
alg?: string;
|
|
108
|
+
exp?: number;
|
|
109
|
+
};
|
|
110
|
+
relayId?: string;
|
|
111
|
+
leaseMs?: number;
|
|
112
|
+
}>;
|
|
113
|
+
}>, "strip", z.ZodTypeAny, {
|
|
114
|
+
requestId?: string;
|
|
115
|
+
type?: "open_ack";
|
|
116
|
+
v?: 1;
|
|
117
|
+
ts?: number;
|
|
118
|
+
data?: {
|
|
119
|
+
assignment?: {
|
|
120
|
+
path?: string;
|
|
121
|
+
jwt?: string;
|
|
122
|
+
fqdn?: string;
|
|
123
|
+
proto?: string;
|
|
124
|
+
kid?: string;
|
|
125
|
+
alg?: string;
|
|
126
|
+
exp?: number;
|
|
127
|
+
};
|
|
128
|
+
relayId?: string;
|
|
129
|
+
leaseMs?: number;
|
|
130
|
+
};
|
|
131
|
+
}, {
|
|
132
|
+
requestId?: string;
|
|
133
|
+
type?: "open_ack";
|
|
134
|
+
v?: 1;
|
|
135
|
+
ts?: number;
|
|
136
|
+
data?: {
|
|
137
|
+
assignment?: {
|
|
138
|
+
path?: string;
|
|
139
|
+
jwt?: string;
|
|
140
|
+
fqdn?: string;
|
|
141
|
+
proto?: string;
|
|
142
|
+
kid?: string;
|
|
143
|
+
alg?: string;
|
|
144
|
+
exp?: number;
|
|
145
|
+
};
|
|
146
|
+
relayId?: string;
|
|
147
|
+
leaseMs?: number;
|
|
148
|
+
};
|
|
149
|
+
}>;
|
|
150
|
+
export const OpenAckLegacy: z.ZodObject<z.objectUtil.extendShape<{
|
|
151
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
152
|
+
v: z.ZodLiteral<1>;
|
|
153
|
+
requestId: z.ZodString;
|
|
154
|
+
ts: z.ZodNumber;
|
|
155
|
+
data: z.ZodUnknown;
|
|
156
|
+
}, {
|
|
157
|
+
type: z.ZodLiteral<"open_ack">;
|
|
158
|
+
data: z.ZodObject<{
|
|
159
|
+
relayId: z.ZodString;
|
|
160
|
+
jwt: z.ZodString;
|
|
161
|
+
leaseMs: z.ZodNumber;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
relayId?: string;
|
|
164
|
+
leaseMs?: number;
|
|
165
|
+
jwt?: string;
|
|
166
|
+
}, {
|
|
167
|
+
relayId?: string;
|
|
168
|
+
leaseMs?: number;
|
|
169
|
+
jwt?: string;
|
|
170
|
+
}>;
|
|
171
|
+
}>, "strip", z.ZodTypeAny, {
|
|
172
|
+
requestId?: string;
|
|
173
|
+
type?: "open_ack";
|
|
174
|
+
v?: 1;
|
|
175
|
+
ts?: number;
|
|
176
|
+
data?: {
|
|
177
|
+
relayId?: string;
|
|
178
|
+
leaseMs?: number;
|
|
179
|
+
jwt?: string;
|
|
180
|
+
};
|
|
181
|
+
}, {
|
|
182
|
+
requestId?: string;
|
|
183
|
+
type?: "open_ack";
|
|
184
|
+
v?: 1;
|
|
185
|
+
ts?: number;
|
|
186
|
+
data?: {
|
|
187
|
+
relayId?: string;
|
|
188
|
+
leaseMs?: number;
|
|
189
|
+
jwt?: string;
|
|
190
|
+
};
|
|
191
|
+
}>;
|
|
192
|
+
export const OpenReject: z.ZodObject<z.objectUtil.extendShape<{
|
|
193
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
194
|
+
v: z.ZodLiteral<1>;
|
|
195
|
+
requestId: z.ZodString;
|
|
196
|
+
ts: z.ZodNumber;
|
|
197
|
+
data: z.ZodUnknown;
|
|
198
|
+
}, {
|
|
199
|
+
type: z.ZodLiteral<"open_reject">;
|
|
200
|
+
data: z.ZodObject<{
|
|
201
|
+
reason: z.ZodString;
|
|
202
|
+
}, "strip", z.ZodTypeAny, {
|
|
203
|
+
reason?: string;
|
|
204
|
+
}, {
|
|
205
|
+
reason?: string;
|
|
206
|
+
}>;
|
|
207
|
+
}>, "strip", z.ZodTypeAny, {
|
|
208
|
+
requestId?: string;
|
|
209
|
+
type?: "open_reject";
|
|
210
|
+
v?: 1;
|
|
211
|
+
ts?: number;
|
|
212
|
+
data?: {
|
|
213
|
+
reason?: string;
|
|
214
|
+
};
|
|
215
|
+
}, {
|
|
216
|
+
requestId?: string;
|
|
217
|
+
type?: "open_reject";
|
|
218
|
+
v?: 1;
|
|
219
|
+
ts?: number;
|
|
220
|
+
data?: {
|
|
221
|
+
reason?: string;
|
|
222
|
+
};
|
|
223
|
+
}>;
|
|
224
|
+
export const ErrorEvt: z.ZodObject<z.objectUtil.extendShape<{
|
|
225
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
226
|
+
v: z.ZodLiteral<1>;
|
|
227
|
+
requestId: z.ZodString;
|
|
228
|
+
ts: z.ZodNumber;
|
|
229
|
+
data: z.ZodUnknown;
|
|
230
|
+
}, {
|
|
231
|
+
type: z.ZodEnum<["error"]>;
|
|
232
|
+
data: z.ZodObject<{
|
|
233
|
+
code: z.ZodString;
|
|
234
|
+
msg: z.ZodOptional<z.ZodString>;
|
|
235
|
+
}, "strip", z.ZodTypeAny, {
|
|
236
|
+
code?: string;
|
|
237
|
+
msg?: string;
|
|
238
|
+
}, {
|
|
239
|
+
code?: string;
|
|
240
|
+
msg?: string;
|
|
241
|
+
}>;
|
|
242
|
+
}>, "strip", z.ZodTypeAny, {
|
|
243
|
+
requestId?: string;
|
|
244
|
+
type?: "error";
|
|
245
|
+
v?: 1;
|
|
246
|
+
ts?: number;
|
|
247
|
+
data?: {
|
|
248
|
+
code?: string;
|
|
249
|
+
msg?: string;
|
|
250
|
+
};
|
|
251
|
+
}, {
|
|
252
|
+
requestId?: string;
|
|
253
|
+
type?: "error";
|
|
254
|
+
v?: 1;
|
|
255
|
+
ts?: number;
|
|
256
|
+
data?: {
|
|
257
|
+
code?: string;
|
|
258
|
+
msg?: string;
|
|
259
|
+
};
|
|
260
|
+
}>;
|
|
261
|
+
export const AnyEvt: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
262
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
263
|
+
v: z.ZodLiteral<1>;
|
|
264
|
+
requestId: z.ZodString;
|
|
265
|
+
ts: z.ZodNumber;
|
|
266
|
+
data: z.ZodUnknown;
|
|
267
|
+
}, {
|
|
268
|
+
type: z.ZodLiteral<"setup_required">;
|
|
269
|
+
data: z.ZodObject<{
|
|
270
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
271
|
+
}, "strip", z.ZodTypeAny, {
|
|
272
|
+
reason?: string;
|
|
273
|
+
}, {
|
|
274
|
+
reason?: string;
|
|
275
|
+
}>;
|
|
276
|
+
}>, "strip", z.ZodTypeAny, {
|
|
277
|
+
requestId?: string;
|
|
278
|
+
type?: "setup_required";
|
|
279
|
+
v?: 1;
|
|
280
|
+
ts?: number;
|
|
281
|
+
data?: {
|
|
282
|
+
reason?: string;
|
|
283
|
+
};
|
|
284
|
+
}, {
|
|
285
|
+
requestId?: string;
|
|
286
|
+
type?: "setup_required";
|
|
287
|
+
v?: 1;
|
|
288
|
+
ts?: number;
|
|
289
|
+
data?: {
|
|
290
|
+
reason?: string;
|
|
291
|
+
};
|
|
292
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
293
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
294
|
+
v: z.ZodLiteral<1>;
|
|
295
|
+
requestId: z.ZodString;
|
|
296
|
+
ts: z.ZodNumber;
|
|
297
|
+
data: z.ZodUnknown;
|
|
298
|
+
}, {
|
|
299
|
+
type: z.ZodLiteral<"open_ack">;
|
|
300
|
+
data: z.ZodObject<{
|
|
301
|
+
relayId: z.ZodString;
|
|
302
|
+
leaseMs: z.ZodNumber;
|
|
303
|
+
assignment: z.ZodObject<{
|
|
304
|
+
jwt: z.ZodString;
|
|
305
|
+
fqdn: z.ZodString;
|
|
306
|
+
proto: z.ZodString;
|
|
307
|
+
path: z.ZodString;
|
|
308
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
309
|
+
alg: z.ZodOptional<z.ZodString>;
|
|
310
|
+
exp: z.ZodOptional<z.ZodNumber>;
|
|
311
|
+
}, "strip", z.ZodTypeAny, {
|
|
312
|
+
path?: string;
|
|
313
|
+
jwt?: string;
|
|
314
|
+
fqdn?: string;
|
|
315
|
+
proto?: string;
|
|
316
|
+
kid?: string;
|
|
317
|
+
alg?: string;
|
|
318
|
+
exp?: number;
|
|
319
|
+
}, {
|
|
320
|
+
path?: string;
|
|
321
|
+
jwt?: string;
|
|
322
|
+
fqdn?: string;
|
|
323
|
+
proto?: string;
|
|
324
|
+
kid?: string;
|
|
325
|
+
alg?: string;
|
|
326
|
+
exp?: number;
|
|
327
|
+
}>;
|
|
328
|
+
}, "strip", z.ZodTypeAny, {
|
|
329
|
+
assignment?: {
|
|
330
|
+
path?: string;
|
|
331
|
+
jwt?: string;
|
|
332
|
+
fqdn?: string;
|
|
333
|
+
proto?: string;
|
|
334
|
+
kid?: string;
|
|
335
|
+
alg?: string;
|
|
336
|
+
exp?: number;
|
|
337
|
+
};
|
|
338
|
+
relayId?: string;
|
|
339
|
+
leaseMs?: number;
|
|
340
|
+
}, {
|
|
341
|
+
assignment?: {
|
|
342
|
+
path?: string;
|
|
343
|
+
jwt?: string;
|
|
344
|
+
fqdn?: string;
|
|
345
|
+
proto?: string;
|
|
346
|
+
kid?: string;
|
|
347
|
+
alg?: string;
|
|
348
|
+
exp?: number;
|
|
349
|
+
};
|
|
350
|
+
relayId?: string;
|
|
351
|
+
leaseMs?: number;
|
|
352
|
+
}>;
|
|
353
|
+
}>, "strip", z.ZodTypeAny, {
|
|
354
|
+
requestId?: string;
|
|
355
|
+
type?: "open_ack";
|
|
356
|
+
v?: 1;
|
|
357
|
+
ts?: number;
|
|
358
|
+
data?: {
|
|
359
|
+
assignment?: {
|
|
360
|
+
path?: string;
|
|
361
|
+
jwt?: string;
|
|
362
|
+
fqdn?: string;
|
|
363
|
+
proto?: string;
|
|
364
|
+
kid?: string;
|
|
365
|
+
alg?: string;
|
|
366
|
+
exp?: number;
|
|
367
|
+
};
|
|
368
|
+
relayId?: string;
|
|
369
|
+
leaseMs?: number;
|
|
370
|
+
};
|
|
371
|
+
}, {
|
|
372
|
+
requestId?: string;
|
|
373
|
+
type?: "open_ack";
|
|
374
|
+
v?: 1;
|
|
375
|
+
ts?: number;
|
|
376
|
+
data?: {
|
|
377
|
+
assignment?: {
|
|
378
|
+
path?: string;
|
|
379
|
+
jwt?: string;
|
|
380
|
+
fqdn?: string;
|
|
381
|
+
proto?: string;
|
|
382
|
+
kid?: string;
|
|
383
|
+
alg?: string;
|
|
384
|
+
exp?: number;
|
|
385
|
+
};
|
|
386
|
+
relayId?: string;
|
|
387
|
+
leaseMs?: number;
|
|
388
|
+
};
|
|
389
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
390
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
391
|
+
v: z.ZodLiteral<1>;
|
|
392
|
+
requestId: z.ZodString;
|
|
393
|
+
ts: z.ZodNumber;
|
|
394
|
+
data: z.ZodUnknown;
|
|
395
|
+
}, {
|
|
396
|
+
type: z.ZodLiteral<"open_ack">;
|
|
397
|
+
data: z.ZodObject<{
|
|
398
|
+
relayId: z.ZodString;
|
|
399
|
+
jwt: z.ZodString;
|
|
400
|
+
leaseMs: z.ZodNumber;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
relayId?: string;
|
|
403
|
+
leaseMs?: number;
|
|
404
|
+
jwt?: string;
|
|
405
|
+
}, {
|
|
406
|
+
relayId?: string;
|
|
407
|
+
leaseMs?: number;
|
|
408
|
+
jwt?: string;
|
|
409
|
+
}>;
|
|
410
|
+
}>, "strip", z.ZodTypeAny, {
|
|
411
|
+
requestId?: string;
|
|
412
|
+
type?: "open_ack";
|
|
413
|
+
v?: 1;
|
|
414
|
+
ts?: number;
|
|
415
|
+
data?: {
|
|
416
|
+
relayId?: string;
|
|
417
|
+
leaseMs?: number;
|
|
418
|
+
jwt?: string;
|
|
419
|
+
};
|
|
420
|
+
}, {
|
|
421
|
+
requestId?: string;
|
|
422
|
+
type?: "open_ack";
|
|
423
|
+
v?: 1;
|
|
424
|
+
ts?: number;
|
|
425
|
+
data?: {
|
|
426
|
+
relayId?: string;
|
|
427
|
+
leaseMs?: number;
|
|
428
|
+
jwt?: string;
|
|
429
|
+
};
|
|
430
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
431
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
432
|
+
v: z.ZodLiteral<1>;
|
|
433
|
+
requestId: z.ZodString;
|
|
434
|
+
ts: z.ZodNumber;
|
|
435
|
+
data: z.ZodUnknown;
|
|
436
|
+
}, {
|
|
437
|
+
type: z.ZodLiteral<"open_reject">;
|
|
438
|
+
data: z.ZodObject<{
|
|
439
|
+
reason: z.ZodString;
|
|
440
|
+
}, "strip", z.ZodTypeAny, {
|
|
441
|
+
reason?: string;
|
|
442
|
+
}, {
|
|
443
|
+
reason?: string;
|
|
444
|
+
}>;
|
|
445
|
+
}>, "strip", z.ZodTypeAny, {
|
|
446
|
+
requestId?: string;
|
|
447
|
+
type?: "open_reject";
|
|
448
|
+
v?: 1;
|
|
449
|
+
ts?: number;
|
|
450
|
+
data?: {
|
|
451
|
+
reason?: string;
|
|
452
|
+
};
|
|
453
|
+
}, {
|
|
454
|
+
requestId?: string;
|
|
455
|
+
type?: "open_reject";
|
|
456
|
+
v?: 1;
|
|
457
|
+
ts?: number;
|
|
458
|
+
data?: {
|
|
459
|
+
reason?: string;
|
|
460
|
+
};
|
|
461
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
462
|
+
type: z.ZodEnum<["setup_required", "open_ack", "open_reject", "error"]>;
|
|
463
|
+
v: z.ZodLiteral<1>;
|
|
464
|
+
requestId: z.ZodString;
|
|
465
|
+
ts: z.ZodNumber;
|
|
466
|
+
data: z.ZodUnknown;
|
|
467
|
+
}, {
|
|
468
|
+
type: z.ZodEnum<["error"]>;
|
|
469
|
+
data: z.ZodObject<{
|
|
470
|
+
code: z.ZodString;
|
|
471
|
+
msg: z.ZodOptional<z.ZodString>;
|
|
472
|
+
}, "strip", z.ZodTypeAny, {
|
|
473
|
+
code?: string;
|
|
474
|
+
msg?: string;
|
|
475
|
+
}, {
|
|
476
|
+
code?: string;
|
|
477
|
+
msg?: string;
|
|
478
|
+
}>;
|
|
479
|
+
}>, "strip", z.ZodTypeAny, {
|
|
480
|
+
requestId?: string;
|
|
481
|
+
type?: "error";
|
|
482
|
+
v?: 1;
|
|
483
|
+
ts?: number;
|
|
484
|
+
data?: {
|
|
485
|
+
code?: string;
|
|
486
|
+
msg?: string;
|
|
487
|
+
};
|
|
488
|
+
}, {
|
|
489
|
+
requestId?: string;
|
|
490
|
+
type?: "error";
|
|
491
|
+
v?: 1;
|
|
492
|
+
ts?: number;
|
|
493
|
+
data?: {
|
|
494
|
+
code?: string;
|
|
495
|
+
msg?: string;
|
|
496
|
+
};
|
|
497
|
+
}>]>;
|
|
498
|
+
import { z } from "zod";
|