@rstreamlabs/tunnels 1.0.11 → 2.0.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 +8 -4
- package/dist/{chunk-NHUJ3FYM.mjs → chunk-UUZYVELQ.mjs} +14 -46
- package/dist/index.d.mts +157 -1692
- package/dist/index.d.ts +157 -1692
- package/dist/index.js +231 -477
- package/dist/index.mjs +27 -232
- package/dist/openapi.js +12 -43
- package/dist/openapi.mjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -43,18 +43,11 @@ __export(index_exports, {
|
|
|
43
43
|
RstreamWebhookRessource: () => RstreamWebhookResource,
|
|
44
44
|
Tunnels: () => RstreamTunnelsClient,
|
|
45
45
|
Watch: () => Watch,
|
|
46
|
-
authTokenPermissionsSchema: () => authTokenPermissionsSchema,
|
|
47
|
-
authTokenSchema: () => authTokenSchema,
|
|
48
|
-
authTokenScopesSchema: () => authTokenScopesSchema,
|
|
49
|
-
authTokenTunnelGrantSchema: () => authTokenTunnelGrantSchema,
|
|
50
|
-
authTokenTunnelsScopesSchema: () => authTokenTunnelsScopesSchema,
|
|
51
46
|
clientFilterSchema: () => clientFilterSchema,
|
|
52
47
|
clientSchema: () => clientSchema,
|
|
53
48
|
createAPITURNCredentials: () => createAPITURNCredentials,
|
|
54
49
|
createAPPTURNCredentials: () => createAPPTURNCredentials,
|
|
55
50
|
createAuthTokenFromClientCredentials: () => createAuthTokenFromClientCredentials,
|
|
56
|
-
createAuthTokenParamsSchema: () => createAuthTokenParamsSchema,
|
|
57
|
-
createAuthTokenResponseSchema: () => createAuthTokenResponseSchema,
|
|
58
51
|
createPATTURNCredentials: () => createPATTURNCredentials,
|
|
59
52
|
createTURNCredentials: () => createTURNCredentials,
|
|
60
53
|
engineOpenApiDocument: () => engineOpenApiDocument,
|
|
@@ -75,9 +68,7 @@ __export(index_exports, {
|
|
|
75
68
|
streamEndpointSchema: () => streamEndpointSchema,
|
|
76
69
|
streamSummarySchema: () => streamSummarySchema,
|
|
77
70
|
streamTLSInfoSchema: () => streamTLSInfoSchema,
|
|
78
|
-
tokenSchema: () => tokenSchema,
|
|
79
71
|
tunnelFilterSchema: () => tunnelFilterSchema,
|
|
80
|
-
tunnelSchema: () => tunnelSchema,
|
|
81
72
|
turnCredentialModeSchema: () => turnCredentialModeSchema,
|
|
82
73
|
webhookEventsSchema: () => webhookEventsSchema,
|
|
83
74
|
webttyServerSchema: () => webttyServerSchema,
|
|
@@ -86,270 +77,8 @@ __export(index_exports, {
|
|
|
86
77
|
module.exports = __toCommonJS(index_exports);
|
|
87
78
|
|
|
88
79
|
// src/auth-resource.ts
|
|
80
|
+
var import_auth_token = require("@rstreamlabs/rstream/auth-token");
|
|
89
81
|
var import_rstream = require("@rstreamlabs/rstream");
|
|
90
|
-
|
|
91
|
-
// src/zod.ts
|
|
92
|
-
var z = __toESM(require("zod"));
|
|
93
|
-
var StringFilter = z.union([
|
|
94
|
-
z.string(),
|
|
95
|
-
z.object({ exact: z.string() }).strict(),
|
|
96
|
-
z.object({ oneof: z.array(z.string()) }).strict(),
|
|
97
|
-
z.object({ regex: z.string() }).strict()
|
|
98
|
-
]);
|
|
99
|
-
function transform(field) {
|
|
100
|
-
if (field instanceof z.ZodOptional) {
|
|
101
|
-
return z.optional(transform(field.unwrap()));
|
|
102
|
-
}
|
|
103
|
-
if (field instanceof z.ZodString) {
|
|
104
|
-
return z.optional(StringFilter);
|
|
105
|
-
}
|
|
106
|
-
if (field instanceof z.ZodRecord) {
|
|
107
|
-
return z.optional(z.record(field.keyType, transform(field.valueType)));
|
|
108
|
-
}
|
|
109
|
-
return z.optional(field);
|
|
110
|
-
}
|
|
111
|
-
function filters(base) {
|
|
112
|
-
const entries = Object.entries(base.shape).map(([key, field]) => [
|
|
113
|
-
key,
|
|
114
|
-
transform(field)
|
|
115
|
-
]);
|
|
116
|
-
const shape = Object.fromEntries(entries);
|
|
117
|
-
const node = z.lazy(
|
|
118
|
-
() => z.union([
|
|
119
|
-
z.object(shape).strict(),
|
|
120
|
-
z.object({ AND: z.array(node) }).strict(),
|
|
121
|
-
z.object({ OR: z.array(node) }).strict()
|
|
122
|
-
])
|
|
123
|
-
);
|
|
124
|
-
return node;
|
|
125
|
-
}
|
|
126
|
-
function select(base) {
|
|
127
|
-
const entries = Object.entries(base.shape).map(([key]) => {
|
|
128
|
-
return [key, z.boolean().optional()];
|
|
129
|
-
});
|
|
130
|
-
const shape = Object.fromEntries(entries);
|
|
131
|
-
return z.object(shape).strict();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/tunnel.ts
|
|
135
|
-
var z2 = __toESM(require("zod"));
|
|
136
|
-
var DEFAULT_PUBLISHED_PORT = 443;
|
|
137
|
-
var tunnelSchema = z2.object({
|
|
138
|
-
// common properties
|
|
139
|
-
client_id: z2.string(),
|
|
140
|
-
user_id: z2.string().optional(),
|
|
141
|
-
workspace_id: z2.string().optional(),
|
|
142
|
-
project_id: z2.string().optional(),
|
|
143
|
-
cluster_id: z2.string().optional(),
|
|
144
|
-
plan: z2.string().optional(),
|
|
145
|
-
provider: z2.string().optional(),
|
|
146
|
-
region: z2.string().optional(),
|
|
147
|
-
status: z2.enum(["online", "offline"]),
|
|
148
|
-
// tunnel properties
|
|
149
|
-
id: z2.string(),
|
|
150
|
-
creation_date: z2.union([z2.string().datetime(), z2.date()]).optional(),
|
|
151
|
-
name: z2.string().optional(),
|
|
152
|
-
type: z2.enum(["bytestream", "datagram"]).optional(),
|
|
153
|
-
publish: z2.boolean().optional(),
|
|
154
|
-
protocol: z2.enum(["tls", "dtls", "quic", "http"]).optional(),
|
|
155
|
-
labels: z2.record(z2.string(), z2.string()).optional(),
|
|
156
|
-
geo_ip: z2.array(z2.string()).optional(),
|
|
157
|
-
trusted_ips: z2.array(z2.string()).optional(),
|
|
158
|
-
host: z2.string().optional(),
|
|
159
|
-
hostname: z2.string().optional(),
|
|
160
|
-
port: z2.number().int().min(1).max(65535).optional(),
|
|
161
|
-
tls_mode: z2.enum(["passthrough", "terminated"]).optional(),
|
|
162
|
-
tls_alpns: z2.array(z2.string()).optional(),
|
|
163
|
-
tls_min_version: z2.string().optional(),
|
|
164
|
-
tls_ciphers: z2.array(z2.string()).optional(),
|
|
165
|
-
mtls_auth: z2.boolean().optional(),
|
|
166
|
-
http_version: z2.enum(["http/1.1", "h2", "h2c", "h3"]).optional(),
|
|
167
|
-
http_use_tls: z2.boolean().optional(),
|
|
168
|
-
upstream_tls: z2.boolean().optional(),
|
|
169
|
-
token_auth: z2.boolean().optional(),
|
|
170
|
-
rstream_auth: z2.boolean().optional(),
|
|
171
|
-
challenge_mode: z2.boolean().optional()
|
|
172
|
-
});
|
|
173
|
-
var tunnelFilterSchema = tunnelSchema.pick({
|
|
174
|
-
id: true,
|
|
175
|
-
name: true,
|
|
176
|
-
type: true,
|
|
177
|
-
status: true,
|
|
178
|
-
client_id: true,
|
|
179
|
-
user_id: true,
|
|
180
|
-
publish: true,
|
|
181
|
-
protocol: true,
|
|
182
|
-
hostname: true,
|
|
183
|
-
http_version: true,
|
|
184
|
-
labels: true
|
|
185
|
-
}).partial();
|
|
186
|
-
var listTunnelsParamsSchema = z2.object({
|
|
187
|
-
limit: z2.number().int().min(1).optional(),
|
|
188
|
-
filters: tunnelFilterSchema.optional()
|
|
189
|
-
});
|
|
190
|
-
var listTunnelsResponseSchema = z2.array(tunnelSchema);
|
|
191
|
-
function formatTunnelHost(tunnel) {
|
|
192
|
-
if (!tunnel.hostname) return tunnel.host;
|
|
193
|
-
if (!tunnel.port || tunnel.port === DEFAULT_PUBLISHED_PORT) {
|
|
194
|
-
return tunnel.hostname;
|
|
195
|
-
}
|
|
196
|
-
return `${tunnel.hostname}:${tunnel.port}`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// src/auth.ts
|
|
200
|
-
var z3 = __toESM(require("zod"));
|
|
201
|
-
var nonEmptyStringSchema = z3.string().trim().min(1);
|
|
202
|
-
var authTokenPermissionsSchema = z3.array(z3.string());
|
|
203
|
-
var authTokenTunnelsScopesSchema = z3.object({
|
|
204
|
-
// Scopes for creating tunnels
|
|
205
|
-
create: z3.union([
|
|
206
|
-
z3.boolean(),
|
|
207
|
-
z3.object({
|
|
208
|
-
filters: filters(
|
|
209
|
-
tunnelSchema.omit({
|
|
210
|
-
client_id: true,
|
|
211
|
-
user_id: true,
|
|
212
|
-
workspace_id: true,
|
|
213
|
-
project_id: true,
|
|
214
|
-
cluster_id: true,
|
|
215
|
-
plan: true,
|
|
216
|
-
provider: true,
|
|
217
|
-
region: true,
|
|
218
|
-
status: true,
|
|
219
|
-
id: true,
|
|
220
|
-
creation_date: true
|
|
221
|
-
})
|
|
222
|
-
).optional()
|
|
223
|
-
}).strict()
|
|
224
|
-
]).optional(),
|
|
225
|
-
// Scopes for connecting to tunnels
|
|
226
|
-
connect: z3.union([
|
|
227
|
-
z3.boolean(),
|
|
228
|
-
z3.object({
|
|
229
|
-
filters: filters(tunnelSchema).optional(),
|
|
230
|
-
params: filters(
|
|
231
|
-
z3.object({
|
|
232
|
-
path: z3.string().optional()
|
|
233
|
-
})
|
|
234
|
-
).optional()
|
|
235
|
-
}).strict()
|
|
236
|
-
]).optional(),
|
|
237
|
-
// Scopes for listing tunnels
|
|
238
|
-
list: z3.union([
|
|
239
|
-
z3.boolean(),
|
|
240
|
-
z3.object({
|
|
241
|
-
filters: filters(tunnelSchema).optional(),
|
|
242
|
-
select: select(tunnelSchema).optional()
|
|
243
|
-
}).strict()
|
|
244
|
-
]).optional()
|
|
245
|
-
}).strict().superRefine((scopes, ctx) => {
|
|
246
|
-
if (scopes.create === void 0 && scopes.connect === void 0 && scopes.list === void 0) {
|
|
247
|
-
ctx.addIssue({
|
|
248
|
-
code: z3.ZodIssueCode.custom,
|
|
249
|
-
message: "At least one tunnel scope action is required."
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
var authTokenScopesSchema = z3.object({
|
|
254
|
-
tunnels: authTokenTunnelsScopesSchema.optional()
|
|
255
|
-
// Scopes related to tunnels
|
|
256
|
-
}).strict().superRefine((scopes, ctx) => {
|
|
257
|
-
if (scopes.tunnels === void 0) {
|
|
258
|
-
ctx.addIssue({
|
|
259
|
-
code: z3.ZodIssueCode.custom,
|
|
260
|
-
message: "Tunnel scopes are required.",
|
|
261
|
-
path: ["tunnels"]
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
var authTokenTunnelGrantLeafSchema = z3.object({
|
|
266
|
-
workspaces: z3.array(nonEmptyStringSchema).min(1).optional(),
|
|
267
|
-
projects: z3.array(nonEmptyStringSchema).min(1).optional(),
|
|
268
|
-
scopes: authTokenScopesSchema.optional()
|
|
269
|
-
}).strict().superRefine((grant, ctx) => {
|
|
270
|
-
if (grant.workspaces !== void 0 && grant.projects !== void 0) {
|
|
271
|
-
ctx.addIssue({
|
|
272
|
-
code: z3.ZodIssueCode.custom,
|
|
273
|
-
message: "A grant cannot target workspaces and projects at the same time.",
|
|
274
|
-
path: ["projects"]
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
if (grant.workspaces === void 0 && grant.projects === void 0 && grant.scopes === void 0) {
|
|
278
|
-
ctx.addIssue({
|
|
279
|
-
code: z3.ZodIssueCode.custom,
|
|
280
|
-
message: "A grant must target workspaces, projects, or scopes.",
|
|
281
|
-
path: ["workspaces"]
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
var authTokenTunnelGrantSchema = z3.lazy(
|
|
286
|
-
() => z3.union([
|
|
287
|
-
authTokenTunnelGrantLeafSchema,
|
|
288
|
-
z3.object({ AND: z3.array(authTokenTunnelGrantSchema).min(1) }).strict(),
|
|
289
|
-
z3.object({ OR: z3.array(authTokenTunnelGrantSchema).min(1) }).strict()
|
|
290
|
-
])
|
|
291
|
-
);
|
|
292
|
-
var authTokenCommonSchema = {
|
|
293
|
-
aud: z3.union([z3.string(), z3.array(z3.string())]).optional(),
|
|
294
|
-
exp: z3.number().optional(),
|
|
295
|
-
tunnelsGrants: authTokenTunnelGrantSchema.optional(),
|
|
296
|
-
iat: z3.number().optional(),
|
|
297
|
-
iss: z3.string().optional(),
|
|
298
|
-
jti: z3.string().optional(),
|
|
299
|
-
metadata: z3.object({
|
|
300
|
-
engine: z3.string().optional()
|
|
301
|
-
}).strict().optional(),
|
|
302
|
-
nbf: z3.number().optional(),
|
|
303
|
-
sub: z3.string().optional()
|
|
304
|
-
};
|
|
305
|
-
var authTokenSchema = z3.union([
|
|
306
|
-
z3.object({
|
|
307
|
-
type: z3.literal("auth"),
|
|
308
|
-
userId: z3.string(),
|
|
309
|
-
permissions: authTokenPermissionsSchema.nullable(),
|
|
310
|
-
...authTokenCommonSchema
|
|
311
|
-
}).strict(),
|
|
312
|
-
z3.object({
|
|
313
|
-
type: z3.literal("pat"),
|
|
314
|
-
tokendpoint: z3.string().optional(),
|
|
315
|
-
token_endpoint: z3.string().optional(),
|
|
316
|
-
...authTokenCommonSchema
|
|
317
|
-
}).strict(),
|
|
318
|
-
z3.object({
|
|
319
|
-
type: z3.literal("app"),
|
|
320
|
-
clientId: z3.string(),
|
|
321
|
-
permissions: authTokenPermissionsSchema.nullable(),
|
|
322
|
-
...authTokenCommonSchema
|
|
323
|
-
}).strict()
|
|
324
|
-
]);
|
|
325
|
-
var tokenSchema = authTokenSchema;
|
|
326
|
-
var createAuthTokenParamsSchema = z3.object({
|
|
327
|
-
expires_in: z3.number().int().min(1).max(3600).default(60),
|
|
328
|
-
scopes: authTokenScopesSchema.optional(),
|
|
329
|
-
tunnelsGrants: authTokenTunnelGrantSchema.optional(),
|
|
330
|
-
metadata: z3.unknown().optional()
|
|
331
|
-
// Additional metadata
|
|
332
|
-
}).strict().superRefine((params, ctx) => {
|
|
333
|
-
if (params.scopes !== void 0 && params.tunnelsGrants !== void 0) {
|
|
334
|
-
ctx.addIssue({
|
|
335
|
-
code: z3.ZodIssueCode.custom,
|
|
336
|
-
message: "Use either scopes or tunnelsGrants, not both.",
|
|
337
|
-
path: ["tunnelsGrants"]
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
if (params.scopes === void 0 && params.tunnelsGrants === void 0) {
|
|
341
|
-
ctx.addIssue({
|
|
342
|
-
code: z3.ZodIssueCode.custom,
|
|
343
|
-
message: "Explicit scopes or tunnelsGrants are required.",
|
|
344
|
-
path: ["scopes"]
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
var createAuthTokenResponseSchema = z3.object({
|
|
349
|
-
token: z3.string()
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// src/auth-resource.ts
|
|
353
82
|
var import_rstream2 = require("@rstreamlabs/rstream");
|
|
354
83
|
var RstreamAuthResource = class {
|
|
355
84
|
client;
|
|
@@ -371,7 +100,7 @@ var RstreamAuthResource = class {
|
|
|
371
100
|
});
|
|
372
101
|
}
|
|
373
102
|
async resolveScopeOptions(params, options) {
|
|
374
|
-
const tokenParams = createAuthTokenParamsSchema.parse(params);
|
|
103
|
+
const tokenParams = import_auth_token.createAuthTokenParamsSchema.parse(params);
|
|
375
104
|
if (options?.projectScoped === false) {
|
|
376
105
|
return options ?? {};
|
|
377
106
|
}
|
|
@@ -390,7 +119,7 @@ var RstreamAuthResource = class {
|
|
|
390
119
|
}
|
|
391
120
|
};
|
|
392
121
|
function createAuthTokenFromClientCredentials(credentials, params, options) {
|
|
393
|
-
const tokenParams = createAuthTokenParamsSchema.parse(params);
|
|
122
|
+
const tokenParams = import_auth_token.createAuthTokenParamsSchema.parse(params);
|
|
394
123
|
const payload = {
|
|
395
124
|
metadata: {
|
|
396
125
|
engine: options?.engine
|
|
@@ -492,24 +221,24 @@ function normalizeOptionalString(value) {
|
|
|
492
221
|
}
|
|
493
222
|
|
|
494
223
|
// src/client.ts
|
|
495
|
-
var
|
|
496
|
-
var clientSchema =
|
|
497
|
-
id:
|
|
498
|
-
status:
|
|
499
|
-
user_id:
|
|
500
|
-
workspace_id:
|
|
501
|
-
project_id:
|
|
502
|
-
cluster_id:
|
|
503
|
-
plan:
|
|
504
|
-
provider:
|
|
505
|
-
region:
|
|
506
|
-
agent:
|
|
507
|
-
channel:
|
|
508
|
-
version:
|
|
509
|
-
os:
|
|
510
|
-
arch:
|
|
511
|
-
protocol_version:
|
|
512
|
-
labels:
|
|
224
|
+
var z = __toESM(require("zod"));
|
|
225
|
+
var clientSchema = z.object({
|
|
226
|
+
id: z.string(),
|
|
227
|
+
status: z.enum(["online", "offline"]),
|
|
228
|
+
user_id: z.string().optional(),
|
|
229
|
+
workspace_id: z.string().optional(),
|
|
230
|
+
project_id: z.string().optional(),
|
|
231
|
+
cluster_id: z.string().optional(),
|
|
232
|
+
plan: z.string().optional(),
|
|
233
|
+
provider: z.string().optional(),
|
|
234
|
+
region: z.string().optional(),
|
|
235
|
+
agent: z.string().optional(),
|
|
236
|
+
channel: z.string().optional(),
|
|
237
|
+
version: z.string().optional(),
|
|
238
|
+
os: z.string().optional(),
|
|
239
|
+
arch: z.string().optional(),
|
|
240
|
+
protocol_version: z.string().optional(),
|
|
241
|
+
labels: z.record(z.string(), z.string()).optional()
|
|
513
242
|
});
|
|
514
243
|
var clientFilterSchema = clientSchema.pick({
|
|
515
244
|
id: true,
|
|
@@ -523,11 +252,11 @@ var clientFilterSchema = clientSchema.pick({
|
|
|
523
252
|
protocol_version: true,
|
|
524
253
|
labels: true
|
|
525
254
|
}).partial();
|
|
526
|
-
var listClientsParamsSchema =
|
|
527
|
-
limit:
|
|
255
|
+
var listClientsParamsSchema = z.object({
|
|
256
|
+
limit: z.number().int().min(1).optional(),
|
|
528
257
|
filters: clientFilterSchema.optional()
|
|
529
258
|
});
|
|
530
|
-
var listClientsResponseSchema =
|
|
259
|
+
var listClientsResponseSchema = z.array(clientSchema);
|
|
531
260
|
|
|
532
261
|
// src/clients-resource.ts
|
|
533
262
|
function clientPathId(id) {
|
|
@@ -561,200 +290,200 @@ var RstreamClientsResource = class {
|
|
|
561
290
|
};
|
|
562
291
|
|
|
563
292
|
// src/stream.ts
|
|
564
|
-
var
|
|
565
|
-
var
|
|
566
|
-
var isoDateTimeSchema =
|
|
567
|
-
var ipAddressSchema =
|
|
568
|
-
var intNonNegSchema =
|
|
569
|
-
var numNonNegSchema =
|
|
570
|
-
var geolocationSchema =
|
|
571
|
-
country:
|
|
572
|
-
region:
|
|
293
|
+
var z2 = __toESM(require("zod"));
|
|
294
|
+
var nonEmptyStringSchema = z2.string().min(1);
|
|
295
|
+
var isoDateTimeSchema = z2.string().datetime({ offset: true });
|
|
296
|
+
var ipAddressSchema = z2.string();
|
|
297
|
+
var intNonNegSchema = z2.number().int().nonnegative();
|
|
298
|
+
var numNonNegSchema = z2.number().nonnegative();
|
|
299
|
+
var geolocationSchema = z2.object({
|
|
300
|
+
country: z2.string().optional(),
|
|
301
|
+
region: z2.string().optional()
|
|
573
302
|
});
|
|
574
|
-
var streamTLSInfoSchema =
|
|
575
|
-
version:
|
|
576
|
-
cipher:
|
|
577
|
-
protocol:
|
|
578
|
-
curve:
|
|
579
|
-
ech:
|
|
303
|
+
var streamTLSInfoSchema = z2.object({
|
|
304
|
+
version: z2.string().min(1).optional(),
|
|
305
|
+
cipher: z2.string().min(1).optional(),
|
|
306
|
+
protocol: z2.string().min(1).optional(),
|
|
307
|
+
curve: z2.string().min(1).optional(),
|
|
308
|
+
ech: z2.boolean().optional()
|
|
580
309
|
});
|
|
581
|
-
var streamEndpointSchema =
|
|
310
|
+
var streamEndpointSchema = z2.object({
|
|
582
311
|
ip: ipAddressSchema.optional(),
|
|
583
312
|
geolocation: geolocationSchema.optional(),
|
|
584
313
|
tls: streamTLSInfoSchema.optional()
|
|
585
314
|
});
|
|
586
|
-
var httpHeadersSchema =
|
|
587
|
-
|
|
588
|
-
|
|
315
|
+
var httpHeadersSchema = z2.record(
|
|
316
|
+
z2.string(),
|
|
317
|
+
z2.union([z2.string(), z2.array(z2.string())])
|
|
589
318
|
);
|
|
590
|
-
var httpProtocolSchema =
|
|
591
|
-
var httpRequestSchema =
|
|
592
|
-
method:
|
|
593
|
-
scheme:
|
|
594
|
-
host:
|
|
595
|
-
path:
|
|
596
|
-
query:
|
|
597
|
-
url:
|
|
319
|
+
var httpProtocolSchema = z2.enum(["http/1.1", "h2", "h2c", "h3"]);
|
|
320
|
+
var httpRequestSchema = z2.object({
|
|
321
|
+
method: nonEmptyStringSchema,
|
|
322
|
+
scheme: z2.string().min(1).optional(),
|
|
323
|
+
host: nonEmptyStringSchema.optional(),
|
|
324
|
+
path: nonEmptyStringSchema.optional(),
|
|
325
|
+
query: z2.string().optional(),
|
|
326
|
+
url: nonEmptyStringSchema.optional(),
|
|
598
327
|
headers: httpHeadersSchema.optional(),
|
|
599
|
-
userAgent:
|
|
328
|
+
userAgent: z2.string().optional()
|
|
600
329
|
});
|
|
601
|
-
var httpResponseSchema =
|
|
602
|
-
status:
|
|
330
|
+
var httpResponseSchema = z2.object({
|
|
331
|
+
status: z2.number().int().min(100).max(999),
|
|
603
332
|
headers: httpHeadersSchema.optional()
|
|
604
333
|
});
|
|
605
|
-
var httpRequestStageSchema =
|
|
334
|
+
var httpRequestStageSchema = z2.object({
|
|
606
335
|
protocol: httpProtocolSchema.optional(),
|
|
607
336
|
request: httpRequestSchema
|
|
608
337
|
});
|
|
609
|
-
var httpResponseStageSchema =
|
|
338
|
+
var httpResponseStageSchema = z2.object({
|
|
610
339
|
protocol: httpProtocolSchema.optional(),
|
|
611
340
|
response: httpResponseSchema
|
|
612
341
|
});
|
|
613
|
-
var tokenSourceSchema =
|
|
342
|
+
var tokenSourceSchema = z2.enum([
|
|
614
343
|
"authorization",
|
|
615
344
|
"query",
|
|
616
345
|
"client",
|
|
617
346
|
"unknown"
|
|
618
347
|
]);
|
|
619
|
-
var tokenTypeSchema =
|
|
620
|
-
var firewallRuleSchema =
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
kind:
|
|
625
|
-
source:
|
|
348
|
+
var tokenTypeSchema = z2.enum(["auth", "pat", "app", "unknown"]);
|
|
349
|
+
var firewallRuleSchema = z2.discriminatedUnion("kind", [
|
|
350
|
+
z2.object({ kind: z2.literal("none") }),
|
|
351
|
+
z2.object({ kind: z2.literal("mtls") }),
|
|
352
|
+
z2.object({
|
|
353
|
+
kind: z2.literal("rstream_auth"),
|
|
354
|
+
source: z2.literal("rstream_auth")
|
|
626
355
|
}),
|
|
627
|
-
|
|
628
|
-
kind:
|
|
356
|
+
z2.object({
|
|
357
|
+
kind: z2.literal("token"),
|
|
629
358
|
source: tokenSourceSchema.optional(),
|
|
630
359
|
tokenType: tokenTypeSchema.optional()
|
|
631
360
|
})
|
|
632
361
|
]);
|
|
633
|
-
var unauthorizedSourceSchema =
|
|
362
|
+
var unauthorizedSourceSchema = z2.object({
|
|
634
363
|
source: tokenSourceSchema
|
|
635
364
|
});
|
|
636
|
-
var unauthorizedReasonSchema = (shape) =>
|
|
637
|
-
var unauthorizedSchema =
|
|
365
|
+
var unauthorizedReasonSchema = (shape) => z2.object(shape).merge(unauthorizedSourceSchema);
|
|
366
|
+
var unauthorizedSchema = z2.discriminatedUnion("reason", [
|
|
638
367
|
unauthorizedReasonSchema({
|
|
639
|
-
reason:
|
|
368
|
+
reason: z2.literal("missing_token")
|
|
640
369
|
}),
|
|
641
370
|
unauthorizedReasonSchema({
|
|
642
|
-
reason:
|
|
371
|
+
reason: z2.literal("invalid_token")
|
|
643
372
|
}),
|
|
644
373
|
unauthorizedReasonSchema({
|
|
645
|
-
reason:
|
|
374
|
+
reason: z2.literal("expired_token")
|
|
646
375
|
}),
|
|
647
376
|
unauthorizedReasonSchema({
|
|
648
|
-
reason:
|
|
377
|
+
reason: z2.literal("invalid_secret")
|
|
649
378
|
}),
|
|
650
379
|
unauthorizedReasonSchema({
|
|
651
|
-
reason:
|
|
380
|
+
reason: z2.literal("user_mismatch")
|
|
652
381
|
}),
|
|
653
382
|
unauthorizedReasonSchema({
|
|
654
|
-
reason:
|
|
383
|
+
reason: z2.literal("insufficient_scope")
|
|
655
384
|
}),
|
|
656
385
|
unauthorizedReasonSchema({
|
|
657
|
-
reason:
|
|
658
|
-
policy:
|
|
659
|
-
value:
|
|
386
|
+
reason: z2.literal("policy_denied"),
|
|
387
|
+
policy: z2.enum(["ip", "geo", "mtls", "challenge", "other"]),
|
|
388
|
+
value: z2.string().optional()
|
|
660
389
|
})
|
|
661
390
|
]);
|
|
662
|
-
var failureSchema =
|
|
663
|
-
|
|
664
|
-
kind:
|
|
391
|
+
var failureSchema = z2.discriminatedUnion("kind", [
|
|
392
|
+
z2.object({
|
|
393
|
+
kind: z2.literal("timeout"),
|
|
665
394
|
timeoutMs: intNonNegSchema.optional(),
|
|
666
|
-
message:
|
|
395
|
+
message: z2.string().optional()
|
|
667
396
|
}),
|
|
668
|
-
|
|
669
|
-
kind:
|
|
397
|
+
z2.object({
|
|
398
|
+
kind: z2.literal("unauthorized"),
|
|
670
399
|
why: unauthorizedSchema,
|
|
671
|
-
message:
|
|
400
|
+
message: z2.string().optional()
|
|
672
401
|
}),
|
|
673
|
-
|
|
674
|
-
kind:
|
|
675
|
-
resource:
|
|
676
|
-
message:
|
|
402
|
+
z2.object({
|
|
403
|
+
kind: z2.literal("not_found"),
|
|
404
|
+
resource: z2.enum(["tunnel", "client", "route"]),
|
|
405
|
+
message: z2.string().optional()
|
|
677
406
|
}),
|
|
678
|
-
|
|
679
|
-
kind:
|
|
680
|
-
reason:
|
|
681
|
-
message:
|
|
407
|
+
z2.object({
|
|
408
|
+
kind: z2.literal("refused"),
|
|
409
|
+
reason: z2.enum(["capacity", "policy", "unsupported", "other"]),
|
|
410
|
+
message: z2.string().optional()
|
|
682
411
|
}),
|
|
683
|
-
|
|
684
|
-
|
|
412
|
+
z2.object({ kind: z2.literal("io"), message: z2.string().optional() }),
|
|
413
|
+
z2.object({ kind: z2.literal("internal"), message: z2.string().optional() })
|
|
685
414
|
]);
|
|
686
|
-
var firewallSchema =
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
decision:
|
|
415
|
+
var firewallSchema = z2.discriminatedUnion("decision", [
|
|
416
|
+
z2.object({ decision: z2.literal("allowed"), rule: firewallRuleSchema }),
|
|
417
|
+
z2.object({
|
|
418
|
+
decision: z2.literal("denied"),
|
|
690
419
|
rule: firewallRuleSchema,
|
|
691
420
|
failure: failureSchema
|
|
692
421
|
})
|
|
693
422
|
]);
|
|
694
|
-
var routedTunnelSchema =
|
|
695
|
-
tunnelId:
|
|
696
|
-
tunnelName:
|
|
697
|
-
hostname:
|
|
698
|
-
protocol:
|
|
699
|
-
published:
|
|
700
|
-
type:
|
|
701
|
-
tlsMode:
|
|
702
|
-
httpVersion:
|
|
703
|
-
httpUseTls:
|
|
704
|
-
upstreamTls:
|
|
705
|
-
tokenAuth:
|
|
706
|
-
mtls_auth:
|
|
423
|
+
var routedTunnelSchema = z2.object({
|
|
424
|
+
tunnelId: nonEmptyStringSchema.optional(),
|
|
425
|
+
tunnelName: z2.string().optional(),
|
|
426
|
+
hostname: z2.string().optional(),
|
|
427
|
+
protocol: z2.string().optional(),
|
|
428
|
+
published: z2.boolean().optional(),
|
|
429
|
+
type: z2.string().optional(),
|
|
430
|
+
tlsMode: z2.string().optional(),
|
|
431
|
+
httpVersion: z2.string().optional(),
|
|
432
|
+
httpUseTls: z2.boolean().optional(),
|
|
433
|
+
upstreamTls: z2.boolean().optional(),
|
|
434
|
+
tokenAuth: z2.boolean().optional(),
|
|
435
|
+
mtls_auth: z2.boolean().optional()
|
|
707
436
|
});
|
|
708
|
-
var routingSchema =
|
|
709
|
-
|
|
710
|
-
|
|
437
|
+
var routingSchema = z2.discriminatedUnion("decision", [
|
|
438
|
+
z2.object({ decision: z2.literal("routed"), tunnel: routedTunnelSchema }),
|
|
439
|
+
z2.object({ decision: z2.literal("not_routed"), failure: failureSchema })
|
|
711
440
|
]);
|
|
712
|
-
var streamConnectedMetricsSchema =
|
|
441
|
+
var streamConnectedMetricsSchema = z2.object({
|
|
713
442
|
establish_ms: numNonNegSchema,
|
|
714
443
|
duration_ms: numNonNegSchema,
|
|
715
444
|
upstream_bytes: intNonNegSchema,
|
|
716
445
|
downstream_bytes: intNonNegSchema
|
|
717
446
|
});
|
|
718
|
-
var streamFailedMetricsSchema =
|
|
447
|
+
var streamFailedMetricsSchema = z2.object({
|
|
719
448
|
time_to_fail_ms: numNonNegSchema.optional(),
|
|
720
449
|
establish_ms: numNonNegSchema.optional()
|
|
721
450
|
});
|
|
722
|
-
var terminationSchema =
|
|
723
|
-
by:
|
|
724
|
-
reason:
|
|
725
|
-
message:
|
|
451
|
+
var terminationSchema = z2.object({
|
|
452
|
+
by: z2.enum(["downstream", "upstream", "server", "unknown"]),
|
|
453
|
+
reason: z2.enum(["closed", "reset", "timeout", "error", "unknown"]),
|
|
454
|
+
message: z2.string().optional()
|
|
726
455
|
});
|
|
727
|
-
var responseConnectedSchema =
|
|
728
|
-
outcome:
|
|
456
|
+
var responseConnectedSchema = z2.object({
|
|
457
|
+
outcome: z2.literal("connected"),
|
|
729
458
|
established_at: isoDateTimeSchema,
|
|
730
459
|
upstream: streamEndpointSchema.optional(),
|
|
731
460
|
metrics: streamConnectedMetricsSchema,
|
|
732
461
|
termination: terminationSchema.optional(),
|
|
733
462
|
http: httpResponseStageSchema.optional()
|
|
734
463
|
});
|
|
735
|
-
var responseFailedSchema =
|
|
736
|
-
outcome:
|
|
464
|
+
var responseFailedSchema = z2.object({
|
|
465
|
+
outcome: z2.literal("failed"),
|
|
737
466
|
failure: failureSchema,
|
|
738
467
|
upstream: streamEndpointSchema.optional(),
|
|
739
468
|
metrics: streamFailedMetricsSchema.optional(),
|
|
740
469
|
termination: terminationSchema.optional(),
|
|
741
470
|
http: httpResponseStageSchema.optional()
|
|
742
471
|
});
|
|
743
|
-
var responseSchema =
|
|
472
|
+
var responseSchema = z2.discriminatedUnion("outcome", [
|
|
744
473
|
responseConnectedSchema,
|
|
745
474
|
responseFailedSchema
|
|
746
475
|
]);
|
|
747
|
-
var streamSummarySchema =
|
|
748
|
-
workspace_id:
|
|
749
|
-
project_id:
|
|
750
|
-
cluster_id:
|
|
751
|
-
user_id:
|
|
752
|
-
client_id:
|
|
753
|
-
tunnel_id:
|
|
754
|
-
stream_id:
|
|
476
|
+
var streamSummarySchema = z2.object({
|
|
477
|
+
workspace_id: nonEmptyStringSchema.optional(),
|
|
478
|
+
project_id: nonEmptyStringSchema.optional(),
|
|
479
|
+
cluster_id: nonEmptyStringSchema.optional(),
|
|
480
|
+
user_id: nonEmptyStringSchema.optional(),
|
|
481
|
+
client_id: nonEmptyStringSchema.optional(),
|
|
482
|
+
tunnel_id: nonEmptyStringSchema.optional(),
|
|
483
|
+
stream_id: nonEmptyStringSchema,
|
|
755
484
|
created_at: isoDateTimeSchema,
|
|
756
485
|
terminated_at: isoDateTimeSchema,
|
|
757
|
-
request:
|
|
486
|
+
request: z2.object({
|
|
758
487
|
downstream: streamEndpointSchema,
|
|
759
488
|
http: httpRequestStageSchema.optional()
|
|
760
489
|
}),
|
|
@@ -764,68 +493,100 @@ var streamSummarySchema = z5.object({
|
|
|
764
493
|
});
|
|
765
494
|
|
|
766
495
|
// src/event.ts
|
|
767
|
-
var
|
|
768
|
-
var
|
|
769
|
-
var
|
|
496
|
+
var import_tunnel = require("@rstreamlabs/rstream/tunnel");
|
|
497
|
+
var z3 = __toESM(require("zod"));
|
|
498
|
+
var isoDateTimeSchema2 = z3.string().datetime({ offset: true });
|
|
499
|
+
var initialStateSchema = z3.object({
|
|
770
500
|
snapshot_at: isoDateTimeSchema2,
|
|
771
|
-
clients:
|
|
772
|
-
tunnels:
|
|
501
|
+
clients: z3.array(clientSchema),
|
|
502
|
+
tunnels: z3.array(import_tunnel.tunnelSchema)
|
|
773
503
|
});
|
|
774
|
-
var eventBaseSchema =
|
|
775
|
-
id:
|
|
504
|
+
var eventBaseSchema = z3.object({
|
|
505
|
+
id: z3.string().optional(),
|
|
776
506
|
created_at: isoDateTimeSchema2.optional(),
|
|
777
|
-
user_id:
|
|
778
|
-
workspace_id:
|
|
779
|
-
project_id:
|
|
780
|
-
cluster_id:
|
|
507
|
+
user_id: z3.string().optional(),
|
|
508
|
+
workspace_id: z3.string().optional(),
|
|
509
|
+
project_id: z3.string().optional(),
|
|
510
|
+
cluster_id: z3.string().optional()
|
|
781
511
|
});
|
|
782
|
-
var withEventBase = (shape) =>
|
|
512
|
+
var withEventBase = (shape) => z3.object(shape).merge(eventBaseSchema).passthrough();
|
|
783
513
|
var stateInitialEventSchema = withEventBase({
|
|
784
|
-
type:
|
|
514
|
+
type: z3.literal("state.initial"),
|
|
785
515
|
object: initialStateSchema
|
|
786
516
|
});
|
|
787
517
|
var streamSummaryEventSchema = withEventBase({
|
|
788
|
-
type:
|
|
518
|
+
type: z3.literal("stream.summary"),
|
|
789
519
|
object: streamSummarySchema
|
|
790
520
|
});
|
|
791
521
|
var commonEventsSchema = [
|
|
792
522
|
withEventBase({
|
|
793
|
-
type:
|
|
523
|
+
type: z3.literal("client.created"),
|
|
794
524
|
object: clientSchema
|
|
795
525
|
}),
|
|
796
526
|
withEventBase({
|
|
797
|
-
type:
|
|
527
|
+
type: z3.literal("client.updated"),
|
|
798
528
|
object: clientSchema
|
|
799
529
|
}),
|
|
800
530
|
withEventBase({
|
|
801
|
-
type:
|
|
531
|
+
type: z3.literal("client.deleted"),
|
|
802
532
|
object: clientSchema
|
|
803
533
|
}),
|
|
804
534
|
withEventBase({
|
|
805
|
-
type:
|
|
806
|
-
object: tunnelSchema
|
|
535
|
+
type: z3.literal("tunnel.created"),
|
|
536
|
+
object: import_tunnel.tunnelSchema
|
|
807
537
|
}),
|
|
808
538
|
withEventBase({
|
|
809
|
-
type:
|
|
810
|
-
object: tunnelSchema
|
|
539
|
+
type: z3.literal("tunnel.updated"),
|
|
540
|
+
object: import_tunnel.tunnelSchema
|
|
811
541
|
}),
|
|
812
542
|
withEventBase({
|
|
813
|
-
type:
|
|
814
|
-
object: tunnelSchema
|
|
543
|
+
type: z3.literal("tunnel.deleted"),
|
|
544
|
+
object: import_tunnel.tunnelSchema
|
|
815
545
|
})
|
|
816
546
|
];
|
|
817
|
-
var wsEventsSchema =
|
|
547
|
+
var wsEventsSchema = z3.union([
|
|
818
548
|
stateInitialEventSchema,
|
|
819
549
|
...commonEventsSchema
|
|
820
550
|
]);
|
|
821
|
-
var webhookEventsSchema =
|
|
551
|
+
var webhookEventsSchema = z3.union([
|
|
822
552
|
...commonEventsSchema,
|
|
823
553
|
streamSummaryEventSchema
|
|
824
554
|
]);
|
|
825
|
-
var eventSchema =
|
|
555
|
+
var eventSchema = z3.union([wsEventsSchema, webhookEventsSchema]);
|
|
556
|
+
|
|
557
|
+
// src/tunnel.ts
|
|
558
|
+
var import_tunnel2 = require("@rstreamlabs/rstream/tunnel");
|
|
559
|
+
var z4 = __toESM(require("zod"));
|
|
560
|
+
var DEFAULT_PUBLISHED_PORT = 443;
|
|
561
|
+
var tunnelFilterSchema = import_tunnel2.tunnelSchema.pick({
|
|
562
|
+
id: true,
|
|
563
|
+
name: true,
|
|
564
|
+
type: true,
|
|
565
|
+
status: true,
|
|
566
|
+
client_id: true,
|
|
567
|
+
user_id: true,
|
|
568
|
+
publish: true,
|
|
569
|
+
protocol: true,
|
|
570
|
+
hostname: true,
|
|
571
|
+
http_version: true,
|
|
572
|
+
labels: true
|
|
573
|
+
}).partial();
|
|
574
|
+
var listTunnelsParamsSchema = z4.object({
|
|
575
|
+
limit: z4.number().int().min(1).optional(),
|
|
576
|
+
filters: tunnelFilterSchema.optional()
|
|
577
|
+
});
|
|
578
|
+
var listTunnelsResponseSchema = z4.array(import_tunnel2.tunnelSchema);
|
|
579
|
+
function formatTunnelHost(tunnel) {
|
|
580
|
+
if (!tunnel.hostname) return tunnel.host;
|
|
581
|
+
if (!tunnel.port || tunnel.port === DEFAULT_PUBLISHED_PORT) {
|
|
582
|
+
return tunnel.hostname;
|
|
583
|
+
}
|
|
584
|
+
return `${tunnel.hostname}:${tunnel.port}`;
|
|
585
|
+
}
|
|
826
586
|
|
|
827
587
|
// src/openapi.ts
|
|
828
|
-
var
|
|
588
|
+
var import_tunnel5 = require("@rstreamlabs/rstream/tunnel");
|
|
589
|
+
var z5 = __toESM(require("zod"));
|
|
829
590
|
var jsonContentType = "application/json";
|
|
830
591
|
var openApiContentType = "application/vnd.oai.openapi+json;version=3.1";
|
|
831
592
|
function isRecord(value) {
|
|
@@ -839,10 +600,10 @@ function dropSchemaKeyword(value) {
|
|
|
839
600
|
}
|
|
840
601
|
function jsonSchemaFor(schema) {
|
|
841
602
|
return dropSchemaKeyword(
|
|
842
|
-
|
|
603
|
+
z5.toJSONSchema(schema, {
|
|
843
604
|
unrepresentable: "any",
|
|
844
605
|
override: (ctx) => {
|
|
845
|
-
if (ctx.zodSchema instanceof
|
|
606
|
+
if (ctx.zodSchema instanceof z5.ZodDate) {
|
|
846
607
|
ctx.jsonSchema.type = "string";
|
|
847
608
|
ctx.jsonSchema.format = "date-time";
|
|
848
609
|
}
|
|
@@ -909,7 +670,7 @@ var readEngineStreamsRules = [
|
|
|
909
670
|
action: "read"
|
|
910
671
|
}
|
|
911
672
|
];
|
|
912
|
-
var watchParamsSchema =
|
|
673
|
+
var watchParamsSchema = z5.object({
|
|
913
674
|
clients: clientFilterSchema.optional(),
|
|
914
675
|
tunnels: tunnelFilterSchema.optional()
|
|
915
676
|
});
|
|
@@ -1037,7 +798,7 @@ var engineOpenApiDocument = {
|
|
|
1037
798
|
Event: jsonSchemaFor(wsEventsSchema),
|
|
1038
799
|
ListClientsParams: jsonSchemaFor(listClientsParamsSchema),
|
|
1039
800
|
ListTunnelsParams: jsonSchemaFor(listTunnelsParamsSchema),
|
|
1040
|
-
TunnelListItem: jsonSchemaFor(tunnelSchema),
|
|
801
|
+
TunnelListItem: jsonSchemaFor(import_tunnel5.tunnelSchema),
|
|
1041
802
|
WatchParams: jsonSchemaFor(watchParamsSchema)
|
|
1042
803
|
}
|
|
1043
804
|
},
|
|
@@ -1288,6 +1049,7 @@ async function resolveManagedTunnelsProject(config) {
|
|
|
1288
1049
|
}
|
|
1289
1050
|
|
|
1290
1051
|
// src/tunnels-resource.ts
|
|
1052
|
+
var import_tunnel7 = require("@rstreamlabs/rstream/tunnel");
|
|
1291
1053
|
function tunnelPathId(id) {
|
|
1292
1054
|
const normalized = id.trim();
|
|
1293
1055
|
if (!normalized) {
|
|
@@ -1314,34 +1076,34 @@ var RstreamTunnelsResource = class {
|
|
|
1314
1076
|
method: "GET"
|
|
1315
1077
|
}
|
|
1316
1078
|
);
|
|
1317
|
-
return tunnelSchema.parse(response);
|
|
1079
|
+
return import_tunnel7.tunnelSchema.parse(response);
|
|
1318
1080
|
}
|
|
1319
1081
|
};
|
|
1320
1082
|
|
|
1321
1083
|
// src/tunnels.ts
|
|
1084
|
+
var import_rstream11 = require("@rstreamlabs/rstream");
|
|
1322
1085
|
var import_rstream12 = require("@rstreamlabs/rstream");
|
|
1323
1086
|
var import_rstream13 = require("@rstreamlabs/rstream");
|
|
1324
|
-
var import_rstream14 = require("@rstreamlabs/rstream");
|
|
1325
1087
|
|
|
1326
1088
|
// src/turn.ts
|
|
1327
1089
|
var import_rstream8 = require("@rstreamlabs/rstream");
|
|
1328
1090
|
var import_rstream9 = require("@rstreamlabs/rstream");
|
|
1329
1091
|
var import_rstream10 = require("@rstreamlabs/rstream");
|
|
1330
|
-
var
|
|
1331
|
-
var
|
|
1092
|
+
var import_turn = require("@rstreamlabs/rstream/turn");
|
|
1093
|
+
var z6 = __toESM(require("zod"));
|
|
1332
1094
|
var import_crypto = __toESM(require("crypto"));
|
|
1333
1095
|
var defaultTURNPort = 3478;
|
|
1334
1096
|
var defaultTURNSPort = 5349;
|
|
1335
1097
|
var defaultTURNCredentialTTLSeconds = 10 * 60;
|
|
1336
1098
|
var maxTURNCredentialTTLSeconds = 60 * 60;
|
|
1337
|
-
var turnTokenClaimsSchema =
|
|
1338
|
-
exp:
|
|
1339
|
-
iat:
|
|
1340
|
-
token_endpoint:
|
|
1341
|
-
tokendpoint:
|
|
1342
|
-
type:
|
|
1099
|
+
var turnTokenClaimsSchema = z6.object({
|
|
1100
|
+
exp: z6.number().int().optional(),
|
|
1101
|
+
iat: z6.number().int().optional(),
|
|
1102
|
+
token_endpoint: z6.string().regex(/^[0-9a-f]{8}$/i).optional(),
|
|
1103
|
+
tokendpoint: z6.string().regex(/^[0-9a-f]{8}$/i).optional(),
|
|
1104
|
+
type: z6.enum(["app", "auth", "pat"])
|
|
1343
1105
|
});
|
|
1344
|
-
var turnCredentialModeSchema =
|
|
1106
|
+
var turnCredentialModeSchema = z6.enum(["api", "app", "pat"]);
|
|
1345
1107
|
function normalizeOptionalString2(value) {
|
|
1346
1108
|
const normalized = value?.trim();
|
|
1347
1109
|
return normalized ? normalized : void 0;
|
|
@@ -1535,7 +1297,7 @@ function createPATTURNCredentials(options) {
|
|
|
1535
1297
|
)
|
|
1536
1298
|
);
|
|
1537
1299
|
const credential = import_crypto.default.createHmac("sha256", key).update(username, "utf8").digest("base64");
|
|
1538
|
-
return
|
|
1300
|
+
return import_turn.turnCredentialsSchema.parse({
|
|
1539
1301
|
credential,
|
|
1540
1302
|
ttl,
|
|
1541
1303
|
urls: createTURNURLs(clusterDomain, options.turnPort, options.turnsPort),
|
|
@@ -1587,7 +1349,7 @@ async function createAPPTURNCredentials(options) {
|
|
|
1587
1349
|
)
|
|
1588
1350
|
);
|
|
1589
1351
|
const credential = import_crypto.default.createHmac("sha256", key).update(username, "utf8").digest("base64");
|
|
1590
|
-
return
|
|
1352
|
+
return import_turn.turnCredentialsSchema.parse({
|
|
1591
1353
|
credential,
|
|
1592
1354
|
ttl: ttlSeconds,
|
|
1593
1355
|
urls: createTURNURLs(clusterDomain, options.turnPort, options.turnsPort),
|
|
@@ -1802,10 +1564,10 @@ var RstreamTunnelsClient = class {
|
|
|
1802
1564
|
const projectEndpoint = normalizeOptionalString3(
|
|
1803
1565
|
this.config?.projectEndpoint
|
|
1804
1566
|
);
|
|
1805
|
-
if (projectEndpoint !== void 0 && normalizeOptionalString3(this.config?.engine) === void 0 && (0,
|
|
1567
|
+
if (projectEndpoint !== void 0 && normalizeOptionalString3(this.config?.engine) === void 0 && (0, import_rstream13.readEnvironment)().engine === void 0) {
|
|
1806
1568
|
const project = await this.getManagedProject();
|
|
1807
1569
|
if (project !== void 0) {
|
|
1808
|
-
const engine = (0,
|
|
1570
|
+
const engine = (0, import_rstream11.getTunnelsProjectEngine)(project);
|
|
1809
1571
|
if (engine) {
|
|
1810
1572
|
return normalizeEngineAddress(engine);
|
|
1811
1573
|
}
|
|
@@ -1891,7 +1653,7 @@ var RstreamTunnelsClient = class {
|
|
|
1891
1653
|
if (!credentials) {
|
|
1892
1654
|
return void 0;
|
|
1893
1655
|
}
|
|
1894
|
-
if (!(0,
|
|
1656
|
+
if (!(0, import_rstream12.isClientCredentials)(credentials)) {
|
|
1895
1657
|
return credentials.token;
|
|
1896
1658
|
}
|
|
1897
1659
|
const tokenParams = await this.getEngineAuthTokenParams();
|
|
@@ -1929,6 +1691,7 @@ function normalizeOptionalString3(value) {
|
|
|
1929
1691
|
}
|
|
1930
1692
|
|
|
1931
1693
|
// src/watch.ts
|
|
1694
|
+
var import_auth_token2 = require("@rstreamlabs/rstream/auth-token");
|
|
1932
1695
|
var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
|
|
1933
1696
|
var maxWatchTokenLifetimeSeconds = 3600;
|
|
1934
1697
|
var watchTokenIssuedAtSkewSeconds = 300;
|
|
@@ -1942,7 +1705,7 @@ function normalizeTransport(transport) {
|
|
|
1942
1705
|
throw new Error("Watch: Unsupported transport.");
|
|
1943
1706
|
}
|
|
1944
1707
|
function validateWatchQueryToken(token) {
|
|
1945
|
-
const parsed = authTokenSchema.safeParse(import_jsonwebtoken.default.decode(token));
|
|
1708
|
+
const parsed = import_auth_token2.authTokenSchema.safeParse(import_jsonwebtoken.default.decode(token));
|
|
1946
1709
|
if (!parsed.success || parsed.data.type === "pat") {
|
|
1947
1710
|
throw new Error(
|
|
1948
1711
|
"Watch requires a short-lived auth or app token for URL-based authentication."
|
|
@@ -2095,7 +1858,7 @@ var Watch = class {
|
|
|
2095
1858
|
};
|
|
2096
1859
|
|
|
2097
1860
|
// src/webtty.ts
|
|
2098
|
-
var
|
|
1861
|
+
var z7 = __toESM(require("zod"));
|
|
2099
1862
|
var osFamilies = [
|
|
2100
1863
|
"linux",
|
|
2101
1864
|
"macos",
|
|
@@ -2104,25 +1867,25 @@ var osFamilies = [
|
|
|
2104
1867
|
"openbsd",
|
|
2105
1868
|
"freebsd"
|
|
2106
1869
|
];
|
|
2107
|
-
var webttyServerSchema =
|
|
2108
|
-
tunnel_id:
|
|
2109
|
-
host:
|
|
2110
|
-
token_auth:
|
|
2111
|
-
os_family:
|
|
2112
|
-
arch:
|
|
2113
|
-
os_id:
|
|
1870
|
+
var webttyServerSchema = z7.object({
|
|
1871
|
+
tunnel_id: z7.string(),
|
|
1872
|
+
host: z7.string(),
|
|
1873
|
+
token_auth: z7.boolean(),
|
|
1874
|
+
os_family: z7.enum(osFamilies).optional(),
|
|
1875
|
+
arch: z7.string().optional(),
|
|
1876
|
+
os_id: z7.string().optional(),
|
|
2114
1877
|
// /etc/os-release::ID (ubuntu, debian, rocky, etc.)
|
|
2115
|
-
os_version_id:
|
|
1878
|
+
os_version_id: z7.string().optional(),
|
|
2116
1879
|
// /etc/os-release::VERSION_ID (24.04, 22.04, 11, 10.0.19045, ...)
|
|
2117
|
-
os_version_codename:
|
|
1880
|
+
os_version_codename: z7.string().optional(),
|
|
2118
1881
|
// /etc/os-release::VERSION_CODENAME (jammy, noble...)
|
|
2119
|
-
os_pretty_name:
|
|
1882
|
+
os_pretty_name: z7.string().optional(),
|
|
2120
1883
|
// /etc/os-release::PRETTY_NAME
|
|
2121
|
-
kernel_release:
|
|
1884
|
+
kernel_release: z7.string().optional(),
|
|
2122
1885
|
// uname -r
|
|
2123
|
-
hostname:
|
|
1886
|
+
hostname: z7.string().optional(),
|
|
2124
1887
|
// uname -n
|
|
2125
|
-
labels:
|
|
1888
|
+
labels: z7.record(z7.string(), z7.string().optional()).optional()
|
|
2126
1889
|
});
|
|
2127
1890
|
function parser(tunnel) {
|
|
2128
1891
|
if (tunnel.status !== "online") return null;
|
|
@@ -2175,18 +1938,11 @@ function parseWebTTYServers(tunnels) {
|
|
|
2175
1938
|
RstreamWebhookRessource,
|
|
2176
1939
|
Tunnels,
|
|
2177
1940
|
Watch,
|
|
2178
|
-
authTokenPermissionsSchema,
|
|
2179
|
-
authTokenSchema,
|
|
2180
|
-
authTokenScopesSchema,
|
|
2181
|
-
authTokenTunnelGrantSchema,
|
|
2182
|
-
authTokenTunnelsScopesSchema,
|
|
2183
1941
|
clientFilterSchema,
|
|
2184
1942
|
clientSchema,
|
|
2185
1943
|
createAPITURNCredentials,
|
|
2186
1944
|
createAPPTURNCredentials,
|
|
2187
1945
|
createAuthTokenFromClientCredentials,
|
|
2188
|
-
createAuthTokenParamsSchema,
|
|
2189
|
-
createAuthTokenResponseSchema,
|
|
2190
1946
|
createPATTURNCredentials,
|
|
2191
1947
|
createTURNCredentials,
|
|
2192
1948
|
engineOpenApiDocument,
|
|
@@ -2207,9 +1963,7 @@ function parseWebTTYServers(tunnels) {
|
|
|
2207
1963
|
streamEndpointSchema,
|
|
2208
1964
|
streamSummarySchema,
|
|
2209
1965
|
streamTLSInfoSchema,
|
|
2210
|
-
tokenSchema,
|
|
2211
1966
|
tunnelFilterSchema,
|
|
2212
|
-
tunnelSchema,
|
|
2213
1967
|
turnCredentialModeSchema,
|
|
2214
1968
|
webhookEventsSchema,
|
|
2215
1969
|
webttyServerSchema,
|