@moqtap/codec 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +175 -0
- package/README.md +3 -2
- package/dist/auth-redaction-B9JJOlIY.d.cts +100 -0
- package/dist/auth-redaction-B9JJOlIY.d.ts +100 -0
- package/dist/{chunk-RYKQXBG6.cjs → chunk-27K5BUAG.cjs} +481 -517
- package/dist/{chunk-WCPENYNE.js → chunk-3RNQMGKA.js} +359 -390
- package/dist/{chunk-TSUZ6GJV.js → chunk-5AWIXOLB.js} +438 -469
- package/dist/{chunk-4XLYCT5Q.cjs → chunk-5IMHJIAZ.cjs} +52 -2
- package/dist/{chunk-KTNERCTZ.cjs → chunk-5JGZCKJO.cjs} +488 -518
- package/dist/{chunk-WCTMPDUX.cjs → chunk-73K4OSAN.cjs} +401 -432
- package/dist/{chunk-N2V7Z37J.js → chunk-7VQKRGRD.js} +19 -3
- package/dist/{chunk-BIBMDTU5.cjs → chunk-A3UCQOIB.cjs} +486 -517
- package/dist/{chunk-K2B3OVFK.js → chunk-A7PDMVXM.js} +24 -3
- package/dist/{chunk-VZHL2U2N.cjs → chunk-A7VQO6YC.cjs} +54 -38
- package/dist/{chunk-AQ445VV7.cjs → chunk-ACQHZLRZ.cjs} +66 -46
- package/dist/{chunk-L5DRACXS.js → chunk-BBICOMW6.js} +25 -3
- package/dist/{chunk-T4VWPKDG.cjs → chunk-BNIUVOCJ.cjs} +529 -599
- package/dist/{chunk-UKKDOOUO.cjs → chunk-CNC6ANS4.cjs} +58 -37
- package/dist/{chunk-OZRK73NQ.js → chunk-FDLQSWHK.js} +433 -469
- package/dist/{chunk-IJAF6PAY.js → chunk-FFNOE4UR.js} +19 -3
- package/dist/{chunk-CZNW3R5E.cjs → chunk-GMENT63T.cjs} +54 -38
- package/dist/{chunk-XCRCAUGI.cjs → chunk-HM7BLRVP.cjs} +291 -297
- package/dist/{chunk-XHAP2YST.js → chunk-HZONHFNO.js} +19 -3
- package/dist/{chunk-SDJTSMOW.cjs → chunk-ILYABWDK.cjs} +60 -38
- package/dist/{chunk-IDV2JYJ6.cjs → chunk-KRSFTZVO.cjs} +56 -40
- package/dist/{chunk-RIIA4ALQ.cjs → chunk-KSPH6KMH.cjs} +54 -38
- package/dist/{chunk-OUNN4IQB.cjs → chunk-KTY4LAUV.cjs} +482 -497
- package/dist/chunk-OBATJBNL.cjs +868 -0
- package/dist/{chunk-RZTLQAKF.js → chunk-OJNLJT5D.js} +0 -1
- package/dist/{chunk-FT3HDNIB.js → chunk-PJK2ZS3I.js} +467 -537
- package/dist/{chunk-G53WYUXL.js → chunk-PSMZKHOC.js} +441 -456
- package/dist/{chunk-7RE6KSIY.cjs → chunk-Q5JQGHWY.cjs} +0 -1
- package/dist/{chunk-BX2N7TZM.js → chunk-SQTUQY5E.js} +31 -11
- package/dist/chunk-T2TCLZZV.js +2304 -0
- package/dist/chunk-WB65UG7G.cjs +2304 -0
- package/dist/{chunk-CF5DDD3Q.js → chunk-WCRLAKDW.js} +239 -245
- package/dist/{chunk-KYVTM5VI.js → chunk-WL2YUEXH.js} +19 -3
- package/dist/chunk-XPCBPACE.js +868 -0
- package/dist/{chunk-KGDVC4O6.js → chunk-YCNIVZS7.js} +439 -469
- package/dist/{chunk-KLPWJU6W.js → chunk-YRZQVNZO.js} +50 -0
- package/dist/{codec-DOmAmFkI.d.ts → codec-B-oUU-cp.d.ts} +21 -2
- package/dist/{codec-DNmiG2e0.d.cts → codec-B3RpCI9k.d.cts} +21 -2
- package/dist/codec-B5pcOS3m.d.cts +38 -0
- package/dist/{codec-BNy5syCU.d.ts → codec-BLjxwK2f.d.ts} +21 -2
- package/dist/{codec-alVA27Uc.d.ts → codec-BV3CL_3m.d.ts} +21 -2
- package/dist/{codec-Czejcmxr.d.cts → codec-BYCDWgED.d.ts} +22 -3
- package/dist/{codec-DaXjRrOV.d.ts → codec-Bwqq7ZQT.d.ts} +22 -3
- package/dist/{codec-CFWu5KVT.d.cts → codec-BzWxOFby.d.cts} +22 -3
- package/dist/codec-C-nJhNNl.d.ts +38 -0
- package/dist/{codec-EvybrBuY.d.cts → codec-C11VEPbQ.d.cts} +21 -2
- package/dist/codec-C9U0Vzy9.d.cts +68 -0
- package/dist/{codec-Cm3D261p.d.ts → codec-CCx22jnd.d.ts} +21 -2
- package/dist/{codec-CwZ6OCPP.d.ts → codec-CP3zkfTv.d.ts} +22 -3
- package/dist/{codec-BxQTybUX.d.cts → codec-CRmOLDpt.d.ts} +22 -3
- package/dist/{codec-DzkdW4kO.d.cts → codec-CUu56DDU.d.cts} +21 -2
- package/dist/codec-Cb8mUre3.d.ts +68 -0
- package/dist/{codec-f7vxeVIS.d.cts → codec-CemqAQdR.d.cts} +22 -3
- package/dist/{codec-gl4_QEva.d.ts → codec-CxMvsVMS.d.ts} +21 -2
- package/dist/{codec-Bd60SGKH.d.cts → codec-DIgMVTi4.d.cts} +21 -2
- package/dist/{codec--CVeqGQv.d.ts → codec-DYzozF68.d.ts} +21 -2
- package/dist/{codec-CWnf8mn_.d.cts → codec-D_O9zxax.d.ts} +22 -3
- package/dist/{codec-08ZOr5wI.d.ts → codec-Ddc-QxV6.d.cts} +22 -3
- package/dist/{codec-CBdOIfMY.d.ts → codec-DoojMl2z.d.cts} +22 -3
- package/dist/{codec-BrTi4K7r.d.cts → codec-DqdjiOQF.d.ts} +22 -3
- package/dist/{codec-CXCjya_G.d.cts → codec-Dstemwrq.d.cts} +21 -2
- package/dist/{codec-Dl_QIXMz.d.ts → codec-Dt6nuejp.d.ts} +21 -2
- package/dist/{codec-Bux_Q40X.d.ts → codec-DuYhd8fP.d.cts} +22 -3
- package/dist/{codec-Cfo_z5ET.d.cts → codec-DwNOFgPU.d.cts} +21 -2
- package/dist/{codec-guzqtfMk.d.cts → codec-l01BpNhF.d.cts} +21 -2
- package/dist/{codec-C3mdsGx3.d.ts → codec-psN2vB6I.d.cts} +22 -3
- package/dist/draft07-session.d.cts +3 -3
- package/dist/draft07-session.d.ts +3 -3
- package/dist/draft07.cjs +48 -4
- package/dist/draft07.d.cts +44 -4
- package/dist/draft07.d.ts +44 -4
- package/dist/draft07.js +49 -5
- package/dist/draft08-session.d.cts +3 -3
- package/dist/draft08-session.d.ts +3 -3
- package/dist/draft08.cjs +76 -3
- package/dist/draft08.d.cts +73 -5
- package/dist/draft08.d.ts +73 -5
- package/dist/draft08.js +77 -4
- package/dist/draft09-session.d.cts +3 -3
- package/dist/draft09-session.d.ts +3 -3
- package/dist/draft09.cjs +76 -3
- package/dist/draft09.d.cts +73 -5
- package/dist/draft09.d.ts +73 -5
- package/dist/draft09.js +77 -4
- package/dist/draft10-session.d.cts +3 -3
- package/dist/draft10-session.d.ts +3 -3
- package/dist/draft10.cjs +76 -3
- package/dist/draft10.d.cts +73 -5
- package/dist/draft10.d.ts +73 -5
- package/dist/draft10.js +77 -4
- package/dist/draft11-session.d.cts +3 -3
- package/dist/draft11-session.d.ts +3 -3
- package/dist/draft11.cjs +104 -3
- package/dist/draft11.d.cts +101 -5
- package/dist/draft11.d.ts +101 -5
- package/dist/draft11.js +105 -4
- package/dist/draft12-session.d.cts +3 -3
- package/dist/draft12-session.d.ts +3 -3
- package/dist/draft12.cjs +113 -3
- package/dist/draft12.d.cts +110 -5
- package/dist/draft12.d.ts +110 -5
- package/dist/draft12.js +114 -4
- package/dist/draft13-session.d.cts +3 -3
- package/dist/draft13-session.d.ts +3 -3
- package/dist/draft13.cjs +105 -3
- package/dist/draft13.d.cts +102 -5
- package/dist/draft13.d.ts +102 -5
- package/dist/draft13.js +106 -4
- package/dist/draft14-session.d.cts +3 -3
- package/dist/draft14-session.d.ts +3 -3
- package/dist/draft14.cjs +107 -3
- package/dist/draft14.d.cts +104 -31
- package/dist/draft14.d.ts +104 -31
- package/dist/draft14.js +108 -4
- package/dist/draft15-session.d.cts +4 -4
- package/dist/draft15-session.d.ts +4 -4
- package/dist/draft15.cjs +69 -3
- package/dist/draft15.d.cts +68 -25
- package/dist/draft15.d.ts +68 -25
- package/dist/draft15.js +70 -4
- package/dist/draft16-session.cjs +2 -2
- package/dist/draft16-session.d.cts +4 -4
- package/dist/draft16-session.d.ts +4 -4
- package/dist/draft16-session.js +1 -1
- package/dist/draft16.cjs +76 -8
- package/dist/draft16.d.cts +70 -16
- package/dist/draft16.d.ts +70 -16
- package/dist/draft16.js +73 -5
- package/dist/draft17-session.d.cts +4 -4
- package/dist/draft17-session.d.ts +4 -4
- package/dist/draft17.cjs +77 -3
- package/dist/draft17.d.cts +75 -6
- package/dist/draft17.d.ts +75 -6
- package/dist/draft17.js +78 -4
- package/dist/draft18-session.d.cts +4 -4
- package/dist/draft18-session.d.ts +4 -4
- package/dist/draft18.cjs +8 -3
- package/dist/draft18.d.cts +6 -5
- package/dist/draft18.d.ts +6 -5
- package/dist/draft18.js +9 -4
- package/dist/draft19-session.d.cts +4 -4
- package/dist/draft19-session.d.ts +4 -4
- package/dist/draft19.cjs +11 -4
- package/dist/draft19.d.cts +6 -5
- package/dist/draft19.d.ts +6 -5
- package/dist/draft19.js +12 -5
- package/dist/draft20-session.d.cts +4 -4
- package/dist/draft20-session.d.ts +4 -4
- package/dist/draft20.cjs +8 -3
- package/dist/draft20.d.cts +6 -5
- package/dist/draft20.d.ts +6 -5
- package/dist/draft20.js +9 -4
- package/dist/draft21-session.cjs +8 -0
- package/dist/draft21-session.d.cts +195 -0
- package/dist/draft21-session.d.ts +195 -0
- package/dist/draft21-session.js +8 -0
- package/dist/draft21.cjs +222 -0
- package/dist/draft21.d.cts +176 -0
- package/dist/draft21.d.ts +176 -0
- package/dist/draft21.js +222 -0
- package/dist/index.cjs +37 -31
- package/dist/index.d.cts +29 -23
- package/dist/index.d.ts +29 -23
- package/dist/index.js +22 -16
- package/dist/{session-types-Dn7b3RZM.d.ts → session-types-Cxx7W8zZ.d.ts} +1 -1
- package/dist/{session-types-B9idsih-.d.cts → session-types-DZkI_qFG.d.cts} +1 -1
- package/dist/session.cjs +7 -3
- package/dist/session.d.cts +11 -9
- package/dist/session.d.ts +11 -9
- package/dist/session.js +6 -2
- package/dist/{types-DG5_iKuv.d.cts → types-2NisMA8_.d.cts} +1 -1
- package/dist/{types-DG5_iKuv.d.ts → types-2NisMA8_.d.ts} +1 -1
- package/dist/{types-C1rxh-id.d.cts → types-Btp416jt.d.cts} +8 -0
- package/dist/{types-C1rxh-id.d.ts → types-Btp416jt.d.ts} +8 -0
- package/dist/{types-CZTzbIzQ.d.cts → types-BxTL1NXw.d.cts} +7 -0
- package/dist/{types-CZTzbIzQ.d.ts → types-BxTL1NXw.d.ts} +7 -0
- package/dist/{types-pShrs3fN.d.cts → types-CuibHYcf.d.cts} +7 -0
- package/dist/{types-pShrs3fN.d.ts → types-CuibHYcf.d.ts} +7 -0
- package/dist/{types-CY-QWxd-.d.cts → types-CwN7AEoL.d.cts} +13 -1
- package/dist/{types-CY-QWxd-.d.ts → types-CwN7AEoL.d.ts} +13 -1
- package/dist/{types-D4bmW8rY.d.cts → types-DAnalt5K.d.cts} +7 -0
- package/dist/{types-D4bmW8rY.d.ts → types-DAnalt5K.d.ts} +7 -0
- package/dist/types-DDwidj2d.d.cts +371 -0
- package/dist/types-DDwidj2d.d.ts +371 -0
- package/dist/{types-Bg86GGVZ.d.cts → types-DxXNP32l.d.cts} +8 -0
- package/dist/{types-Bg86GGVZ.d.ts → types-DxXNP32l.d.ts} +8 -0
- package/package.json +15 -3
- package/src/core/auth-redaction.ts +190 -0
- package/src/core/types.ts +1 -0
- package/src/drafts/draft07/codec.ts +40 -0
- package/src/drafts/draft07/error-codes.ts +44 -0
- package/src/drafts/draft07/index.ts +15 -0
- package/src/drafts/draft08/codec.ts +40 -0
- package/src/drafts/draft08/error-codes.ts +76 -0
- package/src/drafts/draft08/index.ts +21 -0
- package/src/drafts/draft09/codec.ts +40 -0
- package/src/drafts/draft09/error-codes.ts +76 -0
- package/src/drafts/draft09/index.ts +21 -0
- package/src/drafts/draft10/codec.ts +40 -0
- package/src/drafts/draft10/error-codes.ts +76 -0
- package/src/drafts/draft10/index.ts +21 -0
- package/src/drafts/draft11/codec.ts +60 -0
- package/src/drafts/draft11/error-codes.ts +106 -0
- package/src/drafts/draft11/index.ts +23 -0
- package/src/drafts/draft12/codec.ts +61 -0
- package/src/drafts/draft12/error-codes.ts +116 -0
- package/src/drafts/draft12/index.ts +25 -0
- package/src/drafts/draft13/codec.ts +69 -11
- package/src/drafts/draft13/error-codes.ts +107 -0
- package/src/drafts/draft13/index.ts +23 -0
- package/src/drafts/draft13/types.ts +1 -1
- package/src/drafts/draft14/codec.ts +65 -4
- package/src/drafts/draft14/data-streams.ts +331 -259
- package/src/drafts/draft14/error-codes.ts +109 -0
- package/src/drafts/draft14/index.ts +23 -0
- package/src/drafts/draft15/codec.ts +65 -8
- package/src/drafts/draft15/data-streams.ts +489 -444
- package/src/drafts/draft15/error-codes.ts +66 -0
- package/src/drafts/draft15/index.ts +15 -0
- package/src/drafts/draft15/types.ts +7 -0
- package/src/drafts/draft16/codec.ts +146 -52
- package/src/drafts/draft16/data-streams.ts +513 -442
- package/src/drafts/draft16/error-codes.ts +68 -0
- package/src/drafts/draft16/index.ts +15 -0
- package/src/drafts/draft16/messages.ts +4 -4
- package/src/drafts/draft16/session-fsm.ts +0 -1
- package/src/drafts/draft16/types.ts +22 -8
- package/src/drafts/draft17/codec.ts +73 -12
- package/src/drafts/draft17/data-streams.ts +567 -488
- package/src/drafts/draft17/index.ts +15 -0
- package/src/drafts/draft17/types.ts +7 -0
- package/src/drafts/draft18/codec.ts +66 -9
- package/src/drafts/draft18/data-streams.ts +570 -482
- package/src/drafts/draft18/index.ts +3 -0
- package/src/drafts/draft18/types.ts +16 -8
- package/src/drafts/draft19/codec.ts +70 -10
- package/src/drafts/draft19/data-streams.ts +570 -482
- package/src/drafts/draft19/error-codes.ts +3 -1
- package/src/drafts/draft19/index.ts +3 -0
- package/src/drafts/draft19/messages.ts +3 -1
- package/src/drafts/draft19/types.ts +22 -11
- package/src/drafts/draft20/codec.ts +90 -23
- package/src/drafts/draft20/data-streams.ts +610 -563
- package/src/drafts/draft20/index.ts +3 -0
- package/src/drafts/draft20/types.ts +14 -2
- package/src/drafts/draft21/codec.ts +1816 -0
- package/src/drafts/draft21/data-streams.ts +1338 -0
- package/src/drafts/draft21/error-codes.ts +135 -0
- package/src/drafts/draft21/index.ts +168 -0
- package/src/drafts/draft21/messages.ts +68 -0
- package/src/drafts/draft21/rules.ts +107 -0
- package/src/drafts/draft21/session-fsm.ts +1063 -0
- package/src/drafts/draft21/session.ts +21 -0
- package/src/drafts/draft21/types.ts +473 -0
- package/src/index.ts +9 -1
- package/src/session.ts +4 -0
- package/dist/codec-BJ7BHuiZ.d.ts +0 -18
- package/dist/codec-C6Mx4bwz.d.cts +0 -18
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Draft-16 error, status and termination code registries.
|
|
2
|
+
|
|
3
|
+
export const SessionErrorCode = {
|
|
4
|
+
NoError: 0x0n,
|
|
5
|
+
InternalError: 0x1n,
|
|
6
|
+
Unauthorized: 0x2n,
|
|
7
|
+
ProtocolViolation: 0x3n,
|
|
8
|
+
InvalidRequestId: 0x4n,
|
|
9
|
+
DuplicateTrackAlias: 0x5n,
|
|
10
|
+
KeyValueFormattingError: 0x6n,
|
|
11
|
+
TooManyRequests: 0x7n,
|
|
12
|
+
InvalidPath: 0x8n,
|
|
13
|
+
MalformedPath: 0x9n,
|
|
14
|
+
GoawayTimeout: 0x10n,
|
|
15
|
+
ControlMessageTimeout: 0x11n,
|
|
16
|
+
DataStreamTimeout: 0x12n,
|
|
17
|
+
AuthTokenCacheOverflow: 0x13n,
|
|
18
|
+
DuplicateAuthTokenAlias: 0x14n,
|
|
19
|
+
VersionNegotiationFailed: 0x15n,
|
|
20
|
+
MalformedAuthToken: 0x16n,
|
|
21
|
+
UnknownAuthTokenAlias: 0x17n,
|
|
22
|
+
ExpiredAuthToken: 0x18n,
|
|
23
|
+
InvalidAuthority: 0x19n,
|
|
24
|
+
MalformedAuthority: 0x1an,
|
|
25
|
+
} as const
|
|
26
|
+
export type SessionErrorCodeValue = (typeof SessionErrorCode)[keyof typeof SessionErrorCode]
|
|
27
|
+
|
|
28
|
+
export const RequestErrorCode = {
|
|
29
|
+
InternalError: 0x0n,
|
|
30
|
+
Unauthorized: 0x1n,
|
|
31
|
+
Timeout: 0x2n,
|
|
32
|
+
NotSupported: 0x3n,
|
|
33
|
+
MalformedAuthToken: 0x4n,
|
|
34
|
+
ExpiredAuthToken: 0x5n,
|
|
35
|
+
DoesNotExist: 0x10n,
|
|
36
|
+
InvalidRange: 0x11n,
|
|
37
|
+
MalformedTrack: 0x12n,
|
|
38
|
+
DuplicateSubscription: 0x19n,
|
|
39
|
+
Uninterested: 0x20n,
|
|
40
|
+
PrefixOverlap: 0x30n,
|
|
41
|
+
InvalidJoiningRequestId: 0x32n,
|
|
42
|
+
} as const
|
|
43
|
+
export type RequestErrorCodeValue = (typeof RequestErrorCode)[keyof typeof RequestErrorCode]
|
|
44
|
+
|
|
45
|
+
export const PublishDoneStatusCode = {
|
|
46
|
+
InternalError: 0x0n,
|
|
47
|
+
Unauthorized: 0x1n,
|
|
48
|
+
TrackEnded: 0x2n,
|
|
49
|
+
SubscriptionEnded: 0x3n,
|
|
50
|
+
GoingAway: 0x4n,
|
|
51
|
+
Expired: 0x5n,
|
|
52
|
+
TooFarBehind: 0x6n,
|
|
53
|
+
UpdateFailed: 0x8n,
|
|
54
|
+
MalformedTrack: 0x12n,
|
|
55
|
+
} as const
|
|
56
|
+
export type PublishDoneStatusCodeValue =
|
|
57
|
+
(typeof PublishDoneStatusCode)[keyof typeof PublishDoneStatusCode]
|
|
58
|
+
|
|
59
|
+
export const DataStreamResetErrorCode = {
|
|
60
|
+
InternalError: 0x0n,
|
|
61
|
+
Cancelled: 0x1n,
|
|
62
|
+
DeliveryTimeout: 0x2n,
|
|
63
|
+
SessionClosed: 0x3n,
|
|
64
|
+
UnknownObjectStatus: 0x4n,
|
|
65
|
+
MalformedTrack: 0x12n,
|
|
66
|
+
} as const
|
|
67
|
+
export type DataStreamResetErrorCodeValue =
|
|
68
|
+
(typeof DataStreamResetErrorCode)[keyof typeof DataStreamResetErrorCode]
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const DRAFT_VERSION = 0xff000010n
|
|
2
2
|
|
|
3
|
+
export type { AuthRedaction } from '../../core/auth-redaction.js'
|
|
4
|
+
export { REDACTION_FILL } from '../../core/auth-redaction.js'
|
|
3
5
|
export type { Draft16Codec } from './codec.js'
|
|
4
6
|
export {
|
|
5
7
|
createDataStreamDecoder,
|
|
@@ -16,7 +18,20 @@ export {
|
|
|
16
18
|
encodeFetchStream,
|
|
17
19
|
encodeMessage,
|
|
18
20
|
encodeSubgroupStream,
|
|
21
|
+
redactAuthTokens,
|
|
19
22
|
} from './codec.js'
|
|
23
|
+
export type {
|
|
24
|
+
DataStreamResetErrorCodeValue,
|
|
25
|
+
PublishDoneStatusCodeValue,
|
|
26
|
+
RequestErrorCodeValue,
|
|
27
|
+
SessionErrorCodeValue,
|
|
28
|
+
} from './error-codes.js'
|
|
29
|
+
export {
|
|
30
|
+
DataStreamResetErrorCode,
|
|
31
|
+
PublishDoneStatusCode,
|
|
32
|
+
RequestErrorCode,
|
|
33
|
+
SessionErrorCode,
|
|
34
|
+
} from './error-codes.js'
|
|
20
35
|
export {
|
|
21
36
|
MESSAGE_ID_MAP,
|
|
22
37
|
MESSAGE_TYPE_MAP,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// Draft-16 message type wire IDs
|
|
2
2
|
|
|
3
|
-
export const MSG_REQUEST_UPDATE = 0x02n
|
|
3
|
+
export const MSG_REQUEST_UPDATE = 0x02n
|
|
4
4
|
export const MSG_SUBSCRIBE = 0x03n
|
|
5
5
|
export const MSG_SUBSCRIBE_OK = 0x04n
|
|
6
6
|
export const MSG_REQUEST_ERROR = 0x05n
|
|
7
7
|
export const MSG_PUBLISH_NAMESPACE = 0x06n
|
|
8
8
|
export const MSG_REQUEST_OK = 0x07n
|
|
9
|
-
export const MSG_NAMESPACE = 0x08n //
|
|
9
|
+
export const MSG_NAMESPACE = 0x08n // NAMESPACE (draft-16 Section 9.21); draft-15 has no 0x8 control message
|
|
10
10
|
export const MSG_PUBLISH_NAMESPACE_DONE = 0x09n
|
|
11
11
|
export const MSG_UNSUBSCRIBE = 0x0an
|
|
12
12
|
export const MSG_PUBLISH_DONE = 0x0bn
|
|
13
13
|
export const MSG_PUBLISH_NAMESPACE_CANCEL = 0x0cn
|
|
14
14
|
export const MSG_TRACK_STATUS = 0x0dn
|
|
15
|
-
export const MSG_NAMESPACE_DONE = 0x0en //
|
|
15
|
+
export const MSG_NAMESPACE_DONE = 0x0en // NAMESPACE_DONE (draft-16 Section 9.23); draft-15 has no 0xE control message
|
|
16
16
|
export const MSG_GOAWAY = 0x10n
|
|
17
17
|
export const MSG_SUBSCRIBE_NAMESPACE = 0x11n
|
|
18
|
-
// 0x14
|
|
18
|
+
// 0x14 is unassigned in draft-16 (Section 9, Table 1); draft-15 binds it to UNSUBSCRIBE_NAMESPACE.
|
|
19
19
|
export const MSG_MAX_REQUEST_ID = 0x15n
|
|
20
20
|
export const MSG_FETCH = 0x16n
|
|
21
21
|
export const MSG_FETCH_CANCEL = 0x17n
|
|
@@ -41,7 +41,9 @@ export interface LargestObject {
|
|
|
41
41
|
readonly object: bigint
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// Track
|
|
44
|
+
// Track Extensions — a trailing sequence of Extension Headers on SUBSCRIBE_OK, PUBLISH and
|
|
45
|
+
// FETCH_OK, carried alongside the parameters rather than among them; draft-16 is the only
|
|
46
|
+
// draft that carries it
|
|
45
47
|
export interface Draft16TrackExtensions {
|
|
46
48
|
delivery_timeout?: bigint // 0x02 even
|
|
47
49
|
max_cache_duration?: bigint // 0x04 even
|
|
@@ -109,7 +111,8 @@ export interface Draft16ServerSetup extends Draft16BaseMessage {
|
|
|
109
111
|
readonly parameters: Draft16SetupParams
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
//
|
|
114
|
+
// SUBSCRIBE — type 0x3; drafts 07-14 carry the subscriber priority, group order, filter and
|
|
115
|
+
// (from draft-11) forward flag as fields of the message, drafts 15 and 16 as parameters
|
|
113
116
|
export interface Draft16Subscribe extends Draft16BaseMessage {
|
|
114
117
|
readonly type: 'subscribe'
|
|
115
118
|
readonly request_id: bigint
|
|
@@ -126,7 +129,7 @@ export interface Draft16SubscribeOk extends Draft16BaseMessage {
|
|
|
126
129
|
readonly track_extensions?: Draft16TrackExtensions
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
//
|
|
132
|
+
// Request Update — type 0x2; drafts 07-15 name the same codepoint SUBSCRIBE_UPDATE
|
|
130
133
|
export interface Draft16RequestUpdate extends Draft16BaseMessage {
|
|
131
134
|
readonly type: 'request_update'
|
|
132
135
|
readonly request_id: bigint
|
|
@@ -172,13 +175,17 @@ export interface Draft16PublishNamespace extends Draft16BaseMessage {
|
|
|
172
175
|
readonly parameters: Draft16Params
|
|
173
176
|
}
|
|
174
177
|
|
|
175
|
-
//
|
|
178
|
+
// PUBLISH_NAMESPACE_DONE — type 0x9, keyed by request_id here; drafts 07-15 carry the Track
|
|
179
|
+
// Namespace in that position and name the codepoint UNANNOUNCE before draft-14; no draft from
|
|
180
|
+
// 17 on carries the message
|
|
176
181
|
export interface Draft16PublishNamespaceDone extends Draft16BaseMessage {
|
|
177
182
|
readonly type: 'publish_namespace_done'
|
|
178
183
|
readonly request_id: bigint
|
|
179
184
|
}
|
|
180
185
|
|
|
181
|
-
//
|
|
186
|
+
// PUBLISH_NAMESPACE_CANCEL — type 0xC, keyed by request_id here; drafts 07-15 carry the Track
|
|
187
|
+
// Namespace in that position with the same error_code + reason_phrase after it, and name the
|
|
188
|
+
// codepoint ANNOUNCE_CANCEL before draft-14; no draft from 17 on carries the message
|
|
182
189
|
export interface Draft16PublishNamespaceCancel extends Draft16BaseMessage {
|
|
183
190
|
readonly type: 'publish_namespace_cancel'
|
|
184
191
|
readonly request_id: bigint
|
|
@@ -186,7 +193,7 @@ export interface Draft16PublishNamespaceCancel extends Draft16BaseMessage {
|
|
|
186
193
|
readonly reason_phrase: string
|
|
187
194
|
}
|
|
188
195
|
|
|
189
|
-
//
|
|
196
|
+
// Only drafts 16 and 17 carry a subscribe_options field on SUBSCRIBE_NAMESPACE
|
|
190
197
|
export interface Draft16SubscribeNamespace extends Draft16BaseMessage {
|
|
191
198
|
readonly type: 'subscribe_namespace'
|
|
192
199
|
readonly request_id: bigint
|
|
@@ -207,7 +214,7 @@ export interface Draft16NamespaceDone extends Draft16BaseMessage {
|
|
|
207
214
|
readonly namespace_suffix: string[]
|
|
208
215
|
}
|
|
209
216
|
|
|
210
|
-
//
|
|
217
|
+
// No draft from 16 on carries UNSUBSCRIBE_NAMESPACE; drafts 13 through 15 do
|
|
211
218
|
|
|
212
219
|
// Fetch — same structure as draft-15
|
|
213
220
|
export interface StandaloneFetch {
|
|
@@ -264,7 +271,7 @@ export interface Draft16RequestOk extends Draft16BaseMessage {
|
|
|
264
271
|
readonly parameters: Draft16Params
|
|
265
272
|
}
|
|
266
273
|
|
|
267
|
-
//
|
|
274
|
+
// REQUEST_ERROR — type 0x5; draft-15's carries no retry_interval, every draft from 16 on does
|
|
268
275
|
export interface Draft16RequestError extends Draft16BaseMessage {
|
|
269
276
|
readonly type: 'request_error'
|
|
270
277
|
readonly request_id: bigint
|
|
@@ -371,10 +378,17 @@ export type Draft16DataStream = SubgroupStream | DatagramObject | FetchStream
|
|
|
371
378
|
// Streaming data stream decoder types
|
|
372
379
|
export interface SubgroupStreamHeader {
|
|
373
380
|
readonly type: 'subgroup_header'
|
|
381
|
+
/**
|
|
382
|
+
* The stream Type Flags, the same value `SubgroupStream.headerType` carries.
|
|
383
|
+
* Without it the incremental decoder drops every flag the header encodes
|
|
384
|
+
* and a consumer cannot tell the modes apart.
|
|
385
|
+
*/
|
|
386
|
+
readonly headerType: number
|
|
374
387
|
readonly trackAlias: bigint
|
|
375
388
|
readonly groupId: bigint
|
|
376
389
|
readonly subgroupId: bigint
|
|
377
390
|
readonly publisherPriority: number
|
|
391
|
+
readonly endOfGroup?: boolean
|
|
378
392
|
}
|
|
379
393
|
|
|
380
394
|
export interface FetchStreamHeader {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthRedaction, recordAuthValueSpan, redactWith } from '../../core/auth-redaction.js'
|
|
1
2
|
import { Draft17BufferReader as BufferReader } from '../../core/buffer-reader.js'
|
|
2
3
|
import { Draft17BufferWriter as BufferWriter } from '../../core/buffer-writer.js'
|
|
3
4
|
import { bytesToHex, hexToBytes } from '../../core/hex.js'
|
|
@@ -168,10 +169,9 @@ function decodeSetupOptions(reader: BufferReader, payloadEnd: number): Draft17Se
|
|
|
168
169
|
if (optType === SETUP_OPT_PATH) {
|
|
169
170
|
result.path = textDecoder.decode(bytes)
|
|
170
171
|
} else if (optType === SETUP_OPT_AUTHORIZATION_TOKEN) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
]
|
|
172
|
+
const token = decodeAuthorizationToken(new BufferReader(bytes))
|
|
173
|
+
noteAuthTokenValue(reader.offset - length, length, token.token_value)
|
|
174
|
+
result.authorization_token = [...(result.authorization_token ?? []), token]
|
|
175
175
|
} else if (optType === SETUP_OPT_AUTHORITY) {
|
|
176
176
|
result.authority = textDecoder.decode(bytes)
|
|
177
177
|
} else if (optType === SETUP_OPT_MOQT_IMPLEMENTATION) {
|
|
@@ -200,10 +200,14 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
|
|
|
200
200
|
w.writeVarInt(token.token_alias ?? 0n)
|
|
201
201
|
}
|
|
202
202
|
if (aliasType === 1 || aliasType === 3) {
|
|
203
|
-
// REGISTER, USE_VALUE: token_type + token_value present
|
|
203
|
+
// REGISTER, USE_VALUE: token_type + token_value present.
|
|
204
|
+
// In draft-17 the Token Value is NOT length-prefixed inside the Token
|
|
205
|
+
// structure; it consumes the remainder of the outer length-prefixed buffer.
|
|
206
|
+
// Figure 5 writes it as `Token Value (..)`, and the only length genuinely
|
|
207
|
+
// present is the Key-Value-Pair's own, which is what "uses Length-prefixed
|
|
208
|
+
// encoding" describes. Draft-18 repeats that figure and prose verbatim.
|
|
204
209
|
w.writeVarInt(token.token_type ?? 0n)
|
|
205
210
|
const tv = token.token_value ?? new Uint8Array(0)
|
|
206
|
-
w.writeVarInt(BigInt(tv.byteLength))
|
|
207
211
|
w.writeBytes(tv)
|
|
208
212
|
}
|
|
209
213
|
}
|
|
@@ -218,8 +222,8 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
|
|
|
218
222
|
}
|
|
219
223
|
if (aliasType === 1 || aliasType === 3) {
|
|
220
224
|
;(result as { token_type: bigint }).token_type = r.readVarInt()
|
|
221
|
-
|
|
222
|
-
const bytes = r.readBytes(
|
|
225
|
+
// Token Value extends to the end of the outer length-prefixed buffer
|
|
226
|
+
const bytes = r.readBytes(r.remaining)
|
|
223
227
|
;(result as { token_value: Uint8Array }).token_value = bytes
|
|
224
228
|
}
|
|
225
229
|
|
|
@@ -414,10 +418,9 @@ function decodeParams(reader: BufferReader, messageType: string): Draft17Params
|
|
|
414
418
|
} else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
|
|
415
419
|
const length = Number(reader.readVarInt())
|
|
416
420
|
const bytes = reader.readBytes(length)
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
]
|
|
421
|
+
const token = decodeAuthorizationToken(new BufferReader(bytes))
|
|
422
|
+
noteAuthTokenValue(reader.offset - length, length, token.token_value)
|
|
423
|
+
result.authorization_token = [...(result.authorization_token ?? []), token]
|
|
421
424
|
} else if (paramType === PARAM_RENDEZVOUS_TIMEOUT) {
|
|
422
425
|
result.rendezvous_timeout = reader.readVarInt()
|
|
423
426
|
} else if (paramType === PARAM_EXPIRES) {
|
|
@@ -1250,3 +1253,61 @@ export function createDraft17Codec(): Draft17Codec {
|
|
|
1250
1253
|
createDataStreamDecoder,
|
|
1251
1254
|
}
|
|
1252
1255
|
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Record where a Token Value sits, so it can be overwritten before the frame
|
|
1259
|
+
* reaches anything that keeps it.
|
|
1260
|
+
*
|
|
1261
|
+
* The span falls out of the decode with no second walk. The Token Value is the
|
|
1262
|
+
* last field of the Token structure, so its start is the parameter value's end
|
|
1263
|
+
* minus the value's own length. The fields before it are left alone
|
|
1264
|
+
* deliberately: Alias Type, Token Alias and Token Type are structure rather
|
|
1265
|
+
* than secret, and they are what distinguishes a session that failed to
|
|
1266
|
+
* authenticate from one that never tried.
|
|
1267
|
+
*
|
|
1268
|
+
* A token carrying no value at all -- DELETE and USE_ALIAS -- records nothing,
|
|
1269
|
+
* and its frame passes through untouched.
|
|
1270
|
+
*/
|
|
1271
|
+
function noteAuthTokenValue(
|
|
1272
|
+
valueStart: number,
|
|
1273
|
+
valueLength: number,
|
|
1274
|
+
value: Uint8Array | undefined,
|
|
1275
|
+
): void {
|
|
1276
|
+
if (value === undefined || value.byteLength === 0) return
|
|
1277
|
+
recordAuthValueSpan(valueStart + valueLength - value.byteLength, value.byteLength)
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Overwrite every Authorization Token value in a draft-17 control frame.
|
|
1282
|
+
*
|
|
1283
|
+
* One decode, whose *output is discarded*: the point is not to read the
|
|
1284
|
+
* message, it is to learn where the credentials were so the caller never has to
|
|
1285
|
+
* hold a frame that contains one. A caller that also wants the message should
|
|
1286
|
+
* decode the **redacted** frame with {@link decodeMessage}, which then cannot
|
|
1287
|
+
* produce a value because there is no longer one in the bytes.
|
|
1288
|
+
*
|
|
1289
|
+
* A frame that fails to decode is still redacted as far as the decode got. That
|
|
1290
|
+
* is the useful direction to fail in: a value that was read is a value that was
|
|
1291
|
+
* exposed, whatever went wrong after it.
|
|
1292
|
+
*
|
|
1293
|
+
* See {@link AuthRedaction.incomplete} for the one result a caller must not
|
|
1294
|
+
* treat as clean, and {@link AuthRedaction.decoded} for the residual it cannot
|
|
1295
|
+
* close.
|
|
1296
|
+
*/
|
|
1297
|
+
export function redactAuthTokens(bytes: Uint8Array): AuthRedaction {
|
|
1298
|
+
let payloadStart: number
|
|
1299
|
+
try {
|
|
1300
|
+
const probe = new BufferReader(bytes)
|
|
1301
|
+
probe.readVarInt()
|
|
1302
|
+
probe.readUint8()
|
|
1303
|
+
probe.readUint8()
|
|
1304
|
+
payloadStart = probe.offset
|
|
1305
|
+
} catch {
|
|
1306
|
+
// Too short to carry a message header, and so too short for the parameters
|
|
1307
|
+
// that carry a credential. Reported as not decoded rather than as clean: a
|
|
1308
|
+
// framer only ever emits complete frames, so a caller that gets here is
|
|
1309
|
+
// holding something this function did not check.
|
|
1310
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false }
|
|
1311
|
+
}
|
|
1312
|
+
return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok)
|
|
1313
|
+
}
|