@rstreamlabs/tunnels 3.8.3 → 3.10.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.
@@ -0,0 +1,102 @@
1
+ // src/node-engine-http.ts
2
+ import { Agent } from "https";
3
+ import { request } from "https";
4
+ var responseHeaders = (response) => {
5
+ const headers = new Headers();
6
+ for (const [name, value] of Object.entries(response.headers)) {
7
+ if (Array.isArray(value))
8
+ for (const item of value) headers.append(name, item);
9
+ else if (value !== void 0) headers.set(name, value);
10
+ }
11
+ return headers;
12
+ };
13
+ var responseBody = (response) => {
14
+ const state = { ended: false };
15
+ return new ReadableStream({
16
+ start(controller) {
17
+ response.on("data", (chunk) => {
18
+ controller.enqueue(new Uint8Array(chunk));
19
+ response.pause();
20
+ });
21
+ response.once("end", () => {
22
+ if (!state.ended) {
23
+ state.ended = true;
24
+ controller.close();
25
+ }
26
+ });
27
+ response.once("error", (error) => {
28
+ if (!state.ended) {
29
+ state.ended = true;
30
+ controller.error(error);
31
+ }
32
+ });
33
+ response.once("aborted", () => {
34
+ if (!state.ended) {
35
+ state.ended = true;
36
+ controller.error(new Error("Engine response was interrupted."));
37
+ }
38
+ });
39
+ },
40
+ pull() {
41
+ response.resume();
42
+ },
43
+ cancel() {
44
+ state.ended = true;
45
+ response.destroy();
46
+ }
47
+ });
48
+ };
49
+ var NodeEngineHTTP = class {
50
+ constructor(tls) {
51
+ this.tls = tls;
52
+ }
53
+ tls;
54
+ agent = new Agent({
55
+ keepAlive: true,
56
+ maxSockets: 16,
57
+ maxFreeSockets: 4,
58
+ maxTotalSockets: 16
59
+ });
60
+ fetch = async (input, init) => {
61
+ const incoming = new Request(input, init);
62
+ const url = new URL(incoming.url);
63
+ if (url.protocol !== "https:" || url.username || url.password)
64
+ throw new Error(
65
+ "Engine HTTP requests require HTTPS without URL credentials."
66
+ );
67
+ const body = incoming.body ? new Uint8Array(await incoming.arrayBuffer()) : void 0;
68
+ incoming.signal.throwIfAborted();
69
+ return new Promise((resolve, reject) => {
70
+ const outgoing = request(
71
+ url,
72
+ {
73
+ ...this.tls,
74
+ servername: url.hostname,
75
+ agent: this.agent,
76
+ method: incoming.method,
77
+ headers: Object.fromEntries(incoming.headers),
78
+ signal: incoming.signal
79
+ },
80
+ (response) => {
81
+ const status = response.statusCode ?? 502;
82
+ const empty = incoming.method === "HEAD" || [204, 205, 304].includes(status);
83
+ if (empty) response.resume();
84
+ resolve(
85
+ new Response(empty ? null : responseBody(response), {
86
+ status,
87
+ headers: responseHeaders(response)
88
+ })
89
+ );
90
+ }
91
+ );
92
+ outgoing.once("error", reject);
93
+ outgoing.end(body);
94
+ });
95
+ };
96
+ close() {
97
+ this.agent.destroy();
98
+ }
99
+ };
100
+ export {
101
+ NodeEngineHTTP
102
+ };
@@ -24,11 +24,19 @@ declare const engineOpenApiDocument: {
24
24
  };
25
25
  };
26
26
  }[];
