@moqtap/codec 0.4.1 → 0.4.3

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.
Files changed (105) hide show
  1. package/dist/{chunk-UJU63EFY.cjs → chunk-BAG6YWCP.cjs} +2 -3
  2. package/dist/{chunk-2UTVXWFF.js → chunk-COWGGUL4.js} +2 -3
  3. package/dist/{chunk-4IVZZOY3.js → chunk-CXFAQKL3.js} +2 -3
  4. package/dist/{chunk-SDWRXXOO.cjs → chunk-HO44OANK.cjs} +2 -3
  5. package/dist/{chunk-Q46ZURKX.js → chunk-HYI6LFMD.js} +2 -3
  6. package/dist/{chunk-4BDEU3D4.cjs → chunk-JB5VDJ2V.cjs} +27 -4
  7. package/dist/{chunk-XHDPQHYR.cjs → chunk-JTRU76JN.cjs} +33 -2
  8. package/dist/{chunk-GCBFHZW6.js → chunk-NZ7GYEMT.js} +27 -4
  9. package/dist/{chunk-5O764MBD.cjs → chunk-OGZTQA24.cjs} +6 -6
  10. package/dist/{chunk-BLEFTWEB.js → chunk-Q5D6OW6Q.js} +33 -2
  11. package/dist/{chunk-XS77RBY7.js → chunk-RZ3UML47.js} +2 -4
  12. package/dist/{chunk-3XKO6PCR.cjs → chunk-SIYYMFCC.cjs} +2 -3
  13. package/dist/{chunk-Z6U26IRI.js → chunk-UP4XPH4J.js} +6 -6
  14. package/dist/{chunk-OKG2HT25.cjs → chunk-WMJVSBBE.cjs} +2 -4
  15. package/dist/{codec-BHHfBTnV.d.ts → codec-B2lYE0YA.d.ts} +1 -1
  16. package/dist/{codec-C-Yk2RNa.d.ts → codec-BFg5xnrJ.d.ts} +1 -1
  17. package/dist/{codec-BB0U8MF2.d.cts → codec-BWQ5Jlap.d.cts} +1 -1
  18. package/dist/{codec-z6_2PSzi.d.cts → codec-B_QST4y1.d.cts} +1 -1
  19. package/dist/{codec-COy4uuPO.d.cts → codec-BbbLDSKA.d.cts} +1 -1
  20. package/dist/{codec-BO5Go0Lm.d.cts → codec-C7UzTYSS.d.cts} +1 -1
  21. package/dist/{codec-BN6jk0Td.d.cts → codec-C8aSvE41.d.cts} +1 -1
  22. package/dist/{codec-w8z2j_uo.d.cts → codec-CAbm9d_n.d.cts} +1 -1
  23. package/dist/{codec-D2QVSH9D.d.ts → codec-CpZrZ3ok.d.ts} +1 -1
  24. package/dist/{codec-J7ekOSMc.d.ts → codec-DFU-6Rax.d.ts} +1 -1
  25. package/dist/{codec-iMEwV1UO.d.ts → codec-Db-0pk38.d.ts} +1 -1
  26. package/dist/{codec-BU0gaSZm.d.ts → codec-DftaRuVz.d.ts} +1 -1
  27. package/dist/{codec-DNfml-se.d.ts → codec-Va_wZCF_.d.ts} +1 -1
  28. package/dist/{codec-DoOGjjDq.d.cts → codec-lqDowbyT.d.cts} +1 -1
  29. package/dist/draft11-session.d.cts +1 -1
  30. package/dist/draft11-session.d.ts +1 -1
  31. package/dist/draft11.cjs +2 -2
  32. package/dist/draft11.d.cts +3 -3
  33. package/dist/draft11.d.ts +3 -3
  34. package/dist/draft11.js +1 -1
  35. package/dist/draft12-session.d.cts +1 -1
  36. package/dist/draft12-session.d.ts +1 -1
  37. package/dist/draft12.cjs +2 -2
  38. package/dist/draft12.d.cts +3 -3
  39. package/dist/draft12.d.ts +3 -3
  40. package/dist/draft12.js +1 -1
  41. package/dist/draft13-session.d.cts +1 -1
  42. package/dist/draft13-session.d.ts +1 -1
  43. package/dist/draft13.cjs +2 -2
  44. package/dist/draft13.d.cts +3 -3
  45. package/dist/draft13.d.ts +3 -3
  46. package/dist/draft13.js +1 -1
  47. package/dist/draft14-session.d.cts +1 -1
  48. package/dist/draft14-session.d.ts +1 -1
  49. package/dist/draft14.cjs +2 -2
  50. package/dist/draft14.d.cts +3 -3
  51. package/dist/draft14.d.ts +3 -3
  52. package/dist/draft14.js +1 -1
  53. package/dist/draft15-session.d.cts +1 -1
  54. package/dist/draft15-session.d.ts +1 -1
  55. package/dist/draft15.cjs +2 -2
  56. package/dist/draft15.d.cts +3 -3
  57. package/dist/draft15.d.ts +3 -3
  58. package/dist/draft15.js +1 -1
  59. package/dist/draft16-session.d.cts +1 -1
  60. package/dist/draft16-session.d.ts +1 -1
  61. package/dist/draft16.cjs +2 -2
  62. package/dist/draft16.d.cts +3 -3
  63. package/dist/draft16.d.ts +3 -3
  64. package/dist/draft16.js +1 -1
  65. package/dist/draft17-session.d.cts +1 -1
  66. package/dist/draft17-session.d.ts +1 -1
  67. package/dist/draft17.cjs +2 -2
  68. package/dist/draft17.d.cts +3 -3
  69. package/dist/draft17.d.ts +3 -3
  70. package/dist/draft17.js +1 -1
  71. package/dist/index.cjs +14 -14
  72. package/dist/index.d.cts +14 -14
  73. package/dist/index.d.ts +14 -14
  74. package/dist/index.js +7 -7
  75. package/dist/session.d.cts +7 -7
  76. package/dist/session.d.ts +7 -7
  77. package/dist/{types-C2qKTRR_.d.cts → types-Bio-91Rt.d.cts} +2 -1
  78. package/dist/{types-C2qKTRR_.d.ts → types-Bio-91Rt.d.ts} +2 -1
  79. package/dist/{types-DuxfOYiO.d.cts → types-CPaYBsMG.d.cts} +1 -1
  80. package/dist/{types-DuxfOYiO.d.ts → types-CPaYBsMG.d.ts} +1 -1
  81. package/dist/{types-DrQpTW1G.d.cts → types-CXlSn0I9.d.cts} +1 -1
  82. package/dist/{types-DrQpTW1G.d.ts → types-CXlSn0I9.d.ts} +1 -1
  83. package/dist/{types--Q7_DcvP.d.cts → types-Ck45Ex5S.d.cts} +1 -1
  84. package/dist/{types--Q7_DcvP.d.ts → types-Ck45Ex5S.d.ts} +1 -1
  85. package/dist/{types-BFpFNM_m.d.cts → types-Cm9fjeYC.d.cts} +1 -1
  86. package/dist/{types-BFpFNM_m.d.ts → types-Cm9fjeYC.d.ts} +1 -1
  87. package/dist/{types-Br7fm2mf.d.cts → types-D9eiB_9A.d.cts} +2 -2
  88. package/dist/{types-Br7fm2mf.d.ts → types-D9eiB_9A.d.ts} +2 -2
  89. package/dist/{types--FGt0sAp.d.cts → types-DjmrHp_s.d.cts} +1 -1
  90. package/dist/{types--FGt0sAp.d.ts → types-DjmrHp_s.d.ts} +1 -1
  91. package/package.json +2 -2
  92. package/src/drafts/draft11/codec.ts +2 -3
  93. package/src/drafts/draft11/types.ts +1 -1
  94. package/src/drafts/draft12/codec.ts +27 -4
  95. package/src/drafts/draft12/types.ts +2 -1
  96. package/src/drafts/draft13/codec.ts +2 -3
  97. package/src/drafts/draft13/types.ts +1 -1
  98. package/src/drafts/draft14/codec.ts +33 -2
  99. package/src/drafts/draft14/types.ts +1 -1
  100. package/src/drafts/draft15/codec.ts +2 -4
  101. package/src/drafts/draft15/types.ts +1 -1
  102. package/src/drafts/draft16/codec.ts +2 -3
  103. package/src/drafts/draft16/types.ts +1 -1
  104. package/src/drafts/draft17/codec.ts +6 -6
  105. package/src/drafts/draft17/types.ts +2 -2
