@moqtap/codec 0.4.2 → 0.5.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 (164) hide show
  1. package/dist/chunk-A33U4WVS.cjs +1993 -0
  2. package/dist/chunk-A655PHFX.cjs +446 -0
  3. package/dist/{chunk-UJU63EFY.cjs → chunk-BAG6YWCP.cjs} +2 -3
  4. package/dist/{chunk-2UTVXWFF.js → chunk-COWGGUL4.js} +2 -3
  5. package/dist/{chunk-4IVZZOY3.js → chunk-CXFAQKL3.js} +2 -3
  6. package/dist/chunk-DLSGOZ6P.js +1993 -0
  7. package/dist/{chunk-SDWRXXOO.cjs → chunk-HO44OANK.cjs} +2 -3
  8. package/dist/{chunk-Q46ZURKX.js → chunk-HYI6LFMD.js} +2 -3
  9. package/dist/chunk-IWYKDCXP.js +446 -0
  10. package/dist/{chunk-WPFBK7UX.cjs → chunk-JB5VDJ2V.cjs} +4 -6
  11. package/dist/{chunk-2SGE5GMU.cjs → chunk-JTRU76JN.cjs} +4 -4
  12. package/dist/{chunk-TKBYPIN7.js → chunk-NZ7GYEMT.js} +4 -6
  13. package/dist/{chunk-5O764MBD.cjs → chunk-OGZTQA24.cjs} +6 -6
  14. package/dist/{chunk-76774UFF.js → chunk-Q5D6OW6Q.js} +4 -4
  15. package/dist/{chunk-XS77RBY7.js → chunk-RZ3UML47.js} +2 -4
  16. package/dist/{chunk-3XKO6PCR.cjs → chunk-SIYYMFCC.cjs} +2 -3
  17. package/dist/{chunk-Z6U26IRI.js → chunk-UP4XPH4J.js} +6 -6
  18. package/dist/{chunk-OKG2HT25.cjs → chunk-WMJVSBBE.cjs} +2 -4
  19. package/dist/{codec-CewFCsEy.d.ts → codec-3ZgEK-Yj.d.ts} +1 -1
  20. package/dist/{codec-C-Yk2RNa.d.ts → codec-6s9d5yZm.d.ts} +2 -2
  21. package/dist/{codec-w8z2j_uo.d.cts → codec-B6ouUJrm.d.cts} +2 -2
  22. package/dist/{codec-3Ppy_5Gd.d.ts → codec-BhW5CGZq.d.ts} +1 -1
  23. package/dist/{codec-wtt6WF1K.d.ts → codec-Bp4HPezr.d.ts} +1 -1
  24. package/dist/{codec-BB0U8MF2.d.cts → codec-BsSNjvB3.d.cts} +2 -2
  25. package/dist/codec-BvSmr-Jp.d.ts +30 -0
  26. package/dist/{codec-BU0gaSZm.d.ts → codec-BvzKRqiP.d.ts} +2 -2
  27. package/dist/{codec-D8REY9TB.d.ts → codec-BzRIVIzS.d.ts} +2 -2
  28. package/dist/{codec-DDUBJGn0.d.cts → codec-C17JvsEU.d.cts} +1 -1
  29. package/dist/{codec-CpBWhz9f.d.cts → codec-CBLLytyP.d.cts} +2 -2
  30. package/dist/{codec-DNfml-se.d.ts → codec-Cbv3sG2y.d.ts} +2 -2
  31. package/dist/{codec-R9TJCq-E.d.cts → codec-CzBmYisK.d.cts} +1 -1
  32. package/dist/{codec-CFWQY9Lj.d.cts → codec-D2YMCU11.d.cts} +1 -1
  33. package/dist/{codec-BN6jk0Td.d.cts → codec-D5Ss123f.d.cts} +2 -2
  34. package/dist/{codec-j819z_hL.d.cts → codec-DS-As0Pp.d.cts} +1 -1
  35. package/dist/{codec-D2QVSH9D.d.ts → codec-D_9X0i31.d.ts} +2 -2
  36. package/dist/{codec-z6_2PSzi.d.cts → codec-DbpLHKXN.d.cts} +2 -2
  37. package/dist/{codec-BHHfBTnV.d.ts → codec-DqHwYWM-.d.ts} +2 -2
  38. package/dist/{codec-iMEwV1UO.d.ts → codec-GayA_uN0.d.ts} +2 -2
  39. package/dist/codec-MxIhLDR5.d.cts +30 -0
  40. package/dist/{codec-DoOGjjDq.d.cts → codec-R28KwiGM.d.cts} +2 -2
  41. package/dist/{codec-ZwV-Njt6.d.ts → codec-Tdey03Bo.d.ts} +1 -1
  42. package/dist/{codec-BO5Go0Lm.d.cts → codec-yJ_axwtp.d.cts} +2 -2
  43. package/dist/draft07-session.d.cts +3 -3
  44. package/dist/draft07-session.d.ts +3 -3
  45. package/dist/draft07.d.cts +3 -3
  46. package/dist/draft07.d.ts +3 -3
  47. package/dist/draft08-session.d.cts +3 -3
  48. package/dist/draft08-session.d.ts +3 -3
  49. package/dist/draft08.d.cts +4 -4
  50. package/dist/draft08.d.ts +4 -4
  51. package/dist/draft09-session.d.cts +3 -3
  52. package/dist/draft09-session.d.ts +3 -3
  53. package/dist/draft09.d.cts +4 -4
  54. package/dist/draft09.d.ts +4 -4
  55. package/dist/draft10-session.d.cts +3 -3
  56. package/dist/draft10-session.d.ts +3 -3
  57. package/dist/draft10.d.cts +4 -4
  58. package/dist/draft10.d.ts +4 -4
  59. package/dist/draft11-session.d.cts +4 -4
  60. package/dist/draft11-session.d.ts +4 -4
  61. package/dist/draft11.cjs +2 -2
  62. package/dist/draft11.d.cts +6 -6
  63. package/dist/draft11.d.ts +6 -6
  64. package/dist/draft11.js +1 -1
  65. package/dist/draft12-session.d.cts +4 -4
  66. package/dist/draft12-session.d.ts +4 -4
  67. package/dist/draft12.cjs +2 -2
  68. package/dist/draft12.d.cts +6 -6
  69. package/dist/draft12.d.ts +6 -6
  70. package/dist/draft12.js +1 -1
  71. package/dist/draft13-session.d.cts +4 -4
  72. package/dist/draft13-session.d.ts +4 -4
  73. package/dist/draft13.cjs +2 -2
  74. package/dist/draft13.d.cts +6 -6
  75. package/dist/draft13.d.ts +6 -6
  76. package/dist/draft13.js +1 -1
  77. package/dist/draft14-session.d.cts +4 -4
  78. package/dist/draft14-session.d.ts +4 -4
  79. package/dist/draft14.cjs +2 -2
  80. package/dist/draft14.d.cts +6 -6
  81. package/dist/draft14.d.ts +6 -6
  82. package/dist/draft14.js +1 -1
  83. package/dist/draft15-session.d.cts +4 -4
  84. package/dist/draft15-session.d.ts +4 -4
  85. package/dist/draft15.cjs +2 -2
  86. package/dist/draft15.d.cts +6 -6
  87. package/dist/draft15.d.ts +6 -6
  88. package/dist/draft15.js +1 -1
  89. package/dist/draft16-session.d.cts +4 -4
  90. package/dist/draft16-session.d.ts +4 -4
  91. package/dist/draft16.cjs +2 -2
  92. package/dist/draft16.d.cts +6 -6
  93. package/dist/draft16.d.ts +6 -6
  94. package/dist/draft16.js +1 -1
  95. package/dist/draft17-session.d.cts +4 -4
  96. package/dist/draft17-session.d.ts +4 -4
  97. package/dist/draft17.cjs +2 -2
  98. package/dist/draft17.d.cts +5 -5
  99. package/dist/draft17.d.ts +5 -5
  100. package/dist/draft17.js +1 -1
  101. package/dist/draft18-session.cjs +8 -0
  102. package/dist/draft18-session.d.cts +50 -0
  103. package/dist/draft18-session.d.ts +50 -0
  104. package/dist/draft18-session.js +8 -0
  105. package/dist/draft18.cjs +179 -0
  106. package/dist/draft18.d.cts +126 -0
  107. package/dist/draft18.d.ts +126 -0
  108. package/dist/draft18.js +179 -0
  109. package/dist/index.cjs +21 -15
  110. package/dist/index.d.cts +26 -21
  111. package/dist/index.d.ts +26 -21
  112. package/dist/index.js +14 -8
  113. package/dist/{session-types-X-IYEGoG.d.ts → session-types-DBpCRtrL.d.ts} +1 -1
  114. package/dist/{session-types-C7UONex5.d.cts → session-types-sBaTRwDh.d.cts} +1 -1
  115. package/dist/session.cjs +5 -1
  116. package/dist/session.d.cts +12 -10
  117. package/dist/session.d.ts +12 -10
  118. package/dist/session.js +5 -1
  119. package/dist/{types-DuyE0ygT.d.cts → types-Bio-91Rt.d.cts} +1 -1
  120. package/dist/{types-DuyE0ygT.d.ts → types-Bio-91Rt.d.ts} +1 -1
  121. package/dist/{types-DuxfOYiO.d.cts → types-CPaYBsMG.d.cts} +1 -1
  122. package/dist/{types-DuxfOYiO.d.ts → types-CPaYBsMG.d.ts} +1 -1
  123. package/dist/{types-DrQpTW1G.d.cts → types-CXlSn0I9.d.cts} +1 -1
  124. package/dist/{types-DrQpTW1G.d.ts → types-CXlSn0I9.d.ts} +1 -1
  125. package/dist/{types--Q7_DcvP.d.cts → types-Ck45Ex5S.d.cts} +1 -1
  126. package/dist/{types--Q7_DcvP.d.ts → types-Ck45Ex5S.d.ts} +1 -1
  127. package/dist/{types-BFpFNM_m.d.cts → types-Cm9fjeYC.d.cts} +1 -1
  128. package/dist/{types-BFpFNM_m.d.ts → types-Cm9fjeYC.d.ts} +1 -1
  129. package/dist/{types-DuIO7cWK.d.cts → types-CnBuq68e.d.cts} +1 -1
  130. package/dist/{types-DuIO7cWK.d.ts → types-CnBuq68e.d.ts} +1 -1
  131. package/dist/types-Cqp10JtB.d.cts +249 -0
  132. package/dist/types-Cqp10JtB.d.ts +249 -0
  133. package/dist/{types-Br7fm2mf.d.cts → types-D9eiB_9A.d.cts} +2 -2
  134. package/dist/{types-Br7fm2mf.d.ts → types-D9eiB_9A.d.ts} +2 -2
  135. package/dist/{types--FGt0sAp.d.cts → types-DjmrHp_s.d.cts} +1 -1
  136. package/dist/{types--FGt0sAp.d.ts → types-DjmrHp_s.d.ts} +1 -1
  137. package/package.json +14 -2
  138. package/src/core/types.ts +13 -1
  139. package/src/drafts/draft11/codec.ts +2 -3
  140. package/src/drafts/draft11/types.ts +1 -1
  141. package/src/drafts/draft12/codec.ts +4 -6
  142. package/src/drafts/draft12/types.ts +1 -1
  143. package/src/drafts/draft13/codec.ts +2 -3
  144. package/src/drafts/draft13/types.ts +1 -1
  145. package/src/drafts/draft14/codec.ts +4 -4
  146. package/src/drafts/draft14/types.ts +1 -1
  147. package/src/drafts/draft15/codec.ts +2 -4
  148. package/src/drafts/draft15/types.ts +1 -1
  149. package/src/drafts/draft16/codec.ts +2 -3
  150. package/src/drafts/draft16/types.ts +1 -1
  151. package/src/drafts/draft17/codec.ts +6 -6
  152. package/src/drafts/draft17/error-codes.ts +72 -0
  153. package/src/drafts/draft17/types.ts +2 -2
  154. package/src/drafts/draft18/codec.ts +1310 -0
  155. package/src/drafts/draft18/data-streams.ts +996 -0
  156. package/src/drafts/draft18/error-codes.ts +75 -0
  157. package/src/drafts/draft18/index.ts +122 -0
  158. package/src/drafts/draft18/messages.ts +56 -0
  159. package/src/drafts/draft18/rules.ts +85 -0
  160. package/src/drafts/draft18/session-fsm.ts +451 -0
  161. package/src/drafts/draft18/session.ts +15 -0
  162. package/src/drafts/draft18/types.ts +347 -0
  163. package/src/index.ts +9 -1
  164. package/src/session.ts +4 -0
