@homebridge/hap-nodejs 2.3.1-beta.1 → 2.3.1-beta.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 (252) hide show
  1. package/README.md +13 -4
  2. package/dist/accessories/types.d.ts +0 -1
  3. package/dist/hap.d.ts +1 -1
  4. package/dist/hap.js +6 -4
  5. package/dist/hap.js.map +1 -1
  6. package/dist/index.d.ts +4 -1
  7. package/dist/index.js +4 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal-types.d.ts +6 -7
  10. package/dist/internal-types.js +1 -5
  11. package/dist/internal-types.js.map +1 -1
  12. package/dist/lib/Accessory.d.ts +53 -25
  13. package/dist/lib/Accessory.js +289 -171
  14. package/dist/lib/Accessory.js.map +1 -1
  15. package/dist/lib/Advertiser.d.ts +37 -18
  16. package/dist/lib/Advertiser.js +143 -62
  17. package/dist/lib/Advertiser.js.map +1 -1
  18. package/dist/lib/Bridge.d.ts +1 -2
  19. package/dist/lib/Bridge.js +1 -1
  20. package/dist/lib/Characteristic.d.ts +19 -20
  21. package/dist/lib/Characteristic.js +187 -153
  22. package/dist/lib/Characteristic.js.map +1 -1
  23. package/dist/lib/HAPServer.d.ts +19 -13
  24. package/dist/lib/HAPServer.js +266 -220
  25. package/dist/lib/HAPServer.js.map +1 -1
  26. package/dist/lib/Service.d.ts +11 -11
  27. package/dist/lib/Service.js +54 -37
  28. package/dist/lib/Service.js.map +1 -1
  29. package/dist/lib/camera/RTPProxy.d.ts +5 -5
  30. package/dist/lib/camera/RTPProxy.js +48 -23
  31. package/dist/lib/camera/RTPProxy.js.map +1 -1
  32. package/dist/lib/camera/RTPStreamManagement.d.ts +18 -13
  33. package/dist/lib/camera/RTPStreamManagement.js +247 -216
  34. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  35. package/dist/lib/camera/RecordingManagement.d.ts +13 -13
  36. package/dist/lib/camera/RecordingManagement.js +115 -110
  37. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  38. package/dist/lib/camera/index.d.ts +0 -1
  39. package/dist/lib/controller/AdaptiveLightingController.d.ts +41 -36
  40. package/dist/lib/controller/AdaptiveLightingController.js +126 -113
  41. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  42. package/dist/lib/controller/CameraController.d.ts +17 -17
  43. package/dist/lib/controller/CameraController.js +30 -26
  44. package/dist/lib/controller/CameraController.js.map +1 -1
  45. package/dist/lib/controller/Controller.d.ts +15 -12
  46. package/dist/lib/controller/Controller.js +0 -1
  47. package/dist/lib/controller/Controller.js.map +1 -1
  48. package/dist/lib/controller/DoorbellController.d.ts +6 -6
  49. package/dist/lib/controller/DoorbellController.js +10 -3
  50. package/dist/lib/controller/DoorbellController.js.map +1 -1
  51. package/dist/lib/controller/RemoteController.d.ts +46 -27
  52. package/dist/lib/controller/RemoteController.js +268 -178
  53. package/dist/lib/controller/RemoteController.js.map +1 -1
  54. package/dist/lib/controller/index.d.ts +0 -1
  55. package/dist/lib/datastream/DataStreamManagement.d.ts +6 -6
  56. package/dist/lib/datastream/DataStreamManagement.js +30 -26
  57. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  58. package/dist/lib/datastream/DataStreamParser.d.ts +25 -8
  59. package/dist/lib/datastream/DataStreamParser.js +124 -105
  60. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  61. package/dist/lib/datastream/DataStreamServer.d.ts +47 -23
  62. package/dist/lib/datastream/DataStreamServer.js +285 -143
  63. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  64. package/dist/lib/datastream/index.d.ts +0 -1
  65. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +0 -1
  66. package/dist/lib/definitions/CharacteristicDefinitions.js +578 -578
  67. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  68. package/dist/lib/definitions/ServiceDefinitions.d.ts +0 -1
  69. package/dist/lib/definitions/index.d.ts +0 -1
  70. package/dist/lib/gen/HomeKit.d.ts +0 -1
  71. package/dist/lib/model/AccessoryInfo.d.ts +5 -6
  72. package/dist/lib/model/AccessoryInfo.js +23 -19
  73. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  74. package/dist/lib/model/ControllerStorage.d.ts +11 -5
  75. package/dist/lib/model/ControllerStorage.js +34 -8
  76. package/dist/lib/model/ControllerStorage.js.map +1 -1
  77. package/dist/lib/model/HAPFileStorage.d.ts +20 -2
  78. package/dist/lib/model/HAPFileStorage.js +59 -10
  79. package/dist/lib/model/HAPFileStorage.js.map +1 -1
  80. package/dist/lib/model/HAPStorage.d.ts +0 -1
  81. package/dist/lib/model/HAPStorage.js +6 -3
  82. package/dist/lib/model/HAPStorage.js.map +1 -1
  83. package/dist/lib/model/IdentifierCache.d.ts +2 -3
  84. package/dist/lib/model/IdentifierCache.js +26 -13
  85. package/dist/lib/model/IdentifierCache.js.map +1 -1
  86. package/dist/lib/tv/AccessControlManagement.d.ts +6 -7
  87. package/dist/lib/tv/AccessControlManagement.js +13 -19
  88. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  89. package/dist/lib/util/checkName.d.ts +1 -2
  90. package/dist/lib/util/checkName.js.map +1 -1
  91. package/dist/lib/util/clone.d.ts +0 -1
  92. package/dist/lib/util/clone.js.map +1 -1
  93. package/dist/lib/util/color-utils.d.ts +1 -2
  94. package/dist/lib/util/color-utils.js +1 -1
  95. package/dist/lib/util/errors.d.ts +4 -0
  96. package/dist/lib/util/errors.js +15 -0
  97. package/dist/lib/util/errors.js.map +1 -0
  98. package/dist/lib/util/eventedhttp.d.ts +63 -19
  99. package/dist/lib/util/eventedhttp.js +170 -48
  100. package/dist/lib/util/eventedhttp.js.map +1 -1
  101. package/dist/lib/util/hapCrypto.d.ts +1 -2
  102. package/dist/lib/util/hapCrypto.js +6 -7
  103. package/dist/lib/util/hapCrypto.js.map +1 -1
  104. package/dist/lib/util/hapStatusError.d.ts +0 -1
  105. package/dist/lib/util/hapStatusError.js +1 -1
  106. package/dist/lib/util/hapStatusError.js.map +1 -1
  107. package/dist/lib/util/net-utils.d.ts +1 -2
  108. package/dist/lib/util/net-utils.js +6 -7
  109. package/dist/lib/util/net-utils.js.map +1 -1
  110. package/dist/lib/util/once.d.ts +0 -1
  111. package/dist/lib/util/promise-utils.d.ts +1 -2
  112. package/dist/lib/util/promise-utils.js +2 -1
  113. package/dist/lib/util/promise-utils.js.map +1 -1
  114. package/dist/lib/util/request-util.d.ts +4 -4
  115. package/dist/lib/util/request-util.js +29 -28
  116. package/dist/lib/util/request-util.js.map +1 -1
  117. package/dist/lib/util/time.d.ts +1 -2
  118. package/dist/lib/util/time.js.map +1 -1
  119. package/dist/lib/util/tlv.d.ts +4 -4
  120. package/dist/lib/util/tlv.js +16 -5
  121. package/dist/lib/util/tlv.js.map +1 -1
  122. package/dist/lib/util/uuid.d.ts +5 -2
  123. package/dist/lib/util/uuid.js +6 -0
  124. package/dist/lib/util/uuid.js.map +1 -1
  125. package/dist/types.d.ts +20 -17
  126. package/dist/types.js +0 -1
  127. package/dist/types.js.map +1 -1
  128. package/package.json +8 -14
  129. package/dist/accessories/AirConditioner_accessory.d.ts +0 -2
  130. package/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
  131. package/dist/accessories/AirConditioner_accessory.js +0 -126
  132. package/dist/accessories/AirConditioner_accessory.js.map +0 -1
  133. package/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
  134. package/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
  135. package/dist/accessories/AppleTVRemote_accessory.js +0 -146
  136. package/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
  137. package/dist/accessories/Camera_accessory.d.ts +0 -2
  138. package/dist/accessories/Camera_accessory.d.ts.map +0 -1
  139. package/dist/accessories/Camera_accessory.js +0 -562
  140. package/dist/accessories/Camera_accessory.js.map +0 -1
  141. package/dist/accessories/Fan_accessory.d.ts +0 -2
  142. package/dist/accessories/Fan_accessory.d.ts.map +0 -1
  143. package/dist/accessories/Fan_accessory.js +0 -71
  144. package/dist/accessories/Fan_accessory.js.map +0 -1
  145. package/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
  146. package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
  147. package/dist/accessories/GarageDoorOpener_accessory.js +0 -76
  148. package/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
  149. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
  150. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
  151. package/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -103
  152. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
  153. package/dist/accessories/Light_accessory.d.ts +0 -2
  154. package/dist/accessories/Light_accessory.d.ts.map +0 -1
  155. package/dist/accessories/Light_accessory.js +0 -143
  156. package/dist/accessories/Light_accessory.js.map +0 -1
  157. package/dist/accessories/Lock_accessory.d.ts +0 -2
  158. package/dist/accessories/Lock_accessory.d.ts.map +0 -1
  159. package/dist/accessories/Lock_accessory.js +0 -74
  160. package/dist/accessories/Lock_accessory.js.map +0 -1
  161. package/dist/accessories/MotionSensor_accessory.d.ts +0 -2
  162. package/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
  163. package/dist/accessories/MotionSensor_accessory.js +0 -43
  164. package/dist/accessories/MotionSensor_accessory.js.map +0 -1
  165. package/dist/accessories/Outlet_accessory.d.ts +0 -2
  166. package/dist/accessories/Outlet_accessory.d.ts.map +0 -1
  167. package/dist/accessories/Outlet_accessory.js +0 -77
  168. package/dist/accessories/Outlet_accessory.js.map +0 -1
  169. package/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
  170. package/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
  171. package/dist/accessories/SmartSpeaker_accessory.js +0 -42
  172. package/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
  173. package/dist/accessories/Sprinkler_accessory.d.ts +0 -2
  174. package/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
  175. package/dist/accessories/Sprinkler_accessory.js +0 -126
  176. package/dist/accessories/Sprinkler_accessory.js.map +0 -1
  177. package/dist/accessories/TV_accessory.d.ts +0 -2
  178. package/dist/accessories/TV_accessory.d.ts.map +0 -1
  179. package/dist/accessories/TV_accessory.js +0 -99
  180. package/dist/accessories/TV_accessory.js.map +0 -1
  181. package/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
  182. package/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
  183. package/dist/accessories/TemperatureSensor_accessory.js +0 -42
  184. package/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
  185. package/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
  186. package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
  187. package/dist/accessories/Wi-FiRouter_accessory.js +0 -14
  188. package/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
  189. package/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
  190. package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
  191. package/dist/accessories/Wi-FiSatellite_accessory.js +0 -16
  192. package/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
  193. package/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
  194. package/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
  195. package/dist/accessories/gstreamer-audioProducer.js +0 -145
  196. package/dist/accessories/gstreamer-audioProducer.js.map +0 -1
  197. package/dist/accessories/types.d.ts.map +0 -1
  198. package/dist/hap.d.ts.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/internal-types.d.ts.map +0 -1
  201. package/dist/lib/Accessory.d.ts.map +0 -1
  202. package/dist/lib/Advertiser.d.ts.map +0 -1
  203. package/dist/lib/Bridge.d.ts.map +0 -1
  204. package/dist/lib/Characteristic.d.ts.map +0 -1
  205. package/dist/lib/HAPServer.d.ts.map +0 -1
  206. package/dist/lib/Service.d.ts.map +0 -1
  207. package/dist/lib/camera/RTPProxy.d.ts.map +0 -1
  208. package/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
  209. package/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
  210. package/dist/lib/camera/index.d.ts.map +0 -1
  211. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
  212. package/dist/lib/controller/CameraController.d.ts.map +0 -1
  213. package/dist/lib/controller/Controller.d.ts.map +0 -1
  214. package/dist/lib/controller/DoorbellController.d.ts.map +0 -1
  215. package/dist/lib/controller/RemoteController.d.ts.map +0 -1
  216. package/dist/lib/controller/index.d.ts.map +0 -1
  217. package/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
  218. package/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
  219. package/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
  220. package/dist/lib/datastream/index.d.ts.map +0 -1
  221. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
  222. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
  223. package/dist/lib/definitions/generate-definitions.d.ts +0 -34
  224. package/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
  225. package/dist/lib/definitions/generate-definitions.js +0 -624
  226. package/dist/lib/definitions/generate-definitions.js.map +0 -1
  227. package/dist/lib/definitions/generator-configuration.d.ts +0 -22
  228. package/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
  229. package/dist/lib/definitions/generator-configuration.js +0 -674
  230. package/dist/lib/definitions/generator-configuration.js.map +0 -1
  231. package/dist/lib/definitions/index.d.ts.map +0 -1
  232. package/dist/lib/gen/HomeKit.d.ts.map +0 -1
  233. package/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
  234. package/dist/lib/model/ControllerStorage.d.ts.map +0 -1
  235. package/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
  236. package/dist/lib/model/HAPStorage.d.ts.map +0 -1
  237. package/dist/lib/model/IdentifierCache.d.ts.map +0 -1
  238. package/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
  239. package/dist/lib/util/checkName.d.ts.map +0 -1
  240. package/dist/lib/util/clone.d.ts.map +0 -1
  241. package/dist/lib/util/color-utils.d.ts.map +0 -1
  242. package/dist/lib/util/eventedhttp.d.ts.map +0 -1
  243. package/dist/lib/util/hapCrypto.d.ts.map +0 -1
  244. package/dist/lib/util/hapStatusError.d.ts.map +0 -1
  245. package/dist/lib/util/net-utils.d.ts.map +0 -1
  246. package/dist/lib/util/once.d.ts.map +0 -1
  247. package/dist/lib/util/promise-utils.d.ts.map +0 -1
  248. package/dist/lib/util/request-util.d.ts.map +0 -1
  249. package/dist/lib/util/time.d.ts.map +0 -1
  250. package/dist/lib/util/tlv.d.ts.map +0 -1
  251. package/dist/lib/util/uuid.d.ts.map +0 -1
  252. package/dist/types.d.ts.map +0 -1
