@norskvideo/moq-net 0.1.8 → 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 +2 -2
- package/announce.d.ts +7 -0
- package/announce.d.ts.map +1 -0
- package/announce.js +8 -0
- package/announce.js.map +1 -0
- package/announced.d.ts +49 -91
- package/announced.d.ts.map +1 -1
- package/announced.js +21 -156
- package/announced.js.map +1 -1
- package/bandwidth.d.ts +163 -0
- package/bandwidth.d.ts.map +1 -0
- package/bandwidth.js +304 -0
- package/bandwidth.js.map +1 -0
- package/bandwidth_api.d.ts +7 -0
- package/bandwidth_api.d.ts.map +1 -0
- package/bandwidth_api.js +8 -0
- package/bandwidth_api.js.map +1 -0
- package/broadcast.d.ts +44 -35
- package/broadcast.d.ts.map +1 -1
- package/broadcast.js +104 -60
- package/broadcast.js.map +1 -1
- package/connection/accept.d.ts +16 -1
- package/connection/accept.d.ts.map +1 -1
- package/connection/accept.js +52 -28
- package/connection/accept.js.map +1 -1
- package/connection/browser.d.ts.map +1 -1
- package/connection/browser.js +9 -7
- package/connection/browser.js.map +1 -1
- package/connection/connect.d.ts +30 -6
- package/connection/connect.d.ts.map +1 -1
- package/connection/connect.js +110 -54
- package/connection/connect.js.map +1 -1
- package/connection/established.d.ts +17 -21
- package/connection/established.d.ts.map +1 -1
- package/connection/established.js.map +1 -1
- package/connection/forward.d.ts +2 -0
- package/connection/forward.d.ts.map +1 -0
- package/connection/forward.js +173 -0
- package/connection/forward.js.map +1 -0
- package/connection/handshake.d.ts +1 -0
- package/connection/handshake.d.ts.map +1 -1
- package/connection/handshake.js +5 -2
- package/connection/handshake.js.map +1 -1
- package/connection/index.d.ts +5 -5
- package/connection/index.d.ts.map +1 -1
- package/connection/index.js +4 -5
- package/connection/index.js.map +1 -1
- package/connection/pool.d.ts +186 -0
- package/connection/pool.d.ts.map +1 -0
- package/connection/pool.js +361 -0
- package/connection/pool.js.map +1 -0
- package/connection/reload.d.ts +14 -93
- package/connection/reload.d.ts.map +1 -1
- package/connection/reload.js +217 -81
- package/connection/reload.js.map +1 -1
- package/connection/stats.d.ts +3 -26
- package/connection/stats.d.ts.map +1 -1
- package/connection/stats.js.map +1 -1
- package/connection/transport.d.ts +0 -7
- package/connection/transport.d.ts.map +1 -1
- package/consume.d.ts +1 -43
- package/consume.d.ts.map +1 -1
- package/consume.js +1 -1
- package/consume.js.map +1 -1
- package/error.d.ts +180 -29
- package/error.d.ts.map +1 -1
- package/error.js +331 -16
- package/error.js.map +1 -1
- package/errors.d.ts +7 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +8 -0
- package/errors.js.map +1 -0
- package/group.d.ts +9 -43
- package/group.d.ts.map +1 -1
- package/group.js +284 -69
- package/group.js.map +1 -1
- package/hop.d.ts +115 -0
- package/hop.d.ts.map +1 -0
- package/hop.js +119 -0
- package/hop.js.map +1 -0
- package/ietf/adapter.d.ts +5 -1
- package/ietf/adapter.d.ts.map +1 -1
- package/ietf/adapter.js +105 -60
- package/ietf/adapter.js.map +1 -1
- package/ietf/aliases.d.ts +1 -78
- package/ietf/aliases.d.ts.map +1 -1
- package/ietf/cluster.d.ts +9 -123
- package/ietf/cluster.d.ts.map +1 -1
- package/ietf/cluster.js +84 -44
- package/ietf/cluster.js.map +1 -1
- package/ietf/connection.d.ts +6 -72
- package/ietf/connection.d.ts.map +1 -1
- package/ietf/connection.js +62 -56
- package/ietf/connection.js.map +1 -1
- package/ietf/error.d.ts +11 -0
- package/ietf/error.d.ts.map +1 -0
- package/ietf/error.js +193 -0
- package/ietf/error.js.map +1 -0
- package/ietf/fetch.d.ts +7 -20
- package/ietf/fetch.d.ts.map +1 -1
- package/ietf/fetch.js +52 -22
- package/ietf/fetch.js.map +1 -1
- package/ietf/filter.d.ts +2 -0
- package/ietf/filter.d.ts.map +1 -1
- package/ietf/filter.js +10 -1
- package/ietf/filter.js.map +1 -1
- package/ietf/goaway.d.ts.map +1 -1
- package/ietf/goaway.js +22 -5
- package/ietf/goaway.js.map +1 -1
- package/ietf/hidden.d.ts +2 -0
- package/ietf/hidden.d.ts.map +1 -0
- package/ietf/hidden.js +30 -0
- package/ietf/hidden.js.map +1 -0
- package/ietf/index.d.ts +2 -0
- package/ietf/index.d.ts.map +1 -1
- package/ietf/index.js +2 -0
- package/ietf/index.js.map +1 -1
- package/ietf/object.d.ts +15 -8
- package/ietf/object.d.ts.map +1 -1
- package/ietf/object.js +51 -36
- package/ietf/object.js.map +1 -1
- package/ietf/parameters.d.ts +14 -2
- package/ietf/parameters.d.ts.map +1 -1
- package/ietf/parameters.js +97 -29
- package/ietf/parameters.js.map +1 -1
- package/ietf/properties.d.ts +1 -0
- package/ietf/properties.d.ts.map +1 -1
- package/ietf/properties.js +14 -0
- package/ietf/properties.js.map +1 -1
- package/ietf/publish.d.ts +19 -2
- package/ietf/publish.d.ts.map +1 -1
- package/ietf/publish.js +40 -6
- package/ietf/publish.js.map +1 -1
- package/ietf/publish_namespace.d.ts +25 -0
- package/ietf/publish_namespace.d.ts.map +1 -1
- package/ietf/publish_namespace.js +63 -0
- package/ietf/publish_namespace.js.map +1 -1
- package/ietf/publisher.d.ts +1 -82
- package/ietf/publisher.d.ts.map +1 -1
- package/ietf/publisher.js +483 -235
- package/ietf/publisher.js.map +1 -1
- package/ietf/solicit.d.ts +1 -40
- package/ietf/solicit.d.ts.map +1 -1
- package/ietf/subscribe.d.ts +8 -6
- package/ietf/subscribe.d.ts.map +1 -1
- package/ietf/subscribe.js +33 -27
- package/ietf/subscribe.js.map +1 -1
- package/ietf/subscribe_namespace.d.ts +8 -2
- package/ietf/subscribe_namespace.d.ts.map +1 -1
- package/ietf/subscribe_namespace.js +18 -8
- package/ietf/subscribe_namespace.js.map +1 -1
- package/ietf/subscriber.d.ts +1 -65
- package/ietf/subscriber.d.ts.map +1 -1
- package/ietf/subscriber.js +337 -123
- package/ietf/subscriber.js.map +1 -1
- package/ietf/token.d.ts +2 -0
- package/ietf/token.d.ts.map +1 -0
- package/ietf/token.js +99 -0
- package/ietf/token.js.map +1 -0
- package/ietf/track.d.ts +4 -0
- package/ietf/track.d.ts.map +1 -1
- package/ietf/track.js +6 -20
- package/ietf/track.js.map +1 -1
- package/ietf/version.d.ts +12 -1
- package/ietf/version.d.ts.map +1 -1
- package/ietf/version.js +13 -0
- package/ietf/version.js.map +1 -1
- package/index.d.ts +12 -7
- package/index.d.ts.map +1 -1
- package/index.js +10 -5
- package/index.js.map +1 -1
- package/internal.d.ts +115 -1
- package/internal.d.ts.map +1 -1
- package/internal.js +108 -0
- package/internal.js.map +1 -1
- package/lite/announce.d.ts +60 -10
- package/lite/announce.d.ts.map +1 -1
- package/lite/announce.js +176 -31
- package/lite/announce.js.map +1 -1
- package/lite/connection.d.ts +9 -59
- package/lite/connection.d.ts.map +1 -1
- package/lite/connection.js +34 -35
- package/lite/connection.js.map +1 -1
- package/lite/datagram.d.ts +3 -2
- package/lite/datagram.d.ts.map +1 -1
- package/lite/datagram.js +7 -8
- package/lite/datagram.js.map +1 -1
- package/lite/fetch.d.ts +15 -1
- package/lite/fetch.d.ts.map +1 -1
- package/lite/fetch.js +39 -7
- package/lite/fetch.js.map +1 -1
- package/lite/goaway.d.ts.map +1 -1
- package/lite/goaway.js +7 -1
- package/lite/goaway.js.map +1 -1
- package/lite/group.d.ts +30 -12
- package/lite/group.d.ts.map +1 -1
- package/lite/group.js +68 -26
- package/lite/group.js.map +1 -1
- package/lite/message.d.ts +2 -2
- package/lite/message.d.ts.map +1 -1
- package/lite/message.js +14 -5
- package/lite/message.js.map +1 -1
- package/lite/priority.d.ts +1 -61
- package/lite/priority.d.ts.map +1 -1
- package/lite/priority.js +4 -5
- package/lite/priority.js.map +1 -1
- package/lite/publisher.d.ts +1 -69
- package/lite/publisher.d.ts.map +1 -1
- package/lite/publisher.js +630 -262
- package/lite/publisher.js.map +1 -1
- package/lite/setup.d.ts +8 -8
- package/lite/setup.d.ts.map +1 -1
- package/lite/setup.js +33 -30
- package/lite/setup.js.map +1 -1
- package/lite/subscribe.d.ts +71 -17
- package/lite/subscribe.d.ts.map +1 -1
- package/lite/subscribe.js +205 -53
- package/lite/subscribe.js.map +1 -1
- package/lite/subscriber.d.ts +15 -56
- package/lite/subscriber.d.ts.map +1 -1
- package/lite/subscriber.js +451 -247
- package/lite/subscriber.js.map +1 -1
- package/lite/track.d.ts +4 -10
- package/lite/track.d.ts.map +1 -1
- package/lite/track.js +34 -29
- package/lite/track.js.map +1 -1
- package/lite/version.d.ts +42 -6
- package/lite/version.d.ts.map +1 -1
- package/lite/version.js +126 -10
- package/lite/version.js.map +1 -1
- package/origin.d.ts +256 -29
- package/origin.d.ts.map +1 -1
- package/origin.js +1427 -37
- package/origin.js.map +1 -1
- package/package.json +8 -3
- package/path.d.ts +25 -7
- package/path.d.ts.map +1 -1
- package/path.js +5 -3
- package/path.js.map +1 -1
- package/stream.d.ts +73 -14
- package/stream.d.ts.map +1 -1
- package/stream.js +372 -141
- package/stream.js.map +1 -1
- package/tail.d.ts +18 -0
- package/tail.d.ts.map +1 -0
- package/tail.js +167 -0
- package/tail.js.map +1 -0
- package/time.d.ts +15 -2
- package/time.d.ts.map +1 -1
- package/time.js +28 -9
- package/time.js.map +1 -1
- package/track.d.ts +211 -83
- package/track.d.ts.map +1 -1
- package/track.js +816 -205
- package/track.js.map +1 -1
- package/util/abort.d.ts +2 -0
- package/util/abort.d.ts.map +1 -0
- package/util/abort.js +20 -0
- package/util/abort.js.map +1 -0
- package/util/log.d.ts +5 -0
- package/util/log.d.ts.map +1 -0
- package/util/log.js +17 -0
- package/util/log.js.map +1 -0
- package/util/u64.d.ts +39 -0
- package/util/u64.d.ts.map +1 -0
- package/util/u64.js +83 -0
- package/util/u64.js.map +1 -0
- package/util/varint.d.ts +29 -0
- package/util/varint.d.ts.map +1 -0
- package/util/varint.js +198 -0
- package/util/varint.js.map +1 -0
- package/varint.d.ts +10 -6
- package/varint.d.ts.map +1 -1
- package/varint.js +40 -237
- package/varint.js.map +1 -1
- package/wire.d.ts +80 -0
- package/wire.d.ts.map +1 -0
- package/wire.js +32 -0
- package/wire.js.map +1 -0
- package/zod.d.ts +1 -1
- package/zod.d.ts.map +1 -1
- package/zod.js.map +1 -1
- package/mock.d.ts +0 -66
- package/mock.d.ts.map +0 -1
- package/mock.js +0 -243
- package/mock.js.map +0 -1
package/ietf/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ietf/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAkB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAe,OAAO,EAAe,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MA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EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;IACF,CAAC;IAED;;;OAGG;IACH,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;CACD","sourcesContent":["import { type Getter, Signal } from \"@moq/signals\";\nimport * as announce from \"../announced.ts\";\nimport type * as broadcast from \"../broadcast.ts\";\nimport type { Established } from \"../connection/established.ts\";\nimport { type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { ProtocolViolation } from \"../error.ts\";\nimport * as Path from \"../path.ts\";\nimport { type Reader, Readers, type Stream } from \"../stream.ts\";\nimport { ControlStreamAdapter, NativeSession, type Session } from \"./adapter.ts\";\nimport * as Cluster from \"./cluster.ts\";\nimport { GoAway } from \"./goaway.ts\";\nimport { Group } from \"./object.ts\";\nimport { Publish } from \"./publish.ts\";\nimport { PublishNamespace } from \"./publish_namespace.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { Subscribe, SubscribeUpdate } from \"./subscribe.ts\";\nimport { SubscribeNamespace, SubscribeNamespaceLegacy } from \"./subscribe_namespace.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { TrackStatusRequest } from \"./track.ts\";\nimport { type IetfVersion, Version, versionName } from \"./version.ts\";\n\n/**\n * Represents a connection to a MoQ server using moq-transport protocol.\n *\n * @public\n */\nexport class Connection implements Established {\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The negotiated protocol version.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */\n\treadonly discovery: boolean;\n\n\t/** moq-transport has no PROBE, so this stays empty; see {@link Established.probe}. */\n\treadonly probe: Getter<Probe> = new Signal<Probe>({});\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Session abstraction: adapter for v14-v16, native for v17.\n\t#session: Session;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// What the peer declared about being solicited; see {@link Ietf.solicitFromSetup}.\n\t#solicit: boolean | undefined;\n\n\t// The Hop IDs this session declared; see {@link Cluster}.\n\t#cluster?: Cluster.Hops;\n\n\t// Just to avoid logging when `close()` is called.\n\t#closed = false;\n\n\t/**\n\t * Creates a new Connection instance.\n\t * @param url - The URL of the connection\n\t * @param quic - The WebTransport session\n\t * @param control - The control/setup stream\n\t * @param maxRequestId - The initial max request ID\n\t * @param version - The negotiated protocol version\n\t * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)\n\t * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tcontrol,\n\t\tmaxRequestId,\n\t\tversion,\n\t\tclient,\n\t\tdiscovery = true,\n\t\tsolicit,\n\t\tcluster,\n\t}: {\n\t\turl: URL;\n\t\tquic: WebTransport;\n\t\tcontrol: Stream;\n\t\tmaxRequestId: bigint;\n\t\tversion: IetfVersion;\n\t\t/** Whether this peer initiated the session, selecting the even request-ID space. */\n\t\tclient: boolean;\n\t\tdiscovery?: boolean;\n\t\t/**\n\t\t * What the peer declared about being solicited. `undefined` means it declared\n\t\t * nothing, which is the one case where announcing at us unasked is not a bug.\n\t\t */\n\t\tsolicit?: boolean;\n\t\t/**\n\t\t * The Hop IDs this session declared (MoQ Cluster). `undefined` on a version that\n\t\t * cannot negotiate the extension, as is a `peer` the peer never declared.\n\t\t */\n\t\tcluster?: Cluster.Hops;\n\t}) {\n\t\tthis.url = url;\n\t\tthis.discovery = discovery;\n\t\tthis.version = versionName(version);\n\t\tthis.transport = transportOf(quic);\n\t\tthis.#quic = quic;\n\n\t\t// Two-path dispatch: v14-v16 uses adapter, v17+ uses native bidi streams\n\t\tif (version >= Version.DRAFT_17) {\n\t\t\tthis.#session = new NativeSession(quic, version, client);\n\t\t\t// v17+: control/setup stream only carries GoAway\n\t\t\tvoid this.#runGoAway(control, version);\n\t\t} else {\n\t\t\tconst adapter = new ControlStreamAdapter(quic, control, version, maxRequestId, client);\n\t\t\tthis.#session = adapter;\n\t\t\t// Start the adapter read loop (routes control messages to virtual streams)\n\t\t\tvoid adapter.run().catch((err: unknown) => {\n\t\t\t\tif (!this.#closed) console.error(\"adapter error\", err);\n\t\t\t\tthis.close();\n\t\t\t});\n\t\t}\n\n\t\tthis.#publisher = new Publisher({\n\t\t\tquic: this.#quic,\n\t\t\tsession: this.#session,\n\t\t\trequiresSolicitation: solicit ?? false,\n\t\t\tcluster,\n\t\t});\n\t\tthis.#solicit = solicit;\n\t\tthis.#cluster = cluster;\n\t\tthis.#subscriber = new Subscriber({ session: this.#session, cluster });\n\n\t\tvoid this.#run();\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Established.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/**\n\t * Closes the connection.\n\t */\n\tclose() {\n\t\tif (this.#closed) return;\n\n\t\tthis.#closed = true;\n\n\t\tthis.#publisher.close();\n\t\tthis.#session.close();\n\n\t\ttry {\n\t\t\tthis.#quic.close();\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\t}\n\n\tasync #run(): Promise<void> {\n\t\ttry {\n\t\t\tawait Promise.all([this.#runBidis(), this.#runUnis(), this.#publisher.runPublishNamespaces()]);\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Publishes a broadcast to the connection.\n\t * @param name - The broadcast path to publish\n\t * @param broadcast - The broadcast to publish\n\t */\n\tpublish(path: Path.Valid, producer: broadcast.Producer) {\n\t\tthis.#publisher.publish(path, producer);\n\t}\n\n\t/**\n\t * Gets an announced reader for the specified prefix.\n\t * @param prefix - The prefix for announcements\n\t * @returns An Announced instance\n\t */\n\tannounced(prefix = Path.empty()): announce.Consumer {\n\t\treturn this.#subscriber.announced(prefix);\n\t}\n\n\t/**\n\t * Consumes a broadcast from the connection.\n\t *\n\t * @remarks\n\t * If the broadcast is not found, a \"not found\" error will be thrown when requesting any tracks.\n\t *\n\t * @param broadcast - The path of the broadcast to consume\n\t * @returns A Broadcast instance\n\t */\n\tconsume(path: Path.Valid): broadcast.Consumer {\n\t\treturn this.#subscriber.consume(path);\n\t}\n\n\t/**\n\t * Watches a broadcast, live only while it is announced.\n\t *\n\t * @param path - The path of the broadcast to watch\n\t * @returns A reactive handle to the broadcast\n\t */\n\tannouncedBroadcast(path: Path.Valid): announce.Broadcast {\n\t\treturn new announce.Broadcast({ connection: this, path });\n\t}\n\n\t/**\n\t * Accepts bidi streams (virtual for v14-v16, real for v17) and dispatches.\n\t */\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await this.#session.acceptBi();\n\t\t\tif (!stream) break;\n\n\t\t\tvoid this.#runBidi(stream).catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing bidi stream\", err);\n\t\t\t\tstream.abort(new Error(\"bidi stream error\"));\n\n\t\t\t\t// The peer broke the protocol, so losing the stream is not enough: nothing\n\t\t\t\t// stops it repeating the violation on the next one.\n\t\t\t\tif (err instanceof ProtocolViolation) this.close();\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Unified bidi stream dispatch. Reads typeId and routes to handler.\n\t * Matches the lite module's runBidi pattern.\n\t */\n\tasync #runBidi(stream: Stream) {\n\t\tconst typeId = await stream.reader.u53();\n\n\t\tswitch (typeId) {\n\t\t\t// Draft-18 SUBSCRIBE_NAMESPACE (0x50) and the legacy 0x11 message decode\n\t\t\t// to the same request_id + namespace; the legacy options field is ignored.\n\t\t\tcase SubscribeNamespace.id: {\n\t\t\t\tconst msg = await SubscribeNamespace.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeNamespaceLegacy.id: {\n\t\t\t\tconst legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = new SubscribeNamespace({ requestId: legacy.requestId, namespace: legacy.namespace });\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeUpdate.id: {\n\t\t\t\t// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message\n\t\t\t\tstream.abort(new Error(\"unexpected REQUEST_UPDATE as initial message\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Publisher handles incoming requests\n\t\t\tcase Subscribe.id: {\n\t\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TrackStatusRequest.id: {\n\t\t\t\tconst msg = await TrackStatusRequest.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runTrackStatusRequest(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Subscriber handles incoming notifications\n\t\t\tcase PublishNamespace.id: {\n\t\t\t\tconst msg = await PublishNamespace.decode(\n\t\t\t\t\tstream.reader,\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t\tCluster.negotiated(this.#cluster),\n\t\t\t\t);\n\n\t\t\t\t// We always declare that advertisements to us must be solicited (MoQ\n\t\t\t\t// Solicit), and writing the option at all proves the peer implements the\n\t\t\t\t// extension, whichever value it chose. It also cannot have advertised\n\t\t\t\t// before reading our SETUP, since our SETUP is what says whether\n\t\t\t\t// advertising unasked is allowed. So this is a bug in the peer, and a\n\t\t\t\t// silent one on both sides if we tolerate it.\n\t\t\t\t//\n\t\t\t\t// Draft-14/15 are exempt: they have no inline NAMESPACE, so a\n\t\t\t\t// PUBLISH_NAMESPACE request is also how a peer answers our\n\t\t\t\t// SUBSCRIBE_NAMESPACE there, and the message alone does not say which.\n\t\t\t\tconst legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;\n\t\t\t\tif (this.#solicit !== undefined && !legacy) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.close();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tawait this.#subscriber.runPublishNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Publish.id: {\n\t\t\t\tconst msg = await Publish.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#subscriber.runPublish(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn(`unexpected bidi stream type: 0x${typeId.toString(16)}`);\n\t\t\t\tstream.abort(new Error(\"unexpected stream type\"));\n\t\t}\n\t}\n\n\t/**\n\t * Handles unidirectional streams for media delivery (groups).\n\t */\n\tasync #runUnis() {\n\t\tconst readers = new Readers(this.#quic, this.#session.version);\n\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\n\t\t\tthis.#runUni(stream)\n\t\t\t\t.then(() => {\n\t\t\t\t\tstream.stop(new Error(\"cancel\"));\n\t\t\t\t})\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tconsole.error(\"error processing object stream\", err);\n\t\t\t\t\tstream.stop(err);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst header = await Group.decode(stream, this.#session.version);\n\t\tawait this.#subscriber.handleGroup(header, stream);\n\t}\n\n\t/**\n\t * v17+ only: reads GoAway from the setup/control stream.\n\t */\n\tasync #runGoAway(controlStream: Stream, version: IetfVersion) {\n\t\ttry {\n\t\t\tconst done = await controlStream.reader.done();\n\t\t\tif (done) return;\n\n\t\t\tconst typeId = await controlStream.reader.u53();\n\t\t\tif (typeId === GoAway.id) {\n\t\t\t\tconst msg = await GoAway.decode(controlStream.reader, version);\n\t\t\t\tconsole.warn(`received GOAWAY with redirect URI: ${msg.newSessionUri}`);\n\t\t\t} else {\n\t\t\t\tconsole.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"error reading setup stream\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Returns a promise that resolves when the connection is closed.\n\t * @returns A promise that resolves when closed\n\t */\n\tget closed(): Promise<void> {\n\t\treturn this.#quic.closed.then(() => undefined);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ietf/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EAA0B,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAkB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGxG,OAAO,EAAe,OAAO,EAAe,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,MAAM,EAA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CAAC;gBAC1B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC/D,OAAO,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;YACzE,CAAC;iBAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,yCAAyC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAC9E,CAAC;QACF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;IACF,CAAC;IAED,wGAAwG;IACxG,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAY,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["import { type Getter, Signal } from \"@moq/signals\";\nimport type * as announce from \"../announced.ts\";\nimport type { Established } from \"../connection/established.ts\";\nimport { type Probe, type Stats, transportStats } from \"../connection/stats.ts\";\nimport { type Transport, transportOf } from \"../connection/transport.ts\";\nimport { error, fromClose, ProtocolViolation, SessionCode, StreamCode, StreamError } from \"../error.ts\";\nimport type { Consumer as OriginConsumer } from \"../origin.ts\";\nimport type * as Path from \"../path.ts\";\nimport { type Reader, Readers, type Stream } from \"../stream.ts\";\nimport { registerWire } from \"../wire.ts\";\nimport { ControlStreamAdapter, NativeSession, type Session } from \"./adapter.ts\";\nimport * as Cluster from \"./cluster.ts\";\nimport { Fetch, FetchHeader } from \"./fetch.ts\";\nimport { GoAway } from \"./goaway.ts\";\nimport { Group } from \"./object.ts\";\nimport { Publish } from \"./publish.ts\";\nimport { PublishNamespace } from \"./publish_namespace.ts\";\nimport { Publisher } from \"./publisher.ts\";\nimport { Subscribe, SubscribeUpdate } from \"./subscribe.ts\";\nimport { SubscribeNamespace, SubscribeNamespaceLegacy } from \"./subscribe_namespace.ts\";\nimport { Subscriber } from \"./subscriber.ts\";\nimport { TrackStatusRequest } from \"./track.ts\";\nimport { type IetfVersion, Version, versionName } from \"./version.ts\";\n\n// The PADDING stream type (draft-18+): bytes a peer sends to probe for bandwidth.\nconst PADDING = 0x132b3e28n;\n\n/**\n * Represents a connection to a MoQ server using moq-transport protocol.\n *\n * @public\n */\nexport class Connection implements Established {\n\t// The URL of the connection.\n\treadonly url: URL;\n\n\t// The negotiated protocol version.\n\treadonly version: string;\n\n\t// The wire transport this session runs over.\n\treadonly transport: Transport;\n\n\t/** Whether the relay supports broadcast discovery; see {@link Established.discovery}. */\n\treadonly discovery: boolean;\n\n\t/** moq-transport has no PROBE, so this stays empty; see {@link Established.probe}. */\n\treadonly probe: Getter<Probe> = new Signal<Probe>({});\n\n\t// The established WebTransport session.\n\t#quic: WebTransport;\n\n\t// Session abstraction: adapter for v14-v16, native for v17.\n\t#session: Session;\n\n\t// Module for contributing tracks.\n\t#publisher: Publisher;\n\n\t// Module for distributing tracks.\n\t#subscriber: Subscriber;\n\n\t// What the peer declared about being solicited; see {@link Ietf.solicitFromSetup}.\n\t#solicit: boolean | undefined;\n\n\t// The Hop IDs this session declared; see {@link Cluster}.\n\t#cluster?: Cluster.Hops;\n\n\t// Just to avoid logging when `close()` is called.\n\t#closed = false;\n\n\t/**\n\t * Creates a new Connection instance.\n\t * @param url - The URL of the connection\n\t * @param quic - The WebTransport session\n\t * @param control - The control/setup stream\n\t * @param maxRequestId - The initial max request ID\n\t * @param version - The negotiated protocol version\n\t * @param solicit - What the peer's SETUP declared (undefined when it declared nothing)\n\t * @param cluster - The Hop IDs the SETUP exchange settled, on the versions that negotiate them\n\t *\n\t * @internal\n\t */\n\tconstructor({\n\t\turl,\n\t\tquic,\n\t\tcontrol,\n\t\tmaxRequestId,\n\t\tversion,\n\t\tclient,\n\t\tdiscovery = true,\n\t\tpublish,\n\t\tsolicit,\n\t\thidden = false,\n\t\tcluster,\n\t}: {\n\t\turl: URL;\n\t\tquic: WebTransport;\n\t\tcontrol: Stream;\n\t\tmaxRequestId: bigint;\n\t\tversion: IetfVersion;\n\t\t/** Whether this peer initiated the session, selecting the even request-ID space. */\n\t\tclient: boolean;\n\t\tdiscovery?: boolean;\n\t\t/** The origin whose broadcasts are served to the peer. Omit to publish nothing. */\n\t\tpublish?: OriginConsumer;\n\t\t/**\n\t\t * What the peer declared about being solicited. `undefined` means it declared\n\t\t * nothing, which is the one case where announcing at us unasked is not a bug.\n\t\t */\n\t\tsolicit?: boolean;\n\t\t/** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */\n\t\thidden?: boolean;\n\t\t/**\n\t\t * The Hop IDs this session declared (MoQ Cluster). `undefined` on a version that\n\t\t * cannot negotiate the extension, as is a `peer` the peer never declared.\n\t\t */\n\t\tcluster?: Cluster.Hops;\n\t}) {\n\t\tthis.url = url;\n\t\tthis.discovery = discovery;\n\t\tthis.version = versionName(version);\n\t\tthis.transport = transportOf(quic);\n\t\tthis.#quic = quic;\n\n\t\t// Two-path dispatch: v14-v16 uses adapter, v17+ uses native bidi streams\n\t\tif (version >= Version.DRAFT_17) {\n\t\t\tthis.#session = new NativeSession(quic, version, client);\n\t\t\t// v17+: control/setup stream only carries GoAway\n\t\t\tvoid this.#runGoAway(control, version);\n\t\t} else {\n\t\t\tconst adapter = new ControlStreamAdapter(quic, control, version, maxRequestId, client);\n\t\t\tthis.#session = adapter;\n\t\t\t// Start the adapter read loop (routes control messages to virtual streams)\n\t\t\tvoid adapter.run().catch((err: unknown) => {\n\t\t\t\tif (!this.#closed) console.error(\"adapter error\", err);\n\t\t\t\tthis.close();\n\t\t\t});\n\t\t}\n\n\t\tthis.#publisher = new Publisher({\n\t\t\tquic: this.#quic,\n\t\t\tsession: this.#session,\n\t\t\tpublish,\n\t\t\trequiresSolicitation: solicit ?? false,\n\t\t\thidden,\n\t\t\tcluster,\n\t\t});\n\t\tthis.#solicit = solicit;\n\t\tthis.#cluster = cluster;\n\t\tthis.#subscriber = new Subscriber({ session: this.#session, quic, cluster, hidden });\n\t\tregisterWire(this, { consume: (path) => this.#subscriber.consume(path) });\n\n\t\tvoid this.#run();\n\t}\n\n\t/** Snapshot the transport's counters; see {@link Established.stats}. */\n\tasync stats(): Promise<Stats> {\n\t\treturn transportStats(this.#quic);\n\t}\n\n\t/**\n\t * Closes the connection.\n\t */\n\tclose() {\n\t\tthis.#close();\n\t}\n\n\t// Close with the session code the peer should see, a clean close by default.\n\t#close(info?: WebTransportCloseInfo) {\n\t\tif (this.#closed) return;\n\n\t\tthis.#closed = true;\n\n\t\t// Before the session, whose own close would send a clean code first.\n\t\ttry {\n\t\t\tthis.#quic.close(info);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\tthis.#session.close();\n\t}\n\n\t// The peer broke the protocol, so losing the stream is not enough: nothing stops it\n\t// repeating the violation on the next one.\n\t#violated(err: ProtocolViolation) {\n\t\tthis.#close({ closeCode: SessionCode.ProtocolViolation, reason: err.message });\n\t}\n\n\tasync #run(): Promise<void> {\n\t\ttry {\n\t\t\tawait Promise.all([this.#runBidis(), this.#runUnis(), this.#publisher.runPublishNamespaces()]);\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"fatal error running connection\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/** Gets an announced reader for `scope`; see {@link Established.announced}. */\n\tannounced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer {\n\t\treturn this.#subscriber.announced(scope, options);\n\t}\n\n\t/**\n\t * Accepts bidi streams (virtual for v14-v16, real for v17) and dispatches.\n\t */\n\tasync #runBidis() {\n\t\tfor (;;) {\n\t\t\tconst stream = await this.#session.acceptBi();\n\t\t\tif (!stream) break;\n\n\t\t\tvoid this.#runBidi(stream).catch((err: unknown) => {\n\t\t\t\tconsole.error(\"error processing bidi stream\", err);\n\t\t\t\tstream.abort(new Error(\"bidi stream error\"));\n\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Unified bidi stream dispatch. Reads typeId and routes to handler.\n\t * Matches the lite module's runBidi pattern.\n\t */\n\tasync #runBidi(stream: Stream) {\n\t\tconst typeId = await stream.reader.u53();\n\n\t\tswitch (typeId) {\n\t\t\t// Draft-18 SUBSCRIBE_NAMESPACE (0x50) and the legacy 0x11 message decode\n\t\t\t// to the same request_id + namespace; the legacy options field is ignored.\n\t\t\tcase SubscribeNamespace.id: {\n\t\t\t\tconst msg = await SubscribeNamespace.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeNamespaceLegacy.id: {\n\t\t\t\tconst legacy = await SubscribeNamespaceLegacy.decode(stream.reader, this.#session.version);\n\t\t\t\tconst msg = new SubscribeNamespace({\n\t\t\t\t\trequestId: legacy.requestId,\n\t\t\t\t\tnamespace: legacy.namespace,\n\t\t\t\t\thidden: legacy.hidden,\n\t\t\t\t});\n\t\t\t\tawait this.#publisher.runSubscribeNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SubscribeUpdate.id: {\n\t\t\t\t// REQUEST_UPDATE (0x02) is a follow-up, not a valid initial message\n\t\t\t\tstream.abort(new Error(\"unexpected REQUEST_UPDATE as initial message\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Publisher handles incoming requests\n\t\t\tcase Subscribe.id: {\n\t\t\t\tconst msg = await Subscribe.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runSubscribe(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TrackStatusRequest.id: {\n\t\t\t\tconst msg = await TrackStatusRequest.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runTrackStatusRequest(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Fetch.id: {\n\t\t\t\tconst msg = await Fetch.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#publisher.runFetch(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Subscriber handles incoming notifications\n\t\t\tcase PublishNamespace.id: {\n\t\t\t\tconst msg = await PublishNamespace.decode(\n\t\t\t\t\tstream.reader,\n\t\t\t\t\tthis.#session.version,\n\t\t\t\t\tCluster.negotiated(this.#cluster),\n\t\t\t\t);\n\n\t\t\t\t// We always declare that advertisements to us must be solicited (MoQ\n\t\t\t\t// Solicit), and writing the option at all proves the peer implements the\n\t\t\t\t// extension, whichever value it chose. It also cannot have advertised\n\t\t\t\t// before reading our SETUP, since our SETUP is what says whether\n\t\t\t\t// advertising unasked is allowed. So this is a bug in the peer, and a\n\t\t\t\t// silent one on both sides if we tolerate it.\n\t\t\t\t//\n\t\t\t\t// Draft-14/15 are exempt: they have no inline NAMESPACE, so a\n\t\t\t\t// PUBLISH_NAMESPACE request is also how a peer answers our\n\t\t\t\t// SUBSCRIBE_NAMESPACE there, and the message alone does not say which.\n\t\t\t\tconst legacy = this.#session.version === Version.DRAFT_14 || this.#session.version === Version.DRAFT_15;\n\t\t\t\tif (this.#solicit !== undefined && !legacy) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`unsolicited publish_namespace from a peer that implements MoQ Solicit: broadcast=${msg.trackNamespace}`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.close();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tawait this.#subscriber.runPublishNamespace(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Publish.id: {\n\t\t\t\tconst msg = await Publish.decode(stream.reader, this.#session.version);\n\t\t\t\tawait this.#subscriber.runPublish(msg, stream);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn(`unexpected bidi stream type: 0x${typeId.toString(16)}`);\n\t\t\t\tstream.abort(new Error(\"unexpected stream type\"));\n\t\t}\n\t}\n\n\t/**\n\t * Handles unidirectional streams for media delivery (groups).\n\t */\n\tasync #runUnis() {\n\t\tconst readers = new Readers(this.#quic, this.#session.version);\n\n\t\tfor (;;) {\n\t\t\tconst stream = await readers.next();\n\t\t\tif (!stream) break;\n\n\t\t\tthis.#runUni(stream)\n\t\t\t\t.then(() => {\n\t\t\t\t\tstream.stop(new StreamError(StreamCode.Cancel, { message: \"cancel\" }));\n\t\t\t\t})\n\t\t\t\t.catch((err: unknown) => {\n\t\t\t\t\tconsole.error(\"error processing object stream\", err);\n\t\t\t\t\tstream.stop(err);\n\n\t\t\t\t\t// An unknown or invalid stream type MUST close the session, not just the stream.\n\t\t\t\t\tif (err instanceof ProtocolViolation) this.#violated(err);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tasync #runUni(stream: Reader) {\n\t\tconst version = this.#session.version;\n\t\t// Full width, so an unknown type past 2^53 is still classified rather than thrown.\n\t\tconst type = await stream.u62();\n\n\t\t// SUBGROUP_HEADER types match 0b0XX1XXXX; Group.decode validates the bits per draft.\n\t\tif (type <= 0xffn && (type & 0x90n) === 0x10n) {\n\t\t\tconst header = await Group.decode(stream, version, Number(type));\n\t\t\tawait this.#subscriber.handleGroup(header, stream);\n\t\t\treturn;\n\t\t}\n\n\t\t// The receiver MUST discard padding. We read it to the end rather than cancel,\n\t\t// so a peer probing for bandwidth gets the throughput it is measuring.\n\t\tif (type === PADDING && version >= Version.DRAFT_18) {\n\t\t\tawait stream.discard();\n\t\t\treturn;\n\t\t}\n\n\t\t// We never FETCH, so a fetch response answers nothing of ours.\n\t\tif (type === BigInt(FetchHeader.type)) throw new Error(\"unexpected fetch stream\");\n\n\t\t// Anything else is unknown, and a second SETUP is a violation too.\n\t\tthrow new ProtocolViolation(`unknown uni stream type: 0x${type.toString(16)}`);\n\t}\n\n\t/**\n\t * v17+ only: reads GoAway from the setup/control stream.\n\t */\n\tasync #runGoAway(controlStream: Stream, version: IetfVersion) {\n\t\ttry {\n\t\t\tconst done = await controlStream.reader.done();\n\t\t\tif (done) return;\n\n\t\t\tconst typeId = await controlStream.reader.u53();\n\t\t\tif (typeId === GoAway.id) {\n\t\t\t\tconst msg = await GoAway.decode(controlStream.reader, version);\n\t\t\t\tconsole.warn(`received GOAWAY with redirect URI: ${msg.newSessionUri}`);\n\t\t\t} else {\n\t\t\t\tconsole.warn(`unexpected message on setup stream: 0x${typeId.toString(16)}`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!this.#closed) {\n\t\t\t\tconsole.error(\"error reading setup stream\", err);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/** Resolves when the session closes, decoding the peer's close code; see {@link Established.closed}. */\n\tget closed(): Promise<Error | null> {\n\t\treturn this.#quic.closed.then(fromClose, (err: unknown) => error(err));\n\t}\n}\n"]}
|
package/ietf/error.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The moq-transport error code registries, per negotiated draft.
|
|
3
|
+
*
|
|
4
|
+
* A code only means something once you know which draft carried it: the registries grew,
|
|
5
|
+
* moved values, and in draft-15 collapsed five per-message tables into one. Mirrors the
|
|
6
|
+
* Rust `moq_net::ietf::error` module, and the two have to agree value for value.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/ietf/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/ietf/error.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/* @ts-self-types="./error.d.ts" */
|
|
2
|
+
/**
|
|
3
|
+
* The moq-transport error code registries, per negotiated draft.
|
|
4
|
+
*
|
|
5
|
+
* A code only means something once you know which draft carried it: the registries grew,
|
|
6
|
+
* moved values, and in draft-15 collapsed five per-message tables into one. Mirrors the
|
|
7
|
+
* Rust `moq_net::ietf::error` module, and the two have to agree value for value.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { Version } from "./version.js";
|
|
12
|
+
/**
|
|
13
|
+
* Whether `code` means the same thing in the negotiated draft's stream reset registry as it
|
|
14
|
+
* does in moq-lite's.
|
|
15
|
+
*
|
|
16
|
+
* The two registries agree on most of what they both assign, but this one grew across the
|
|
17
|
+
* drafts we negotiate and moved a value on the way:
|
|
18
|
+
*
|
|
19
|
+
* | Code | draft-14/15 | draft-16/17 | draft-18+ |
|
|
20
|
+
* |------|-------------|-------------|-----------|
|
|
21
|
+
* | 0x0 | INTERNAL_ERROR | INTERNAL_ERROR | INTERNAL_ERROR |
|
|
22
|
+
* | 0x1 | CANCELLED | CANCELLED | CANCELLED |
|
|
23
|
+
* | 0x2 | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT |
|
|
24
|
+
* | 0x3 | SESSION_CLOSED | SESSION_CLOSED | SESSION_CLOSED |
|
|
25
|
+
* | 0x4 | - | UNKNOWN_OBJECT_STATUS | GOING_AWAY |
|
|
26
|
+
* | 0x5 | - | TOO_FAR_BEHIND (17) | TOO_FAR_BEHIND |
|
|
27
|
+
* | 0x12 | - | MALFORMED_TRACK | MALFORMED_TRACK |
|
|
28
|
+
*
|
|
29
|
+
* So GOING_AWAY sent to a draft-17 peer reads as UNKNOWN_OBJECT_STATUS, and that peer's
|
|
30
|
+
* UNKNOWN_OBJECT_STATUS read as GOING_AWAY would retire a session that is not going
|
|
31
|
+
* anywhere. Anything this says `false` about is sent as, and read as, INTERNAL_ERROR: the
|
|
32
|
+
* codes moq-lite assigns in its own 48-63 range, and the ones the draft assigns that
|
|
33
|
+
* moq-lite has no name for (UNKNOWN_OBJECT_STATUS, EXPIRED_AUTH_TOKEN, EXCESSIVE_LOAD).
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export function sharedStreamCode(code, version) {
|
|
38
|
+
switch (code) {
|
|
39
|
+
case 0x0:
|
|
40
|
+
case 0x1:
|
|
41
|
+
case 0x2:
|
|
42
|
+
case 0x3:
|
|
43
|
+
return true;
|
|
44
|
+
// Draft-16 and 17 give 0x4 to UNKNOWN_OBJECT_STATUS, which draft-18 moved to 0x6 when
|
|
45
|
+
// it took 0x4 for GOING_AWAY. Draft-14 and 15 assign it nothing.
|
|
46
|
+
case 0x4:
|
|
47
|
+
return version >= Version.DRAFT_18;
|
|
48
|
+
// TOO_FAR_BEHIND arrived in draft-17.
|
|
49
|
+
case 0x5:
|
|
50
|
+
return version >= Version.DRAFT_17;
|
|
51
|
+
// MALFORMED_TRACK arrived in draft-16.
|
|
52
|
+
case 0x12:
|
|
53
|
+
return version >= Version.DRAFT_16;
|
|
54
|
+
default:
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** An implementation-specific error. Assigned by every draft, for every request. */
|
|
59
|
+
const INTERNAL_ERROR = 0x0;
|
|
60
|
+
const UNAUTHORIZED = 0x1;
|
|
61
|
+
const TIMEOUT = 0x2;
|
|
62
|
+
const NOT_SUPPORTED = 0x3;
|
|
63
|
+
/** A draining session. Draft-17 and later. */
|
|
64
|
+
const GOING_AWAY = 0x6;
|
|
65
|
+
/** FETCH-only errors. INVALID_JOINING_REQUEST_ID was removed in draft-20. */
|
|
66
|
+
const INVALID_RANGE_14 = 0x5;
|
|
67
|
+
const INVALID_RANGE = 0x11;
|
|
68
|
+
const INVALID_JOINING_REQUEST_ID_14 = 0x7;
|
|
69
|
+
const INVALID_JOINING_REQUEST_ID = 0x32;
|
|
70
|
+
function invalidRange(kind, version) {
|
|
71
|
+
if (kind !== "fetch")
|
|
72
|
+
return undefined;
|
|
73
|
+
return version === Version.DRAFT_14 ? INVALID_RANGE_14 : INVALID_RANGE;
|
|
74
|
+
}
|
|
75
|
+
function invalidJoiningRequestId(kind, version) {
|
|
76
|
+
if (kind !== "fetch")
|
|
77
|
+
return undefined;
|
|
78
|
+
if (version === Version.DRAFT_14)
|
|
79
|
+
return INVALID_JOINING_REQUEST_ID_14;
|
|
80
|
+
return version <= Version.DRAFT_19 ? INVALID_JOINING_REQUEST_ID : undefined;
|
|
81
|
+
}
|
|
82
|
+
/** Draft-14 calls it TRACK_DOES_NOT_EXIST; draft-15 renamed it and moved it off 0x4. */
|
|
83
|
+
const DOES_NOT_EXIST_14 = 0x4;
|
|
84
|
+
const DOES_NOT_EXIST = 0x10;
|
|
85
|
+
/** Draft-14 assigns UNINTERESTED only to the two requests that offer content. */
|
|
86
|
+
const UNINTERESTED_14 = 0x4;
|
|
87
|
+
const UNINTERESTED = 0x20;
|
|
88
|
+
/** Draft-14 assigns MALFORMED_TRACK to FETCH_ERROR only. */
|
|
89
|
+
const MALFORMED_TRACK_14 = 0x9;
|
|
90
|
+
const MALFORMED_TRACK = 0x12;
|
|
91
|
+
/** The value for "the thing you asked for is not here", or undefined where none is assigned. */
|
|
92
|
+
function doesNotExist(kind, version) {
|
|
93
|
+
if (version !== Version.DRAFT_14)
|
|
94
|
+
return DOES_NOT_EXIST;
|
|
95
|
+
return kind === "subscribe" || kind === "fetch" || kind === "track_status" ? DOES_NOT_EXIST_14 : undefined;
|
|
96
|
+
}
|
|
97
|
+
/** The value for "we do not want this", or undefined where none is assigned. */
|
|
98
|
+
function uninterested(kind, version) {
|
|
99
|
+
if (version !== Version.DRAFT_14)
|
|
100
|
+
return UNINTERESTED;
|
|
101
|
+
return kind === "publish" || kind === "publish_namespace" ? UNINTERESTED_14 : undefined;
|
|
102
|
+
}
|
|
103
|
+
/** The value for a track we could not parse, or undefined where none is assigned. */
|
|
104
|
+
function malformedTrack(kind, version) {
|
|
105
|
+
if (version !== Version.DRAFT_14)
|
|
106
|
+
return MALFORMED_TRACK;
|
|
107
|
+
return kind === "fetch" ? MALFORMED_TRACK_14 : undefined;
|
|
108
|
+
}
|
|
109
|
+
/** The value for a draining session, or undefined before draft-17 registered one. */
|
|
110
|
+
function goingAway(version) {
|
|
111
|
+
return version >= Version.DRAFT_17 ? GOING_AWAY : undefined;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The code to reject a request with, on the negotiated draft.
|
|
115
|
+
*
|
|
116
|
+
* A condition the draft does not register for this request falls back to INTERNAL_ERROR
|
|
117
|
+
* rather than borrowing a number from another draft, which would say something the peer's
|
|
118
|
+
* registry gives a different meaning. The renumbering is the trap: draft-14 SUBSCRIBE_ERROR
|
|
119
|
+
* gives 0x4 to TRACK_DOES_NOT_EXIST and 0x10 to MALFORMED_AUTH_TOKEN, and draft-15 swaps
|
|
120
|
+
* the two.
|
|
121
|
+
*
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
export function toRequestCode(condition, kind, version) {
|
|
125
|
+
switch (condition) {
|
|
126
|
+
case "internal":
|
|
127
|
+
return INTERNAL_ERROR;
|
|
128
|
+
case "unauthorized":
|
|
129
|
+
return UNAUTHORIZED;
|
|
130
|
+
case "timeout":
|
|
131
|
+
return TIMEOUT;
|
|
132
|
+
case "not_supported":
|
|
133
|
+
return NOT_SUPPORTED;
|
|
134
|
+
case "invalid_range":
|
|
135
|
+
return invalidRange(kind, version) ?? INTERNAL_ERROR;
|
|
136
|
+
case "invalid_joining_request_id":
|
|
137
|
+
return invalidJoiningRequestId(kind, version) ?? INTERNAL_ERROR;
|
|
138
|
+
case "does_not_exist":
|
|
139
|
+
return doesNotExist(kind, version) ?? INTERNAL_ERROR;
|
|
140
|
+
// A subscriber that asked for content cannot act on "we do not want it": what it needs
|
|
141
|
+
// to know is that we do not have it, which is the same refusal from its side. Only the
|
|
142
|
+
// requests that offer content say UNINTERESTED.
|
|
143
|
+
case "uninterested":
|
|
144
|
+
return kind === "subscribe" || kind === "fetch" || kind === "track_status"
|
|
145
|
+
? (doesNotExist(kind, version) ?? INTERNAL_ERROR)
|
|
146
|
+
: (uninterested(kind, version) ?? INTERNAL_ERROR);
|
|
147
|
+
case "malformed_track":
|
|
148
|
+
return malformedTrack(kind, version) ?? INTERNAL_ERROR;
|
|
149
|
+
case "going_away":
|
|
150
|
+
return goingAway(version) ?? INTERNAL_ERROR;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Read a rejection code received on the negotiated draft.
|
|
155
|
+
*
|
|
156
|
+
* A code the draft does not assign for this request, INTERNAL_ERROR included, is
|
|
157
|
+
* `undefined`: an error, but never one given a meaning it did not carry.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
export function fromRequestCode(code, kind, version) {
|
|
162
|
+
switch (code) {
|
|
163
|
+
case UNAUTHORIZED:
|
|
164
|
+
return "unauthorized";
|
|
165
|
+
case TIMEOUT:
|
|
166
|
+
return "timeout";
|
|
167
|
+
case NOT_SUPPORTED:
|
|
168
|
+
return "not_supported";
|
|
169
|
+
}
|
|
170
|
+
if (code === doesNotExist(kind, version))
|
|
171
|
+
return "does_not_exist";
|
|
172
|
+
if (code === invalidRange(kind, version))
|
|
173
|
+
return "invalid_range";
|
|
174
|
+
if (code === invalidJoiningRequestId(kind, version))
|
|
175
|
+
return "invalid_joining_request_id";
|
|
176
|
+
if (code === uninterested(kind, version))
|
|
177
|
+
return "uninterested";
|
|
178
|
+
if (code === malformedTrack(kind, version))
|
|
179
|
+
return "malformed_track";
|
|
180
|
+
if (code === goingAway(version))
|
|
181
|
+
return "going_away";
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Describe a rejection a peer sent, naming the condition when the draft registers one.
|
|
186
|
+
*
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
export function requestReason(code, reasonPhrase, kind, version) {
|
|
190
|
+
const condition = fromRequestCode(code, kind, version) ?? "unregistered";
|
|
191
|
+
return `${condition} (code=${code}) ${reasonPhrase}`;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/ietf/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAoB,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAoB;IAClE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACP,OAAO,IAAI,CAAC;QACb,sFAAsF;QACtF,iEAAiE;QACjE,KAAK,GAAG;YACP,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC,sCAAsC;QACtC,KAAK,GAAG;YACP,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC,uCAAuC;QACvC,KAAK,IAAI;YACR,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;QACpC;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC;AA+CD,oFAAoF;AACpF,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,8CAA8C;AAC9C,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,6EAA6E;AAC7E,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,0BAA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O,GAAG,SAAS,UAAU,IAAI,KAAK,YAAY,EAAE,CAAC;AACtD,CAAC","sourcesContent":["/**\n * The moq-transport error code registries, per negotiated draft.\n *\n * A code only means something once you know which draft carried it: the registries grew,\n * moved values, and in draft-15 collapsed five per-message tables into one. Mirrors the\n * Rust `moq_net::ietf::error` module, and the two have to agree value for value.\n *\n * @module\n */\n\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * Whether `code` means the same thing in the negotiated draft's stream reset registry as it\n * does in moq-lite's.\n *\n * The two registries agree on most of what they both assign, but this one grew across the\n * drafts we negotiate and moved a value on the way:\n *\n * | Code | draft-14/15 | draft-16/17 | draft-18+ |\n * |------|-------------|-------------|-----------|\n * | 0x0 | INTERNAL_ERROR | INTERNAL_ERROR | INTERNAL_ERROR |\n * | 0x1 | CANCELLED | CANCELLED | CANCELLED |\n * | 0x2 | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT | DELIVERY_TIMEOUT |\n * | 0x3 | SESSION_CLOSED | SESSION_CLOSED | SESSION_CLOSED |\n * | 0x4 | - | UNKNOWN_OBJECT_STATUS | GOING_AWAY |\n * | 0x5 | - | TOO_FAR_BEHIND (17) | TOO_FAR_BEHIND |\n * | 0x12 | - | MALFORMED_TRACK | MALFORMED_TRACK |\n *\n * So GOING_AWAY sent to a draft-17 peer reads as UNKNOWN_OBJECT_STATUS, and that peer's\n * UNKNOWN_OBJECT_STATUS read as GOING_AWAY would retire a session that is not going\n * anywhere. Anything this says `false` about is sent as, and read as, INTERNAL_ERROR: the\n * codes moq-lite assigns in its own 48-63 range, and the ones the draft assigns that\n * moq-lite has no name for (UNKNOWN_OBJECT_STATUS, EXPIRED_AUTH_TOKEN, EXCESSIVE_LOAD).\n *\n * @internal\n */\nexport function sharedStreamCode(code: number, version: IetfVersion): boolean {\n\tswitch (code) {\n\t\tcase 0x0:\n\t\tcase 0x1:\n\t\tcase 0x2:\n\t\tcase 0x3:\n\t\t\treturn true;\n\t\t// Draft-16 and 17 give 0x4 to UNKNOWN_OBJECT_STATUS, which draft-18 moved to 0x6 when\n\t\t// it took 0x4 for GOING_AWAY. Draft-14 and 15 assign it nothing.\n\t\tcase 0x4:\n\t\t\treturn version >= Version.DRAFT_18;\n\t\t// TOO_FAR_BEHIND arrived in draft-17.\n\t\tcase 0x5:\n\t\t\treturn version >= Version.DRAFT_17;\n\t\t// MALFORMED_TRACK arrived in draft-16.\n\t\tcase 0x12:\n\t\t\treturn version >= Version.DRAFT_16;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Which request a rejection answers, so draft-14 picks the right registry.\n *\n * Draft-14 gives each error message its own registry and they disagree about 0x4; draft-15\n * folded them all into REQUEST_ERROR with a single registry, so from there on the kind\n * changes nothing.\n *\n * @internal\n */\nexport type RequestKind =\n\t| \"subscribe\"\n\t| \"fetch\"\n\t| \"publish\"\n\t| \"publish_namespace\"\n\t| \"subscribe_namespace\"\n\t| \"track_status\";\n\n/**\n * What a rejection reports, before the draft picks the number for it.\n *\n * Named separately from the wire code because a rejection says less than a failure does: a\n * dozen local errors are one INTERNAL_ERROR on the wire.\n *\n * @internal\n */\nexport type RequestCondition =\n\t/** Something went wrong that the registry has no value for. */\n\t| \"internal\"\n\t/** The peer's credentials do not cover the request. */\n\t| \"unauthorized\"\n\t/** The request outlived an implementation-specific deadline. */\n\t| \"timeout\"\n\t/** This endpoint does not implement the request at all. */\n\t| \"not_supported\"\n\t/** The broadcast or track the peer asked for is not here. */\n\t| \"invalid_range\"\n\t| \"invalid_joining_request_id\"\n\t| \"does_not_exist\"\n\t/** The content the peer offered is not wanted here, so it should stop offering it. */\n\t| \"uninterested\"\n\t/** The track's content could not be parsed. */\n\t| \"malformed_track\"\n\t/** A GOAWAY is draining the session, so no new request is accepted. */\n\t| \"going_away\";\n\n/** An implementation-specific error. Assigned by every draft, for every request. */\nconst INTERNAL_ERROR = 0x0;\nconst UNAUTHORIZED = 0x1;\nconst TIMEOUT = 0x2;\nconst NOT_SUPPORTED = 0x3;\n\n/** A draining session. Draft-17 and later. */\nconst GOING_AWAY = 0x6;\n\n/** FETCH-only errors. INVALID_JOINING_REQUEST_ID was removed in draft-20. */\nconst INVALID_RANGE_14 = 0x5;\nconst INVALID_RANGE = 0x11;\nconst INVALID_JOINING_REQUEST_ID_14 = 0x7;\nconst INVALID_JOINING_REQUEST_ID = 0x32;\n\nfunction invalidRange(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (kind !== \"fetch\") return undefined;\n\treturn version === Version.DRAFT_14 ? INVALID_RANGE_14 : INVALID_RANGE;\n}\n\nfunction invalidJoiningRequestId(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (kind !== \"fetch\") return undefined;\n\tif (version === Version.DRAFT_14) return INVALID_JOINING_REQUEST_ID_14;\n\treturn version <= Version.DRAFT_19 ? INVALID_JOINING_REQUEST_ID : undefined;\n}\n\n/** Draft-14 calls it TRACK_DOES_NOT_EXIST; draft-15 renamed it and moved it off 0x4. */\nconst DOES_NOT_EXIST_14 = 0x4;\nconst DOES_NOT_EXIST = 0x10;\n\n/** Draft-14 assigns UNINTERESTED only to the two requests that offer content. */\nconst UNINTERESTED_14 = 0x4;\nconst UNINTERESTED = 0x20;\n\n/** Draft-14 assigns MALFORMED_TRACK to FETCH_ERROR only. */\nconst MALFORMED_TRACK_14 = 0x9;\nconst MALFORMED_TRACK = 0x12;\n\n/** The value for \"the thing you asked for is not here\", or undefined where none is assigned. */\nfunction doesNotExist(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return DOES_NOT_EXIST;\n\treturn kind === \"subscribe\" || kind === \"fetch\" || kind === \"track_status\" ? DOES_NOT_EXIST_14 : undefined;\n}\n\n/** The value for \"we do not want this\", or undefined where none is assigned. */\nfunction uninterested(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return UNINTERESTED;\n\treturn kind === \"publish\" || kind === \"publish_namespace\" ? UNINTERESTED_14 : undefined;\n}\n\n/** The value for a track we could not parse, or undefined where none is assigned. */\nfunction malformedTrack(kind: RequestKind, version: IetfVersion): number | undefined {\n\tif (version !== Version.DRAFT_14) return MALFORMED_TRACK;\n\treturn kind === \"fetch\" ? MALFORMED_TRACK_14 : undefined;\n}\n\n/** The value for a draining session, or undefined before draft-17 registered one. */\nfunction goingAway(version: IetfVersion): number | undefined {\n\treturn version >= Version.DRAFT_17 ? GOING_AWAY : undefined;\n}\n\n/**\n * The code to reject a request with, on the negotiated draft.\n *\n * A condition the draft does not register for this request falls back to INTERNAL_ERROR\n * rather than borrowing a number from another draft, which would say something the peer's\n * registry gives a different meaning. The renumbering is the trap: draft-14 SUBSCRIBE_ERROR\n * gives 0x4 to TRACK_DOES_NOT_EXIST and 0x10 to MALFORMED_AUTH_TOKEN, and draft-15 swaps\n * the two.\n *\n * @internal\n */\nexport function toRequestCode(condition: RequestCondition, kind: RequestKind, version: IetfVersion): number {\n\tswitch (condition) {\n\t\tcase \"internal\":\n\t\t\treturn INTERNAL_ERROR;\n\t\tcase \"unauthorized\":\n\t\t\treturn UNAUTHORIZED;\n\t\tcase \"timeout\":\n\t\t\treturn TIMEOUT;\n\t\tcase \"not_supported\":\n\t\t\treturn NOT_SUPPORTED;\n\t\tcase \"invalid_range\":\n\t\t\treturn invalidRange(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"invalid_joining_request_id\":\n\t\t\treturn invalidJoiningRequestId(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"does_not_exist\":\n\t\t\treturn doesNotExist(kind, version) ?? INTERNAL_ERROR;\n\t\t// A subscriber that asked for content cannot act on \"we do not want it\": what it needs\n\t\t// to know is that we do not have it, which is the same refusal from its side. Only the\n\t\t// requests that offer content say UNINTERESTED.\n\t\tcase \"uninterested\":\n\t\t\treturn kind === \"subscribe\" || kind === \"fetch\" || kind === \"track_status\"\n\t\t\t\t? (doesNotExist(kind, version) ?? INTERNAL_ERROR)\n\t\t\t\t: (uninterested(kind, version) ?? INTERNAL_ERROR);\n\t\tcase \"malformed_track\":\n\t\t\treturn malformedTrack(kind, version) ?? INTERNAL_ERROR;\n\t\tcase \"going_away\":\n\t\t\treturn goingAway(version) ?? INTERNAL_ERROR;\n\t}\n}\n\n/**\n * Read a rejection code received on the negotiated draft.\n *\n * A code the draft does not assign for this request, INTERNAL_ERROR included, is\n * `undefined`: an error, but never one given a meaning it did not carry.\n *\n * @internal\n */\nexport function fromRequestCode(code: number, kind: RequestKind, version: IetfVersion): RequestCondition | undefined {\n\tswitch (code) {\n\t\tcase UNAUTHORIZED:\n\t\t\treturn \"unauthorized\";\n\t\tcase TIMEOUT:\n\t\t\treturn \"timeout\";\n\t\tcase NOT_SUPPORTED:\n\t\t\treturn \"not_supported\";\n\t}\n\n\tif (code === doesNotExist(kind, version)) return \"does_not_exist\";\n\tif (code === invalidRange(kind, version)) return \"invalid_range\";\n\tif (code === invalidJoiningRequestId(kind, version)) return \"invalid_joining_request_id\";\n\tif (code === uninterested(kind, version)) return \"uninterested\";\n\tif (code === malformedTrack(kind, version)) return \"malformed_track\";\n\tif (code === goingAway(version)) return \"going_away\";\n\treturn undefined;\n}\n\n/**\n * Describe a rejection a peer sent, naming the condition when the draft registers one.\n *\n * @internal\n */\nexport function requestReason(code: number, reasonPhrase: string, kind: RequestKind, version: IetfVersion): string {\n\tconst condition = fromRequestCode(code, kind, version) ?? \"unregistered\";\n\treturn `${condition} (code=${code}) ${reasonPhrase}`;\n}\n"]}
|
package/ietf/fetch.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type * as Path from "../path";
|
|
2
1
|
import type { Reader, Writer } from "../stream";
|
|
3
|
-
import type
|
|
2
|
+
import { type IetfVersion } from "./version";
|
|
4
3
|
/**
|
|
5
4
|
* The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it
|
|
6
5
|
* answers. Written by the publisher when serving a subscription's fill.
|
|
@@ -18,31 +17,19 @@ export declare class FetchHeader {
|
|
|
18
17
|
/** Read the header, with the stream type already consumed. */
|
|
19
18
|
static decode(r: Reader, _version: IetfVersion): Promise<FetchHeader>;
|
|
20
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* A FETCH request. We serve none, so only what a refusal needs is kept; the rest is
|
|
22
|
+
* decoded so a legal request is refused rather than breaking the stream.
|
|
23
|
+
*/
|
|
21
24
|
export declare class Fetch {
|
|
22
25
|
#private;
|
|
23
26
|
static id: number;
|
|
24
27
|
requestId: bigint;
|
|
25
|
-
|
|
26
|
-
trackName: string;
|
|
27
|
-
subscriberPriority: number;
|
|
28
|
-
groupOrder: number;
|
|
29
|
-
startGroup: bigint;
|
|
30
|
-
startObject: bigint;
|
|
31
|
-
endGroup: bigint;
|
|
32
|
-
endObject: bigint;
|
|
33
|
-
constructor({ requestId, trackNamespace, trackName, subscriberPriority, groupOrder, startGroup, startObject, endGroup, endObject, }: {
|
|
28
|
+
constructor({ requestId }: {
|
|
34
29
|
requestId: bigint;
|
|
35
|
-
trackNamespace: Path.Valid;
|
|
36
|
-
trackName: string;
|
|
37
|
-
subscriberPriority: number;
|
|
38
|
-
groupOrder: number;
|
|
39
|
-
startGroup: bigint;
|
|
40
|
-
startObject: bigint;
|
|
41
|
-
endGroup: bigint;
|
|
42
|
-
endObject: bigint;
|
|
43
30
|
});
|
|
44
31
|
encode(w: Writer, _version: IetfVersion): Promise<void>;
|
|
45
|
-
static decode(r: Reader,
|
|
32
|
+
static decode(r: Reader, version: IetfVersion): Promise<Fetch>;
|
|
46
33
|
}
|
|
47
34
|
export declare class FetchOk {
|
|
48
35
|
#private;
|
package/ietf/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAA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AQ,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAEtE;CAKD;AAED,qBAAa,UAAU;;IACtB,MAAM,CAAC,EAAE,SAAQ;IAEjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAErB,YAAY,EACX,SAAS,EACT,SAAS,EACT,YAAY,GACZ,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,EAIhE;IAMK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAEzE;CAKD;AAGD,qBAAa,WAAW;;IACvB,MAAM,CAAC,EAAE,SAAQ;IAEjB,SAAS,EAAE,MAAM,CAAC;IAElB,YAAY,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAE/C;IAMK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAE1E;CAKD"}
|
package/ietf/fetch.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/* @ts-self-types="./fetch.d.ts" */
|
|
2
|
+
import { hasRangeFilters, isDraft20 } from "./filter.js";
|
|
2
3
|
import * as Message from "./message.js";
|
|
4
|
+
import * as Namespace from "./namespace.js";
|
|
5
|
+
import { Parameters } from "./parameters.js";
|
|
6
|
+
import { Version } from "./version.js";
|
|
3
7
|
/**
|
|
4
8
|
* The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it
|
|
5
9
|
* answers. Written by the publisher when serving a subscription's fill.
|
|
@@ -21,27 +25,15 @@ export class FetchHeader {
|
|
|
21
25
|
return new FetchHeader({ requestId: await r.u62() });
|
|
22
26
|
}
|
|
23
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A FETCH request. We serve none, so only what a refusal needs is kept; the rest is
|
|
30
|
+
* decoded so a legal request is refused rather than breaking the stream.
|
|
31
|
+
*/
|
|
24
32
|
export class Fetch {
|
|
25
33
|
static id = 0x16;
|
|
26
34
|
requestId;
|
|
27
|
-
|
|
28
|
-
trackName;
|
|
29
|
-
subscriberPriority;
|
|
30
|
-
groupOrder;
|
|
31
|
-
startGroup;
|
|
32
|
-
startObject;
|
|
33
|
-
endGroup;
|
|
34
|
-
endObject;
|
|
35
|
-
constructor({ requestId, trackNamespace, trackName, subscriberPriority, groupOrder, startGroup, startObject, endGroup, endObject, }) {
|
|
35
|
+
constructor({ requestId }) {
|
|
36
36
|
this.requestId = requestId;
|
|
37
|
-
this.trackNamespace = trackNamespace;
|
|
38
|
-
this.trackName = trackName;
|
|
39
|
-
this.subscriberPriority = subscriberPriority;
|
|
40
|
-
this.groupOrder = groupOrder;
|
|
41
|
-
this.startGroup = startGroup;
|
|
42
|
-
this.startObject = startObject;
|
|
43
|
-
this.endGroup = endGroup;
|
|
44
|
-
this.endObject = endObject;
|
|
45
37
|
}
|
|
46
38
|
async #encode(_w) {
|
|
47
39
|
throw new Error("FETCH messages are not supported");
|
|
@@ -49,11 +41,49 @@ export class Fetch {
|
|
|
49
41
|
async encode(w, _version) {
|
|
50
42
|
return Message.encode(w, this.#encode.bind(this));
|
|
51
43
|
}
|
|
52
|
-
static async decode(r,
|
|
53
|
-
return Message.decode(r, Fetch.#decode);
|
|
54
|
-
}
|
|
55
|
-
static async #decode(
|
|
56
|
-
|
|
44
|
+
static async decode(r, version) {
|
|
45
|
+
return Message.decode(r, (mr) => Fetch.#decode(mr, version));
|
|
46
|
+
}
|
|
47
|
+
static async #decode(r, version) {
|
|
48
|
+
const requestId = await r.u62();
|
|
49
|
+
if (version === Version.DRAFT_17) {
|
|
50
|
+
await r.u62(); // required_request_id_delta
|
|
51
|
+
}
|
|
52
|
+
if (version === Version.DRAFT_14) {
|
|
53
|
+
await r.u8(); // subscriber_priority
|
|
54
|
+
await r.u8(); // group_order
|
|
55
|
+
}
|
|
56
|
+
if (isDraft20(version)) {
|
|
57
|
+
// Draft-20 names the track up front and moves the range into LOCATION_FILTER.
|
|
58
|
+
await Namespace.decode(r);
|
|
59
|
+
await r.string();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const fetchType = await r.u53();
|
|
63
|
+
switch (fetchType) {
|
|
64
|
+
case 0x1: // Standalone: namespace, name, start and end Locations
|
|
65
|
+
await Namespace.decode(r);
|
|
66
|
+
await r.string();
|
|
67
|
+
for (let i = 0; i < 4; i++)
|
|
68
|
+
await r.u62();
|
|
69
|
+
break;
|
|
70
|
+
case 0x2: // Relative Joining: subscription, group offset
|
|
71
|
+
case 0x3: // Absolute Joining: subscription, group
|
|
72
|
+
await r.u62();
|
|
73
|
+
await r.u62();
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
throw new Error(`unknown fetch type: ${fetchType}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const params = await Parameters.decode(r, version);
|
|
80
|
+
if (params.rangeFilters && !hasRangeFilters(version)) {
|
|
81
|
+
throw new Error("Range Filters need draft-19");
|
|
82
|
+
}
|
|
83
|
+
if (params.trackPropertyFilter) {
|
|
84
|
+
throw new Error("TRACK_PROPERTY_FILTER is not allowed on FETCH");
|
|
85
|
+
}
|
|
86
|
+
return new Fetch({ requestId });
|
|
57
87
|
}
|
|
58
88
|
}
|
|
59
89
|
export class FetchOk {
|
package/ietf/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/ietf/fetch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,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QAC5C,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QACnD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import type * as Path from \"../path.ts\";\nimport type { Reader, Writer } from \"../stream.ts\";\nimport * as Message from \"./message.ts\";\nimport type { IetfVersion } from \"./version.ts\";\n\n/**\n * The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it\n * answers. Written by the publisher when serving a subscription's fill.\n */\nexport class FetchHeader {\n\t/** The uni stream type, not a control message id. */\n\tstatic type = 0x5;\n\n\t/** The SUBSCRIBE (or FETCH) request this stream carries objects for. */\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\t/** Write the header, which the stream type must already precede. */\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\tawait w.u62(this.requestId);\n\t}\n\n\t/** Read the header, with the stream type already consumed. */\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchHeader> {\n\t\treturn new FetchHeader({ requestId: await r.u62() });\n\t}\n}\n\nexport class Fetch {\n\tstatic id = 0x16;\n\n\trequestId: bigint;\n\ttrackNamespace: Path.Valid;\n\ttrackName: string;\n\tsubscriberPriority: number;\n\tgroupOrder: number;\n\tstartGroup: bigint;\n\tstartObject: bigint;\n\tendGroup: bigint;\n\tendObject: bigint;\n\n\tconstructor({\n\t\trequestId,\n\t\ttrackNamespace,\n\t\ttrackName,\n\t\tsubscriberPriority,\n\t\tgroupOrder,\n\t\tstartGroup,\n\t\tstartObject,\n\t\tendGroup,\n\t\tendObject,\n\t}: {\n\t\trequestId: bigint;\n\t\ttrackNamespace: Path.Valid;\n\t\ttrackName: string;\n\t\tsubscriberPriority: number;\n\t\tgroupOrder: number;\n\t\tstartGroup: bigint;\n\t\tstartObject: bigint;\n\t\tendGroup: bigint;\n\t\tendObject: bigint;\n\t}) {\n\t\tthis.requestId = requestId;\n\t\tthis.trackNamespace = trackNamespace;\n\t\tthis.trackName = trackName;\n\t\tthis.subscriberPriority = subscriberPriority;\n\t\tthis.groupOrder = groupOrder;\n\t\tthis.startGroup = startGroup;\n\t\tthis.startObject = startObject;\n\t\tthis.endGroup = endGroup;\n\t\tthis.endObject = endObject;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<Fetch> {\n\t\treturn Message.decode(r, Fetch.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<Fetch> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n}\n\nexport class FetchOk {\n\tstatic id = 0x18;\n\n\trequestId: bigint | undefined;\n\n\tconstructor({ requestId }: { requestId?: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchOk> {\n\t\treturn Message.decode(r, FetchOk.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchOk> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n}\n\nexport class FetchError {\n\tstatic id = 0x19;\n\n\trequestId: bigint;\n\terrorCode: number;\n\treasonPhrase: string;\n\n\tconstructor({\n\t\trequestId,\n\t\terrorCode,\n\t\treasonPhrase,\n\t}: { requestId: bigint; errorCode: number; reasonPhrase: string }) {\n\t\tthis.requestId = requestId;\n\t\tthis.errorCode = errorCode;\n\t\tthis.reasonPhrase = reasonPhrase;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchError> {\n\t\treturn Message.decode(r, FetchError.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchError> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n}\n\n// Removed in d17\nexport class FetchCancel {\n\tstatic id = 0x17;\n\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchCancel> {\n\t\treturn Message.decode(r, FetchCancel.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchCancel> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/ietf/fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAA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AE,QAAqB;QAC5C,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,QAAqB;QACnD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU;QAC9B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import type { Reader, Writer } from \"../stream.ts\";\nimport { hasRangeFilters, isDraft20 } from \"./filter.ts\";\nimport * as Message from \"./message.ts\";\nimport * as Namespace from \"./namespace.ts\";\nimport { Parameters } from \"./parameters.ts\";\nimport { type IetfVersion, Version } from \"./version.ts\";\n\n/**\n * The header that begins a fetch stream (draft-20 section 11.4.4), naming the request it\n * answers. Written by the publisher when serving a subscription's fill.\n */\nexport class FetchHeader {\n\t/** The uni stream type, not a control message id. */\n\tstatic type = 0x5;\n\n\t/** The SUBSCRIBE (or FETCH) request this stream carries objects for. */\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\t/** Write the header, which the stream type must already precede. */\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\tawait w.u62(this.requestId);\n\t}\n\n\t/** Read the header, with the stream type already consumed. */\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchHeader> {\n\t\treturn new FetchHeader({ requestId: await r.u62() });\n\t}\n}\n\n/**\n * A FETCH request. We serve none, so only what a refusal needs is kept; the rest is\n * decoded so a legal request is refused rather than breaking the stream.\n */\nexport class Fetch {\n\tstatic id = 0x16;\n\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, version: IetfVersion): Promise<Fetch> {\n\t\treturn Message.decode(r, (mr) => Fetch.#decode(mr, version));\n\t}\n\n\tstatic async #decode(r: Reader, version: IetfVersion): Promise<Fetch> {\n\t\tconst requestId = await r.u62();\n\t\tif (version === Version.DRAFT_17) {\n\t\t\tawait r.u62(); // required_request_id_delta\n\t\t}\n\n\t\tif (version === Version.DRAFT_14) {\n\t\t\tawait r.u8(); // subscriber_priority\n\t\t\tawait r.u8(); // group_order\n\t\t}\n\n\t\tif (isDraft20(version)) {\n\t\t\t// Draft-20 names the track up front and moves the range into LOCATION_FILTER.\n\t\t\tawait Namespace.decode(r);\n\t\t\tawait r.string();\n\t\t} else {\n\t\t\tconst fetchType = await r.u53();\n\t\t\tswitch (fetchType) {\n\t\t\t\tcase 0x1: // Standalone: namespace, name, start and end Locations\n\t\t\t\t\tawait Namespace.decode(r);\n\t\t\t\t\tawait r.string();\n\t\t\t\t\tfor (let i = 0; i < 4; i++) await r.u62();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x2: // Relative Joining: subscription, group offset\n\t\t\t\tcase 0x3: // Absolute Joining: subscription, group\n\t\t\t\t\tawait r.u62();\n\t\t\t\t\tawait r.u62();\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`unknown fetch type: ${fetchType}`);\n\t\t\t}\n\t\t}\n\n\t\tconst params = await Parameters.decode(r, version);\n\t\tif (params.rangeFilters && !hasRangeFilters(version)) {\n\t\t\tthrow new Error(\"Range Filters need draft-19\");\n\t\t}\n\t\tif (params.trackPropertyFilter) {\n\t\t\tthrow new Error(\"TRACK_PROPERTY_FILTER is not allowed on FETCH\");\n\t\t}\n\n\t\treturn new Fetch({ requestId });\n\t}\n}\n\nexport class FetchOk {\n\tstatic id = 0x18;\n\n\trequestId: bigint | undefined;\n\n\tconstructor({ requestId }: { requestId?: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchOk> {\n\t\treturn Message.decode(r, FetchOk.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchOk> {\n\t\tthrow new Error(\"FETCH_OK messages are not supported\");\n\t}\n}\n\nexport class FetchError {\n\tstatic id = 0x19;\n\n\trequestId: bigint;\n\terrorCode: number;\n\treasonPhrase: string;\n\n\tconstructor({\n\t\trequestId,\n\t\terrorCode,\n\t\treasonPhrase,\n\t}: { requestId: bigint; errorCode: number; reasonPhrase: string }) {\n\t\tthis.requestId = requestId;\n\t\tthis.errorCode = errorCode;\n\t\tthis.reasonPhrase = reasonPhrase;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchError> {\n\t\treturn Message.decode(r, FetchError.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchError> {\n\t\tthrow new Error(\"FETCH_ERROR messages are not supported\");\n\t}\n}\n\n// Removed in d17\nexport class FetchCancel {\n\tstatic id = 0x17;\n\n\trequestId: bigint;\n\n\tconstructor({ requestId }: { requestId: bigint }) {\n\t\tthis.requestId = requestId;\n\t}\n\n\tasync #encode(_w: Writer): Promise<void> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n\n\tasync encode(w: Writer, _version: IetfVersion): Promise<void> {\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, _version: IetfVersion): Promise<FetchCancel> {\n\t\treturn Message.decode(r, FetchCancel.#decode);\n\t}\n\n\tstatic async #decode(_r: Reader): Promise<FetchCancel> {\n\t\tthrow new Error(\"FETCH_CANCEL messages are not supported\");\n\t}\n}\n"]}
|
package/ietf/filter.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export type Filter =
|
|
|
41
41
|
* present selects the meaning.
|
|
42
42
|
*/
|
|
43
43
|
export declare function isDraft20(version: IetfVersion): boolean;
|
|
44
|
+
/** Whether the Range Filters (draft-19) exist on this draft. */
|
|
45
|
+
export declare function hasRangeFilters(version: IetfVersion): boolean;
|
|
44
46
|
/** Encode a filter as its raw parameter value. Unfiltered encodes to zero bytes. */
|
|
45
47
|
export declare function encode(filter: Filter, version: IetfVersion): Uint8Array;
|
|
46
48
|
/** Decode a filter from its raw parameter value. */
|
package/ietf/filter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/ietf/filter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,cAAc,CAAC;AAEzD,6CAA6C;AAC7C,MAAM,MAAM,MAAM;AACjB,oEAAoE;AAClE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE;AACxB,sEAAsE;GACpE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE;AACxB;;;GAGG;GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACtC;;;GAGG;GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QA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C,MAAM,CAAC,CAkB7D;AAQD;;;;;;;GAOG;AACH,MAAM,WAAW,IAAI;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;CACtB;AAmCD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,UAAU,CAYvE;AAED,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAyDvE"}
|
package/ietf/filter.js
CHANGED
|
@@ -18,7 +18,16 @@ const TAG_ABSOLUTE_RANGE = 0x4n;
|
|
|
18
18
|
* present selects the meaning.
|
|
19
19
|
*/
|
|
20
20
|
export function isDraft20(version) {
|
|
21
|
-
return version
|
|
21
|
+
return (version !== Version.DRAFT_14 &&
|
|
22
|
+
version !== Version.DRAFT_15 &&
|
|
23
|
+
version !== Version.DRAFT_16 &&
|
|
24
|
+
version !== Version.DRAFT_17 &&
|
|
25
|
+
version !== Version.DRAFT_18 &&
|
|
26
|
+
version !== Version.DRAFT_19);
|
|
27
|
+
}
|
|
28
|
+
/** Whether the Range Filters (draft-19) exist on this draft. */
|
|
29
|
+
export function hasRangeFilters(version) {
|
|
30
|
+
return isDraft20(version) || version === Version.DRAFT_19;
|
|
22
31
|
}
|
|
23
32
|
/**
|
|
24
33
|
* Draft-17 replaced QUIC's two-bit-length varint with a leading-1-bits one. The two agree
|