@@ -78,6 +78,7 @@ function encodeSetupParams(params: Draft14Params, writer: BufferWriter): void {
78
78
  if (params.role !== undefined) count++
79
79
  if (params.path !== undefined) count++
80
80
  if (params.max_request_id !== undefined) count++
81
+ if (params.authorization_token !== undefined) count++
81
82
  if (params.authority !== undefined) count++
82
83
  if (params.max_auth_token_cache_size !== undefined) count++
83
84
  if (params.moqt_implementation !== undefined) count++
@@ -99,6 +100,24 @@ function encodeSetupParams(params: Draft14Params, writer: BufferWriter): void {
99
100
  writer.writeVarInt(PARAM_MAX_REQUEST_ID)
100
101
  writer.writeVarInt(params.max_request_id)
101
102
  }
103
+ if (params.authorization_token !== undefined) {
104
+ writer.writeVarInt(PARAM_AUTHORIZATION_TOKEN)
105
+ const tok = params.authorization_token
106
+ const tmpWriter = new BufferWriter(64)
107
+ tmpWriter.writeVarInt(tok.alias_type)
108
+ if (tok.token_type !== undefined) {
109
+ tmpWriter.writeVarInt(tok.token_type)
110
+ }
111
+ if (tok.token_value !== undefined) {
112
+ tmpWriter.writeBytes(tok.token_value)
113
+ }
114
+ if (tok.token_alias !== undefined) {
115
+ tmpWriter.writeVarInt(tok.token_alias)
116
+ }
117
+ const tokenBytes = tmpWriter.finish()
118
+ writer.writeVarInt(tokenBytes.byteLength)
119
+ writer.writeBytes(tokenBytes)
120
+ }
102
121
  if (params.max_auth_token_cache_size !== undefined) {
103
122
  writer.writeVarInt(PARAM_MAX_AUTH_TOKEN_CACHE_SIZE)
104
123
  writer.writeVarInt(params.max_auth_token_cache_size)
@@ -157,6 +176,18 @@ function decodeSetupParams(reader: BufferReader): Draft14Params {
157
176
  const bytes = reader.readBytes(length)
158
177
  if (paramType === PARAM_PATH) {
159
178
  result.path = textDecoder.decode(bytes)
179
+ } else if (paramType === PARAM_AUTHORIZATION_TOKEN) {
180
+ const tokenReader = new BufferReader(bytes)
181
+ const alias_type = tokenReader.readVarInt()
182
+ const tok: Record<string, unknown> = { alias_type }
183
+ if (tokenReader.remaining > 0) {
184
+ tok.token_type = tokenReader.readVarInt()
185
+ if (tokenReader.remaining > 0) {
186
+ const tokenValue = tokenReader.readBytesView(tokenReader.remaining)
187
+ tok.token_value = new Uint8Array(tokenValue)
188
+ }
189
+ }
190
+ result.authorization_token = tok as unknown as AuthorizationToken
160
191
  } else if (paramType === PARAM_AUTHORITY) {
161
192
  result.authority = textDecoder.decode(bytes)
162
193
  } else if (paramType === PARAM_MOQT_IMPLEMENTATION) {
@@ -197,7 +228,7 @@ function encodeMessageParams(params: Draft14Params, writer: BufferWriter): void
197
228
  tmpWriter.writeVarInt(tok.token_type)
198
229
  }
199
230
  if (tok.token_value !== undefined) {
200
- tmpWriter.writeBytes(hexToBytes(tok.token_value))
231
+ tmpWriter.writeBytes(tok.token_value)
201
232
  }
202
233
  if (tok.token_alias !== undefined) {
203
234
  tmpWriter.writeVarInt(tok.token_alias)
@@ -256,7 +287,7 @@ function decodeMessageParams(reader: BufferReader): Draft14Params {
256
287
  tok.token_type = tokenReader.readVarInt()
257
288
  if (tokenReader.remaining > 0) {
258
289
  const tokenValue = tokenReader.readBytesView(tokenReader.remaining)
259
- tok.token_value = bytesToHex(tokenValue)
290
+ tok.token_value = new Uint8Array(tokenValue)
260
291
  }
261
292
  }
262
293
  result.authorization_token = tok as unknown as AuthorizationToken
@@ -33,7 +33,7 @@ export interface UnknownParam {
33
33
  export interface AuthorizationToken {
34
34
  readonly alias_type: bigint
35
35
  readonly token_type?: bigint
36
- readonly token_value?: string // raw hex
36
+ readonly token_value?: Uint8Array
37
37
  readonly token_alias?: bigint
38
38
  }
39
39
 
@@ -203,8 +203,7 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
203
203
  if (aliasType === 1 || aliasType === 3) {
204
204
  w.writeVarInt(token.token_type!)
205
205
  // token_value is the remaining bytes (no inner length prefix)
206
- const tokenBytes = hexToBytes(token.token_value_hex!)
207
- w.writeBytes(tokenBytes)
206
+ w.writeBytes(token.token_value!)
208
207
  }
209
208
  }
210
209
 
@@ -218,8 +217,7 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
218
217
  if (aliasType === 1 || aliasType === 3) {
219
218
  result.token_type = r.readVarInt()
220
219
  // token_value is the remaining bytes in the length-prefixed block
221
- const tokenBytes = r.readBytesView(r.remaining)
222
- result.token_value_hex = bytesToHex(tokenBytes)
220
+ result.token_value = r.readBytes(r.remaining)
223
221
  }
224
222
  return result as unknown as AuthorizationToken
225
223
  }
@@ -13,7 +13,7 @@ export interface AuthorizationToken {
13
13
  readonly alias_type: bigint
14
14
  readonly token_alias?: bigint // present when alias_type = 0 or 1
15
15
  readonly token_type?: bigint // present when alias_type = 1 or 3
16
- readonly token_value_hex?: string // present when alias_type = 1 or 3
16
+ readonly token_value?: Uint8Array // present when alias_type = 1 or 3
17
17
  }
18
18
 
19
19
  // Setup parameters (constant namespace across versions)
@@ -200,8 +200,7 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
200
200
  }
201
201
  if (aliasType === 1 || aliasType === 3) {
202
202
  w.writeVarInt(token.token_type!)
203
- const tokenBytes = hexToBytes(token.token_value_hex!)
204
- w.writeBytes(tokenBytes)
203
+ w.writeBytes(token.token_value!)
205
204
  }
206
205
  }
207
206
 
@@ -215,7 +214,7 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
215
214
  if (aliasType === 1 || aliasType === 3) {
216
215
  result.token_type = r.readVarInt()
217
216
  const tokenBytes = r.readBytesView(r.remaining)
218
- result.token_value_hex = bytesToHex(tokenBytes)
217
+ result.token_value = new Uint8Array(tokenBytes)
219
218
  }
220
219
  return result as unknown as AuthorizationToken
221
220
  }
