@moqtap/codec 0.4.3 → 0.6.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/dist/chunk-62LYLROG.js +2095 -0
- package/dist/chunk-A33U4WVS.cjs +1993 -0
- package/dist/chunk-A655PHFX.cjs +446 -0
- package/dist/chunk-CQ65LKPQ.cjs +446 -0
- package/dist/chunk-DLSGOZ6P.js +1993 -0
- package/dist/chunk-IWYKDCXP.js +446 -0
- package/dist/chunk-MSG2FXJ2.cjs +2095 -0
- package/dist/chunk-O5DQ44TM.js +446 -0
- package/dist/{codec-C7UzTYSS.d.cts → codec-B1snaM9L.d.cts} +1 -1
- package/dist/{codec-ZwV-Njt6.d.ts → codec-BLYAy2OP.d.ts} +1 -1
- package/dist/{codec-B2lYE0YA.d.ts → codec-BNS3gS77.d.ts} +1 -1
- package/dist/{codec-BbbLDSKA.d.cts → codec-BOtv3R5j.d.cts} +1 -1
- package/dist/{codec-DDUBJGn0.d.cts → codec-BOyrk_C9.d.cts} +1 -1
- package/dist/{codec-BWQ5Jlap.d.cts → codec-BqqoYdh_.d.cts} +1 -1
- package/dist/{codec-3Ppy_5Gd.d.ts → codec-CI0BjmHc.d.ts} +1 -1
- package/dist/{codec-DftaRuVz.d.ts → codec-CWj5iTxA.d.ts} +1 -1
- package/dist/{codec-B_QST4y1.d.cts → codec-CyApDKwf.d.cts} +1 -1
- package/dist/{codec-BFg5xnrJ.d.ts → codec-D2JbI2tp.d.ts} +1 -1
- package/dist/{codec-DFU-6Rax.d.ts → codec-D47r_-Rl.d.ts} +1 -1
- package/dist/{codec-Db-0pk38.d.ts → codec-D49OofBr.d.ts} +1 -1
- package/dist/codec-D89DWXbv.d.cts +30 -0
- package/dist/{codec-R9TJCq-E.d.cts → codec-D95gT98n.d.cts} +1 -1
- package/dist/codec-DAePx2NL.d.ts +30 -0
- package/dist/{codec-CpZrZ3ok.d.ts → codec-DJmV04i0.d.ts} +1 -1
- package/dist/{codec-Va_wZCF_.d.ts → codec-DL0njGkL.d.ts} +1 -1
- package/dist/{codec-CFWQY9Lj.d.cts → codec-DQWQSam3.d.cts} +1 -1
- package/dist/{codec-wtt6WF1K.d.ts → codec-DplRgIKq.d.ts} +1 -1
- package/dist/{codec-CewFCsEy.d.ts → codec-DujHf55Z.d.ts} +1 -1
- package/dist/{codec-j819z_hL.d.cts → codec-DvcJgYKq.d.cts} +1 -1
- package/dist/{codec-C8aSvE41.d.cts → codec-NMsTK0GX.d.cts} +1 -1
- package/dist/codec-WwwUipaU.d.ts +30 -0
- package/dist/{codec-CAbm9d_n.d.cts → codec-cou9XBMF.d.cts} +1 -1
- package/dist/{codec-lqDowbyT.d.cts → codec-hvkJfCF5.d.cts} +1 -1
- package/dist/codec-xeuGZY77.d.cts +30 -0
- package/dist/draft07-session.d.cts +3 -3
- package/dist/draft07-session.d.ts +3 -3
- package/dist/draft07.d.cts +3 -3
- package/dist/draft07.d.ts +3 -3
- package/dist/draft08-session.d.cts +3 -3
- package/dist/draft08-session.d.ts +3 -3
- package/dist/draft08.d.cts +4 -4
- package/dist/draft08.d.ts +4 -4
- package/dist/draft09-session.d.cts +3 -3
- package/dist/draft09-session.d.ts +3 -3
- package/dist/draft09.d.cts +4 -4
- package/dist/draft09.d.ts +4 -4
- package/dist/draft10-session.d.cts +3 -3
- package/dist/draft10-session.d.ts +3 -3
- package/dist/draft10.d.cts +4 -4
- package/dist/draft10.d.ts +4 -4
- package/dist/draft11-session.d.cts +3 -3
- package/dist/draft11-session.d.ts +3 -3
- package/dist/draft11.d.cts +4 -4
- package/dist/draft11.d.ts +4 -4
- package/dist/draft12-session.d.cts +3 -3
- package/dist/draft12-session.d.ts +3 -3
- package/dist/draft12.d.cts +4 -4
- package/dist/draft12.d.ts +4 -4
- package/dist/draft13-session.d.cts +3 -3
- package/dist/draft13-session.d.ts +3 -3
- package/dist/draft13.d.cts +4 -4
- package/dist/draft13.d.ts +4 -4
- package/dist/draft14-session.d.cts +3 -3
- package/dist/draft14-session.d.ts +3 -3
- package/dist/draft14.d.cts +4 -4
- package/dist/draft14.d.ts +4 -4
- package/dist/draft15-session.d.cts +3 -3
- package/dist/draft15-session.d.ts +3 -3
- package/dist/draft15.d.cts +4 -4
- package/dist/draft15.d.ts +4 -4
- package/dist/draft16-session.d.cts +3 -3
- package/dist/draft16-session.d.ts +3 -3
- package/dist/draft16.d.cts +4 -4
- package/dist/draft16.d.ts +4 -4
- package/dist/draft17-session.d.cts +3 -3
- package/dist/draft17-session.d.ts +3 -3
- package/dist/draft17.d.cts +3 -3
- package/dist/draft17.d.ts +3 -3
- package/dist/draft18-session.cjs +8 -0
- package/dist/draft18-session.d.cts +50 -0
- package/dist/draft18-session.d.ts +50 -0
- package/dist/draft18-session.js +8 -0
- package/dist/draft18.cjs +179 -0
- package/dist/draft18.d.cts +126 -0
- package/dist/draft18.d.ts +126 -0
- package/dist/draft18.js +179 -0
- package/dist/draft19-session.cjs +8 -0
- package/dist/draft19-session.d.cts +50 -0
- package/dist/draft19-session.d.ts +50 -0
- package/dist/draft19-session.js +8 -0
- package/dist/draft19.cjs +189 -0
- package/dist/draft19.d.cts +130 -0
- package/dist/draft19.d.ts +130 -0
- package/dist/draft19.js +189 -0
- package/dist/index.cjs +13 -1
- package/dist/index.d.cts +24 -14
- package/dist/index.d.ts +24 -14
- package/dist/index.js +13 -1
- package/dist/{session-types-X-IYEGoG.d.ts → session-types-C0l_-Ups.d.ts} +1 -1
- package/dist/{session-types-C7UONex5.d.cts → session-types-KsqyVp6y.d.cts} +1 -1
- package/dist/session.cjs +9 -1
- package/dist/session.d.cts +7 -3
- package/dist/session.d.ts +7 -3
- package/dist/session.js +9 -1
- package/dist/{types-DuIO7cWK.d.cts → types-CdCSIfvI.d.cts} +1 -1
- package/dist/{types-DuIO7cWK.d.ts → types-CdCSIfvI.d.ts} +1 -1
- package/dist/types-Cqp10JtB.d.cts +249 -0
- package/dist/types-Cqp10JtB.d.ts +249 -0
- package/dist/types-zHgCS6o5.d.cts +265 -0
- package/dist/types-zHgCS6o5.d.ts +265 -0
- package/package.json +26 -2
- package/src/core/types.ts +14 -1
- package/src/drafts/draft17/error-codes.ts +72 -0
- package/src/drafts/draft18/codec.ts +1310 -0
- package/src/drafts/draft18/data-streams.ts +996 -0
- package/src/drafts/draft18/error-codes.ts +75 -0
- package/src/drafts/draft18/index.ts +122 -0
- package/src/drafts/draft18/messages.ts +56 -0
- package/src/drafts/draft18/rules.ts +85 -0
- package/src/drafts/draft18/session-fsm.ts +451 -0
- package/src/drafts/draft18/session.ts +15 -0
- package/src/drafts/draft18/types.ts +347 -0
- package/src/drafts/draft19/codec.ts +1425 -0
- package/src/drafts/draft19/data-streams.ts +996 -0
- package/src/drafts/draft19/error-codes.ts +78 -0
- package/src/drafts/draft19/index.ts +126 -0
- package/src/drafts/draft19/messages.ts +58 -0
- package/src/drafts/draft19/rules.ts +85 -0
- package/src/drafts/draft19/session-fsm.ts +451 -0
- package/src/drafts/draft19/session.ts +15 -0
- package/src/drafts/draft19/types.ts +368 -0
- package/src/index.ts +17 -1
- package/src/session.ts +8 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const SessionTerminationCode = {
|
|
2
|
+
NoError: 0x0n,
|
|
3
|
+
InternalError: 0x1n,
|
|
4
|
+
Unauthorized: 0x2n,
|
|
5
|
+
ProtocolViolation: 0x3n,
|
|
6
|
+
InvalidRequestId: 0x4n,
|
|
7
|
+
DuplicateTrackAlias: 0x5n,
|
|
8
|
+
KeyValueFormattingError: 0x6n,
|
|
9
|
+
InvalidPath: 0x8n,
|
|
10
|
+
MalformedPath: 0x9n,
|
|
11
|
+
GoawayTimeout: 0x10n,
|
|
12
|
+
ControlMessageTimeout: 0x11n,
|
|
13
|
+
DataStreamTimeout: 0x12n,
|
|
14
|
+
AuthTokenCacheOverflow: 0x13n,
|
|
15
|
+
DuplicateAuthTokenAlias: 0x14n,
|
|
16
|
+
VersionNegotiationFailed: 0x15n,
|
|
17
|
+
MalformedAuthToken: 0x16n,
|
|
18
|
+
UnknownAuthTokenAlias: 0x17n,
|
|
19
|
+
ExpiredAuthToken: 0x18n,
|
|
20
|
+
InvalidAuthority: 0x19n,
|
|
21
|
+
MalformedAuthority: 0x1an,
|
|
22
|
+
TooManyRequestUpdates: 0x1bn, // NEW in draft-19
|
|
23
|
+
} as const
|
|
24
|
+
export type SessionTerminationCodeValue =
|
|
25
|
+
(typeof SessionTerminationCode)[keyof typeof SessionTerminationCode]
|
|
26
|
+
|
|
27
|
+
export const RequestErrorCode = {
|
|
28
|
+
InternalError: 0x0n,
|
|
29
|
+
Unauthorized: 0x1n,
|
|
30
|
+
Timeout: 0x2n,
|
|
31
|
+
NotSupported: 0x3n,
|
|
32
|
+
MalformedAuthToken: 0x4n,
|
|
33
|
+
ExpiredAuthToken: 0x5n,
|
|
34
|
+
GoingAway: 0x6n,
|
|
35
|
+
ExcessiveLoad: 0x9n,
|
|
36
|
+
DoesNotExist: 0x10n,
|
|
37
|
+
InvalidRange: 0x11n,
|
|
38
|
+
MalformedTrack: 0x12n,
|
|
39
|
+
// DuplicateSubscription (0x19) removed in draft-19 — multiple concurrent subscriptions per Track are now allowed
|
|
40
|
+
Uninterested: 0x20n,
|
|
41
|
+
PrefixOverlap: 0x30n,
|
|
42
|
+
NamespaceTooLarge: 0x31n,
|
|
43
|
+
InvalidJoiningRequestId: 0x32n,
|
|
44
|
+
UnsupportedExtension: 0x33n,
|
|
45
|
+
Redirect: 0x34n,
|
|
46
|
+
ConflictingFilters: 0x35n, // NEW in draft-19
|
|
47
|
+
InvalidFilter: 0x36n, // NEW in draft-19
|
|
48
|
+
} as const
|
|
49
|
+
export type RequestErrorCodeValue = (typeof RequestErrorCode)[keyof typeof RequestErrorCode]
|
|
50
|
+
|
|
51
|
+
export const PublishDoneCode = {
|
|
52
|
+
InternalError: 0x0n,
|
|
53
|
+
Unauthorized: 0x1n,
|
|
54
|
+
TrackEnded: 0x2n,
|
|
55
|
+
SubscriptionEnded: 0x3n,
|
|
56
|
+
GoingAway: 0x4n,
|
|
57
|
+
TooFarBehind: 0x5n,
|
|
58
|
+
Expired: 0x6n,
|
|
59
|
+
UpdateFailed: 0x8n,
|
|
60
|
+
ExcessiveLoad: 0x9n,
|
|
61
|
+
MalformedTrack: 0x12n,
|
|
62
|
+
} as const
|
|
63
|
+
export type PublishDoneCodeValue = (typeof PublishDoneCode)[keyof typeof PublishDoneCode]
|
|
64
|
+
|
|
65
|
+
export const DataStreamResetCode = {
|
|
66
|
+
InternalError: 0x0n,
|
|
67
|
+
Cancelled: 0x1n,
|
|
68
|
+
DeliveryTimeout: 0x2n,
|
|
69
|
+
SessionClosed: 0x3n,
|
|
70
|
+
GoingAway: 0x4n,
|
|
71
|
+
TooFarBehind: 0x5n,
|
|
72
|
+
UnknownObjectStatus: 0x6n,
|
|
73
|
+
ExpiredAuthToken: 0x7n,
|
|
74
|
+
ExcessiveLoad: 0x9n,
|
|
75
|
+
MalformedTrack: 0x12n,
|
|
76
|
+
} as const
|
|
77
|
+
export type DataStreamResetCodeValue =
|
|
78
|
+
(typeof DataStreamResetCode)[keyof typeof DataStreamResetCode]
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Draft-19 codec entry point
|
|
2
|
+
|
|
3
|
+
export const DRAFT_VERSION = 0xff000013n
|
|
4
|
+
|
|
5
|
+
export type { Draft19Codec } from './codec.js'
|
|
6
|
+
export {
|
|
7
|
+
createDataStreamDecoder,
|
|
8
|
+
createDraft19Codec,
|
|
9
|
+
createFetchStreamDecoder,
|
|
10
|
+
createStreamDecoder,
|
|
11
|
+
createSubgroupStreamDecoder,
|
|
12
|
+
decodeDatagram,
|
|
13
|
+
decodeDataStream,
|
|
14
|
+
decodeFetchStream,
|
|
15
|
+
decodeMessage,
|
|
16
|
+
decodeSubgroupStream,
|
|
17
|
+
encodeDatagram,
|
|
18
|
+
encodeFetchStream,
|
|
19
|
+
encodeMessage,
|
|
20
|
+
encodeSubgroupStream,
|
|
21
|
+
} from './codec.js'
|
|
22
|
+
export type {
|
|
23
|
+
DataStreamResetCodeValue,
|
|
24
|
+
PublishDoneCodeValue,
|
|
25
|
+
RequestErrorCodeValue,
|
|
26
|
+
SessionTerminationCodeValue,
|
|
27
|
+
} from './error-codes.js'
|
|
28
|
+
export {
|
|
29
|
+
DataStreamResetCode,
|
|
30
|
+
PublishDoneCode,
|
|
31
|
+
RequestErrorCode,
|
|
32
|
+
SessionTerminationCode,
|
|
33
|
+
} from './error-codes.js'
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
MESSAGE_ID_MAP,
|
|
37
|
+
MESSAGE_TYPE_MAP,
|
|
38
|
+
MSG_FETCH,
|
|
39
|
+
MSG_FETCH_OK,
|
|
40
|
+
MSG_GOAWAY,
|
|
41
|
+
MSG_NAMESPACE,
|
|
42
|
+
MSG_NAMESPACE_DONE,
|
|
43
|
+
MSG_PUBLISH,
|
|
44
|
+
MSG_PUBLISH_DONE,
|
|
45
|
+
MSG_PUBLISH_NAMESPACE,
|
|
46
|
+
MSG_PUBLISH_OK,
|
|
47
|
+
MSG_PUBLISH_SKIPPED,
|
|
48
|
+
MSG_REQUEST_ERROR,
|
|
49
|
+
MSG_REQUEST_OK,
|
|
50
|
+
MSG_REQUEST_UPDATE,
|
|
51
|
+
MSG_SETUP,
|
|
52
|
+
MSG_SUBSCRIBE,
|
|
53
|
+
MSG_SUBSCRIBE_NAMESPACE,
|
|
54
|
+
MSG_SUBSCRIBE_OK,
|
|
55
|
+
MSG_SUBSCRIBE_TRACKS,
|
|
56
|
+
MSG_TRACK_STATUS,
|
|
57
|
+
SETUP_OPT_AUTHORITY,
|
|
58
|
+
SETUP_OPT_AUTHORIZATION_TOKEN,
|
|
59
|
+
SETUP_OPT_MAX_AUTH_TOKEN_CACHE_SIZE,
|
|
60
|
+
SETUP_OPT_MAX_FILTER_RANGES,
|
|
61
|
+
SETUP_OPT_MAX_REQUEST_UPDATES,
|
|
62
|
+
SETUP_OPT_MOQT_IMPLEMENTATION,
|
|
63
|
+
SETUP_OPT_PATH,
|
|
64
|
+
} from './messages.js'
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
BIDIRECTIONAL_MESSAGES,
|
|
68
|
+
CLIENT_ONLY_MESSAGES,
|
|
69
|
+
CONTROL_MESSAGES,
|
|
70
|
+
getLegalIncoming,
|
|
71
|
+
getLegalOutgoing,
|
|
72
|
+
SERVER_ONLY_MESSAGES,
|
|
73
|
+
} from './rules.js'
|
|
74
|
+
export type {
|
|
75
|
+
ProtocolViolation,
|
|
76
|
+
SessionPhase,
|
|
77
|
+
SideEffect,
|
|
78
|
+
TransitionResult,
|
|
79
|
+
ValidationResult,
|
|
80
|
+
} from './session.js'
|
|
81
|
+
export { createDraft19SessionState, Draft19SessionFSM } from './session.js'
|
|
82
|
+
|
|
83
|
+
export type {
|
|
84
|
+
DatagramObject,
|
|
85
|
+
DataStreamEvent,
|
|
86
|
+
DataStreamHeader,
|
|
87
|
+
Draft19BaseMessage,
|
|
88
|
+
Draft19DataStream,
|
|
89
|
+
Draft19Fetch,
|
|
90
|
+
Draft19FetchOk,
|
|
91
|
+
Draft19GoAway,
|
|
92
|
+
Draft19Message,
|
|
93
|
+
Draft19MessageType,
|
|
94
|
+
Draft19Namespace,
|
|
95
|
+
Draft19NamespaceDone,
|
|
96
|
+
Draft19Params,
|
|
97
|
+
Draft19Publish,
|
|
98
|
+
Draft19PublishDone,
|
|
99
|
+
Draft19PublishNamespace,
|
|
100
|
+
Draft19PublishSkipped,
|
|
101
|
+
Draft19RequestError,
|
|
102
|
+
Draft19RequestOk,
|
|
103
|
+
Draft19RequestUpdate,
|
|
104
|
+
Draft19Setup,
|
|
105
|
+
Draft19SetupOptions,
|
|
106
|
+
Draft19Subscribe,
|
|
107
|
+
Draft19SubscribeNamespace,
|
|
108
|
+
Draft19SubscribeOk,
|
|
109
|
+
Draft19SubscribeTracks,
|
|
110
|
+
Draft19TrackProperties,
|
|
111
|
+
Draft19TrackStatus,
|
|
112
|
+
FetchObjectPayload,
|
|
113
|
+
FetchStream,
|
|
114
|
+
FetchStreamHeader,
|
|
115
|
+
JoiningFetch,
|
|
116
|
+
LargestObject,
|
|
117
|
+
LocationFilter,
|
|
118
|
+
ObjectPayload,
|
|
119
|
+
RangeFilter,
|
|
120
|
+
RangeFilterRange,
|
|
121
|
+
Redirect,
|
|
122
|
+
StandaloneFetch,
|
|
123
|
+
SubgroupStream,
|
|
124
|
+
SubgroupStreamHeader,
|
|
125
|
+
UnknownParam,
|
|
126
|
+
} from './types.js'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Draft-19 message type wire IDs
|
|
2
|
+
|
|
3
|
+
export const MSG_REQUEST_UPDATE = 0x02n
|
|
4
|
+
export const MSG_SUBSCRIBE = 0x03n
|
|
5
|
+
export const MSG_SUBSCRIBE_OK = 0x04n
|
|
6
|
+
export const MSG_REQUEST_ERROR = 0x05n
|
|
7
|
+
export const MSG_PUBLISH_NAMESPACE = 0x06n
|
|
8
|
+
export const MSG_REQUEST_OK = 0x07n
|
|
9
|
+
export const MSG_NAMESPACE = 0x08n
|
|
10
|
+
export const MSG_PUBLISH_DONE = 0x0bn
|
|
11
|
+
export const MSG_TRACK_STATUS = 0x0dn
|
|
12
|
+
export const MSG_NAMESPACE_DONE = 0x0en
|
|
13
|
+
export const MSG_PUBLISH_SKIPPED = 0x0fn
|
|
14
|
+
export const MSG_GOAWAY = 0x10n
|
|
15
|
+
export const MSG_FETCH = 0x16n
|
|
16
|
+
export const MSG_FETCH_OK = 0x18n
|
|
17
|
+
export const MSG_PUBLISH = 0x1dn
|
|
18
|
+
// In draft-18 PUBLISH_OK is an alias for REQUEST_OK (0x07). Kept as alias.
|
|
19
|
+
export const MSG_PUBLISH_OK = MSG_REQUEST_OK
|
|
20
|
+
export const MSG_SUBSCRIBE_NAMESPACE = 0x50n
|
|
21
|
+
export const MSG_SUBSCRIBE_TRACKS = 0x51n
|
|
22
|
+
export const MSG_SETUP = 0x2f00n
|
|
23
|
+
|
|
24
|
+
// Setup option type IDs (KVP encoding, constant across versions)
|
|
25
|
+
export const SETUP_OPT_PATH = 0x01n
|
|
26
|
+
export const SETUP_OPT_AUTHORIZATION_TOKEN = 0x03n
|
|
27
|
+
export const SETUP_OPT_MAX_AUTH_TOKEN_CACHE_SIZE = 0x04n
|
|
28
|
+
export const SETUP_OPT_AUTHORITY = 0x05n
|
|
29
|
+
export const SETUP_OPT_MAX_FILTER_RANGES = 0x06n // NEW in draft-19
|
|
30
|
+
export const SETUP_OPT_MOQT_IMPLEMENTATION = 0x07n
|
|
31
|
+
export const SETUP_OPT_MAX_REQUEST_UPDATES = 0x08n // NEW in draft-19
|
|
32
|
+
|
|
33
|
+
// Map from wire ID to message type name
|
|
34
|
+
export const MESSAGE_TYPE_MAP: ReadonlyMap<bigint, string> = new Map([
|
|
35
|
+
[MSG_SETUP, 'setup'],
|
|
36
|
+
[MSG_SUBSCRIBE, 'subscribe'],
|
|
37
|
+
[MSG_SUBSCRIBE_OK, 'subscribe_ok'],
|
|
38
|
+
[MSG_REQUEST_UPDATE, 'request_update'],
|
|
39
|
+
[MSG_PUBLISH, 'publish'],
|
|
40
|
+
[MSG_PUBLISH_DONE, 'publish_done'],
|
|
41
|
+
[MSG_PUBLISH_NAMESPACE, 'publish_namespace'],
|
|
42
|
+
[MSG_NAMESPACE, 'namespace'],
|
|
43
|
+
[MSG_NAMESPACE_DONE, 'namespace_done'],
|
|
44
|
+
[MSG_SUBSCRIBE_NAMESPACE, 'subscribe_namespace'],
|
|
45
|
+
[MSG_SUBSCRIBE_TRACKS, 'subscribe_tracks'],
|
|
46
|
+
[MSG_PUBLISH_SKIPPED, 'publish_skipped'],
|
|
47
|
+
[MSG_FETCH, 'fetch'],
|
|
48
|
+
[MSG_FETCH_OK, 'fetch_ok'],
|
|
49
|
+
[MSG_TRACK_STATUS, 'track_status'],
|
|
50
|
+
[MSG_REQUEST_OK, 'request_ok'],
|
|
51
|
+
[MSG_REQUEST_ERROR, 'request_error'],
|
|
52
|
+
[MSG_GOAWAY, 'goaway'],
|
|
53
|
+
])
|
|
54
|
+
|
|
55
|
+
// Reverse map from message type name to wire ID
|
|
56
|
+
export const MESSAGE_ID_MAP: ReadonlyMap<string, bigint> = new Map(
|
|
57
|
+
[...MESSAGE_TYPE_MAP.entries()].map(([id, name]) => [name, id]),
|
|
58
|
+
)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Draft19MessageType } from './types.js'
|
|
2
|
+
|
|
3
|
+
// All draft-18 control messages
|
|
4
|
+
export const CONTROL_MESSAGES: ReadonlySet<Draft19MessageType> = new Set([
|
|
5
|
+
'setup',
|
|
6
|
+
'subscribe',
|
|
7
|
+
'subscribe_ok',
|
|
8
|
+
'request_update',
|
|
9
|
+
'publish',
|
|
10
|
+
'publish_done',
|
|
11
|
+
'publish_namespace',
|
|
12
|
+
'namespace',
|
|
13
|
+
'namespace_done',
|
|
14
|
+
'subscribe_namespace',
|
|
15
|
+
'subscribe_tracks',
|
|
16
|
+
'publish_skipped',
|
|
17
|
+
'fetch',
|
|
18
|
+
'fetch_ok',
|
|
19
|
+
'track_status',
|
|
20
|
+
'request_ok',
|
|
21
|
+
'request_error',
|
|
22
|
+
'goaway',
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
// Draft-19 has a single SETUP message — both roles can send it
|
|
26
|
+
export const CLIENT_ONLY_MESSAGES: ReadonlySet<Draft19MessageType> = new Set<Draft19MessageType>()
|
|
27
|
+
|
|
28
|
+
export const SERVER_ONLY_MESSAGES: ReadonlySet<Draft19MessageType> = new Set<Draft19MessageType>()
|
|
29
|
+
|
|
30
|
+
// Messages that are bidirectional (both client and server can send)
|
|
31
|
+
export const BIDIRECTIONAL_MESSAGES: ReadonlySet<Draft19MessageType> = new Set([
|
|
32
|
+
'setup',
|
|
33
|
+
'subscribe',
|
|
34
|
+
'subscribe_ok',
|
|
35
|
+
'request_update',
|
|
36
|
+
'publish',
|
|
37
|
+
'publish_done',
|
|
38
|
+
'publish_namespace',
|
|
39
|
+
'namespace',
|
|
40
|
+
'namespace_done',
|
|
41
|
+
'subscribe_namespace',
|
|
42
|
+
'subscribe_tracks',
|
|
43
|
+
'publish_skipped',
|
|
44
|
+
'fetch',
|
|
45
|
+
'fetch_ok',
|
|
46
|
+
'track_status',
|
|
47
|
+
'request_ok',
|
|
48
|
+
'request_error',
|
|
49
|
+
'goaway',
|
|
50
|
+
])
|
|
51
|
+
|
|
52
|
+
// Messages legal in each session phase
|
|
53
|
+
export function getLegalOutgoing(
|
|
54
|
+
phase: string,
|
|
55
|
+
_role: 'client' | 'server',
|
|
56
|
+
): Set<Draft19MessageType> {
|
|
57
|
+
const legal = new Set<Draft19MessageType>()
|
|
58
|
+
|
|
59
|
+
switch (phase) {
|
|
60
|
+
case 'idle':
|
|
61
|
+
legal.add('setup')
|
|
62
|
+
break
|
|
63
|
+
case 'setup':
|
|
64
|
+
legal.add('setup')
|
|
65
|
+
break
|
|
66
|
+
case 'ready': {
|
|
67
|
+
for (const msg of BIDIRECTIONAL_MESSAGES) {
|
|
68
|
+
legal.add(msg)
|
|
69
|
+
}
|
|
70
|
+
break
|
|
71
|
+
}
|
|
72
|
+
case 'draining':
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return legal
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getLegalIncoming(
|
|
80
|
+
phase: string,
|
|
81
|
+
role: 'client' | 'server',
|
|
82
|
+
): Set<Draft19MessageType> {
|
|
83
|
+
const remoteRole = role === 'client' ? 'server' : 'client'
|
|
84
|
+
return getLegalOutgoing(phase, remoteRole)
|
|
85
|
+
}
|