@rstreamlabs/tunnels 3.6.2 → 3.8.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-3VBF43NB.mjs} +17 -1
- package/dist/index.d.mts +102 -2
- package/dist/index.d.ts +102 -2
- 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 +5 -5
package/README.md
CHANGED
|
@@ -319,11 +319,13 @@ console.log(engineOpenApiDocument.info.title);
|
|
|
319
319
|
|
|
320
320
|
## Environment Variables
|
|
321
321
|
|
|
322
|
-
| Variable
|
|
323
|
-
|
|
|
324
|
-
| `RSTREAM_API_URL`
|
|
325
|
-
| `RSTREAM_ENGINE`
|
|
326
|
-
| `RSTREAM_AUTHENTICATION_TOKEN`
|
|
322
|
+
| Variable | Purpose |
|
|
323
|
+
| ------------------------------- | --------------------------------------------------------------- |
|
|
324
|
+
| `RSTREAM_API_URL` | Control plane API URL used for managed project resolution. |
|
|
325
|
+
| `RSTREAM_ENGINE` | Engine endpoint used when no engine is provided explicitly. |
|
|
326
|
+
| `RSTREAM_AUTHENTICATION_TOKEN` | Bearer token used when credentials are not provided explicitly. |
|
|
327
|
+
| `RSTREAM_REGION` | Authorized region to select for a managed project. |
|
|
328
|
+
| `RSTREAM_CONTROL_PLANE_HEADERS` | Additional Control plane request headers as a JSON object. |
|
|
327
329
|
|
|
328
330
|
## Development
|
|
329
331
|
|
|
@@ -233,8 +233,24 @@ var routedTunnelSchema = z3.object({
|
|
|
233
233
|
tokenAuth: z3.boolean().optional(),
|
|
234
234
|
mtls_auth: z3.boolean().optional()
|
|
235
235
|
});
|
|
236
|
+
var routingNodeSchema = z3.object({
|
|
237
|
+
engineId: nonEmptyStringSchema,
|
|
238
|
+
region: nonEmptyStringSchema,
|
|
239
|
+
generation: nonEmptyStringSchema.optional()
|
|
240
|
+
});
|
|
241
|
+
var routingPathSchema = z3.object({
|
|
242
|
+
mode: z3.enum(["direct", "cross_region"]),
|
|
243
|
+
crossRegionRoutingAllowed: z3.boolean(),
|
|
244
|
+
ingress: routingNodeSchema,
|
|
245
|
+
owner: routingNodeSchema,
|
|
246
|
+
anchor: routingNodeSchema
|
|
247
|
+
});
|
|
236
248
|
var routingSchema = z3.discriminatedUnion("decision", [
|
|
237
|
-
z3.object({
|
|
249
|
+
z3.object({
|
|
250
|
+
decision: z3.literal("routed"),
|
|
251
|
+
tunnel: routedTunnelSchema,
|
|
252
|
+
path: routingPathSchema.optional()
|
|
253
|
+
}),
|
|
238
254
|
z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
|
|
239
255
|
]);
|
|
240
256
|
var streamConnectedMetricsSchema = z3.object({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RstreamCredentials, TURNCredentials as TURNCredentials$1, ClientCredentials, TunnelsProject } from '@rstreamlabs/rstream';
|
|
1
|
+
import { RstreamCredentials, TURNCredentials as TURNCredentials$1, ControlPlaneHeaders, ClientCredentials, TunnelsProject } from '@rstreamlabs/rstream';
|
|
2
2
|
import { CreateAuthTokenParams, CreateAuthTokenResponse } from '@rstreamlabs/rstream/auth-token';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import { Tunnel } from '@rstreamlabs/rstream/tunnel';
|
|
@@ -598,6 +598,28 @@ declare const streamSummaryEventSchema: z.ZodObject<{
|
|
|
598
598
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
599
599
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
600
600
|
}, z.core.$strip>;
|
|
601
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
602
|
+
mode: z.ZodEnum<{
|
|
603
|
+
direct: "direct";
|
|
604
|
+
cross_region: "cross_region";
|
|
605
|
+
}>;
|
|
606
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
607
|
+
ingress: z.ZodObject<{
|
|
608
|
+
engineId: z.ZodString;
|
|
609
|
+
region: z.ZodString;
|
|
610
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
611
|
+
}, z.core.$strip>;
|
|
612
|
+
owner: z.ZodObject<{
|
|
613
|
+
engineId: z.ZodString;
|
|
614
|
+
region: z.ZodString;
|
|
615
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
616
|
+
}, z.core.$strip>;
|
|
617
|
+
anchor: z.ZodObject<{
|
|
618
|
+
engineId: z.ZodString;
|
|
619
|
+
region: z.ZodString;
|
|
620
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
621
|
+
}, z.core.$strip>;
|
|
622
|
+
}, z.core.$strip>>;
|
|
601
623
|
}, z.core.$strip>, z.ZodObject<{
|
|
602
624
|
decision: z.ZodLiteral<"not_routed">;
|
|
603
625
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -2709,6 +2731,28 @@ declare const projectLogEventsSchema: z.ZodObject<{
|
|
|
2709
2731
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
2710
2732
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
2711
2733
|
}, z.core.$strip>;
|
|
2734
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
2735
|
+
mode: z.ZodEnum<{
|
|
2736
|
+
direct: "direct";
|
|
2737
|
+
cross_region: "cross_region";
|
|
2738
|
+
}>;
|
|
2739
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
2740
|
+
ingress: z.ZodObject<{
|
|
2741
|
+
engineId: z.ZodString;
|
|
2742
|
+
region: z.ZodString;
|
|
2743
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
2744
|
+
}, z.core.$strip>;
|
|
2745
|
+
owner: z.ZodObject<{
|
|
2746
|
+
engineId: z.ZodString;
|
|
2747
|
+
region: z.ZodString;
|
|
2748
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
2749
|
+
}, z.core.$strip>;
|
|
2750
|
+
anchor: z.ZodObject<{
|
|
2751
|
+
engineId: z.ZodString;
|
|
2752
|
+
region: z.ZodString;
|
|
2753
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
2754
|
+
}, z.core.$strip>;
|
|
2755
|
+
}, z.core.$strip>>;
|
|
2712
2756
|
}, z.core.$strip>, z.ZodObject<{
|
|
2713
2757
|
decision: z.ZodLiteral<"not_routed">;
|
|
2714
2758
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -4818,6 +4862,28 @@ declare const eventSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject
|
|
|
4818
4862
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
4819
4863
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
4820
4864
|
}, z.core.$strip>;
|
|
4865
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
4866
|
+
mode: z.ZodEnum<{
|
|
4867
|
+
direct: "direct";
|
|
4868
|
+
cross_region: "cross_region";
|
|
4869
|
+
}>;
|
|
4870
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
4871
|
+
ingress: z.ZodObject<{
|
|
4872
|
+
engineId: z.ZodString;
|
|
4873
|
+
region: z.ZodString;
|
|
4874
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
4875
|
+
}, z.core.$strip>;
|
|
4876
|
+
owner: z.ZodObject<{
|
|
4877
|
+
engineId: z.ZodString;
|
|
4878
|
+
region: z.ZodString;
|
|
4879
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
4880
|
+
}, z.core.$strip>;
|
|
4881
|
+
anchor: z.ZodObject<{
|
|
4882
|
+
engineId: z.ZodString;
|
|
4883
|
+
region: z.ZodString;
|
|
4884
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
4885
|
+
}, z.core.$strip>;
|
|
4886
|
+
}, z.core.$strip>>;
|
|
4821
4887
|
}, z.core.$strip>, z.ZodObject<{
|
|
4822
4888
|
decision: z.ZodLiteral<"not_routed">;
|
|
4823
4889
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -5684,6 +5750,11 @@ interface RstreamTunnelsConfig {
|
|
|
5684
5750
|
* Used when the engine is not set explicitly.
|
|
5685
5751
|
*/
|
|
5686
5752
|
projectEndpoint?: string;
|
|
5753
|
+
/**
|
|
5754
|
+
* Region selected from the endpoints authorized for the managed project.
|
|
5755
|
+
* Defaults to automatic project routing.
|
|
5756
|
+
*/
|
|
5757
|
+
region?: string;
|
|
5687
5758
|
/**
|
|
5688
5759
|
* Project ID used to scope locally signed engine auth tokens.
|
|
5689
5760
|
*/
|
|
@@ -5697,6 +5768,10 @@ interface RstreamTunnelsConfig {
|
|
|
5697
5768
|
* Defaults to the same credentials used against the engine when available.
|
|
5698
5769
|
*/
|
|
5699
5770
|
controlPlaneCredentials?: RstreamCredentials;
|
|
5771
|
+
/**
|
|
5772
|
+
* Additional headers sent only to the configured Control plane API.
|
|
5773
|
+
*/
|
|
5774
|
+
controlPlaneHeaders?: ControlPlaneHeaders;
|
|
5700
5775
|
}
|
|
5701
5776
|
declare class RstreamTunnelsClient {
|
|
5702
5777
|
private readonly config?;
|
|
@@ -5744,13 +5819,16 @@ type RstreamAuth = (() => Promise<string>) | string;
|
|
|
5744
5819
|
interface TunnelsResolutionConfig {
|
|
5745
5820
|
apiUrl?: string;
|
|
5746
5821
|
controlPlaneCredentials?: RstreamCredentials;
|
|
5822
|
+
controlPlaneHeaders?: ControlPlaneHeaders;
|
|
5747
5823
|
credentials?: RstreamCredentials;
|
|
5748
5824
|
engine?: string;
|
|
5749
5825
|
projectEndpoint?: string;
|
|
5826
|
+
region?: string;
|
|
5750
5827
|
token?: string;
|
|
5751
5828
|
}
|
|
5752
5829
|
declare function normalizeEngineAddress(engine: string): string;
|
|
5753
5830
|
declare function resolveTunnelsAPIURL(apiUrl?: string): string;
|
|
5831
|
+
declare function resolveTunnelsRegion(region?: string): string | undefined;
|
|
5754
5832
|
declare function resolveTunnelsCredentials(credentials?: RstreamCredentials): RstreamCredentials | undefined;
|
|
5755
5833
|
declare function resolveControlPlaneCredentials(controlPlaneCredentials?: RstreamCredentials, credentials?: RstreamCredentials, authToken?: string): RstreamCredentials | undefined;
|
|
5756
5834
|
declare function resolveTunnelsEngine(config: TunnelsResolutionConfig): Promise<string>;
|
|
@@ -6080,6 +6158,28 @@ declare const streamSummarySchema: z.ZodObject<{
|
|
|
6080
6158
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
6081
6159
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
6082
6160
|
}, z.core.$strip>;
|
|
6161
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
6162
|
+
mode: z.ZodEnum<{
|
|
6163
|
+
direct: "direct";
|
|
6164
|
+
cross_region: "cross_region";
|
|
6165
|
+
}>;
|
|
6166
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
6167
|
+
ingress: z.ZodObject<{
|
|
6168
|
+
engineId: z.ZodString;
|
|
6169
|
+
region: z.ZodString;
|
|
6170
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
6171
|
+
}, z.core.$strip>;
|
|
6172
|
+
owner: z.ZodObject<{
|
|
6173
|
+
engineId: z.ZodString;
|
|
6174
|
+
region: z.ZodString;
|
|
6175
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
6176
|
+
}, z.core.$strip>;
|
|
6177
|
+
anchor: z.ZodObject<{
|
|
6178
|
+
engineId: z.ZodString;
|
|
6179
|
+
region: z.ZodString;
|
|
6180
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
6181
|
+
}, z.core.$strip>;
|
|
6182
|
+
}, z.core.$strip>>;
|
|
6083
6183
|
}, z.core.$strip>, z.ZodObject<{
|
|
6084
6184
|
decision: z.ZodLiteral<"not_routed">;
|
|
6085
6185
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -6565,4 +6665,4 @@ declare const webttyServerSchema: z.ZodObject<{
|
|
|
6565
6665
|
type WebTTYServer = z.infer<typeof webttyServerSchema>;
|
|
6566
6666
|
declare function parseWebTTYServers(tunnels: Tunnel[]): WebTTYServer[];
|
|
6567
6667
|
|
|
6568
|
-
export { type AttachWebTTYParticipantParams, type BuildWebhookHeadersOptions, type Client, type ClientFilter, type CreateAPITURNCredentialsOptions, type CreateAPPTURNCredentialsOptions, type CreateAuthTokenFromClientCredentialsOptions, type CreatePATTURNCredentialsOptions, type CreateTURNCredentialsOptions, type CreateWebTTYControlRequestParams, type DetachWebTTYParticipantParams, type Event, type InitialState, type ListClientsParams, type ListClientsResponse, type ListTunnelsParams, type ListTunnelsResponse, type ListWebTTYControlRequestsParams, type ListWebTTYKeyGrantDecryptMaterialParams, type ListWebTTYSessionGroupsParams, type ListWebTTYSessionsParams, type ProjectLogEvent, type ReadWebTTYSessionEventsParams, type ResolveWebTTYControlRequestParams, type RstreamAuth, RstreamAuthResource, RstreamAuthResource as RstreamAuthRessource, RstreamTunnelsClient as RstreamClient, RstreamClientsResource, RstreamClientsResource as RstreamClientsRessource, RstreamTURNResource, RstreamTunnelsClient, type RstreamTunnelsConfig, RstreamTunnelsResource, RstreamTunnelsResource as RstreamTunnelsRessource, RstreamWebTTYResource, RstreamWebhookResource, RstreamWebhookResource as RstreamWebhookRessource, type StreamEndpoint, type StreamEntry, type StreamSummary, type StreamTLSInfo, type TURNCredentialMode, type TunnelFilter, RstreamTunnelsClient as Tunnels, type TunnelsResolutionConfig, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, Watch, type WatchConfig, type WatchWsEvents, type WebTTYCapabilities, type WebTTYControlRequest, type WebTTYKeyGrant, type WebTTYKeyGrantDecryptMaterial, type WebTTYParticipant, type WebTTYParticipantLive, type WebTTYServer, type WebTTYSession, type WebTTYSessionEvent, type WebTTYSessionGroup, type WebTTYSessionLive, type WebhookEvent, type WebhookHeaders, type WebhookPayload, type WsEvent, attachWebTTYParticipantParamsSchema, buildWebhookHeaders, clientFilterSchema, clientSchema, createAPITURNCredentials, createAPPTURNCredentials, createAuthTokenFromClientCredentials, createPATTURNCredentials, createTURNCredentials, createWebTTYControlRequestParamsSchema, detachWebTTYParticipantParamsSchema, eventSchema, formatStreamAccessPath, formatTunnelHost, generateWebhookSigningSecret, listClientsParamsSchema, listClientsResponseSchema, listTunnelsParamsSchema, listTunnelsResponseSchema, listWebTTYControlRequestsParamsSchema, listWebTTYKeyGrantDecryptMaterialParamsSchema, listWebTTYSessionGroupsParamsSchema, listWebTTYSessionsParamsSchema, normalizeEngineAddress, parseWebTTYServers, projectLogEventsSchema, readWebTTYSessionEventsParamsSchema, resolveControlPlaneCredentials, resolveManagedTunnelsProject, resolveTunnelsAPIURL, resolveTunnelsCredentials, resolveTunnelsEngine, resolveWebTTYControlRequestParamsSchema, signWebhookPayload, streamEndpointSchema, streamEntrySchema, streamSummaryEventSchema, streamSummarySchema, streamTLSInfoSchema, streamWebTTYMetadataSchema, tunnelFilterSchema, turnCredentialModeSchema, webTTYCapabilitiesSchema, webTTYContextMetadataSchema, webTTYControlRequestSchema, webTTYCryptoMetadataSchema, webTTYEncryptionModeSchema, webTTYKeyGrantDecryptMaterialSchema, webTTYKeyGrantSchema, webTTYOriginSchema, webTTYParticipantLiveSchema, webTTYParticipantRoleSchema, webTTYParticipantSchema, webTTYRecordingModeSchema, webTTYSessionEventSchema, webTTYSessionGroupSchema, webTTYSessionLiveSchema, webTTYSessionModeSchema, webTTYSessionSchema, webTTYTransportSchema, webhookEventsSchema, webttyServerSchema, wsEventsSchema };
|
|
6668
|
+
export { type AttachWebTTYParticipantParams, type BuildWebhookHeadersOptions, type Client, type ClientFilter, type CreateAPITURNCredentialsOptions, type CreateAPPTURNCredentialsOptions, type CreateAuthTokenFromClientCredentialsOptions, type CreatePATTURNCredentialsOptions, type CreateTURNCredentialsOptions, type CreateWebTTYControlRequestParams, type DetachWebTTYParticipantParams, type Event, type InitialState, type ListClientsParams, type ListClientsResponse, type ListTunnelsParams, type ListTunnelsResponse, type ListWebTTYControlRequestsParams, type ListWebTTYKeyGrantDecryptMaterialParams, type ListWebTTYSessionGroupsParams, type ListWebTTYSessionsParams, type ProjectLogEvent, type ReadWebTTYSessionEventsParams, type ResolveWebTTYControlRequestParams, type RstreamAuth, RstreamAuthResource, RstreamAuthResource as RstreamAuthRessource, RstreamTunnelsClient as RstreamClient, RstreamClientsResource, RstreamClientsResource as RstreamClientsRessource, RstreamTURNResource, RstreamTunnelsClient, type RstreamTunnelsConfig, RstreamTunnelsResource, RstreamTunnelsResource as RstreamTunnelsRessource, RstreamWebTTYResource, RstreamWebhookResource, RstreamWebhookResource as RstreamWebhookRessource, type StreamEndpoint, type StreamEntry, type StreamSummary, type StreamTLSInfo, type TURNCredentialMode, type TunnelFilter, RstreamTunnelsClient as Tunnels, type TunnelsResolutionConfig, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, Watch, type WatchConfig, type WatchWsEvents, type WebTTYCapabilities, type WebTTYControlRequest, type WebTTYKeyGrant, type WebTTYKeyGrantDecryptMaterial, type WebTTYParticipant, type WebTTYParticipantLive, type WebTTYServer, type WebTTYSession, type WebTTYSessionEvent, type WebTTYSessionGroup, type WebTTYSessionLive, type WebhookEvent, type WebhookHeaders, type WebhookPayload, type WsEvent, attachWebTTYParticipantParamsSchema, buildWebhookHeaders, clientFilterSchema, clientSchema, createAPITURNCredentials, createAPPTURNCredentials, createAuthTokenFromClientCredentials, createPATTURNCredentials, createTURNCredentials, createWebTTYControlRequestParamsSchema, detachWebTTYParticipantParamsSchema, eventSchema, formatStreamAccessPath, formatTunnelHost, generateWebhookSigningSecret, listClientsParamsSchema, listClientsResponseSchema, listTunnelsParamsSchema, listTunnelsResponseSchema, listWebTTYControlRequestsParamsSchema, listWebTTYKeyGrantDecryptMaterialParamsSchema, listWebTTYSessionGroupsParamsSchema, listWebTTYSessionsParamsSchema, normalizeEngineAddress, parseWebTTYServers, projectLogEventsSchema, readWebTTYSessionEventsParamsSchema, resolveControlPlaneCredentials, resolveManagedTunnelsProject, resolveTunnelsAPIURL, resolveTunnelsCredentials, resolveTunnelsEngine, resolveTunnelsRegion, resolveWebTTYControlRequestParamsSchema, signWebhookPayload, streamEndpointSchema, streamEntrySchema, streamSummaryEventSchema, streamSummarySchema, streamTLSInfoSchema, streamWebTTYMetadataSchema, tunnelFilterSchema, turnCredentialModeSchema, webTTYCapabilitiesSchema, webTTYContextMetadataSchema, webTTYControlRequestSchema, webTTYCryptoMetadataSchema, webTTYEncryptionModeSchema, webTTYKeyGrantDecryptMaterialSchema, webTTYKeyGrantSchema, webTTYOriginSchema, webTTYParticipantLiveSchema, webTTYParticipantRoleSchema, webTTYParticipantSchema, webTTYRecordingModeSchema, webTTYSessionEventSchema, webTTYSessionGroupSchema, webTTYSessionLiveSchema, webTTYSessionModeSchema, webTTYSessionSchema, webTTYTransportSchema, webhookEventsSchema, webttyServerSchema, wsEventsSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RstreamCredentials, TURNCredentials as TURNCredentials$1, ClientCredentials, TunnelsProject } from '@rstreamlabs/rstream';
|
|
1
|
+
import { RstreamCredentials, TURNCredentials as TURNCredentials$1, ControlPlaneHeaders, ClientCredentials, TunnelsProject } from '@rstreamlabs/rstream';
|
|
2
2
|
import { CreateAuthTokenParams, CreateAuthTokenResponse } from '@rstreamlabs/rstream/auth-token';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import { Tunnel } from '@rstreamlabs/rstream/tunnel';
|
|
@@ -598,6 +598,28 @@ declare const streamSummaryEventSchema: z.ZodObject<{
|
|
|
598
598
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
599
599
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
600
600
|
}, z.core.$strip>;
|
|
601
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
602
|
+
mode: z.ZodEnum<{
|
|
603
|
+
direct: "direct";
|
|
604
|
+
cross_region: "cross_region";
|
|
605
|
+
}>;
|
|
606
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
607
|
+
ingress: z.ZodObject<{
|
|
608
|
+
engineId: z.ZodString;
|
|
609
|
+
region: z.ZodString;
|
|
610
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
611
|
+
}, z.core.$strip>;
|
|
612
|
+
owner: z.ZodObject<{
|
|
613
|
+
engineId: z.ZodString;
|
|
614
|
+
region: z.ZodString;
|
|
615
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
616
|
+
}, z.core.$strip>;
|
|
617
|
+
anchor: z.ZodObject<{
|
|
618
|
+
engineId: z.ZodString;
|
|
619
|
+
region: z.ZodString;
|
|
620
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
621
|
+
}, z.core.$strip>;
|
|
622
|
+
}, z.core.$strip>>;
|
|
601
623
|
}, z.core.$strip>, z.ZodObject<{
|
|
602
624
|
decision: z.ZodLiteral<"not_routed">;
|
|
603
625
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -2709,6 +2731,28 @@ declare const projectLogEventsSchema: z.ZodObject<{
|
|
|
2709
2731
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
2710
2732
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
2711
2733
|
}, z.core.$strip>;
|
|
2734
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
2735
|
+
mode: z.ZodEnum<{
|
|
2736
|
+
direct: "direct";
|
|
2737
|
+
cross_region: "cross_region";
|
|
2738
|
+
}>;
|
|
2739
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
2740
|
+
ingress: z.ZodObject<{
|
|
2741
|
+
engineId: z.ZodString;
|
|
2742
|
+
region: z.ZodString;
|
|
2743
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
2744
|
+
}, z.core.$strip>;
|
|
2745
|
+
owner: z.ZodObject<{
|
|
2746
|
+
engineId: z.ZodString;
|
|
2747
|
+
region: z.ZodString;
|
|
2748
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
2749
|
+
}, z.core.$strip>;
|
|
2750
|
+
anchor: z.ZodObject<{
|
|
2751
|
+
engineId: z.ZodString;
|
|
2752
|
+
region: z.ZodString;
|
|
2753
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
2754
|
+
}, z.core.$strip>;
|
|
2755
|
+
}, z.core.$strip>>;
|
|
2712
2756
|
}, z.core.$strip>, z.ZodObject<{
|
|
2713
2757
|
decision: z.ZodLiteral<"not_routed">;
|
|
2714
2758
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -4818,6 +4862,28 @@ declare const eventSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject
|
|
|
4818
4862
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
4819
4863
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
4820
4864
|
}, z.core.$strip>;
|
|
4865
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
4866
|
+
mode: z.ZodEnum<{
|
|
4867
|
+
direct: "direct";
|
|
4868
|
+
cross_region: "cross_region";
|
|
4869
|
+
}>;
|
|
4870
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
4871
|
+
ingress: z.ZodObject<{
|
|
4872
|
+
engineId: z.ZodString;
|
|
4873
|
+
region: z.ZodString;
|
|
4874
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
4875
|
+
}, z.core.$strip>;
|
|
4876
|
+
owner: z.ZodObject<{
|
|
4877
|
+
engineId: z.ZodString;
|
|
4878
|
+
region: z.ZodString;
|
|
4879
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
4880
|
+
}, z.core.$strip>;
|
|
4881
|
+
anchor: z.ZodObject<{
|
|
4882
|
+
engineId: z.ZodString;
|
|
4883
|
+
region: z.ZodString;
|
|
4884
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
4885
|
+
}, z.core.$strip>;
|
|
4886
|
+
}, z.core.$strip>>;
|
|
4821
4887
|
}, z.core.$strip>, z.ZodObject<{
|
|
4822
4888
|
decision: z.ZodLiteral<"not_routed">;
|
|
4823
4889
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -5684,6 +5750,11 @@ interface RstreamTunnelsConfig {
|
|
|
5684
5750
|
* Used when the engine is not set explicitly.
|
|
5685
5751
|
*/
|
|
5686
5752
|
projectEndpoint?: string;
|
|
5753
|
+
/**
|
|
5754
|
+
* Region selected from the endpoints authorized for the managed project.
|
|
5755
|
+
* Defaults to automatic project routing.
|
|
5756
|
+
*/
|
|
5757
|
+
region?: string;
|
|
5687
5758
|
/**
|
|
5688
5759
|
* Project ID used to scope locally signed engine auth tokens.
|
|
5689
5760
|
*/
|
|
@@ -5697,6 +5768,10 @@ interface RstreamTunnelsConfig {
|
|
|
5697
5768
|
* Defaults to the same credentials used against the engine when available.
|
|
5698
5769
|
*/
|
|
5699
5770
|
controlPlaneCredentials?: RstreamCredentials;
|
|
5771
|
+
/**
|
|
5772
|
+
* Additional headers sent only to the configured Control plane API.
|
|
5773
|
+
*/
|
|
5774
|
+
controlPlaneHeaders?: ControlPlaneHeaders;
|
|
5700
5775
|
}
|
|
5701
5776
|
declare class RstreamTunnelsClient {
|
|
5702
5777
|
private readonly config?;
|
|
@@ -5744,13 +5819,16 @@ type RstreamAuth = (() => Promise<string>) | string;
|
|
|
5744
5819
|
interface TunnelsResolutionConfig {
|
|
5745
5820
|
apiUrl?: string;
|
|
5746
5821
|
controlPlaneCredentials?: RstreamCredentials;
|
|
5822
|
+
controlPlaneHeaders?: ControlPlaneHeaders;
|
|
5747
5823
|
credentials?: RstreamCredentials;
|
|
5748
5824
|
engine?: string;
|
|
5749
5825
|
projectEndpoint?: string;
|
|
5826
|
+
region?: string;
|
|
5750
5827
|
token?: string;
|
|
5751
5828
|
}
|
|
5752
5829
|
declare function normalizeEngineAddress(engine: string): string;
|
|
5753
5830
|
declare function resolveTunnelsAPIURL(apiUrl?: string): string;
|
|
5831
|
+
declare function resolveTunnelsRegion(region?: string): string | undefined;
|
|
5754
5832
|
declare function resolveTunnelsCredentials(credentials?: RstreamCredentials): RstreamCredentials | undefined;
|
|
5755
5833
|
declare function resolveControlPlaneCredentials(controlPlaneCredentials?: RstreamCredentials, credentials?: RstreamCredentials, authToken?: string): RstreamCredentials | undefined;
|
|
5756
5834
|
declare function resolveTunnelsEngine(config: TunnelsResolutionConfig): Promise<string>;
|
|
@@ -6080,6 +6158,28 @@ declare const streamSummarySchema: z.ZodObject<{
|
|
|
6080
6158
|
tokenAuth: z.ZodOptional<z.ZodBoolean>;
|
|
6081
6159
|
mtls_auth: z.ZodOptional<z.ZodBoolean>;
|
|
6082
6160
|
}, z.core.$strip>;
|
|
6161
|
+
path: z.ZodOptional<z.ZodObject<{
|
|
6162
|
+
mode: z.ZodEnum<{
|
|
6163
|
+
direct: "direct";
|
|
6164
|
+
cross_region: "cross_region";
|
|
6165
|
+
}>;
|
|
6166
|
+
crossRegionRoutingAllowed: z.ZodBoolean;
|
|
6167
|
+
ingress: z.ZodObject<{
|
|
6168
|
+
engineId: z.ZodString;
|
|
6169
|
+
region: z.ZodString;
|
|
6170
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
6171
|
+
}, z.core.$strip>;
|
|
6172
|
+
owner: z.ZodObject<{
|
|
6173
|
+
engineId: z.ZodString;
|
|
6174
|
+
region: z.ZodString;
|
|
6175
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
6176
|
+
}, z.core.$strip>;
|
|
6177
|
+
anchor: z.ZodObject<{
|
|
6178
|
+
engineId: z.ZodString;
|
|
6179
|
+
region: z.ZodString;
|
|
6180
|
+
generation: z.ZodOptional<z.ZodString>;
|
|
6181
|
+
}, z.core.$strip>;
|
|
6182
|
+
}, z.core.$strip>>;
|
|
6083
6183
|
}, z.core.$strip>, z.ZodObject<{
|
|
6084
6184
|
decision: z.ZodLiteral<"not_routed">;
|
|
6085
6185
|
failure: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -6565,4 +6665,4 @@ declare const webttyServerSchema: z.ZodObject<{
|
|
|
6565
6665
|
type WebTTYServer = z.infer<typeof webttyServerSchema>;
|
|
6566
6666
|
declare function parseWebTTYServers(tunnels: Tunnel[]): WebTTYServer[];
|
|
6567
6667
|
|
|
6568
|
-
export { type AttachWebTTYParticipantParams, type BuildWebhookHeadersOptions, type Client, type ClientFilter, type CreateAPITURNCredentialsOptions, type CreateAPPTURNCredentialsOptions, type CreateAuthTokenFromClientCredentialsOptions, type CreatePATTURNCredentialsOptions, type CreateTURNCredentialsOptions, type CreateWebTTYControlRequestParams, type DetachWebTTYParticipantParams, type Event, type InitialState, type ListClientsParams, type ListClientsResponse, type ListTunnelsParams, type ListTunnelsResponse, type ListWebTTYControlRequestsParams, type ListWebTTYKeyGrantDecryptMaterialParams, type ListWebTTYSessionGroupsParams, type ListWebTTYSessionsParams, type ProjectLogEvent, type ReadWebTTYSessionEventsParams, type ResolveWebTTYControlRequestParams, type RstreamAuth, RstreamAuthResource, RstreamAuthResource as RstreamAuthRessource, RstreamTunnelsClient as RstreamClient, RstreamClientsResource, RstreamClientsResource as RstreamClientsRessource, RstreamTURNResource, RstreamTunnelsClient, type RstreamTunnelsConfig, RstreamTunnelsResource, RstreamTunnelsResource as RstreamTunnelsRessource, RstreamWebTTYResource, RstreamWebhookResource, RstreamWebhookResource as RstreamWebhookRessource, type StreamEndpoint, type StreamEntry, type StreamSummary, type StreamTLSInfo, type TURNCredentialMode, type TunnelFilter, RstreamTunnelsClient as Tunnels, type TunnelsResolutionConfig, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, Watch, type WatchConfig, type WatchWsEvents, type WebTTYCapabilities, type WebTTYControlRequest, type WebTTYKeyGrant, type WebTTYKeyGrantDecryptMaterial, type WebTTYParticipant, type WebTTYParticipantLive, type WebTTYServer, type WebTTYSession, type WebTTYSessionEvent, type WebTTYSessionGroup, type WebTTYSessionLive, type WebhookEvent, type WebhookHeaders, type WebhookPayload, type WsEvent, attachWebTTYParticipantParamsSchema, buildWebhookHeaders, clientFilterSchema, clientSchema, createAPITURNCredentials, createAPPTURNCredentials, createAuthTokenFromClientCredentials, createPATTURNCredentials, createTURNCredentials, createWebTTYControlRequestParamsSchema, detachWebTTYParticipantParamsSchema, eventSchema, formatStreamAccessPath, formatTunnelHost, generateWebhookSigningSecret, listClientsParamsSchema, listClientsResponseSchema, listTunnelsParamsSchema, listTunnelsResponseSchema, listWebTTYControlRequestsParamsSchema, listWebTTYKeyGrantDecryptMaterialParamsSchema, listWebTTYSessionGroupsParamsSchema, listWebTTYSessionsParamsSchema, normalizeEngineAddress, parseWebTTYServers, projectLogEventsSchema, readWebTTYSessionEventsParamsSchema, resolveControlPlaneCredentials, resolveManagedTunnelsProject, resolveTunnelsAPIURL, resolveTunnelsCredentials, resolveTunnelsEngine, resolveWebTTYControlRequestParamsSchema, signWebhookPayload, streamEndpointSchema, streamEntrySchema, streamSummaryEventSchema, streamSummarySchema, streamTLSInfoSchema, streamWebTTYMetadataSchema, tunnelFilterSchema, turnCredentialModeSchema, webTTYCapabilitiesSchema, webTTYContextMetadataSchema, webTTYControlRequestSchema, webTTYCryptoMetadataSchema, webTTYEncryptionModeSchema, webTTYKeyGrantDecryptMaterialSchema, webTTYKeyGrantSchema, webTTYOriginSchema, webTTYParticipantLiveSchema, webTTYParticipantRoleSchema, webTTYParticipantSchema, webTTYRecordingModeSchema, webTTYSessionEventSchema, webTTYSessionGroupSchema, webTTYSessionLiveSchema, webTTYSessionModeSchema, webTTYSessionSchema, webTTYTransportSchema, webhookEventsSchema, webttyServerSchema, wsEventsSchema };
|
|
6668
|
+
export { type AttachWebTTYParticipantParams, type BuildWebhookHeadersOptions, type Client, type ClientFilter, type CreateAPITURNCredentialsOptions, type CreateAPPTURNCredentialsOptions, type CreateAuthTokenFromClientCredentialsOptions, type CreatePATTURNCredentialsOptions, type CreateTURNCredentialsOptions, type CreateWebTTYControlRequestParams, type DetachWebTTYParticipantParams, type Event, type InitialState, type ListClientsParams, type ListClientsResponse, type ListTunnelsParams, type ListTunnelsResponse, type ListWebTTYControlRequestsParams, type ListWebTTYKeyGrantDecryptMaterialParams, type ListWebTTYSessionGroupsParams, type ListWebTTYSessionsParams, type ProjectLogEvent, type ReadWebTTYSessionEventsParams, type ResolveWebTTYControlRequestParams, type RstreamAuth, RstreamAuthResource, RstreamAuthResource as RstreamAuthRessource, RstreamTunnelsClient as RstreamClient, RstreamClientsResource, RstreamClientsResource as RstreamClientsRessource, RstreamTURNResource, RstreamTunnelsClient, type RstreamTunnelsConfig, RstreamTunnelsResource, RstreamTunnelsResource as RstreamTunnelsRessource, RstreamWebTTYResource, RstreamWebhookResource, RstreamWebhookResource as RstreamWebhookRessource, type StreamEndpoint, type StreamEntry, type StreamSummary, type StreamTLSInfo, type TURNCredentialMode, type TunnelFilter, RstreamTunnelsClient as Tunnels, type TunnelsResolutionConfig, WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_EVENT_TYPE_HEADER, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, Watch, type WatchConfig, type WatchWsEvents, type WebTTYCapabilities, type WebTTYControlRequest, type WebTTYKeyGrant, type WebTTYKeyGrantDecryptMaterial, type WebTTYParticipant, type WebTTYParticipantLive, type WebTTYServer, type WebTTYSession, type WebTTYSessionEvent, type WebTTYSessionGroup, type WebTTYSessionLive, type WebhookEvent, type WebhookHeaders, type WebhookPayload, type WsEvent, attachWebTTYParticipantParamsSchema, buildWebhookHeaders, clientFilterSchema, clientSchema, createAPITURNCredentials, createAPPTURNCredentials, createAuthTokenFromClientCredentials, createPATTURNCredentials, createTURNCredentials, createWebTTYControlRequestParamsSchema, detachWebTTYParticipantParamsSchema, eventSchema, formatStreamAccessPath, formatTunnelHost, generateWebhookSigningSecret, listClientsParamsSchema, listClientsResponseSchema, listTunnelsParamsSchema, listTunnelsResponseSchema, listWebTTYControlRequestsParamsSchema, listWebTTYKeyGrantDecryptMaterialParamsSchema, listWebTTYSessionGroupsParamsSchema, listWebTTYSessionsParamsSchema, normalizeEngineAddress, parseWebTTYServers, projectLogEventsSchema, readWebTTYSessionEventsParamsSchema, resolveControlPlaneCredentials, resolveManagedTunnelsProject, resolveTunnelsAPIURL, resolveTunnelsCredentials, resolveTunnelsEngine, resolveTunnelsRegion, resolveWebTTYControlRequestParamsSchema, signWebhookPayload, streamEndpointSchema, streamEntrySchema, streamSummaryEventSchema, streamSummarySchema, streamTLSInfoSchema, streamWebTTYMetadataSchema, tunnelFilterSchema, turnCredentialModeSchema, webTTYCapabilitiesSchema, webTTYContextMetadataSchema, webTTYControlRequestSchema, webTTYCryptoMetadataSchema, webTTYEncryptionModeSchema, webTTYKeyGrantDecryptMaterialSchema, webTTYKeyGrantSchema, webTTYOriginSchema, webTTYParticipantLiveSchema, webTTYParticipantRoleSchema, webTTYParticipantSchema, webTTYRecordingModeSchema, webTTYSessionEventSchema, webTTYSessionGroupSchema, webTTYSessionLiveSchema, webTTYSessionModeSchema, webTTYSessionSchema, webTTYTransportSchema, webhookEventsSchema, webttyServerSchema, wsEventsSchema };
|
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
|
+
anchor: 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-3VBF43NB.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
|
+
anchor: 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.8.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": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"type-check": "tsc --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@turbo/gen": "^2.10.
|
|
41
|
+
"@turbo/gen": "^2.10.6",
|
|
42
42
|
"@types/node": "^26",
|
|
43
|
-
"eslint": "9.39.
|
|
43
|
+
"eslint": "9.39.5",
|
|
44
44
|
"eslint-config": "*",
|
|
45
45
|
"tsup": "^8.5.1",
|
|
46
|
-
"typescript": "
|
|
46
|
+
"typescript": "6.0.3",
|
|
47
47
|
"typescript-config": "*"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@rstreamlabs/rstream": "3.
|
|
50
|
+
"@rstreamlabs/rstream": "3.8.0",
|
|
51
51
|
"@types/jsonwebtoken": "^9.0.10",
|
|
52
52
|
"jsonwebtoken": "^9.0.3",
|
|
53
53
|
"zod": "^4.4.3"
|