@@ -13,7 +13,7 @@ export interface AuthorizationToken {
13
13
  readonly alias_type: bigint
14
14
  readonly token_alias?: bigint
15
15
  readonly token_type?: bigint
16
- readonly token_value_hex?: string
16
+ readonly token_value?: Uint8Array
17
17
  }
18
18
 
19
19
  // Setup parameters (constant namespace across versions)
@@ -199,9 +199,9 @@ function encodeAuthorizationToken(token: AuthorizationToken, w: BufferWriter): v
199
199
  if (aliasType === 1 || aliasType === 3) {
200
200
  // REGISTER, USE_VALUE: token_type + token_value present
201
201
  w.writeVarInt(token.token_type ?? 0n)
202
- const encoded = textEncoder.encode(token.token_value ?? '')
203
- w.writeVarInt(BigInt(encoded.byteLength))
204
- w.writeBytes(encoded)
202
+ const tv = token.token_value ?? new Uint8Array(0)
203
+ w.writeVarInt(BigInt(tv.byteLength))
204
+ w.writeBytes(tv)
205
205
  }
206
206
  }
207
207
 
@@ -217,7 +217,7 @@ function decodeAuthorizationToken(r: BufferReader): AuthorizationToken {
217
217
  ;(result as { token_type: bigint }).token_type = r.readVarInt()
218
218
  const len = Number(r.readVarInt())
219
219
  const bytes = r.readBytes(len)
220
- ;(result as { token_value: string }).token_value = textDecoder.decode(bytes)
220
+ ;(result as { token_value: Uint8Array }).token_value = bytes
221
221
  }
