@rstreamlabs/tunnels 1.0.11 → 3.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 +25 -14
- package/dist/{chunk-NHUJ3FYM.mjs → chunk-UUZYVELQ.mjs} +14 -46
- package/dist/index.d.mts +157 -1691
- package/dist/index.d.ts +157 -1691
- package/dist/index.js +322 -551
- package/dist/index.mjs +118 -306
- package/dist/openapi.js +12 -43
- package/dist/openapi.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -112,22 +112,28 @@ await watch.connect();
|
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
URL-based watch authentication requires a short-lived token with bounded
|
|
115
|
-
lifetime and watch-only tunnel list
|
|
115
|
+
lifetime and watch-only tunnel list resources.
|
|
116
|
+
|
|
117
|
+
Browser integrations should provide `auth` as a function that calls a backend
|
|
118
|
+
token route and returns a fresh watch token for each connection attempt. Do not
|
|
119
|
+
store the `rstream.token` query token as durable browser state.
|
|
116
120
|
|
|
117
121
|
## Scoped Auth Tokens
|
|
118
122
|
|
|
119
123
|
`auth.createAuthToken()` mints short-lived engine tokens. Prefer
|
|
120
|
-
`
|
|
121
|
-
other services.
|
|
124
|
+
`resources.tunnels` when delegating capabilities to devices, browser sessions,
|
|
125
|
+
or other services.
|
|
122
126
|
|
|
123
127
|
```ts
|
|
124
128
|
const { token } = await client.auth.createAuthToken({
|
|
125
129
|
expires_in: 60,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
resources: {
|
|
131
|
+
tunnels: {
|
|
132
|
+
scopes: {
|
|
133
|
+
tunnels: {
|
|
134
|
+
list: { select: { id: true, name: true, protocol: true } },
|
|
135
|
+
connect: { params: { path: { regex: "^/api" } } },
|
|
136
|
+
},
|
|
131
137
|
},
|
|
132
138
|
},
|
|
133
139
|
},
|
|
@@ -135,8 +141,8 @@ const { token } = await client.auth.createAuthToken({
|
|
|
135
141
|
```
|
|
136
142
|
|
|
137
143
|
When the client is configured with `projectEndpoint` or `projectId`, scope-only
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
tunnel resources are project-scoped by default. Pass `projectScoped: false`
|
|
145
|
+
only when a global scope-only tunnel resource is intentional.
|
|
140
146
|
|
|
141
147
|
## TURN Credentials
|
|
142
148
|
|
|
@@ -156,9 +162,14 @@ const turn = await createTURNCredentials({
|
|
|
156
162
|
},
|
|
157
163
|
projectEndpoint: "project-endpoint",
|
|
158
164
|
clusterDomain: "cluster.example.rstream.test",
|
|
165
|
+
ttlSeconds: 600,
|
|
159
166
|
});
|
|
160
167
|
```
|
|
161
168
|
|
|
169
|
+
TURN credentials are short-lived. `ttlSeconds` is optional, defaults to 600 for
|
|
170
|
+
local derivation, and must be an integer between 1 and 3600 seconds. PAT-backed
|
|
171
|
+
credentials are additionally capped by the PAT expiration.
|
|
172
|
+
|
|
162
173
|
## Webhooks
|
|
163
174
|
|
|
164
175
|
Validate signed engine webhook payloads with constant-time signature comparison
|
|
@@ -198,10 +209,10 @@ console.log(engineOpenApiDocument.info.title);
|
|
|
198
209
|
|
|
199
210
|
## Environment Variables
|
|
200
211
|
|
|
201
|
-
| Variable
|
|
202
|
-
|
|
|
203
|
-
| `RSTREAM_API_URL`
|
|
204
|
-
| `RSTREAM_ENGINE`
|
|
212
|
+
| Variable | Purpose |
|
|
213
|
+
| ------------------------------ | --------------------------------------------------------------- |
|
|
214
|
+
| `RSTREAM_API_URL` | Control plane API URL used for managed project resolution. |
|
|
215
|
+
| `RSTREAM_ENGINE` | Engine endpoint used when no engine is provided explicitly. |
|
|
205
216
|
| `RSTREAM_AUTHENTICATION_TOKEN` | Bearer token used when credentials are not provided explicitly. |
|
|
206
217
|
|
|
207
218
|
## Development
|
|
@@ -37,44 +37,9 @@ var listClientsParamsSchema = z.object({
|
|
|
37
37
|
var listClientsResponseSchema = z.array(clientSchema);
|
|
38
38
|
|
|
39
39
|
// src/tunnel.ts
|
|
40
|
+
import { tunnelSchema } from "@rstreamlabs/rstream/tunnel";
|
|
40
41
|
import * as z2 from "zod";
|
|
41
42
|
var DEFAULT_PUBLISHED_PORT = 443;
|
|
42
|
-
var tunnelSchema = z2.object({
|
|
43
|
-
// common properties
|
|
44
|
-
client_id: z2.string(),
|
|
45
|
-
user_id: z2.string().optional(),
|
|
46
|
-
workspace_id: z2.string().optional(),
|
|
47
|
-
project_id: z2.string().optional(),
|
|
48
|
-
cluster_id: z2.string().optional(),
|
|
49
|
-
plan: z2.string().optional(),
|
|
50
|
-
provider: z2.string().optional(),
|
|
51
|
-
region: z2.string().optional(),
|
|
52
|
-
status: z2.enum(["online", "offline"]),
|
|
53
|
-
// tunnel properties
|
|
54
|
-
id: z2.string(),
|
|
55
|
-
creation_date: z2.union([z2.string().datetime(), z2.date()]).optional(),
|
|
56
|
-
name: z2.string().optional(),
|
|
57
|
-
type: z2.enum(["bytestream", "datagram"]).optional(),
|
|
58
|
-
publish: z2.boolean().optional(),
|
|
59
|
-
protocol: z2.enum(["tls", "dtls", "quic", "http"]).optional(),
|
|
60
|
-
labels: z2.record(z2.string(), z2.string()).optional(),
|
|
61
|
-
geo_ip: z2.array(z2.string()).optional(),
|
|
62
|
-
trusted_ips: z2.array(z2.string()).optional(),
|
|
63
|
-
host: z2.string().optional(),
|
|
64
|
-
hostname: z2.string().optional(),
|
|
65
|
-
port: z2.number().int().min(1).max(65535).optional(),
|
|
66
|
-
tls_mode: z2.enum(["passthrough", "terminated"]).optional(),
|
|
67
|
-
tls_alpns: z2.array(z2.string()).optional(),
|
|
68
|
-
tls_min_version: z2.string().optional(),
|
|
69
|
-
tls_ciphers: z2.array(z2.string()).optional(),
|
|
70
|
-
mtls_auth: z2.boolean().optional(),
|
|
71
|
-
http_version: z2.enum(["http/1.1", "h2", "h2c", "h3"]).optional(),
|
|
72
|
-
http_use_tls: z2.boolean().optional(),
|
|
73
|
-
upstream_tls: z2.boolean().optional(),
|
|
74
|
-
token_auth: z2.boolean().optional(),
|
|
75
|
-
rstream_auth: z2.boolean().optional(),
|
|
76
|
-
challenge_mode: z2.boolean().optional()
|
|
77
|
-
});
|
|
78
43
|
var tunnelFilterSchema = tunnelSchema.pick({
|
|
79
44
|
id: true,
|
|
80
45
|
name: true,
|
|
@@ -101,6 +66,9 @@ function formatTunnelHost(tunnel) {
|
|
|
101
66
|
return `${tunnel.hostname}:${tunnel.port}`;
|
|
102
67
|
}
|
|
103
68
|
|
|
69
|
+
// src/openapi.ts
|
|
70
|
+
import { tunnelSchema as tunnelSchema3 } from "@rstreamlabs/rstream/tunnel";
|
|
71
|
+
|
|
104
72
|
// src/stream.ts
|
|
105
73
|
import * as z3 from "zod";
|
|
106
74
|
var nonEmptyStringSchema = z3.string().min(1);
|
|
@@ -305,12 +273,13 @@ var streamSummarySchema = z3.object({
|
|
|
305
273
|
});
|
|
306
274
|
|
|
307
275
|
// src/event.ts
|
|
276
|
+
import { tunnelSchema as tunnelSchema2 } from "@rstreamlabs/rstream/tunnel";
|
|
308
277
|
import * as z4 from "zod";
|
|
309
278
|
var isoDateTimeSchema2 = z4.string().datetime({ offset: true });
|
|
310
279
|
var initialStateSchema = z4.object({
|
|
311
280
|
snapshot_at: isoDateTimeSchema2,
|
|
312
281
|
clients: z4.array(clientSchema),
|
|
313
|
-
tunnels: z4.array(
|
|
282
|
+
tunnels: z4.array(tunnelSchema2)
|
|
314
283
|
});
|
|
315
284
|
var eventBaseSchema = z4.object({
|
|
316
285
|
id: z4.string().optional(),
|
|
@@ -344,15 +313,15 @@ var commonEventsSchema = [
|
|
|
344
313
|
}),
|
|
345
314
|
withEventBase({
|
|
346
315
|
type: z4.literal("tunnel.created"),
|
|
347
|
-
object:
|
|
316
|
+
object: tunnelSchema2
|
|
348
317
|
}),
|
|
349
318
|
withEventBase({
|
|
350
319
|
type: z4.literal("tunnel.updated"),
|
|
351
|
-
object:
|
|
320
|
+
object: tunnelSchema2
|
|
352
321
|
}),
|
|
353
322
|
withEventBase({
|
|
354
323
|
type: z4.literal("tunnel.deleted"),
|
|
355
|
-
object:
|
|
324
|
+
object: tunnelSchema2
|
|
356
325
|
})
|
|
357
326
|
];
|
|
358
327
|
var wsEventsSchema = z4.union([
|
|
@@ -578,7 +547,7 @@ var engineOpenApiDocument = {
|
|
|
578
547
|
Event: jsonSchemaFor(wsEventsSchema),
|
|
579
548
|
ListClientsParams: jsonSchemaFor(listClientsParamsSchema),
|
|
580
549
|
ListTunnelsParams: jsonSchemaFor(listTunnelsParamsSchema),
|
|
581
|
-
TunnelListItem: jsonSchemaFor(
|
|
550
|
+
TunnelListItem: jsonSchemaFor(tunnelSchema3),
|
|
582
551
|
WatchParams: jsonSchemaFor(watchParamsSchema)
|
|
583
552
|
}
|
|
584
553
|
},
|
|
@@ -712,11 +681,6 @@ var engineOpenApiJson = `${JSON.stringify(
|
|
|
712
681
|
`;
|
|
713
682
|
|
|
714
683
|
export {
|
|
715
|
-
tunnelSchema,
|
|
716
|
-
tunnelFilterSchema,
|
|
717
|
-
listTunnelsParamsSchema,
|
|
718
|
-
listTunnelsResponseSchema,
|
|
719
|
-
formatTunnelHost,
|
|
720
684
|
clientSchema,
|
|
721
685
|
clientFilterSchema,
|
|
722
686
|
listClientsParamsSchema,
|
|
@@ -727,6 +691,10 @@ export {
|
|
|
727
691
|
wsEventsSchema,
|
|
728
692
|
webhookEventsSchema,
|
|
729
693
|
eventSchema,
|
|
694
|
+
tunnelFilterSchema,
|
|
695
|
+
listTunnelsParamsSchema,
|
|
696
|
+
listTunnelsResponseSchema,
|
|
697
|
+
formatTunnelHost,
|
|
730
698
|
engineOpenApiDocument,
|
|
731
699
|
engineOpenApiJson
|
|
732
700
|
};
|