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