27
- security: {
27
+ security: ({
28
28
  bearerAuth: never[];
29
- }[];
29
+ mutualTLS?: undefined;
30
+ } | {
31
+ mutualTLS: never[];
32
+ bearerAuth?: undefined;
33
+ })[];
30
34
  components: {
31
35
  securitySchemes: {
36
+ mutualTLS: {
37
+ type: string;
38
+ description: string;
39
+ };
32
40
  bearerAuth: {
33
41
  type: string;
34
42
  scheme: string;
@@ -98,6 +106,74 @@ declare const engineOpenApiDocument: {
98
106
  };
99
107
  };
100
108
  schemas: {
109
+ EngineDiscovery: {
110
+ type: string;
111
+ required: string[];
112
+ properties: {
113
+ version: {
114
+ type: string;
115
+ const: number;
116
+ };
117
+ projectEndpoint: {
118
+ type: string;
119
+ };
120
+ mtlsApiUrl: {
121
+ type: string;
122
+ format: string;
123
+ example: string;
124
+ };
125
+ capabilities: {
126
+ type: string;
127
+ items: {
128
+ type: string;
129
+ };
130
+ examples: string[][];
131
+ };
132
+ };
133
+ };
134
+ CreateTURNCredentials: {
135
+ type: string;
136
+ additionalProperties: boolean;
137
+ properties: {
138
+ ttlSeconds: {
139
+ type: string;
140
+ minimum: number;
141
+ maximum: number;
142
+ default: number;
143
+ };
144
+ };
145
+ };
146
+ TURNCredentials: {
147
+ type: string;
148
+ required: string[];
149
+ properties: {
150
+ username: {
151
+ type: string;
152
+ maxLength: number;
153
+ description: string;
154
+ };
155
+ credential: {
156
+ type: string;
157
+ maxLength: number;
158
+ description: string;
159
+ };
160
+ urls: {
161
+ type: string;
162
+ minItems: number;
163
+ maxItems: number;
164
+ items: {
165
+ type: string;
166
+ maxLength: number;
167
+ };
168
+ };
169
+ ttl: {
170
+ type: string;
171
+ minimum: number;
172
+ maximum: number;
173
+ description: string;
174
+ };
175
+ };
176
+ };
101
177
  Client: unknown;
102
178
  Event: unknown;
103
179
  ListClientsParams: unknown;
@@ -122,6 +198,164 @@ declare const engineOpenApiDocument: {
122
198
  "read-managed-webtty-recordings": string[];
123
199
  };
124
200
  paths: {
201
+ "/.well-known/rstream/engine": {
202
+ get: {
203
+ tags: string[];
204
+ summary: string;
205
+ operationId: string;
206
+ description: string;
207
+ security: never[];
208
+ responses: {
209
+ "200": {
210
+ description: string;
211
+ headers: {
212
+ "Cache-Control": {
213
+ schema: {
214
+ type: string;
215
+ };
216
+ example: string;
217
+ };
218
+ };
219
+ content: {
220
+ "application/json": {
221
+ schema: {
222
+ $ref: string;
223
+ };
224
+ };
225
+ };
226
+ };
227
+ "404": {
228
+ description: string;
229
+ };
230
+ };
231
+ };
232
+ };
233
+ "/api/turn-server/credentials": {
234
+ post: {
235
+ tags: string[];
236
+ summary: string;
237
+ operationId: string;
238
+ description: string;
239
+ security: ({
240
+ bearerAuth: never[];
241
+ mutualTLS?: undefined;
242
+ } | {
243
+ mutualTLS: never[];
244
+ bearerAuth?: undefined;
245
+ })[];
246
+ requestBody: {
247
+ required: boolean;
248
+ content: {
249
+ "application/json": {
250
+ schema: {
251
+ $ref: string;
252
+ };
253
+ };
254
+ };
255
+ };
256
+ responses: {
257
+ "200": {
258
+ description: string;
259
+ headers: {
260
+ "Cache-Control": {
261
+ schema: {
262
+ type: string;
263
+ };
264
+ example: string;
265
+ };
266
+ };
267
+ content: {
268
+ "application/json": {
269
+ schema: {
270
+ $ref: string;
271
+ };
272
+ };
273
+ };
274
+ };
275
+ "400": {
276
+ description: string;
277
+ headers: {
278
+ "Cache-Control": {
279
+ schema: {
280
+ type: string;
281
+ };
282
+ example: string;
283
+ };
284
+ };
285
+ };
286
+ "401": {
287
+ description: string;
288
+ headers: {
289
+ "Cache-Control": {
290
+ schema: {
291
+ type: string;
292
+ };
293
+ example: string;
294
+ };
295
+ };
296
+ };
297
+ "403": {
298
+ description: string;
299
+ headers: {
300
+ "Cache-Control": {
301
+ schema: {
302
+ type: string;
303
+ };
304
+ example: string;
305
+ };
306
+ };
307
+ };
308
+ "404": {
309
+ description: string;
310
+ headers: {
311
+ "Cache-Control": {
312
+ schema: {
313
+ type: string;
314
+ };
315
+ example: string;
316
+ };
317
+ };
318
+ };
319
+ "409": {
320
+ description: string;
321
+ headers: {
322
+ "Cache-Control": {
323
+ schema: {
324
+ type: string;
325
+ };
326
+ example: string;
327
+ };
328
+ };
329
+ };
330
+ "429": {
331
+ description: string;
332
+ headers: {
333
+ "Cache-Control": {
334
+ schema: {
335
+ type: string;
336
+ };
337
+ example: string;
338
+ };
339
+ };
340
+ };
341
+ "503": {
342
+ description: string;
343
+ headers: {
344
+ "Cache-Control": {
345
+ schema: {
346
+ type: string;
347
+ };
348
+ example: string;
349
+ };
350
+ };
351
+ };
352
+ };
353
+ "x-rstream-required-rules": {
354
+ resource: string;
355
+ action: string;
356
+ }[];
357
+ };
358
+ };
125
359
  "/api/openapi.json": {
126
360
  get: {
127
361
  tags: string[];
@@ -150,9 +384,13 @@ declare const engineOpenApiDocument: {
150
384
  parameters: {
151
385
  $ref: string;
152
386
  }[];
153
- security: {
387
+ security: ({
154
388
  bearerAuth: never[];
155
- }[];
389
+ mutualTLS?: undefined;
390
+ } | {
391
+ mutualTLS: never[];
392
+ bearerAuth?: undefined;
393
+ })[];
156
394
  responses: {
157
395
  "200": {
158
396
  description: string;
@@ -188,9 +426,13 @@ declare const engineOpenApiDocument: {
188
426
  parameters: {
189
427
  $ref: string;
190
428
  }[];
191
- security: {
429
+ security: ({
192
430
  bearerAuth: never[];
193
- }[];
431
+ mutualTLS?: undefined;
432
+ } | {
433
+ mutualTLS: never[];
434
+ bearerAuth?: undefined;
435
+ })[];
194
436
  responses: {
195
437
  "200": {
196
438
  description: string;
@@ -227,9 +469,13 @@ declare const engineOpenApiDocument: {
227
469
  parameters: {
228
470
  $ref: string;
229
471
  }[];
230
- security: {
472
+ security: ({
231
473
  bearerAuth: never[];
232
- }[];
474
+ mutualTLS?: undefined;
475
+ } | {
476
+ mutualTLS: never[];
477
+ bearerAuth?: undefined;
478
+ })[];
233
479
  responses: {
234
480
  "200": {
235
481
  description: string;
@@ -263,9 +509,13 @@ declare const engineOpenApiDocument: {
263
509
  parameters: {
264
510
  $ref: string;
265
511
  }[];
266
- security: {
512
+ security: ({
267
513
  bearerAuth: never[];
268
- }[];
514
+ mutualTLS?: undefined;
515
+ } | {
516
+ mutualTLS: never[];
517
+ bearerAuth?: undefined;
518
+ })[];
269
519
  responses: {
270
520
  "101": {
271
521
  description: string;