@rstreamlabs/tunnels 3.6.2 → 3.7.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 +7 -5
- package/dist/{chunk-6OUCIT5G.mjs → chunk-K6TZT3PB.mjs} +17 -1
- package/dist/index.d.mts +322 -222
- package/dist/index.d.ts +322 -222
- package/dist/index.js +73 -5
- package/dist/index.mjs +56 -5
- package/dist/openapi.js +17 -1
- package/dist/openapi.mjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(index_exports, {
|
|
|
83
83
|
resolveTunnelsAPIURL: () => resolveTunnelsAPIURL,
|
|
84
84
|
resolveTunnelsCredentials: () => resolveTunnelsCredentials,
|
|
85
85
|
resolveTunnelsEngine: () => resolveTunnelsEngine,
|
|
86
|
+
resolveTunnelsRegion: () => resolveTunnelsRegion,
|
|
86
87
|
resolveWebTTYControlRequestParamsSchema: () => resolveWebTTYControlRequestParamsSchema,
|
|
87
88
|
signWebhookPayload: () => signWebhookPayload,
|
|
88
89
|
streamEndpointSchema: () => streamEndpointSchema,
|
|
@@ -530,8 +531,24 @@ var routedTunnelSchema = z3.object({
|
|
|
530
531
|
tokenAuth: z3.boolean().optional(),
|
|
531
532
|
mtls_auth: z3.boolean().optional()
|
|
532
533
|
});
|
|
534
|
+
var routingNodeSchema = z3.object({
|
|
535
|
+
engineId: nonEmptyStringSchema,
|
|
536
|
+
region: nonEmptyStringSchema,
|
|
537
|
+
generation: nonEmptyStringSchema.optional()
|
|
538
|
+
});
|
|
539
|
+
var routingPathSchema = z3.object({
|
|
540
|
+
mode: z3.enum(["direct", "cross_region"]),
|
|
541
|
+
crossRegionRoutingAllowed: z3.boolean(),
|
|
542
|
+
ingress: routingNodeSchema,
|
|
543
|
+
owner: routingNodeSchema,
|
|
544
|
+
agentTarget: routingNodeSchema
|
|
545
|
+
});
|
|
533
546
|
var routingSchema = z3.discriminatedUnion("decision", [
|
|
534
|
-
z3.object({
|
|
547
|
+
z3.object({
|
|
548
|
+
decision: z3.literal("routed"),
|
|
549
|
+
tunnel: routedTunnelSchema,
|
|
550
|
+
path: routingPathSchema.optional()
|
|
551
|
+
}),
|
|
535
552
|
z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
|
|
536
553
|
]);
|
|
537
554
|
var streamConnectedMetricsSchema = z3.object({
|
|
@@ -1615,6 +1632,16 @@ function normalizeEngineAddress(engine) {
|
|
|
1615
1632
|
function resolveTunnelsAPIURL(apiUrl) {
|
|
1616
1633
|
return trimOptionalString(apiUrl) ?? (0, import_rstream6.readEnvironment)().apiUrl ?? import_rstream3.DEFAULT_API_URL;
|
|
1617
1634
|
}
|
|
1635
|
+
function resolveTunnelsRegion(region) {
|
|
1636
|
+
const value = trimOptionalString(region) ?? (0, import_rstream6.readEnvironment)().region;
|
|
1637
|
+
if (value === void 0 || value.toLowerCase() === "auto") return void 0;
|
|
1638
|
+
if (!/^[a-z0-9](?:[a-z0-9._-]{0,62}[a-z0-9])?$/i.test(value)) {
|
|
1639
|
+
throw new Error(
|
|
1640
|
+
"Region can only contain letters, numbers, dots, underscores, or hyphens."
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
return value.toLowerCase();
|
|
1644
|
+
}
|
|
1618
1645
|
function resolveTunnelsCredentials(credentials) {
|
|
1619
1646
|
if (credentials !== void 0) {
|
|
1620
1647
|
return credentials;
|
|
@@ -1642,11 +1669,25 @@ function resolveControlPlaneCredentials(controlPlaneCredentials, credentials, au
|
|
|
1642
1669
|
return { token: environmentToken };
|
|
1643
1670
|
}
|
|
1644
1671
|
async function resolveTunnelsEngine(config) {
|
|
1672
|
+
const region = resolveTunnelsRegion(config.region);
|
|
1645
1673
|
const explicitEngine = trimOptionalString(config.engine);
|
|
1674
|
+
const environmentEngine = (0, import_rstream6.readEnvironment)().engine;
|
|
1675
|
+
if (region !== void 0 && (explicitEngine || environmentEngine)) {
|
|
1676
|
+
throw new Error(
|
|
1677
|
+
"Region selection cannot be combined with an explicit engine override."
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
if (region !== void 0) {
|
|
1681
|
+
const project = await resolveManagedTunnelsProject(config);
|
|
1682
|
+
const engine = (0, import_rstream4.getTunnelsProjectEngine)(project, region);
|
|
1683
|
+
if (engine) return normalizeEngineAddress(engine);
|
|
1684
|
+
throw new Error(
|
|
1685
|
+
"Failed to resolve the selected regional engine from the managed tunnels project."
|
|
1686
|
+
);
|
|
1687
|
+
}
|
|
1646
1688
|
if (explicitEngine) {
|
|
1647
1689
|
return normalizeEngineAddress(explicitEngine);
|
|
1648
1690
|
}
|
|
1649
|
-
const environmentEngine = (0, import_rstream6.readEnvironment)().engine;
|
|
1650
1691
|
if (environmentEngine) {
|
|
1651
1692
|
return normalizeEngineAddress(environmentEngine);
|
|
1652
1693
|
}
|
|
@@ -1657,7 +1698,7 @@ async function resolveTunnelsEngine(config) {
|
|
|
1657
1698
|
...config,
|
|
1658
1699
|
token
|
|
1659
1700
|
});
|
|
1660
|
-
const engine = (0, import_rstream4.getTunnelsProjectEngine)(project);
|
|
1701
|
+
const engine = (0, import_rstream4.getTunnelsProjectEngine)(project, region);
|
|
1661
1702
|
if (engine) {
|
|
1662
1703
|
return normalizeEngineAddress(engine);
|
|
1663
1704
|
}
|
|
@@ -1686,6 +1727,7 @@ async function resolveManagedTunnelsProject(config) {
|
|
|
1686
1727
|
}
|
|
1687
1728
|
const controlPlane = new import_rstream7.RstreamClient({
|
|
1688
1729
|
apiUrl: resolveTunnelsAPIURL(config.apiUrl),
|
|
1730
|
+
controlPlaneHeaders: config.controlPlaneHeaders,
|
|
1689
1731
|
credentials
|
|
1690
1732
|
});
|
|
1691
1733
|
return await controlPlane.tunnels.projects.resolveByEndpoint(projectEndpoint);
|
|
@@ -2276,9 +2318,30 @@ var RstreamTunnelsClient = class {
|
|
|
2276
2318
|
return this.config?.projectEndpoint;
|
|
2277
2319
|
}
|
|
2278
2320
|
async getEngine() {
|
|
2321
|
+
const region = resolveTunnelsRegion(this.config?.region);
|
|
2279
2322
|
const projectEndpoint = normalizeOptionalString3(
|
|
2280
2323
|
this.config?.projectEndpoint
|
|
2281
2324
|
);
|
|
2325
|
+
if (region !== void 0) {
|
|
2326
|
+
if (normalizeOptionalString3(this.config?.engine) !== void 0 || (0, import_rstream13.readEnvironment)().engine !== void 0) {
|
|
2327
|
+
throw new Error(
|
|
2328
|
+
"Region selection cannot be combined with an explicit engine override."
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
if (projectEndpoint === void 0) {
|
|
2332
|
+
throw new Error(
|
|
2333
|
+
"Managed project endpoint is required for region selection."
|
|
2334
|
+
);
|
|
2335
|
+
}
|
|
2336
|
+
const project = await this.getManagedProject();
|
|
2337
|
+
if (project !== void 0) {
|
|
2338
|
+
const engine = (0, import_rstream11.getTunnelsProjectEngine)(project, region);
|
|
2339
|
+
if (engine) return normalizeEngineAddress(engine);
|
|
2340
|
+
}
|
|
2341
|
+
throw new Error(
|
|
2342
|
+
"Failed to resolve the selected regional engine from the managed tunnels project."
|
|
2343
|
+
);
|
|
2344
|
+
}
|
|
2282
2345
|
if (projectEndpoint !== void 0 && normalizeOptionalString3(this.config?.engine) === void 0 && (0, import_rstream13.readEnvironment)().engine === void 0) {
|
|
2283
2346
|
const project = await this.getManagedProject();
|
|
2284
2347
|
if (project !== void 0) {
|
|
@@ -2294,9 +2357,11 @@ var RstreamTunnelsClient = class {
|
|
|
2294
2357
|
return await resolveTunnelsEngine({
|
|
2295
2358
|
apiUrl: this.config?.apiUrl,
|
|
2296
2359
|
controlPlaneCredentials: this.controlPlaneCredentials,
|
|
2360
|
+
controlPlaneHeaders: this.config?.controlPlaneHeaders,
|
|
2297
2361
|
credentials: this.credentials,
|
|
2298
2362
|
engine: this.config?.engine,
|
|
2299
|
-
projectEndpoint: this.config?.projectEndpoint
|
|
2363
|
+
projectEndpoint: this.config?.projectEndpoint,
|
|
2364
|
+
region: this.config?.region
|
|
2300
2365
|
});
|
|
2301
2366
|
}
|
|
2302
2367
|
async getManagedProject() {
|
|
@@ -2310,8 +2375,10 @@ var RstreamTunnelsClient = class {
|
|
|
2310
2375
|
this.managedProject = resolveManagedTunnelsProject({
|
|
2311
2376
|
apiUrl: this.config?.apiUrl,
|
|
2312
2377
|
controlPlaneCredentials: this.controlPlaneCredentials,
|
|
2378
|
+
controlPlaneHeaders: this.config?.controlPlaneHeaders,
|
|
2313
2379
|
credentials: this.credentials,
|
|
2314
|
-
projectEndpoint
|
|
2380
|
+
projectEndpoint,
|
|
2381
|
+
region: this.config?.region
|
|
2315
2382
|
}).catch((error) => {
|
|
2316
2383
|
this.managedProject = void 0;
|
|
2317
2384
|
throw error;
|
|
@@ -2761,6 +2828,7 @@ function parseWebTTYServers(tunnels) {
|
|
|
2761
2828
|
resolveTunnelsAPIURL,
|
|
2762
2829
|
resolveTunnelsCredentials,
|
|
2763
2830
|
resolveTunnelsEngine,
|
|
2831
|
+
resolveTunnelsRegion,
|
|
2764
2832
|
resolveWebTTYControlRequestParamsSchema,
|
|
2765
2833
|
signWebhookPayload,
|
|
2766
2834
|
streamEndpointSchema,
|
package/dist/index.mjs
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
webTTYTransportSchema,
|
|
49
49
|
webhookEventsSchema,
|
|
50
50
|
wsEventsSchema
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-K6TZT3PB.mjs";
|
|
52
52
|
|
|
53
53
|
// src/auth-resource.ts
|
|
54
54
|
import { createAuthTokenParamsSchema } from "@rstreamlabs/rstream/auth-token";
|
|
@@ -269,6 +269,16 @@ function normalizeEngineAddress(engine) {
|
|
|
269
269
|
function resolveTunnelsAPIURL(apiUrl) {
|
|
270
270
|
return trimOptionalString(apiUrl) ?? readEnvironment().apiUrl ?? DEFAULT_API_URL;
|
|
271
271
|
}
|
|
272
|
+
function resolveTunnelsRegion(region) {
|
|
273
|
+
const value = trimOptionalString(region) ?? readEnvironment().region;
|
|
274
|
+
if (value === void 0 || value.toLowerCase() === "auto") return void 0;
|
|
275
|
+
if (!/^[a-z0-9](?:[a-z0-9._-]{0,62}[a-z0-9])?$/i.test(value)) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
"Region can only contain letters, numbers, dots, underscores, or hyphens."
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
return value.toLowerCase();
|
|
281
|
+
}
|
|
272
282
|
function resolveTunnelsCredentials(credentials) {
|
|
273
283
|
if (credentials !== void 0) {
|
|
274
284
|
return credentials;
|
|
@@ -296,11 +306,25 @@ function resolveControlPlaneCredentials(controlPlaneCredentials, credentials, au
|
|
|
296
306
|
return { token: environmentToken };
|
|
297
307
|
}
|
|
298
308
|
async function resolveTunnelsEngine(config) {
|
|
309
|
+
const region = resolveTunnelsRegion(config.region);
|
|
299
310
|
const explicitEngine = trimOptionalString(config.engine);
|
|
311
|
+
const environmentEngine = readEnvironment().engine;
|
|
312
|
+
if (region !== void 0 && (explicitEngine || environmentEngine)) {
|
|
313
|
+
throw new Error(
|
|
314
|
+
"Region selection cannot be combined with an explicit engine override."
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
if (region !== void 0) {
|
|
318
|
+
const project = await resolveManagedTunnelsProject(config);
|
|
319
|
+
const engine = getTunnelsProjectEngine(project, region);
|
|
320
|
+
if (engine) return normalizeEngineAddress(engine);
|
|
321
|
+
throw new Error(
|
|
322
|
+
"Failed to resolve the selected regional engine from the managed tunnels project."
|
|
323
|
+
);
|
|
324
|
+
}
|
|
300
325
|
if (explicitEngine) {
|
|
301
326
|
return normalizeEngineAddress(explicitEngine);
|
|
302
327
|
}
|
|
303
|
-
const environmentEngine = readEnvironment().engine;
|
|
304
328
|
if (environmentEngine) {
|
|
305
329
|
return normalizeEngineAddress(environmentEngine);
|
|
306
330
|
}
|
|
@@ -311,7 +335,7 @@ async function resolveTunnelsEngine(config) {
|
|
|
311
335
|
...config,
|
|
312
336
|
token
|
|
313
337
|
});
|
|
314
|
-
const engine = getTunnelsProjectEngine(project);
|
|
338
|
+
const engine = getTunnelsProjectEngine(project, region);
|
|
315
339
|
if (engine) {
|
|
316
340
|
return normalizeEngineAddress(engine);
|
|
317
341
|
}
|
|
@@ -340,6 +364,7 @@ async function resolveManagedTunnelsProject(config) {
|
|
|
340
364
|
}
|
|
341
365
|
const controlPlane = new RstreamClient({
|
|
342
366
|
apiUrl: resolveTunnelsAPIURL(config.apiUrl),
|
|
367
|
+
controlPlaneHeaders: config.controlPlaneHeaders,
|
|
343
368
|
credentials
|
|
344
369
|
});
|
|
345
370
|
return await controlPlane.tunnels.projects.resolveByEndpoint(projectEndpoint);
|
|
@@ -930,9 +955,30 @@ var RstreamTunnelsClient = class {
|
|
|
930
955
|
return this.config?.projectEndpoint;
|
|
931
956
|
}
|
|
932
957
|
async getEngine() {
|
|
958
|
+
const region = resolveTunnelsRegion(this.config?.region);
|
|
933
959
|
const projectEndpoint = normalizeOptionalString3(
|
|
934
960
|
this.config?.projectEndpoint
|
|
935
961
|
);
|
|
962
|
+
if (region !== void 0) {
|
|
963
|
+
if (normalizeOptionalString3(this.config?.engine) !== void 0 || readEnvironment2().engine !== void 0) {
|
|
964
|
+
throw new Error(
|
|
965
|
+
"Region selection cannot be combined with an explicit engine override."
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
if (projectEndpoint === void 0) {
|
|
969
|
+
throw new Error(
|
|
970
|
+
"Managed project endpoint is required for region selection."
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
const project = await this.getManagedProject();
|
|
974
|
+
if (project !== void 0) {
|
|
975
|
+
const engine = getTunnelsProjectEngine2(project, region);
|
|
976
|
+
if (engine) return normalizeEngineAddress(engine);
|
|
977
|
+
}
|
|
978
|
+
throw new Error(
|
|
979
|
+
"Failed to resolve the selected regional engine from the managed tunnels project."
|
|
980
|
+
);
|
|
981
|
+
}
|
|
936
982
|
if (projectEndpoint !== void 0 && normalizeOptionalString3(this.config?.engine) === void 0 && readEnvironment2().engine === void 0) {
|
|
937
983
|
const project = await this.getManagedProject();
|
|
938
984
|
if (project !== void 0) {
|
|
@@ -948,9 +994,11 @@ var RstreamTunnelsClient = class {
|
|
|
948
994
|
return await resolveTunnelsEngine({
|
|
949
995
|
apiUrl: this.config?.apiUrl,
|
|
950
996
|
controlPlaneCredentials: this.controlPlaneCredentials,
|
|
997
|
+
controlPlaneHeaders: this.config?.controlPlaneHeaders,
|
|
951
998
|
credentials: this.credentials,
|
|
952
999
|
engine: this.config?.engine,
|
|
953
|
-
projectEndpoint: this.config?.projectEndpoint
|
|
1000
|
+
projectEndpoint: this.config?.projectEndpoint,
|
|
1001
|
+
region: this.config?.region
|
|
954
1002
|
});
|
|
955
1003
|
}
|
|
956
1004
|
async getManagedProject() {
|
|
@@ -964,8 +1012,10 @@ var RstreamTunnelsClient = class {
|
|
|
964
1012
|
this.managedProject = resolveManagedTunnelsProject({
|
|
965
1013
|
apiUrl: this.config?.apiUrl,
|
|
966
1014
|
controlPlaneCredentials: this.controlPlaneCredentials,
|
|
1015
|
+
controlPlaneHeaders: this.config?.controlPlaneHeaders,
|
|
967
1016
|
credentials: this.credentials,
|
|
968
|
-
projectEndpoint
|
|
1017
|
+
projectEndpoint,
|
|
1018
|
+
region: this.config?.region
|
|
969
1019
|
}).catch((error) => {
|
|
970
1020
|
this.managedProject = void 0;
|
|
971
1021
|
throw error;
|
|
@@ -1414,6 +1464,7 @@ export {
|
|
|
1414
1464
|
resolveTunnelsAPIURL,
|
|
1415
1465
|
resolveTunnelsCredentials,
|
|
1416
1466
|
resolveTunnelsEngine,
|
|
1467
|
+
resolveTunnelsRegion,
|
|
1417
1468
|
resolveWebTTYControlRequestParamsSchema,
|
|
1418
1469
|
signWebhookPayload,
|
|
1419
1470
|
streamEndpointSchema,
|
package/dist/openapi.js
CHANGED
|
@@ -270,8 +270,24 @@ var routedTunnelSchema = z3.object({
|
|
|
270
270
|
tokenAuth: z3.boolean().optional(),
|
|
271
271
|
mtls_auth: z3.boolean().optional()
|
|
272
272
|
});
|
|
273
|
+
var routingNodeSchema = z3.object({
|
|
274
|
+
engineId: nonEmptyStringSchema,
|
|
275
|
+
region: nonEmptyStringSchema,
|
|
276
|
+
generation: nonEmptyStringSchema.optional()
|
|
277
|
+
});
|
|
278
|
+
var routingPathSchema = z3.object({
|
|
279
|
+
mode: z3.enum(["direct", "cross_region"]),
|
|
280
|
+
crossRegionRoutingAllowed: z3.boolean(),
|
|
281
|
+
ingress: routingNodeSchema,
|
|
282
|
+
owner: routingNodeSchema,
|
|
283
|
+
agentTarget: routingNodeSchema
|
|
284
|
+
});
|
|
273
285
|
var routingSchema = z3.discriminatedUnion("decision", [
|
|
274
|
-
z3.object({
|
|
286
|
+
z3.object({
|
|
287
|
+
decision: z3.literal("routed"),
|
|
288
|
+
tunnel: routedTunnelSchema,
|
|
289
|
+
path: routingPathSchema.optional()
|
|
290
|
+
}),
|
|
275
291
|
z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
|
|
276
292
|
]);
|
|
277
293
|
var streamConnectedMetricsSchema = z3.object({
|
package/dist/openapi.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstreamlabs/tunnels",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "JS/TS SDK for the rstream Engine API and tunnel runtime APIs.",
|
|
5
5
|
"author": "@uartnet <hello@rstream.io>",
|
|
6
6
|
"repository": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typescript-config": "*"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@rstreamlabs/rstream": "3.
|
|
50
|
+
"@rstreamlabs/rstream": "3.7.0",
|
|
51
51
|
"@types/jsonwebtoken": "^9.0.10",
|
|
52
52
|
"jsonwebtoken": "^9.0.3",
|
|
53
53
|
"zod": "^4.4.3"
|