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