@@ -0,0 +1,249 @@
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 Draft18SetupOptions {
13
+ path?: string;
14
+ authorization_token?: AuthorizationToken;
15
+ max_auth_token_cache_size?: bigint;
16
+ authority?: string;
17
+ moqt_implementation?: string;
18
+ unknown?: UnknownParam[];
19
+ }
20
+ interface SubscriptionFilter {
21
+ readonly filter_type: bigint;
22
+ readonly start_group?: bigint;
23
+ readonly start_object?: bigint;
24
+ readonly end_group?: bigint;
25
+ }
26
+ interface LargestObject {
27
+ readonly group: bigint;
28
+ readonly object: bigint;
29
+ }
30
+ interface Draft18Params {
31
+ object_delivery_timeout?: bigint;
32
+ authorization_token?: AuthorizationToken;
33
+ rendezvous_timeout?: bigint;
34
+ subgroup_delivery_timeout?: bigint;
35
+ expires?: bigint;
36
+ largest_object?: LargestObject;
37
+ fill_timeout?: bigint;
38
+ forward?: bigint;
39
+ subscriber_priority?: bigint;
40
+ subscription_filter?: SubscriptionFilter;
41
+ group_order?: bigint;
42
+ new_group_request?: bigint;
43
+ track_namespace_prefix?: string[];
44
+ unknown?: UnknownParam[];
45
+ }
46
+ interface Draft18TrackProperties {
47
+ object_delivery_timeout?: bigint;
48
+ max_cache_duration?: bigint;
49
+ subgroup_delivery_timeout?: bigint;
50
+ immutable_properties?: Uint8Array;
51
+ default_publisher_priority?: bigint;
52
+ default_publisher_group_order?: bigint;
53
+ dynamic_groups?: bigint;
54
+ unknown?: UnknownParam[];
55
+ }
56
+ type Draft18MessageType = 'setup' | 'subscribe' | 'subscribe_ok' | 'request_update' | 'publish' | 'publish_done' | 'publish_namespace' | 'namespace' | 'namespace_done' | 'subscribe_namespace' | 'subscribe_tracks' | 'publish_blocked' | 'fetch' | 'fetch_ok' | 'track_status' | 'request_ok' | 'request_error' | 'goaway';
57
+ interface Draft18BaseMessage {
58
+ readonly type: Draft18MessageType;
59
+ }
60
+ interface Draft18Setup extends Draft18BaseMessage {
61
+ readonly type: 'setup';
62
+ readonly options: Draft18SetupOptions;
63
+ }
64
+ interface Draft18Subscribe extends Draft18BaseMessage {
65
+ readonly type: 'subscribe';
66
+ readonly request_id: bigint;
67
+ readonly track_namespace: string[];
68
+ readonly track_name: string;
69
+ readonly parameters: Draft18Params;
70
+ }
71
+ interface Draft18SubscribeOk extends Draft18BaseMessage {
72
+ readonly type: 'subscribe_ok';
73
+ readonly track_alias: bigint;
74
+ readonly parameters: Draft18Params;
75
+ readonly track_properties: Draft18TrackProperties;
76
+ }
77
+ interface Draft18RequestUpdate extends Draft18BaseMessage {
78
+ readonly type: 'request_update';
79
+ readonly request_id: bigint;
80
+ readonly parameters: Draft18Params;
81
+ }
82
+ interface Draft18Publish extends Draft18BaseMessage {
83
+ readonly type: 'publish';
84
+ readonly request_id: bigint;
85
+ readonly track_namespace: string[];
86
+ readonly track_name: string;
87
+ readonly track_alias: bigint;
88
+ readonly parameters: Draft18Params;
89
+ readonly track_properties: Draft18TrackProperties;
90
+ }
91
+ interface Draft18PublishDone extends Draft18BaseMessage {
92
+ readonly type: 'publish_done';
93
+ readonly status_code: bigint;
94
+ readonly stream_count: bigint;
95
+ readonly reason_phrase: string;
96
+ }
97
+ interface Draft18PublishNamespace extends Draft18BaseMessage {
98
+ readonly type: 'publish_namespace';
99
+ readonly request_id: bigint;
100
+ readonly track_namespace: string[];
101
+ readonly parameters: Draft18Params;
102
+ }
103
+ interface Draft18Namespace extends Draft18BaseMessage {
104
+ readonly type: 'namespace';
105
+ readonly namespace_suffix: string[];
106
+ }
107
+ interface Draft18NamespaceDone extends Draft18BaseMessage {
108
+ readonly type: 'namespace_done';
109
+ readonly namespace_suffix: string[];
110
+ }
111
+ interface Draft18SubscribeNamespace extends Draft18BaseMessage {
112
+ readonly type: 'subscribe_namespace';
113
+ readonly request_id: bigint;
114
+ readonly namespace_prefix: string[];
115
+ readonly parameters: Draft18Params;
116
+ }
117
+ interface Draft18SubscribeTracks extends Draft18BaseMessage {
118
+ readonly type: 'subscribe_tracks';
119
+ readonly request_id: bigint;
120
+ readonly namespace_prefix: string[];
121
+ readonly parameters: Draft18Params;
122
+ }
123
+ interface Draft18PublishBlocked extends Draft18BaseMessage {
124
+ readonly type: 'publish_blocked';
125
+ readonly namespace_suffix: string[];
126
+ readonly track_name: string;
127
+ }
128
+ interface StandaloneFetch {
129
+ readonly track_namespace: string[];
130
+ readonly track_name: string;
131
+ readonly start_group: bigint;
132
+ readonly start_object: bigint;
133
+ readonly end_group: bigint;
134
+ readonly end_object: bigint;
135
+ }
136
+ interface JoiningFetch {
137
+ readonly joining_request_id: bigint;
138
+ readonly joining_start: bigint;
139
+ }
140
+ interface Draft18Fetch extends Draft18BaseMessage {
141
+ readonly type: 'fetch';
142
+ readonly request_id: bigint;
143
+ readonly fetch_type: bigint;
144
+ readonly standalone?: StandaloneFetch;
145
+ readonly joining?: JoiningFetch;
146
+ readonly parameters: Draft18Params;
147
+ }
148
+ interface Draft18FetchOk extends Draft18BaseMessage {
149
+ readonly type: 'fetch_ok';
150
+ readonly end_of_track: number;
151
+ readonly end_group: bigint;
152
+ readonly end_object: bigint;
153
+ readonly parameters: Draft18Params;
154
+ readonly track_properties: Draft18TrackProperties;
155
+ }
156
+ interface Draft18TrackStatus extends Draft18BaseMessage {
157
+ readonly type: 'track_status';
158
+ readonly request_id: bigint;
159
+ readonly track_namespace: string[];
160
+ readonly track_name: string;
161
+ readonly parameters: Draft18Params;
162
+ }
163
+ interface Draft18RequestOk extends Draft18BaseMessage {
164
+ readonly type: 'request_ok';
165
+ readonly parameters: Draft18Params;
166
+ readonly track_properties: Draft18TrackProperties;
167
+ }
168
+ interface Redirect {
169
+ readonly connect_uri: string;
170
+ readonly track_namespace: string[];
171
+ readonly track_name: string;
172
+ }
173
+ interface Draft18RequestError extends Draft18BaseMessage {
174
+ readonly type: 'request_error';
175
+ readonly error_code: bigint;
176
+ readonly retry_interval: bigint;
177
+ readonly reason_phrase: string;
178
+ readonly redirect?: Redirect;
179
+ }
180
+ interface Draft18GoAway extends Draft18BaseMessage {
181
+ readonly type: 'goaway';
182
+ readonly new_session_uri: string;
183
+ readonly timeout: bigint;
184
+ readonly request_id?: bigint;
185
+ }
186
+ type Draft18Message = Draft18Setup | Draft18Subscribe | Draft18SubscribeOk | Draft18RequestUpdate | Draft18Publish | Draft18PublishDone | Draft18PublishNamespace | Draft18Namespace | Draft18NamespaceDone | Draft18SubscribeNamespace | Draft18SubscribeTracks | Draft18PublishBlocked | Draft18Fetch | Draft18FetchOk | Draft18TrackStatus | Draft18RequestOk | Draft18RequestError | Draft18GoAway;
187
+ interface ObjectPayload {
188
+ readonly type: 'object';
189
+ readonly byteOffset: number;
190
+ readonly payloadByteOffset: number;
191
+ readonly objectId: bigint;
192
+ readonly payloadLength: number;
193
+ readonly status?: bigint;
194
+ readonly extensionData: Uint8Array;
195
+ readonly objectProperties?: Record<string, bigint>;
196
+ readonly payload: Uint8Array;
197
+ }
198
+ interface SubgroupStream {
199
+ readonly type: 'subgroup';
200
+ readonly headerType: number;
201
+ readonly trackAlias: bigint;
202
+ readonly groupId: bigint;
203
+ readonly subgroupId: bigint;
204
+ readonly publisherPriority: number;
205
+ readonly endOfGroup?: boolean;
206
+ readonly firstObject?: boolean;
207
+ readonly objects: ObjectPayload[];
208
+ }
209
+ interface DatagramObject {
210
+ readonly type: 'datagram';
211
+ readonly datagramType: number;
212
+ readonly trackAlias: bigint;
213
+ readonly groupId: bigint;
214
+ readonly objectId: bigint;
215
+ readonly publisherPriority: number;
216
+ readonly endOfGroup?: boolean;
217
+ readonly objectStatus?: bigint;
218
+ readonly objectProperties?: Record<string, bigint>;
219
+ readonly payloadLength: number;
220
+ readonly payload: Uint8Array;
221
+ }
222
+ interface FetchObjectPayload extends ObjectPayload {
223
+ readonly serializationFlags: number;
224
+ readonly groupId: bigint;
225
+ readonly subgroupId: bigint;
226
+ readonly publisherPriority: number;
227
+ readonly objectProperties?: Record<string, bigint>;
228
+ }
229
+ interface FetchStream {
230
+ readonly type: 'fetch';
231
+ readonly requestId: bigint;
232
+ readonly objects: FetchObjectPayload[];
233
+ }
234
+ type Draft18DataStream = SubgroupStream | DatagramObject | FetchStream;
235
+ interface SubgroupStreamHeader {
236
+ readonly type: 'subgroup_header';
237
+ readonly trackAlias: bigint;
238
+ readonly groupId: bigint;
239
+ readonly subgroupId: bigint;
240
+ readonly publisherPriority: number;
241
+ }
242
+ interface FetchStreamHeader {
243
+ readonly type: 'fetch_header';
244
+ readonly requestId: bigint;
245
+ }
246
+ type DataStreamHeader = SubgroupStreamHeader | FetchStreamHeader;
247
+ type DataStreamEvent = DataStreamHeader | ObjectPayload;
248
+
249
+ export type { Draft18SubscribeTracks as A, Draft18TrackProperties as B, Draft18TrackStatus as C, Draft18Message as D, FetchObjectPayload as E, FetchStreamHeader as F, StandaloneFetch as G, SubscriptionFilter as H, JoiningFetch as J, LargestObject as L, ObjectPayload as O, Redirect as R, SubgroupStreamHeader as S, UnknownParam as U, Draft18MessageType as a, DataStreamEvent as b, Draft18DataStream as c, DatagramObject as d, FetchStream as e, SubgroupStream as f, DataStreamHeader as g, Draft18BaseMessage as h, Draft18Fetch as i, Draft18FetchOk as j, Draft18GoAway as k, Draft18Namespace as l, Draft18NamespaceDone as m, Draft18Params as n, Draft18Publish as o, Draft18PublishBlocked as p, Draft18PublishDone as q, Draft18PublishNamespace as r, Draft18RequestError as s, Draft18RequestOk as t, Draft18RequestUpdate as u, Draft18Setup as v, Draft18SetupOptions as w, Draft18Subscribe as x, Draft18SubscribeNamespace as y, Draft18SubscribeOk as z };
@@ -7,7 +7,7 @@ interface AuthorizationToken {
7
7
  readonly alias_type: bigint;
8
8
  readonly token_alias?: bigint;
9
9
  readonly token_type?: bigint;
10
- readonly token_value?: string;
10
+ readonly token_value?: Uint8Array;
11
11
  }
