@rstreamlabs/rstream 1.5.0 → 1.6.1
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 +1 -1
- package/dist/index.d.mts +419 -39
- package/dist/index.d.ts +419 -39
- package/dist/index.js +26 -3
- package/dist/index.mjs +26 -3
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -149,6 +149,8 @@ var tunnelSchema = z2.object({
|
|
|
149
149
|
// common properties
|
|
150
150
|
client_id: z2.string(),
|
|
151
151
|
user_id: z2.string(),
|
|
152
|
+
project_id: z2.string(),
|
|
153
|
+
workspace_id: z2.string(),
|
|
152
154
|
status: z2.enum(["online", "offline"]),
|
|
153
155
|
// tunnel properties
|
|
154
156
|
id: z2.string(),
|
|
@@ -199,6 +201,8 @@ var authTokenTunnelsScopesSchema = z3.object({
|
|
|
199
201
|
filters: filters(
|
|
200
202
|
tunnelSchema.omit({
|
|
201
203
|
client_id: true,
|
|
204
|
+
project_id: true,
|
|
205
|
+
workspace_id: true,
|
|
202
206
|
user_id: true,
|
|
203
207
|
status: true,
|
|
204
208
|
creation_date: true
|
|
@@ -269,6 +273,8 @@ var z4 = __toESM(require("zod"));
|
|
|
269
273
|
var clientSchema = z4.object({
|
|
270
274
|
id: z4.string(),
|
|
271
275
|
user_id: z4.string(),
|
|
276
|
+
project_id: z4.string(),
|
|
277
|
+
workspace_id: z4.string(),
|
|
272
278
|
status: z4.enum(["online", "offline"]),
|
|
273
279
|
details: z4.object({
|
|
274
280
|
agent: z4.string().optional(),
|
|
@@ -432,7 +438,13 @@ var RstreamClient = class {
|
|
|
432
438
|
this.cfg = config;
|
|
433
439
|
}
|
|
434
440
|
get engine() {
|
|
435
|
-
|
|
441
|
+
if (this.cfg?.engine) {
|
|
442
|
+
return this.cfg.engine;
|
|
443
|
+
}
|
|
444
|
+
if (process.env.RSTREAM_DEFAULT_ENGINE) {
|
|
445
|
+
return process.env.RSTREAM_DEFAULT_ENGINE;
|
|
446
|
+
}
|
|
447
|
+
return void 0;
|
|
436
448
|
}
|
|
437
449
|
get credentials() {
|
|
438
450
|
if (this.cfg?.credentials && "token" in this.cfg.credentials) {
|
|
@@ -455,7 +467,13 @@ var RstreamClient = class {
|
|
|
455
467
|
return void 0;
|
|
456
468
|
}
|
|
457
469
|
get api() {
|
|
458
|
-
|
|
470
|
+
const engine = this.engine;
|
|
471
|
+
if (!engine) {
|
|
472
|
+
throw new Error(
|
|
473
|
+
"Engine URL is not defined. Please provide an engine in the rstream client configuration or set the RSTREAM_DEFAULT_ENGINE environment variable."
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
return `https://${engine}/api`;
|
|
459
477
|
}
|
|
460
478
|
get auth() {
|
|
461
479
|
return new RstreamAuthRessource(this);
|
|
@@ -523,7 +541,12 @@ var Watch = class {
|
|
|
523
541
|
const payload = authTokenSchema.parse(
|
|
524
542
|
import_jsonwebtoken2.default.decode(token, { complete: false })
|
|
525
543
|
);
|
|
526
|
-
|
|
544
|
+
if (this.config.engine === void 0 && payload.metadata?.engine === void 0) {
|
|
545
|
+
throw new Error(
|
|
546
|
+
"Watch: No engine specified in configuration or token metadata."
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
const base = `https://${this.config.engine || payload.metadata?.engine}`;
|
|
527
550
|
if (this.config.transport === "sse") {
|
|
528
551
|
const url = new URL(`/api/sse`, base);
|
|
529
552
|
url.searchParams.set("rstream.token", token);
|
package/dist/index.mjs
CHANGED
|
@@ -92,6 +92,8 @@ var tunnelSchema = z2.object({
|
|
|
92
92
|
// common properties
|
|
93
93
|
client_id: z2.string(),
|
|
94
94
|
user_id: z2.string(),
|
|
95
|
+
project_id: z2.string(),
|
|
96
|
+
workspace_id: z2.string(),
|
|
95
97
|
status: z2.enum(["online", "offline"]),
|
|
96
98
|
// tunnel properties
|
|
97
99
|
id: z2.string(),
|
|
@@ -142,6 +144,8 @@ var authTokenTunnelsScopesSchema = z3.object({
|
|
|
142
144
|
filters: filters(
|
|
143
145
|
tunnelSchema.omit({
|
|
144
146
|
client_id: true,
|
|
147
|
+
project_id: true,
|
|
148
|
+
workspace_id: true,
|
|
145
149
|
user_id: true,
|
|
146
150
|
status: true,
|
|
147
151
|
creation_date: true
|
|
@@ -212,6 +216,8 @@ import * as z4 from "zod";
|
|
|
212
216
|
var clientSchema = z4.object({
|
|
213
217
|
id: z4.string(),
|
|
214
218
|
user_id: z4.string(),
|
|
219
|
+
project_id: z4.string(),
|
|
220
|
+
workspace_id: z4.string(),
|
|
215
221
|
status: z4.enum(["online", "offline"]),
|
|
216
222
|
details: z4.object({
|
|
217
223
|
agent: z4.string().optional(),
|
|
@@ -375,7 +381,13 @@ var RstreamClient = class {
|
|
|
375
381
|
this.cfg = config;
|
|
376
382
|
}
|
|
377
383
|
get engine() {
|
|
378
|
-
|
|
384
|
+
if (this.cfg?.engine) {
|
|
385
|
+
return this.cfg.engine;
|
|
386
|
+
}
|
|
387
|
+
if (process.env.RSTREAM_DEFAULT_ENGINE) {
|
|
388
|
+
return process.env.RSTREAM_DEFAULT_ENGINE;
|
|
389
|
+
}
|
|
390
|
+
return void 0;
|
|
379
391
|
}
|
|
380
392
|
get credentials() {
|
|
381
393
|
if (this.cfg?.credentials && "token" in this.cfg.credentials) {
|
|
@@ -398,7 +410,13 @@ var RstreamClient = class {
|
|
|
398
410
|
return void 0;
|
|
399
411
|
}
|
|
400
412
|
get api() {
|
|
401
|
-
|
|
413
|
+
const engine = this.engine;
|
|
414
|
+
if (!engine) {
|
|
415
|
+
throw new Error(
|
|
416
|
+
"Engine URL is not defined. Please provide an engine in the rstream client configuration or set the RSTREAM_DEFAULT_ENGINE environment variable."
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
return `https://${engine}/api`;
|
|
402
420
|
}
|
|
403
421
|
get auth() {
|
|
404
422
|
return new RstreamAuthRessource(this);
|
|
@@ -466,7 +484,12 @@ var Watch = class {
|
|
|
466
484
|
const payload = authTokenSchema.parse(
|
|
467
485
|
jwt2.decode(token, { complete: false })
|
|
468
486
|
);
|
|
469
|
-
|
|
487
|
+
if (this.config.engine === void 0 && payload.metadata?.engine === void 0) {
|
|
488
|
+
throw new Error(
|
|
489
|
+
"Watch: No engine specified in configuration or token metadata."
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
const base = `https://${this.config.engine || payload.metadata?.engine}`;
|
|
470
493
|
if (this.config.transport === "sse") {
|
|
471
494
|
const url = new URL(`/api/sse`, base);
|
|
472
495
|
url.searchParams.set("rstream.token", token);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstreamlabs/rstream",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "JS SDK for rstream
|
|
3
|
+
"version": "1.6.1",
|
|
4
|
+
"description": "JS/TS SDK for rstream - serverless networking",
|
|
5
5
|
"author": "@uartnet <hello@rstream.io>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"type-check": "tsc --noEmit"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@turbo/gen": "^2.
|
|
22
|
+
"@turbo/gen": "^2.7.4",
|
|
23
23
|
"@types/jsonwebtoken": "^9.0.10",
|
|
24
|
-
"@types/node": "^
|
|
24
|
+
"@types/node": "^25",
|
|
25
25
|
"eslint-config": "*",
|
|
26
|
-
"eslint": "9.39.
|
|
26
|
+
"eslint": "9.39.2",
|
|
27
27
|
"tsup": "^8.5.1",
|
|
28
28
|
"typescript-config": "*",
|
|
29
29
|
"typescript": "5.9.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"jsonwebtoken": "^9.0.
|
|
32
|
+
"jsonwebtoken": "^9.0.3",
|
|
33
33
|
"zod": "^3.25.76"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|