@rstreamlabs/tunnels 1.0.5 → 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 +363 -1
- package/dist/index.d.ts +363 -1
- package/dist/index.js +424 -32
- package/dist/index.mjs +92 -405
- 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/index.mjs
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clientFilterSchema,
|
|
3
|
+
clientSchema,
|
|
4
|
+
engineOpenApiDocument,
|
|
5
|
+
engineOpenApiJson,
|
|
6
|
+
eventSchema,
|
|
7
|
+
formatTunnelHost,
|
|
8
|
+
listClientsParamsSchema,
|
|
9
|
+
listClientsResponseSchema,
|
|
10
|
+
listTunnelsParamsSchema,
|
|
11
|
+
listTunnelsResponseSchema,
|
|
12
|
+
streamEndpointSchema,
|
|
13
|
+
streamSummarySchema,
|
|
14
|
+
streamTLSInfoSchema,
|
|
15
|
+
tunnelFilterSchema,
|
|
16
|
+
tunnelSchema,
|
|
17
|
+
webhookEventsSchema,
|
|
18
|
+
wsEventsSchema
|
|
19
|
+
} from "./chunk-OPJKEDVS.mjs";
|
|
20
|
+
|
|
1
21
|
// src/auth-resource.ts
|
|
2
22
|
import { createClientCredentialsToken } from "@rstreamlabs/rstream";
|
|
3
23
|
|
|
@@ -44,63 +64,15 @@ function select(base) {
|
|
|
44
64
|
return z.object(shape);
|
|
45
65
|
}
|
|
46
66
|
|
|
47
|
-
// src/tunnel.ts
|
|
48
|
-
import * as z2 from "zod";
|
|
49
|
-
var tunnelSchema = z2.object({
|
|
50
|
-
// common properties
|
|
51
|
-
client_id: z2.string(),
|
|
52
|
-
user_id: z2.string().optional(),
|
|
53
|
-
workspace_id: z2.string().optional(),
|
|
54
|
-
project_id: z2.string().optional(),
|
|
55
|
-
cluster_id: z2.string().optional(),
|
|
56
|
-
plan: z2.string().optional(),
|
|
57
|
-
provider: z2.string().optional(),
|
|
58
|
-
region: z2.string().optional(),
|
|
59
|
-
status: z2.enum(["online", "offline"]),
|
|
60
|
-
// tunnel properties
|
|
61
|
-
id: z2.string(),
|
|
62
|
-
creation_date: z2.union([z2.string().datetime(), z2.date()]).optional(),
|
|
63
|
-
name: z2.string().optional(),
|
|
64
|
-
type: z2.enum(["bytestream", "datagram"]).optional(),
|
|
65
|
-
publish: z2.boolean().optional(),
|
|
66
|
-
protocol: z2.enum(["tls", "dtls", "quic", "http"]).optional(),
|
|
67
|
-
labels: z2.record(z2.string(), z2.string()).optional(),
|
|
68
|
-
geo_ip: z2.array(z2.string()).optional(),
|
|
69
|
-
trusted_ips: z2.array(z2.string()).optional(),
|
|
70
|
-
host: z2.string().optional(),
|
|
71
|
-
tls_mode: z2.enum(["passthrough", "terminated"]).optional(),
|
|
72
|
-
tls_alpns: z2.array(z2.string()).optional(),
|
|
73
|
-
tls_min_version: z2.string().optional(),
|
|
74
|
-
tls_ciphers: z2.array(z2.string()).optional(),
|
|
75
|
-
mtls: z2.boolean().optional(),
|
|
76
|
-
mtls_ca_cert_pem: z2.string().optional(),
|
|
77
|
-
http_version: z2.enum(["http/1.1", "h2", "h2c", "h3"]).optional(),
|
|
78
|
-
http_use_tls: z2.boolean().optional(),
|
|
79
|
-
token_auth: z2.boolean().optional(),
|
|
80
|
-
rstream_auth: z2.boolean().optional(),
|
|
81
|
-
challenge_mode: z2.boolean().optional()
|
|
82
|
-
});
|
|
83
|
-
var listTunnelsParamsSchema = z2.object({
|
|
84
|
-
limit: z2.number().optional(),
|
|
85
|
-
filters: tunnelSchema.pick({
|
|
86
|
-
status: true,
|
|
87
|
-
client_id: true,
|
|
88
|
-
protocol: true,
|
|
89
|
-
publish: true,
|
|
90
|
-
labels: true
|
|
91
|
-
}).partial().optional()
|
|
92
|
-
});
|
|
93
|
-
var listTunnelsResponseSchema = z2.array(tunnelSchema);
|
|
94
|
-
|
|
95
67
|
// src/auth.ts
|
|
96
|
-
import * as
|
|
97
|
-
var nonEmptyStringSchema =
|
|
98
|
-
var authTokenPermissionsSchema =
|
|
99
|
-
var authTokenTunnelsScopesSchema =
|
|
68
|
+
import * as z2 from "zod";
|
|
69
|
+
var nonEmptyStringSchema = z2.string().trim().min(1);
|
|
70
|
+
var authTokenPermissionsSchema = z2.array(z2.string());
|
|
71
|
+
var authTokenTunnelsScopesSchema = z2.object({
|
|
100
72
|
// Scopes for creating tunnels
|
|
101
|
-
create:
|
|
102
|
-
|
|
103
|
-
|
|
73
|
+
create: z2.union([
|
|
74
|
+
z2.boolean(),
|
|
75
|
+
z2.object({
|
|
104
76
|
filters: filters(
|
|
105
77
|
tunnelSchema.omit({
|
|
106
78
|
client_id: true,
|
|
@@ -119,94 +91,94 @@ var authTokenTunnelsScopesSchema = z3.object({
|
|
|
119
91
|
})
|
|
120
92
|
]).optional(),
|
|
121
93
|
// Scopes for connecting to tunnels
|
|
122
|
-
connect:
|
|
123
|
-
|
|
124
|
-
|
|
94
|
+
connect: z2.union([
|
|
95
|
+
z2.boolean(),
|
|
96
|
+
z2.object({
|
|
125
97
|
filters: filters(tunnelSchema).optional(),
|
|
126
98
|
params: filters(
|
|
127
|
-
|
|
128
|
-
path:
|
|
99
|
+
z2.object({
|
|
100
|
+
path: z2.string().optional()
|
|
129
101
|
})
|
|
130
102
|
).optional()
|
|
131
103
|
})
|
|
132
104
|
]).optional(),
|
|
133
105
|
// Scopes for listing tunnels
|
|
134
|
-
list:
|
|
135
|
-
|
|
136
|
-
|
|
106
|
+
list: z2.union([
|
|
107
|
+
z2.boolean(),
|
|
108
|
+
z2.object({
|
|
137
109
|
filters: filters(tunnelSchema).optional(),
|
|
138
110
|
select: select(tunnelSchema).optional()
|
|
139
111
|
})
|
|
140
112
|
]).optional()
|
|
141
113
|
});
|
|
142
|
-
var authTokenScopesSchema =
|
|
114
|
+
var authTokenScopesSchema = z2.object({
|
|
143
115
|
tunnels: authTokenTunnelsScopesSchema.optional()
|
|
144
116
|
// Scopes related to tunnels
|
|
145
117
|
});
|
|
146
|
-
var authTokenTunnelGrantSchema =
|
|
147
|
-
workspaces:
|
|
148
|
-
projects:
|
|
118
|
+
var authTokenTunnelGrantSchema = z2.object({
|
|
119
|
+
workspaces: z2.array(nonEmptyStringSchema).min(1).optional(),
|
|
120
|
+
projects: z2.array(nonEmptyStringSchema).min(1).optional(),
|
|
149
121
|
scopes: authTokenScopesSchema.optional()
|
|
150
122
|
}).strict().superRefine((grant, ctx) => {
|
|
151
123
|
if (grant.workspaces !== void 0 && grant.projects !== void 0) {
|
|
152
124
|
ctx.addIssue({
|
|
153
|
-
code:
|
|
125
|
+
code: z2.ZodIssueCode.custom,
|
|
154
126
|
message: "A grant cannot target workspaces and projects at the same time.",
|
|
155
127
|
path: ["projects"]
|
|
156
128
|
});
|
|
157
129
|
}
|
|
158
130
|
});
|
|
159
131
|
var authTokenCommonSchema = {
|
|
160
|
-
aud:
|
|
161
|
-
exp:
|
|
162
|
-
tunnelsGrants:
|
|
163
|
-
iat:
|
|
164
|
-
iss:
|
|
165
|
-
jti:
|
|
166
|
-
metadata:
|
|
167
|
-
engine:
|
|
132
|
+
aud: z2.union([z2.string(), z2.array(z2.string())]).optional(),
|
|
133
|
+
exp: z2.number().optional(),
|
|
134
|
+
tunnelsGrants: z2.array(authTokenTunnelGrantSchema).optional(),
|
|
135
|
+
iat: z2.number().optional(),
|
|
136
|
+
iss: z2.string().optional(),
|
|
137
|
+
jti: z2.string().optional(),
|
|
138
|
+
metadata: z2.object({
|
|
139
|
+
engine: z2.string().optional()
|
|
168
140
|
}).strict().optional(),
|
|
169
|
-
nbf:
|
|
170
|
-
sub:
|
|
141
|
+
nbf: z2.number().optional(),
|
|
142
|
+
sub: z2.string().optional()
|
|
171
143
|
};
|
|
172
|
-
var authTokenSchema =
|
|
173
|
-
|
|
174
|
-
type:
|
|
175
|
-
userId:
|
|
144
|
+
var authTokenSchema = z2.union([
|
|
145
|
+
z2.object({
|
|
146
|
+
type: z2.literal("auth"),
|
|
147
|
+
userId: z2.string(),
|
|
176
148
|
permissions: authTokenPermissionsSchema.nullable(),
|
|
177
149
|
...authTokenCommonSchema
|
|
178
150
|
}).strict(),
|
|
179
|
-
|
|
180
|
-
type:
|
|
181
|
-
token_endpoint:
|
|
151
|
+
z2.object({
|
|
152
|
+
type: z2.literal("pat"),
|
|
153
|
+
token_endpoint: z2.string().optional(),
|
|
182
154
|
...authTokenCommonSchema
|
|
183
155
|
}).strict(),
|
|
184
|
-
|
|
185
|
-
type:
|
|
186
|
-
clientId:
|
|
156
|
+
z2.object({
|
|
157
|
+
type: z2.literal("app"),
|
|
158
|
+
clientId: z2.string(),
|
|
187
159
|
permissions: authTokenPermissionsSchema.nullable(),
|
|
188
160
|
...authTokenCommonSchema
|
|
189
161
|
}).strict()
|
|
190
162
|
]);
|
|
191
163
|
var tokenSchema = authTokenSchema;
|
|
192
|
-
var createAuthTokenParamsSchema =
|
|
193
|
-
expires_in:
|
|
164
|
+
var createAuthTokenParamsSchema = z2.object({
|
|
165
|
+
expires_in: z2.number().default(60),
|
|
194
166
|
// 1 minute
|
|
195
167
|
scopes: authTokenScopesSchema.optional(),
|
|
196
|
-
tunnelsGrants:
|
|
197
|
-
metadata:
|
|
168
|
+
tunnelsGrants: z2.array(authTokenTunnelGrantSchema).optional(),
|
|
169
|
+
metadata: z2.unknown().optional()
|
|
198
170
|
// Additional metadata
|
|
199
171
|
}).strict().superRefine((params, ctx) => {
|
|
200
172
|
if (params.scopes !== void 0 && params.tunnelsGrants !== void 0) {
|
|
201
173
|
ctx.addIssue({
|
|
202
|
-
code:
|
|
174
|
+
code: z2.ZodIssueCode.custom,
|
|
203
175
|
message: "Use either scopes or tunnelsGrants, not both.",
|
|
204
176
|
path: ["tunnelsGrants"]
|
|
205
177
|
});
|
|
206
178
|
}
|
|
207
179
|
});
|
|
208
|
-
var createAuthTokenResponseSchema =
|
|
209
|
-
token:
|
|
180
|
+
var createAuthTokenResponseSchema = z2.object({
|
|
181
|
+
token: z2.string()
|
|
210
182
|
});
|
|
211
183
|
|
|
212
184
|
// src/auth-resource.ts
|
|
@@ -258,34 +230,6 @@ function normalizeAuthTokenTunnelGrants(params) {
|
|
|
258
230
|
return void 0;
|
|
259
231
|
}
|
|
260
232
|
|
|
261
|
-
// src/client.ts
|
|
262
|
-
import * as z4 from "zod";
|
|
263
|
-
var clientSchema = z4.object({
|
|
264
|
-
id: z4.string(),
|
|
265
|
-
status: z4.enum(["online", "offline"]),
|
|
266
|
-
user_id: z4.string().optional(),
|
|
267
|
-
workspace_id: z4.string().optional(),
|
|
268
|
-
project_id: z4.string().optional(),
|
|
269
|
-
cluster_id: z4.string().optional(),
|
|
270
|
-
plan: z4.string().optional(),
|
|
271
|
-
provider: z4.string().optional(),
|
|
272
|
-
region: z4.string().optional(),
|
|
273
|
-
agent: z4.string().optional(),
|
|
274
|
-
channel: z4.string().optional(),
|
|
275
|
-
version: z4.string().optional(),
|
|
276
|
-
os: z4.string().optional(),
|
|
277
|
-
arch: z4.string().optional(),
|
|
278
|
-
protocol_version: z4.string().optional(),
|
|
279
|
-
labels: z4.record(z4.string(), z4.string()).optional()
|
|
280
|
-
});
|
|
281
|
-
var listClientsParamsSchema = z4.object({
|
|
282
|
-
limit: z4.number().optional(),
|
|
283
|
-
filters: clientSchema.pick({
|
|
284
|
-
labels: true
|
|
285
|
-
}).partial().optional()
|
|
286
|
-
});
|
|
287
|
-
var listClientsResponseSchema = z4.array(clientSchema);
|
|
288
|
-
|
|
289
233
|
// src/clients-resource.ts
|
|
290
234
|
var RstreamClientsResource = class {
|
|
291
235
|
client;
|
|
@@ -307,268 +251,6 @@ var RstreamClientsResource = class {
|
|
|
307
251
|
}
|
|
308
252
|
};
|
|
309
253
|
|
|
310
|
-
// src/stream.ts
|
|
311
|
-
import * as z5 from "zod";
|
|
312
|
-
var nonEmptyStringSchema2 = z5.string().min(1);
|
|
313
|
-
var isoDateTimeSchema = z5.string().datetime({ offset: true });
|
|
314
|
-
var ipAddressSchema = z5.string();
|
|
315
|
-
var intNonNegSchema = z5.number().int().nonnegative();
|
|
316
|
-
var numNonNegSchema = z5.number().nonnegative();
|
|
317
|
-
var geolocationSchema = z5.object({
|
|
318
|
-
country: z5.string().optional(),
|
|
319
|
-
region: z5.string().optional()
|
|
320
|
-
});
|
|
321
|
-
var streamTLSInfoSchema = z5.object({
|
|
322
|
-
version: z5.string().min(1).optional(),
|
|
323
|
-
cipher: z5.string().min(1).optional(),
|
|
324
|
-
protocol: z5.string().min(1).optional(),
|
|
325
|
-
curve: z5.string().min(1).optional(),
|
|
326
|
-
ech: z5.boolean().optional()
|
|
327
|
-
});
|
|
328
|
-
var streamEndpointSchema = z5.object({
|
|
329
|
-
ip: ipAddressSchema.optional(),
|
|
330
|
-
geolocation: geolocationSchema.optional(),
|
|
331
|
-
tls: streamTLSInfoSchema.optional()
|
|
332
|
-
});
|
|
333
|
-
var httpHeadersSchema = z5.record(
|
|
334
|
-
z5.string(),
|
|
335
|
-
z5.union([z5.string(), z5.array(z5.string())])
|
|
336
|
-
);
|
|
337
|
-
var httpProtocolSchema = z5.enum(["http/1.1", "h2", "h2c", "h3"]);
|
|
338
|
-
var httpRequestSchema = z5.object({
|
|
339
|
-
method: nonEmptyStringSchema2,
|
|
340
|
-
scheme: z5.string().min(1).optional(),
|
|
341
|
-
host: nonEmptyStringSchema2.optional(),
|
|
342
|
-
path: nonEmptyStringSchema2.optional(),
|
|
343
|
-
query: z5.string().optional(),
|
|
344
|
-
url: nonEmptyStringSchema2.optional(),
|
|
345
|
-
headers: httpHeadersSchema.optional(),
|
|
346
|
-
userAgent: z5.string().optional()
|
|
347
|
-
});
|
|
348
|
-
var httpResponseSchema = z5.object({
|
|
349
|
-
status: z5.number().int().min(100).max(999),
|
|
350
|
-
headers: httpHeadersSchema.optional()
|
|
351
|
-
});
|
|
352
|
-
var httpRequestStageSchema = z5.object({
|
|
353
|
-
protocol: httpProtocolSchema.optional(),
|
|
354
|
-
request: httpRequestSchema
|
|
355
|
-
});
|
|
356
|
-
var httpResponseStageSchema = z5.object({
|
|
357
|
-
protocol: httpProtocolSchema.optional(),
|
|
358
|
-
response: httpResponseSchema
|
|
359
|
-
});
|
|
360
|
-
var tokenSourceSchema = z5.enum([
|
|
361
|
-
"authorization",
|
|
362
|
-
"query",
|
|
363
|
-
"client",
|
|
364
|
-
"unknown"
|
|
365
|
-
]);
|
|
366
|
-
var tokenTypeSchema = z5.enum(["auth", "pat", "app", "unknown"]);
|
|
367
|
-
var firewallRuleSchema = z5.discriminatedUnion("kind", [
|
|
368
|
-
z5.object({ kind: z5.literal("none") }),
|
|
369
|
-
z5.object({ kind: z5.literal("mtls") }),
|
|
370
|
-
z5.object({
|
|
371
|
-
kind: z5.literal("rstream_auth"),
|
|
372
|
-
source: z5.literal("rstream_auth")
|
|
373
|
-
}),
|
|
374
|
-
z5.object({
|
|
375
|
-
kind: z5.literal("token"),
|
|
376
|
-
source: tokenSourceSchema.optional(),
|
|
377
|
-
tokenType: tokenTypeSchema.optional()
|
|
378
|
-
})
|
|
379
|
-
]);
|
|
380
|
-
var unauthorizedSourceSchema = z5.object({
|
|
381
|
-
source: tokenSourceSchema
|
|
382
|
-
});
|
|
383
|
-
var unauthorizedReasonSchema = (shape) => z5.object(shape).merge(unauthorizedSourceSchema);
|
|
384
|
-
var unauthorizedSchema = z5.discriminatedUnion("reason", [
|
|
385
|
-
unauthorizedReasonSchema({
|
|
386
|
-
reason: z5.literal("missing_token")
|
|
387
|
-
}),
|
|
388
|
-
unauthorizedReasonSchema({
|
|
389
|
-
reason: z5.literal("invalid_token")
|
|
390
|
-
}),
|
|
391
|
-
unauthorizedReasonSchema({
|
|
392
|
-
reason: z5.literal("expired_token")
|
|
393
|
-
}),
|
|
394
|
-
unauthorizedReasonSchema({
|
|
395
|
-
reason: z5.literal("invalid_secret")
|
|
396
|
-
}),
|
|
397
|
-
unauthorizedReasonSchema({
|
|
398
|
-
reason: z5.literal("user_mismatch")
|
|
399
|
-
}),
|
|
400
|
-
unauthorizedReasonSchema({
|
|
401
|
-
reason: z5.literal("insufficient_scope")
|
|
402
|
-
}),
|
|
403
|
-
unauthorizedReasonSchema({
|
|
404
|
-
reason: z5.literal("policy_denied"),
|
|
405
|
-
policy: z5.enum(["ip", "geo", "mtls", "challenge", "other"]),
|
|
406
|
-
value: z5.string().optional()
|
|
407
|
-
})
|
|
408
|
-
]);
|
|
409
|
-
var failureSchema = z5.discriminatedUnion("kind", [
|
|
410
|
-
z5.object({
|
|
411
|
-
kind: z5.literal("timeout"),
|
|
412
|
-
timeoutMs: intNonNegSchema.optional(),
|
|
413
|
-
message: z5.string().optional()
|
|
414
|
-
}),
|
|
415
|
-
z5.object({
|
|
416
|
-
kind: z5.literal("unauthorized"),
|
|
417
|
-
why: unauthorizedSchema,
|
|
418
|
-
message: z5.string().optional()
|
|
419
|
-
}),
|
|
420
|
-
z5.object({
|
|
421
|
-
kind: z5.literal("not_found"),
|
|
422
|
-
resource: z5.enum(["tunnel", "client", "route"]),
|
|
423
|
-
message: z5.string().optional()
|
|
424
|
-
}),
|
|
425
|
-
z5.object({
|
|
426
|
-
kind: z5.literal("refused"),
|
|
427
|
-
reason: z5.enum(["capacity", "policy", "unsupported", "other"]),
|
|
428
|
-
message: z5.string().optional()
|
|
429
|
-
}),
|
|
430
|
-
z5.object({ kind: z5.literal("io"), message: z5.string().optional() }),
|
|
431
|
-
z5.object({ kind: z5.literal("internal"), message: z5.string().optional() })
|
|
432
|
-
]);
|
|
433
|
-
var firewallSchema = z5.discriminatedUnion("decision", [
|
|
434
|
-
z5.object({ decision: z5.literal("allowed"), rule: firewallRuleSchema }),
|
|
435
|
-
z5.object({
|
|
436
|
-
decision: z5.literal("denied"),
|
|
437
|
-
rule: firewallRuleSchema,
|
|
438
|
-
failure: failureSchema
|
|
439
|
-
})
|
|
440
|
-
]);
|
|
441
|
-
var routedTunnelSchema = z5.object({
|
|
442
|
-
tunnelId: nonEmptyStringSchema2.optional(),
|
|
443
|
-
tunnelName: z5.string().optional(),
|
|
444
|
-
protocol: z5.string().optional(),
|
|
445
|
-
published: z5.boolean().optional(),
|
|
446
|
-
type: z5.string().optional(),
|
|
447
|
-
tlsMode: z5.string().optional(),
|
|
448
|
-
httpVersion: z5.string().optional(),
|
|
449
|
-
httpUseTls: z5.boolean().optional(),
|
|
450
|
-
tokenAuth: z5.boolean().optional(),
|
|
451
|
-
mtls: z5.boolean().optional()
|
|
452
|
-
});
|
|
453
|
-
var routingSchema = z5.discriminatedUnion("decision", [
|
|
454
|
-
z5.object({ decision: z5.literal("routed"), tunnel: routedTunnelSchema }),
|
|
455
|
-
z5.object({ decision: z5.literal("not_routed"), failure: failureSchema })
|
|
456
|
-
]);
|
|
457
|
-
var streamConnectedMetricsSchema = z5.object({
|
|
458
|
-
establish_ms: numNonNegSchema,
|
|
459
|
-
duration_ms: numNonNegSchema,
|
|
460
|
-
upstream_bytes: intNonNegSchema,
|
|
461
|
-
downstream_bytes: intNonNegSchema
|
|
462
|
-
});
|
|
463
|
-
var streamFailedMetricsSchema = z5.object({
|
|
464
|
-
time_to_fail_ms: numNonNegSchema.optional(),
|
|
465
|
-
establish_ms: numNonNegSchema.optional()
|
|
466
|
-
});
|
|
467
|
-
var terminationSchema = z5.object({
|
|
468
|
-
by: z5.enum(["downstream", "upstream", "server", "unknown"]),
|
|
469
|
-
reason: z5.enum(["closed", "reset", "timeout", "error", "unknown"]),
|
|
470
|
-
message: z5.string().optional()
|
|
471
|
-
});
|
|
472
|
-
var responseConnectedSchema = z5.object({
|
|
473
|
-
outcome: z5.literal("connected"),
|
|
474
|
-
established_at: isoDateTimeSchema,
|
|
475
|
-
upstream: streamEndpointSchema.optional(),
|
|
476
|
-
metrics: streamConnectedMetricsSchema,
|
|
477
|
-
termination: terminationSchema.optional(),
|
|
478
|
-
http: httpResponseStageSchema.optional()
|
|
479
|
-
});
|
|
480
|
-
var responseFailedSchema = z5.object({
|
|
481
|
-
outcome: z5.literal("failed"),
|
|
482
|
-
failure: failureSchema,
|
|
483
|
-
upstream: streamEndpointSchema.optional(),
|
|
484
|
-
metrics: streamFailedMetricsSchema.optional(),
|
|
485
|
-
termination: terminationSchema.optional(),
|
|
486
|
-
http: httpResponseStageSchema.optional()
|
|
487
|
-
});
|
|
488
|
-
var responseSchema = z5.discriminatedUnion("outcome", [
|
|
489
|
-
responseConnectedSchema,
|
|
490
|
-
responseFailedSchema
|
|
491
|
-
]);
|
|
492
|
-
var streamSummarySchema = z5.object({
|
|
493
|
-
workspace_id: nonEmptyStringSchema2.optional(),
|
|
494
|
-
project_id: nonEmptyStringSchema2.optional(),
|
|
495
|
-
cluster_id: nonEmptyStringSchema2.optional(),
|
|
496
|
-
user_id: nonEmptyStringSchema2.optional(),
|
|
497
|
-
client_id: nonEmptyStringSchema2.optional(),
|
|
498
|
-
tunnel_id: nonEmptyStringSchema2.optional(),
|
|
499
|
-
stream_id: nonEmptyStringSchema2,
|
|
500
|
-
created_at: isoDateTimeSchema,
|
|
501
|
-
terminated_at: isoDateTimeSchema,
|
|
502
|
-
request: z5.object({
|
|
503
|
-
downstream: streamEndpointSchema,
|
|
504
|
-
http: httpRequestStageSchema.optional()
|
|
505
|
-
}),
|
|
506
|
-
firewall: firewallSchema,
|
|
507
|
-
routing: routingSchema,
|
|
508
|
-
response: responseSchema
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// src/event.ts
|
|
512
|
-
import * as z6 from "zod";
|
|
513
|
-
var isoDateTimeSchema2 = z6.string().datetime({ offset: true });
|
|
514
|
-
var initialStateSchema = z6.object({
|
|
515
|
-
snapshot_at: isoDateTimeSchema2,
|
|
516
|
-
clients: z6.array(clientSchema),
|
|
517
|
-
tunnels: z6.array(tunnelSchema)
|
|
518
|
-
});
|
|
519
|
-
var eventBaseSchema = z6.object({
|
|
520
|
-
id: z6.string().optional(),
|
|
521
|
-
created_at: isoDateTimeSchema2.optional(),
|
|
522
|
-
user_id: z6.string().optional(),
|
|
523
|
-
workspace_id: z6.string().optional(),
|
|
524
|
-
project_id: z6.string().optional(),
|
|
525
|
-
cluster_id: z6.string().optional()
|
|
526
|
-
});
|
|
527
|
-
var withEventBase = (shape) => z6.object(shape).merge(eventBaseSchema).passthrough();
|
|
528
|
-
var stateInitialEventSchema = withEventBase({
|
|
529
|
-
type: z6.literal("state.initial"),
|
|
530
|
-
object: initialStateSchema
|
|
531
|
-
});
|
|
532
|
-
var streamSummaryEventSchema = withEventBase({
|
|
533
|
-
type: z6.literal("stream.summary"),
|
|
534
|
-
object: streamSummarySchema
|
|
535
|
-
});
|
|
536
|
-
var commonEventsSchema = [
|
|
537
|
-
withEventBase({
|
|
538
|
-
type: z6.literal("client.created"),
|
|
539
|
-
object: clientSchema
|
|
540
|
-
}),
|
|
541
|
-
withEventBase({
|
|
542
|
-
type: z6.literal("client.updated"),
|
|
543
|
-
object: clientSchema
|
|
544
|
-
}),
|
|
545
|
-
withEventBase({
|
|
546
|
-
type: z6.literal("client.deleted"),
|
|
547
|
-
object: clientSchema
|
|
548
|
-
}),
|
|
549
|
-
withEventBase({
|
|
550
|
-
type: z6.literal("tunnel.created"),
|
|
551
|
-
object: tunnelSchema
|
|
552
|
-
}),
|
|
553
|
-
withEventBase({
|
|
554
|
-
type: z6.literal("tunnel.updated"),
|
|
555
|
-
object: tunnelSchema
|
|
556
|
-
}),
|
|
557
|
-
withEventBase({
|
|
558
|
-
type: z6.literal("tunnel.deleted"),
|
|
559
|
-
object: tunnelSchema
|
|
560
|
-
})
|
|
561
|
-
];
|
|
562
|
-
var wsEventsSchema = z6.union([
|
|
563
|
-
stateInitialEventSchema,
|
|
564
|
-
...commonEventsSchema
|
|
565
|
-
]);
|
|
566
|
-
var webhookEventsSchema = z6.union([
|
|
567
|
-
...commonEventsSchema,
|
|
568
|
-
streamSummaryEventSchema
|
|
569
|
-
]);
|
|
570
|
-
var eventSchema = z6.union([wsEventsSchema, webhookEventsSchema]);
|
|
571
|
-
|
|
572
254
|
// src/resolution.ts
|
|
573
255
|
import { DEFAULT_API_URL } from "@rstreamlabs/rstream";
|
|
574
256
|
import { getTunnelsProjectEngine } from "@rstreamlabs/rstream";
|
|
@@ -694,16 +376,16 @@ import { isClientCredentials as isClientCredentials2 } from "@rstreamlabs/rstrea
|
|
|
694
376
|
import { isTokenCredentials as isTokenCredentials2 } from "@rstreamlabs/rstream";
|
|
695
377
|
import { RstreamClient as RstreamClient2 } from "@rstreamlabs/rstream";
|
|
696
378
|
import { turnCredentialsSchema } from "@rstreamlabs/rstream";
|
|
697
|
-
import * as
|
|
379
|
+
import * as z3 from "zod";
|
|
698
380
|
import crypto from "crypto";
|
|
699
381
|
var defaultTURNPort = 3478;
|
|
700
382
|
var defaultTURNSPort = 5349;
|
|
701
383
|
var defaultTURNCredentialTTLSeconds = 24 * 60 * 60;
|
|
702
|
-
var turnTokenClaimsSchema =
|
|
703
|
-
token_endpoint:
|
|
704
|
-
type:
|
|
384
|
+
var turnTokenClaimsSchema = z3.object({
|
|
385
|
+
token_endpoint: z3.string().optional(),
|
|
386
|
+
type: z3.string()
|
|
705
387
|
});
|
|
706
|
-
var turnCredentialModeSchema =
|
|
388
|
+
var turnCredentialModeSchema = z3.enum(["api", "app", "pat"]);
|
|
707
389
|
function normalizeOptionalString(value) {
|
|
708
390
|
const normalized = value?.trim();
|
|
709
391
|
return normalized ? normalized : void 0;
|
|
@@ -1229,7 +911,7 @@ var Watch = class {
|
|
|
1229
911
|
};
|
|
1230
912
|
|
|
1231
913
|
// src/webtty.ts
|
|
1232
|
-
import * as
|
|
914
|
+
import * as z4 from "zod";
|
|
1233
915
|
var osFamilies = [
|
|
1234
916
|
"linux",
|
|
1235
917
|
"macos",
|
|
@@ -1238,25 +920,25 @@ var osFamilies = [
|
|
|
1238
920
|
"openbsd",
|
|
1239
921
|
"freebsd"
|
|
1240
922
|
];
|
|
1241
|
-
var webttyServerSchema =
|
|
1242
|
-
tunnel_id:
|
|
1243
|
-
host:
|
|
1244
|
-
token_auth:
|
|
1245
|
-
os_family:
|
|
1246
|
-
arch:
|
|
1247
|
-
os_id:
|
|
923
|
+
var webttyServerSchema = z4.object({
|
|
924
|
+
tunnel_id: z4.string(),
|
|
925
|
+
host: z4.string(),
|
|
926
|
+
token_auth: z4.boolean(),
|
|
927
|
+
os_family: z4.enum(osFamilies).optional(),
|
|
928
|
+
arch: z4.string().optional(),
|
|
929
|
+
os_id: z4.string().optional(),
|
|
1248
930
|
// /etc/os-release::ID (ubuntu, debian, rocky, etc.)
|
|
1249
|
-
os_version_id:
|
|
931
|
+
os_version_id: z4.string().optional(),
|
|
1250
932
|
// /etc/os-release::VERSION_ID (24.04, 22.04, 11, 10.0.19045, ...)
|
|
1251
|
-
os_version_codename:
|
|
933
|
+
os_version_codename: z4.string().optional(),
|
|
1252
934
|
// /etc/os-release::VERSION_CODENAME (jammy, noble...)
|
|
1253
|
-
os_pretty_name:
|
|
935
|
+
os_pretty_name: z4.string().optional(),
|
|
1254
936
|
// /etc/os-release::PRETTY_NAME
|
|
1255
|
-
kernel_release:
|
|
937
|
+
kernel_release: z4.string().optional(),
|
|
1256
938
|
// uname -r
|
|
1257
|
-
hostname:
|
|
939
|
+
hostname: z4.string().optional(),
|
|
1258
940
|
// uname -n
|
|
1259
|
-
labels:
|
|
941
|
+
labels: z4.record(z4.string(), z4.string().optional()).optional()
|
|
1260
942
|
});
|
|
1261
943
|
function parser(tunnel) {
|
|
1262
944
|
if (tunnel.status !== "online") return null;
|
|
@@ -1275,7 +957,7 @@ function parser(tunnel) {
|
|
|
1275
957
|
}
|
|
1276
958
|
const candidate = {
|
|
1277
959
|
tunnel_id: tunnel.id,
|
|
1278
|
-
host: tunnel
|
|
960
|
+
host: formatTunnelHost(tunnel),
|
|
1279
961
|
token_auth: tunnel.token_auth === true,
|
|
1280
962
|
os_family: tunnelLabels["rstream.webtty.os_family"],
|
|
1281
963
|
arch: tunnelLabels["rstream.webtty.arch"],
|
|
@@ -1313,6 +995,7 @@ export {
|
|
|
1313
995
|
authTokenScopesSchema,
|
|
1314
996
|
authTokenTunnelGrantSchema,
|
|
1315
997
|
authTokenTunnelsScopesSchema,
|
|
998
|
+
clientFilterSchema,
|
|
1316
999
|
clientSchema,
|
|
1317
1000
|
createAPITURNCredentials,
|
|
1318
1001
|
createAPPTURNCredentials,
|
|
@@ -1321,7 +1004,10 @@ export {
|
|
|
1321
1004
|
createAuthTokenResponseSchema,
|
|
1322
1005
|
createPATTURNCredentials,
|
|
1323
1006
|
createTURNCredentials,
|
|
1007
|
+
engineOpenApiDocument,
|
|
1008
|
+
engineOpenApiJson,
|
|
1324
1009
|
eventSchema,
|
|
1010
|
+
formatTunnelHost,
|
|
1325
1011
|
listClientsParamsSchema,
|
|
1326
1012
|
listClientsResponseSchema,
|
|
1327
1013
|
listTunnelsParamsSchema,
|
|
@@ -1335,6 +1021,7 @@ export {
|
|
|
1335
1021
|
streamSummarySchema,
|
|
1336
1022
|
streamTLSInfoSchema,
|
|
1337
1023
|
tokenSchema,
|
|
1024
|
+
tunnelFilterSchema,
|
|
1338
1025
|
tunnelSchema,
|
|
1339
1026
|
turnCredentialModeSchema,
|
|
1340
1027
|
webhookEventsSchema,
|