@caprid/relay 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +160 -1
  3. package/dist/connect-session.d.ts +125 -0
  4. package/dist/connect-session.d.ts.map +1 -0
  5. package/dist/connect-session.js +300 -0
  6. package/dist/connect-session.js.map +1 -0
  7. package/dist/connect.d.ts +143 -0
  8. package/dist/connect.d.ts.map +1 -0
  9. package/dist/connect.js +129 -0
  10. package/dist/connect.js.map +1 -0
  11. package/dist/delivery-timeouts.d.ts +37 -0
  12. package/dist/delivery-timeouts.d.ts.map +1 -0
  13. package/dist/delivery-timeouts.js +48 -0
  14. package/dist/delivery-timeouts.js.map +1 -0
  15. package/dist/document-service.d.ts +58 -0
  16. package/dist/document-service.d.ts.map +1 -0
  17. package/dist/document-service.js +166 -0
  18. package/dist/document-service.js.map +1 -0
  19. package/dist/errors.d.ts +71 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +99 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/frame-reader.d.ts +81 -0
  24. package/dist/frame-reader.d.ts.map +1 -0
  25. package/dist/frame-reader.js +110 -0
  26. package/dist/frame-reader.js.map +1 -0
  27. package/dist/frame-writer.d.ts +109 -0
  28. package/dist/frame-writer.d.ts.map +1 -0
  29. package/dist/frame-writer.js +409 -0
  30. package/dist/frame-writer.js.map +1 -0
  31. package/dist/index.d.ts +19 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +9 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/media-track-properties.d.ts +59 -0
  36. package/dist/media-track-properties.d.ts.map +1 -0
  37. package/dist/media-track-properties.js +120 -0
  38. package/dist/media-track-properties.js.map +1 -0
  39. package/dist/media.d.ts +28 -0
  40. package/dist/media.d.ts.map +1 -0
  41. package/dist/media.js +28 -0
  42. package/dist/media.js.map +1 -0
  43. package/dist/namespace-events.d.ts +44 -0
  44. package/dist/namespace-events.d.ts.map +1 -0
  45. package/dist/namespace-events.js +107 -0
  46. package/dist/namespace-events.js.map +1 -0
  47. package/dist/node.d.ts +75 -0
  48. package/dist/node.d.ts.map +1 -0
  49. package/dist/node.js +114 -0
  50. package/dist/node.js.map +1 -0
  51. package/dist/payload.d.ts +8 -0
  52. package/dist/payload.d.ts.map +1 -0
  53. package/dist/payload.js +23 -0
  54. package/dist/payload.js.map +1 -0
  55. package/dist/publish.d.ts +209 -0
  56. package/dist/publish.d.ts.map +1 -0
  57. package/dist/publish.js +123 -0
  58. package/dist/publish.js.map +1 -0
  59. package/dist/room-endpoint.d.ts +21 -0
  60. package/dist/room-endpoint.d.ts.map +1 -0
  61. package/dist/room-endpoint.js +47 -0
  62. package/dist/room-endpoint.js.map +1 -0
  63. package/dist/send-order.d.ts +14 -0
  64. package/dist/send-order.d.ts.map +1 -0
  65. package/dist/send-order.js +11 -0
  66. package/dist/send-order.js.map +1 -0
  67. package/dist/settling-groups.d.ts +35 -0
  68. package/dist/settling-groups.d.ts.map +1 -0
  69. package/dist/settling-groups.js +73 -0
  70. package/dist/settling-groups.js.map +1 -0
  71. package/dist/subscription-events.d.ts +51 -0
  72. package/dist/subscription-events.d.ts.map +1 -0
  73. package/dist/subscription-events.js +125 -0
  74. package/dist/subscription-events.js.map +1 -0
  75. package/dist/subscription.d.ts +207 -0
  76. package/dist/subscription.d.ts.map +1 -0
  77. package/dist/subscription.js +283 -0
  78. package/dist/subscription.js.map +1 -0
  79. package/dist/supervised-publisher.d.ts +92 -0
  80. package/dist/supervised-publisher.d.ts.map +1 -0
  81. package/dist/supervised-publisher.js +839 -0
  82. package/dist/supervised-publisher.js.map +1 -0
  83. package/dist/supervised-subscriber.d.ts +201 -0
  84. package/dist/supervised-subscriber.d.ts.map +1 -0
  85. package/dist/supervised-subscriber.js +1420 -0
  86. package/dist/supervised-subscriber.js.map +1 -0
  87. package/dist/supervision.d.ts +78 -0
  88. package/dist/supervision.d.ts.map +1 -0
  89. package/dist/supervision.js +149 -0
  90. package/dist/supervision.js.map +1 -0
  91. package/dist/switchable.d.ts +164 -0
  92. package/dist/switchable.d.ts.map +1 -0
  93. package/dist/switchable.js +327 -0
  94. package/dist/switchable.js.map +1 -0
  95. package/dist/validation.d.ts +64 -0
  96. package/dist/validation.d.ts.map +1 -0
  97. package/dist/validation.js +137 -0
  98. package/dist/validation.js.map +1 -0
  99. package/dist/write-slot.d.ts +87 -0
  100. package/dist/write-slot.d.ts.map +1 -0
  101. package/dist/write-slot.js +519 -0
  102. package/dist/write-slot.js.map +1 -0
  103. package/package.json +82 -4
