@moqtap/codec 0.5.0 → 0.7.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 (170) hide show
  1. package/README.md +4 -2
  2. package/dist/{chunk-CXFAQKL3.js → chunk-23KRITJ6.js} +1 -1
  3. package/dist/{chunk-JL3NEW3O.cjs → chunk-4XLYCT5Q.cjs} +90 -1
  4. package/dist/{chunk-DLSGOZ6P.js → chunk-5XZKO2U5.js} +34 -34
  5. package/dist/chunk-APTV6F72.js +2095 -0
  6. package/dist/{chunk-JB5VDJ2V.cjs → chunk-B56AG5HU.cjs} +37 -37
  7. package/dist/chunk-CQ65LKPQ.cjs +446 -0
  8. package/dist/{chunk-4HBKHNU2.cjs → chunk-CZNW3R5E.cjs} +37 -37
  9. package/dist/{chunk-Q5D6OW6Q.js → chunk-DORX55MO.js} +1 -1
  10. package/dist/{chunk-OGZTQA24.cjs → chunk-EQAYMCXO.cjs} +64 -64
  11. package/dist/{chunk-HYI6LFMD.js → chunk-HEO2JG6C.js} +1 -1
  12. package/dist/{chunk-UP4XPH4J.js → chunk-I55J3KXD.js} +31 -31
  13. package/dist/{chunk-HZHSO7EW.cjs → chunk-IDV2JYJ6.cjs} +39 -39
  14. package/dist/{chunk-BAG6YWCP.cjs → chunk-IEJULBKB.cjs} +63 -63
  15. package/dist/{chunk-Y6KCSM3V.js → chunk-IJAF6PAY.js} +1 -1
  16. package/dist/{chunk-WMJVSBBE.cjs → chunk-J3ASFPCX.cjs} +57 -57
  17. package/dist/{chunk-COWGGUL4.js → chunk-JKMYAUGY.js} +1 -1
  18. package/dist/{chunk-SIYYMFCC.cjs → chunk-KCH4BQXK.cjs} +37 -37
  19. package/dist/{chunk-VOU7PNHI.js → chunk-KLPWJU6W.js} +89 -0
  20. package/dist/{chunk-NZ7GYEMT.js → chunk-KNLPX3YA.js} +1 -1
  21. package/dist/{chunk-A33U4WVS.cjs → chunk-KTVN4P6J.cjs} +67 -67
  22. package/dist/{chunk-7KBAWOBA.js → chunk-KYVTM5VI.js} +1 -1
  23. package/dist/{chunk-RZ3UML47.js → chunk-MD2OA7SE.js} +1 -1
  24. package/dist/chunk-MH7537FB.cjs +2095 -0
  25. package/dist/{chunk-SHMA4PBY.js → chunk-N2V7Z37J.js} +1 -1
  26. package/dist/chunk-O5DQ44TM.js +446 -0
  27. package/dist/{chunk-HO44OANK.cjs → chunk-QGIHC6BA.cjs} +36 -36
  28. package/dist/{chunk-PKEOQSSZ.cjs → chunk-RIIA4ALQ.cjs} +37 -37
  29. package/dist/{chunk-XZE5R57R.cjs → chunk-VZHL2U2N.cjs} +37 -37
  30. package/dist/{chunk-RW4UG7CN.js → chunk-XHAP2YST.js} +1 -1
  31. package/dist/{chunk-JTRU76JN.cjs → chunk-Y4FRXYX6.cjs} +59 -59
  32. package/dist/{codec-yJ_axwtp.d.cts → codec-B1snaM9L.d.cts} +1 -1
  33. package/dist/{codec-Tdey03Bo.d.ts → codec-BLYAy2OP.d.ts} +1 -1
  34. package/dist/{codec-DqHwYWM-.d.ts → codec-BNS3gS77.d.ts} +1 -1
  35. package/dist/{codec-CBLLytyP.d.cts → codec-BOtv3R5j.d.cts} +1 -1
  36. package/dist/{codec-C17JvsEU.d.cts → codec-BOyrk_C9.d.cts} +1 -1
  37. package/dist/{codec-BsSNjvB3.d.cts → codec-BqqoYdh_.d.cts} +1 -1
  38. package/dist/{codec-BhW5CGZq.d.ts → codec-CI0BjmHc.d.ts} +1 -1
  39. package/dist/{codec-BvzKRqiP.d.ts → codec-CWj5iTxA.d.ts} +1 -1
  40. package/dist/{codec-DbpLHKXN.d.cts → codec-CyApDKwf.d.cts} +1 -1
  41. package/dist/{codec-6s9d5yZm.d.ts → codec-D2JbI2tp.d.ts} +1 -1
  42. package/dist/{codec-BzRIVIzS.d.ts → codec-D47r_-Rl.d.ts} +1 -1
  43. package/dist/{codec-GayA_uN0.d.ts → codec-D49OofBr.d.ts} +1 -1
  44. package/dist/{codec-MxIhLDR5.d.cts → codec-D89DWXbv.d.cts} +1 -1
  45. package/dist/{codec-CzBmYisK.d.cts → codec-D95gT98n.d.cts} +1 -1
  46. package/dist/codec-DAePx2NL.d.ts +30 -0
  47. package/dist/{codec-D_9X0i31.d.ts → codec-DJmV04i0.d.ts} +1 -1
  48. package/dist/{codec-Cbv3sG2y.d.ts → codec-DL0njGkL.d.ts} +1 -1
  49. package/dist/{codec-D2YMCU11.d.cts → codec-DQWQSam3.d.cts} +1 -1
  50. package/dist/{codec-Bp4HPezr.d.ts → codec-DplRgIKq.d.ts} +1 -1
  51. package/dist/{codec-3ZgEK-Yj.d.ts → codec-DujHf55Z.d.ts} +1 -1
  52. package/dist/{codec-DS-As0Pp.d.cts → codec-DvcJgYKq.d.cts} +1 -1
  53. package/dist/{codec-D5Ss123f.d.cts → codec-NMsTK0GX.d.cts} +1 -1
  54. package/dist/{codec-BvSmr-Jp.d.ts → codec-WwwUipaU.d.ts} +1 -1
  55. package/dist/{codec-B6ouUJrm.d.cts → codec-cou9XBMF.d.cts} +1 -1
  56. package/dist/{codec-R28KwiGM.d.cts → codec-hvkJfCF5.d.cts} +1 -1
  57. package/dist/codec-xeuGZY77.d.cts +30 -0
  58. package/dist/draft07-session.d.cts +3 -3
  59. package/dist/draft07-session.d.ts +3 -3
  60. package/dist/draft07.cjs +4 -4
  61. package/dist/draft07.d.cts +3 -3
  62. package/dist/draft07.d.ts +3 -3
  63. package/dist/draft07.js +2 -2
  64. package/dist/draft08-session.d.cts +3 -3
  65. package/dist/draft08-session.d.ts +3 -3
  66. package/dist/draft08.cjs +3 -3
  67. package/dist/draft08.d.cts +4 -4
  68. package/dist/draft08.d.ts +4 -4
  69. package/dist/draft08.js +2 -2
  70. package/dist/draft09-session.d.cts +3 -3
  71. package/dist/draft09-session.d.ts +3 -3
  72. package/dist/draft09.cjs +3 -3
  73. package/dist/draft09.d.cts +4 -4
  74. package/dist/draft09.d.ts +4 -4
  75. package/dist/draft09.js +2 -2
  76. package/dist/draft10-session.d.cts +3 -3
  77. package/dist/draft10-session.d.ts +3 -3
  78. package/dist/draft10.cjs +3 -3
  79. package/dist/draft10.d.cts +4 -4
  80. package/dist/draft10.d.ts +4 -4
  81. package/dist/draft10.js +2 -2
  82. package/dist/draft11-session.d.cts +3 -3
  83. package/dist/draft11-session.d.ts +3 -3
  84. package/dist/draft11.cjs +3 -3
  85. package/dist/draft11.d.cts +4 -4
  86. package/dist/draft11.d.ts +4 -4
  87. package/dist/draft11.js +2 -2
  88. package/dist/draft12-session.d.cts +3 -3
  89. package/dist/draft12-session.d.ts +3 -3
  90. package/dist/draft12.cjs +3 -3
  91. package/dist/draft12.d.cts +4 -4
  92. package/dist/draft12.d.ts +4 -4
  93. package/dist/draft12.js +2 -2
  94. package/dist/draft13-session.d.cts +3 -3
  95. package/dist/draft13-session.d.ts +3 -3
  96. package/dist/draft13.cjs +3 -3
  97. package/dist/draft13.d.cts +4 -4
  98. package/dist/draft13.d.ts +4 -4
  99. package/dist/draft13.js +2 -2
  100. package/dist/draft14-session.d.cts +3 -3
  101. package/dist/draft14-session.d.ts +3 -3
  102. package/dist/draft14.cjs +3 -3
  103. package/dist/draft14.d.cts +4 -4
  104. package/dist/draft14.d.ts +4 -4
  105. package/dist/draft14.js +2 -2
  106. package/dist/draft15-session.d.cts +3 -3
  107. package/dist/draft15-session.d.ts +3 -3
  108. package/dist/draft15.cjs +3 -3
  109. package/dist/draft15.d.cts +4 -4
  110. package/dist/draft15.d.ts +4 -4
  111. package/dist/draft15.js +2 -2
  112. package/dist/draft16-session.d.cts +3 -3
  113. package/dist/draft16-session.d.ts +3 -3
  114. package/dist/draft16.cjs +3 -3
  115. package/dist/draft16.d.cts +4 -4
  116. package/dist/draft16.d.ts +4 -4
  117. package/dist/draft16.js +2 -2
  118. package/dist/draft17-session.d.cts +3 -3
  119. package/dist/draft17-session.d.ts +3 -3
  120. package/dist/draft17.cjs +3 -3
  121. package/dist/draft17.d.cts +3 -3
  122. package/dist/draft17.d.ts +3 -3
  123. package/dist/draft17.js +2 -2
  124. package/dist/draft18-session.d.cts +3 -3
  125. package/dist/draft18-session.d.ts +3 -3
  126. package/dist/draft18.cjs +3 -3
  127. package/dist/draft18.d.cts +3 -3
  128. package/dist/draft18.d.ts +3 -3
  129. package/dist/draft18.js +2 -2
  130. package/dist/draft19-session.cjs +8 -0
  131. package/dist/draft19-session.d.cts +50 -0
  132. package/dist/draft19-session.d.ts +50 -0
  133. package/dist/draft19-session.js +8 -0
  134. package/dist/draft19.cjs +189 -0
  135. package/dist/draft19.d.cts +130 -0
  136. package/dist/draft19.d.ts +130 -0
  137. package/dist/draft19.js +189 -0
  138. package/dist/index.cjs +33 -27
  139. package/dist/index.d.cts +20 -15
  140. package/dist/index.d.ts +20 -15
  141. package/dist/index.js +20 -14
  142. package/dist/{session-types-DBpCRtrL.d.ts → session-types-C0l_-Ups.d.ts} +1 -1
  143. package/dist/{session-types-sBaTRwDh.d.cts → session-types-KsqyVp6y.d.cts} +1 -1
  144. package/dist/session.cjs +5 -1
  145. package/dist/session.d.cts +5 -3
  146. package/dist/session.d.ts +5 -3
  147. package/dist/session.js +5 -1
  148. package/dist/{types-CnBuq68e.d.cts → types-CdCSIfvI.d.cts} +1 -1
  149. package/dist/{types-CnBuq68e.d.ts → types-CdCSIfvI.d.ts} +1 -1
  150. package/dist/types-zHgCS6o5.d.cts +265 -0
  151. package/dist/types-zHgCS6o5.d.ts +265 -0
  152. package/package.json +14 -2
  153. package/src/core/buffer-reader.ts +74 -2
  154. package/src/core/buffer-writer.ts +56 -4
  155. package/src/core/types.ts +1 -0
  156. package/src/drafts/draft17/codec.ts +2 -2
  157. package/src/drafts/draft17/data-streams.ts +2 -2
  158. package/src/drafts/draft18/codec.ts +2 -2
  159. package/src/drafts/draft18/data-streams.ts +2 -2
  160. package/src/drafts/draft19/codec.ts +1425 -0
  161. package/src/drafts/draft19/data-streams.ts +996 -0
  162. package/src/drafts/draft19/error-codes.ts +78 -0
  163. package/src/drafts/draft19/index.ts +126 -0
  164. package/src/drafts/draft19/messages.ts +58 -0
  165. package/src/drafts/draft19/rules.ts +85 -0
  166. package/src/drafts/draft19/session-fsm.ts +451 -0
  167. package/src/drafts/draft19/session.ts +15 -0
  168. package/src/drafts/draft19/types.ts +368 -0
  169. package/src/index.ts +9 -1
  170. package/src/session.ts +4 -0
