@tribe-nest/media-protocol 1.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.
Files changed (84) hide show
  1. package/build/_fixtures/joinTokenVectors.json +103 -0
  2. package/build/claims.d.ts +327 -0
  3. package/build/claims.d.ts.map +1 -0
  4. package/build/claims.js +91 -0
  5. package/build/claims.js.map +1 -0
  6. package/build/codecs.d.ts +102 -0
  7. package/build/codecs.d.ts.map +1 -0
  8. package/build/codecs.js +138 -0
  9. package/build/codecs.js.map +1 -0
  10. package/build/errorSchema.d.ts +8 -0
  11. package/build/errorSchema.d.ts.map +1 -0
  12. package/build/errorSchema.js +12 -0
  13. package/build/errorSchema.js.map +1 -0
  14. package/build/errors.d.ts +18 -0
  15. package/build/errors.d.ts.map +1 -0
  16. package/build/errors.js +47 -0
  17. package/build/errors.js.map +1 -0
  18. package/build/frames.d.ts +1291 -0
  19. package/build/frames.d.ts.map +1 -0
  20. package/build/frames.js +222 -0
  21. package/build/frames.js.map +1 -0
  22. package/build/grants.d.ts +307 -0
  23. package/build/grants.d.ts.map +1 -0
  24. package/build/grants.js +228 -0
  25. package/build/grants.js.map +1 -0
  26. package/build/index.d.ts +24 -0
  27. package/build/index.d.ts.map +1 -0
  28. package/build/index.js +40 -0
  29. package/build/index.js.map +1 -0
  30. package/build/mp-build/_fixtures/joinTokenVectors.json +103 -0
  31. package/build/mp-build/claims.d.ts +299 -0
  32. package/build/mp-build/claims.d.ts.map +1 -0
  33. package/build/mp-build/claims.js +60 -0
  34. package/build/mp-build/claims.js.map +1 -0
  35. package/build/mp-build/errorSchema.d.ts +8 -0
  36. package/build/mp-build/errorSchema.d.ts.map +1 -0
  37. package/build/mp-build/errorSchema.js +12 -0
  38. package/build/mp-build/errorSchema.js.map +1 -0
  39. package/build/mp-build/errors.d.ts +18 -0
  40. package/build/mp-build/errors.d.ts.map +1 -0
  41. package/build/mp-build/errors.js +47 -0
  42. package/build/mp-build/errors.js.map +1 -0
  43. package/build/mp-build/frames.d.ts +786 -0
  44. package/build/mp-build/frames.d.ts.map +1 -0
  45. package/build/mp-build/frames.js +153 -0
  46. package/build/mp-build/frames.js.map +1 -0
  47. package/build/mp-build/grants.d.ts +245 -0
  48. package/build/mp-build/grants.d.ts.map +1 -0
  49. package/build/mp-build/grants.js +135 -0
  50. package/build/mp-build/grants.js.map +1 -0
  51. package/build/mp-build/index.d.ts +23 -0
  52. package/build/mp-build/index.d.ts.map +1 -0
  53. package/build/mp-build/index.js +39 -0
  54. package/build/mp-build/index.js.map +1 -0
  55. package/build/mp-build/token.d.ts +66 -0
  56. package/build/mp-build/token.d.ts.map +1 -0
  57. package/build/mp-build/token.js +208 -0
  58. package/build/mp-build/token.js.map +1 -0
  59. package/build/mp-build/version.d.ts +9 -0
  60. package/build/mp-build/version.d.ts.map +1 -0
  61. package/build/mp-build/version.js +12 -0
  62. package/build/mp-build/version.js.map +1 -0
  63. package/build/token.d.ts +66 -0
  64. package/build/token.d.ts.map +1 -0
  65. package/build/token.js +208 -0
  66. package/build/token.js.map +1 -0
  67. package/build/version.d.ts +9 -0
  68. package/build/version.d.ts.map +1 -0
  69. package/build/version.js +12 -0
  70. package/build/version.js.map +1 -0
  71. package/package.json +53 -0
  72. package/src/_fixtures/joinTokenVectors.json +103 -0
  73. package/src/_tests/codecs.spec.ts +66 -0
  74. package/src/_tests/publishGrants.spec.ts +109 -0
  75. package/src/_tests/token.spec.ts +272 -0
  76. package/src/claims.ts +116 -0
  77. package/src/codecs.ts +165 -0
  78. package/src/errorSchema.ts +9 -0
  79. package/src/errors.ts +44 -0
  80. package/src/frames.ts +234 -0
  81. package/src/grants.ts +248 -0
  82. package/src/index.ts +23 -0
  83. package/src/token.ts +237 -0
  84. package/src/version.ts +8 -0