222
222
 
223
223
  return result
@@ -464,7 +464,7 @@ function encodeTrackProperties(props: Draft17TrackProperties, writer: BufferWrit
464
464
  entries.push({
465
465
  type: TPROP_IMMUTABLE_PROPERTIES,
466
466
  encode: (w) => {
467
- const raw = hexToBytes(props.immutable_properties!)
467
+ const raw = props.immutable_properties!
468
468
  w.writeVarInt(BigInt(raw.byteLength))
469
469
  w.writeBytes(raw)
470
470
  },
@@ -557,7 +557,7 @@ function decodeTrackProperties(reader: BufferReader, payloadEnd: number): Draft1
557
557
  const length = Number(reader.readVarInt())
558
558
  const bytes = reader.readBytes(length)
559
559
  if (propType === TPROP_IMMUTABLE_PROPERTIES) {
560
- result.immutable_properties = bytesToHex(bytes)
560
+ result.immutable_properties = bytes
561
561
  } else {
562
562
  unknown.push({
563
563
  id: `0x${propType.toString(16)}`,
@@ -12,7 +12,7 @@ export interface AuthorizationToken {
12
12
  readonly alias_type: bigint // 0=DELETE, 1=REGISTER, 2=USE_ALIAS, 3=USE_VALUE
13
13
  readonly token_alias?: bigint // present for DELETE(0), REGISTER(1), USE_ALIAS(2)
14
14
  readonly token_type?: bigint // present for REGISTER(1), USE_VALUE(3)
15
- readonly token_value?: string // present for REGISTER(1), USE_VALUE(3)
15
+ readonly token_value?: Uint8Array // present for REGISTER(1), USE_VALUE(3)
16
16
  }
17
17
 
18
18
  // Setup options (KVP encoding, no count prefix)
@@ -58,7 +58,7 @@ export interface Draft17Params {
58
58
  export interface Draft17TrackProperties {
59
59
  delivery_timeout?: bigint // 0x02 even varint
60
60
  max_cache_duration?: bigint // 0x04 even varint
61
- immutable_properties?: string // 0x0b odd length-prefixed raw hex
61
+ immutable_properties?: Uint8Array // 0x0b odd length-prefixed
62
62
  default_publisher_priority?: bigint // 0x0c even varint
63
63
  default_publisher_group_order?: bigint // 0x22 even varint
64
64
  dynamic_groups?: bigint // 0x30 even varint