@@ -0,0 +1,265 @@
1
+ interface UnknownParam {
2
+ readonly id: string;
3
+ readonly length: number;
4
+ readonly raw_hex: string;
5
+ }
6
+ interface AuthorizationToken {
7
+ readonly alias_type: bigint;
8
+ readonly token_alias?: bigint;
9
+ readonly token_type?: bigint;
10
+ readonly token_value?: Uint8Array;
11
+ }
12
+ interface Draft19SetupOptions {
13
+ path?: string;
14
+ authorization_token?: AuthorizationToken;
15
+ max_auth_token_cache_size?: bigint;
16
+ authority?: string;
17
+ max_filter_ranges?: bigint;
18
+ moqt_implementation?: string;
19
+ max_request_updates?: bigint;
20
+ unknown?: UnknownParam[];
21
+ }
22
+ interface LocationFilter {
23
+ readonly filter_type: bigint;
24
+ readonly start_group?: bigint;
25
+ readonly start_object?: bigint;
26
+ readonly end_group?: bigint;
27
+ }
28
+ interface RangeFilterRange {
29
+ readonly start: bigint;
30
+ readonly end?: bigint;
31
+ }
32
+ interface RangeFilter {
33
+ readonly set_id?: bigint;
34
+ readonly property_type?: bigint;
35
+ readonly ranges?: RangeFilterRange[];
36
+ readonly removed?: boolean;
37
+ }
38
+ interface LargestObject {
39
+ readonly group: bigint;
40
+ readonly object: bigint;
41
+ }
42
+ interface Draft19Params {
43
+ object_delivery_timeout?: bigint;
44
+ authorization_token?: AuthorizationToken;
45
+ rendezvous_timeout?: bigint;
46
+ subgroup_delivery_timeout?: bigint;
47
+ expires?: bigint;
48
+ largest_object?: LargestObject;
49
+ fill_timeout?: bigint;
50
+ forward?: bigint;
51
+ subscriber_priority?: bigint;
52
+ location_filter?: LocationFilter;
53
+ group_order?: bigint;
54
+ subgroup_filter?: RangeFilter;
55
+ objectid_filter?: RangeFilter;
56
+ priority_filter?: RangeFilter;
57
+ object_property_filter?: RangeFilter;
58
+ track_property_filter?: RangeFilter;
59
+ new_group_request?: bigint;
60
+ track_namespace_prefix?: string[];
61
+ unknown?: UnknownParam[];
62
+ }
63
+ interface Draft19TrackProperties {
64
+ object_delivery_timeout?: bigint;
65
+ max_cache_duration?: bigint;
66
+ subgroup_delivery_timeout?: bigint;
67
+ immutable_properties?: Uint8Array;
68
+ default_publisher_priority?: bigint;
69
+ default_publisher_group_order?: bigint;
70
+ dynamic_groups?: bigint;
71
+ unknown?: UnknownParam[];
72
+ }
73
+ type Draft19MessageType = 'setup' | 'subscribe' | 'subscribe_ok' | 'request_update' | 'publish' | 'publish_done' | 'publish_namespace' | 'namespace' | 'namespace_done' | 'subscribe_namespace' | 'subscribe_tracks' | 'publish_skipped' | 'fetch' | 'fetch_ok' | 'track_status' | 'request_ok' | 'request_error' | 'goaway';
74
+ interface Draft19BaseMessage {
75
+ readonly type: Draft19MessageType;
76
+ }
77
+ interface Draft19Setup extends Draft19BaseMessage {
78
+ readonly type: 'setup';
79
+ readonly options: Draft19SetupOptions;
80
+ }
81
+ interface Draft19Subscribe extends Draft19BaseMessage {
82
+ readonly type: 'subscribe';
83
+ readonly request_id: bigint;
84
+ readonly track_namespace: string[];
85
+ readonly track_name: string;
86
+ readonly parameters: Draft19Params;
87
+ }
88
+ interface Draft19SubscribeOk extends Draft19BaseMessage {
89
+ readonly type: 'subscribe_ok';
90
+ readonly track_alias: bigint;
91
+ readonly parameters: Draft19Params;
92
+ readonly track_properties: Draft19TrackProperties;
93
+ }
94
+ interface Draft19RequestUpdate extends Draft19BaseMessage {
95
+ readonly type: 'request_update';
96
+ readonly request_id: bigint;
97
+ readonly parameters: Draft19Params;
98
+ }
99
+ interface Draft19Publish extends Draft19BaseMessage {
100
+ readonly type: 'publish';
101
+ readonly request_id: bigint;
102
+ readonly track_namespace: string[];
103
+ readonly track_name: string;
104
+ readonly track_alias: bigint;
105
+ readonly parameters: Draft19Params;
106
+ readonly track_properties: Draft19TrackProperties;
107
+ }
108
+ interface Draft19PublishDone extends Draft19BaseMessage {
109
+ readonly type: 'publish_done';
110
+ readonly status_code: bigint;
111
+ readonly stream_count: bigint;
112
+ readonly reason_phrase: string;
113
+ }
114
+ interface Draft19PublishNamespace extends Draft19BaseMessage {
115
+ readonly type: 'publish_namespace';
116
+ readonly request_id: bigint;
117
+ readonly track_namespace: string[];
118
+ readonly parameters: Draft19Params;
119
+ }
120
+ interface Draft19Namespace extends Draft19BaseMessage {
121
+ readonly type: 'namespace';
122
+ readonly namespace_suffix: string[];
123
+ }
124
+ interface Draft19NamespaceDone extends Draft19BaseMessage {
125
+ readonly type: 'namespace_done';
126
+ readonly namespace_suffix: string[];
127
+ }
128
+ interface Draft19SubscribeNamespace extends Draft19BaseMessage {
129
+ readonly type: 'subscribe_namespace';
130
+ readonly request_id: bigint;
131
+ readonly namespace_prefix: string[];
132
+ readonly parameters: Draft19Params;
133
+ }
134
+ interface Draft19SubscribeTracks extends Draft19BaseMessage {
135
+ readonly type: 'subscribe_tracks';
136
+ readonly request_id: bigint;
137
+ readonly namespace_prefix: string[];
138
+ readonly parameters: Draft19Params;
139
+ }
140
+ interface Draft19PublishSkipped extends Draft19BaseMessage {
141
+ readonly type: 'publish_skipped';
142
+ readonly namespace_suffix: string[];
143
+ readonly track_name: string;
144
+ }
145
+ interface StandaloneFetch {
146
+ readonly track_namespace: string[];
147
+ readonly track_name: string;
148
+ readonly start_group: bigint;
149
+ readonly start_object: bigint;
150
+ readonly end_group: bigint;
151
+ readonly end_object: bigint;
152
+ }
153
+ interface JoiningFetch {
154
+ readonly joining_request_id: bigint;
155
+ readonly joining_start: bigint;
156
+ }
157
+ interface Draft19Fetch extends Draft19BaseMessage {
158
+ readonly type: 'fetch';
159
+ readonly request_id: bigint;
160
+ readonly fetch_type: bigint;
161
+ readonly standalone?: StandaloneFetch;
162
+ readonly joining?: JoiningFetch;
163
+ readonly parameters: Draft19Params;
164
+ }
165
+ interface Draft19FetchOk extends Draft19BaseMessage {
166
+ readonly type: 'fetch_ok';
167
+ readonly end_of_track: number;
168
+ readonly end_group: bigint;
169
+ readonly end_object: bigint;
170
+ readonly parameters: Draft19Params;
171
+ readonly track_properties: Draft19TrackProperties;
172
+ }
173
+ interface Draft19TrackStatus extends Draft19BaseMessage {
174
+ readonly type: 'track_status';
175
+ readonly request_id: bigint;
176
+ readonly track_namespace: string[];
177
+ readonly track_name: string;
178
+ readonly parameters: Draft19Params;
179
+ }
180
+ interface Draft19RequestOk extends Draft19BaseMessage {
181
+ readonly type: 'request_ok';
182
+ readonly parameters: Draft19Params;
183
+ readonly track_properties: Draft19TrackProperties;
184
+ }
185
+ interface Redirect {
186
+ readonly connect_uri: string;
187
+ readonly track_namespace: string[];
188
+ readonly track_name: string;
189
+ }
190
+ interface Draft19RequestError extends Draft19BaseMessage {
191
+ readonly type: 'request_error';
192
+ readonly error_code: bigint;
193
+ readonly retry_interval: bigint;
194
+ readonly reason_phrase: string;
195
+ readonly redirect?: Redirect;
196
+ }
197
+ interface Draft19GoAway extends Draft19BaseMessage {
198
+ readonly type: 'goaway';
199
+ readonly new_session_uri: string;
200
+ readonly timeout: bigint;
201
+ }
202
+ type Draft19Message = Draft19Setup | Draft19Subscribe | Draft19SubscribeOk | Draft19RequestUpdate | Draft19Publish | Draft19PublishDone | Draft19PublishNamespace | Draft19Namespace | Draft19NamespaceDone | Draft19SubscribeNamespace | Draft19SubscribeTracks | Draft19PublishSkipped | Draft19Fetch | Draft19FetchOk | Draft19TrackStatus | Draft19RequestOk | Draft19RequestError | Draft19GoAway;
203
+ interface ObjectPayload {
204
+ readonly type: 'object';
205
+ readonly byteOffset: number;
206
+ readonly payloadByteOffset: number;
207
+ readonly objectId: bigint;
208
+ readonly payloadLength: number;
209
+ readonly status?: bigint;
210
+ readonly extensionData: Uint8Array;
211
+ readonly objectProperties?: Record<string, bigint>;
212
+ readonly payload: Uint8Array;
213
+ }
214
+ interface SubgroupStream {
215
+ readonly type: 'subgroup';
216
+ readonly headerType: number;
217
+ readonly trackAlias: bigint;
218
+ readonly groupId: bigint;
219
+ readonly subgroupId: bigint;
220
+ readonly publisherPriority: number;
221
+ readonly endOfGroup?: boolean;
222
+ readonly firstObject?: boolean;
223
+ readonly objects: ObjectPayload[];
224
+ }
225
+ interface DatagramObject {
226
+ readonly type: 'datagram';
227
+ readonly datagramType: number;
228
+ readonly trackAlias: bigint;
229
+ readonly groupId: bigint;
230
+ readonly objectId: bigint;
231
+ readonly publisherPriority: number;
232
+ readonly endOfGroup?: boolean;
233
+ readonly objectStatus?: bigint;
234
+ readonly objectProperties?: Record<string, bigint>;
235
+ readonly payloadLength: number;
236
+ readonly payload: Uint8Array;
237
+ }
238
+ interface FetchObjectPayload extends ObjectPayload {
239
+ readonly serializationFlags: number;
240
+ readonly groupId: bigint;
241
+ readonly subgroupId: bigint;
242
+ readonly publisherPriority: number;
243
+ readonly objectProperties?: Record<string, bigint>;
244
+ }
245
+ interface FetchStream {
246
+ readonly type: 'fetch';
247
+ readonly requestId: bigint;
248
+ readonly objects: FetchObjectPayload[];
249
+ }
250
+ type Draft19DataStream = SubgroupStream | DatagramObject | FetchStream;
251
+ interface SubgroupStreamHeader {
252
+ readonly type: 'subgroup_header';
253
+ readonly trackAlias: bigint;
254
+ readonly groupId: bigint;
255
+ readonly subgroupId: bigint;
256
+ readonly publisherPriority: number;
257
+ }
258
+ interface FetchStreamHeader {
259
+ readonly type: 'fetch_header';
260
+ readonly requestId: bigint;
261
+ }
262
+ type DataStreamHeader = SubgroupStreamHeader | FetchStreamHeader;
263
+ type DataStreamEvent = DataStreamHeader | ObjectPayload;
264
+
265
+ export type { Draft19SubscribeTracks as A, Draft19TrackProperties as B, Draft19TrackStatus as C, Draft19Message as D, FetchObjectPayload as E, FetchStreamHeader as F, LocationFilter as G, RangeFilterRange as H, Redirect as I, JoiningFetch as J, StandaloneFetch as K, LargestObject as L, ObjectPayload as O, RangeFilter as R, SubgroupStreamHeader as S, UnknownParam as U, Draft19MessageType as a, DataStreamEvent as b, Draft19DataStream as c, DatagramObject as d, FetchStream as e, SubgroupStream as f, DataStreamHeader as g, Draft19BaseMessage as h, Draft19Fetch as i, Draft19FetchOk as j, Draft19GoAway as k, Draft19Namespace as l, Draft19NamespaceDone as m, Draft19Params as n, Draft19Publish as o, Draft19PublishDone as p, Draft19PublishNamespace as q, Draft19PublishSkipped as r, Draft19RequestError as s, Draft19RequestOk as t, Draft19RequestUpdate as u, Draft19Setup as v, Draft19SetupOptions as w, Draft19Subscribe as x, Draft19SubscribeNamespace as y, Draft19SubscribeOk as z };
@@ -0,0 +1,265 @@
1
+ interface UnknownParam {
2
+ readonly id: string;
3
+ readonly length: number;
4
+ readonly raw_hex: string;
5
+ }
6
+ interface AuthorizationToken {
7
+ readonly alias_type: bigint;
8
+ readonly token_alias?: bigint;
9
+ readonly token_type?: bigint;
10
+ readonly token_value?: Uint8Array;
11
+ }
12
+ interface Draft19SetupOptions {
13
+ path?: string;
14
+ authorization_token?: AuthorizationToken;
15
+ max_auth_token_cache_size?: bigint;
16
+ authority?: string;
17
+ max_filter_ranges?: bigint;
18
+ moqt_implementation?: string;
19
+ max_request_updates?: bigint;
20
+ unknown?: UnknownParam[];
21
+ }
22
+ interface LocationFilter {
23
+ readonly filter_type: bigint;
24
+ readonly start_group?: bigint;
25
+ readonly start_object?: bigint;
26
+ readonly end_group?: bigint;
27
+ }
28
+ interface RangeFilterRange {
29
+ readonly start: bigint;
30
+ readonly end?: bigint;
31
+ }
32
+ interface RangeFilter {
33
+ readonly set_id?: bigint;
34
+ readonly property_type?: bigint;
35
+ readonly ranges?: RangeFilterRange[];
36
+ readonly removed?: boolean;
37
+ }
38
+ interface LargestObject {
39
+ readonly group: bigint;
40
+ readonly object: bigint;
41
+ }
42
+ interface Draft19Params {
43
+ object_delivery_timeout?: bigint;
44
+ authorization_token?: AuthorizationToken;
45
+ rendezvous_timeout?: bigint;
46
+ subgroup_delivery_timeout?: bigint;
47
+ expires?: bigint;
48
+ largest_object?: LargestObject;
49
+ fill_timeout?: bigint;
50
+ forward?: bigint;
51
+ subscriber_priority?: bigint;
52
+ location_filter?: LocationFilter;
53
+ group_order?: bigint;
54
+ subgroup_filter?: RangeFilter;
55
+ objectid_filter?: RangeFilter;
56
+ priority_filter?: RangeFilter;
57
+ object_property_filter?: RangeFilter;
58
+ track_property_filter?: RangeFilter;
59
+ new_group_request?: bigint;
60
+ track_namespace_prefix?: string[];
61
+ unknown?: UnknownParam[];
62
+ }
63
+ interface Draft19TrackProperties {
64
+ object_delivery_timeout?: bigint;
65
+ max_cache_duration?: bigint;
66
+ subgroup_delivery_timeout?: bigint;
67
+ immutable_properties?: Uint8Array;
68
+ default_publisher_priority?: bigint;
69
+ default_publisher_group_order?: bigint;
70
+ dynamic_groups?: bigint;
71
+ unknown?: UnknownParam[];
72
+ }
73
+ type Draft19MessageType = 'setup' | 'subscribe' | 'subscribe_ok' | 'request_update' | 'publish' | 'publish_done' | 'publish_namespace' | 'namespace' | 'namespace_done' | 'subscribe_namespace' | 'subscribe_tracks' | 'publish_skipped' | 'fetch' | 'fetch_ok' | 'track_status' | 'request_ok' | 'request_error' | 'goaway';
74
+ interface Draft19BaseMessage {
75
+ readonly type: Draft19MessageType;
76
+ }
77
+ interface Draft19Setup extends Draft19BaseMessage {
78
+ readonly type: 'setup';
79
+ readonly options: Draft19SetupOptions;
80
+ }
81
+ interface Draft19Subscribe extends Draft19BaseMessage {
82
+ readonly type: 'subscribe';
83
+ readonly request_id: bigint;
84
+ readonly track_namespace: string[];
85
+ readonly track_name: string;
86
+ readonly parameters: Draft19Params;
87
+ }
88
+ interface Draft19SubscribeOk extends Draft19BaseMessage {
89
+ readonly type: 'subscribe_ok';
90
+ readonly track_alias: bigint;
91
+ readonly parameters: Draft19Params;
92
+ readonly track_properties: Draft19TrackProperties;
93
+ }
94
+ interface Draft19RequestUpdate extends Draft19BaseMessage {
95
+ readonly type: 'request_update';
96
+ readonly request_id: bigint;
97
+ readonly parameters: Draft19Params;
98
+ }
99
+ interface Draft19Publish extends Draft19BaseMessage {
100
+ readonly type: 'publish';
101
+ readonly request_id: bigint;
102
+ readonly track_namespace: string[];
103
+ readonly track_name: string;
104
+ readonly track_alias: bigint;
105
+ readonly parameters: Draft19Params;
106
+ readonly track_properties: Draft19TrackProperties;
107
+ }
108
+ interface Draft19PublishDone extends Draft19BaseMessage {
109
+ readonly type: 'publish_done';
110
+ readonly status_code: bigint;
111
+ readonly stream_count: bigint;
112
+ readonly reason_phrase: string;
113
+ }
114
+ interface Draft19PublishNamespace extends Draft19BaseMessage {
115
+ readonly type: 'publish_namespace';
116
+ readonly request_id: bigint;
117
+ readonly track_namespace: string[];
118
+ readonly parameters: Draft19Params;
119
+ }
120
+ interface Draft19Namespace extends Draft19BaseMessage {
121
+ readonly type: 'namespace';
122
+ readonly namespace_suffix: string[];
123
+ }
124
+ interface Draft19NamespaceDone extends Draft19BaseMessage {
125
+ readonly type: 'namespace_done';
126
+ readonly namespace_suffix: string[];
127
+ }
128
+ interface Draft19SubscribeNamespace extends Draft19BaseMessage {
129
+ readonly type: 'subscribe_namespace';
130
+ readonly request_id: bigint;
131
+ readonly namespace_prefix: string[];
132
+ readonly parameters: Draft19Params;
133
+ }
134
+ interface Draft19SubscribeTracks extends Draft19BaseMessage {
135
+ readonly type: 'subscribe_tracks';
136
+ readonly request_id: bigint;
137
+ readonly namespace_prefix: string[];
138
+ readonly parameters: Draft19Params;
139
+ }
140
+ interface Draft19PublishSkipped extends Draft19BaseMessage {
141
+ readonly type: 'publish_skipped';
142
+ readonly namespace_suffix: string[];
143
+ readonly track_name: string;
144
+ }
145
+ interface StandaloneFetch {
146
+ readonly track_namespace: string[];
147
+ readonly track_name: string;
148
+ readonly start_group: bigint;
149
+ readonly start_object: bigint;
150
+ readonly end_group: bigint;
151
+ readonly end_object: bigint;
152
+ }
153
+ interface JoiningFetch {
154
+ readonly joining_request_id: bigint;
155
+ readonly joining_start: bigint;
156
+ }
157
+ interface Draft19Fetch extends Draft19BaseMessage {
158
+ readonly type: 'fetch';
159
+ readonly request_id: bigint;
160
+ readonly fetch_type: bigint;
161
+ readonly standalone?: StandaloneFetch;
162
+ readonly joining?: JoiningFetch;
163
+ readonly parameters: Draft19Params;
164
+ }
165
+ interface Draft19FetchOk extends Draft19BaseMessage {
166
+ readonly type: 'fetch_ok';
167
+ readonly end_of_track: number;
168
+ readonly end_group: bigint;
169
+ readonly end_object: bigint;
170
+ readonly parameters: Draft19Params;
171
+ readonly track_properties: Draft19TrackProperties;
172
+ }
173
+ interface Draft19TrackStatus extends Draft19BaseMessage {
174
+ readonly type: 'track_status';
175
+ readonly request_id: bigint;
176
+ readonly track_namespace: string[];
177
+ readonly track_name: string;
178
+ readonly parameters: Draft19Params;
179
+ }
180
+ interface Draft19RequestOk extends Draft19BaseMessage {
181
+ readonly type: 'request_ok';
182
+ readonly parameters: Draft19Params;
183
+ readonly track_properties: Draft19TrackProperties;
184
+ }
185
+ interface Redirect {
186
+ readonly connect_uri: string;
187
+ readonly track_namespace: string[];
188
+ readonly track_name: string;
189
+ }
190
+ interface Draft19RequestError extends Draft19BaseMessage {
191
+ readonly type: 'request_error';
192
+ readonly error_code: bigint;
193
+ readonly retry_interval: bigint;
194
+ readonly reason_phrase: string;
195
+ readonly redirect?: Redirect;
196
+ }
197
+ interface Draft19GoAway extends Draft19BaseMessage {
198
+ readonly type: 'goaway';
199
+ readonly new_session_uri: string;
200
+ readonly timeout: bigint;
201
+ }
202
+ type Draft19Message = Draft19Setup | Draft19Subscribe | Draft19SubscribeOk | Draft19RequestUpdate | Draft19Publish | Draft19PublishDone | Draft19PublishNamespace | Draft19Namespace | Draft19NamespaceDone | Draft19SubscribeNamespace | Draft19SubscribeTracks | Draft19PublishSkipped | Draft19Fetch | Draft19FetchOk | Draft19TrackStatus | Draft19RequestOk | Draft19RequestError | Draft19GoAway;
203
+ interface ObjectPayload {
204
+ readonly type: 'object';
205
+ readonly byteOffset: number;
206
+ readonly payloadByteOffset: number;
207
+ readonly objectId: bigint;
208
+ readonly payloadLength: number;
209
+ readonly status?: bigint;
210
+ readonly extensionData: Uint8Array;
211
+ readonly objectProperties?: Record<string, bigint>;
212
+ readonly payload: Uint8Array;
213
+ }
214
+ interface SubgroupStream {
215
+ readonly type: 'subgroup';
216
+ readonly headerType: number;
217
+ readonly trackAlias: bigint;
218
+ readonly groupId: bigint;
219
+ readonly subgroupId: bigint;
220
+ readonly publisherPriority: number;
221
+ readonly endOfGroup?: boolean;
222
+ readonly firstObject?: boolean;
223
+ readonly objects: ObjectPayload[];
224
+ }
225
+ interface DatagramObject {
226
+ readonly type: 'datagram';
227
+ readonly datagramType: number;
228
+ readonly trackAlias: bigint;
229
+ readonly groupId: bigint;
230
+ readonly objectId: bigint;
231
+ readonly publisherPriority: number;
232
+ readonly endOfGroup?: boolean;
233
+ readonly objectStatus?: bigint;
234
+ readonly objectProperties?: Record<string, bigint>;
235
+ readonly payloadLength: number;
236
+ readonly payload: Uint8Array;
237
+ }
238
+ interface FetchObjectPayload extends ObjectPayload {
239
+ readonly serializationFlags: number;
240
+ readonly groupId: bigint;
241
+ readonly subgroupId: bigint;
242
+ readonly publisherPriority: number;
243
+ readonly objectProperties?: Record<string, bigint>;
244
+ }
245
+ interface FetchStream {
246
+ readonly type: 'fetch';
247
+ readonly requestId: bigint;
248
+ readonly objects: FetchObjectPayload[];
249
+ }
250
+ type Draft19DataStream = SubgroupStream | DatagramObject | FetchStream;
251
+ interface SubgroupStreamHeader {
252
+ readonly type: 'subgroup_header';
253
+ readonly trackAlias: bigint;
254
+ readonly groupId: bigint;
255
+ readonly subgroupId: bigint;
256
+ readonly publisherPriority: number;
257
+ }
258
+ interface FetchStreamHeader {
259
+ readonly type: 'fetch_header';
260
+ readonly requestId: bigint;
261
+ }
262
+ type DataStreamHeader = SubgroupStreamHeader | FetchStreamHeader;
263
+ type DataStreamEvent = DataStreamHeader | ObjectPayload;
264
+
265
+ export type { Draft19SubscribeTracks as A, Draft19TrackProperties as B, Draft19TrackStatus as C, Draft19Message as D, FetchObjectPayload as E, FetchStreamHeader as F, LocationFilter as G, RangeFilterRange as H, Redirect as I, JoiningFetch as J, StandaloneFetch as K, LargestObject as L, ObjectPayload as O, RangeFilter as R, SubgroupStreamHeader as S, UnknownParam as U, Draft19MessageType as a, DataStreamEvent as b, Draft19DataStream as c, DatagramObject as d, FetchStream as e, SubgroupStream as f, DataStreamHeader as g, Draft19BaseMessage as h, Draft19Fetch as i, Draft19FetchOk as j, Draft19GoAway as k, Draft19Namespace as l, Draft19NamespaceDone as m, Draft19Params as n, Draft19Publish as o, Draft19PublishDone as p, Draft19PublishNamespace as q, Draft19PublishSkipped as r, Draft19RequestError as s, Draft19RequestOk as t, Draft19RequestUpdate as u, Draft19Setup as v, Draft19SetupOptions as w, Draft19Subscribe as x, Draft19SubscribeNamespace as y, Draft19SubscribeOk as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moqtap/codec",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "MoQT wire-format codec and session state machine — multi-draft, zero dependencies",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -184,6 +184,18 @@
184
184
  "types": "./dist/draft18-session.d.ts",
185
185
  "import": "./dist/draft18-session.js",
186
186
  "require": "./dist/draft18-session.cjs"
187
+ },
188
+ "./draft19": {
189
+ "bun": "./src/drafts/draft19/index.ts",
190
+ "types": "./dist/draft19.d.ts",
191
+ "import": "./dist/draft19.js",
192
+ "require": "./dist/draft19.cjs"
193
+ },
194
+ "./draft19/session": {
195
+ "bun": "./src/drafts/draft19/session.ts",
196
+ "types": "./dist/draft19-session.d.ts",
197
+ "import": "./dist/draft19-session.js",
198
+ "require": "./dist/draft19-session.cjs"
187
199
  }
