@caprid/relay 0.1.0 → 0.2.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/README.md +56 -43
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/publish.d.ts +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +19 -3
- package/dist/publish.js.map +1 -1
- package/dist/room-endpoint.d.ts +8 -2
- package/dist/room-endpoint.d.ts.map +1 -1
- package/dist/room-endpoint.js +5 -20
- package/dist/room-endpoint.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Relay TypeScript SDK. `connectRelaySubscriber` subscribes to track objects and
|
|
4
4
|
`connectRelayPublisher` publishes them, through Relay, Mux's Media over QUIC (MoQ) relay service.
|
|
5
|
-
|
|
5
|
+
The SDK does not interpret payloads, so you need no player, media catalog, or Video.js.
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
@@ -10,28 +10,33 @@ Payloads are bytes the SDK does not interpret; no player, media catalog, or Vide
|
|
|
10
10
|
It needs WebTransport protocol negotiation, which the live tests verify against the Relay in
|
|
11
11
|
Chromium and in Firefox 155 or later (Playwright's builds). WebKit cannot open a WebTransport
|
|
12
12
|
session to the Relay yet.
|
|
13
|
-
- Node 24
|
|
13
|
+
- Node 24 or later: import from `@caprid/relay/node`, which connects over native QUIC through
|
|
14
14
|
`@caprid/relay-quic` ([Node](#node)). Other runtimes must pass a compatible `createTransport`
|
|
15
15
|
factory.
|
|
16
|
-
- Where UDP is blocked, or the browser has no usable WebTransport (Safari)
|
|
17
|
-
[`@caprid/relay-websocket`](packages/relay-websocket/README.md)'s `withWebSocketFallback()` or
|
|
18
|
-
`createWebSocketTransport()` as `createTransport
|
|
19
|
-
([networks without UDP](GUIDE.md#networks-without-udp-qmux-over-websocket)).
|
|
16
|
+
- Where UDP is blocked, or the browser has no usable WebTransport (Safari), pass
|
|
17
|
+
[`@caprid/relay-websocket`](https://github.com/caprids/relay-sdks/blob/main/ts/packages/relay-websocket/README.md)'s `withWebSocketFallback()` or
|
|
18
|
+
`createWebSocketTransport()` as `createTransport`. The connection then runs QMux over WebSocket on
|
|
19
|
+
TCP 443 ([networks without UDP](https://github.com/caprids/relay-sdks/blob/main/ts/GUIDE.md#networks-without-udp-qmux-over-websocket)).
|
|
20
20
|
- A Relay endpoint and a short-lived Relay JWT authorized for the namespace you use. The SDK
|
|
21
|
-
consumes tokens
|
|
21
|
+
consumes tokens. It does not issue them.
|
|
22
22
|
|
|
23
23
|
## Install
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
```sh
|
|
26
|
+
npm install @caprid/relay
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Add `@caprid/relay-quic` for Node ([Node](#node)), `@caprid/relay-websocket` for networks without
|
|
30
|
+
UDP, and `@caprid/moq-media` to publish or play media. To build the packages from a checkout of this
|
|
31
|
+
repository instead, see
|
|
32
|
+
[Use the local packages in your application](https://github.com/caprids/relay-sdks/blob/main/ts/GUIDE.md#use-the-local-packages-in-your-application).
|
|
28
33
|
|
|
29
34
|
## Publish and subscribe
|
|
30
35
|
|
|
31
36
|
```ts
|
|
32
37
|
import { connectRelayPublisher, connectRelaySubscriber, readText, roomEndpoint } from '@caprid/relay';
|
|
33
38
|
|
|
34
|
-
const url = roomEndpoint(
|
|
39
|
+
const url = roomEndpoint(['team']); // your token's root as the path, on https://relay.mux.global
|
|
35
40
|
const namespace = ['quickstart', 'unique-run']; // relative to that root
|
|
36
41
|
const getToken = () => token; // a Relay JWT allowed to publish and subscribe there
|
|
37
42
|
|
|
@@ -54,26 +59,32 @@ subscriber.close();
|
|
|
54
59
|
await publisher.close();
|
|
55
60
|
```
|
|
56
61
|
|
|
57
|
-
The [guide's
|
|
58
|
-
|
|
62
|
+
The [guide's full demo](https://github.com/caprids/relay-sdks/blob/main/ts/GUIDE.md#run-the-full-demo-from-a-checkout) runs the complete version of this, with
|
|
63
|
+
credential handling, the subscribe retry, a deadline, and cleanup on failure.
|
|
59
64
|
|
|
60
65
|
These connections never reconnect. For a live application, `connectSupervisedPublisher` and
|
|
61
|
-
`connectSupervisedSubscriber` reconnect with backoff
|
|
62
|
-
across connections and publisher restarts ([stay connected](GUIDE.md#stay-connected-supervised-connections)).
|
|
66
|
+
`connectSupervisedSubscriber` reconnect with backoff. They keep tracks registered and subscribed
|
|
67
|
+
across connections and publisher restarts ([stay connected](https://github.com/caprids/relay-sdks/blob/main/ts/GUIDE.md#stay-connected-supervised-connections)).
|
|
63
68
|
|
|
64
69
|
## Node
|
|
65
70
|
|
|
66
71
|
`@caprid/relay/node` exports everything `@caprid/relay` does. Its `connectRelayPublisher`,
|
|
67
|
-
`connectRelaySubscriber
|
|
68
|
-
[`@caprid/relay-quic`](packages/relay-quic/README.md), Mux's transport adapter for Node.
|
|
72
|
+
`connectRelaySubscriber`, and both `connectSupervised*` functions connect over native QUIC through
|
|
73
|
+
[`@caprid/relay-quic`](https://github.com/caprids/relay-sdks/blob/main/ts/packages/relay-quic/README.md), Mux's transport adapter for Node. Native QUIC
|
|
74
|
+
means MOQT directly on QUIC, with ALPN `moqt-22` and a fallback to `moqt-20`. Pass the same
|
|
69
75
|
`https://` endpoint you pass in a browser.
|
|
70
76
|
|
|
71
77
|
### Install
|
|
72
78
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
```sh
|
|
80
|
+
npm install @caprid/relay @caprid/relay-quic
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`@caprid/relay-quic` is an optional peer dependency that only `@caprid/relay/node` needs. It lists
|
|
84
|
+
a prebuilt native binary for each supported platform as an optional dependency, and your package
|
|
85
|
+
manager installs the one that matches ([its README](https://github.com/caprids/relay-sdks/blob/main/ts/packages/relay-quic/README.md#prebuilt-binaries)).
|
|
86
|
+
Without the package or the binary, a connect call fails with `RelayError` code
|
|
87
|
+
`TRANSPORT_UNAVAILABLE`.
|
|
77
88
|
|
|
78
89
|
### Publish and subscribe
|
|
79
90
|
|
|
@@ -82,7 +93,7 @@ The code is the browser example's, with a different import:
|
|
|
82
93
|
```ts
|
|
83
94
|
import { connectRelayPublisher, connectRelaySubscriber, readText, roomEndpoint } from '@caprid/relay/node';
|
|
84
95
|
|
|
85
|
-
const url = roomEndpoint(
|
|
96
|
+
const url = roomEndpoint(['team']);
|
|
86
97
|
const namespace = ['quickstart', 'unique-run'];
|
|
87
98
|
const getToken = () => process.env.RELAY_TOKEN;
|
|
88
99
|
|
|
@@ -105,10 +116,10 @@ await ticker.writeText('hello from Node');
|
|
|
105
116
|
By default a connection trusts the platform's root certificates. Two options change that, on
|
|
106
117
|
either connect function:
|
|
107
118
|
|
|
108
|
-
- `ca
|
|
109
|
-
|
|
110
|
-
- `serverCertificateHashes
|
|
111
|
-
The server's certificate must match one hash, and
|
|
119
|
+
- `ca` adds extra trust anchors to the platform's roots. Pass PEM as a string, as bytes, or as an
|
|
120
|
+
array of either. Use it for a relay behind a private certificate authority.
|
|
121
|
+
- `serverCertificateHashes` takes `[{ algorithm: 'sha-256', value }]`, in the W3C WebTransport
|
|
122
|
+
shape. The server's certificate must match one hash, and the adapter does not validate its chain.
|
|
112
123
|
|
|
113
124
|
```ts
|
|
114
125
|
import { readFile } from 'node:fs/promises';
|
|
@@ -117,46 +128,48 @@ const subscriber = await connectRelaySubscriber({ url, getToken, ca: await readF
|
|
|
117
128
|
```
|
|
118
129
|
|
|
119
130
|
Connections without trust options share one adapter. Passing `createTransport` replaces the adapter
|
|
120
|
-
entirely
|
|
131
|
+
entirely. Passing it together with `ca` or `serverCertificateHashes` throws a `TypeError`. To combine
|
|
121
132
|
them, build the factory yourself with `nativeQuicTransport({ ca })` from `@caprid/relay-quic`.
|
|
122
133
|
|
|
123
134
|
### Process lifetime
|
|
124
135
|
|
|
125
|
-
An open connection keeps the Node process alive
|
|
136
|
+
An open connection keeps the Node process alive from the start of the dial until the connection
|
|
126
137
|
has closed. After that the adapter holds nothing, so a script exits by itself once it has closed
|
|
127
|
-
its publisher and subscriber ([TA-25, TA-26](
|
|
138
|
+
its publisher and subscriber ([TA-25, TA-26](https://github.com/caprids/relay-sdks/blob/main/spec/transport-adapter.md)). A script that stops
|
|
128
139
|
early without closing them keeps running.
|
|
129
140
|
|
|
130
141
|
### Native WebTransport
|
|
131
142
|
|
|
132
143
|
`@caprid/relay/node` uses `@caprid/relay-quic` even where a global `WebTransport` exists. If Node gains
|
|
133
144
|
a `WebTransport` that can negotiate protocols, the first connect emits a `DeprecationWarning`
|
|
134
|
-
(code `CAPRID_RELAY_NODE_NATIVE_WEBTRANSPORT`) through `process.emitWarning`, once per process
|
|
145
|
+
(code `CAPRID_RELAY_NODE_NATIVE_WEBTRANSPORT`) through `process.emitWarning`, once per process. At
|
|
135
146
|
that point `@caprid/relay` connects on its own, and this entry point will be retired.
|
|
136
147
|
|
|
137
148
|
### Deno
|
|
138
149
|
|
|
139
|
-
|
|
140
|
-
its npm compatibility layer. Deno's own `WebTransport` cannot negotiate protocols,
|
|
141
|
-
`@caprid/relay` fails there with `TRANSPORT_UNAVAILABLE`.
|
|
150
|
+
Deno support is best effort and untested. Deno can load the entry as `npm:@caprid/relay/node` and
|
|
151
|
+
the addon through its npm compatibility layer. Deno's own `WebTransport` cannot negotiate protocols,
|
|
152
|
+
so plain `@caprid/relay` fails there with `TRANSPORT_UNAVAILABLE`.
|
|
142
153
|
|
|
143
154
|
## Stability
|
|
144
155
|
|
|
145
|
-
Before 1.0, a minor version can break the API, and [CHANGELOG.md](CHANGELOG.md) says what changed.
|
|
146
|
-
`@caprid/relay`, `@caprid/moq-core`, `@caprid/moq-media`, `@caprid/moq-mediabunny
|
|
147
|
-
release together at the same version, so
|
|
156
|
+
Before 1.0, a minor version can break the API, and [CHANGELOG.md](https://github.com/caprids/relay-sdks/blob/main/ts/CHANGELOG.md) says what changed.
|
|
157
|
+
`@caprid/relay`, `@caprid/moq-core`, `@caprid/moq-media`, `@caprid/moq-mediabunny`,
|
|
158
|
+
`@caprid/relay-quic`, and `@caprid/relay-websocket` always release together at the same version, so
|
|
159
|
+
install matching versions. A release supports:
|
|
148
160
|
|
|
149
161
|
- browsers with WebTransport, and Node 24 or later on the platforms `@caprid/relay-quic` ships
|
|
150
|
-
binaries for (Linux x64 and arm64 with glibc or musl, macOS arm64 and x64, Windows x64)
|
|
162
|
+
binaries for (Linux x64 and arm64 with glibc or musl, macOS arm64 and x64, Windows x64).
|
|
151
163
|
- MOQT draft 22 (`moqt-22`), with draft 20 (`moqt-20`) as an offered fallback, against moq-relay
|
|
152
164
|
0.15.4 or later.
|
|
153
165
|
|
|
154
166
|
## Documentation
|
|
155
167
|
|
|
156
|
-
- [TypeScript guide](GUIDE.md): the quickstart, subscription and publishing lifecycles, async
|
|
157
|
-
consumption, and publishing media.
|
|
158
|
-
- API reference: run `mise run ts:docs` to build it from the source
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
168
|
+
- [TypeScript guide](https://github.com/caprids/relay-sdks/blob/main/ts/GUIDE.md): the quickstart, subscription and publishing lifecycles, async
|
|
169
|
+
consumption, and publishing and playing media.
|
|
170
|
+
- API reference: run `mise run ts:docs` from a checkout to build it from the source into
|
|
171
|
+
`ts/docs-api/`.
|
|
172
|
+
- [Errors and recovery](https://github.com/caprids/relay-sdks/blob/main/ts/GUIDE.md#errors-and-recovery): stable `RelayError` codes and phases, and
|
|
173
|
+
how to recover without assuming delivery or safe replay.
|
|
174
|
+
- [Shared specification](https://github.com/caprids/relay-sdks/blob/main/spec/README.md): the protocol pins, behavior contract, and test vectors
|
|
162
175
|
every Relay SDK implements.
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { NamespaceEvent, NamespaceEventOptions, NamespaceEvents } from './n
|
|
|
6
6
|
export { readJSON, readText } from './payload.js';
|
|
7
7
|
export type { ConnectRelayPublisherOptions, PublishProperty, RegisterTrackOptions, RelayGroupWriter, RelayPublisher, RelayTrackWriter, } from './publish.js';
|
|
8
8
|
export { connectRelayPublisher } from './publish.js';
|
|
9
|
-
export { roomEndpoint } from './room-endpoint.js';
|
|
9
|
+
export { DEFAULT_ENDPOINT, roomEndpoint } from './room-endpoint.js';
|
|
10
10
|
export type { RelaySubscription, SubscriptionEnd, SubscriptionEndKind } from './subscription.js';
|
|
11
11
|
export type { SubscriptionEvent, SubscriptionEventOptions, SubscriptionEvents } from './subscription-events.js';
|
|
12
12
|
export { SubscriptionConnectionClosedError, SubscriptionOverflowError, SubscriptionRequestError, } from './subscription-events.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,MAAM,EACN,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACpF,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EACV,4BAA4B,EAC5B,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,gBAAgB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zB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,iCAAiC,EACjC,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,YAAY,EACV,kCAAkC,EAClC,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,aAAa,GACd,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { connectRelaySubscriber } from './connect.js';
|
|
|
2
2
|
export { RelayError } from './errors.js';
|
|
3
3
|
export { readJSON, readText } from './payload.js';
|
|
4
4
|
export { connectRelayPublisher } from './publish.js';
|
|
5
|
-
export { roomEndpoint } from './room-endpoint.js';
|
|
5
|
+
export { DEFAULT_ENDPOINT, roomEndpoint } from './room-endpoint.js';
|
|
6
6
|
export { SubscriptionConnectionClosedError, SubscriptionOverflowError, SubscriptionRequestError, } from './subscription-events.js';
|
|
7
7
|
export { connectSupervisedPublisher } from './supervised-publisher.js';
|
|
8
8
|
export { connectSupervisedSubscriber } from './supervised-subscriber.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAA6C,MAAM,aAAa,CAAC;AAEpF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AASlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAA6C,MAAM,aAAa,CAAC;AAEpF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AASlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGpE,OAAO,EACL,iCAAiC,EACjC,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAUvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/publish.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface RegisterTrackOptions {
|
|
|
34
34
|
* add, drop, or rewrite properties before delivery to subscribers. With moq-relay 0.17.0 every
|
|
35
35
|
* SUBSCRIBE_OK carries the relay's track properties, not these, and a Timescale (`0x08`) here is
|
|
36
36
|
* what keeps supplied object Timestamps unchanged. See "Relay property handling" in
|
|
37
|
-
* spec/behavior.md. The list rides in every SUBSCRIBE_OK, so it must encode to at most 65525
|
|
37
|
+
* spec/behavior.md. The list rides in every SUBSCRIBE_OK (and TRACK_STATUS_OK), so it must encode to at most 65525
|
|
38
38
|
* bytes, hold at most 64 pairs (the relay's limit) and keep `0x0E` at most 255 and `0x22` at 1
|
|
39
39
|
* or 2 (draft-22); otherwise the relay would refuse every subscriber, so `registerTrack` throws a
|
|
40
40
|
* RangeError instead.
|
package/dist/publish.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAmB,KAAK,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AA8BnG;;;GAGG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,uFAAuF;IACvF,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,oHAAoH;IACpH,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,2FAA2F;IAC3F,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wGAAwG;IACxG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4FAA4F;IAC5F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,wGAAwG;IACxG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,KAAK,CACH,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,GAC3E,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB;;;OAGG;IACH,KAAK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AE;QAAE,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpH,wGAAwG;IACxG,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvH;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CAAC;IAC/D;;;;;;;;;OASG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACvB,4EAA4E;QAC5E,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC,CAAC;IACH;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,cAAc,CAAC,CAuH1G"}
|
package/dist/publish.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMoqtPublishSession, createSubgroupWriter } from '@caprid/moq-core';
|
|
1
|
+
import { createMoqtPublishSession, createSubgroupWriter, } from '@caprid/moq-core';
|
|
2
2
|
import { assertTimeoutMs, openRelaySession } from './connect-session.js';
|
|
3
3
|
import { NO_DELIVERY_TIMEOUTS, publisherTimeouts, subscriberTimeouts, } from './delivery-timeouts.js';
|
|
4
4
|
import { RelayError } from './errors.js';
|
|
@@ -6,6 +6,22 @@ import { trackSendOptions } from './send-order.js';
|
|
|
6
6
|
import { createSettlingGroups } from './settling-groups.js';
|
|
7
7
|
import { namespaceFields, trackName, trackPropertyPairs } from './validation.js';
|
|
8
8
|
import { createWriteSlot } from './write-slot.js';
|
|
9
|
+
/**
|
|
10
|
+
* A subgroup writer that tells the core of every object the transport took, so the core answers the
|
|
11
|
+
* relay's TRACK_STATUS with the track's largest object (draft-22 §9.20.17).
|
|
12
|
+
*/
|
|
13
|
+
function reportingObjects(subgroup, track) {
|
|
14
|
+
return {
|
|
15
|
+
groupId: subgroup.groupId,
|
|
16
|
+
async writeObject(object, options) {
|
|
17
|
+
await subgroup.writeObject(object, options);
|
|
18
|
+
track.objectPublished({ group: subgroup.groupId, object: object.objectId });
|
|
19
|
+
},
|
|
20
|
+
fin: () => subgroup.fin(),
|
|
21
|
+
handOverFin: () => subgroup.handOverFin(),
|
|
22
|
+
abort: (reason) => subgroup.abort(reason),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
9
25
|
/**
|
|
10
26
|
* Open a dedicated Relay publisher connection. Subscribers use connectRelaySubscriber; this
|
|
11
27
|
* initial publishing API does not share their physical transport. A relay must solicit the
|
|
@@ -88,11 +104,11 @@ export async function connectRelayPublisher(options) {
|
|
|
88
104
|
});
|
|
89
105
|
const sendOptions = trackSendOptions(properties);
|
|
90
106
|
const slot = createWriteSlot({
|
|
91
|
-
openSubgroup: async (trackAlias, groupId) => createSubgroupWriter(await session.openUniStream(trackAlias, sendOptions), {
|
|
107
|
+
openSubgroup: async (trackAlias, groupId) => reportingObjects(createSubgroupWriter(await session.openUniStream(trackAlias, sendOptions), {
|
|
92
108
|
trackAlias,
|
|
93
109
|
groupId,
|
|
94
110
|
hasProperties: true,
|
|
95
|
-
}),
|
|
111
|
+
}), registered),
|
|
96
112
|
settlingGroups,
|
|
97
113
|
namespaceSolicited: () => session.namespaceSolicited,
|
|
98
114
|
assertOpen: lifetime.assertOpen,
|
package/dist/publish.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GAIrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAA4B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAEL,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAElE;;;GAGG;AACH,SAAS,gBAAgB,CAAC,QAAwB,EAAE,KAAsB;IACxE,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO;YAC/B,MAAM,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5C,KAAK,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE;QACzB,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE;QACzC,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,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osted Relay endpoint, pinned in spec/protocol.json as `relay.defaultEndpoint`. */
|
|
2
|
+
export declare const DEFAULT_ENDPOINT = "https://relay.mux.global";
|
|
1
3
|
/**
|
|
2
4
|
* Root an endpoint at a room. The result is the endpoint with each room field appended to its
|
|
3
5
|
* path, after any path it has and without its trailing slashes, and with its query kept, a `jwt`
|
|
4
|
-
* parameter included. A connection to it names namespaces relative to the room
|
|
6
|
+
* parameter included. A connection to it names namespaces relative to the room. Without an
|
|
7
|
+
* endpoint it roots {@link DEFAULT_ENDPOINT}:
|
|
5
8
|
*
|
|
6
9
|
* ```ts
|
|
7
|
-
* roomEndpoint(
|
|
10
|
+
* roomEndpoint(['acme', 'rooms', '42']);
|
|
8
11
|
* // 'https://relay.mux.global/acme/rooms/42'
|
|
12
|
+
* roomEndpoint('https://relay.example', ['acme', 'rooms', '42']);
|
|
13
|
+
* // 'https://relay.example/acme/rooms/42'
|
|
9
14
|
* ```
|
|
10
15
|
*
|
|
11
16
|
* The endpoint follows the connect calls' rules and the room the namespace rules. Nothing is
|
|
@@ -17,5 +22,6 @@
|
|
|
17
22
|
* @throws {RangeError} An endpoint that is not `https`, has a fragment or userinfo, or an empty
|
|
18
23
|
* `jwt`; a room of more than 32 fields; a room field with any other character, or `.` or `..`.
|
|
19
24
|
*/
|
|
25
|
+
export declare function roomEndpoint(room: readonly string[]): string;
|
|
20
26
|
export declare function roomEndpoint(endpoint: string, room: readonly string[]): string;
|
|
21
27
|
//# sourceMappingURL=room-endpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-endpoint.d.ts","sourceRoot":"","sources":["../src/room-endpoint.ts"],"names":[],"mappings":"AAeA
|
|
1
|
+
{"version":3,"file":"room-endpoint.d.ts","sourceRoot":"","sources":["../src/room-endpoint.ts"],"names":[],"mappings":"AAeA,0FAA0F;AAC1F,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC;AAC9D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC"}
|
package/dist/room-endpoint.js
CHANGED
|
@@ -11,26 +11,11 @@ import { namespaceFields } from './validation.js';
|
|
|
11
11
|
* "Endpoint paths").
|
|
12
12
|
*/
|
|
13
13
|
const ROOM_FIELD = /^[A-Za-z0-9\-._~!$&'()+,;=:@]+$/;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* ```ts
|
|
20
|
-
* roomEndpoint('https://relay.mux.global', ['acme', 'rooms', '42']);
|
|
21
|
-
* // 'https://relay.mux.global/acme/rooms/42'
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* The endpoint follows the connect calls' rules and the room the namespace rules. Nothing is
|
|
25
|
-
* percent-encoded: a room field holds only `A`–`Z`, `a`–`z`, `0`–`9` and `-._~!$&'()+,;=:@`, and is
|
|
26
|
-
* not `.` or `..`. A namespace with any other field is reached from the bare host instead.
|
|
27
|
-
*
|
|
28
|
-
* @throws {TypeError} An endpoint that is not an absolute URL string, or a room that is not a
|
|
29
|
-
* sequence of non-empty string fields.
|
|
30
|
-
* @throws {RangeError} An endpoint that is not `https`, has a fragment or userinfo, or an empty
|
|
31
|
-
* `jwt`; a room of more than 32 fields; a room field with any other character, or `.` or `..`.
|
|
32
|
-
*/
|
|
33
|
-
export function roomEndpoint(endpoint, room) {
|
|
14
|
+
/** The hosted Relay endpoint, pinned in spec/protocol.json as `relay.defaultEndpoint`. */
|
|
15
|
+
export const DEFAULT_ENDPOINT = 'https://relay.mux.global';
|
|
16
|
+
export function roomEndpoint(...args) {
|
|
17
|
+
// One argument is the room alone; two are the endpoint and the room, as before the default.
|
|
18
|
+
const [endpoint, room] = args.length === 1 ? [DEFAULT_ENDPOINT, args[0]] : args;
|
|
34
19
|
const url = endpointUrl(endpoint);
|
|
35
20
|
const fields = namespaceFields(room);
|
|
36
21
|
fields.forEach((field, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-endpoint.js","sourceRoot":"","sources":["../src/room-endpoint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,iCAAiC,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"room-endpoint.js","sourceRoot":"","sources":["../src/room-endpoint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,iCAAiC,CAAC;AAErD,0FAA0F;AAC1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AA0B3D,MAAM,UAAU,YAAY,CAAC,GAAG,IAA6E;IAC3G,4FAA4F;IAC5F,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChF,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;YACzB,MAAM,IAAI,UAAU,CAClB,cAAc,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,yDAAyD;gBACpG,6EAA6E;gBAC7E,iDAAiD,CACpD,CAAC;QACJ,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI;YACjC,MAAM,IAAI,UAAU,CAClB,cAAc,KAAK,QAAQ,KAAK,qFAAqF,CACtH,CAAC;IACN,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACzE,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caprid/relay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "JavaScript SDK for Relay",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@caprid/moq-core": "0.
|
|
32
|
+
"@caprid/moq-core": "0.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@caprid/relay-quic": "0.
|
|
35
|
+
"@caprid/relay-quic": "0.2.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@caprid/relay-quic": {
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"typescript": "6.0.2",
|
|
51
51
|
"vitest": "4.1.10",
|
|
52
52
|
"ws": "8.22.0",
|
|
53
|
-
"@caprid/
|
|
54
|
-
"@caprid/moq-mediabunny": "0.
|
|
55
|
-
"@caprid/relay-
|
|
56
|
-
"@caprid/
|
|
53
|
+
"@caprid/relay-quic": "0.2.0",
|
|
54
|
+
"@caprid/moq-mediabunny": "0.2.0",
|
|
55
|
+
"@caprid/relay-websocket": "0.2.0",
|
|
56
|
+
"@caprid/moq-media": "0.2.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=24"
|