@rstreamlabs/tunnels 1.0.6 → 1.0.7
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/dist/chunk-OPJKEDVS.mjs +739 -0
- package/dist/index.d.mts +73 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.js +408 -32
- package/dist/index.mjs +90 -418
- package/dist/openapi.d.mts +310 -0
- package/dist/openapi.d.ts +310 -0
- package/dist/openapi.js +753 -0
- package/dist/openapi.mjs +8 -0
- package/package.json +6 -1
package/dist/openapi.js
ADDED
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/openapi.ts
|
|
31
|
+
var openapi_exports = {};
|
|
32
|
+
__export(openapi_exports, {
|
|
33
|
+
engineOpenApiDocument: () => engineOpenApiDocument,
|
|
34
|
+
engineOpenApiJson: () => engineOpenApiJson
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(openapi_exports);
|
|
37
|
+
|
|
38
|
+
// src/client.ts
|
|
39
|
+
var z = __toESM(require("zod"));
|
|
40
|
+
var clientSchema = z.object({
|
|
41
|
+
id: z.string(),
|
|
42
|
+
status: z.enum(["online", "offline"]),
|
|
43
|
+
user_id: z.string().optional(),
|
|
44
|
+
workspace_id: z.string().optional(),
|
|
45
|
+
project_id: z.string().optional(),
|
|
46
|
+
cluster_id: z.string().optional(),
|
|
47
|
+
plan: z.string().optional(),
|
|
48
|
+
provider: z.string().optional(),
|
|
49
|
+
region: z.string().optional(),
|
|
50
|
+
agent: z.string().optional(),
|
|
51
|
+
channel: z.string().optional(),
|
|
52
|
+
version: z.string().optional(),
|
|
53
|
+
os: z.string().optional(),
|
|
54
|
+
arch: z.string().optional(),
|
|
55
|
+
protocol_version: z.string().optional(),
|
|
56
|
+
labels: z.record(z.string(), z.string()).optional()
|
|
57
|
+
});
|
|
58
|
+
var clientFilterSchema = clientSchema.pick({
|
|
59
|
+
id: true,
|
|
60
|
+
status: true,
|
|
61
|
+
user_id: true,
|
|
62
|
+
agent: true,
|
|
63
|
+
channel: true,
|
|
64
|
+
version: true,
|
|
65
|
+
os: true,
|
|
66
|
+
arch: true,
|
|
67
|
+
protocol_version: true,
|
|
68
|
+
labels: true
|
|
69
|
+
}).partial();
|
|
70
|
+
var listClientsParamsSchema = z.object({
|
|
71
|
+
limit: z.number().int().min(1).optional(),
|
|
72
|
+
filters: clientFilterSchema.optional()
|
|
73
|
+
});
|
|
74
|
+
var listClientsResponseSchema = z.array(clientSchema);
|
|
75
|
+
|
|
76
|
+
// src/tunnel.ts
|
|
77
|
+
var z2 = __toESM(require("zod"));
|
|
78
|
+
var tunnelSchema = z2.object({
|
|
79
|
+
// common properties
|
|
80
|
+
client_id: z2.string(),
|
|
81
|
+
user_id: z2.string().optional(),
|
|
82
|
+
workspace_id: z2.string().optional(),
|
|
83
|
+
project_id: z2.string().optional(),
|
|
84
|
+
cluster_id: z2.string().optional(),
|
|
85
|
+
plan: z2.string().optional(),
|
|
86
|
+
provider: z2.string().optional(),
|
|
87
|
+
region: z2.string().optional(),
|
|
88
|
+
status: z2.enum(["online", "offline"]),
|
|
89
|
+
// tunnel properties
|
|
90
|
+
id: z2.string(),
|
|
91
|
+
creation_date: z2.union([z2.string().datetime(), z2.date()]).optional(),
|
|
92
|
+
name: z2.string().optional(),
|
|
93
|
+
type: z2.enum(["bytestream", "datagram"]).optional(),
|
|
94
|
+
publish: z2.boolean().optional(),
|
|
95
|
+
protocol: z2.enum(["tls", "dtls", "quic", "http"]).optional(),
|
|
96
|
+
labels: z2.record(z2.string(), z2.string()).optional(),
|
|
97
|
+
geo_ip: z2.array(z2.string()).optional(),
|
|
98
|
+
trusted_ips: z2.array(z2.string()).optional(),
|
|
99
|
+
host: z2.string().optional(),
|
|
100
|
+
hostname: z2.string().optional(),
|
|
101
|
+
port: z2.number().int().min(1).max(65535).optional(),
|
|
102
|
+
tls_mode: z2.enum(["passthrough", "terminated"]).optional(),
|
|
103
|
+
tls_alpns: z2.array(z2.string()).optional(),
|
|
104
|
+
tls_min_version: z2.string().optional(),
|
|
105
|
+
tls_ciphers: z2.array(z2.string()).optional(),
|
|
106
|
+
mtls: z2.boolean().optional(),
|
|
107
|
+
mtls_ca_cert_pem: z2.string().optional(),
|
|
108
|
+
http_version: z2.enum(["http/1.1", "h2", "h2c", "h3"]).optional(),
|
|
109
|
+
http_use_tls: z2.boolean().optional(),
|
|
110
|
+
upstream_tls: z2.boolean().optional(),
|
|
111
|
+
token_auth: z2.boolean().optional(),
|
|
112
|
+
rstream_auth: z2.boolean().optional(),
|
|
113
|
+
challenge_mode: z2.boolean().optional()
|
|
114
|
+
});
|
|
115
|
+
var tunnelFilterSchema = tunnelSchema.pick({
|
|
116
|
+
id: true,
|
|
117
|
+
name: true,
|
|
118
|
+
type: true,
|
|
119
|
+
status: true,
|
|
120
|
+
client_id: true,
|
|
121
|
+
user_id: true,
|
|
122
|
+
publish: true,
|
|
123
|
+
protocol: true,
|
|
124
|
+
hostname: true,
|
|
125
|
+
http_version: true,
|
|
126
|
+
labels: true
|
|
127
|
+
}).partial();
|
|
128
|
+
var listTunnelsParamsSchema = z2.object({
|
|
129
|
+
limit: z2.number().int().min(1).optional(),
|
|
130
|
+
filters: tunnelFilterSchema.optional()
|
|
131
|
+
});
|
|
132
|
+
var listTunnelsResponseSchema = z2.array(tunnelSchema);
|
|
133
|
+
|
|
134
|
+
// src/stream.ts
|
|
135
|
+
var z3 = __toESM(require("zod"));
|
|
136
|
+
var nonEmptyStringSchema = z3.string().min(1);
|
|
137
|
+
var isoDateTimeSchema = z3.string().datetime({ offset: true });
|
|
138
|
+
var ipAddressSchema = z3.string();
|
|
139
|
+
var intNonNegSchema = z3.number().int().nonnegative();
|
|
140
|
+
var numNonNegSchema = z3.number().nonnegative();
|
|
141
|
+
var geolocationSchema = z3.object({
|
|
142
|
+
country: z3.string().optional(),
|
|
143
|
+
region: z3.string().optional()
|
|
144
|
+
});
|
|
145
|
+
var streamTLSInfoSchema = z3.object({
|
|
146
|
+
version: z3.string().min(1).optional(),
|
|
147
|
+
cipher: z3.string().min(1).optional(),
|
|
148
|
+
protocol: z3.string().min(1).optional(),
|
|
149
|
+
curve: z3.string().min(1).optional(),
|
|
150
|
+
ech: z3.boolean().optional()
|
|
151
|
+
});
|
|
152
|
+
var streamEndpointSchema = z3.object({
|
|
153
|
+
ip: ipAddressSchema.optional(),
|
|
154
|
+
geolocation: geolocationSchema.optional(),
|
|
155
|
+
tls: streamTLSInfoSchema.optional()
|
|
156
|
+
});
|
|
157
|
+
var httpHeadersSchema = z3.record(
|
|
158
|
+
z3.string(),
|
|
159
|
+
z3.union([z3.string(), z3.array(z3.string())])
|
|
160
|
+
);
|
|
161
|
+
var httpProtocolSchema = z3.enum(["http/1.1", "h2", "h2c", "h3"]);
|
|
162
|
+
var httpRequestSchema = z3.object({
|
|
163
|
+
method: nonEmptyStringSchema,
|
|
164
|
+
scheme: z3.string().min(1).optional(),
|
|
165
|
+
host: nonEmptyStringSchema.optional(),
|
|
166
|
+
path: nonEmptyStringSchema.optional(),
|
|
167
|
+
query: z3.string().optional(),
|
|
168
|
+
url: nonEmptyStringSchema.optional(),
|
|
169
|
+
headers: httpHeadersSchema.optional(),
|
|
170
|
+
userAgent: z3.string().optional()
|
|
171
|
+
});
|
|
172
|
+
var httpResponseSchema = z3.object({
|
|
173
|
+
status: z3.number().int().min(100).max(999),
|
|
174
|
+
headers: httpHeadersSchema.optional()
|
|
175
|
+
});
|
|
176
|
+
var httpRequestStageSchema = z3.object({
|
|
177
|
+
protocol: httpProtocolSchema.optional(),
|
|
178
|
+
request: httpRequestSchema
|
|
179
|
+
});
|
|
180
|
+
var httpResponseStageSchema = z3.object({
|
|
181
|
+
protocol: httpProtocolSchema.optional(),
|
|
182
|
+
response: httpResponseSchema
|
|
183
|
+
});
|
|
184
|
+
var tokenSourceSchema = z3.enum([
|
|
185
|
+
"authorization",
|
|
186
|
+
"query",
|
|
187
|
+
"client",
|
|
188
|
+
"unknown"
|
|
189
|
+
]);
|
|
190
|
+
var tokenTypeSchema = z3.enum(["auth", "pat", "app", "unknown"]);
|
|
191
|
+
var firewallRuleSchema = z3.discriminatedUnion("kind", [
|
|
192
|
+
z3.object({ kind: z3.literal("none") }),
|
|
193
|
+
z3.object({ kind: z3.literal("mtls") }),
|
|
194
|
+
z3.object({
|
|
195
|
+
kind: z3.literal("rstream_auth"),
|
|
196
|
+
source: z3.literal("rstream_auth")
|
|
197
|
+
}),
|
|
198
|
+
z3.object({
|
|
199
|
+
kind: z3.literal("token"),
|
|
200
|
+
source: tokenSourceSchema.optional(),
|
|
201
|
+
tokenType: tokenTypeSchema.optional()
|
|
202
|
+
})
|
|
203
|
+
]);
|
|
204
|
+
var unauthorizedSourceSchema = z3.object({
|
|
205
|
+
source: tokenSourceSchema
|
|
206
|
+
});
|
|
207
|
+
var unauthorizedReasonSchema = (shape) => z3.object(shape).merge(unauthorizedSourceSchema);
|
|
208
|
+
var unauthorizedSchema = z3.discriminatedUnion("reason", [
|
|
209
|
+
unauthorizedReasonSchema({
|
|
210
|
+
reason: z3.literal("missing_token")
|
|
211
|
+
}),
|
|
212
|
+
unauthorizedReasonSchema({
|
|
213
|
+
reason: z3.literal("invalid_token")
|
|
214
|
+
}),
|
|
215
|
+
unauthorizedReasonSchema({
|
|
216
|
+
reason: z3.literal("expired_token")
|
|
217
|
+
}),
|
|
218
|
+
unauthorizedReasonSchema({
|
|
219
|
+
reason: z3.literal("invalid_secret")
|
|
220
|
+
}),
|
|
221
|
+
unauthorizedReasonSchema({
|
|
222
|
+
reason: z3.literal("user_mismatch")
|
|
223
|
+
}),
|
|
224
|
+
unauthorizedReasonSchema({
|
|
225
|
+
reason: z3.literal("insufficient_scope")
|
|
226
|
+
}),
|
|
227
|
+
unauthorizedReasonSchema({
|
|
228
|
+
reason: z3.literal("policy_denied"),
|
|
229
|
+
policy: z3.enum(["ip", "geo", "mtls", "challenge", "other"]),
|
|
230
|
+
value: z3.string().optional()
|
|
231
|
+
})
|
|
232
|
+
]);
|
|
233
|
+
var failureSchema = z3.discriminatedUnion("kind", [
|
|
234
|
+
z3.object({
|
|
235
|
+
kind: z3.literal("timeout"),
|
|
236
|
+
timeoutMs: intNonNegSchema.optional(),
|
|
237
|
+
message: z3.string().optional()
|
|
238
|
+
}),
|
|
239
|
+
z3.object({
|
|
240
|
+
kind: z3.literal("unauthorized"),
|
|
241
|
+
why: unauthorizedSchema,
|
|
242
|
+
message: z3.string().optional()
|
|
243
|
+
}),
|
|
244
|
+
z3.object({
|
|
245
|
+
kind: z3.literal("not_found"),
|
|
246
|
+
resource: z3.enum(["tunnel", "client", "route"]),
|
|
247
|
+
message: z3.string().optional()
|
|
248
|
+
}),
|
|
249
|
+
z3.object({
|
|
250
|
+
kind: z3.literal("refused"),
|
|
251
|
+
reason: z3.enum(["capacity", "policy", "unsupported", "other"]),
|
|
252
|
+
message: z3.string().optional()
|
|
253
|
+
}),
|
|
254
|
+
z3.object({ kind: z3.literal("io"), message: z3.string().optional() }),
|
|
255
|
+
z3.object({ kind: z3.literal("internal"), message: z3.string().optional() })
|
|
256
|
+
]);
|
|
257
|
+
var firewallSchema = z3.discriminatedUnion("decision", [
|
|
258
|
+
z3.object({ decision: z3.literal("allowed"), rule: firewallRuleSchema }),
|
|
259
|
+
z3.object({
|
|
260
|
+
decision: z3.literal("denied"),
|
|
261
|
+
rule: firewallRuleSchema,
|
|
262
|
+
failure: failureSchema
|
|
263
|
+
})
|
|
264
|
+
]);
|
|
265
|
+
var routedTunnelSchema = z3.object({
|
|
266
|
+
tunnelId: nonEmptyStringSchema.optional(),
|
|
267
|
+
tunnelName: z3.string().optional(),
|
|
268
|
+
hostname: z3.string().optional(),
|
|
269
|
+
protocol: z3.string().optional(),
|
|
270
|
+
published: z3.boolean().optional(),
|
|
271
|
+
type: z3.string().optional(),
|
|
272
|
+
tlsMode: z3.string().optional(),
|
|
273
|
+
httpVersion: z3.string().optional(),
|
|
274
|
+
httpUseTls: z3.boolean().optional(),
|
|
275
|
+
upstreamTls: z3.boolean().optional(),
|
|
276
|
+
tokenAuth: z3.boolean().optional(),
|
|
277
|
+
mtls: z3.boolean().optional()
|
|
278
|
+
});
|
|
279
|
+
var routingSchema = z3.discriminatedUnion("decision", [
|
|
280
|
+
z3.object({ decision: z3.literal("routed"), tunnel: routedTunnelSchema }),
|
|
281
|
+
z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
|
|
282
|
+
]);
|
|
283
|
+
var streamConnectedMetricsSchema = z3.object({
|
|
284
|
+
establish_ms: numNonNegSchema,
|
|
285
|
+
duration_ms: numNonNegSchema,
|
|
286
|
+
upstream_bytes: intNonNegSchema,
|
|
287
|
+
downstream_bytes: intNonNegSchema
|
|
288
|
+
});
|
|
289
|
+
var streamFailedMetricsSchema = z3.object({
|
|
290
|
+
time_to_fail_ms: numNonNegSchema.optional(),
|
|
291
|
+
establish_ms: numNonNegSchema.optional()
|
|
292
|
+
});
|
|
293
|
+
var terminationSchema = z3.object({
|
|
294
|
+
by: z3.enum(["downstream", "upstream", "server", "unknown"]),
|
|
295
|
+
reason: z3.enum(["closed", "reset", "timeout", "error", "unknown"]),
|
|
296
|
+
message: z3.string().optional()
|
|
297
|
+
});
|
|
298
|
+
var responseConnectedSchema = z3.object({
|
|
299
|
+
outcome: z3.literal("connected"),
|
|
300
|
+
established_at: isoDateTimeSchema,
|
|
301
|
+
upstream: streamEndpointSchema.optional(),
|
|
302
|
+
metrics: streamConnectedMetricsSchema,
|
|
303
|
+
termination: terminationSchema.optional(),
|
|
304
|
+
http: httpResponseStageSchema.optional()
|
|
305
|
+
});
|
|
306
|
+
var responseFailedSchema = z3.object({
|
|
307
|
+
outcome: z3.literal("failed"),
|
|
308
|
+
failure: failureSchema,
|
|
309
|
+
upstream: streamEndpointSchema.optional(),
|
|
310
|
+
metrics: streamFailedMetricsSchema.optional(),
|
|
311
|
+
termination: terminationSchema.optional(),
|
|
312
|
+
http: httpResponseStageSchema.optional()
|
|
313
|
+
});
|
|
314
|
+
var responseSchema = z3.discriminatedUnion("outcome", [
|
|
315
|
+
responseConnectedSchema,
|
|
316
|
+
responseFailedSchema
|
|
317
|
+
]);
|
|
318
|
+
var streamSummarySchema = z3.object({
|
|
319
|
+
workspace_id: nonEmptyStringSchema.optional(),
|
|
320
|
+
project_id: nonEmptyStringSchema.optional(),
|
|
321
|
+
cluster_id: nonEmptyStringSchema.optional(),
|
|
322
|
+
user_id: nonEmptyStringSchema.optional(),
|
|
323
|
+
client_id: nonEmptyStringSchema.optional(),
|
|
324
|
+
tunnel_id: nonEmptyStringSchema.optional(),
|
|
325
|
+
stream_id: nonEmptyStringSchema,
|
|
326
|
+
created_at: isoDateTimeSchema,
|
|
327
|
+
terminated_at: isoDateTimeSchema,
|
|
328
|
+
request: z3.object({
|
|
329
|
+
downstream: streamEndpointSchema,
|
|
330
|
+
http: httpRequestStageSchema.optional()
|
|
331
|
+
}),
|
|
332
|
+
firewall: firewallSchema,
|
|
333
|
+
routing: routingSchema,
|
|
334
|
+
response: responseSchema
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// src/event.ts
|
|
338
|
+
var z4 = __toESM(require("zod"));
|
|
339
|
+
var isoDateTimeSchema2 = z4.string().datetime({ offset: true });
|
|
340
|
+
var initialStateSchema = z4.object({
|
|
341
|
+
snapshot_at: isoDateTimeSchema2,
|
|
342
|
+
clients: z4.array(clientSchema),
|
|
343
|
+
tunnels: z4.array(tunnelSchema)
|
|
344
|
+
});
|
|
345
|
+
var eventBaseSchema = z4.object({
|
|
346
|
+
id: z4.string().optional(),
|
|
347
|
+
created_at: isoDateTimeSchema2.optional(),
|
|
348
|
+
user_id: z4.string().optional(),
|
|
349
|
+
workspace_id: z4.string().optional(),
|
|
350
|
+
project_id: z4.string().optional(),
|
|
351
|
+
cluster_id: z4.string().optional()
|
|
352
|
+
});
|
|
353
|
+
var withEventBase = (shape) => z4.object(shape).merge(eventBaseSchema).passthrough();
|
|
354
|
+
var stateInitialEventSchema = withEventBase({
|
|
355
|
+
type: z4.literal("state.initial"),
|
|
356
|
+
object: initialStateSchema
|
|
357
|
+
});
|
|
358
|
+
var streamSummaryEventSchema = withEventBase({
|
|
359
|
+
type: z4.literal("stream.summary"),
|
|
360
|
+
object: streamSummarySchema
|
|
361
|
+
});
|
|
362
|
+
var commonEventsSchema = [
|
|
363
|
+
withEventBase({
|
|
364
|
+
type: z4.literal("client.created"),
|
|
365
|
+
object: clientSchema
|
|
366
|
+
}),
|
|
367
|
+
withEventBase({
|
|
368
|
+
type: z4.literal("client.updated"),
|
|
369
|
+
object: clientSchema
|
|
370
|
+
}),
|
|
371
|
+
withEventBase({
|
|
372
|
+
type: z4.literal("client.deleted"),
|
|
373
|
+
object: clientSchema
|
|
374
|
+
}),
|
|
375
|
+
withEventBase({
|
|
376
|
+
type: z4.literal("tunnel.created"),
|
|
377
|
+
object: tunnelSchema
|
|
378
|
+
}),
|
|
379
|
+
withEventBase({
|
|
380
|
+
type: z4.literal("tunnel.updated"),
|
|
381
|
+
object: tunnelSchema
|
|
382
|
+
}),
|
|
383
|
+
withEventBase({
|
|
384
|
+
type: z4.literal("tunnel.deleted"),
|
|
385
|
+
object: tunnelSchema
|
|
386
|
+
})
|
|
387
|
+
];
|
|
388
|
+
var wsEventsSchema = z4.union([
|
|
389
|
+
stateInitialEventSchema,
|
|
390
|
+
...commonEventsSchema
|
|
391
|
+
]);
|
|
392
|
+
var webhookEventsSchema = z4.union([
|
|
393
|
+
...commonEventsSchema,
|
|
394
|
+
streamSummaryEventSchema
|
|
395
|
+
]);
|
|
396
|
+
var eventSchema = z4.union([wsEventsSchema, webhookEventsSchema]);
|
|
397
|
+
|
|
398
|
+
// src/openapi.ts
|
|
399
|
+
var z5 = __toESM(require("zod"));
|
|
400
|
+
var jsonContentType = "application/json";
|
|
401
|
+
var openApiContentType = "application/vnd.oai.openapi+json;version=3.1";
|
|
402
|
+
function isRecord(value) {
|
|
403
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
404
|
+
}
|
|
405
|
+
function dropSchemaKeyword(value) {
|
|
406
|
+
if (!isRecord(value)) return value;
|
|
407
|
+
return Object.fromEntries(
|
|
408
|
+
Object.entries(value).filter(([key]) => key !== "$schema")
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function jsonSchemaFor(schema) {
|
|
412
|
+
return dropSchemaKeyword(
|
|
413
|
+
z5.toJSONSchema(schema, {
|
|
414
|
+
unrepresentable: "any",
|
|
415
|
+
override: (ctx) => {
|
|
416
|
+
if (ctx.zodSchema instanceof z5.ZodDate) {
|
|
417
|
+
ctx.jsonSchema.type = "string";
|
|
418
|
+
ctx.jsonSchema.format = "date-time";
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
})
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
function jsonArrayResponse(description, itemSchemaRef) {
|
|
425
|
+
return {
|
|
426
|
+
description,
|
|
427
|
+
content: {
|
|
428
|
+
[jsonContentType]: {
|
|
429
|
+
schema: {
|
|
430
|
+
type: "array",
|
|
431
|
+
items: {
|
|
432
|
+
$ref: itemSchemaRef
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function streamResponse(description) {
|
|
440
|
+
return {
|
|
441
|
+
description,
|
|
442
|
+
content: {
|
|
443
|
+
"text/event-stream": {
|
|
444
|
+
schema: {
|
|
445
|
+
type: "string"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function errorResponse(description) {
|
|
452
|
+
return {
|
|
453
|
+
description
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function queryJsonParameter(name, description, schemaRef, examples) {
|
|
457
|
+
return {
|
|
458
|
+
name,
|
|
459
|
+
in: "query",
|
|
460
|
+
required: false,
|
|
461
|
+
description,
|
|
462
|
+
content: {
|
|
463
|
+
[jsonContentType]: {
|
|
464
|
+
schema: {
|
|
465
|
+
$ref: schemaRef
|
|
466
|
+
},
|
|
467
|
+
...examples ? { examples } : {}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
var readEngineStateRule = {
|
|
473
|
+
resource: ["engine.tunnels", "engine.streams"],
|
|
474
|
+
action: "read"
|
|
475
|
+
};
|
|
476
|
+
var readEngineStateRules = [readEngineStateRule];
|
|
477
|
+
var readEngineStreamsRules = [
|
|
478
|
+
{
|
|
479
|
+
resource: "engine.streams",
|
|
480
|
+
action: "read"
|
|
481
|
+
}
|
|
482
|
+
];
|
|
483
|
+
var watchParamsSchema = z5.object({
|
|
484
|
+
clients: clientFilterSchema.optional(),
|
|
485
|
+
tunnels: tunnelFilterSchema.optional()
|
|
486
|
+
});
|
|
487
|
+
var enginePermissions = {
|
|
488
|
+
"tunnels.resources.read-only": {
|
|
489
|
+
name: "Discovery: Read-Only",
|
|
490
|
+
description: "Read active clients, active tunnels, and live state events.",
|
|
491
|
+
rules: [readEngineStateRule]
|
|
492
|
+
},
|
|
493
|
+
"tunnels.tunnels.create-delete": {
|
|
494
|
+
name: "Tunnels: Create and Delete",
|
|
495
|
+
description: "Create and close tunnels through the CLI, SDK, or engine control channel.",
|
|
496
|
+
rules: [
|
|
497
|
+
{
|
|
498
|
+
resource: "engine.tunnels",
|
|
499
|
+
action: ["create", "delete"]
|
|
500
|
+
}
|
|
501
|
+
]
|
|
502
|
+
},
|
|
503
|
+
"tunnels.streams.create-delete": {
|
|
504
|
+
name: "Connections: Create and Delete",
|
|
505
|
+
description: "Open and close private tunnel streams and WebTTY connections.",
|
|
506
|
+
rules: [
|
|
507
|
+
{
|
|
508
|
+
resource: "engine.streams",
|
|
509
|
+
action: ["create", "delete"]
|
|
510
|
+
}
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
var engineOpenApiDocument = {
|
|
515
|
+
openapi: "3.1.0",
|
|
516
|
+
info: {
|
|
517
|
+
title: "rstream Engine API",
|
|
518
|
+
version: "1.0.0",
|
|
519
|
+
description: "Operational data-plane API exposed by rstream-engine. This surface is scoped to the authenticated engine or project endpoint and covers live clients, live tunnels, and state-change streams."
|
|
520
|
+
},
|
|
521
|
+
servers: [
|
|
522
|
+
{
|
|
523
|
+
url: "https://{engine}",
|
|
524
|
+
description: "Project-scoped rstream engine endpoint.",
|
|
525
|
+
variables: {
|
|
526
|
+
engine: {
|
|
527
|
+
default: "project-endpoint.cluster-host:443",
|
|
528
|
+
description: "Use the engine value returned by project discovery or configured in RSTREAM_ENGINE."
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
],
|
|
533
|
+
security: [
|
|
534
|
+
{
|
|
535
|
+
bearerAuth: []
|
|
536
|
+
}
|
|
537
|
+
],
|
|
538
|
+
components: {
|
|
539
|
+
securitySchemes: {
|
|
540
|
+
bearerAuth: {
|
|
541
|
+
type: "http",
|
|
542
|
+
scheme: "bearer",
|
|
543
|
+
bearerFormat: "rstream token",
|
|
544
|
+
description: "Preferred authentication mechanism. Send an OAuth-issued rstream access token or compatible rstream credential in Authorization: Bearer <token>."
|
|
545
|
+
},
|
|
546
|
+
queryToken: {
|
|
547
|
+
type: "apiKey",
|
|
548
|
+
in: "query",
|
|
549
|
+
name: "rstream.token",
|
|
550
|
+
description: "Fallback authentication mechanism for transports where setting Authorization is impractical. Prefer bearerAuth whenever possible."
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
parameters: {
|
|
554
|
+
ListClientsParams: queryJsonParameter(
|
|
555
|
+
"params",
|
|
556
|
+
"JSON-encoded ListClientsParams object.",
|
|
557
|
+
"#/components/schemas/ListClientsParams",
|
|
558
|
+
{
|
|
559
|
+
filterByAgent: {
|
|
560
|
+
value: {
|
|
561
|
+
limit: 10,
|
|
562
|
+
filters: {
|
|
563
|
+
agent: "rstream",
|
|
564
|
+
channel: "stable"
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
),
|
|
570
|
+
ListTunnelsParams: queryJsonParameter(
|
|
571
|
+
"params",
|
|
572
|
+
"JSON-encoded ListTunnelsParams object.",
|
|
573
|
+
"#/components/schemas/ListTunnelsParams",
|
|
574
|
+
{
|
|
575
|
+
filterByLabels: {
|
|
576
|
+
value: {
|
|
577
|
+
filters: {
|
|
578
|
+
labels: {
|
|
579
|
+
service: "ssh",
|
|
580
|
+
env: "prod"
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
),
|
|
587
|
+
WatchParams: queryJsonParameter(
|
|
588
|
+
"params",
|
|
589
|
+
"JSON-encoded WatchParams object. The same shape is accepted by SSE and WebSocket transports.",
|
|
590
|
+
"#/components/schemas/WatchParams",
|
|
591
|
+
{
|
|
592
|
+
watchTaggedTunnels: {
|
|
593
|
+
value: {
|
|
594
|
+
clients: {
|
|
595
|
+
agent: "rstream"
|
|
596
|
+
},
|
|
597
|
+
tunnels: {
|
|
598
|
+
labels: {
|
|
599
|
+
service: "ssh"
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
)
|
|
606
|
+
},
|
|
607
|
+
responses: {
|
|
608
|
+
BadRequest: errorResponse("Request validation failed."),
|
|
609
|
+
Unauthorized: errorResponse("Authentication is required."),
|
|
610
|
+
Forbidden: errorResponse("The token is not authorized.")
|
|
611
|
+
},
|
|
612
|
+
schemas: {
|
|
613
|
+
Client: jsonSchemaFor(clientSchema),
|
|
614
|
+
Event: jsonSchemaFor(wsEventsSchema),
|
|
615
|
+
ListClientsParams: jsonSchemaFor(listClientsParamsSchema),
|
|
616
|
+
ListTunnelsParams: jsonSchemaFor(listTunnelsParamsSchema),
|
|
617
|
+
TunnelListItem: jsonSchemaFor(tunnelSchema),
|
|
618
|
+
WatchParams: jsonSchemaFor(watchParamsSchema)
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
"x-rstream-agent-authentication": {
|
|
622
|
+
oauth_authorization_server_metadata: "https://rstream.io/.well-known/oauth-authorization-server",
|
|
623
|
+
oauth_protected_resource_metadata: "https://rstream.io/.well-known/oauth-protected-resource",
|
|
624
|
+
scope_selection: "Use x-rstream-required-rules to understand backend authorization checks. Choose OAuth scopes from x-rstream-permissions or use the task bundles in x-rstream-use-case-permissions."
|
|
625
|
+
},
|
|
626
|
+
"x-rstream-permissions": enginePermissions,
|
|
627
|
+
"x-rstream-use-case-permissions": {
|
|
628
|
+
"inspect-engine-state": ["tunnels.resources.read-only"],
|
|
629
|
+
"expose-service-from-cli": [
|
|
630
|
+
"tunnels.resources.read-only",
|
|
631
|
+
"tunnels.tunnels.create-delete"
|
|
632
|
+
],
|
|
633
|
+
"connect-private-tunnel": [
|
|
634
|
+
"tunnels.resources.read-only",
|
|
635
|
+
"tunnels.streams.create-delete"
|
|
636
|
+
],
|
|
637
|
+
"operate-webtty": [
|
|
638
|
+
"tunnels.resources.read-only",
|
|
639
|
+
"tunnels.tunnels.create-delete",
|
|
640
|
+
"tunnels.streams.create-delete"
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
paths: {
|
|
644
|
+
"/api/openapi.json": {
|
|
645
|
+
get: {
|
|
646
|
+
tags: ["Discovery"],
|
|
647
|
+
summary: "Return this OpenAPI description.",
|
|
648
|
+
operationId: "get_engine_openapi",
|
|
649
|
+
security: [],
|
|
650
|
+
responses: {
|
|
651
|
+
"200": {
|
|
652
|
+
description: "OpenAPI document.",
|
|
653
|
+
content: {
|
|
654
|
+
[openApiContentType]: {
|
|
655
|
+
schema: {
|
|
656
|
+
type: "object"
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
"/api/clients": {
|
|
665
|
+
get: {
|
|
666
|
+
tags: ["Runtime inventory"],
|
|
667
|
+
summary: "List visible engine clients.",
|
|
668
|
+
operationId: "list_engine_clients",
|
|
669
|
+
parameters: [{ $ref: "#/components/parameters/ListClientsParams" }],
|
|
670
|
+
security: [{ bearerAuth: [] }, { queryToken: [] }],
|
|
671
|
+
responses: {
|
|
672
|
+
"200": jsonArrayResponse(
|
|
673
|
+
"Visible clients.",
|
|
674
|
+
"#/components/schemas/Client"
|
|
675
|
+
),
|
|
676
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
677
|
+
"401": { $ref: "#/components/responses/Unauthorized" },
|
|
678
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
679
|
+
},
|
|
680
|
+
"x-rstream-required-rules": readEngineStreamsRules
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
"/api/tunnels": {
|
|
684
|
+
get: {
|
|
685
|
+
tags: ["Runtime inventory"],
|
|
686
|
+
summary: "List visible engine tunnels.",
|
|
687
|
+
operationId: "list_engine_tunnels",
|
|
688
|
+
parameters: [{ $ref: "#/components/parameters/ListTunnelsParams" }],
|
|
689
|
+
security: [{ bearerAuth: [] }, { queryToken: [] }],
|
|
690
|
+
responses: {
|
|
691
|
+
"200": jsonArrayResponse(
|
|
692
|
+
"Visible tunnels. Fine-grained list scopes may filter objects and project fields.",
|
|
693
|
+
"#/components/schemas/TunnelListItem"
|
|
694
|
+
),
|
|
695
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
696
|
+
"401": { $ref: "#/components/responses/Unauthorized" },
|
|
697
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
698
|
+
},
|
|
699
|
+
"x-rstream-required-rules": readEngineStateRules,
|
|
700
|
+
"x-rstream-token-metadata-scope": "metadata.scopes.tunnels.list"
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
"/api/sse": {
|
|
704
|
+
get: {
|
|
705
|
+
tags: ["Runtime watch"],
|
|
706
|
+
summary: "Subscribe to visible engine state through Server-Sent Events.",
|
|
707
|
+
operationId: "watch_engine_events_sse",
|
|
708
|
+
parameters: [{ $ref: "#/components/parameters/WatchParams" }],
|
|
709
|
+
security: [{ bearerAuth: [] }, { queryToken: [] }],
|
|
710
|
+
responses: {
|
|
711
|
+
"200": streamResponse(
|
|
712
|
+
"SSE stream. Each event is emitted as a data line containing a JSON Event object."
|
|
713
|
+
),
|
|
714
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
715
|
+
"401": { $ref: "#/components/responses/Unauthorized" },
|
|
716
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
717
|
+
},
|
|
718
|
+
"x-rstream-event-schema": "#/components/schemas/Event",
|
|
719
|
+
"x-rstream-required-rules": readEngineStateRules
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
"/api/websocket": {
|
|
723
|
+
get: {
|
|
724
|
+
tags: ["Runtime watch"],
|
|
725
|
+
summary: "Subscribe to visible engine state through a WebSocket upgrade.",
|
|
726
|
+
operationId: "watch_engine_events_websocket",
|
|
727
|
+
parameters: [{ $ref: "#/components/parameters/WatchParams" }],
|
|
728
|
+
security: [{ bearerAuth: [] }, { queryToken: [] }],
|
|
729
|
+
responses: {
|
|
730
|
+
"101": {
|
|
731
|
+
description: "WebSocket connection accepted. Frames contain JSON Event objects."
|
|
732
|
+
},
|
|
733
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
734
|
+
"401": { $ref: "#/components/responses/Unauthorized" },
|
|
735
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
736
|
+
},
|
|
737
|
+
"x-rstream-event-schema": "#/components/schemas/Event",
|
|
738
|
+
"x-rstream-required-rules": readEngineStateRules
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
var engineOpenApiJson = `${JSON.stringify(
|
|
744
|
+
engineOpenApiDocument,
|
|
745
|
+
null,
|
|
746
|
+
2
|
|
747
|
+
)}
|
|
748
|
+
`;
|
|
749
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
750
|
+
0 && (module.exports = {
|
|
751
|
+
engineOpenApiDocument,
|
|
752
|
+
engineOpenApiJson
|
|
753
|
+
});
|