188
200
  },
189
201
  "files": [
@@ -196,7 +208,7 @@
196
208
  "test": "vitest run"
197
209
  },
198
210
  "devDependencies": {
199
- "@moqtap/test-vectors": "^0.9.1",
211
+ "@moqtap/test-vectors": "^0.11.0",
200
212
  "tsup": "^8.0.0",
201
213
  "typescript": "^5.5.0",
202
214
  "vitest": "^3.0.0"
@@ -3,8 +3,8 @@ import { DecodeError } from './types.js'
3
3
  const textDecoder = /* @__PURE__ */ new TextDecoder()
4
4
 
5
5
  export class BufferReader {
6
- private readonly view: DataView
7
- private pos: number
6
+ protected readonly view: DataView
7
+ protected pos: number
8
8
 
9
9
  constructor(
10
10
  readonly buffer: Uint8Array,
@@ -128,3 +128,75 @@ export class BufferReader {
128
128
  return params
129
129
  }
130
130
  }
131
+
132
+ /**
133
+ * Reader for drafts 17 and later, which dropped the RFC 9000 varint for MoQT's
134
+ * own (§1.4.1).
135
+ *
136
+ * The number of leading 1 bits in the first byte gives the encoded length; the
137
+ * bits after the terminating 0, followed by the remaining bytes, are the value
138
+ * in network byte order. One byte therefore carries 0-127 rather than 0-63,
139
+ * and nine bytes carry the full 64-bit range instead of RFC 9000's 62. A first
140
+ * byte of 0xff is the nine-byte form and is prefix only.
141
+ *
142
+ * Encodings need not be minimal: draft-19 §1.4.1 says any length that can
143
+ * represent the value is valid, so 0 may arrive as 0x00, 0x8000, 0xc00000 or
144
+ * longer.
145
+ */
146
+ export class MoqtBufferReader extends BufferReader {
147
+ /** Draft-17 omits the 7-byte length; draft-18 restored it. */
148
+ protected get allowSevenByte(): boolean {
149
+ return true
150
+ }
151
+
152
+ override readVarInt(): bigint {
153
+ if (this.remaining < 1) {
154
+ throw new DecodeError('UNEXPECTED_END', 'Not enough bytes for varint', this.pos)
155
+ }
156
+ const first = this.view.getUint8(this.pos)
157
+
158
+ if (first === 0xff) {
159
+ if (this.remaining < 9) {
160
+ throw new DecodeError('UNEXPECTED_END', 'Not enough bytes for 9-byte varint', this.pos)
161
+ }
162
+ const value = this.view.getBigUint64(this.pos + 1)
163
+ this.pos += 9
164
+ return value
165
+ }
166
+
167
+ let leadingOnes = 0
168
+ while (leadingOnes < 8 && (first & (0x80 >> leadingOnes)) !== 0) leadingOnes++
169
+ const length = leadingOnes + 1
170
+
171
+ if (length === 7 && !this.allowSevenByte) {
172
+ // draft-17 §1.4.1: "11111100 is an invalid code point. An endpoint that
173
+ // receives this value MUST close the session with a PROTOCOL_VIOLATION."
174
+ throw new DecodeError(
175
+ 'INVALID_VARINT',
176
+ 'The 7-byte varint is not defined in draft-17',
177
+ this.pos,
178
+ )
179
+ }
180
+ if (this.remaining < length) {
181
+ throw new DecodeError(
182
+ 'UNEXPECTED_END',
183
+ `Not enough bytes for ${length}-byte varint`,
184
+ this.pos,
185
+ )
186
+ }
187
+
188
+ let value = BigInt(first & ((1 << (8 - length)) - 1))
189
+ for (let i = 1; i < length; i++) {
190
+ value = (value << 8n) | BigInt(this.view.getUint8(this.pos + i))
191
+ }
192
+ this.pos += length
193
+ return value
194
+ }
195
+ }
196
+
197
+ /** Draft-17's reader, which rejects the 7-byte form draft-18 restored. */
198
+ export class Draft17BufferReader extends MoqtBufferReader {
199
+ protected override get allowSevenByte(): boolean {
200
+ return false
201
+ }
202
+ }