@rstreamlabs/tunnels 1.0.7 → 1.0.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@rstreamlabs/tunnels`
2
2
 
3
- Data-plane JS/TS SDK for rstream tunnels.
3
+ Engine API JS/TS SDK for rstream tunnels.
4
4
 
5
5
  Use this package to talk directly to the tunnels engine: list tunnels, inspect
6
6
  clients, watch engine events, validate webhooks, and create fine-grained app
@@ -9,7 +9,7 @@ tokens.
9
9
  The package supports both:
10
10
 
11
11
  - direct engine usage, including self-hosted deployments
12
- - managed rstream projects resolved via the control plane
12
+ - managed rstream projects resolved via the Control plane API
13
13
  - bearer-token authentication and application credentials
14
14
 
15
15
  ## Self-hosted usage
@@ -45,6 +45,10 @@ const turn = await client.turn.createCredentials();
45
45
  `clientSecret`. This is the intended backend flow when you want the server to
46
46
  mint short-lived tokens for downstream clients.
47
47
 
48
+ Managed `projectEndpoint` clients mint engine tokens restricted to the resolved
49
+ project. Explicit `engine` clients using application credentials must provide
50
+ `projectId` or `workspaceId` so locally signed engine tokens are not global.
51
+
48
52
  ```ts
49
53
  import { RstreamTunnelsClient } from "@rstreamlabs/tunnels";
50
54
 
@@ -56,13 +60,16 @@ const client = new RstreamTunnelsClient({
56
60
  projectEndpoint: "project-endpoint",
57
61
  });
58
62
 
59
- const { token } = await client.auth.createAuthToken({ expires_in: 60 });
63
+ const tunnels = await client.tunnels.list();
60
64
  ```
61
65
 
62
66
  ## Fine-Grained Tokens
63
67
 
64
- Use `scopes` for a global grant, or `tunnelsGrants` when the token must be restricted
65
- to specific workspaces or projects.
68
+ Prefer `tunnelsGrants` with explicit operation scopes. When the client is
69
+ configured with `projectEndpoint` or `projectId`, scope-only requests and
70
+ scope-only grant leaves are project-scoped by default. Pass
71
+ `projectScoped: false` only when you intentionally need a global scope-only
72
+ grant.
66
73
 
67
74
  ```ts
68
75
  import { RstreamTunnelsClient } from "@rstreamlabs/tunnels";