@@ -0,0 +1,327 @@
1
+ import { MAX_TIMEOUT_MS } from './connect-session.js';
2
+ import { RelayError } from './errors.js';
3
+ import { endError, synchronousCallback, } from './subscription.js';
4
+ import { trackName } from './validation.js';
5
+ const HANDLER_NAMES = [
6
+ 'onSubscribed',
7
+ 'onError',
8
+ 'onObject',
9
+ 'onSubgroupEnd',
10
+ 'onSubgroupReset',
11
+ 'onPublisherDone',
12
+ 'onStateNotify',
13
+ 'onGoaway',
14
+ 'onSwitched',
15
+ ];
16
+ /** The handler each product event reaches; `updateOk` has none, since a switchable has no `update()`. */
17
+ const EVENT_HANDLERS = {
18
+ subscribed: 'onSubscribed',
19
+ object: 'onObject',
20
+ publisherDone: 'onPublisherDone',
21
+ subgroupEnd: 'onSubgroupEnd',
22
+ subgroupReset: 'onSubgroupReset',
23
+ stateNotify: 'onStateNotify',
24
+ goaway: 'onGoaway',
25
+ updateOk: undefined,
26
+ };
27
+ /** How many of a pending subscription's events are held for its cutover; the oldest are dropped first. */
28
+ export const HELD_EVENTS = 256;
29
+ /** Hold one more of a pending subscription's events, dropping the oldest beyond {@link HELD_EVENTS}. */
30
+ export function holdEvent(held, event) {
31
+ held.push(event);
32
+ if (held.length > HELD_EVENTS)
33
+ held.shift();
34
+ }
35
+ /**
36
+ * The held events that come after the cutover object in its own subscription, in arrival order: those of later
37
+ * groups, and later objects, subgroup ends and resets of its group (the ends and resets complete objects that follow
38
+ * it, and never arrive again). Groups arrive out of order across streams, so a later group can reach a
39
+ * pending subscription before the object that cuts over; discarding it would leave a gap, while the earlier groups
40
+ * are the old subscription's to deliver. Group IDs are compared only within the one subscription.
41
+ */
42
+ export function heldAfter(held, cutover) {
43
+ return held.filter((event) => event.value.groupId > cutover.groupId ||
44
+ (event.value.groupId === cutover.groupId && (event.type !== 'object' || event.value.objectId > cutover.objectId)));
45
+ }
46
+ /** Check `until` and return the predicate it stands for; shared with the supervised want (spec/behavior.md). */
47
+ export function untilPredicate(until) {
48
+ if (until === undefined || until === 'first-object')
49
+ return () => true;
50
+ if (typeof until !== 'function')
51
+ throw new TypeError("until must be 'first-object' or a function");
52
+ if (Object.prototype.toString.call(until) === '[object AsyncFunction]')
53
+ throw new TypeError('until must be synchronous');
54
+ return (object) => {
55
+ const passed = until(object);
56
+ if (typeof passed !== 'boolean') {
57
+ // A promise is never awaited; observe its rejection so refusing it cannot surface as unhandled.
58
+ if (passed &&
59
+ (typeof passed === 'object' || typeof passed === 'function') &&
60
+ 'then' in passed &&
61
+ typeof passed.then === 'function')
62
+ void Promise.resolve(passed).catch(() => { });
63
+ throw new TypeError('until must return a boolean');
64
+ }
65
+ return passed;
66
+ };
67
+ }
68
+ /** Check a drain duration in milliseconds; shared with the supervised want. */
69
+ export function assertDrainMs(drainMs) {
70
+ if (typeof drainMs !== 'number')
71
+ throw new TypeError('drainMs must be a number of milliseconds');
72
+ // A timer holds at most MAX_TIMEOUT_MS; a larger delay would fire at once and end the drain early.
73
+ if (!Number.isFinite(drainMs) || drainMs < 0 || drainMs > MAX_TIMEOUT_MS)
74
+ throw new RangeError(`drainMs must be between 0 and ${MAX_TIMEOUT_MS} milliseconds`);
75
+ }
76
+ /** Check and snapshot the handlers, before connection state is read. */
77
+ export function snapshotSwitchableHandlers(handlers = {}) {
78
+ if (typeof handlers !== 'object' || handlers === null)
79
+ throw new TypeError('handlers must be an object');
80
+ const snapshot = new Map();
81
+ for (const name of HANDLER_NAMES) {
82
+ const callback = handlers[name];
83
+ if (callback === undefined)
84
+ continue;
85
+ if (typeof callback !== 'function')
86
+ throw new TypeError(`${name} must be a function`);
87
+ snapshot.set(name, synchronousCallback(name, callback, handlers));
88
+ }
89
+ return snapshot;
90
+ }
91
+ export function createSwitchable(deps, initialTrack, parameters, snapshot) {
92
+ const call = (name, ...args) => snapshot.get(name)?.(...args);
93
+ let active;
94
+ /** The largest group ID among the objects the active subscription delivered. */
95
+ let activeLargestGroup;
96
+ let pending;
97
+ /** Old subscriptions draining after a cutover, each with the timer that cancels it. */
98
+ const draining = new Map();
99
+ let end;
100
+ let hasSubscribed = false;
101
+ let resolveSubscribed;
102
+ let rejectSubscribed;
103
+ let resolveEnded;
104
+ const subscribed = new Promise((resolve, reject) => {
105
+ resolveSubscribed = resolve;
106
+ rejectSubscribed = reject;
107
+ });
108
+ void subscribed.catch(() => { });
109
+ const ended = new Promise((resolve) => {
110
+ resolveEnded = resolve;
111
+ });
112
+ const markSubscribed = (info) => {
113
+ if (hasSubscribed)
114
+ return;
115
+ hasSubscribed = true;
116
+ resolveSubscribed(info);
117
+ };
118
+ const stopDrain = (slot) => {
119
+ clearTimeout(draining.get(slot));
120
+ draining.delete(slot);
121
+ slot.subscription.cancel();
122
+ };
123
+ /** Settle a pending switch that did not cut over, cancelling its subscription if it still runs. */
124
+ const abandon = (switching, error) => {
125
+ if (pending === switching)
126
+ pending = undefined;
127
+ switching.removeAbort();
128
+ switching.reject(error);
129
+ switching.subscription.cancel(error);
130
+ };
131
+ const finish = (next) => {
132
+ if (end)
133
+ return;
134
+ end = next;
135
+ if (!hasSubscribed)
136
+ rejectSubscribed(endError(next));
137
+ // A closed connection ends both subscriptions; report it the same way on the pending switch.
138
+ if (pending)
139
+ abandon(pending, next.cause === 'connection-closed'
140
+ ? endError(next)
141
+ : new RelayError('CLOSED', 'The switchable subscription ended before the switch', 'subscription'));
142
+ for (const slot of [...draining.keys()])
143
+ stopDrain(slot);
144
+ resolveEnded(next);
145
+ if (next.cause === 'request-error')
146
+ call('onError', next.error, active.track);
147
+ };
148
+ const cutover = (switching, object) => {
149
+ const from = active;
150
+ pending = undefined;
151
+ switching.removeAbort();
152
+ active = switching;
153
+ // The old subscription's consumer checks `active` first, so its events from here on reach the
154
+ // handlers only while it drains, and its ending reaches nobody.
155
+ if (switching.drainMs > 0 && activeLargestGroup !== undefined) {
156
+ from.drainThrough = activeLargestGroup;
157
+ draining.set(from, setTimeout(() => stopDrain(from), switching.drainMs));
158
+ }
159
+ else
160
+ from.subscription.cancel();
161
+ activeLargestGroup = object.groupId;
162
+ // A subscription that delivered an object was accepted.
163
+ const info = switching.accepted;
164
+ markSubscribed(info);
165
+ const switched = { from: from.track, to: switching.track, subscribed: info };
166
+ switching.resolve(switched);
167
+ // Later groups that reached the new subscription early, out of order, follow the object that cut over. Each
168
+ // delivery is isolated, so one throwing handler loses neither the rest nor the held events.
169
+ const replay = heldAfter(switching.held, object);
170
+ switching.held = [];
171
+ const deliver = (name, ...args) => {
172
+ try {
173
+ call(name, ...args);
174
+ }
175
+ catch (error) {
176
+ // biome-ignore lint/suspicious/noConsole: the application's handler failed and has no caller to report to
177
+ console.error(new Error(`${name} threw at a cutover; the switchable delivers regardless`, { cause: error }));
178
+ }
179
+ };
180
+ deliver('onSwitched', switched);
181
+ // A handler may have switched again or cancelled; the object still belongs to this cutover.
182
+ if (!end && active === switching)
183
+ deliver('onObject', object, switching.track);
184
+ for (const event of replay) {
185
+ if (end || active !== switching)
186
+ break;
187
+ if (event.type === 'object' && event.value.groupId > activeLargestGroup)
188
+ activeLargestGroup = event.value.groupId;
189
+ deliver(EVENT_HANDLERS[event.type], event.value, switching.track);
190
+ }
191
+ };
192
+ /** The consumer for one slot: active events go to the handlers, pending ones to the cutover check. */
193
+ const consumerFor = (slot) => ({
194
+ event(event) {
195
+ const self = slot();
196
+ // Nothing is delivered while the subscription is being opened, but stay safe if it were.
197
+ if (end || !self)
198
+ return;
199
+ if (event.type === 'subscribed')
200
+ self.accepted = event.value;
201
+ if (self === active) {
202
+ if (event.type === 'subscribed') {
203
+ if (hasSubscribed)
204
+ return;
205
+ markSubscribed(event.value);
206
+ }
207
+ if (event.type === 'object' && (activeLargestGroup === undefined || event.value.groupId > activeLargestGroup))
208
+ activeLargestGroup = event.value.groupId;
209
+ const name = EVENT_HANDLERS[event.type];
210
+ if (name)
211
+ call(name, event.value, self.track);
212
+ return;
213
+ }
214
+ if (draining.has(self)) {
215
+ if ((event.type === 'object' || event.type === 'subgroupEnd' || event.type === 'subgroupReset') &&
216
+ event.value.groupId <= self.drainThrough)
217
+ call(EVENT_HANDLERS[event.type], event.value, self.track);
218
+ return;
219
+ }
220
+ if (self !== pending)
221
+ return;
222
+ const switching = pending;
223
+ if (event.type === 'subgroupEnd' || event.type === 'subgroupReset')
224
+ holdEvent(switching.held, event);
225
+ if (event.type !== 'object')
226
+ return;
227
+ let passed;
228
+ try {
229
+ passed = switching.until(event.value);
230
+ }
231
+ catch (error) {
232
+ if (!end && pending === switching)
233
+ abandon(switching, error);
234
+ return;
235
+ }
236
+ // The predicate is application code: it may have switched again or cancelled.
237
+ if (!passed)
238
+ holdEvent(switching.held, event);
239
+ else if (!end && pending === switching)
240
+ cutover(switching, event.value);
241
+ },
242
+ ended(subscriptionEnd) {
243
+ const self = slot();
244
+ // An ending recorded while the subscription was being opened is read back by the opener.
245
+ if (!self)
246
+ return;
247
+ if (self === active)
248
+ finish(subscriptionEnd);
249
+ else if (draining.has(self))
250
+ stopDrain(self);
251
+ else if (self === pending)
252
+ abandon(pending, endError(subscriptionEnd));
253
+ },
254
+ });
255
+ const open = (track, params, slot) => deps.subscribe(track, params, consumerFor(slot));
256
+ {
257
+ let initial;
258
+ const subscription = open(initialTrack, parameters, () => initial);
259
+ initial = { track: initialTrack, subscription };
260
+ active = initial;
261
+ // An ending recorded while the subscription was being opened found no slot yet.
262
+ if (subscription.end)
263
+ finish(subscription.end);
264
+ }
265
+ return {
266
+ get track() {
267
+ return active.track;
268
+ },
269
+ get pending() {
270
+ return pending?.track;
271
+ },
272
+ subscribed,
273
+ ended,
274
+ switchTo(track, options = {}) {
275
+ if (typeof options !== 'object' || options === null)
276
+ throw new TypeError('switchTo options must be an object');
277
+ const { parameters: params, until, signal, drainMs = 0 } = options;
278
+ // Arguments before the switchable's or the connection's state (spec/behavior.md, Arguments).
279
+ trackName(track);
280
+ const predicate = untilPredicate(until);
281
+ assertDrainMs(drainMs);
282
+ if (signal !== undefined && !(signal instanceof AbortSignal))
283
+ throw new TypeError('signal must be an AbortSignal');
284
+ if (end) {
285
+ throw new RelayError('CLOSED', 'The switchable subscription has ended; subscribe again', 'subscription');
286
+ }
287
+ signal?.throwIfAborted();
288
+ let resolve;
289
+ let reject;
290
+ const promise = new Promise((res, rej) => {
291
+ resolve = res;
292
+ reject = rej;
293
+ });
294
+ void promise.catch(() => { });
295
+ let switching;
296
+ // Open first: an invalid track or a closed connection throws here and leaves any pending switch alone.
297
+ const subscription = open(track, params, () => switching);
298
+ const previous = pending;
299
+ switching = { track, subscription, held: [], until: predicate, drainMs, resolve, reject, removeAbort: () => { } };
300
+ pending = switching;
301
+ if (previous)
302
+ abandon(previous, new RelayError('CLOSED', `Superseded by a switch to ${track}`, 'subscription'));
303
+ if (subscription.end) {
304
+ abandon(switching, endError(subscription.end));
305
+ return promise;
306
+ }
307
+ if (signal) {
308
+ const pendingSwitch = switching;
309
+ const onAbort = () => {
310
+ if (pending === pendingSwitch)
311
+ abandon(pendingSwitch, signal.reason);
312
+ };
313
+ signal.addEventListener('abort', onAbort, { once: true });
314
+ pendingSwitch.removeAbort = () => signal.removeEventListener('abort', onAbort);
315
+ }
316
+ return promise;
317
+ },
318
+ cancel(reason) {
319
+ if (end)
320
+ return;
321
+ if (pending)
322
+ abandon(pending, reason ?? new RelayError('CLOSED', 'The switchable subscription was cancelled', 'subscription'));
323
+ active.subscription.cancel(reason);
324
+ },
325
+ };
326
+ }
327
+ //# sourceMappingURL=switchable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchable.js","sourceRoot":"","sources":["../src/switchable.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,QAAQ,EAKR,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAkI5C,MAAM,aAAa,GAAG;IACpB,cAAc;IACd,SAAS;IACT,UAAU;IACV,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,UAAU;IACV,YAAY;CAC4C,CAAC;AAE3D,yGAAyG;AACzG,MAAM,cAAc,GAAG;IACrB,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,UAAU;IAClB,aAAa,EAAE,iBAAiB;IAChC,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,WAAW,EAAE,eAAe;IAC5B,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,SAAS;CACX,CAAC;AAeX,0GAA0G;AAC1G,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE/B,wGAAwG;AACxG,MAAM,UAAU,SAAS,CAAC,IAAiB,EAAE,KAAgB;IAC3D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjB,IAAI,IAAI,CAAC,MAAM,GAAG,WAAW;QAAE,IAAI,CAAC,KAAK,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAA0B,EAAE,OAAmB;IACvE,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO;QACrC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,CAA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AAI,MAAM,EAAE,CAAC;gBACX,MAAM,aAAa,GAAG,SAAS,CAAC;gBAChC,MAAM,OAAO,GAAG,GAAG,EAAE;oBACnB,IAAI,OAAO,KAAK,aAAa;wBAAE,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACvE,CAAC,CAAC;gBACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1D,aAAa,CAAC,WAAW,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACjF,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,CAAC,MAAM;YACX,IAAI,GAAG;gBAAE,OAAO;YAChB,IAAI,OAAO;gBACT,OAAO,CACL,OAAO,EACP,MAAM,IAAI,IAAI,UAAU,CAAC,QAAQ,EAAE,2CAA2C,EAAE,cAAc,CAAC,CAChG,CAAC;YACJ,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * What the SDK admits from the caller before anything reaches the core: the wire-facing values
3
+ * (namespace, track name, properties, payload), each checked in its original container and copied
4
+ * once. Both roles use the same rules, so the publisher and the subscriber cannot drift apart, and
5
+ * the "Arguments" table in spec/behavior.md is the list these functions implement.
6
+ *
7
+ * Errors keep their idiomatic types: a wrong type or shape is a `TypeError`; a value of the right
8
+ * type outside its bound is a `RangeError`. Nothing here is a `RelayError`: these are programming
9
+ * errors, raised before any connection state is consulted.
10
+ */
11
+ import { type KeyValuePair } from '@caprid/moq-core';
12
+ /**
13
+ * A key-value pair's byte value carries a 16-bit length on the wire (draft-ietf-moq-transport-22
14
+ * §8.3), pinned in spec/protocol.json. The core enforces the same bound while encoding.
15
+ */
16
+ export declare const MAX_PROPERTY_VALUE_LENGTH = 65535;
17
+ /**
18
+ * moq-relay drops an object whose encoded property block is larger than this (`MAX_OBJECT_EXTENSIONS`
19
+ * since 0.17.0, an implementation limit rather than a draft one), so a write refuses it up front.
20
+ * Pinned in spec/protocol.json as `relay.limits.maxObjectPropertiesBytes`.
21
+ */
22
+ export declare const MAX_RELAY_OBJECT_PROPERTIES_LENGTH: number;
23
+ /**
24
+ * moq-relay refuses every subscriber to a track with more track properties than this
25
+ * (`MAX_PROPERTIES` in 0.17.0, REQUEST_ERROR 18 `too many`) and the publisher hears nothing, so
26
+ * registration refuses it. Pinned in spec/protocol.json as `relay.limits.maxTrackProperties`.
27
+ */
28
+ export declare const MAX_RELAY_TRACK_PROPERTIES = 64;
29
+ /**
30
+ * Track property values draft-ietf-moq-transport-22 restricts (sections 10.4 and 10.5), pinned in
31
+ * spec/protocol.json under `trackProperties`. moq-relay refuses every subscriber to a track that
32
+ * breaks them, so registration checks them.
33
+ */
34
+ export declare const DEFAULT_PUBLISHER_PRIORITY = 14;
35
+ export declare const MAX_DEFAULT_PUBLISHER_PRIORITY = 255;
36
+ export declare const DEFAULT_PUBLISHER_GROUP_ORDER = 34;
37
+ export declare const DEFAULT_PUBLISHER_GROUP_ORDERS: readonly number[];
38
+ /**
39
+ * Check a namespace in its original container and return a fresh copy of its fields. The copy is
40
+ * the SDK's own; it is handed to the core (whose namespace type is mutable) and never to the caller.
41
+ */
42
+ export declare function namespaceFields(namespace: unknown): string[];
43
+ /** Check a track name: the string part of a full track name. */
44
+ export declare function trackName(track: unknown): string;
45
+ /** Check a write payload and copy the bytes its view spans, before any slot or stream is taken. */
46
+ export declare function payloadBytes(payload: unknown): Uint8Array;
47
+ /**
48
+ * Check track properties and copy any byte values, so later mutation cannot leak in.
49
+ * Integer types and values are bounded by what the core's varint can carry, which in this
50
+ * language is `Number.MAX_SAFE_INTEGER`, and byte values by their 16-bit wire length. The list
51
+ * rides in every SUBSCRIBE_OK, so its encoding, measured here with the core's own encoder, must fit
52
+ * the room that control message leaves; the relay also caps how many pairs it reads and refuses
53
+ * the values draft-22 rules out. A track that breaks any of these would register and then never
54
+ * answer a subscription, with the publisher's writes timing out, so each is an argument error here
55
+ * instead.
56
+ */
57
+ export declare function trackPropertyPairs(properties?: unknown): KeyValuePair[];
58
+ /**
59
+ * Check one object's properties like {@link trackPropertyPairs}, against the relay's object bound. The
60
+ * relay would drop an object whose block is over its limit, silently for the subscriber, so the
61
+ * write fails here instead. The relay forwards no object property but LOC Timestamp anyway.
62
+ */
63
+ export declare function objectPropertyPairs(properties?: unknown): KeyValuePair[];
64
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,kBAAkB,CAAC;AAG1B;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,QAAY,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAO,CAAC;AAC/C,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,6BAA6B,KAAO,CAAC;AAClD,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAAW,CAAC;AAExE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,CAU5D;AAMD,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGhD;AAED,mGAAmG;AACnG,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAKzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,OAAY,GAAG,YAAY,EAAE,CAyB3E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,OAAY,GAAG,YAAY,EAAE,CAS5E"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * What the SDK admits from the caller before anything reaches the core: the wire-facing values
3
+ * (namespace, track name, properties, payload), each checked in its original container and copied
4
+ * once. Both roles use the same rules, so the publisher and the subscriber cannot drift apart, and
5
+ * the "Arguments" table in spec/behavior.md is the list these functions implement.
6
+ *
7
+ * Errors keep their idiomatic types: a wrong type or shape is a `TypeError`; a value of the right
8
+ * type outside its bound is a `RangeError`. Nothing here is a `RelayError`: these are programming
9
+ * errors, raised before any connection state is consulted.
10
+ */
11
+ import { ByteWriter, encodeKeyValuePairs, MAX_NAMESPACE_FIELDS, MAX_OBJECT_PAYLOAD_LENGTH, MAX_TRACK_PROPERTIES_LENGTH, } from '@caprid/moq-core';
12
+ /**
13
+ * A key-value pair's byte value carries a 16-bit length on the wire (draft-ietf-moq-transport-22
14
+ * §8.3), pinned in spec/protocol.json. The core enforces the same bound while encoding.
15
+ */
16
+ export const MAX_PROPERTY_VALUE_LENGTH = 0xffff;
17
+ /**
18
+ * moq-relay drops an object whose encoded property block is larger than this (`MAX_OBJECT_EXTENSIONS`
19
+ * since 0.17.0, an implementation limit rather than a draft one), so a write refuses it up front.
20
+ * Pinned in spec/protocol.json as `relay.limits.maxObjectPropertiesBytes`.
21
+ */
22
+ export const MAX_RELAY_OBJECT_PROPERTIES_LENGTH = 64 * 1024;
23
+ /**
24
+ * moq-relay refuses every subscriber to a track with more track properties than this
25
+ * (`MAX_PROPERTIES` in 0.17.0, REQUEST_ERROR 18 `too many`) and the publisher hears nothing, so
26
+ * registration refuses it. Pinned in spec/protocol.json as `relay.limits.maxTrackProperties`.
27
+ */
28
+ export const MAX_RELAY_TRACK_PROPERTIES = 64;
29
+ /**
30
+ * Track property values draft-ietf-moq-transport-22 restricts (sections 10.4 and 10.5), pinned in
31
+ * spec/protocol.json under `trackProperties`. moq-relay refuses every subscriber to a track that
32
+ * breaks them, so registration checks them.
33
+ */
34
+ export const DEFAULT_PUBLISHER_PRIORITY = 0x0e;
35
+ export const MAX_DEFAULT_PUBLISHER_PRIORITY = 255;
36
+ export const DEFAULT_PUBLISHER_GROUP_ORDER = 0x22;
37
+ export const DEFAULT_PUBLISHER_GROUP_ORDERS = [1, 2];
38
+ /**
39
+ * Check a namespace in its original container and return a fresh copy of its fields. The copy is
40
+ * the SDK's own; it is handed to the core (whose namespace type is mutable) and never to the caller.
41
+ */
42
+ export function namespaceFields(namespace) {
43
+ // Array.from materializes holes as undefined, so a sparse array fails the field check below.
44
+ const fields = Array.isArray(namespace) ? Array.from(namespace) : undefined;
45
+ if (fields === undefined || fields.length === 0 || !fields.every(isNonEmptyString)) {
46
+ throw new TypeError('A namespace must be a sequence of non-empty string fields');
47
+ }
48
+ if (fields.length > MAX_NAMESPACE_FIELDS) {
49
+ throw new RangeError(`A namespace must contain at most ${MAX_NAMESPACE_FIELDS} fields`);
50
+ }
51
+ return fields;
52
+ }
53
+ function isNonEmptyString(value) {
54
+ return typeof value === 'string' && value.length > 0;
55
+ }
56
+ /** Check a track name: the string part of a full track name. */
57
+ export function trackName(track) {
58
+ if (typeof track !== 'string' || track.length === 0)
59
+ throw new TypeError('A track name must be a non-empty string');
60
+ return track;
61
+ }
62
+ /** Check a write payload and copy the bytes its view spans, before any slot or stream is taken. */
63
+ export function payloadBytes(payload) {
64
+ if (!ArrayBuffer.isView(payload))
65
+ throw new TypeError('Payload must be a Uint8Array or other ArrayBufferView; wrap an ArrayBuffer in one');
66
+ if (payload.byteLength > MAX_OBJECT_PAYLOAD_LENGTH)
67
+ throw new RangeError('Payload exceeds the 16 MiB object limit');
68
+ return new Uint8Array(payload.buffer, payload.byteOffset, payload.byteLength).slice();
69
+ }
70
+ /**
71
+ * Check track properties and copy any byte values, so later mutation cannot leak in.
72
+ * Integer types and values are bounded by what the core's varint can carry, which in this
73
+ * language is `Number.MAX_SAFE_INTEGER`, and byte values by their 16-bit wire length. The list
74
+ * rides in every SUBSCRIBE_OK, so its encoding, measured here with the core's own encoder, must fit
75
+ * the room that control message leaves; the relay also caps how many pairs it reads and refuses
76
+ * the values draft-22 rules out. A track that breaks any of these would register and then never
77
+ * answer a subscription, with the publisher's writes timing out, so each is an argument error here
78
+ * instead.
79
+ */
80
+ export function trackPropertyPairs(properties = []) {
81
+ const { pairs, length } = measuredPairs(properties);
82
+ pairs.forEach(({ type, value }, index) => {
83
+ // Both types are even, so the shape check above already made their values integers.
84
+ if (typeof value !== 'number')
85
+ return;
86
+ if (type === DEFAULT_PUBLISHER_PRIORITY && value > MAX_DEFAULT_PUBLISHER_PRIORITY)
87
+ throw new RangeError(`Property ${index} (Default Publisher Priority, 0x0E) must be at most ${MAX_DEFAULT_PUBLISHER_PRIORITY}`);
88
+ if (type === DEFAULT_PUBLISHER_GROUP_ORDER && !DEFAULT_PUBLISHER_GROUP_ORDERS.includes(value))
89
+ throw new RangeError(`Property ${index} (Default Publisher Group Order, 0x22) must be 1 (ascending) or 2 (descending)`);
90
+ });
91
+ if (pairs.length > MAX_RELAY_TRACK_PROPERTIES)
92
+ throw new RangeError(`Track properties hold ${pairs.length} pairs, over the relay's ${MAX_RELAY_TRACK_PROPERTIES}-pair limit, ` +
93
+ 'so the relay would refuse every subscriber');
94
+ if (length > MAX_TRACK_PROPERTIES_LENGTH)
95
+ throw new RangeError(`Track properties encode to ${length} bytes, over the ${MAX_TRACK_PROPERTIES_LENGTH} bytes SUBSCRIBE_OK ` +
96
+ "has room for, so no subscription could be answered; carry larger data in a track's objects");
97
+ return pairs;
98
+ }
99
+ /**
100
+ * Check one object's properties like {@link trackPropertyPairs}, against the relay's object bound. The
101
+ * relay would drop an object whose block is over its limit, silently for the subscriber, so the
102
+ * write fails here instead. The relay forwards no object property but LOC Timestamp anyway.
103
+ */
104
+ export function objectPropertyPairs(properties = []) {
105
+ const { pairs, length } = measuredPairs(properties);
106
+ if (length > MAX_RELAY_OBJECT_PROPERTIES_LENGTH)
107
+ throw new RangeError(`Object properties encode to ${length} bytes, over the relay's ${MAX_RELAY_OBJECT_PROPERTIES_LENGTH}-byte ` +
108
+ 'limit, so the relay would drop the object; it forwards only LOC Timestamp (0x10), so carry larger ' +
109
+ 'data in the payload');
110
+ return pairs;
111
+ }
112
+ /** Check and copy a property list, returning it with its encoded length. */
113
+ function measuredPairs(properties) {
114
+ if (!Array.isArray(properties))
115
+ throw new TypeError('Properties must be an array of {type, value} pairs');
116
+ const pairs = properties.map((property, index) => {
117
+ const { type, value } = property ?? {};
118
+ if (typeof type !== 'number' || !Number.isSafeInteger(type) || type < 0)
119
+ throw new TypeError(`Property ${index} type must be a non-negative integer`);
120
+ if (type % 2 === 0) {
121
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0)
122
+ throw new TypeError(`Property ${index} value must be a non-negative integer for an even type`);
123
+ return { type, value };
124
+ }
125
+ if (!ArrayBuffer.isView(value))
126
+ throw new TypeError(`Property ${index} value must be an ArrayBufferView for an odd type`);
127
+ if (value.byteLength > MAX_PROPERTY_VALUE_LENGTH)
128
+ throw new RangeError(`Property ${index} value exceeds the ${MAX_PROPERTY_VALUE_LENGTH}-byte limit`);
129
+ return { type, value: new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice() };
130
+ });
131
+ if (pairs.length === 0)
132
+ return { pairs, length: 0 };
133
+ const encoded = new ByteWriter(64);
134
+ encodeKeyValuePairs(encoded, pairs);
135
+ return { pairs, length: encoded.length };
136
+ }
137
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,mBAAmB,EAEnB,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAG1B;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEhD;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,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YAC5B,MAAM,IAAI,SAAS,CAAC,YAAY,KAAK,mDAAmD,CAAC,CAAC;QAC5F,IAAI,KAAK,CAAC,UAAU,GAAG,yBAAyB;YAC9C,MAAM,IAAI,UAAU,CAAC,YAAY,KAAK,sBAAsB,yBAAyB,aAAa,CAAC,CAAC;QACtG,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IACnG,CAAC,CACF,CAAC;IACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACnC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The write slot: a track's single place for a pending operation (see CONTEXT.md).
3
+ *
4
+ * One slot per registered track. It owns the relay's demand binding for the track, the one active
5
+ * operation (a single write or an open group) and its phases, the write deadline, cancellation, and
6
+ * the demand observers behind `hasDemand` and `demandChanges()`. Its public face is the
7
+ * {@link RelayTrackWriter} the application holds; the publisher connection drives it through two
8
+ * inbound calls, `bind()` when the relay's binding changes and `disconnect()` when the connection
9
+ * ends.
10
+ *
11
+ * An operation completes once the transport has taken its group's FIN, not once the relay has
12
+ * acknowledged it: the slot hands the FIN over, frees itself, and passes the group on to the
13
+ * connection as a settling group (see CONTEXT.md). Only the group's own delivery timeout resets a
14
+ * settling group, and nothing reports how it ends.
15
+ *
16
+ * The slot enforces the group's delivery timeouts (draft-ietf-moq-transport-22 §5.2, see
17
+ * delivery-timeouts.ts), fixed per group: the subscriber's side just before the group's stream opens
18
+ * (until then only the publisher's applies), the publisher's side from the first object or the track. The object timeout
19
+ * runs from the application's call until the transport takes the object, so waiting for demand, for
20
+ * settling room and for the stream all count, and it fails the operation with `DELIVERY_TIMEOUT`. The
21
+ * subgroup timeout runs from the FIN's hand-over and resets the settling group with code
22
+ * DELIVERY_TIMEOUT if the relay has not acknowledged it by then; it outlives the subscription and the
23
+ * track, and only the connection's end stops it.
24
+ *
25
+ * Everything the slot borrows enters through {@link WriteSlotDependencies}: how to open a subgroup
26
+ * stream, the connection's settling-group limit, whether the namespace is solicited, whether the
27
+ * connection is still open, how to end the track in the core, and both sides' delivery timeouts.
28
+ * Tests drive a slot with an in-memory subgroup writer and fake timers; the "Write phases and
29
+ * interruptions" table in spec/behavior.md is the list they cover.
30
+ */
31
+ import { type SubgroupWriter } from '@caprid/moq-core';
32
+ import { type DeliveryTimeouts } from './delivery-timeouts.js';
33
+ import type { RelayTrackWriter } from './publish.js';
34
+ import type { SettlingGroups } from './settling-groups.js';
35
+ /**
36
+ * Stream reset codes a publisher sends (draft-ietf-moq-transport-22 §12.5, registry §16.11.4).
37
+ * The core defines the same values but does not export them.
38
+ */
39
+ export declare const RESET_CODE: {
40
+ readonly INTERNAL_ERROR: 0;
41
+ readonly CANCELLED: 1;
42
+ readonly DELIVERY_TIMEOUT: 2;
43
+ readonly SESSION_CLOSED: 3;
44
+ readonly GOING_AWAY: 4;
45
+ };
46
+ export type ResetCode = (typeof RESET_CODE)[keyof typeof RESET_CODE];
47
+ /** What the slot borrows from the publisher connection and the core session. */
48
+ export interface WriteSlotDependencies {
49
+ /** Open a subgroup stream for one group of this track. Rejects when the transport refuses. */
50
+ openSubgroup(trackAlias: number, groupId: number): Promise<SubgroupWriter>;
51
+ /** The connection's settling groups: an operation waits for room before opening its stream. */
52
+ settlingGroups: SettlingGroups;
53
+ /** Whether a current relay solicitation covers the namespace; undefined before any arrived. */
54
+ namespaceSolicited(): boolean | undefined;
55
+ /** Throws the connection's closing error once the connection has ended. */
56
+ assertOpen(): void;
57
+ /** Tell the core the track is done, so it FINs any live subscription stream. */
58
+ endTrack(): void;
59
+ /** Deadline for waiting for demand and for each stream step. */
60
+ writeTimeoutMs: number;
61
+ /** The publisher's delivery timeouts from the track properties, unless a group's first object overrides them. */
62
+ trackTimeouts: DeliveryTimeouts;
63
+ /** The delivery timeouts of the relay subscription with this alias, as REQUEST_UPDATE has left them. */
64
+ subscriberTimeouts(trackAlias: number): DeliveryTimeouts;
65
+ }
66
+ export interface WriteSlot {
67
+ /** The application's handle: the public track writer. */
68
+ readonly writer: RelayTrackWriter;
69
+ /** The relay's binding for this track changed: a new alias, or undefined when its subscription ended. */
70
+ bind(trackAlias: number | undefined): void;
71
+ /** The publisher connection ended; `error` is its failure, absent after a clean shutdown. */
72
+ disconnect(error?: unknown): void;
73
+ }
74
+ /** A monotonic clock for object ages. */
75
+ export declare const now: () => number;
76
+ /**
77
+ * An internal option on `write()` and `openGroup()`: when, on {@link now}, the application made the call. A wrapper that
78
+ * checks the arguments before handing them on (the supervised publisher) passes it, so its own work counts toward the
79
+ * object's delivery timeout (§5.2: the clock starts when the application provides the object).
80
+ */
81
+ export declare const CALL_STARTED_AT: unique symbol;
82
+ /** Options carrying {@link CALL_STARTED_AT}. */
83
+ export type CallStarted = {
84
+ readonly [CALL_STARTED_AT]?: number;
85
+ };
86
+ export declare function createWriteSlot(deps: WriteSlotDependencies): WriteSlot;
87
+ //# sourceMappingURL=write-slot.d.ts.map