@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthRedaction, recordAuthValueSpan, redactWith } from '../../core/auth-redaction.js'
|
|
1
2
|
import { BufferReader } from '../../core/buffer-reader.js'
|
|
2
3
|
import { BufferWriter } from '../../core/buffer-writer.js'
|
|
3
4
|
import { bytesToHex, hexToBytes } from '../../core/hex.js'
|
|
@@ -213,6 +214,11 @@ function decodeParams(r: BufferReader): Draft07Params {
|
|
|
213
214
|
|
|
214
215
|
if (paramType === PARAM_AUTHORIZATION_INFO) {
|
|
215
216
|
const bytes = r.readBytes(length)
|
|
217
|
+
// The credential is the whole value in this draft: a bare UTF-8 string,
|
|
218
|
+
// with no alias and no token type around it. What survives the overwrite
|
|
219
|
+
// is the parameter's presence, which is what says authorization was
|
|
220
|
+
// attempted at all.
|
|
221
|
+
recordAuthValueSpan(r.offset - length, length)
|
|
216
222
|
result.authorization_info = textDecoder.decode(bytes)
|
|
217
223
|
} else if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
218
224
|
const blob = r.readBytes(length)
|
|
@@ -1056,3 +1062,37 @@ export function createDraft07Codec(): Draft07Codec {
|
|
|
1056
1062
|
|
|
1057
1063
|
// Export data-stream decoder map for callers that need to disambiguate
|
|
1058
1064
|
export { dataStreamDecoders }
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Overwrite every AUTHORIZATION_INFO value in a draft-07 control frame.
|
|
1068
|
+
*
|
|
1069
|
+
* One decode, whose *output is discarded*: the point is not to read the
|
|
1070
|
+
* message, it is to learn where the credentials were so the caller never has to
|
|
1071
|
+
* hold a frame that contains one. A caller that also wants the message should
|
|
1072
|
+
* decode the **redacted** frame with {@link decodeMessage}, which then cannot
|
|
1073
|
+
* produce a value because there is no longer one in the bytes.
|
|
1074
|
+
*
|
|
1075
|
+
* A frame that fails to decode is still redacted as far as the decode got. That
|
|
1076
|
+
* is the useful direction to fail in: a value that was read is a value that was
|
|
1077
|
+
* exposed, whatever went wrong after it.
|
|
1078
|
+
*
|
|
1079
|
+
* See {@link AuthRedaction.incomplete} for the one result a caller must not
|
|
1080
|
+
* treat as clean, and {@link AuthRedaction.decoded} for the residual it cannot
|
|
1081
|
+
* close.
|
|
1082
|
+
*/
|
|
1083
|
+
export function redactAuthTokens(bytes: Uint8Array): AuthRedaction {
|
|
1084
|
+
let payloadStart: number
|
|
1085
|
+
try {
|
|
1086
|
+
const probe = new BufferReader(bytes)
|
|
1087
|
+
probe.readVarInt()
|
|
1088
|
+
probe.readVarInt()
|
|
1089
|
+
payloadStart = probe.offset
|
|
1090
|
+
} catch {
|
|
1091
|
+
// Too short to carry a message header, and so too short for the parameters
|
|
1092
|
+
// that carry a credential. Reported as not decoded rather than as clean: a
|
|
1093
|
+
// framer only ever emits complete frames, so a caller that gets here is
|
|
1094
|
+
// holding something this function did not check.
|
|
1095
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false }
|
|
1096
|
+
}
|
|
1097
|
+
return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok)
|
|
1098
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Draft-07 error, status and termination code registries.
|
|
2
|
+
|
|
3
|
+
export const SessionErrorCode = {
|
|
4
|
+
NoError: 0x0n,
|
|
5
|
+
InternalError: 0x1n,
|
|
6
|
+
Unauthorized: 0x2n,
|
|
7
|
+
ProtocolViolation: 0x3n,
|
|
8
|
+
DuplicateTrackAlias: 0x4n,
|
|
9
|
+
ParameterLengthMismatch: 0x5n,
|
|
10
|
+
TooManySubscribes: 0x6n,
|
|
11
|
+
GoawayTimeout: 0x10n,
|
|
12
|
+
} as const
|
|
13
|
+
export type SessionErrorCodeValue = (typeof SessionErrorCode)[keyof typeof SessionErrorCode]
|
|
14
|
+
|
|
15
|
+
export const SubscribeErrorCode = {
|
|
16
|
+
InternalError: 0x0n,
|
|
17
|
+
InvalidRange: 0x1n,
|
|
18
|
+
RetryTrackAlias: 0x2n,
|
|
19
|
+
TrackDoesNotExist: 0x3n,
|
|
20
|
+
Unauthorized: 0x4n,
|
|
21
|
+
Timeout: 0x5n,
|
|
22
|
+
} as const
|
|
23
|
+
export type SubscribeErrorCodeValue = (typeof SubscribeErrorCode)[keyof typeof SubscribeErrorCode]
|
|
24
|
+
|
|
25
|
+
export const SubscribeDoneStatusCode = {
|
|
26
|
+
Unsubscribed: 0x0n,
|
|
27
|
+
InternalError: 0x1n,
|
|
28
|
+
Unauthorized: 0x2n,
|
|
29
|
+
TrackEnded: 0x3n,
|
|
30
|
+
SubscriptionEnded: 0x4n,
|
|
31
|
+
GoingAway: 0x5n,
|
|
32
|
+
Expired: 0x6n,
|
|
33
|
+
} as const
|
|
34
|
+
export type SubscribeDoneStatusCodeValue =
|
|
35
|
+
(typeof SubscribeDoneStatusCode)[keyof typeof SubscribeDoneStatusCode]
|
|
36
|
+
|
|
37
|
+
export const TrackStatusCode = {
|
|
38
|
+
InProgress: 0x00n,
|
|
39
|
+
TrackDoesNotExist: 0x01n,
|
|
40
|
+
NotYetBegun: 0x02n,
|
|
41
|
+
Finished: 0x03n,
|
|
42
|
+
RelayStatusUnavailable: 0x04n,
|
|
43
|
+
} as const
|
|
44
|
+
export type TrackStatusCodeValue = (typeof TrackStatusCode)[keyof typeof TrackStatusCode]
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const DRAFT_VERSION = 0xff000007n
|
|
2
2
|
|
|
3
|
+
export type { AuthRedaction } from '../../core/auth-redaction.js'
|
|
4
|
+
export { REDACTION_FILL } from '../../core/auth-redaction.js'
|
|
3
5
|
export type { DecodeErrorCode, DecodeResult } from '../../core/types.js'
|
|
4
6
|
// Re-export types consumers need
|
|
5
7
|
export { DecodeError } from '../../core/types.js'
|
|
@@ -12,7 +14,20 @@ export {
|
|
|
12
14
|
encodeDatagram,
|
|
13
15
|
encodeFetchStream,
|
|
14
16
|
encodeSubgroupStream,
|
|
17
|
+
redactAuthTokens,
|
|
15
18
|
} from './codec.js'
|
|
19
|
+
export type {
|
|
20
|
+
SessionErrorCodeValue,
|
|
21
|
+
SubscribeDoneStatusCodeValue,
|
|
22
|
+
SubscribeErrorCodeValue,
|
|
23
|
+
TrackStatusCodeValue,
|
|
24
|
+
} from './error-codes.js'
|
|
25
|
+
export {
|
|
26
|
+
SessionErrorCode,
|
|
27
|
+
SubscribeDoneStatusCode,
|
|
28
|
+
SubscribeErrorCode,
|
|
29
|
+
TrackStatusCode,
|
|
30
|
+
} from './error-codes.js'
|
|
16
31
|
export {
|
|
17
32
|
MESSAGE_ID_MAP,
|
|
18
33
|
MESSAGE_TYPE_MAP,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthRedaction, recordAuthValueSpan, redactWith } from '../../core/auth-redaction.js'
|
|
1
2
|
import { BufferReader } from '../../core/buffer-reader.js'
|
|
2
3
|
import { BufferWriter } from '../../core/buffer-writer.js'
|
|
3
4
|
import { bytesToHex, hexToBytes } from '../../core/hex.js'
|
|
@@ -183,6 +184,11 @@ function decodeParams(r: BufferReader): Draft08Params {
|
|
|
183
184
|
|
|
184
185
|
if (paramType === PARAM_AUTHORIZATION_INFO) {
|
|
185
186
|
const bytes = r.readBytes(length)
|
|
187
|
+
// The credential is the whole value in this draft: a bare UTF-8 string,
|
|
188
|
+
// with no alias and no token type around it. What survives the overwrite
|
|
189
|
+
// is the parameter's presence, which is what says authorization was
|
|
190
|
+
// attempted at all.
|
|
191
|
+
recordAuthValueSpan(r.offset - length, length)
|
|
186
192
|
result.authorization_info = textDecoder.decode(bytes)
|
|
187
193
|
} else if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
188
194
|
const blob = r.readBytes(length)
|
|
@@ -983,3 +989,37 @@ export function createDraft08Codec(): Draft08Codec {
|
|
|
983
989
|
createStreamDecoder,
|
|
984
990
|
}
|
|
985
991
|
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Overwrite every AUTHORIZATION_INFO value in a draft-08 control frame.
|
|
995
|
+
*
|
|
996
|
+
* One decode, whose *output is discarded*: the point is not to read the
|
|
997
|
+
* message, it is to learn where the credentials were so the caller never has to
|
|
998
|
+
* hold a frame that contains one. A caller that also wants the message should
|
|
999
|
+
* decode the **redacted** frame with {@link decodeMessage}, which then cannot
|
|
1000
|
+
* produce a value because there is no longer one in the bytes.
|
|
1001
|
+
*
|
|
1002
|
+
* A frame that fails to decode is still redacted as far as the decode got. That
|
|
1003
|
+
* is the useful direction to fail in: a value that was read is a value that was
|
|
1004
|
+
* exposed, whatever went wrong after it.
|
|
1005
|
+
*
|
|
1006
|
+
* See {@link AuthRedaction.incomplete} for the one result a caller must not
|
|
1007
|
+
* treat as clean, and {@link AuthRedaction.decoded} for the residual it cannot
|
|
1008
|
+
* close.
|
|
1009
|
+
*/
|
|
1010
|
+
export function redactAuthTokens(bytes: Uint8Array): AuthRedaction {
|
|
1011
|
+
let payloadStart: number
|
|
1012
|
+
try {
|
|
1013
|
+
const probe = new BufferReader(bytes)
|
|
1014
|
+
probe.readVarInt()
|
|
1015
|
+
probe.readVarInt()
|
|
1016
|
+
payloadStart = probe.offset
|
|
1017
|
+
} catch {
|
|
1018
|
+
// Too short to carry a message header, and so too short for the parameters
|
|
1019
|
+
// that carry a credential. Reported as not decoded rather than as clean: a
|
|
1020
|
+
// framer only ever emits complete frames, so a caller that gets here is
|
|
1021
|
+
// holding something this function did not check.
|
|
1022
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false }
|
|
1023
|
+
}
|
|
1024
|
+
return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok)
|
|
1025
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Draft-08 error, status and termination code registries.
|
|
2
|
+
|
|
3
|
+
export const SessionErrorCode = {
|
|
4
|
+
NoError: 0x0n,
|
|
5
|
+
InternalError: 0x1n,
|
|
6
|
+
Unauthorized: 0x2n,
|
|
7
|
+
ProtocolViolation: 0x3n,
|
|
8
|
+
DuplicateTrackAlias: 0x4n,
|
|
9
|
+
ParameterLengthMismatch: 0x5n,
|
|
10
|
+
TooManySubscribes: 0x6n,
|
|
11
|
+
GoawayTimeout: 0x10n,
|
|
12
|
+
ControlMessageTimeout: 0x11n,
|
|
13
|
+
DataStreamTimeout: 0x12n,
|
|
14
|
+
} as const
|
|
15
|
+
export type SessionErrorCodeValue = (typeof SessionErrorCode)[keyof typeof SessionErrorCode]
|
|
16
|
+
|
|
17
|
+
export const AnnounceErrorCode = {
|
|
18
|
+
InternalError: 0x0n,
|
|
19
|
+
Unauthorized: 0x1n,
|
|
20
|
+
Timeout: 0x2n,
|
|
21
|
+
NotSupported: 0x3n,
|
|
22
|
+
Uninterested: 0x4n,
|
|
23
|
+
} as const
|
|
24
|
+
export type AnnounceErrorCodeValue = (typeof AnnounceErrorCode)[keyof typeof AnnounceErrorCode]
|
|
25
|
+
|
|
26
|
+
export const SubscribeErrorCode = {
|
|
27
|
+
InternalError: 0x0n,
|
|
28
|
+
Unauthorized: 0x1n,
|
|
29
|
+
Timeout: 0x2n,
|
|
30
|
+
NotSupported: 0x3n,
|
|
31
|
+
TrackDoesNotExist: 0x4n,
|
|
32
|
+
InvalidRange: 0x5n,
|
|
33
|
+
RetryTrackAlias: 0x6n,
|
|
34
|
+
} as const
|
|
35
|
+
export type SubscribeErrorCodeValue = (typeof SubscribeErrorCode)[keyof typeof SubscribeErrorCode]
|
|
36
|
+
|
|
37
|
+
export const FetchErrorCode = {
|
|
38
|
+
InternalError: 0x0n,
|
|
39
|
+
Unauthorized: 0x1n,
|
|
40
|
+
Timeout: 0x2n,
|
|
41
|
+
NotSupported: 0x3n,
|
|
42
|
+
TrackDoesNotExist: 0x4n,
|
|
43
|
+
InvalidRange: 0x5n,
|
|
44
|
+
} as const
|
|
45
|
+
export type FetchErrorCodeValue = (typeof FetchErrorCode)[keyof typeof FetchErrorCode]
|
|
46
|
+
|
|
47
|
+
export const SubscribeDoneStatusCode = {
|
|
48
|
+
InternalError: 0x0n,
|
|
49
|
+
Unauthorized: 0x1n,
|
|
50
|
+
TrackEnded: 0x2n,
|
|
51
|
+
SubscriptionEnded: 0x3n,
|
|
52
|
+
GoingAway: 0x4n,
|
|
53
|
+
Expired: 0x5n,
|
|
54
|
+
TooFarBehind: 0x6n,
|
|
55
|
+
} as const
|
|
56
|
+
export type SubscribeDoneStatusCodeValue =
|
|
57
|
+
(typeof SubscribeDoneStatusCode)[keyof typeof SubscribeDoneStatusCode]
|
|
58
|
+
|
|
59
|
+
export const SubscribeAnnouncesErrorCode = {
|
|
60
|
+
InternalError: 0x0n,
|
|
61
|
+
Unauthorized: 0x1n,
|
|
62
|
+
Timeout: 0x2n,
|
|
63
|
+
NotSupported: 0x3n,
|
|
64
|
+
NamespacePrefixUnknown: 0x4n,
|
|
65
|
+
} as const
|
|
66
|
+
export type SubscribeAnnouncesErrorCodeValue =
|
|
67
|
+
(typeof SubscribeAnnouncesErrorCode)[keyof typeof SubscribeAnnouncesErrorCode]
|
|
68
|
+
|
|
69
|
+
export const TrackStatusCode = {
|
|
70
|
+
InProgress: 0x00n,
|
|
71
|
+
TrackDoesNotExist: 0x01n,
|
|
72
|
+
NotYetBegun: 0x02n,
|
|
73
|
+
Finished: 0x03n,
|
|
74
|
+
RelayStatusUnavailable: 0x04n,
|
|
75
|
+
} as const
|
|
76
|
+
export type TrackStatusCodeValue = (typeof TrackStatusCode)[keyof typeof TrackStatusCode]
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const DRAFT_VERSION = 0xff000008n
|
|
2
2
|
|
|
3
|
+
export type { AuthRedaction } from '../../core/auth-redaction.js'
|
|
4
|
+
export { REDACTION_FILL } from '../../core/auth-redaction.js'
|
|
3
5
|
export type { Draft08Codec } from './codec.js'
|
|
4
6
|
export {
|
|
5
7
|
createDraft08Codec,
|
|
@@ -15,7 +17,26 @@ export {
|
|
|
15
17
|
encodeFetchStream,
|
|
16
18
|
encodeMessage,
|
|
17
19
|
encodeSubgroupStream,
|
|
20
|
+
redactAuthTokens,
|
|
18
21
|
} from './codec.js'
|
|
22
|
+
export type {
|
|
23
|
+
AnnounceErrorCodeValue,
|
|
24
|
+
FetchErrorCodeValue,
|
|
25
|
+
SessionErrorCodeValue,
|
|
26
|
+
SubscribeAnnouncesErrorCodeValue,
|
|
27
|
+
SubscribeDoneStatusCodeValue,
|
|
28
|
+
SubscribeErrorCodeValue,
|
|
29
|
+
TrackStatusCodeValue,
|
|
30
|
+
} from './error-codes.js'
|
|
31
|
+
export {
|
|
32
|
+
AnnounceErrorCode,
|
|
33
|
+
FetchErrorCode,
|
|
34
|
+
SessionErrorCode,
|
|
35
|
+
SubscribeAnnouncesErrorCode,
|
|
36
|
+
SubscribeDoneStatusCode,
|
|
37
|
+
SubscribeErrorCode,
|
|
38
|
+
TrackStatusCode,
|
|
39
|
+
} from './error-codes.js'
|
|
19
40
|
export {
|
|
20
41
|
MESSAGE_ID_MAP,
|
|
21
42
|
MESSAGE_TYPE_MAP,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthRedaction, recordAuthValueSpan, redactWith } from '../../core/auth-redaction.js'
|
|
1
2
|
import { BufferReader } from '../../core/buffer-reader.js'
|
|
2
3
|
import { BufferWriter } from '../../core/buffer-writer.js'
|
|
3
4
|
import { bytesToHex, hexToBytes } from '../../core/hex.js'
|
|
@@ -182,6 +183,11 @@ function decodeParams(r: BufferReader): Draft09Params {
|
|
|
182
183
|
|
|
183
184
|
if (paramType === PARAM_AUTHORIZATION_INFO) {
|
|
184
185
|
const bytes = r.readBytes(length)
|
|
186
|
+
// The credential is the whole value in this draft: a bare UTF-8 string,
|
|
187
|
+
// with no alias and no token type around it. What survives the overwrite
|
|
188
|
+
// is the parameter's presence, which is what says authorization was
|
|
189
|
+
// attempted at all.
|
|
190
|
+
recordAuthValueSpan(r.offset - length, length)
|
|
185
191
|
result.authorization_info = textDecoder.decode(bytes)
|
|
186
192
|
} else if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
187
193
|
const blob = r.readBytes(length)
|
|
@@ -975,3 +981,37 @@ export function createDraft09Codec(): Draft09Codec {
|
|
|
975
981
|
createStreamDecoder,
|
|
976
982
|
}
|
|
977
983
|
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Overwrite every AUTHORIZATION_INFO value in a draft-09 control frame.
|
|
987
|
+
*
|
|
988
|
+
* One decode, whose *output is discarded*: the point is not to read the
|
|
989
|
+
* message, it is to learn where the credentials were so the caller never has to
|
|
990
|
+
* hold a frame that contains one. A caller that also wants the message should
|
|
991
|
+
* decode the **redacted** frame with {@link decodeMessage}, which then cannot
|
|
992
|
+
* produce a value because there is no longer one in the bytes.
|
|
993
|
+
*
|
|
994
|
+
* A frame that fails to decode is still redacted as far as the decode got. That
|
|
995
|
+
* is the useful direction to fail in: a value that was read is a value that was
|
|
996
|
+
* exposed, whatever went wrong after it.
|
|
997
|
+
*
|
|
998
|
+
* See {@link AuthRedaction.incomplete} for the one result a caller must not
|
|
999
|
+
* treat as clean, and {@link AuthRedaction.decoded} for the residual it cannot
|
|
1000
|
+
* close.
|
|
1001
|
+
*/
|
|
1002
|
+
export function redactAuthTokens(bytes: Uint8Array): AuthRedaction {
|
|
1003
|
+
let payloadStart: number
|
|
1004
|
+
try {
|
|
1005
|
+
const probe = new BufferReader(bytes)
|
|
1006
|
+
probe.readVarInt()
|
|
1007
|
+
probe.readVarInt()
|
|
1008
|
+
payloadStart = probe.offset
|
|
1009
|
+
} catch {
|
|
1010
|
+
// Too short to carry a message header, and so too short for the parameters
|
|
1011
|
+
// that carry a credential. Reported as not decoded rather than as clean: a
|
|
1012
|
+
// framer only ever emits complete frames, so a caller that gets here is
|
|
1013
|
+
// holding something this function did not check.
|
|
1014
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false }
|
|
1015
|
+
}
|
|
1016
|
+
return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok)
|
|
1017
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Draft-09 error, status and termination code registries.
|
|
2
|
+
|
|
3
|
+
export const SessionErrorCode = {
|
|
4
|
+
NoError: 0x0n,
|
|
5
|
+
InternalError: 0x1n,
|
|
6
|
+
Unauthorized: 0x2n,
|
|
7
|
+
ProtocolViolation: 0x3n,
|
|
8
|
+
DuplicateTrackAlias: 0x4n,
|
|
9
|
+
ParameterLengthMismatch: 0x5n,
|
|
10
|
+
TooManySubscribes: 0x6n,
|
|
11
|
+
GoawayTimeout: 0x10n,
|
|
12
|
+
ControlMessageTimeout: 0x11n,
|
|
13
|
+
DataStreamTimeout: 0x12n,
|
|
14
|
+
} as const
|
|
15
|
+
export type SessionErrorCodeValue = (typeof SessionErrorCode)[keyof typeof SessionErrorCode]
|
|
16
|
+
|
|
17
|
+
export const AnnounceErrorCode = {
|
|
18
|
+
InternalError: 0x0n,
|
|
19
|
+
Unauthorized: 0x1n,
|
|
20
|
+
Timeout: 0x2n,
|
|
21
|
+
NotSupported: 0x3n,
|
|
22
|
+
Uninterested: 0x4n,
|
|
23
|
+
} as const
|
|
24
|
+
export type AnnounceErrorCodeValue = (typeof AnnounceErrorCode)[keyof typeof AnnounceErrorCode]
|
|
25
|
+
|
|
26
|
+
export const SubscribeErrorCode = {
|
|
27
|
+
InternalError: 0x0n,
|
|
28
|
+
Unauthorized: 0x1n,
|
|
29
|
+
Timeout: 0x2n,
|
|
30
|
+
NotSupported: 0x3n,
|
|
31
|
+
TrackDoesNotExist: 0x4n,
|
|
32
|
+
InvalidRange: 0x5n,
|
|
33
|
+
RetryTrackAlias: 0x6n,
|
|
34
|
+
} as const
|
|
35
|
+
export type SubscribeErrorCodeValue = (typeof SubscribeErrorCode)[keyof typeof SubscribeErrorCode]
|
|
36
|
+
|
|
37
|
+
export const FetchErrorCode = {
|
|
38
|
+
InternalError: 0x0n,
|
|
39
|
+
Unauthorized: 0x1n,
|
|
40
|
+
Timeout: 0x2n,
|
|
41
|
+
NotSupported: 0x3n,
|
|
42
|
+
TrackDoesNotExist: 0x4n,
|
|
43
|
+
InvalidRange: 0x5n,
|
|
44
|
+
} as const
|
|
45
|
+
export type FetchErrorCodeValue = (typeof FetchErrorCode)[keyof typeof FetchErrorCode]
|
|
46
|
+
|
|
47
|
+
export const SubscribeDoneStatusCode = {
|
|
48
|
+
InternalError: 0x0n,
|
|
49
|
+
Unauthorized: 0x1n,
|
|
50
|
+
TrackEnded: 0x2n,
|
|
51
|
+
SubscriptionEnded: 0x3n,
|
|
52
|
+
GoingAway: 0x4n,
|
|
53
|
+
Expired: 0x5n,
|
|
54
|
+
TooFarBehind: 0x6n,
|
|
55
|
+
} as const
|
|
56
|
+
export type SubscribeDoneStatusCodeValue =
|
|
57
|
+
(typeof SubscribeDoneStatusCode)[keyof typeof SubscribeDoneStatusCode]
|
|
58
|
+
|
|
59
|
+
export const SubscribeAnnouncesErrorCode = {
|
|
60
|
+
InternalError: 0x0n,
|
|
61
|
+
Unauthorized: 0x1n,
|
|
62
|
+
Timeout: 0x2n,
|
|
63
|
+
NotSupported: 0x3n,
|
|
64
|
+
NamespacePrefixUnknown: 0x4n,
|
|
65
|
+
} as const
|
|
66
|
+
export type SubscribeAnnouncesErrorCodeValue =
|
|
67
|
+
(typeof SubscribeAnnouncesErrorCode)[keyof typeof SubscribeAnnouncesErrorCode]
|
|
68
|
+
|
|
69
|
+
export const TrackStatusCode = {
|
|
70
|
+
InProgress: 0x00n,
|
|
71
|
+
TrackDoesNotExist: 0x01n,
|
|
72
|
+
NotYetBegun: 0x02n,
|
|
73
|
+
Finished: 0x03n,
|
|
74
|
+
RelayStatusUnavailable: 0x04n,
|
|
75
|
+
} as const
|
|
76
|
+
export type TrackStatusCodeValue = (typeof TrackStatusCode)[keyof typeof TrackStatusCode]
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const DRAFT_VERSION = 0xff000009n
|
|
2
2
|
|
|
3
|
+
export type { AuthRedaction } from '../../core/auth-redaction.js'
|
|
4
|
+
export { REDACTION_FILL } from '../../core/auth-redaction.js'
|
|
3
5
|
export type { Draft09Codec } from './codec.js'
|
|
4
6
|
export {
|
|
5
7
|
createDraft09Codec,
|
|
@@ -15,7 +17,26 @@ export {
|
|
|
15
17
|
encodeFetchStream,
|
|
16
18
|
encodeMessage,
|
|
17
19
|
encodeSubgroupStream,
|
|
20
|
+
redactAuthTokens,
|
|
18
21
|
} from './codec.js'
|
|
22
|
+
export type {
|
|
23
|
+
AnnounceErrorCodeValue,
|
|
24
|
+
FetchErrorCodeValue,
|
|
25
|
+
SessionErrorCodeValue,
|
|
26
|
+
SubscribeAnnouncesErrorCodeValue,
|
|
27
|
+
SubscribeDoneStatusCodeValue,
|
|
28
|
+
SubscribeErrorCodeValue,
|
|
29
|
+
TrackStatusCodeValue,
|
|
30
|
+
} from './error-codes.js'
|
|
31
|
+
export {
|
|
32
|
+
AnnounceErrorCode,
|
|
33
|
+
FetchErrorCode,
|
|
34
|
+
SessionErrorCode,
|
|
35
|
+
SubscribeAnnouncesErrorCode,
|
|
36
|
+
SubscribeDoneStatusCode,
|
|
37
|
+
SubscribeErrorCode,
|
|
38
|
+
TrackStatusCode,
|
|
39
|
+
} from './error-codes.js'
|
|
19
40
|
export {
|
|
20
41
|
MESSAGE_ID_MAP,
|
|
21
42
|
MESSAGE_TYPE_MAP,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthRedaction, recordAuthValueSpan, redactWith } from '../../core/auth-redaction.js'
|
|
1
2
|
import { BufferReader } from '../../core/buffer-reader.js'
|
|
2
3
|
import { BufferWriter } from '../../core/buffer-writer.js'
|
|
3
4
|
import { bytesToHex, hexToBytes } from '../../core/hex.js'
|
|
@@ -182,6 +183,11 @@ function decodeParams(r: BufferReader): Draft10Params {
|
|
|
182
183
|
|
|
183
184
|
if (paramType === PARAM_AUTHORIZATION_INFO) {
|
|
184
185
|
const bytes = r.readBytes(length)
|
|
186
|
+
// The credential is the whole value in this draft: a bare UTF-8 string,
|
|
187
|
+
// with no alias and no token type around it. What survives the overwrite
|
|
188
|
+
// is the parameter's presence, which is what says authorization was
|
|
189
|
+
// attempted at all.
|
|
190
|
+
recordAuthValueSpan(r.offset - length, length)
|
|
185
191
|
result.authorization_info = textDecoder.decode(bytes)
|
|
186
192
|
} else if (paramType === PARAM_DELIVERY_TIMEOUT) {
|
|
187
193
|
const blob = r.readBytes(length)
|
|
@@ -975,3 +981,37 @@ export function createDraft10Codec(): Draft10Codec {
|
|
|
975
981
|
createStreamDecoder,
|
|
976
982
|
}
|
|
977
983
|
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Overwrite every AUTHORIZATION_INFO value in a draft-10 control frame.
|
|
987
|
+
*
|
|
988
|
+
* One decode, whose *output is discarded*: the point is not to read the
|
|
989
|
+
* message, it is to learn where the credentials were so the caller never has to
|
|
990
|
+
* hold a frame that contains one. A caller that also wants the message should
|
|
991
|
+
* decode the **redacted** frame with {@link decodeMessage}, which then cannot
|
|
992
|
+
* produce a value because there is no longer one in the bytes.
|
|
993
|
+
*
|
|
994
|
+
* A frame that fails to decode is still redacted as far as the decode got. That
|
|
995
|
+
* is the useful direction to fail in: a value that was read is a value that was
|
|
996
|
+
* exposed, whatever went wrong after it.
|
|
997
|
+
*
|
|
998
|
+
* See {@link AuthRedaction.incomplete} for the one result a caller must not
|
|
999
|
+
* treat as clean, and {@link AuthRedaction.decoded} for the residual it cannot
|
|
1000
|
+
* close.
|
|
1001
|
+
*/
|
|
1002
|
+
export function redactAuthTokens(bytes: Uint8Array): AuthRedaction {
|
|
1003
|
+
let payloadStart: number
|
|
1004
|
+
try {
|
|
1005
|
+
const probe = new BufferReader(bytes)
|
|
1006
|
+
probe.readVarInt()
|
|
1007
|
+
probe.readVarInt()
|
|
1008
|
+
payloadStart = probe.offset
|
|
1009
|
+
} catch {
|
|
1010
|
+
// Too short to carry a message header, and so too short for the parameters
|
|
1011
|
+
// that carry a credential. Reported as not decoded rather than as clean: a
|
|
1012
|
+
// framer only ever emits complete frames, so a caller that gets here is
|
|
1013
|
+
// holding something this function did not check.
|
|
1014
|
+
return { bytes, redacted: 0, incomplete: false, decoded: false }
|
|
1015
|
+
}
|
|
1016
|
+
return redactWith(bytes, payloadStart, () => decodeMessage(bytes).ok)
|
|
1017
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Draft-10 error, status and termination code registries.
|
|
2
|
+
|
|
3
|
+
export const SessionErrorCode = {
|
|
4
|
+
NoError: 0x0n,
|
|
5
|
+
InternalError: 0x1n,
|
|
6
|
+
Unauthorized: 0x2n,
|
|
7
|
+
ProtocolViolation: 0x3n,
|
|
8
|
+
DuplicateTrackAlias: 0x4n,
|
|
9
|
+
ParameterLengthMismatch: 0x5n,
|
|
10
|
+
TooManySubscribes: 0x6n,
|
|
11
|
+
GoawayTimeout: 0x10n,
|
|
12
|
+
ControlMessageTimeout: 0x11n,
|
|
13
|
+
DataStreamTimeout: 0x12n,
|
|
14
|
+
} as const
|
|
15
|
+
export type SessionErrorCodeValue = (typeof SessionErrorCode)[keyof typeof SessionErrorCode]
|
|
16
|
+
|
|
17
|
+
export const SubscribeErrorCode = {
|
|
18
|
+
InternalError: 0x0n,
|
|
19
|
+
Unauthorized: 0x1n,
|
|
20
|
+
Timeout: 0x2n,
|
|
21
|
+
NotSupported: 0x3n,
|
|
22
|
+
TrackDoesNotExist: 0x4n,
|
|
23
|
+
InvalidRange: 0x5n,
|
|
24
|
+
RetryTrackAlias: 0x6n,
|
|
25
|
+
} as const
|
|
26
|
+
export type SubscribeErrorCodeValue = (typeof SubscribeErrorCode)[keyof typeof SubscribeErrorCode]
|
|
27
|
+
|
|
28
|
+
export const SubscribeDoneStatusCode = {
|
|
29
|
+
InternalError: 0x0n,
|
|
30
|
+
Unauthorized: 0x1n,
|
|
31
|
+
TrackEnded: 0x2n,
|
|
32
|
+
SubscriptionEnded: 0x3n,
|
|
33
|
+
GoingAway: 0x4n,
|
|
34
|
+
Expired: 0x5n,
|
|
35
|
+
TooFarBehind: 0x6n,
|
|
36
|
+
} as const
|
|
37
|
+
export type SubscribeDoneStatusCodeValue =
|
|
38
|
+
(typeof SubscribeDoneStatusCode)[keyof typeof SubscribeDoneStatusCode]
|
|
39
|
+
|
|
40
|
+
export const FetchErrorCode = {
|
|
41
|
+
InternalError: 0x0n,
|
|
42
|
+
Unauthorized: 0x1n,
|
|
43
|
+
Timeout: 0x2n,
|
|
44
|
+
NotSupported: 0x3n,
|
|
45
|
+
TrackDoesNotExist: 0x4n,
|
|
46
|
+
InvalidRange: 0x5n,
|
|
47
|
+
} as const
|
|
48
|
+
export type FetchErrorCodeValue = (typeof FetchErrorCode)[keyof typeof FetchErrorCode]
|
|
49
|
+
|
|
50
|
+
export const AnnounceErrorCode = {
|
|
51
|
+
InternalError: 0x0n,
|
|
52
|
+
Unauthorized: 0x1n,
|
|
53
|
+
Timeout: 0x2n,
|
|
54
|
+
NotSupported: 0x3n,
|
|
55
|
+
Uninterested: 0x4n,
|
|
56
|
+
} as const
|
|
57
|
+
export type AnnounceErrorCodeValue = (typeof AnnounceErrorCode)[keyof typeof AnnounceErrorCode]
|
|
58
|
+
|
|
59
|
+
export const SubscribeAnnouncesErrorCode = {
|
|
60
|
+
InternalError: 0x0n,
|
|
61
|
+
Unauthorized: 0x1n,
|
|
62
|
+
Timeout: 0x2n,
|
|
63
|
+
NotSupported: 0x3n,
|
|
64
|
+
NamespacePrefixUnknown: 0x4n,
|
|
65
|
+
} as const
|
|
66
|
+
export type SubscribeAnnouncesErrorCodeValue =
|
|
67
|
+
(typeof SubscribeAnnouncesErrorCode)[keyof typeof SubscribeAnnouncesErrorCode]
|
|
68
|
+
|
|
69
|
+
export const TrackStatusCode = {
|
|
70
|
+
InProgress: 0x00n,
|
|
71
|
+
TrackDoesNotExist: 0x01n,
|
|
72
|
+
NotYetBegun: 0x02n,
|
|
73
|
+
Finished: 0x03n,
|
|
74
|
+
RelayStatusUnavailable: 0x04n,
|
|
75
|
+
} as const
|
|
76
|
+
export type TrackStatusCodeValue = (typeof TrackStatusCode)[keyof typeof TrackStatusCode]
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const DRAFT_VERSION = 0xff00000an
|
|
2
2
|
|
|
3
|
+
export type { AuthRedaction } from '../../core/auth-redaction.js'
|
|
4
|
+
export { REDACTION_FILL } from '../../core/auth-redaction.js'
|
|
3
5
|
export type { Draft10Codec } from './codec.js'
|
|
4
6
|
export {
|
|
5
7
|
createDraft10Codec,
|
|
@@ -15,7 +17,26 @@ export {
|
|
|
15
17
|
encodeFetchStream,
|
|
16
18
|
encodeMessage,
|
|
17
19
|
encodeSubgroupStream,
|
|
20
|
+
redactAuthTokens,
|
|
18
21
|
} from './codec.js'
|
|
22
|
+
export type {
|
|
23
|
+
AnnounceErrorCodeValue,
|
|
24
|
+
FetchErrorCodeValue,
|
|
25
|
+
SessionErrorCodeValue,
|
|
26
|
+
SubscribeAnnouncesErrorCodeValue,
|
|
27
|
+
SubscribeDoneStatusCodeValue,
|
|
28
|
+
SubscribeErrorCodeValue,
|
|
29
|
+
TrackStatusCodeValue,
|
|
30
|
+
} from './error-codes.js'
|
|
31
|
+
export {
|
|
32
|
+
AnnounceErrorCode,
|
|
33
|
+
FetchErrorCode,
|
|
34
|
+
SessionErrorCode,
|
|
35
|
+
SubscribeAnnouncesErrorCode,
|
|
36
|
+
SubscribeDoneStatusCode,
|
|
37
|
+
SubscribeErrorCode,
|
|
38
|
+
TrackStatusCode,
|
|
39
|
+
} from './error-codes.js'
|
|
19
40
|
export {
|
|
20
41
|
MESSAGE_ID_MAP,
|
|
21
42
|
MESSAGE_TYPE_MAP,
|