@@ -77,18 +84,15 @@ const admin = new RstreamTunnelsClient({
77
84
 
78
85
  const { token } = await admin.auth.createAuthToken({
79
86
  expires_in: 60,
80
- tunnelsGrants: [
81
- {
82
- projects: ["project-id"],
83
- scopes: {
84
- tunnels: {
85
- create: { filters: { protocol: { oneof: ["http"] } } },
86
- connect: { params: { path: { regex: "^/api" } } },
87
- list: { select: { id: true, name: true, protocol: true } },
88
- },
87
+ tunnelsGrants: {
88
+ scopes: {
89
+ tunnels: {
90
+ create: { filters: { protocol: { oneof: ["http"] } } },
91
+ connect: { params: { path: { regex: "^/api" } } },
92
+ list: { select: { id: true, name: true, protocol: true } },
89
93
  },
90
94
  },
91
- ],
95
+ },
92
96
  });
93
97
  ```
94
98
 
@@ -113,4 +117,4 @@ const turn = await createTURNCredentials({
113
117
  `@rstreamlabs/tunnels` reads `RSTREAM_API_URL`, `RSTREAM_ENGINE`, and
114
118
  `RSTREAM_AUTHENTICATION_TOKEN` when they are not provided explicitly.
115
119
 
116
- For managed control-plane APIs, use [`@rstreamlabs/rstream`](../rstream/README.md).
120
+ For the Control plane API, use [`@rstreamlabs/rstream`](../rstream/README.md).
@@ -67,8 +67,7 @@ var tunnelSchema = z2.object({
67
67
  tls_alpns: z2.array(z2.string()).optional(),
68
68
  tls_min_version: z2.string().optional(),
69
69
  tls_ciphers: z2.array(z2.string()).optional(),
70
- mtls: z2.boolean().optional(),
71
- mtls_ca_cert_pem: z2.string().optional(),
70
+ mtls_auth: z2.boolean().optional(),
72
71
  http_version: z2.enum(["http/1.1", "h2", "h2c", "h3"]).optional(),
73
72
  http_use_tls: z2.boolean().optional(),
74
73
  upstream_tls: z2.boolean().optional(),
@@ -245,7 +244,7 @@ var routedTunnelSchema = z3.object({
245
244
  httpUseTls: z3.boolean().optional(),
246
245
  upstreamTls: z3.boolean().optional(),
247
246
  tokenAuth: z3.boolean().optional(),
248
- mtls: z3.boolean().optional()
247
+ mtls_auth: z3.boolean().optional()
249
248
  });
250
249
  var routingSchema = z3.discriminatedUnion("decision", [
251
250
  z3.object({ decision: z3.literal("routed"), tunnel: routedTunnelSchema }),
@@ -487,7 +486,7 @@ var engineOpenApiDocument = {
487
486
  info: {
488
487
  title: "rstream Engine API",
489
488
  version: "1.0.0",
490
- description: "Operational data-plane API exposed by rstream-engine. This surface is scoped to the authenticated engine or project endpoint and covers live clients, live tunnels, and state-change streams."
489
+ description: "Operational Engine API exposed by rstream-engine. This surface is scoped to the authenticated engine or project endpoint and covers live clients, live tunnels, and state-change streams."
491
490
  },
492
491
  servers: [
493
492
  {
@@ -513,12 +512,6 @@ var engineOpenApiDocument = {
513
512
  scheme: "bearer",
514
513
  bearerFormat: "rstream token",
515
514
  description: "Preferred authentication mechanism. Send an OAuth-issued rstream access token or compatible rstream credential in Authorization: Bearer <token>."
516
- },
517
- queryToken: {
518
- type: "apiKey",
519
- in: "query",
520
- name: "rstream.token",
521
- description: "Fallback authentication mechanism for transports where setting Authorization is impractical. Prefer bearerAuth whenever possible."
522
515
  }
523
516
  },
524
517
  parameters: {
@@ -638,7 +631,7 @@ var engineOpenApiDocument = {
638
631
  summary: "List visible engine clients.",
639
632
  operationId: "list_engine_clients",
640
633
  parameters: [{ $ref: "#/components/parameters/ListClientsParams" }],
641
- security: [{ bearerAuth: [] }, { queryToken: [] }],
634
+ security: [{ bearerAuth: [] }],
642
635
  responses: {
643
636
  "200": jsonArrayResponse(
644
637
  "Visible clients.",
@@ -657,7 +650,7 @@ var engineOpenApiDocument = {
657
650
  summary: "List visible engine tunnels.",
658
651
  operationId: "list_engine_tunnels",
659
652
  parameters: [{ $ref: "#/components/parameters/ListTunnelsParams" }],
660
- security: [{ bearerAuth: [] }, { queryToken: [] }],
653
+ security: [{ bearerAuth: [] }],
661
654
  responses: {
662
655
  "200": jsonArrayResponse(
663
656
  "Visible tunnels. Fine-grained list scopes may filter objects and project fields.",
@@ -677,7 +670,7 @@ var engineOpenApiDocument = {
677
670
  summary: "Subscribe to visible engine state through Server-Sent Events.",
678
671
  operationId: "watch_engine_events_sse",
679
672
  parameters: [{ $ref: "#/components/parameters/WatchParams" }],
680
- security: [{ bearerAuth: [] }, { queryToken: [] }],
673
+ security: [{ bearerAuth: [] }],
681
674
  responses: {
682
675
  "200": streamResponse(
683
676
  "SSE stream. Each event is emitted as a data line containing a JSON Event object."
@@ -696,7 +689,7 @@ var engineOpenApiDocument = {
696
689
  summary: "Subscribe to visible engine state through a WebSocket upgrade.",
697
690
  operationId: "watch_engine_events_websocket",
698
691
  parameters: [{ $ref: "#/components/parameters/WatchParams" }],
699
- security: [{ bearerAuth: [] }, { queryToken: [] }],
692
+ security: [{ bearerAuth: [] }],
700
693
  responses: {
701
694
  "101": {
702
695
  description: "WebSocket connection accepted. Frames contain JSON Event objects."