12
12
  interface Draft17SetupOptions {
13
13
  path?: string;
@@ -43,7 +43,7 @@ interface Draft17Params {
43
43
  interface Draft17TrackProperties {
44
44
  delivery_timeout?: bigint;
45
45
  max_cache_duration?: bigint;
46
- immutable_properties?: string;
46
+ immutable_properties?: Uint8Array;
47
47
  default_publisher_priority?: bigint;
48
48
  default_publisher_group_order?: bigint;
49
49
  dynamic_groups?: bigint;
@@ -7,7 +7,7 @@ interface AuthorizationToken {
7
7
  readonly alias_type: bigint;
8
8
  readonly token_alias?: bigint;
9
9
  readonly token_type?: bigint;
10
- readonly token_value?: string;
10
+ readonly token_value?: Uint8Array;
11
11
  }
12
12
  interface Draft17SetupOptions {
13
13
  path?: string;
@@ -43,7 +43,7 @@ interface Draft17Params {
43
43
  interface Draft17TrackProperties {
44
44
  delivery_timeout?: bigint;
45
45
  max_cache_duration?: bigint;
46
- immutable_properties?: string;
46
+ immutable_properties?: Uint8Array;
47
47
  default_publisher_priority?: bigint;
48
48
  default_publisher_group_order?: bigint;
49
49
  dynamic_groups?: bigint;
@@ -25,7 +25,7 @@ interface UnknownParam {
25
25
  interface AuthorizationToken {
26
26
  readonly alias_type: bigint;
27
27
  readonly token_type?: bigint;
28
- readonly token_value?: string;
28
+ readonly token_value?: Uint8Array;
29
29
  readonly token_alias?: bigint;
30
30
  }
31
31
  interface Draft14Params {
@@ -25,7 +25,7 @@ interface UnknownParam {
25
25
  interface AuthorizationToken {
26
26
  readonly alias_type: bigint;
27
27
  readonly token_type?: bigint;
28
- readonly token_value?: string;
28
+ readonly token_value?: Uint8Array;
29
29
  readonly token_alias?: bigint;
30
30
  }
31
31
  interface Draft14Params {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moqtap/codec",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "MoQT wire-format codec and session state machine — multi-draft, zero dependencies",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -172,6 +172,18 @@
172
172
  "types": "./dist/draft17-session.d.ts",
173
173
  "import": "./dist/draft17-session.js",
174
174
  "require": "./dist/draft17-session.cjs"
175
+ },
176
+ "./draft18": {
177
+ "bun": "./src/drafts/draft18/index.ts",
178
+ "types": "./dist/draft18.d.ts",
179
+ "import": "./dist/draft18.js",
180
+ "require": "./dist/draft18.cjs"
181
+ },
182
+ "./draft18/session": {
183
+ "bun": "./src/drafts/draft18/session.ts",
184
+ "types": "./dist/draft18-session.d.ts",
185
+ "import": "./dist/draft18-session.js",
186
+ "require": "./dist/draft18-session.cjs"
175
187
  }
176
188
  },
177
189
  "files": [
@@ -184,7 +196,7 @@
184
196
  "test": "vitest run"
185
197
  },
186
198
  "devDependencies": {
187
- "@moqtap/test-vectors": "^0.8.2",
199
+ "@moqtap/test-vectors": "^0.9.1",
188
200
  "tsup": "^8.0.0",
189
201
  "typescript": "^5.5.0",
190
202
  "vitest": "^3.0.0"
package/src/core/types.ts CHANGED
@@ -1,5 +1,17 @@
1
1
  // Draft identifiers
2
- export type Draft = '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17'
2
+ export type Draft =
3
+ | '07'
4
+ | '08'
5
+ | '09'
6
+ | '10'
7
+ | '11'
8
+ | '12'
9
+ | '13'
10
+ | '14'
11
+ | '15'
12
+ | '16'
13
+ | '17'
14
+ | '18'
3
15
 
4
16
  // Base codec interface — draft-specific codecs extend this
5
17
  export interface BaseCodec<M> {
@@ -158,8 +158,7 @@ function encodeParams(params: Draft11Params, w: BufferWriter): void {
158
158
  const tmpW = new BufferWriter(64)
159
159
  tmpW.writeVarInt(at.alias_type)
160
160
  tmpW.writeVarInt(at.token_type)
161
- const tokenBytes = textEncoder.encode(at.token_value)
162
- tmpW.writeBytes(tokenBytes)
161
+ tmpW.writeBytes(at.token_value)
163
162
  const raw = tmpW.finish()
164
163
  w.writeVarInt(raw.byteLength)
165
164
  w.writeBytes(raw)
@@ -231,7 +230,7 @@ function decodeParams(r: BufferReader): Draft11Params {
231
230
  result.authorization_token = {
232
231
  alias_type,
233
232
  token_type,
234
- token_value: textDecoder.decode(tokenBytes),
233
+ token_value: tokenBytes,
235
234
  }
236
235
  } else {
237
236
  const bytes = r.readBytes(length)
@@ -12,7 +12,7 @@ export interface UnknownParam {
12
12
  export interface AuthorizationToken {
13
13
  readonly alias_type: bigint
14
14
  readonly token_type: bigint
15
- readonly token_value: string
15
+ readonly token_value: Uint8Array
16
16
  }
17
17
 
18
18
  // Setup parameters (PATH, MAX_REQUEST_ID) — same even/odd encoding as later drafts
@@ -94,8 +94,7 @@ function encodeSetupParams(params: Draft12SetupParams, w: BufferWriter): void {
94
94
  const tmpW = new BufferWriter(64)
95
95
  tmpW.writeVarInt(at.alias_type)
96
96
  tmpW.writeVarInt(at.token_type)
97
- const tokenBytes = textEncoder.encode(at.token_value)
98
- tmpW.writeBytes(tokenBytes)
97
+ tmpW.writeBytes(at.token_value)
99
98
  const raw = tmpW.finish()
100
99
  w.writeVarInt(raw.byteLength)
101
100
  w.writeBytes(raw)
@@ -152,7 +151,7 @@ function decodeSetupParams(r: BufferReader): Draft12SetupParams {
152
151
  result.authorization_token = {
153
152
  alias_type,
154
153
  token_type,
155
- token_value: textDecoder.decode(tokenBytes),
154
+ token_value: tokenBytes,
156
155
  }
157
156
  } else {
158
157
  const bytes = r.readBytes(length)
@@ -191,8 +190,7 @@ function encodeParams(params: Draft12Params, w: BufferWriter): void {
191
190
  const tmpW = new BufferWriter(64)
192
191
  tmpW.writeVarInt(at.alias_type)
193
192
  tmpW.writeVarInt(at.token_type)
194
- const tokenBytes = textEncoder.encode(at.token_value)
195
- tmpW.writeBytes(tokenBytes)
193
+ tmpW.writeBytes(at.token_value)
196
194
  const raw = tmpW.finish()
197
195
  w.writeVarInt(raw.byteLength)
198
196
  w.writeBytes(raw)
@@ -259,7 +257,7 @@ function decodeParams(r: BufferReader): Draft12Params {
259
257
  result.authorization_token = {
260
258
  alias_type,
261
259
  token_type,
262
- token_value: textDecoder.decode(tokenBytes),
260
+ token_value: tokenBytes,
263
261
  }
264
262
  } else {
265
263
  const bytes = r.readBytes(length)
@@ -12,7 +12,7 @@ export interface UnknownParam {
12
12
  export interface AuthorizationToken {
13
13
  readonly alias_type: bigint
14
14
  readonly token_type: bigint
15
- readonly token_value: string
15
+ readonly token_value: Uint8Array
16
16
  }
17
17
 
18
18
  // Setup parameters (PATH, MAX_REQUEST_ID) — same even/odd encoding as later drafts
@@ -85,8 +85,7 @@ function encodeAuthorizationToken(at: AuthorizationToken, w: BufferWriter): void
85
85
  if (aliasType === 1 || aliasType === 3) {
86
86
  // REGISTER, USE_VALUE have token_type + token_value
87
87
  tmpW.writeVarInt(at.token_type ?? 0n)
88
- const tokenBytes = textEncoder.encode(at.token_value ?? '')
89
- tmpW.writeBytes(tokenBytes)
88
+ tmpW.writeBytes(at.token_value ?? new Uint8Array(0))
90
89
  }
91
90
  const raw = tmpW.finish()
92
91
  w.writeVarInt(raw.byteLength)
@@ -105,7 +104,7 @@ function decodeAuthorizationToken(r: BufferReader, length: number): Authorizatio
105
104
  result.token_type = r.readVarInt()
106
105
  const tokenBytesLen = length - (r.offset - startOff)
107
106
  const tokenBytes = r.readBytes(tokenBytesLen)
108
- result.token_value = textDecoder.decode(tokenBytes)
107
+ result.token_value = tokenBytes
109
108
  }
110
109
  return result as unknown as AuthorizationToken
111
110
  }
@@ -14,7 +14,7 @@ export interface AuthorizationToken {
14
14
  readonly alias_type: bigint
15
15
  readonly token_alias?: bigint // present for DELETE(0), REGISTER(1), USE_ALIAS(2)
16
16
  readonly token_type?: bigint // present for USE_VALUE(3), REGISTER(1)
17
- readonly token_value?: string // present for USE_VALUE(3), REGISTER(1)
17
+ readonly token_value?: Uint8Array // present for USE_VALUE(3), REGISTER(1)
18
18
  }
19
19
 
20
20
  // Setup parameters (PATH, MAX_REQUEST_ID, AUTHORIZATION_TOKEN, MAX_AUTH_TOKEN_CACHE_SIZE)
@@ -109,7 +109,7 @@ function encodeSetupParams(params: Draft14Params, writer: BufferWriter): void {
109
109
  tmpWriter.writeVarInt(tok.token_type)
110
110
  }
111
111
  if (tok.token_value !== undefined) {
112
- tmpWriter.writeBytes(hexToBytes(tok.token_value))
112
+ tmpWriter.writeBytes(tok.token_value)
113
113
  }
114
114
  if (tok.token_alias !== undefined) {
115
115
  tmpWriter.writeVarInt(tok.token_alias)
@@ -184,7 +184,7 @@ function decodeSetupParams(reader: BufferReader): Draft14Params {
184
184
  tok.token_type = tokenReader.readVarInt()
185
185
  if (tokenReader.remaining > 0) {
186
186
  const tokenValue = tokenReader.readBytesView(tokenReader.remaining)
187
- tok.token_value = bytesToHex(tokenValue)
187
+ tok.token_value = new Uint8Array(tokenValue)
188
188
  }
189
189
  }
190
190
  result.authorization_token = tok as unknown as AuthorizationToken
@@ -228,7 +228,7 @@ function encodeMessageParams(params: Draft14Params, writer: BufferWriter): void
228
228
  tmpWriter.writeVarInt(tok.token_type)
229
229
  }
230
230
  if (tok.token_value !== undefined) {
231
- tmpWriter.writeBytes(hexToBytes(tok.token_value))
231
+ tmpWriter.writeBytes(tok.token_value)
232
232
  }
233
233
  if (tok.token_alias !== undefined) {
234
234
  tmpWriter.writeVarInt(tok.token_alias)
@@ -287,7 +287,7 @@ function decodeMessageParams(reader: BufferReader): Draft14Params {
287
287
  tok.token_type = tokenReader.readVarInt()
288
288
  if (tokenReader.remaining > 0) {
289
289
  const tokenValue = tokenReader.readBytesView(tokenReader.remaining)
290
- tok.token_value = bytesToHex(tokenValue)
290
+ tok.token_value = new Uint8Array(tokenValue)
291
291
  }
292
292
  }
293
293
  result.authorization_token = tok as unknown as AuthorizationToken
@@ -33,7 +33,7 @@ export interface UnknownParam {
33
33
  export interface AuthorizationToken {
34
34
  readonly alias_type: bigint
35
35
  readonly token_type?: bigint
36
- readonly token_value?: string // raw hex
36
+ readonly token_value?: Uint8Array
37
37
  readonly token_alias?: bigint
38
38
  }
39
39
 
@@ -203,8 +203,7 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
203
203
  if (aliasType === 1 || aliasType === 3) {
204
204
  w.writeVarInt(token.token_type!)
205
205
  // token_value is the remaining bytes (no inner length prefix)
206
- const tokenBytes = hexToBytes(token.token_value_hex!)
207
- w.writeBytes(tokenBytes)
206
+ w.writeBytes(token.token_value!)
208
207
  }
209
208
  }
210
209
 
@@ -218,8 +217,7 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
218
217
  if (aliasType === 1 || aliasType === 3) {
219
218
  result.token_type = r.readVarInt()
220
219
  // token_value is the remaining bytes in the length-prefixed block
221
- const tokenBytes = r.readBytesView(r.remaining)
222
- result.token_value_hex = bytesToHex(tokenBytes)
220
+ result.token_value = r.readBytes(r.remaining)
223
221
  }
224
222
  return result as unknown as AuthorizationToken
225
223
  }
@@ -13,7 +13,7 @@ export interface AuthorizationToken {
13
13
  readonly alias_type: bigint
14
14
  readonly token_alias?: bigint // present when alias_type = 0 or 1
15
15
  readonly token_type?: bigint // present when alias_type = 1 or 3
16
- readonly token_value_hex?: string // present when alias_type = 1 or 3
16
+ readonly token_value?: Uint8Array // present when alias_type = 1 or 3
17
17
  }
18
18
 
19
19
  // Setup parameters (constant namespace across versions)
@@ -200,8 +200,7 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
200
200
  }
201
201
  if (aliasType === 1 || aliasType === 3) {
202
202
  w.writeVarInt(token.token_type!)
203
- const tokenBytes = hexToBytes(token.token_value_hex!)
204
- w.writeBytes(tokenBytes)
203
+ w.writeBytes(token.token_value!)
205
204
  }
206
205
  }
207
206
 
@@ -215,7 +214,7 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
215
214
  if (aliasType === 1 || aliasType === 3) {
216
215
  result.token_type = r.readVarInt()
217
216
  const tokenBytes = r.readBytesView(r.remaining)
218
- result.token_value_hex = bytesToHex(tokenBytes)
217
+ result.token_value = new Uint8Array(tokenBytes)
219
218
  }
220
219
  return result as unknown as AuthorizationToken
221
220
  }
@@ -13,7 +13,7 @@ export interface AuthorizationToken {
13
13
  readonly alias_type: bigint
14
14
  readonly token_alias?: bigint
15
15
  readonly token_type?: bigint
16
- readonly token_value_hex?: string
16
+ readonly token_value?: Uint8Array
17
17
  }
18
18
 
19
19
  // Setup parameters (constant namespace across versions)
@@ -199,9 +199,9 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
199
199
  if (aliasType === 1 || aliasType === 3) {
200
200
  // REGISTER, USE_VALUE: token_type + token_value present
201
201
  w.writeVarInt(token.token_type ?? 0n)
202
- const encoded = textEncoder.encode(token.token_value ?? '')
203
- w.writeVarInt(BigInt(encoded.byteLength))
204
- w.writeBytes(encoded)
202
+ const tv = token.token_value ?? new Uint8Array(0)
203
+ w.writeVarInt(BigInt(tv.byteLength))
204
+ w.writeBytes(tv)
205
205
  }
206
206
  }
207
207
 
@@ -217,7 +217,7 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
217
217
  ;(result as { token_type: bigint }).token_type = r.readVarInt()
218
218
  const len = Number(r.readVarInt())
219
219
  const bytes = r.readBytes(len)
220
- ;(result as { token_value: string }).token_value = textDecoder.decode(bytes)
220
+ ;(result as { token_value: Uint8Array }).token_value = bytes
221
221
  }
222
222
 
223
223
  return result
@@ -464,7 +464,7 @@ function encodeTrackProperties(props: Draft17TrackProperties, writer: BufferWrit
464
464
  entries.push({
465
465
  type: TPROP_IMMUTABLE_PROPERTIES,
466
466
  encode: (w) => {
467
- const raw = hexToBytes(props.immutable_properties!)
467
+ const raw = props.immutable_properties!
468
468
  w.writeVarInt(BigInt(raw.byteLength))
469
469
  w.writeBytes(raw)
470
470
  },
@@ -557,7 +557,7 @@ function decodeTrackProperties(reader: BufferReader, payloadEnd: number): Draft1
557
557
  const length = Number(reader.readVarInt())
558
558
  const bytes = reader.readBytes(length)
559
559
  if (propType === TPROP_IMMUTABLE_PROPERTIES) {
560
- result.immutable_properties = bytesToHex(bytes)
560
+ result.immutable_properties = bytes
561
561
  } else {
562
562
  unknown.push({
563
563
  id: `0x${propType.toString(16)}`,