@@ -4,7 +4,7 @@ import createDebug from 'debug';
4
4
  import * as hapCrypto from '../util/hapCrypto.js';
5
5
  import * as uuid from '../util/uuid.js';
6
6
  // welcome to hell :)
7
- // in this file lies madness and frustration. and It's not only about HDS. Also, JavaScript is hell
7
+ // in this file lies madness and frustration. and it's not only about HDS. Also, JavaScript is hell
8
8
  const debug = createDebug('HAP-NodeJS:DataStream:Parser');
9
9
  class Magics {
10
10
  static TERMINATOR = { type: 'terminator' };
@@ -68,7 +68,6 @@ export class UUID extends ValueWrapper {
68
68
  /**
69
69
  * @group HomeKit Data Streams (HDS)
70
70
  */
71
- // eslint-disable-next-line no-restricted-syntax
72
71
  export var DataFormatTags;
73
72
  (function (DataFormatTags) {
74
73
  DataFormatTags[DataFormatTags["INVALID"] = 0] = "INVALID";
@@ -80,7 +79,7 @@ export var DataFormatTags;
80
79
  DataFormatTags[DataFormatTags["DATE"] = 6] = "DATE";
81
80
  DataFormatTags[DataFormatTags["INTEGER_MINUS_ONE"] = 7] = "INTEGER_MINUS_ONE";
82
81
  DataFormatTags[DataFormatTags["INTEGER_RANGE_START_0"] = 8] = "INTEGER_RANGE_START_0";
83
- DataFormatTags[DataFormatTags["INTEGER_RANGE_STOP_39"] = 46] = "INTEGER_RANGE_STOP_39";
82
+ DataFormatTags[DataFormatTags["INTEGER_RANGE_STOP_39"] = 47] = "INTEGER_RANGE_STOP_39";
84
83
  DataFormatTags[DataFormatTags["INT8"] = 48] = "INT8";
85
84
  DataFormatTags[DataFormatTags["INT16LE"] = 49] = "INT16LE";
86
85
  DataFormatTags[DataFormatTags["INT32LE"] = 50] = "INT32LE";
@@ -114,133 +113,160 @@ export var DataFormatTags;
114
113
  * @group HomeKit Data Streams (HDS)
115
114
  */
116
115
  export class DataStreamParser {
116
+ /**
117
+ * How many arrays and dictionaries may be nested into each other. A real message is only a few levels deep,
118
+ * while a message made of nothing but array tags would otherwise use up the call stack.
119
+ */
120
+ static MAX_NESTING_DEPTH = 32;
117
121
  static decode(buffer) {
122
+ return this.decodeValue(buffer, 0);
123
+ }
124
+ /**
125
+ * Decodes the next value, which must not be a terminator.
126
+ * @param buffer - The reader to take the value from.
127
+ * @param depth - The number of arrays and dictionaries around this value.
128
+ */
129
+ static decodeValue(buffer, depth) {
130
+ const value = this.decodeNext(buffer, depth);
131
+ // a terminator only has a meaning where an array or a dictionary without a length looks for its end
132
+ if (value === Magics.TERMINATOR) {
133
+ throw new Error(`HDSDecoder: unexpected terminator tag on index ${buffer.readerIndex - 1}`);
134
+ }
135
+ return value;
136
+ }
137
+ /**
138
+ * Decodes the next value. Unlike {@link decodeValue} it returns the terminator marker for a terminator tag.
139
+ */
140
+ static decodeNext(buffer, depth) {
118
141
  const tag = buffer.readTag();
119
- if (tag === 0 /* DataFormatTags.INVALID */) {
142
+ if (tag >= DataFormatTags.ARRAY_LENGTH_START && tag <= DataFormatTags.DICTIONARY_TERMINATED && depth >= this.MAX_NESTING_DEPTH) {
143
+ throw new Error(`HDSDecoder: arrays and dictionaries are nested more than ${this.MAX_NESTING_DEPTH} levels deep on index ${buffer.readerIndex - 1}`);
144
+ }
145
+ if (tag === DataFormatTags.INVALID) {
120
146
  throw new Error(`HDSDecoder: zero tag detected on index ${buffer.readerIndex}`);
121
147
  }
122
- else if (tag === 1 /* DataFormatTags.TRUE */) {
148
+ else if (tag === DataFormatTags.TRUE) {
123
149
  return buffer.readTrue();
124
150
  }
125
- else if (tag === 2 /* DataFormatTags.FALSE */) {
151
+ else if (tag === DataFormatTags.FALSE) {
126
152
  return buffer.readFalse();
127
153
  }
128
- else if (tag === 3 /* DataFormatTags.TERMINATOR */) {
154
+ else if (tag === DataFormatTags.TERMINATOR) {
129
155
  return Magics.TERMINATOR;
130
156
  }
131
- else if (tag === 4 /* DataFormatTags.NULL */) {
157
+ else if (tag === DataFormatTags.NULL) {
132
158
  return null;
133
159
  }
134
- else if (tag === 5 /* DataFormatTags.UUID */) {
160
+ else if (tag === DataFormatTags.UUID) {
135
161
  return buffer.readUUID();
136
162
  }
137
- else if (tag === 6 /* DataFormatTags.DATE */) {
163
+ else if (tag === DataFormatTags.DATE) {
138
164
  return buffer.readSecondsSince2001_01_01();
139
165
  }
140
- else if (tag === 7 /* DataFormatTags.INTEGER_MINUS_ONE */) {
166
+ else if (tag === DataFormatTags.INTEGER_MINUS_ONE) {
141
167
  return buffer.readNegOne();
142
168
  }
143
- else if (tag >= 8 /* DataFormatTags.INTEGER_RANGE_START_0 */ && tag <= 46 /* DataFormatTags.INTEGER_RANGE_STOP_39 */) {
169
+ else if (tag >= DataFormatTags.INTEGER_RANGE_START_0 && tag <= DataFormatTags.INTEGER_RANGE_STOP_39) {
144
170
  return buffer.readIntRange(tag); // integer values from 0-39
145
171
  }
146
- else if (tag === 48 /* DataFormatTags.INT8 */) {
172
+ else if (tag === DataFormatTags.INT8) {
147
173
  return buffer.readInt8();
148
174
  }
149
- else if (tag === 49 /* DataFormatTags.INT16LE */) {
175
+ else if (tag === DataFormatTags.INT16LE) {
150
176
  return buffer.readInt16LE();
151
177
  }
152
- else if (tag === 50 /* DataFormatTags.INT32LE */) {
178
+ else if (tag === DataFormatTags.INT32LE) {
153
179
  return buffer.readInt32LE();
154
180
  }
155
- else if (tag === 51 /* DataFormatTags.INT64LE */) {
181
+ else if (tag === DataFormatTags.INT64LE) {
156
182
  return buffer.readInt64LE();
157
183
  }
158
- else if (tag === 53 /* DataFormatTags.FLOAT32LE */) {
184
+ else if (tag === DataFormatTags.FLOAT32LE) {
159
185
  return buffer.readFloat32LE();
160
186
  }
161
- else if (tag === 54 /* DataFormatTags.FLOAT64LE */) {
187
+ else if (tag === DataFormatTags.FLOAT64LE) {
162
188
  return buffer.readFloat64LE();
163
189
  }
164
- else if (tag >= 64 /* DataFormatTags.UTF8_LENGTH_START */ && tag <= 96 /* DataFormatTags.UTF8_LENGTH_STOP */) {
165
- const length = tag - 64 /* DataFormatTags.UTF8_LENGTH_START */;
190
+ else if (tag >= DataFormatTags.UTF8_LENGTH_START && tag <= DataFormatTags.UTF8_LENGTH_STOP) {
191
+ const length = tag - DataFormatTags.UTF8_LENGTH_START;
166
192
  if (length === 0) {
167
193
  return ''; // a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
168
194
  }
169
195
  return buffer.readUTF8(length);
170
196
  }
171
- else if (tag === 97 /* DataFormatTags.UTF8_LENGTH8 */) {
197
+ else if (tag === DataFormatTags.UTF8_LENGTH8) {
172
198
  return buffer.readUTF8_Length8();
173
199
  }
174
- else if (tag === 98 /* DataFormatTags.UTF8_LENGTH16LE */) {
200
+ else if (tag === DataFormatTags.UTF8_LENGTH16LE) {
175
201
  return buffer.readUTF8_Length16LE();
176
202
  }
177
- else if (tag === 99 /* DataFormatTags.UTF8_LENGTH32LE */) {
203
+ else if (tag === DataFormatTags.UTF8_LENGTH32LE) {
178
204
  return buffer.readUTF8_Length32LE();
179
205
  }
180
- else if (tag === 100 /* DataFormatTags.UTF8_LENGTH64LE */) {
206
+ else if (tag === DataFormatTags.UTF8_LENGTH64LE) {
181
207
  return buffer.readUTF8_Length64LE();
182
208
  }
183
- else if (tag === 111 /* DataFormatTags.UTF8_NULL_TERMINATED */) {
209
+ else if (tag === DataFormatTags.UTF8_NULL_TERMINATED) {
184
210
  return buffer.readUTF8_NULL_terminated();
185
211
  }
186
- else if (tag >= 112 /* DataFormatTags.DATA_LENGTH_START */ && tag <= 144 /* DataFormatTags.DATA_LENGTH_STOP */) {
187
- const length = tag - 112 /* DataFormatTags.DATA_LENGTH_START */;
212
+ else if (tag >= DataFormatTags.DATA_LENGTH_START && tag <= DataFormatTags.DATA_LENGTH_STOP) {
213
+ const length = tag - DataFormatTags.DATA_LENGTH_START;
188
214
  if (length === 0) {
189
215
  return Buffer.alloc(0); // a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
190
216
  }
191
217
  return buffer.readData(length);
192
218
  }
193
- else if (tag === 145 /* DataFormatTags.DATA_LENGTH8 */) {
219
+ else if (tag === DataFormatTags.DATA_LENGTH8) {
194
220
  return buffer.readData_Length8();
195
221
  }
196
- else if (tag === 146 /* DataFormatTags.DATA_LENGTH16LE */) {
222
+ else if (tag === DataFormatTags.DATA_LENGTH16LE) {
197
223
  return buffer.readData_Length16LE();
198
224
  }
199
- else if (tag === 147 /* DataFormatTags.DATA_LENGTH32LE */) {
225
+ else if (tag === DataFormatTags.DATA_LENGTH32LE) {
200
226
  return buffer.readData_Length32LE();
201
227
  }
202
- else if (tag === 148 /* DataFormatTags.DATA_LENGTH64LE */) {
228
+ else if (tag === DataFormatTags.DATA_LENGTH64LE) {
203
229
  return buffer.readData_Length64LE();
204
230
  }
205
- else if (tag === 159 /* DataFormatTags.DATA_TERMINATED */) {
231
+ else if (tag === DataFormatTags.DATA_TERMINATED) {
206
232
  return buffer.readData_terminated();
207
233
  }
208
- else if (tag >= 160 /* DataFormatTags.COMPRESSION_START */ && tag <= 207 /* DataFormatTags.COMPRESSION_STOP */) {
209
- const index = tag - 160 /* DataFormatTags.COMPRESSION_START */;
234
+ else if (tag >= DataFormatTags.COMPRESSION_START && tag <= DataFormatTags.COMPRESSION_STOP) {
235
+ const index = tag - DataFormatTags.COMPRESSION_START;
210
236
  return buffer.decompressData(index);
211
237
  }
212
- else if (tag >= 208 /* DataFormatTags.ARRAY_LENGTH_START */ && tag <= 222 /* DataFormatTags.ARRAY_LENGTH_STOP */) {
213
- const length = tag - 208 /* DataFormatTags.ARRAY_LENGTH_START */;
238
+ else if (tag >= DataFormatTags.ARRAY_LENGTH_START && tag <= DataFormatTags.ARRAY_LENGTH_STOP) {
239
+ const length = tag - DataFormatTags.ARRAY_LENGTH_START;
214
240
  const array = [];
215
241
  for (let i = 0; i < length; i++) {
216
- array.push(this.decode(buffer));
242
+ array.push(this.decodeValue(buffer, depth + 1));
217
243
  }
218
244
  return array;
219
245
  }
220
- else if (tag === 223 /* DataFormatTags.ARRAY_TERMINATED */) {
246
+ else if (tag === DataFormatTags.ARRAY_TERMINATED) {
221
247
  const array = [];
222
248
  let element;
223
249
  // eslint-disable-next-line no-cond-assign
224
- while ((element = this.decode(buffer)) !== Magics.TERMINATOR) {
250
+ while ((element = this.decodeNext(buffer, depth + 1)) !== Magics.TERMINATOR) {
225
251
  array.push(element);
226
252
  }
227
253
  return array;
228
254
  }
229
- else if (tag >= 224 /* DataFormatTags.DICTIONARY_LENGTH_START */ && tag <= 238 /* DataFormatTags.DICTIONARY_LENGTH_STOP */) {
230
- const length = tag - 224 /* DataFormatTags.DICTIONARY_LENGTH_START */;
255
+ else if (tag >= DataFormatTags.DICTIONARY_LENGTH_START && tag <= DataFormatTags.DICTIONARY_LENGTH_STOP) {
256
+ const length = tag - DataFormatTags.DICTIONARY_LENGTH_START;
231
257
  const dictionary = {};
232
258
  for (let i = 0; i < length; i++) {
233
- const key = this.decode(buffer);
234
- dictionary[key] = this.decode(buffer);
259
+ const key = this.decodeValue(buffer, depth + 1);
260
+ this.setDictionaryEntry(dictionary, key, this.decodeValue(buffer, depth + 1));
235
261
  }
236
262
  return dictionary;
237
263
  }
238
- else if (tag === 239 /* DataFormatTags.DICTIONARY_TERMINATED */) {
264
+ else if (tag === DataFormatTags.DICTIONARY_TERMINATED) {
239
265
  const dictionary = {};
240
266
  let key;
241
267
  // eslint-disable-next-line no-cond-assign
242
- while ((key = this.decode(buffer)) !== Magics.TERMINATOR) {
243
- dictionary[key] = this.decode(buffer); // decode value
268
+ while ((key = this.decodeNext(buffer, depth + 1)) !== Magics.TERMINATOR) {
269
+ this.setDictionaryEntry(dictionary, key, this.decodeValue(buffer, depth + 1));
244
270
  }
245
271
  return dictionary;
246
272
  }
@@ -248,13 +274,25 @@ export class DataStreamParser {
248
274
  throw new Error(`HDSDecoder: encountered unknown tag on index ${buffer.readerIndex}: ${tag.toString(16)}`);
249
275
  }
250
276
  }
251
- // eslint-disable-next-line ts/explicit-module-boundary-types
277
+ /**
278
+ * Stores a decoded entry as an own property of the dictionary.
279
+ * A key is a string on the wire, as the writer only writes strings; anything else is named by its string form.
280
+ */
281
+ static setDictionaryEntry(dictionary, key, value) {
282
+ // a plain assignment to the key `__proto__` would replace the prototype of the dictionary instead of storing the value
283
+ Object.defineProperty(dictionary, String(key), {
284
+ value,
285
+ writable: true,
286
+ enumerable: true,
287
+ configurable: true,
288
+ });
289
+ }
252
290
  static encode(data, buffer) {
253
291
  if (data === undefined) {
254
292
  throw new Error('HDSEncoder: cannot encode undefined');
255
293
  }
256
294
  if (data === null) {
257
- buffer.writeTag(4 /* DataFormatTags.NULL */);
295
+ buffer.writeTag(DataFormatTags.NULL);
258
296
  return;
259
297
  }
260
298
  switch (typeof data) {
@@ -281,16 +319,16 @@ export class DataStreamParser {
281
319
  if (Array.isArray(data)) {
282
320
  const length = data.length;
283
321
  if (length <= 12) {
284
- buffer.writeTag(208 /* DataFormatTags.ARRAY_LENGTH_START */ + length);
322
+ buffer.writeTag(DataFormatTags.ARRAY_LENGTH_START + length);
285
323
  }
286
324
  else {
287
- buffer.writeTag(223 /* DataFormatTags.ARRAY_TERMINATED */);
325
+ buffer.writeTag(DataFormatTags.ARRAY_TERMINATED);
288
326
  }
289
327
  data.forEach((element) => {
290
328
  this.encode(element, buffer);
291
329
  });
292
330
  if (length > 12) {
293
- buffer.writeTag(3 /* DataFormatTags.TERMINATOR */);
331
+ buffer.writeTag(DataFormatTags.TERMINATOR);
294
332
  }
295
333
  }
296
334
  else if (data instanceof ValueWrapper) {
@@ -329,17 +367,17 @@ export class DataStreamParser {
329
367
  const entries = Object.entries(data)
330
368
  .filter(entry => entry[1] !== undefined); // explicitly setting undefined will result in an entry here
331
369
  if (entries.length <= 14) {
332
- buffer.writeTag(224 /* DataFormatTags.DICTIONARY_LENGTH_START */ + entries.length);
370
+ buffer.writeTag(DataFormatTags.DICTIONARY_LENGTH_START + entries.length);
333
371
  }
334
372
  else {
335
- buffer.writeTag(239 /* DataFormatTags.DICTIONARY_TERMINATED */);
373
+ buffer.writeTag(DataFormatTags.DICTIONARY_TERMINATED);
336
374
  }
337
375
  entries.forEach((entry) => {
338
376
  this.encode(entry[0], buffer); // encode key
339
377
  this.encode(entry[1], buffer); // encode value
340
378
  });
341
379
  if (entries.length > 14) {
342
- buffer.writeTag(3 /* DataFormatTags.TERMINATOR */);
380
+ buffer.writeTag(DataFormatTags.TERMINATOR);
343
381
  }
344
382
  }
345
383
  break;
@@ -362,7 +400,7 @@ export class DataStreamReader {
362
400
  finished() {
363
401
  if (this.readerIndex < this.data.length) {
364
402
  const remainingHex = this.data.subarray(this.readerIndex, this.data.length).toString('hex');
365
- debug('WARNING Finished reading HDS stream, but there are still %d bytes remaining () %s', this.data.length - this.readerIndex, remainingHex);
403
+ debug('WARNING Finished reading HDS stream, but there are still %d bytes remaining: %s', this.data.length - this.readerIndex, remainingHex);
366
404
  }
367
405
  }
368
406
  decompressData(index) {
@@ -405,7 +443,7 @@ export class DataStreamReader {
405
443
  return -1;
406
444
  }
407
445
  readIntRange(tag) {
408
- return tag - 8 /* DataFormatTags.INTEGER_RANGE_START_0 */; // integer values from 0-39
446
+ return tag - DataFormatTags.INTEGER_RANGE_START_0; // integer values from 0-39
409
447
  }
410
448
  readInt8() {
411
449
  this.ensureLength(1);
@@ -539,7 +577,7 @@ export class DataStreamReader {
539
577
  if (nextByte === undefined) {
540
578
  throw new Error('HDSDecoder: Reached end of data stream while reading terminated data!');
541
579
  }
542
- else if (nextByte === 3 /* DataFormatTags.TERMINATOR */) {
580
+ else if (nextByte === DataFormatTags.TERMINATOR) {
543
581
  break;
544
582
  }
545
583
  else {
@@ -625,7 +663,7 @@ export class DataStreamWriter {
625
663
  }
626
664
  else if (index <= DataStreamWriter.maxDirectReferenceIndex) {
627
665
  // data was already written and the index is in the applicable range => shorten the payload
628
- this.writeTag(160 /* DataFormatTags.COMPRESSION_START */ + index);
666
+ this.writeTag(DataFormatTags.COMPRESSION_START + index);
629
667
  return true;
630
668
  }
631
669
  return false;
@@ -635,17 +673,17 @@ export class DataStreamWriter {
635
673
  this.data.writeUInt8(tag, this.writerIndex++);
636
674
  }
637
675
  writeTrue() {
638
- this.writeTag(1 /* DataFormatTags.TRUE */);
676
+ this.writeTag(DataFormatTags.TRUE);
639
677
  }
640
678
  writeFalse() {
641
- this.writeTag(2 /* DataFormatTags.FALSE */);
679
+ this.writeTag(DataFormatTags.FALSE);
642
680
  }
643
681
  writeNumber(number) {
644
682
  if (number === -1) {
645
- this.writeTag(7 /* DataFormatTags.INTEGER_MINUS_ONE */);
683
+ this.writeTag(DataFormatTags.INTEGER_MINUS_ONE);
646
684
  }
647
685
  else if (number >= 0 && number <= 39) {
648
- this.writeTag(8 /* DataFormatTags.INTEGER_RANGE_START_0 */ + number);
686
+ this.writeTag(DataFormatTags.INTEGER_RANGE_START_0 + number);
649
687
  }
650
688
  else if (number >= -128 && number <= 127) {
651
689
  this.writeInt8(new Int8(number));
@@ -656,7 +694,7 @@ export class DataStreamWriter {
656
694
  else if (number >= -2147483648 && number <= 2147483647) {
657
695
  this.writeInt32LE(new Int32(number));
658
696
  }
659
- else if (number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER) { // use correct uin64 restriction when we convert to bigint
697
+ else if (number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER) { // a number can't hold a larger integer exactly
660
698
  this.writeInt64LE(new Int64(number));
661
699
  }
662
700
  else {
@@ -668,7 +706,7 @@ export class DataStreamWriter {
668
706
  return;
669
707
  }
670
708
  this.ensureLength(2);
671
- this.writeTag(48 /* DataFormatTags.INT8 */);
709
+ this.writeTag(DataFormatTags.INT8);
672
710
  this.data.writeInt8(int8.value, this.writerIndex++);
673
711
  }
674
712
  writeInt16LE(int16) {
@@ -676,7 +714,7 @@ export class DataStreamWriter {
676
714
  return;
677
715
  }
678
716
  this.ensureLength(3);
679
- this.writeTag(49 /* DataFormatTags.INT16LE */);
717
+ this.writeTag(DataFormatTags.INT16LE);
680
718
  this.data.writeInt16LE(int16.value, this.writerIndex);
681
719
  this.writerIndex += 2;
682
720
  }
@@ -685,7 +723,7 @@ export class DataStreamWriter {
685
723
  return;
686
724
  }
687
725
  this.ensureLength(5);
688
- this.writeTag(50 /* DataFormatTags.INT32LE */);
726
+ this.writeTag(DataFormatTags.INT32LE);
689
727
  this.data.writeInt32LE(int32.value, this.writerIndex);
690
728
  this.writerIndex += 4;
691
729
  }
@@ -694,9 +732,8 @@ export class DataStreamWriter {
694
732
  return;
695
733
  }
696
734
  this.ensureLength(9);
697
- this.writeTag(51 /* DataFormatTags.INT64LE */);
698
- this.data.writeUInt32LE(int64.value, this.writerIndex); // TODO correctly implement int64; currently it's basically an int32
699
- this.data.writeUInt32LE(0, this.writerIndex + 4);
735
+ this.writeTag(DataFormatTags.INT64LE);
736
+ this.data.writeBigInt64LE(BigInt(Math.trunc(int64.value)), this.writerIndex);
700
737
  this.writerIndex += 8;
701
738
  }
702
739
  writeFloat32LE(float32) {
@@ -704,7 +741,7 @@ export class DataStreamWriter {
704
741
  return;
705
742
  }
706
743
  this.ensureLength(5);
707
- this.writeTag(53 /* DataFormatTags.FLOAT32LE */);
744
+ this.writeTag(DataFormatTags.FLOAT32LE);
708
745
  this.data.writeFloatLE(float32.value, this.writerIndex);
709
746
  this.writerIndex += 4;
710
747
  }
@@ -713,7 +750,7 @@ export class DataStreamWriter {
713
750
  return;
714
751
  }
715
752
  this.ensureLength(9);
716
- this.writeTag(54 /* DataFormatTags.FLOAT64LE */);
753
+ this.writeTag(DataFormatTags.FLOAT64LE);
717
754
  this.data.writeDoubleLE(float64.value, this.writerIndex);
718
755
  this.writerIndex += 8;
719
756
  }
@@ -739,7 +776,7 @@ export class DataStreamWriter {
739
776
  writeUTF8(utf8) {
740
777
  if (utf8.length === 0) {
741
778
  // a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
742
- this.writeTag(64 /* DataFormatTags.UTF8_LENGTH_START */);
779
+ this.writeTag(DataFormatTags.UTF8_LENGTH_START);
743
780
  return;
744
781
  }
745
782
  if (this.compressDataIfPossible(utf8)) {
@@ -748,7 +785,7 @@ export class DataStreamWriter {
748
785
  const length = Buffer.byteLength(utf8);
749
786
  if (length <= 32) {
750
787
  this.ensureLength(1 + length);
751
- this.writeTag(64 /* DataFormatTags.UTF8_LENGTH_START */ + length);
788
+ this.writeTag(DataFormatTags.UTF8_LENGTH_START + length);
752
789
  this._writeUTF8(utf8);
753
790
  }
754
791
  else if (length <= 255) {
@@ -760,12 +797,9 @@ export class DataStreamWriter {
760
797
  else if (length <= 4294967295) {
761
798
  this.writeUTF8_Length32LE(utf8);
762
799
  }
763
- else if (length <= Number.MAX_SAFE_INTEGER) { // use correct uin64 restriction when we convert to bigint
800
+ else { // a string can never be longer than a number can count
764
801
  this.writeUTF8_Length64LE(utf8);
765
802
  }
766
- else {
767
- this.writeUTF8_NULL_terminated(utf8);
768
- }
769
803
  }
770
804
  _writeUTF8(utf8) {
771
805
  const byteLength = Buffer.byteLength(utf8);
@@ -776,48 +810,42 @@ export class DataStreamWriter {
776
810
  writeUTF8_Length8(utf8) {
777
811
  const length = Buffer.byteLength(utf8);
778
812
  this.ensureLength(2 + length);
779
- this.writeTag(97 /* DataFormatTags.UTF8_LENGTH8 */);
813
+ this.writeTag(DataFormatTags.UTF8_LENGTH8);
780
814
  this.writeLength8(length);
781
815
  this._writeUTF8(utf8);
782
816
  }
783
817
  writeUTF8_Length16LE(utf8) {
784
818
  const length = Buffer.byteLength(utf8);
785
819
  this.ensureLength(3 + length);
786
- this.writeTag(98 /* DataFormatTags.UTF8_LENGTH16LE */);
820
+ this.writeTag(DataFormatTags.UTF8_LENGTH16LE);
787
821
  this.writeLength16LE(length);
788
822
  this._writeUTF8(utf8);
789
823
  }
790
824
  writeUTF8_Length32LE(utf8) {
791
825
  const length = Buffer.byteLength(utf8);
792
826
  this.ensureLength(5 + length);
793
- this.writeTag(99 /* DataFormatTags.UTF8_LENGTH32LE */);
827
+ this.writeTag(DataFormatTags.UTF8_LENGTH32LE);
794
828
  this.writeLength32LE(length);
795
829
  this._writeUTF8(utf8);
796
830
  }
797
831
  writeUTF8_Length64LE(utf8) {
798
832
  const length = Buffer.byteLength(utf8);
799
833
  this.ensureLength(9 + length);
800
- this.writeTag(100 /* DataFormatTags.UTF8_LENGTH64LE */);
834
+ this.writeTag(DataFormatTags.UTF8_LENGTH64LE);
801
835
  this.writeLength64LE(length);
802
836
  this._writeUTF8(utf8);
803
837
  }
804
- writeUTF8_NULL_terminated(utf8) {
805
- this.ensureLength(1 + Buffer.byteLength(utf8) + 1);
806
- this.writeTag(111 /* DataFormatTags.UTF8_NULL_TERMINATED */);
807
- this._writeUTF8(utf8);
808
- this.data.writeUInt8(0, this.writerIndex++);
809
- }
810
838
  writeData(data) {
811
839
  if (data.length === 0) {
812
840
  // a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
813
- this.writeTag(112 /* DataFormatTags.DATA_LENGTH_START */);
841
+ this.writeTag(DataFormatTags.DATA_LENGTH_START);
814
842
  return;
815
843
  }
816
844
  if (this.compressDataIfPossible(data)) {
817
845
  return;
818
846
  }
819
847
  if (data.length <= 32) {
820
- this.writeTag(112 /* DataFormatTags.DATA_LENGTH_START */ + data.length);
848
+ this.writeTag(DataFormatTags.DATA_LENGTH_START + data.length);
821
849
  this._writeData(data);
822
850
  }
823
851
  else if (data.length <= 255) {
@@ -829,12 +857,9 @@ export class DataStreamWriter {
829
857
  else if (data.length <= 4294967295) {
830
858
  this.writeData_Length32LE(data);
831
859
  }
832
- else if (data.length <= Number.MAX_SAFE_INTEGER) {
860
+ else { // a buffer can never be longer than a number can count
833
861
  this.writeData_Length64LE(data);
834
862
  }
835
- else {
836
- this.writeData_terminated(data);
837
- }
838
863
  }
839
864
  _writeData(data) {
840
865
  this.ensureLength(data.length);
@@ -844,40 +869,34 @@ export class DataStreamWriter {
844
869
  }
845
870
  writeData_Length8(data) {
846
871
  this.ensureLength(2 + data.length);
847
- this.writeTag(145 /* DataFormatTags.DATA_LENGTH8 */);
872
+ this.writeTag(DataFormatTags.DATA_LENGTH8);
848
873
  this.writeLength8(data.length);
849
874
  this._writeData(data);
850
875
  }
851
876
  writeData_Length16LE(data) {
852
877
  this.ensureLength(3 + data.length);
853
- this.writeTag(146 /* DataFormatTags.DATA_LENGTH16LE */);
878
+ this.writeTag(DataFormatTags.DATA_LENGTH16LE);
854
879
  this.writeLength16LE(data.length);
855
880
  this._writeData(data);
856
881
  }
857
882
  writeData_Length32LE(data) {
858
883
  this.ensureLength(5 + data.length);
859
- this.writeTag(147 /* DataFormatTags.DATA_LENGTH32LE */);
884
+ this.writeTag(DataFormatTags.DATA_LENGTH32LE);
860
885
  this.writeLength32LE(data.length);
861
886
  this._writeData(data);
862
887
  }
863
888
  writeData_Length64LE(data) {
864
889
  this.ensureLength(9 + data.length);
865
- this.writeTag(148 /* DataFormatTags.DATA_LENGTH64LE */);
890
+ this.writeTag(DataFormatTags.DATA_LENGTH64LE);
866
891
  this.writeLength64LE(data.length);
867
892
  this._writeData(data);
868
893
  }
869
- writeData_terminated(data) {
870
- this.ensureLength(1 + data.length + 1);
871
- this.writeTag(159 /* DataFormatTags.DATA_TERMINATED */);
872
- this._writeData(data);
873
- this.writeTag(3 /* DataFormatTags.TERMINATOR */);
874
- }
875
894
  writeSecondsSince2001_01_01(seconds) {
876
895
  if (this.compressDataIfPossible(seconds)) {
877
896
  return;
878
897
  }
879
898
  this.ensureLength(9);
880
- this.writeTag(6 /* DataFormatTags.DATE */);
899
+ this.writeTag(DataFormatTags.DATE);
881
900
  this.data.writeDoubleLE(seconds.value, this.writerIndex);
882
901
  this.writerIndex += 8;
883
902
  }
@@ -887,7 +906,7 @@ export class DataStreamWriter {
887
906
  return;
888
907
  }
889
908
  this.ensureLength(17);
890
- this.writeTag(5 /* DataFormatTags.UUID */);
909
+ this.writeTag(DataFormatTags.UUID);
891
910
  uuid.write(uuid_string, this.data, this.writerIndex);
892
911
  this.writerIndex += 16;
893
912
  }