@@ -0,0 +1,786 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The client <-> node signalling wire.
4
+ *
5
+ * One envelope, stated once. Six phase plans independently invented four
6
+ * different ones (`m` / `type` / `method` / `action`, numeric versus string
7
+ * ids, `result` versus `data`), and every mismatch is a hard parse failure
8
+ * discovered at integration by a different pair of people.
9
+ *
10
+ * ## Shape
11
+ *
12
+ * Requests carry an `id` and get exactly one reply with the same `id`. Events
13
+ * carry no `id` and are never replied to. That is the whole protocol; anything
14
+ * needing more structure is a request that returns a handle.
15
+ *
16
+ * ## What is deliberately NOT here
17
+ *
18
+ * No pipe verb, no node id, no mesh address. A client cannot express "pipe this
19
+ * producer to that node", because piping is a side effect of `consume` and the
20
+ * only way to keep it lazy is for eager piping to be unsayable.
21
+ */
22
+ export declare const requestFrameSchema: z.ZodDiscriminatedUnion<"method", [z.ZodObject<{
23
+ method: z.ZodLiteral<"join">;
24
+ id: z.ZodNumber;
25
+ protocolVersion: z.ZodNumber;
26
+ /** The token travels in the first frame, NEVER in the URL: a query string
27
+ * lands in load-balancer access logs, and a join ticket in a log is a join
28
+ * ticket for anyone who can read logs. */
29
+ token: z.ZodString;
30
+ }, "strip", z.ZodTypeAny, {
31
+ method: "join";
32
+ id: number;
33
+ protocolVersion: number;
34
+ token: string;
35
+ }, {
36
+ method: "join";
37
+ id: number;
38
+ protocolVersion: number;
39
+ token: string;
40
+ }>, z.ZodObject<{
41
+ method: z.ZodLiteral<"createTransport">;
42
+ id: z.ZodNumber;
43
+ direction: z.ZodEnum<["send", "recv"]>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ method: "createTransport";
46
+ id: number;
47
+ direction: "send" | "recv";
48
+ }, {
49
+ method: "createTransport";
50
+ id: number;
51
+ direction: "send" | "recv";
52
+ }>, z.ZodObject<{
53
+ method: z.ZodLiteral<"connectTransport">;
54
+ id: z.ZodNumber;
55
+ transportId: z.ZodString;
56
+ dtlsParameters: z.ZodUnknown;
57
+ }, "strip", z.ZodTypeAny, {
58
+ method: "connectTransport";
59
+ id: number;
60
+ transportId: string;
61
+ dtlsParameters?: unknown;
62
+ }, {
63
+ method: "connectTransport";
64
+ id: number;
65
+ transportId: string;
66
+ dtlsParameters?: unknown;
67
+ }>, z.ZodObject<{
68
+ method: z.ZodLiteral<"produce">;
69
+ id: z.ZodNumber;
70
+ transportId: z.ZodString;
71
+ kind: z.ZodEnum<["audio", "video"]>;
72
+ /** Opaque to this package: only mediasoup interprets it. */
73
+ rtpParameters: z.ZodUnknown;
74
+ appData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ kind: "audio" | "video";
77
+ method: "produce";
78
+ id: number;
79
+ transportId: string;
80
+ rtpParameters?: unknown;
81
+ appData?: Record<string, unknown> | undefined;
82
+ }, {
83
+ kind: "audio" | "video";
84
+ method: "produce";
85
+ id: number;
86
+ transportId: string;
87
+ rtpParameters?: unknown;
88
+ appData?: Record<string, unknown> | undefined;
89
+ }>, z.ZodObject<{
90
+ method: z.ZodLiteral<"consume">;
91
+ id: z.ZodNumber;
92
+ transportId: z.ZodString;
93
+ producerId: z.ZodString;
94
+ rtpCapabilities: z.ZodUnknown;
95
+ }, "strip", z.ZodTypeAny, {
96
+ method: "consume";
97
+ id: number;
98
+ transportId: string;
99
+ producerId: string;
100
+ rtpCapabilities?: unknown;
101
+ }, {
102
+ method: "consume";
103
+ id: number;
104
+ transportId: string;
105
+ producerId: string;
106
+ rtpCapabilities?: unknown;
107
+ }>, z.ZodObject<{
108
+ method: z.ZodLiteral<"pauseProducer">;
109
+ id: z.ZodNumber;
110
+ producerId: z.ZodString;
111
+ }, "strip", z.ZodTypeAny, {
112
+ method: "pauseProducer";
113
+ id: number;
114
+ producerId: string;
115
+ }, {
116
+ method: "pauseProducer";
117
+ id: number;
118
+ producerId: string;
119
+ }>, z.ZodObject<{
120
+ method: z.ZodLiteral<"resumeProducer">;
121
+ id: z.ZodNumber;
122
+ producerId: z.ZodString;
123
+ }, "strip", z.ZodTypeAny, {
124
+ method: "resumeProducer";
125
+ id: number;
126
+ producerId: string;
127
+ }, {
128
+ method: "resumeProducer";
129
+ id: number;
130
+ producerId: string;
131
+ }>, z.ZodObject<{
132
+ method: z.ZodLiteral<"resumeConsumer">;
133
+ id: z.ZodNumber;
134
+ consumerId: z.ZodString;
135
+ }, "strip", z.ZodTypeAny, {
136
+ method: "resumeConsumer";
137
+ id: number;
138
+ consumerId: string;
139
+ }, {
140
+ method: "resumeConsumer";
141
+ id: number;
142
+ consumerId: string;
143
+ }>, z.ZodObject<{
144
+ method: z.ZodLiteral<"closeProducer">;
145
+ id: z.ZodNumber;
146
+ producerId: z.ZodString;
147
+ }, "strip", z.ZodTypeAny, {
148
+ method: "closeProducer";
149
+ id: number;
150
+ producerId: string;
151
+ }, {
152
+ method: "closeProducer";
153
+ id: number;
154
+ producerId: string;
155
+ }>, z.ZodObject<{
156
+ method: z.ZodLiteral<"requestKeyFrame">;
157
+ id: z.ZodNumber;
158
+ consumerId: z.ZodString;
159
+ }, "strip", z.ZodTypeAny, {
160
+ method: "requestKeyFrame";
161
+ id: number;
162
+ consumerId: string;
163
+ }, {
164
+ method: "requestKeyFrame";
165
+ id: number;
166
+ consumerId: string;
167
+ }>, z.ZodObject<{
168
+ method: z.ZodLiteral<"leave">;
169
+ id: z.ZodNumber;
170
+ }, "strip", z.ZodTypeAny, {
171
+ method: "leave";
172
+ id: number;
173
+ }, {
174
+ method: "leave";
175
+ id: number;
176
+ }>]>;
177
+ export type RequestFrame = z.infer<typeof requestFrameSchema>;
178
+ export type RequestMethod = RequestFrame["method"];
179
+ export declare const responseFrameSchema: z.ZodUnion<[z.ZodObject<{
180
+ id: z.ZodNumber;
181
+ ok: z.ZodLiteral<true>;
182
+ data: z.ZodUnknown;
183
+ }, "strip", z.ZodTypeAny, {
184
+ id: number;
185
+ ok: true;
186
+ data?: unknown;
187
+ }, {
188
+ id: number;
189
+ ok: true;
190
+ data?: unknown;
191
+ }>, z.ZodObject<{
192
+ id: z.ZodNumber;
193
+ ok: z.ZodLiteral<false>;
194
+ /** The client sees a CODE, never why a token was refused. Telling a caller
195
+ * whether the signature or the room was wrong turns this into an oracle. */
196
+ code: z.ZodEnum<["unauthorized", "replayed", "protocol_version", "forbidden_transport", "forbidden", "not_subscribable", "subscription_limit", "room_closed", "no_such_room", "no_such_producer", "no_such_transport", "duplicate_identity", "node_draining", "capacity", "bad_request", "internal"]>;
197
+ message: z.ZodOptional<z.ZodString>;
198
+ }, "strip", z.ZodTypeAny, {
199
+ code: "unauthorized" | "replayed" | "protocol_version" | "forbidden_transport" | "forbidden" | "not_subscribable" | "subscription_limit" | "room_closed" | "no_such_room" | "no_such_producer" | "no_such_transport" | "duplicate_identity" | "node_draining" | "capacity" | "bad_request" | "internal";
200
+ id: number;
201
+ ok: false;
202
+ message?: string | undefined;
203
+ }, {
204
+ code: "unauthorized" | "replayed" | "protocol_version" | "forbidden_transport" | "forbidden" | "not_subscribable" | "subscription_limit" | "room_closed" | "no_such_room" | "no_such_producer" | "no_such_transport" | "duplicate_identity" | "node_draining" | "capacity" | "bad_request" | "internal";
205
+ id: number;
206
+ ok: false;
207
+ message?: string | undefined;
208
+ }>]>;
209
+ export type ResponseFrame = z.infer<typeof responseFrameSchema>;
210
+ /** A participant as everyone else sees them. Grants are NOT included: what
211
+ * someone else is permitted to do is not the room's business. */
212
+ export declare const peerSchema: z.ZodObject<{
213
+ identity: z.ZodString;
214
+ name: z.ZodOptional<z.ZodString>;
215
+ kind: z.ZodEnum<["human", "agent", "egress", "sip", "ingress"]>;
216
+ }, "strip", z.ZodTypeAny, {
217
+ identity: string;
218
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
219
+ name?: string | undefined;
220
+ }, {
221
+ identity: string;
222
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
223
+ name?: string | undefined;
224
+ }>;
225
+ export type Peer = z.infer<typeof peerSchema>;
226
+ export declare const eventFrameSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
227
+ event: z.ZodLiteral<"joined">;
228
+ identity: z.ZodString;
229
+ room: z.ZodString;
230
+ /** Everything the client needs to build its device before any transport. */
231
+ routerRtpCapabilities: z.ZodUnknown;
232
+ peers: z.ZodArray<z.ZodObject<{
233
+ identity: z.ZodString;
234
+ name: z.ZodOptional<z.ZodString>;
235
+ kind: z.ZodEnum<["human", "agent", "egress", "sip", "ingress"]>;
236
+ }, "strip", z.ZodTypeAny, {
237
+ identity: string;
238
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
239
+ name?: string | undefined;
240
+ }, {
241
+ identity: string;
242
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
243
+ name?: string | undefined;
244
+ }>, "many">;
245
+ /** Producers this participant is ALLOWED to see. The barrier is applied to
246
+ * the snapshot, not only at consume: an identity it may not receive must
247
+ * not be discoverable either. */
248
+ producers: z.ZodArray<z.ZodObject<{
249
+ producerId: z.ZodString;
250
+ identity: z.ZodString;
251
+ kind: z.ZodEnum<["audio", "video"]>;
252
+ }, "strip", z.ZodTypeAny, {
253
+ identity: string;
254
+ kind: "audio" | "video";
255
+ producerId: string;
256
+ }, {
257
+ identity: string;
258
+ kind: "audio" | "video";
259
+ producerId: string;
260
+ }>, "many">;
261
+ iceServers: z.ZodArray<z.ZodObject<{
262
+ urls: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
263
+ username: z.ZodOptional<z.ZodString>;
264
+ credential: z.ZodOptional<z.ZodString>;
265
+ }, "strip", z.ZodTypeAny, {
266
+ urls: string | string[];
267
+ username?: string | undefined;
268
+ credential?: string | undefined;
269
+ }, {
270
+ urls: string | string[];
271
+ username?: string | undefined;
272
+ credential?: string | undefined;
273
+ }>, "many">;
274
+ /** True while any `kind: "egress"` participant is present. A consent
275
+ * requirement, not a nicety. */
276
+ recording: z.ZodBoolean;
277
+ }, "strip", z.ZodTypeAny, {
278
+ room: string;
279
+ identity: string;
280
+ event: "joined";
281
+ peers: {
282
+ identity: string;
283
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
284
+ name?: string | undefined;
285
+ }[];
286
+ producers: {
287
+ identity: string;
288
+ kind: "audio" | "video";
289
+ producerId: string;
290
+ }[];
291
+ iceServers: {
292
+ urls: string | string[];
293
+ username?: string | undefined;
294
+ credential?: string | undefined;
295
+ }[];
296
+ recording: boolean;
297
+ routerRtpCapabilities?: unknown;
298
+ }, {
299
+ room: string;
300
+ identity: string;
301
+ event: "joined";
302
+ peers: {
303
+ identity: string;
304
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
305
+ name?: string | undefined;
306
+ }[];
307
+ producers: {
308
+ identity: string;
309
+ kind: "audio" | "video";
310
+ producerId: string;
311
+ }[];
312
+ iceServers: {
313
+ urls: string | string[];
314
+ username?: string | undefined;
315
+ credential?: string | undefined;
316
+ }[];
317
+ recording: boolean;
318
+ routerRtpCapabilities?: unknown;
319
+ }>, z.ZodObject<{
320
+ event: z.ZodLiteral<"peerJoined">;
321
+ peer: z.ZodObject<{
322
+ identity: z.ZodString;
323
+ name: z.ZodOptional<z.ZodString>;
324
+ kind: z.ZodEnum<["human", "agent", "egress", "sip", "ingress"]>;
325
+ }, "strip", z.ZodTypeAny, {
326
+ identity: string;
327
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
328
+ name?: string | undefined;
329
+ }, {
330
+ identity: string;
331
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
332
+ name?: string | undefined;
333
+ }>;
334
+ }, "strip", z.ZodTypeAny, {
335
+ event: "peerJoined";
336
+ peer: {
337
+ identity: string;
338
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
339
+ name?: string | undefined;
340
+ };
341
+ }, {
342
+ event: "peerJoined";
343
+ peer: {
344
+ identity: string;
345
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
346
+ name?: string | undefined;
347
+ };
348
+ }>, z.ZodObject<{
349
+ event: z.ZodLiteral<"peerLeft">;
350
+ identity: z.ZodString;
351
+ }, "strip", z.ZodTypeAny, {
352
+ identity: string;
353
+ event: "peerLeft";
354
+ }, {
355
+ identity: string;
356
+ event: "peerLeft";
357
+ }>, z.ZodObject<{
358
+ event: z.ZodLiteral<"producerAppeared">;
359
+ producerId: z.ZodString;
360
+ identity: z.ZodString;
361
+ kind: z.ZodEnum<["audio", "video"]>;
362
+ }, "strip", z.ZodTypeAny, {
363
+ identity: string;
364
+ kind: "audio" | "video";
365
+ producerId: string;
366
+ event: "producerAppeared";
367
+ }, {
368
+ identity: string;
369
+ kind: "audio" | "video";
370
+ producerId: string;
371
+ event: "producerAppeared";
372
+ }>, z.ZodObject<{
373
+ event: z.ZodLiteral<"producerClosed">;
374
+ producerId: z.ZodString;
375
+ }, "strip", z.ZodTypeAny, {
376
+ producerId: string;
377
+ event: "producerClosed";
378
+ }, {
379
+ producerId: string;
380
+ event: "producerClosed";
381
+ }>, z.ZodObject<{
382
+ event: z.ZodLiteral<"producerPaused">;
383
+ producerId: z.ZodString;
384
+ paused: z.ZodBoolean;
385
+ }, "strip", z.ZodTypeAny, {
386
+ producerId: string;
387
+ event: "producerPaused";
388
+ paused: boolean;
389
+ }, {
390
+ producerId: string;
391
+ event: "producerPaused";
392
+ paused: boolean;
393
+ }>, z.ZodObject<{
394
+ event: z.ZodLiteral<"activeSpeakers">;
395
+ producerIds: z.ZodArray<z.ZodString, "many">;
396
+ }, "strip", z.ZodTypeAny, {
397
+ event: "activeSpeakers";
398
+ producerIds: string[];
399
+ }, {
400
+ event: "activeSpeakers";
401
+ producerIds: string[];
402
+ }>, z.ZodObject<{
403
+ event: z.ZodLiteral<"recordingChanged">;
404
+ recording: z.ZodBoolean;
405
+ }, "strip", z.ZodTypeAny, {
406
+ event: "recordingChanged";
407
+ recording: boolean;
408
+ }, {
409
+ event: "recordingChanged";
410
+ recording: boolean;
411
+ }>, z.ZodObject<{
412
+ event: z.ZodLiteral<"draining">;
413
+ reconnectAfterMs: z.ZodNumber;
414
+ }, "strip", z.ZodTypeAny, {
415
+ event: "draining";
416
+ reconnectAfterMs: number;
417
+ }, {
418
+ event: "draining";
419
+ reconnectAfterMs: number;
420
+ }>, z.ZodObject<{
421
+ event: z.ZodLiteral<"roomClosed">;
422
+ reason: z.ZodString;
423
+ }, "strip", z.ZodTypeAny, {
424
+ event: "roomClosed";
425
+ reason: string;
426
+ }, {
427
+ event: "roomClosed";
428
+ reason: string;
429
+ }>, z.ZodObject<{
430
+ event: z.ZodLiteral<"subscribeRuleChanged">;
431
+ subscribe: z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{
432
+ mode: z.ZodLiteral<"all">;
433
+ }, "strict", z.ZodTypeAny, {
434
+ mode: "all";
435
+ }, {
436
+ mode: "all";
437
+ }>, z.ZodObject<{
438
+ mode: z.ZodLiteral<"none">;
439
+ }, "strict", z.ZodTypeAny, {
440
+ mode: "none";
441
+ }, {
442
+ mode: "none";
443
+ }>, z.ZodObject<{
444
+ mode: z.ZodLiteral<"allow">;
445
+ identities: z.ZodArray<z.ZodString, "many">;
446
+ }, "strict", z.ZodTypeAny, {
447
+ mode: "allow";
448
+ identities: string[];
449
+ }, {
450
+ mode: "allow";
451
+ identities: string[];
452
+ }>, z.ZodObject<{
453
+ mode: z.ZodLiteral<"deny">;
454
+ identities: z.ZodArray<z.ZodString, "many">;
455
+ }, "strict", z.ZodTypeAny, {
456
+ mode: "deny";
457
+ identities: string[];
458
+ }, {
459
+ mode: "deny";
460
+ identities: string[];
461
+ }>]>;
462
+ }, "strip", z.ZodTypeAny, {
463
+ subscribe: {
464
+ mode: "all";
465
+ } | {
466
+ mode: "none";
467
+ } | {
468
+ mode: "allow";
469
+ identities: string[];
470
+ } | {
471
+ mode: "deny";
472
+ identities: string[];
473
+ };
474
+ event: "subscribeRuleChanged";
475
+ }, {
476
+ subscribe: {
477
+ mode: "all";
478
+ } | {
479
+ mode: "none";
480
+ } | {
481
+ mode: "allow";
482
+ identities: string[];
483
+ } | {
484
+ mode: "deny";
485
+ identities: string[];
486
+ };
487
+ event: "subscribeRuleChanged";
488
+ }>]>;
489
+ export type EventFrame = z.infer<typeof eventFrameSchema>;
490
+ export type EventName = EventFrame["event"];
491
+ /** Anything arriving from a node. */
492
+ export declare const serverFrameSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
493
+ id: z.ZodNumber;
494
+ ok: z.ZodLiteral<true>;
495
+ data: z.ZodUnknown;
496
+ }, "strip", z.ZodTypeAny, {
497
+ id: number;
498
+ ok: true;
499
+ data?: unknown;
500
+ }, {
501
+ id: number;
502
+ ok: true;
503
+ data?: unknown;
504
+ }>, z.ZodObject<{
505
+ id: z.ZodNumber;
506
+ ok: z.ZodLiteral<false>;
507
+ /** The client sees a CODE, never why a token was refused. Telling a caller
508
+ * whether the signature or the room was wrong turns this into an oracle. */
509
+ code: z.ZodEnum<["unauthorized", "replayed", "protocol_version", "forbidden_transport", "forbidden", "not_subscribable", "subscription_limit", "room_closed", "no_such_room", "no_such_producer", "no_such_transport", "duplicate_identity", "node_draining", "capacity", "bad_request", "internal"]>;
510
+ message: z.ZodOptional<z.ZodString>;
511
+ }, "strip", z.ZodTypeAny, {
512
+ code: "unauthorized" | "replayed" | "protocol_version" | "forbidden_transport" | "forbidden" | "not_subscribable" | "subscription_limit" | "room_closed" | "no_such_room" | "no_such_producer" | "no_such_transport" | "duplicate_identity" | "node_draining" | "capacity" | "bad_request" | "internal";
513
+ id: number;
514
+ ok: false;
515
+ message?: string | undefined;
516
+ }, {
517
+ code: "unauthorized" | "replayed" | "protocol_version" | "forbidden_transport" | "forbidden" | "not_subscribable" | "subscription_limit" | "room_closed" | "no_such_room" | "no_such_producer" | "no_such_transport" | "duplicate_identity" | "node_draining" | "capacity" | "bad_request" | "internal";
518
+ id: number;
519
+ ok: false;
520
+ message?: string | undefined;
521
+ }>]>, z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
522
+ event: z.ZodLiteral<"joined">;
523
+ identity: z.ZodString;
524
+ room: z.ZodString;
525
+ /** Everything the client needs to build its device before any transport. */
526
+ routerRtpCapabilities: z.ZodUnknown;
527
+ peers: z.ZodArray<z.ZodObject<{
528
+ identity: z.ZodString;
529
+ name: z.ZodOptional<z.ZodString>;
530
+ kind: z.ZodEnum<["human", "agent", "egress", "sip", "ingress"]>;
531
+ }, "strip", z.ZodTypeAny, {
532
+ identity: string;
533
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
534
+ name?: string | undefined;
535
+ }, {
536
+ identity: string;
537
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
538
+ name?: string | undefined;
539
+ }>, "many">;
540
+ /** Producers this participant is ALLOWED to see. The barrier is applied to
541
+ * the snapshot, not only at consume: an identity it may not receive must
542
+ * not be discoverable either. */
543
+ producers: z.ZodArray<z.ZodObject<{
544
+ producerId: z.ZodString;
545
+ identity: z.ZodString;
546
+ kind: z.ZodEnum<["audio", "video"]>;
547
+ }, "strip", z.ZodTypeAny, {
548
+ identity: string;
549
+ kind: "audio" | "video";
550
+ producerId: string;
551
+ }, {
552
+ identity: string;
553
+ kind: "audio" | "video";
554
+ producerId: string;
555
+ }>, "many">;
556
+ iceServers: z.ZodArray<z.ZodObject<{
557
+ urls: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
558
+ username: z.ZodOptional<z.ZodString>;
559
+ credential: z.ZodOptional<z.ZodString>;
560
+ }, "strip", z.ZodTypeAny, {
561
+ urls: string | string[];
562
+ username?: string | undefined;
563
+ credential?: string | undefined;
564
+ }, {
565
+ urls: string | string[];
566
+ username?: string | undefined;
567
+ credential?: string | undefined;
568
+ }>, "many">;
569
+ /** True while any `kind: "egress"` participant is present. A consent
570
+ * requirement, not a nicety. */
571
+ recording: z.ZodBoolean;
572
+ }, "strip", z.ZodTypeAny, {
573
+ room: string;
574
+ identity: string;
575
+ event: "joined";
576
+ peers: {
577
+ identity: string;
578
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
579
+ name?: string | undefined;
580
+ }[];
581
+ producers: {
582
+ identity: string;
583
+ kind: "audio" | "video";
584
+ producerId: string;
585
+ }[];
586
+ iceServers: {
587
+ urls: string | string[];
588
+ username?: string | undefined;
589
+ credential?: string | undefined;
590
+ }[];
591
+ recording: boolean;
592
+ routerRtpCapabilities?: unknown;
593
+ }, {
594
+ room: string;
595
+ identity: string;
596
+ event: "joined";
597
+ peers: {
598
+ identity: string;
599
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
600
+ name?: string | undefined;
601
+ }[];
602
+ producers: {
603
+ identity: string;
604
+ kind: "audio" | "video";
605
+ producerId: string;
606
+ }[];
607
+ iceServers: {
608
+ urls: string | string[];
609
+ username?: string | undefined;
610
+ credential?: string | undefined;
611
+ }[];
612
+ recording: boolean;
613
+ routerRtpCapabilities?: unknown;
614
+ }>, z.ZodObject<{
615
+ event: z.ZodLiteral<"peerJoined">;
616
+ peer: z.ZodObject<{
617
+ identity: z.ZodString;
618
+ name: z.ZodOptional<z.ZodString>;
619
+ kind: z.ZodEnum<["human", "agent", "egress", "sip", "ingress"]>;
620
+ }, "strip", z.ZodTypeAny, {
621
+ identity: string;
622
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
623
+ name?: string | undefined;
624
+ }, {
625
+ identity: string;
626
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
627
+ name?: string | undefined;
628
+ }>;
629
+ }, "strip", z.ZodTypeAny, {
630
+ event: "peerJoined";
631
+ peer: {
632
+ identity: string;
633
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
634
+ name?: string | undefined;
635
+ };
636
+ }, {
637
+ event: "peerJoined";
638
+ peer: {
639
+ identity: string;
640
+ kind: "human" | "agent" | "egress" | "sip" | "ingress";
641
+ name?: string | undefined;
642
+ };
643
+ }>, z.ZodObject<{
644
+ event: z.ZodLiteral<"peerLeft">;
645
+ identity: z.ZodString;
646
+ }, "strip", z.ZodTypeAny, {
647
+ identity: string;
648
+ event: "peerLeft";
649
+ }, {
650
+ identity: string;
651
+ event: "peerLeft";
652
+ }>, z.ZodObject<{
653
+ event: z.ZodLiteral<"producerAppeared">;
654
+ producerId: z.ZodString;
655
+ identity: z.ZodString;
656
+ kind: z.ZodEnum<["audio", "video"]>;
657
+ }, "strip", z.ZodTypeAny, {
658
+ identity: string;
659
+ kind: "audio" | "video";
660
+ producerId: string;
661
+ event: "producerAppeared";
662
+ }, {
663
+ identity: string;
664
+ kind: "audio" | "video";
665
+ producerId: string;
666
+ event: "producerAppeared";
667
+ }>, z.ZodObject<{
668
+ event: z.ZodLiteral<"producerClosed">;
669
+ producerId: z.ZodString;
670
+ }, "strip", z.ZodTypeAny, {
671
+ producerId: string;
672
+ event: "producerClosed";
673
+ }, {
674
+ producerId: string;
675
+ event: "producerClosed";
676
+ }>, z.ZodObject<{
677
+ event: z.ZodLiteral<"producerPaused">;
678
+ producerId: z.ZodString;
679
+ paused: z.ZodBoolean;
680
+ }, "strip", z.ZodTypeAny, {
681
+ producerId: string;
682
+ event: "producerPaused";
683
+ paused: boolean;
684
+ }, {
685
+ producerId: string;
686
+ event: "producerPaused";
687
+ paused: boolean;
688
+ }>, z.ZodObject<{
689
+ event: z.ZodLiteral<"activeSpeakers">;
690
+ producerIds: z.ZodArray<z.ZodString, "many">;
691
+ }, "strip", z.ZodTypeAny, {
692
+ event: "activeSpeakers";
693
+ producerIds: string[];
694
+ }, {
695
+ event: "activeSpeakers";
696
+ producerIds: string[];
697
+ }>, z.ZodObject<{
698
+ event: z.ZodLiteral<"recordingChanged">;
699
+ recording: z.ZodBoolean;
700
+ }, "strip", z.ZodTypeAny, {
701
+ event: "recordingChanged";
702
+ recording: boolean;
703
+ }, {
704
+ event: "recordingChanged";
705
+ recording: boolean;
706
+ }>, z.ZodObject<{
707
+ event: z.ZodLiteral<"draining">;
708
+ reconnectAfterMs: z.ZodNumber;
709
+ }, "strip", z.ZodTypeAny, {
710
+ event: "draining";
711
+ reconnectAfterMs: number;
712
+ }, {
713
+ event: "draining";
714
+ reconnectAfterMs: number;
715
+ }>, z.ZodObject<{
716
+ event: z.ZodLiteral<"roomClosed">;
717
+ reason: z.ZodString;
718
+ }, "strip", z.ZodTypeAny, {
719
+ event: "roomClosed";
720
+ reason: string;
721
+ }, {
722
+ event: "roomClosed";
723
+ reason: string;
724
+ }>, z.ZodObject<{
725
+ event: z.ZodLiteral<"subscribeRuleChanged">;
726
+ subscribe: z.ZodDiscriminatedUnion<"mode", [z.ZodObject<{
727
+ mode: z.ZodLiteral<"all">;
728
+ }, "strict", z.ZodTypeAny, {
729
+ mode: "all";
730
+ }, {
731
+ mode: "all";
732
+ }>, z.ZodObject<{
733
+ mode: z.ZodLiteral<"none">;
734
+ }, "strict", z.ZodTypeAny, {
735
+ mode: "none";
736
+ }, {
737
+ mode: "none";
738
+ }>, z.ZodObject<{
739
+ mode: z.ZodLiteral<"allow">;
740
+ identities: z.ZodArray<z.ZodString, "many">;
741
+ }, "strict", z.ZodTypeAny, {
742
+ mode: "allow";
743
+ identities: string[];
744
+ }, {
745
+ mode: "allow";
746
+ identities: string[];
747
+ }>, z.ZodObject<{
748
+ mode: z.ZodLiteral<"deny">;
749
+ identities: z.ZodArray<z.ZodString, "many">;
750
+ }, "strict", z.ZodTypeAny, {
751
+ mode: "deny";
752
+ identities: string[];
753
+ }, {
754
+ mode: "deny";
755
+ identities: string[];
756
+ }>]>;
757
+ }, "strip", z.ZodTypeAny, {
758
+ subscribe: {
759
+ mode: "all";
760
+ } | {
761
+ mode: "none";
762
+ } | {
763
+ mode: "allow";
764
+ identities: string[];
765
+ } | {
766
+ mode: "deny";
767
+ identities: string[];
768
+ };
769
+ event: "subscribeRuleChanged";
770
+ }, {
771
+ subscribe: {
772
+ mode: "all";
773
+ } | {
774
+ mode: "none";
775
+ } | {
776
+ mode: "allow";
777
+ identities: string[];
778
+ } | {
779
+ mode: "deny";
780
+ identities: string[];
781
+ };
782
+ event: "subscribeRuleChanged";
783
+ }>]>]>;
784
+ export type ServerFrame = z.infer<typeof serverFrameSchema>;
785
+ export declare const isEvent: (frame: ServerFrame) => frame is EventFrame;
786
+ //# sourceMappingURL=frames.d.ts.map