@moqtap/codec 0.8.0 → 0.9.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.
- package/CHANGELOG.md +49 -0
- package/README.md +16 -4
- package/dist/{chunk-5XZKO2U5.js → chunk-2XH6PHXR.js} +62 -51
- package/dist/{chunk-BQHLUT37.cjs → chunk-7ENEWAMZ.cjs} +2 -6
- package/dist/chunk-BMJMY6FX.cjs +868 -0
- package/dist/{chunk-MD2OA7SE.js → chunk-BV6MITLO.js} +15 -8
- package/dist/{chunk-B56AG5HU.cjs → chunk-EVCPBFSR.cjs} +6 -4
- package/dist/{chunk-KNLPX3YA.js → chunk-H6DTAIWM.js} +6 -4
- package/dist/{chunk-J3ASFPCX.cjs → chunk-IADVBKEJ.cjs} +15 -8
- package/dist/chunk-MAXEHYVB.cjs +2362 -0
- package/dist/{chunk-I55J3KXD.js → chunk-NH4L6NIY.js} +48 -33
- package/dist/{chunk-EQAYMCXO.cjs → chunk-PU2KV7VP.cjs} +48 -33
- package/dist/{chunk-APTV6F72.js → chunk-Q7NSUXXB.js} +70 -52
- package/dist/{chunk-HEO2JG6C.js → chunk-TMXRYOBS.js} +100 -92
- package/dist/{chunk-MH7537FB.cjs → chunk-TVSFDQYE.cjs} +70 -52
- package/dist/{chunk-IEJULBKB.cjs → chunk-UA5XFP4O.cjs} +100 -92
- package/dist/{chunk-KTVN4P6J.cjs → chunk-UZO5Z2XT.cjs} +62 -51
- package/dist/chunk-WX5PU7HF.js +868 -0
- package/dist/{chunk-JJEN2VG5.js → chunk-XQGEOFGE.js} +2 -6
- package/dist/chunk-YJGOD3Y4.js +2362 -0
- package/dist/{codec-BLYAy2OP.d.ts → codec--CVeqGQv.d.ts} +1 -1
- package/dist/{codec-DujHf55Z.d.ts → codec-BJ7BHuiZ.d.ts} +1 -1
- package/dist/{codec-D47r_-Rl.d.ts → codec-BKsVu3Fr.d.ts} +1 -1
- package/dist/{codec-BNS3gS77.d.ts → codec-BMwgZIgG.d.ts} +1 -1
- package/dist/{codec-CI0BjmHc.d.ts → codec-BNy5syCU.d.ts} +1 -1
- package/dist/{codec-CFhUGTu2.d.ts → codec-BQa6Qsav.d.ts} +2 -2
- package/dist/codec-Bym-K2q2.d.cts +49 -0
- package/dist/{codec-D2JbI2tp.d.ts → codec-C006F75E.d.ts} +1 -1
- package/dist/codec-C5evFHL-.d.ts +49 -0
- package/dist/{codec-DQWQSam3.d.cts → codec-C6Mx4bwz.d.cts} +1 -1
- package/dist/{codec-DL0njGkL.d.ts → codec-CA6nbbEk.d.ts} +1 -1
- package/dist/{codec-D89DWXbv.d.cts → codec-CSBFdPgP.d.cts} +1 -1
- package/dist/{codec-DvcJgYKq.d.cts → codec-CXCjya_G.d.cts} +1 -1
- package/dist/{codec-hvkJfCF5.d.cts → codec-C_xxsbKy.d.cts} +1 -1
- package/dist/{codec-BOyrk_C9.d.cts → codec-Cfo_z5ET.d.cts} +1 -1
- package/dist/{codec-xeuGZY77.d.cts → codec-CgZdadPt.d.cts} +2 -2
- package/dist/{codec-WwwUipaU.d.ts → codec-Cl73EfRW.d.ts} +1 -1
- package/dist/{codec-BOtv3R5j.d.cts → codec-CtvFK4aV.d.cts} +1 -1
- package/dist/{codec-DAePx2NL.d.ts → codec-CviAa4lp.d.ts} +2 -2
- package/dist/{codec-DJmV04i0.d.ts → codec-D4RvFQmu.d.ts} +1 -1
- package/dist/{codec-cou9XBMF.d.cts → codec-DAyiF5sq.d.cts} +1 -1
- package/dist/{codec-CyApDKwf.d.cts → codec-DJmqoIsp.d.cts} +1 -1
- package/dist/{codec-NMsTK0GX.d.cts → codec-DchsPfr3.d.cts} +1 -1
- package/dist/{codec-DplRgIKq.d.ts → codec-Dl_QIXMz.d.ts} +1 -1
- package/dist/{codec-BnamSx7L.d.cts → codec-DzLvG8Wb.d.cts} +2 -2
- package/dist/{codec-D95gT98n.d.cts → codec-DzkdW4kO.d.cts} +1 -1
- package/dist/{codec-CWj5iTxA.d.ts → codec-O-1Js7h4.d.ts} +1 -1
- package/dist/{codec-BqqoYdh_.d.cts → codec-vddqy0KY.d.cts} +1 -1
- package/dist/draft07-session.d.cts +3 -3
- package/dist/draft07-session.d.ts +3 -3
- package/dist/draft07.d.cts +3 -3
- package/dist/draft07.d.ts +3 -3
- package/dist/draft08-session.d.cts +3 -3
- package/dist/draft08-session.d.ts +3 -3
- package/dist/draft08.d.cts +4 -4
- package/dist/draft08.d.ts +4 -4
- package/dist/draft09-session.d.cts +3 -3
- package/dist/draft09-session.d.ts +3 -3
- package/dist/draft09.d.cts +4 -4
- package/dist/draft09.d.ts +4 -4
- package/dist/draft10-session.d.cts +3 -3
- package/dist/draft10-session.d.ts +3 -3
- package/dist/draft10.d.cts +4 -4
- package/dist/draft10.d.ts +4 -4
- package/dist/draft11-session.d.cts +3 -3
- package/dist/draft11-session.d.ts +3 -3
- package/dist/draft11.d.cts +4 -4
- package/dist/draft11.d.ts +4 -4
- package/dist/draft12-session.d.cts +3 -3
- package/dist/draft12-session.d.ts +3 -3
- package/dist/draft12.cjs +2 -2
- package/dist/draft12.d.cts +4 -4
- package/dist/draft12.d.ts +4 -4
- package/dist/draft12.js +1 -1
- package/dist/draft13-session.d.cts +3 -3
- package/dist/draft13-session.d.ts +3 -3
- package/dist/draft13.d.cts +4 -4
- package/dist/draft13.d.ts +4 -4
- package/dist/draft14-session.d.cts +4 -4
- package/dist/draft14-session.d.ts +4 -4
- package/dist/draft14.cjs +2 -2
- package/dist/draft14.d.cts +6 -6
- package/dist/draft14.d.ts +6 -6
- package/dist/draft14.js +1 -1
- package/dist/draft15-session.d.cts +3 -3
- package/dist/draft15-session.d.ts +3 -3
- package/dist/draft15.cjs +2 -2
- package/dist/draft15.d.cts +4 -4
- package/dist/draft15.d.ts +4 -4
- package/dist/draft15.js +1 -1
- package/dist/draft16-session.d.cts +3 -3
- package/dist/draft16-session.d.ts +3 -3
- package/dist/draft16.cjs +2 -2
- package/dist/draft16.d.cts +4 -4
- package/dist/draft16.d.ts +4 -4
- package/dist/draft16.js +1 -1
- package/dist/draft17-session.d.cts +3 -3
- package/dist/draft17-session.d.ts +3 -3
- package/dist/draft17.cjs +2 -2
- package/dist/draft17.d.cts +3 -3
- package/dist/draft17.d.ts +3 -3
- package/dist/draft17.js +1 -1
- package/dist/draft18-session.d.cts +3 -3
- package/dist/draft18-session.d.ts +3 -3
- package/dist/draft18.cjs +2 -2
- package/dist/draft18.d.cts +3 -3
- package/dist/draft18.d.ts +3 -3
- package/dist/draft18.js +1 -1
- package/dist/draft19-session.d.cts +3 -3
- package/dist/draft19-session.d.ts +3 -3
- package/dist/draft19.cjs +2 -2
- package/dist/draft19.d.cts +3 -3
- package/dist/draft19.d.ts +3 -3
- package/dist/draft19.js +1 -1
- package/dist/draft20-session.cjs +8 -0
- package/dist/draft20-session.d.cts +195 -0
- package/dist/draft20-session.d.ts +195 -0
- package/dist/draft20-session.js +8 -0
- package/dist/draft20.cjs +217 -0
- package/dist/draft20.d.cts +175 -0
- package/dist/draft20.d.ts +175 -0
- package/dist/draft20.js +217 -0
- package/dist/index.cjs +21 -15
- package/dist/index.d.cts +33 -18
- package/dist/index.d.ts +33 -18
- package/dist/index.js +14 -8
- package/dist/{session-types-KsqyVp6y.d.cts → session-types-B9idsih-.d.cts} +13 -1
- package/dist/{session-types-C0l_-Ups.d.ts → session-types-Dn7b3RZM.d.ts} +13 -1
- package/dist/session.cjs +5 -1
- package/dist/session.d.cts +6 -4
- package/dist/session.d.ts +6 -4
- package/dist/session.js +5 -1
- package/dist/types-CWCQwuvy.d.cts +359 -0
- package/dist/types-CWCQwuvy.d.ts +359 -0
- package/dist/{types-CdCSIfvI.d.cts → types-DG5_iKuv.d.cts} +1 -1
- package/dist/{types-CdCSIfvI.d.ts → types-DG5_iKuv.d.ts} +1 -1
- package/dist/{types-CVeKIk7A.d.cts → types-HI_bbXka.d.cts} +0 -2
- package/dist/{types-CVeKIk7A.d.ts → types-HI_bbXka.d.ts} +0 -2
- package/package.json +16 -3
- package/src/core/session-types.ts +7 -0
- package/src/core/types.ts +1 -0
- package/src/drafts/draft12/data-streams.ts +13 -4
- package/src/drafts/draft14/codec.ts +2 -6
- package/src/drafts/draft14/types.ts +0 -2
- package/src/drafts/draft15/data-streams.ts +30 -16
- package/src/drafts/draft16/codec.ts +116 -93
- package/src/drafts/draft17/codec.ts +72 -35
- package/src/drafts/draft18/codec.ts +89 -53
- package/src/drafts/draft19/codec.ts +98 -55
- package/src/drafts/draft20/codec.ts +1737 -0
- package/src/drafts/draft20/data-streams.ts +1291 -0
- package/src/drafts/draft20/error-codes.ts +135 -0
- package/src/drafts/draft20/index.ts +165 -0
- package/src/drafts/draft20/messages.ts +68 -0
- package/src/drafts/draft20/rules.ts +107 -0
- package/src/drafts/draft20/session-fsm.ts +1063 -0
- package/src/drafts/draft20/session.ts +21 -0
- package/src/drafts/draft20/types.ts +455 -0
- package/src/index.ts +20 -2
- package/src/session.ts +4 -0
|
@@ -0,0 +1,359 @@
|
|
|
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 Draft20SetupOptions {
|
|
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
|
+
/**
|
|
23
|
+
* LOCATION_FILTER (0x21) — restructured in draft-20 (Section 5.1.2).
|
|
24
|
+
*
|
|
25
|
+
* The draft-19 `Filter Type` discriminator (0x1 Next Group Start / 0x2 Largest
|
|
26
|
+
* Object / 0x3 AbsoluteStart / 0x4 AbsoluteRange) is gone; the shape is the
|
|
27
|
+
* number of vi64 fields the value holds. The fields below carry the wire
|
|
28
|
+
* values verbatim, unresolved:
|
|
29
|
+
*
|
|
30
|
+
* - 1 field → `start_group` alone is RELATIVE: start is
|
|
31
|
+
* {Largest Object.Group + 1 - start_group, 0}. Open-ended.
|
|
32
|
+
* - 2 fields → absolute start {start_group, start_object}, except that
|
|
33
|
+
* {0, 0} means the Next Object. Open-ended.
|
|
34
|
+
* - 3 fields → end group is `start_group + end_group_delta`; `end_object`
|
|
35
|
+
* omitted means every object in that group.
|
|
36
|
+
* - 4 fields → the fully specified INCLUSIVE range
|
|
37
|
+
* {start_group, start_object} … {start_group + end_group_delta,
|
|
38
|
+
* end_object}.
|
|
39
|
+
*
|
|
40
|
+
* `removed: true` is the `Length == 0` form, which in REQUEST_UPDATE removes an
|
|
41
|
+
* existing filter.
|
|
42
|
+
*
|
|
43
|
+
* The range is inclusive at both ends. draft-19's "last Object, plus 1" and
|
|
44
|
+
* "Object == 0 means the whole group" conventions are gone, so nothing here is
|
|
45
|
+
* ever incremented or decremented on the way in or out.
|
|
46
|
+
*/
|
|
47
|
+
interface LocationFilter {
|
|
48
|
+
readonly start_group?: bigint;
|
|
49
|
+
readonly start_object?: bigint;
|
|
50
|
+
readonly end_group_delta?: bigint;
|
|
51
|
+
readonly end_object?: bigint;
|
|
52
|
+
readonly removed?: boolean;
|
|
53
|
+
}
|
|
54
|
+
interface RangeFilterRange {
|
|
55
|
+
readonly start: bigint;
|
|
56
|
+
readonly end?: bigint;
|
|
57
|
+
}
|
|
58
|
+
interface RangeFilter {
|
|
59
|
+
readonly set_id?: bigint;
|
|
60
|
+
readonly property_type?: bigint;
|
|
61
|
+
readonly ranges?: RangeFilterRange[];
|
|
62
|
+
readonly removed?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface LargestObject {
|
|
65
|
+
readonly group: bigint;
|
|
66
|
+
readonly object: bigint;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* FILL_PARAMETERS (0x23) value — NEW in draft-20 (Section 10.2.15).
|
|
70
|
+
*
|
|
71
|
+
* A separate parameter scope carrying only the settings that differ from the
|
|
72
|
+
* subscription's. Table 6 closes the list to exactly these eight types;
|
|
73
|
+
* TRACK_PROPERTY_FILTER (0x29) is deliberately excluded.
|
|
74
|
+
*
|
|
75
|
+
* The mere presence of the parameter is what requests a fill fetch stream, so
|
|
76
|
+
* an empty value is meaningful — it asks for a fill with everything inherited.
|
|
77
|
+
*/
|
|
78
|
+
interface Draft20FillParameters {
|
|
79
|
+
fill_timeout?: bigint;
|
|
80
|
+
subscriber_priority?: bigint;
|
|
81
|
+
location_filter?: LocationFilter;
|
|
82
|
+
group_order?: bigint;
|
|
83
|
+
subgroup_filter?: RangeFilter;
|
|
84
|
+
objectid_filter?: RangeFilter;
|
|
85
|
+
priority_filter?: RangeFilter;
|
|
86
|
+
object_property_filter?: RangeFilter;
|
|
87
|
+
}
|
|
88
|
+
interface Draft20Params {
|
|
89
|
+
object_delivery_timeout?: bigint;
|
|
90
|
+
authorization_token?: AuthorizationToken;
|
|
91
|
+
rendezvous_timeout?: bigint;
|
|
92
|
+
subgroup_delivery_timeout?: bigint;
|
|
93
|
+
expires?: bigint;
|
|
94
|
+
largest_object?: LargestObject;
|
|
95
|
+
fill_timeout?: bigint;
|
|
96
|
+
forward?: bigint;
|
|
97
|
+
subscriber_priority?: bigint;
|
|
98
|
+
location_filter?: LocationFilter;
|
|
99
|
+
group_order?: bigint;
|
|
100
|
+
fill_parameters?: Draft20FillParameters;
|
|
101
|
+
subgroup_filter?: RangeFilter;
|
|
102
|
+
objectid_filter?: RangeFilter;
|
|
103
|
+
priority_filter?: RangeFilter;
|
|
104
|
+
object_property_filter?: RangeFilter;
|
|
105
|
+
track_property_filter?: RangeFilter;
|
|
106
|
+
new_group_request?: bigint;
|
|
107
|
+
track_namespace_prefix?: string[];
|
|
108
|
+
include_properties?: bigint;
|
|
109
|
+
unknown?: UnknownParam[];
|
|
110
|
+
}
|
|
111
|
+
interface Draft20TrackProperties {
|
|
112
|
+
object_delivery_timeout?: bigint;
|
|
113
|
+
max_cache_duration?: bigint;
|
|
114
|
+
subgroup_delivery_timeout?: bigint;
|
|
115
|
+
immutable_properties?: Uint8Array;
|
|
116
|
+
default_publisher_priority?: bigint;
|
|
117
|
+
default_publisher_group_order?: bigint;
|
|
118
|
+
dynamic_groups?: bigint;
|
|
119
|
+
unknown?: UnknownParam[];
|
|
120
|
+
}
|
|
121
|
+
type Draft20MessageType = 'setup' | 'subscribe' | 'subscribe_ok' | 'request_update' | 'publish_state_notify' | 'publish' | 'publish_done' | 'publish_namespace' | 'namespace' | 'namespace_done' | 'subscribe_namespace' | 'subscribe_tracks' | 'publish_skipped' | 'fetch' | 'fetch_ok' | 'track_status' | 'request_ok' | 'request_error' | 'goaway';
|
|
122
|
+
interface Draft20BaseMessage {
|
|
123
|
+
readonly type: Draft20MessageType;
|
|
124
|
+
}
|
|
125
|
+
interface Draft20Setup extends Draft20BaseMessage {
|
|
126
|
+
readonly type: 'setup';
|
|
127
|
+
readonly options: Draft20SetupOptions;
|
|
128
|
+
}
|
|
129
|
+
interface Draft20Subscribe extends Draft20BaseMessage {
|
|
130
|
+
readonly type: 'subscribe';
|
|
131
|
+
readonly request_id: bigint;
|
|
132
|
+
readonly track_namespace: string[];
|
|
133
|
+
readonly track_name: string;
|
|
134
|
+
readonly parameters: Draft20Params;
|
|
135
|
+
}
|
|
136
|
+
interface Draft20SubscribeOk extends Draft20BaseMessage {
|
|
137
|
+
readonly type: 'subscribe_ok';
|
|
138
|
+
readonly track_alias: bigint;
|
|
139
|
+
readonly parameters: Draft20Params;
|
|
140
|
+
readonly track_properties: Draft20TrackProperties;
|
|
141
|
+
}
|
|
142
|
+
interface Draft20RequestUpdate extends Draft20BaseMessage {
|
|
143
|
+
readonly type: 'request_update';
|
|
144
|
+
readonly request_id: bigint;
|
|
145
|
+
readonly parameters: Draft20Params;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* PUBLISH_STATE_NOTIFY (0x22) — NEW in draft-20, Section 10.10.
|
|
149
|
+
*
|
|
150
|
+
* No Request ID: the message is identified by the subscription's bidirectional
|
|
151
|
+
* stream it arrives on, like SUBSCRIBE_OK, PUBLISH_DONE and FETCH_OK.
|
|
152
|
+
*/
|
|
153
|
+
interface Draft20PublishStateNotify extends Draft20BaseMessage {
|
|
154
|
+
readonly type: 'publish_state_notify';
|
|
155
|
+
readonly parameters: Draft20Params;
|
|
156
|
+
}
|
|
157
|
+
interface Draft20Publish extends Draft20BaseMessage {
|
|
158
|
+
readonly type: 'publish';
|
|
159
|
+
readonly request_id: bigint;
|
|
160
|
+
readonly track_namespace: string[];
|
|
161
|
+
readonly track_name: string;
|
|
162
|
+
readonly track_alias: bigint;
|
|
163
|
+
readonly parameters: Draft20Params;
|
|
164
|
+
readonly track_properties: Draft20TrackProperties;
|
|
165
|
+
}
|
|
166
|
+
interface Draft20PublishDone extends Draft20BaseMessage {
|
|
167
|
+
readonly type: 'publish_done';
|
|
168
|
+
readonly status_code: bigint;
|
|
169
|
+
/**
|
|
170
|
+
* Number of streams opened for the subscription, including empty subgroups
|
|
171
|
+
* and — new in draft-20 — fill fetch streams (Section 10.12), or the
|
|
172
|
+
* `UNKNOWN_STREAM_COUNT` sentinel exported from `codec.ts` (2^64 - 1, raised
|
|
173
|
+
* from draft-19's 2^62 - 1) when the publisher cannot state it exactly.
|
|
174
|
+
*
|
|
175
|
+
* `bigint`, not `number`: the sentinel does not fit a double.
|
|
176
|
+
*/
|
|
177
|
+
readonly stream_count: bigint;
|
|
178
|
+
readonly reason_phrase: string;
|
|
179
|
+
}
|
|
180
|
+
interface Draft20PublishNamespace extends Draft20BaseMessage {
|
|
181
|
+
readonly type: 'publish_namespace';
|
|
182
|
+
readonly request_id: bigint;
|
|
183
|
+
readonly track_namespace: string[];
|
|
184
|
+
readonly parameters: Draft20Params;
|
|
185
|
+
}
|
|
186
|
+
interface Draft20Namespace extends Draft20BaseMessage {
|
|
187
|
+
readonly type: 'namespace';
|
|
188
|
+
readonly namespace_suffix: string[];
|
|
189
|
+
}
|
|
190
|
+
interface Draft20NamespaceDone extends Draft20BaseMessage {
|
|
191
|
+
readonly type: 'namespace_done';
|
|
192
|
+
readonly namespace_suffix: string[];
|
|
193
|
+
}
|
|
194
|
+
interface Draft20SubscribeNamespace extends Draft20BaseMessage {
|
|
195
|
+
readonly type: 'subscribe_namespace';
|
|
196
|
+
readonly request_id: bigint;
|
|
197
|
+
readonly namespace_prefix: string[];
|
|
198
|
+
readonly parameters: Draft20Params;
|
|
199
|
+
}
|
|
200
|
+
interface Draft20SubscribeTracks extends Draft20BaseMessage {
|
|
201
|
+
readonly type: 'subscribe_tracks';
|
|
202
|
+
readonly request_id: bigint;
|
|
203
|
+
readonly namespace_prefix: string[];
|
|
204
|
+
readonly parameters: Draft20Params;
|
|
205
|
+
}
|
|
206
|
+
interface Draft20PublishSkipped extends Draft20BaseMessage {
|
|
207
|
+
readonly type: 'publish_skipped';
|
|
208
|
+
readonly namespace_suffix: string[];
|
|
209
|
+
readonly track_name: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* FETCH (0x16) — the byte layout was rewritten in draft-20 (Section 10.13).
|
|
213
|
+
*
|
|
214
|
+
* Gone: the `Fetch Type` field and its enum, the `Standalone Fetch` and
|
|
215
|
+
* `Joining Fetch` structures, and the inline `Start Location` / `End Location`.
|
|
216
|
+
* Track Namespace and Track Name are inline fields of FETCH itself, and the
|
|
217
|
+
* range travels in the LOCATION_FILTER parameter. A FETCH with no
|
|
218
|
+
* LOCATION_FILTER covers {0,0} through Largest Object, inclusive.
|
|
219
|
+
*
|
|
220
|
+
* The codepoint did not change, so a draft-19 decoder fed one of these reads
|
|
221
|
+
* the Number of Track Namespace Fields count as a Fetch Type and mis-parses in
|
|
222
|
+
* silence. There is no in-band version signal that catches it.
|
|
223
|
+
*/
|
|
224
|
+
interface Draft20Fetch extends Draft20BaseMessage {
|
|
225
|
+
readonly type: 'fetch';
|
|
226
|
+
readonly request_id: bigint;
|
|
227
|
+
readonly track_namespace: string[];
|
|
228
|
+
readonly track_name: string;
|
|
229
|
+
readonly parameters: Draft20Params;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* FETCH_OK (0x18) — bytes identical to draft-19, meaning changed.
|
|
233
|
+
*
|
|
234
|
+
* `end_group` / `end_object` are the INCLUSIVE end of the range the response
|
|
235
|
+
* covers: the last Object actually covered. draft-19's "the last Object, plus
|
|
236
|
+
* 1; or 0 to indicate the entire Group" is gone (draft-20 Section 10.14 with
|
|
237
|
+
* Section 5.1.2). The same bytes mean a different object under the two drafts,
|
|
238
|
+
* and nothing on the wire distinguishes them.
|
|
239
|
+
*/
|
|
240
|
+
interface Draft20FetchOk extends Draft20BaseMessage {
|
|
241
|
+
readonly type: 'fetch_ok';
|
|
242
|
+
readonly end_of_track: number;
|
|
243
|
+
readonly end_group: bigint;
|
|
244
|
+
readonly end_object: bigint;
|
|
245
|
+
readonly parameters: Draft20Params;
|
|
246
|
+
readonly track_properties: Draft20TrackProperties;
|
|
247
|
+
}
|
|
248
|
+
interface Draft20TrackStatus extends Draft20BaseMessage {
|
|
249
|
+
readonly type: 'track_status';
|
|
250
|
+
readonly request_id: bigint;
|
|
251
|
+
readonly track_namespace: string[];
|
|
252
|
+
readonly track_name: string;
|
|
253
|
+
readonly parameters: Draft20Params;
|
|
254
|
+
}
|
|
255
|
+
interface Draft20RequestOk extends Draft20BaseMessage {
|
|
256
|
+
readonly type: 'request_ok';
|
|
257
|
+
readonly parameters: Draft20Params;
|
|
258
|
+
readonly track_properties: Draft20TrackProperties;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Redirect structure, used inside REQUEST_ERROR when error_code = REDIRECT (0x34).
|
|
262
|
+
*
|
|
263
|
+
* draft-20 Section 10.6.1 names the namespace/name pair "the Redirect target"
|
|
264
|
+
* and dropped draft-19's rule that a zero-length pair meant "reuse the values
|
|
265
|
+
* from the original request". An empty namespace and name are now a literal
|
|
266
|
+
* empty namespace and name.
|
|
267
|
+
*/
|
|
268
|
+
interface Redirect {
|
|
269
|
+
readonly connect_uri: string;
|
|
270
|
+
readonly track_namespace: string[];
|
|
271
|
+
readonly track_name: string;
|
|
272
|
+
}
|
|
273
|
+
interface Draft20RequestError extends Draft20BaseMessage {
|
|
274
|
+
readonly type: 'request_error';
|
|
275
|
+
readonly error_code: bigint;
|
|
276
|
+
readonly retry_interval: bigint;
|
|
277
|
+
readonly reason_phrase: string;
|
|
278
|
+
readonly redirect?: Redirect;
|
|
279
|
+
}
|
|
280
|
+
interface Draft20GoAway extends Draft20BaseMessage {
|
|
281
|
+
readonly type: 'goaway';
|
|
282
|
+
readonly new_session_uri: string;
|
|
283
|
+
readonly timeout: bigint;
|
|
284
|
+
}
|
|
285
|
+
type Draft20Message = Draft20Setup | Draft20Subscribe | Draft20SubscribeOk | Draft20RequestUpdate | Draft20PublishStateNotify | Draft20Publish | Draft20PublishDone | Draft20PublishNamespace | Draft20Namespace | Draft20NamespaceDone | Draft20SubscribeNamespace | Draft20SubscribeTracks | Draft20PublishSkipped | Draft20Fetch | Draft20FetchOk | Draft20TrackStatus | Draft20RequestOk | Draft20RequestError | Draft20GoAway;
|
|
286
|
+
interface ObjectPayload {
|
|
287
|
+
readonly type: 'object';
|
|
288
|
+
readonly byteOffset: number;
|
|
289
|
+
readonly payloadByteOffset: number;
|
|
290
|
+
readonly objectId: bigint;
|
|
291
|
+
/** The Object ID Delta as it appeared on the wire, before delta resolution. */
|
|
292
|
+
readonly objectIdDelta?: bigint;
|
|
293
|
+
readonly payloadLength: number;
|
|
294
|
+
readonly status?: bigint;
|
|
295
|
+
readonly extensionData: Uint8Array;
|
|
296
|
+
readonly objectProperties?: Record<string, bigint>;
|
|
297
|
+
readonly payload: Uint8Array;
|
|
298
|
+
}
|
|
299
|
+
interface SubgroupStream {
|
|
300
|
+
readonly type: 'subgroup';
|
|
301
|
+
/** SUBGROUP_HEADER `Type Flags` (draft-20 Section 11.4.2). */
|
|
302
|
+
readonly headerType: number;
|
|
303
|
+
readonly trackAlias: bigint;
|
|
304
|
+
readonly groupId: bigint;
|
|
305
|
+
readonly subgroupId: bigint;
|
|
306
|
+
readonly publisherPriority: number;
|
|
307
|
+
readonly endOfGroup?: boolean;
|
|
308
|
+
readonly firstObject?: boolean;
|
|
309
|
+
readonly objects: ObjectPayload[];
|
|
310
|
+
}
|
|
311
|
+
interface DatagramObject {
|
|
312
|
+
readonly type: 'datagram';
|
|
313
|
+
/** OBJECT_DATAGRAM `Type Flags` (draft-20 Section 11.3.1). */
|
|
314
|
+
readonly datagramType: number;
|
|
315
|
+
readonly trackAlias: bigint;
|
|
316
|
+
readonly groupId: bigint;
|
|
317
|
+
readonly objectId: bigint;
|
|
318
|
+
readonly publisherPriority: number;
|
|
319
|
+
readonly endOfGroup?: boolean;
|
|
320
|
+
readonly objectStatus?: bigint;
|
|
321
|
+
readonly objectProperties?: Record<string, bigint>;
|
|
322
|
+
readonly payloadLength: number;
|
|
323
|
+
readonly payload: Uint8Array;
|
|
324
|
+
}
|
|
325
|
+
interface FetchObjectPayload extends ObjectPayload {
|
|
326
|
+
readonly serializationFlags: number;
|
|
327
|
+
readonly groupId: bigint;
|
|
328
|
+
/** The Group ID Delta as it appeared on the wire, before delta resolution. */
|
|
329
|
+
readonly groupIdDelta?: bigint;
|
|
330
|
+
readonly subgroupId: bigint;
|
|
331
|
+
readonly publisherPriority: number;
|
|
332
|
+
readonly objectProperties?: Record<string, bigint>;
|
|
333
|
+
}
|
|
334
|
+
interface FetchStream {
|
|
335
|
+
readonly type: 'fetch';
|
|
336
|
+
/**
|
|
337
|
+
* The Request ID of the message that opened the stream. In draft-20 that is
|
|
338
|
+
* not necessarily a FETCH: a fill fetch stream (Section 5.1.3) carries the
|
|
339
|
+
* Request ID of the SUBSCRIBE or REQUEST_UPDATE that requested the fill.
|
|
340
|
+
*/
|
|
341
|
+
readonly requestId: bigint;
|
|
342
|
+
readonly objects: FetchObjectPayload[];
|
|
343
|
+
}
|
|
344
|
+
type Draft20DataStream = SubgroupStream | DatagramObject | FetchStream;
|
|
345
|
+
interface SubgroupStreamHeader {
|
|
346
|
+
readonly type: 'subgroup_header';
|
|
347
|
+
readonly trackAlias: bigint;
|
|
348
|
+
readonly groupId: bigint;
|
|
349
|
+
readonly subgroupId: bigint;
|
|
350
|
+
readonly publisherPriority: number;
|
|
351
|
+
}
|
|
352
|
+
interface FetchStreamHeader {
|
|
353
|
+
readonly type: 'fetch_header';
|
|
354
|
+
readonly requestId: bigint;
|
|
355
|
+
}
|
|
356
|
+
type DataStreamHeader = SubgroupStreamHeader | FetchStreamHeader;
|
|
357
|
+
type DataStreamEvent = DataStreamHeader | ObjectPayload;
|
|
358
|
+
|
|
359
|
+
export type { Draft20SubscribeNamespace as A, Draft20SubscribeOk as B, Draft20SubscribeTracks as C, Draft20Message as D, Draft20TrackProperties as E, FetchStreamHeader as F, Draft20TrackStatus as G, FetchObjectPayload as H, LocationFilter as I, RangeFilterRange as J, Redirect as K, LargestObject as L, ObjectPayload as O, RangeFilter as R, SubgroupStreamHeader as S, UnknownParam as U, Draft20MessageType as a, DataStreamEvent as b, Draft20DataStream as c, DatagramObject as d, FetchStream as e, SubgroupStream as f, DataStreamHeader as g, Draft20BaseMessage as h, Draft20Fetch as i, Draft20FetchOk as j, Draft20FillParameters as k, Draft20GoAway as l, Draft20Namespace as m, Draft20NamespaceDone as n, Draft20Params as o, Draft20Publish as p, Draft20PublishDone as q, Draft20PublishNamespace as r, Draft20PublishSkipped as s, Draft20PublishStateNotify as t, Draft20RequestError as u, Draft20RequestOk as v, Draft20RequestUpdate as w, Draft20Setup as x, Draft20SetupOptions as y, Draft20Subscribe as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Draft = '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17' | '18' | '19';
|
|
1
|
+
type Draft = '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17' | '18' | '19' | '20';
|
|
2
2
|
interface BaseCodec<M> {
|
|
3
3
|
readonly draft: Draft;
|
|
4
4
|
encodeMessage(message: M): Uint8Array;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Draft = '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17' | '18' | '19';
|
|
1
|
+
type Draft = '07' | '08' | '09' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '17' | '18' | '19' | '20';
|
|
2
2
|
interface BaseCodec<M> {
|
|
3
3
|
readonly draft: Draft;
|
|
4
4
|
encodeMessage(message: M): Uint8Array;
|
|
@@ -149,7 +149,6 @@ interface Draft14PublishNamespace extends Draft14BaseMessage {
|
|
|
149
149
|
interface Draft14PublishNamespaceOk extends Draft14BaseMessage {
|
|
150
150
|
readonly type: 'publish_namespace_ok';
|
|
151
151
|
readonly request_id: bigint;
|
|
152
|
-
readonly parameters: Draft14Params;
|
|
153
152
|
}
|
|
154
153
|
interface Draft14PublishNamespaceError extends Draft14BaseMessage {
|
|
155
154
|
readonly type: 'publish_namespace_error';
|
|
@@ -176,7 +175,6 @@ interface Draft14SubscribeNamespace extends Draft14BaseMessage {
|
|
|
176
175
|
interface Draft14SubscribeNamespaceOk extends Draft14BaseMessage {
|
|
177
176
|
readonly type: 'subscribe_namespace_ok';
|
|
178
177
|
readonly request_id: bigint;
|
|
179
|
-
readonly parameters: Draft14Params;
|
|
180
178
|
}
|
|
181
179
|
interface Draft14SubscribeNamespaceError extends Draft14BaseMessage {
|
|
182
180
|
readonly type: 'subscribe_namespace_error';
|
|
@@ -149,7 +149,6 @@ interface Draft14PublishNamespace extends Draft14BaseMessage {
|
|
|
149
149
|
interface Draft14PublishNamespaceOk extends Draft14BaseMessage {
|
|
150
150
|
readonly type: 'publish_namespace_ok';
|
|
151
151
|
readonly request_id: bigint;
|
|
152
|
-
readonly parameters: Draft14Params;
|
|
153
152
|
}
|
|
154
153
|
interface Draft14PublishNamespaceError extends Draft14BaseMessage {
|
|
155
154
|
readonly type: 'publish_namespace_error';
|
|
@@ -176,7 +175,6 @@ interface Draft14SubscribeNamespace extends Draft14BaseMessage {
|
|
|
176
175
|
interface Draft14SubscribeNamespaceOk extends Draft14BaseMessage {
|
|
177
176
|
readonly type: 'subscribe_namespace_ok';
|
|
178
177
|
readonly request_id: bigint;
|
|
179
|
-
readonly parameters: Draft14Params;
|
|
180
178
|
}
|
|
181
179
|
interface Draft14SubscribeNamespaceError extends Draft14BaseMessage {
|
|
182
180
|
readonly type: 'subscribe_namespace_error';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moqtap/codec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "MoQT wire-format codec and session state machine — multi-draft, zero dependencies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -196,19 +196,32 @@
|
|
|
196
196
|
"types": "./dist/draft19-session.d.ts",
|
|
197
197
|
"import": "./dist/draft19-session.js",
|
|
198
198
|
"require": "./dist/draft19-session.cjs"
|
|
199
|
+
},
|
|
200
|
+
"./draft20": {
|
|
201
|
+
"bun": "./src/drafts/draft20/index.ts",
|
|
202
|
+
"types": "./dist/draft20.d.ts",
|
|
203
|
+
"import": "./dist/draft20.js",
|
|
204
|
+
"require": "./dist/draft20.cjs"
|
|
205
|
+
},
|
|
206
|
+
"./draft20/session": {
|
|
207
|
+
"bun": "./src/drafts/draft20/session.ts",
|
|
208
|
+
"types": "./dist/draft20-session.d.ts",
|
|
209
|
+
"import": "./dist/draft20-session.js",
|
|
210
|
+
"require": "./dist/draft20-session.cjs"
|
|
199
211
|
}
|
|
200
212
|
},
|
|
201
213
|
"files": [
|
|
202
214
|
"dist",
|
|
203
215
|
"src",
|
|
204
|
-
"!src/__tests__"
|
|
216
|
+
"!src/__tests__",
|
|
217
|
+
"CHANGELOG.md"
|
|
205
218
|
],
|
|
206
219
|
"scripts": {
|
|
207
220
|
"build": "tsup",
|
|
208
221
|
"test": "vitest run"
|
|
209
222
|
},
|
|
210
223
|
"devDependencies": {
|
|
211
|
-
"@moqtap/test-vectors": "^0.
|
|
224
|
+
"@moqtap/test-vectors": "^0.13.0",
|
|
212
225
|
"tsup": "^8.0.0",
|
|
213
226
|
"typescript": "^5.5.0",
|
|
214
227
|
"vitest": "^3.0.0"
|
|
@@ -81,6 +81,13 @@ export type ProtocolViolationCode =
|
|
|
81
81
|
export type SideEffect =
|
|
82
82
|
| { type: 'subscription-activated'; subscribeId: bigint }
|
|
83
83
|
| { type: 'subscription-ended'; subscribeId: bigint; reason: string }
|
|
84
|
+
// draft-20 fill fetch streams (Section 5.1.3). A subscription can have
|
|
85
|
+
// several open at once, each keyed by the Request ID of the SUBSCRIBE or
|
|
86
|
+
// REQUEST_UPDATE that opened it; opening one does not close another.
|
|
87
|
+
| { type: 'fill-fetch-stream-opened'; subscribeId: bigint; requestId: bigint }
|
|
88
|
+
| { type: 'fill-fetch-stream-closed'; subscribeId: bigint; requestId: bigint; reason: string }
|
|
89
|
+
// draft-20 PUBLISH_STATE_NOTIFY (Section 10.10) — unilateral, no response.
|
|
90
|
+
| { type: 'subscription-state-notified'; subscribeId: bigint }
|
|
84
91
|
| { type: 'announce-activated'; namespace: string[] }
|
|
85
92
|
| { type: 'announce-ended'; namespace: string[] }
|
|
86
93
|
| { type: 'publish-activated'; requestId: bigint }
|
package/src/core/types.ts
CHANGED
|
@@ -56,7 +56,7 @@ export function encodeDatagram(dg: DatagramObject): Uint8Array {
|
|
|
56
56
|
w.writeVarInt(extData.byteLength)
|
|
57
57
|
if (extData.byteLength > 0) w.writeBytes(extData)
|
|
58
58
|
}
|
|
59
|
-
const isStatus = dg.streamTypeId
|
|
59
|
+
const isStatus = dg.streamTypeId >= 0x04
|
|
60
60
|
if (isStatus) {
|
|
61
61
|
w.writeVarInt(dg.objectStatus ?? 0n)
|
|
62
62
|
} else {
|
|
@@ -182,18 +182,26 @@ export function decodeDatagram(bytes: Uint8Array): DecodeResult<DatagramObject>
|
|
|
182
182
|
try {
|
|
183
183
|
const r = new BufferReader(bytes)
|
|
184
184
|
const streamTypeId = Number(r.readVarInt())
|
|
185
|
-
if (streamTypeId < 0x00 || streamTypeId >
|
|
185
|
+
if (streamTypeId < 0x00 || streamTypeId > 0x05) {
|
|
186
186
|
return {
|
|
187
187
|
ok: false,
|
|
188
188
|
error: new DecodeError(
|
|
189
189
|
'CONSTRAINT_VIOLATION',
|
|
190
|
-
`Expected datagram type 0x00-
|
|
190
|
+
`Expected datagram type 0x00-0x05, got 0x${streamTypeId.toString(16)}`,
|
|
191
191
|
0,
|
|
192
192
|
),
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
const extensionsPresent = (streamTypeId & 0x01) !== 0
|
|
196
|
-
|
|
196
|
+
// Draft-12 states its datagram types twice and the two disagree. Table 12
|
|
197
|
+
// gives OBJECT_DATAGRAM four values and puts the End of Group marker on
|
|
198
|
+
// 0x02/0x03; the OBJECT_DATAGRAM_STATUS paragraph still says "0x02 to
|
|
199
|
+
// 0x03", which is the sentence draft-11 wrote before an End of Group
|
|
200
|
+
// marker existed. Both cannot hold, and the table is the half that
|
|
201
|
+
// changed. Draft-13 repeats the contradiction verbatim and draft-14
|
|
202
|
+
// resolves it the same way: payload below 0x04, status at and above it.
|
|
203
|
+
const endOfGroup = (streamTypeId & 0x02) !== 0 && streamTypeId < 0x04
|
|
204
|
+
const isStatus = streamTypeId >= 0x04
|
|
197
205
|
const trackAlias = r.readVarInt()
|
|
198
206
|
const groupId = r.readVarInt()
|
|
199
207
|
const objectId = r.readVarInt()
|
|
@@ -225,6 +233,7 @@ export function decodeDatagram(bytes: Uint8Array): DecodeResult<DatagramObject>
|
|
|
225
233
|
payloadLength: payload.byteLength,
|
|
226
234
|
payload,
|
|
227
235
|
}
|
|
236
|
+
if (endOfGroup) (result as unknown as Record<string, unknown>).endOfGroup = true
|
|
228
237
|
if (extensionHeadersLength !== undefined)
|
|
229
238
|
(result as unknown as Record<string, unknown>).extensionHeadersLength = extensionHeadersLength
|
|
230
239
|
if (extensionData !== undefined)
|
|
@@ -462,7 +462,6 @@ function encodePublishNamespaceOkPayload(
|
|
|
462
462
|
w: BufferWriter,
|
|
463
463
|
): void {
|
|
464
464
|
w.writeVarInt(msg.request_id)
|
|
465
|
-
encodeMessageParams(msg.parameters, w)
|
|
466
465
|
}
|
|
467
466
|
|
|
468
467
|
function encodePublishNamespaceErrorPayload(
|
|
@@ -504,7 +503,6 @@ function encodeSubscribeNamespaceOkPayload(
|
|
|
504
503
|
w: BufferWriter,
|
|
505
504
|
): void {
|
|
506
505
|
w.writeVarInt(msg.request_id)
|
|
507
|
-
encodeMessageParams(msg.parameters, w)
|
|
508
506
|
}
|
|
509
507
|
|
|
510
508
|
function encodeSubscribeNamespaceErrorPayload(
|
|
@@ -861,8 +859,7 @@ function decodePublishNamespacePayload(r: BufferReader): Draft14Message {
|
|
|
861
859
|
|
|
862
860
|
function decodePublishNamespaceOkPayload(r: BufferReader): Draft14Message {
|
|
863
861
|
const request_id = r.readVarInt()
|
|
864
|
-
|
|
865
|
-
return { type: 'publish_namespace_ok', request_id, parameters }
|
|
862
|
+
return { type: 'publish_namespace_ok', request_id }
|
|
866
863
|
}
|
|
867
864
|
|
|
868
865
|
function decodePublishNamespaceErrorPayload(r: BufferReader): Draft14Message {
|
|
@@ -908,8 +905,7 @@ function decodeSubscribeNamespacePayload(r: BufferReader): Draft14Message {
|
|
|
908
905
|
|
|
909
906
|
function decodeSubscribeNamespaceOkPayload(r: BufferReader): Draft14Message {
|
|
910
907
|
const request_id = r.readVarInt()
|
|
911
|
-
|
|
912
|
-
return { type: 'subscribe_namespace_ok', request_id, parameters }
|
|
908
|
+
return { type: 'subscribe_namespace_ok', request_id }
|
|
913
909
|
}
|
|
914
910
|
|
|
915
911
|
function decodeSubscribeNamespaceErrorPayload(r: BufferReader): Draft14Message {
|
|
@@ -213,7 +213,6 @@ export interface Draft14PublishNamespace extends Draft14BaseMessage {
|
|
|
213
213
|
export interface Draft14PublishNamespaceOk extends Draft14BaseMessage {
|
|
214
214
|
readonly type: 'publish_namespace_ok'
|
|
215
215
|
readonly request_id: bigint
|
|
216
|
-
readonly parameters: Draft14Params
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
export interface Draft14PublishNamespaceError extends Draft14BaseMessage {
|
|
@@ -245,7 +244,6 @@ export interface Draft14SubscribeNamespace extends Draft14BaseMessage {
|
|
|
245
244
|
export interface Draft14SubscribeNamespaceOk extends Draft14BaseMessage {
|
|
246
245
|
readonly type: 'subscribe_namespace_ok'
|
|
247
246
|
readonly request_id: bigint
|
|
248
|
-
readonly parameters: Draft14Params
|
|
249
247
|
}
|
|
250
248
|
|
|
251
249
|
export interface Draft14SubscribeNamespaceError extends Draft14BaseMessage {
|