@zwave-js/cc 14.0.0-beta.4 → 14.0.0-beta.5

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 (331) hide show
  1. package/build/cjs/cc/AlarmSensorCC.js +381 -266
  2. package/build/cjs/cc/AlarmSensorCC.js.map +3 -3
  3. package/build/cjs/cc/AssociationCC.js +669 -503
  4. package/build/cjs/cc/AssociationCC.js.map +3 -3
  5. package/build/cjs/cc/AssociationGroupInfoCC.js +633 -492
  6. package/build/cjs/cc/AssociationGroupInfoCC.js.map +3 -3
  7. package/build/cjs/cc/BarrierOperatorCC.js +595 -429
  8. package/build/cjs/cc/BarrierOperatorCC.js.map +3 -3
  9. package/build/cjs/cc/BasicCC.js +354 -260
  10. package/build/cjs/cc/BasicCC.js.map +3 -3
  11. package/build/cjs/cc/BatteryCC.js +427 -345
  12. package/build/cjs/cc/BatteryCC.js.map +3 -3
  13. package/build/cjs/cc/BinarySensorCC.js +391 -276
  14. package/build/cjs/cc/BinarySensorCC.js.map +3 -3
  15. package/build/cjs/cc/BinarySwitchCC.js +347 -253
  16. package/build/cjs/cc/BinarySwitchCC.js.map +3 -3
  17. package/build/cjs/cc/CRC16CC.js +160 -85
  18. package/build/cjs/cc/CRC16CC.js.map +3 -3
  19. package/build/cjs/cc/CentralSceneCC.js +459 -324
  20. package/build/cjs/cc/CentralSceneCC.js.map +3 -3
  21. package/build/cjs/cc/ClimateControlScheduleCC.js +459 -293
  22. package/build/cjs/cc/ClimateControlScheduleCC.js.map +3 -3
  23. package/build/cjs/cc/ClockCC.js +254 -150
  24. package/build/cjs/cc/ClockCC.js.map +3 -3
  25. package/build/cjs/cc/ColorSwitchCC.js +758 -610
  26. package/build/cjs/cc/ColorSwitchCC.js.map +3 -3
  27. package/build/cjs/cc/ConfigurationCC.js +1700 -1453
  28. package/build/cjs/cc/ConfigurationCC.js.map +3 -3
  29. package/build/cjs/cc/DeviceResetLocallyCC.js +125 -49
  30. package/build/cjs/cc/DeviceResetLocallyCC.js.map +3 -3
  31. package/build/cjs/cc/DoorLockCC.js +904 -777
  32. package/build/cjs/cc/DoorLockCC.js.map +3 -3
  33. package/build/cjs/cc/DoorLockLoggingCC.js +321 -206
  34. package/build/cjs/cc/DoorLockLoggingCC.js.map +3 -3
  35. package/build/cjs/cc/EnergyProductionCC.js +249 -160
  36. package/build/cjs/cc/EnergyProductionCC.js.map +3 -3
  37. package/build/cjs/cc/EntryControlCC.js +619 -458
  38. package/build/cjs/cc/EntryControlCC.js.map +3 -3
  39. package/build/cjs/cc/FirmwareUpdateMetaDataCC.js +898 -698
  40. package/build/cjs/cc/FirmwareUpdateMetaDataCC.js.map +3 -3
  41. package/build/cjs/cc/HailCC.js +57 -11
  42. package/build/cjs/cc/HailCC.js.map +2 -2
  43. package/build/cjs/cc/HumidityControlModeCC.js +359 -233
  44. package/build/cjs/cc/HumidityControlModeCC.js.map +3 -3
  45. package/build/cjs/cc/HumidityControlOperatingStateCC.js +189 -103
  46. package/build/cjs/cc/HumidityControlOperatingStateCC.js.map +3 -3
  47. package/build/cjs/cc/HumidityControlSetpointCC.js +682 -495
  48. package/build/cjs/cc/HumidityControlSetpointCC.js.map +3 -3
  49. package/build/cjs/cc/InclusionControllerCC.js +205 -114
  50. package/build/cjs/cc/InclusionControllerCC.js.map +3 -3
  51. package/build/cjs/cc/IndicatorCC.js +897 -736
  52. package/build/cjs/cc/IndicatorCC.js.map +3 -3
  53. package/build/cjs/cc/IrrigationCC.js +1651 -1405
  54. package/build/cjs/cc/IrrigationCC.js.map +3 -3
  55. package/build/cjs/cc/LanguageCC.js +268 -171
  56. package/build/cjs/cc/LanguageCC.js.map +3 -3
  57. package/build/cjs/cc/LockCC.js +254 -154
  58. package/build/cjs/cc/LockCC.js.map +3 -3
  59. package/build/cjs/cc/ManufacturerProprietaryCC.js +189 -129
  60. package/build/cjs/cc/ManufacturerProprietaryCC.js.map +2 -2
  61. package/build/cjs/cc/ManufacturerSpecificCC.js +319 -213
  62. package/build/cjs/cc/ManufacturerSpecificCC.js.map +3 -3
  63. package/build/cjs/cc/MeterCC.js +827 -707
  64. package/build/cjs/cc/MeterCC.js.map +3 -3
  65. package/build/cjs/cc/MultiChannelAssociationCC.js +612 -478
  66. package/build/cjs/cc/MultiChannelAssociationCC.js.map +3 -3
  67. package/build/cjs/cc/MultiChannelCC.js +1037 -819
  68. package/build/cjs/cc/MultiChannelCC.js.map +3 -3
  69. package/build/cjs/cc/MultiCommandCC.js +172 -97
  70. package/build/cjs/cc/MultiCommandCC.js.map +3 -3
  71. package/build/cjs/cc/MultilevelSensorCC.js +589 -449
  72. package/build/cjs/cc/MultilevelSensorCC.js.map +3 -3
  73. package/build/cjs/cc/MultilevelSwitchCC.js +587 -439
  74. package/build/cjs/cc/MultilevelSwitchCC.js.map +3 -3
  75. package/build/cjs/cc/NoOperationCC.js +89 -27
  76. package/build/cjs/cc/NoOperationCC.js.map +2 -2
  77. package/build/cjs/cc/NodeNamingCC.js +417 -277
  78. package/build/cjs/cc/NodeNamingCC.js.map +3 -3
  79. package/build/cjs/cc/NotificationCC.js +972 -818
  80. package/build/cjs/cc/NotificationCC.js.map +3 -3
  81. package/build/cjs/cc/PowerlevelCC.js +450 -303
  82. package/build/cjs/cc/PowerlevelCC.js.map +3 -3
  83. package/build/cjs/cc/ProtectionCC.js +686 -494
  84. package/build/cjs/cc/ProtectionCC.js.map +3 -3
  85. package/build/cjs/cc/SceneActivationCC.js +165 -97
  86. package/build/cjs/cc/SceneActivationCC.js.map +3 -3
  87. package/build/cjs/cc/SceneActuatorConfigurationCC.js +346 -243
  88. package/build/cjs/cc/SceneActuatorConfigurationCC.js.map +3 -3
  89. package/build/cjs/cc/SceneControllerConfigurationCC.js +401 -298
  90. package/build/cjs/cc/SceneControllerConfigurationCC.js.map +3 -3
  91. package/build/cjs/cc/ScheduleEntryLockCC.js +1552 -1272
  92. package/build/cjs/cc/ScheduleEntryLockCC.js.map +3 -3
  93. package/build/cjs/cc/Security2CC.js +1483 -1219
  94. package/build/cjs/cc/Security2CC.js.map +3 -3
  95. package/build/cjs/cc/SecurityCC.js +839 -619
  96. package/build/cjs/cc/SecurityCC.js.map +3 -3
  97. package/build/cjs/cc/SoundSwitchCC.js +707 -515
  98. package/build/cjs/cc/SoundSwitchCC.js.map +3 -3
  99. package/build/cjs/cc/SupervisionCC.js +327 -237
  100. package/build/cjs/cc/SupervisionCC.js.map +3 -3
  101. package/build/cjs/cc/ThermostatFanModeCC.js +386 -263
  102. package/build/cjs/cc/ThermostatFanModeCC.js.map +3 -3
  103. package/build/cjs/cc/ThermostatFanStateCC.js +192 -106
  104. package/build/cjs/cc/ThermostatFanStateCC.js.map +3 -3
  105. package/build/cjs/cc/ThermostatModeCC.js +425 -302
  106. package/build/cjs/cc/ThermostatModeCC.js.map +3 -3
  107. package/build/cjs/cc/ThermostatOperatingStateCC.js +188 -102
  108. package/build/cjs/cc/ThermostatOperatingStateCC.js.map +3 -3
  109. package/build/cjs/cc/ThermostatSetbackCC.js +277 -173
  110. package/build/cjs/cc/ThermostatSetbackCC.js.map +3 -3
  111. package/build/cjs/cc/ThermostatSetpointCC.js +645 -491
  112. package/build/cjs/cc/ThermostatSetpointCC.js.map +3 -3
  113. package/build/cjs/cc/TimeCC.js +515 -353
  114. package/build/cjs/cc/TimeCC.js.map +3 -3
  115. package/build/cjs/cc/TimeParametersCC.js +302 -202
  116. package/build/cjs/cc/TimeParametersCC.js.map +3 -3
  117. package/build/cjs/cc/TransportServiceCC.js +433 -315
  118. package/build/cjs/cc/TransportServiceCC.js.map +3 -3
  119. package/build/cjs/cc/UserCodeCC.js +1385 -1102
  120. package/build/cjs/cc/UserCodeCC.js.map +3 -3
  121. package/build/cjs/cc/VersionCC.js +696 -562
  122. package/build/cjs/cc/VersionCC.js.map +3 -3
  123. package/build/cjs/cc/WakeUpCC.js +499 -346
  124. package/build/cjs/cc/WakeUpCC.js.map +3 -3
  125. package/build/cjs/cc/WindowCoveringCC.js +626 -478
  126. package/build/cjs/cc/WindowCoveringCC.js.map +3 -3
  127. package/build/cjs/cc/ZWaveLongRangeCC.js +57 -10
  128. package/build/cjs/cc/ZWaveLongRangeCC.js.map +2 -2
  129. package/build/cjs/cc/ZWavePlusCC.js +233 -159
  130. package/build/cjs/cc/ZWavePlusCC.js.map +3 -3
  131. package/build/cjs/cc/ZWaveProtocolCC.js +1515 -948
  132. package/build/cjs/cc/ZWaveProtocolCC.js.map +3 -3
  133. package/build/cjs/cc/manufacturerProprietary/Decorators.d.ts +4 -4
  134. package/build/cjs/cc/manufacturerProprietary/Decorators.js.map +1 -1
  135. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js +395 -274
  136. package/build/cjs/cc/manufacturerProprietary/FibaroCC.js.map +3 -3
  137. package/build/cjs/lib/CommandClassDecorators.d.ts +11 -15
  138. package/build/cjs/lib/CommandClassDecorators.js +19 -20
  139. package/build/cjs/lib/CommandClassDecorators.js.map +2 -2
  140. package/build/cjs/lib/Security2/Extension.d.ts +1 -1
  141. package/build/cjs/lib/Security2/Extension.js +217 -126
  142. package/build/cjs/lib/Security2/Extension.js.map +3 -3
  143. package/build/esm/cc/AlarmSensorCC.d.ts.map +1 -1
  144. package/build/esm/cc/AlarmSensorCC.js +389 -291
  145. package/build/esm/cc/AlarmSensorCC.js.map +1 -1
  146. package/build/esm/cc/AssociationCC.d.ts.map +1 -1
  147. package/build/esm/cc/AssociationCC.js +678 -537
  148. package/build/esm/cc/AssociationCC.js.map +1 -1
  149. package/build/esm/cc/AssociationGroupInfoCC.d.ts.map +1 -1
  150. package/build/esm/cc/AssociationGroupInfoCC.js +659 -539
  151. package/build/esm/cc/AssociationGroupInfoCC.js.map +1 -1
  152. package/build/esm/cc/BarrierOperatorCC.d.ts.map +1 -1
  153. package/build/esm/cc/BarrierOperatorCC.js +634 -493
  154. package/build/esm/cc/BarrierOperatorCC.js.map +1 -1
  155. package/build/esm/cc/BasicCC.d.ts.map +1 -1
  156. package/build/esm/cc/BasicCC.js +380 -302
  157. package/build/esm/cc/BasicCC.js.map +1 -1
  158. package/build/esm/cc/BatteryCC.d.ts.map +1 -1
  159. package/build/esm/cc/BatteryCC.js +449 -384
  160. package/build/esm/cc/BatteryCC.js.map +1 -1
  161. package/build/esm/cc/BinarySensorCC.d.ts.map +1 -1
  162. package/build/esm/cc/BinarySensorCC.js +395 -297
  163. package/build/esm/cc/BinarySensorCC.js.map +1 -1
  164. package/build/esm/cc/BinarySwitchCC.d.ts.map +1 -1
  165. package/build/esm/cc/BinarySwitchCC.js +353 -274
  166. package/build/esm/cc/BinarySwitchCC.js.map +1 -1
  167. package/build/esm/cc/CRC16CC.js +162 -98
  168. package/build/esm/cc/CRC16CC.js.map +1 -1
  169. package/build/esm/cc/CentralSceneCC.d.ts.map +1 -1
  170. package/build/esm/cc/CentralSceneCC.js +465 -351
  171. package/build/esm/cc/CentralSceneCC.js.map +1 -1
  172. package/build/esm/cc/ClimateControlScheduleCC.d.ts.map +1 -1
  173. package/build/esm/cc/ClimateControlScheduleCC.js +454 -313
  174. package/build/esm/cc/ClimateControlScheduleCC.js.map +1 -1
  175. package/build/esm/cc/ClockCC.js +248 -159
  176. package/build/esm/cc/ClockCC.js.map +1 -1
  177. package/build/esm/cc/ColorSwitchCC.d.ts.map +1 -1
  178. package/build/esm/cc/ColorSwitchCC.js +802 -677
  179. package/build/esm/cc/ColorSwitchCC.js.map +1 -1
  180. package/build/esm/cc/ConfigurationCC.js +1899 -1687
  181. package/build/esm/cc/ConfigurationCC.js.map +1 -1
  182. package/build/esm/cc/DeviceResetLocallyCC.js +124 -59
  183. package/build/esm/cc/DeviceResetLocallyCC.js.map +1 -1
  184. package/build/esm/cc/DoorLockCC.d.ts.map +1 -1
  185. package/build/esm/cc/DoorLockCC.js +951 -849
  186. package/build/esm/cc/DoorLockCC.js.map +1 -1
  187. package/build/esm/cc/DoorLockLoggingCC.d.ts.map +1 -1
  188. package/build/esm/cc/DoorLockLoggingCC.js +316 -218
  189. package/build/esm/cc/DoorLockLoggingCC.js.map +1 -1
  190. package/build/esm/cc/EnergyProductionCC.js +240 -164
  191. package/build/esm/cc/EnergyProductionCC.js.map +1 -1
  192. package/build/esm/cc/EntryControlCC.d.ts.map +1 -1
  193. package/build/esm/cc/EntryControlCC.js +629 -493
  194. package/build/esm/cc/EntryControlCC.js.map +1 -1
  195. package/build/esm/cc/FirmwareUpdateMetaDataCC.d.ts.map +1 -1
  196. package/build/esm/cc/FirmwareUpdateMetaDataCC.js +938 -769
  197. package/build/esm/cc/FirmwareUpdateMetaDataCC.js.map +1 -1
  198. package/build/esm/cc/HailCC.js +51 -12
  199. package/build/esm/cc/HailCC.js.map +1 -1
  200. package/build/esm/cc/HumidityControlModeCC.d.ts.map +1 -1
  201. package/build/esm/cc/HumidityControlModeCC.js +357 -250
  202. package/build/esm/cc/HumidityControlModeCC.js.map +1 -1
  203. package/build/esm/cc/HumidityControlOperatingStateCC.d.ts.map +1 -1
  204. package/build/esm/cc/HumidityControlOperatingStateCC.js +182 -109
  205. package/build/esm/cc/HumidityControlOperatingStateCC.js.map +1 -1
  206. package/build/esm/cc/HumidityControlSetpointCC.d.ts.map +1 -1
  207. package/build/esm/cc/HumidityControlSetpointCC.js +706 -546
  208. package/build/esm/cc/HumidityControlSetpointCC.js.map +1 -1
  209. package/build/esm/cc/InclusionControllerCC.js +197 -119
  210. package/build/esm/cc/InclusionControllerCC.js.map +1 -1
  211. package/build/esm/cc/IndicatorCC.js +973 -835
  212. package/build/esm/cc/IndicatorCC.js.map +1 -1
  213. package/build/esm/cc/IrrigationCC.d.ts.map +1 -1
  214. package/build/esm/cc/IrrigationCC.js +1697 -1496
  215. package/build/esm/cc/IrrigationCC.js.map +1 -1
  216. package/build/esm/cc/LanguageCC.d.ts.map +1 -1
  217. package/build/esm/cc/LanguageCC.js +266 -184
  218. package/build/esm/cc/LanguageCC.js.map +1 -1
  219. package/build/esm/cc/LockCC.d.ts.map +1 -1
  220. package/build/esm/cc/LockCC.js +247 -162
  221. package/build/esm/cc/LockCC.js.map +1 -1
  222. package/build/esm/cc/ManufacturerProprietaryCC.js +192 -141
  223. package/build/esm/cc/ManufacturerProprietaryCC.js.map +1 -1
  224. package/build/esm/cc/ManufacturerSpecificCC.d.ts.map +1 -1
  225. package/build/esm/cc/ManufacturerSpecificCC.js +312 -223
  226. package/build/esm/cc/ManufacturerSpecificCC.js.map +1 -1
  227. package/build/esm/cc/MeterCC.d.ts.map +1 -1
  228. package/build/esm/cc/MeterCC.js +896 -795
  229. package/build/esm/cc/MeterCC.js.map +1 -1
  230. package/build/esm/cc/MultiChannelAssociationCC.d.ts.map +1 -1
  231. package/build/esm/cc/MultiChannelAssociationCC.js +631 -518
  232. package/build/esm/cc/MultiChannelAssociationCC.js.map +1 -1
  233. package/build/esm/cc/MultiChannelCC.d.ts.map +1 -1
  234. package/build/esm/cc/MultiChannelCC.js +1106 -921
  235. package/build/esm/cc/MultiChannelCC.js.map +1 -1
  236. package/build/esm/cc/MultiCommandCC.js +166 -102
  237. package/build/esm/cc/MultiCommandCC.js.map +1 -1
  238. package/build/esm/cc/MultilevelSensorCC.d.ts.map +1 -1
  239. package/build/esm/cc/MultilevelSensorCC.js +616 -497
  240. package/build/esm/cc/MultilevelSensorCC.js.map +1 -1
  241. package/build/esm/cc/MultilevelSwitchCC.d.ts.map +1 -1
  242. package/build/esm/cc/MultilevelSwitchCC.js +621 -496
  243. package/build/esm/cc/MultilevelSwitchCC.js.map +1 -1
  244. package/build/esm/cc/NoOperationCC.js +82 -29
  245. package/build/esm/cc/NoOperationCC.js.map +1 -1
  246. package/build/esm/cc/NodeNamingCC.d.ts.map +1 -1
  247. package/build/esm/cc/NodeNamingCC.js +413 -294
  248. package/build/esm/cc/NodeNamingCC.js.map +1 -1
  249. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  250. package/build/esm/cc/NotificationCC.js +1097 -966
  251. package/build/esm/cc/NotificationCC.js.map +1 -1
  252. package/build/esm/cc/PowerlevelCC.js +437 -311
  253. package/build/esm/cc/PowerlevelCC.js.map +1 -1
  254. package/build/esm/cc/ProtectionCC.d.ts.map +1 -1
  255. package/build/esm/cc/ProtectionCC.js +704 -543
  256. package/build/esm/cc/ProtectionCC.js.map +1 -1
  257. package/build/esm/cc/SceneActivationCC.d.ts.map +1 -1
  258. package/build/esm/cc/SceneActivationCC.js +157 -100
  259. package/build/esm/cc/SceneActivationCC.js.map +1 -1
  260. package/build/esm/cc/SceneActuatorConfigurationCC.js +357 -269
  261. package/build/esm/cc/SceneActuatorConfigurationCC.js.map +1 -1
  262. package/build/esm/cc/SceneControllerConfigurationCC.js +434 -346
  263. package/build/esm/cc/SceneControllerConfigurationCC.js.map +1 -1
  264. package/build/esm/cc/ScheduleEntryLockCC.d.ts.map +1 -1
  265. package/build/esm/cc/ScheduleEntryLockCC.js +1596 -1357
  266. package/build/esm/cc/ScheduleEntryLockCC.js.map +1 -1
  267. package/build/esm/cc/Security2CC.js +1633 -1406
  268. package/build/esm/cc/Security2CC.js.map +1 -1
  269. package/build/esm/cc/SecurityCC.js +876 -687
  270. package/build/esm/cc/SecurityCC.js.map +1 -1
  271. package/build/esm/cc/SoundSwitchCC.d.ts.map +1 -1
  272. package/build/esm/cc/SoundSwitchCC.js +689 -526
  273. package/build/esm/cc/SoundSwitchCC.js.map +1 -1
  274. package/build/esm/cc/SupervisionCC.js +349 -272
  275. package/build/esm/cc/SupervisionCC.js.map +1 -1
  276. package/build/esm/cc/ThermostatFanModeCC.d.ts.map +1 -1
  277. package/build/esm/cc/ThermostatFanModeCC.js +388 -284
  278. package/build/esm/cc/ThermostatFanModeCC.js.map +1 -1
  279. package/build/esm/cc/ThermostatFanStateCC.d.ts.map +1 -1
  280. package/build/esm/cc/ThermostatFanStateCC.js +184 -111
  281. package/build/esm/cc/ThermostatFanStateCC.js.map +1 -1
  282. package/build/esm/cc/ThermostatModeCC.d.ts.map +1 -1
  283. package/build/esm/cc/ThermostatModeCC.js +435 -331
  284. package/build/esm/cc/ThermostatModeCC.js.map +1 -1
  285. package/build/esm/cc/ThermostatOperatingStateCC.d.ts.map +1 -1
  286. package/build/esm/cc/ThermostatOperatingStateCC.js +180 -107
  287. package/build/esm/cc/ThermostatOperatingStateCC.js.map +1 -1
  288. package/build/esm/cc/ThermostatSetbackCC.js +274 -185
  289. package/build/esm/cc/ThermostatSetbackCC.js.map +1 -1
  290. package/build/esm/cc/ThermostatSetpointCC.d.ts.map +1 -1
  291. package/build/esm/cc/ThermostatSetpointCC.js +674 -543
  292. package/build/esm/cc/ThermostatSetpointCC.js.map +1 -1
  293. package/build/esm/cc/TimeCC.js +499 -360
  294. package/build/esm/cc/TimeCC.js.map +1 -1
  295. package/build/esm/cc/TimeParametersCC.d.ts.map +1 -1
  296. package/build/esm/cc/TimeParametersCC.js +296 -211
  297. package/build/esm/cc/TimeParametersCC.js.map +1 -1
  298. package/build/esm/cc/TransportServiceCC.js +464 -363
  299. package/build/esm/cc/TransportServiceCC.js.map +1 -1
  300. package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
  301. package/build/esm/cc/UserCodeCC.js +1443 -1205
  302. package/build/esm/cc/UserCodeCC.js.map +1 -1
  303. package/build/esm/cc/VersionCC.d.ts.map +1 -1
  304. package/build/esm/cc/VersionCC.js +744 -635
  305. package/build/esm/cc/VersionCC.js.map +1 -1
  306. package/build/esm/cc/WakeUpCC.d.ts.map +1 -1
  307. package/build/esm/cc/WakeUpCC.js +494 -364
  308. package/build/esm/cc/WakeUpCC.js.map +1 -1
  309. package/build/esm/cc/WindowCoveringCC.d.ts.map +1 -1
  310. package/build/esm/cc/WindowCoveringCC.js +655 -530
  311. package/build/esm/cc/WindowCoveringCC.js.map +1 -1
  312. package/build/esm/cc/ZWaveLongRangeCC.js +51 -11
  313. package/build/esm/cc/ZWaveLongRangeCC.js.map +1 -1
  314. package/build/esm/cc/ZWavePlusCC.d.ts.map +1 -1
  315. package/build/esm/cc/ZWavePlusCC.js +223 -162
  316. package/build/esm/cc/ZWavePlusCC.js.map +1 -1
  317. package/build/esm/cc/ZWaveProtocolCC.js +1443 -953
  318. package/build/esm/cc/ZWaveProtocolCC.js.map +1 -1
  319. package/build/esm/cc/manufacturerProprietary/Decorators.d.ts +4 -4
  320. package/build/esm/cc/manufacturerProprietary/Decorators.d.ts.map +1 -1
  321. package/build/esm/cc/manufacturerProprietary/FibaroCC.js +390 -286
  322. package/build/esm/cc/manufacturerProprietary/FibaroCC.js.map +1 -1
  323. package/build/esm/lib/CommandClassDecorators.d.ts +11 -15
  324. package/build/esm/lib/CommandClassDecorators.d.ts.map +1 -1
  325. package/build/esm/lib/CommandClassDecorators.js +24 -24
  326. package/build/esm/lib/CommandClassDecorators.js.map +1 -1
  327. package/build/esm/lib/Security2/Extension.d.ts +1 -1
  328. package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
  329. package/build/esm/lib/Security2/Extension.js +207 -123
  330. package/build/esm/lib/Security2/Extension.js.map +1 -1
  331. package/package.json +6 -6
@@ -1,10 +1,37 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
6
34
  };
7
- var SecurityCC_1, SecurityCCNonceReport_1, SecurityCCCommandEncapsulation_1, SecurityCCSchemeReport_1, SecurityCCNetworkKeySet_1, SecurityCCCommandsSupportedReport_1;
8
35
  import { CommandClasses, EncapsulationFlags, MessagePriority, SecurityClass, TransmitOptions, ZWaveError, ZWaveErrorCodes, computeMAC, decryptAES128OFB, encodeCCList, encryptAES128OFB, generateAuthKey, generateEncryptionKey, getCCName, isTransmissionError, parseCCList, validatePayload, } from "@zwave-js/core";
9
36
  import { Bytes } from "@zwave-js/shared/safe";
10
37
  import { buffer2hex, num2hex, pick } from "@zwave-js/shared/safe";
@@ -58,743 +85,905 @@ function assertSecurityTX(ctx) {
58
85
  // Encapsulation CCs are used internally and too frequently that we
59
86
  // want to pay the cost of validating each call
60
87
  /* eslint-disable @zwave-js/ccapi-validate-args */
61
- let SecurityCCAPI = class SecurityCCAPI extends PhysicalCCAPI {
62
- supportsCommand(_cmd) {
63
- // All commands are mandatory
64
- return true;
65
- }
66
- async sendEncapsulated(encapsulated, requestNextNonce = false) {
67
- if (requestNextNonce) {
68
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulation);
69
- }
70
- else {
71
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulationNonceGet);
72
- }
73
- const cc = new (requestNextNonce
74
- ? SecurityCCCommandEncapsulationNonceGet
75
- : SecurityCCCommandEncapsulation)({
76
- nodeId: this.endpoint.nodeId,
77
- encapsulated,
78
- });
79
- await this.host.sendCommand(cc, this.commandOptions);
80
- }
81
- /**
82
- * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.
83
- */
84
- async getNonce() {
85
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);
86
- const cc = new SecurityCCNonceGet({
87
- nodeId: this.endpoint.nodeId,
88
- endpointIndex: this.endpoint.index,
89
- });
90
- const response = await this.host.sendCommand(cc, {
91
- ...this.commandOptions,
92
- // Only try getting a nonce once
93
- maxSendAttempts: 1,
94
- });
95
- if (!response)
96
- return;
97
- const nonce = response.nonce;
98
- const secMan = this.host.securityManager;
99
- secMan.setNonce({
100
- issuer: this.endpoint.nodeId,
101
- nonceId: secMan.getNonceId(nonce),
102
- }, { nonce, receiver: this.host.ownNodeId }, { free: true });
103
- return nonce;
104
- }
105
- /**
106
- * Responds to a NonceGet request. The message is sent without any retransmission etc.
107
- * The return value indicates whether a nonce was successfully sent
108
- */
109
- async sendNonce() {
110
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceReport);
111
- if (!this.host.securityManager) {
112
- throw new ZWaveError(`Nonces can only be sent if secure communication is set up!`, ZWaveErrorCodes.Driver_NoSecurity);
113
- }
114
- const nonce = this.host.securityManager.generateNonce(this.endpoint.nodeId, HALF_NONCE_SIZE);
115
- const nonceId = this.host.securityManager.getNonceId(nonce);
116
- const cc = new SecurityCCNonceReport({
117
- nodeId: this.endpoint.nodeId,
118
- endpointIndex: this.endpoint.index,
119
- nonce,
120
- });
121
- try {
122
- await this.host.sendCommand(cc, {
88
+ let SecurityCCAPI = (() => {
89
+ let _classDecorators = [API(CommandClasses.Security)];
90
+ let _classDescriptor;
91
+ let _classExtraInitializers = [];
92
+ let _classThis;
93
+ let _classSuper = PhysicalCCAPI;
94
+ var SecurityCCAPI = class extends _classSuper {
95
+ static { _classThis = this; }
96
+ static {
97
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
98
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
99
+ SecurityCCAPI = _classThis = _classDescriptor.value;
100
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
101
+ __runInitializers(_classThis, _classExtraInitializers);
102
+ }
103
+ supportsCommand(_cmd) {
104
+ // All commands are mandatory
105
+ return true;
106
+ }
107
+ async sendEncapsulated(encapsulated, requestNextNonce = false) {
108
+ if (requestNextNonce) {
109
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulation);
110
+ }
111
+ else {
112
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulationNonceGet);
113
+ }
114
+ const cc = new (requestNextNonce
115
+ ? SecurityCCCommandEncapsulationNonceGet
116
+ : SecurityCCCommandEncapsulation)({
117
+ nodeId: this.endpoint.nodeId,
118
+ encapsulated,
119
+ });
120
+ await this.host.sendCommand(cc, this.commandOptions);
121
+ }
122
+ /**
123
+ * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.
124
+ */
125
+ async getNonce() {
126
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);
127
+ const cc = new SecurityCCNonceGet({
128
+ nodeId: this.endpoint.nodeId,
129
+ endpointIndex: this.endpoint.index,
130
+ });
131
+ const response = await this.host.sendCommand(cc, {
123
132
  ...this.commandOptions,
124
- // Seems we need these options or some nodes won't accept the nonce
125
- transmitOptions: TransmitOptions.ACK
126
- | TransmitOptions.AutoRoute,
127
- // Only try sending a nonce once
133
+ // Only try getting a nonce once
128
134
  maxSendAttempts: 1,
129
- // Nonce requests must be handled immediately
130
- priority: MessagePriority.Immediate,
131
- // We don't want failures causing us to treat the node as asleep or dead
132
- changeNodeStatusOnMissingACK: false,
133
135
  });
136
+ if (!response)
137
+ return;
138
+ const nonce = response.nonce;
139
+ const secMan = this.host.securityManager;
140
+ secMan.setNonce({
141
+ issuer: this.endpoint.nodeId,
142
+ nonceId: secMan.getNonceId(nonce),
143
+ }, { nonce, receiver: this.host.ownNodeId }, { free: true });
144
+ return nonce;
134
145
  }
135
- catch (e) {
136
- if (isTransmissionError(e)) {
137
- // The nonce could not be sent, invalidate it
138
- this.host.securityManager.deleteNonce(nonceId);
139
- return false;
146
+ /**
147
+ * Responds to a NonceGet request. The message is sent without any retransmission etc.
148
+ * The return value indicates whether a nonce was successfully sent
149
+ */
150
+ async sendNonce() {
151
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceReport);
152
+ if (!this.host.securityManager) {
153
+ throw new ZWaveError(`Nonces can only be sent if secure communication is set up!`, ZWaveErrorCodes.Driver_NoSecurity);
140
154
  }
141
- else {
142
- // Pass other errors through
143
- throw e;
155
+ const nonce = this.host.securityManager.generateNonce(this.endpoint.nodeId, HALF_NONCE_SIZE);
156
+ const nonceId = this.host.securityManager.getNonceId(nonce);
157
+ const cc = new SecurityCCNonceReport({
158
+ nodeId: this.endpoint.nodeId,
159
+ endpointIndex: this.endpoint.index,
160
+ nonce,
161
+ });
162
+ try {
163
+ await this.host.sendCommand(cc, {
164
+ ...this.commandOptions,
165
+ // Seems we need these options or some nodes won't accept the nonce
166
+ transmitOptions: TransmitOptions.ACK
167
+ | TransmitOptions.AutoRoute,
168
+ // Only try sending a nonce once
169
+ maxSendAttempts: 1,
170
+ // Nonce requests must be handled immediately
171
+ priority: MessagePriority.Immediate,
172
+ // We don't want failures causing us to treat the node as asleep or dead
173
+ changeNodeStatusOnMissingACK: false,
174
+ });
144
175
  }
176
+ catch (e) {
177
+ if (isTransmissionError(e)) {
178
+ // The nonce could not be sent, invalidate it
179
+ this.host.securityManager.deleteNonce(nonceId);
180
+ return false;
181
+ }
182
+ else {
183
+ // Pass other errors through
184
+ throw e;
185
+ }
186
+ }
187
+ return true;
145
188
  }
146
- return true;
147
- }
148
- async getSecurityScheme() {
149
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);
150
- const cc = new SecurityCCSchemeGet({
151
- nodeId: this.endpoint.nodeId,
152
- endpointIndex: this.endpoint.index,
153
- });
154
- await this.host.sendCommand(cc, this.commandOptions);
155
- // There is only one scheme, so we hardcode it
156
- return [0];
157
- }
158
- async reportSecurityScheme(encapsulated) {
159
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeReport);
160
- let cc = new SecurityCCSchemeReport({
161
- nodeId: this.endpoint.nodeId,
162
- endpointIndex: this.endpoint.index,
163
- });
164
- if (encapsulated) {
165
- cc = new SecurityCCCommandEncapsulation({
189
+ async getSecurityScheme() {
190
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);
191
+ const cc = new SecurityCCSchemeGet({
166
192
  nodeId: this.endpoint.nodeId,
167
193
  endpointIndex: this.endpoint.index,
168
- encapsulated: cc,
169
194
  });
195
+ await this.host.sendCommand(cc, this.commandOptions);
196
+ // There is only one scheme, so we hardcode it
197
+ return [0];
170
198
  }
171
- await this.host.sendCommand(cc, this.commandOptions);
172
- }
173
- async inheritSecurityScheme() {
174
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeInherit);
175
- const cc = new SecurityCCSchemeInherit({
176
- nodeId: this.endpoint.nodeId,
177
- endpointIndex: this.endpoint.index,
178
- });
179
- await this.host.sendCommand(cc, this.commandOptions);
180
- // There is only one scheme, so we don't return anything here
181
- }
182
- async setNetworkKey(networkKey) {
183
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeySet);
184
- const keySet = new SecurityCCNetworkKeySet({
185
- nodeId: this.endpoint.nodeId,
186
- endpointIndex: this.endpoint.index,
187
- networkKey,
188
- });
189
- const cc = new SecurityCCCommandEncapsulation({
190
- nodeId: this.endpoint.nodeId,
191
- endpointIndex: this.endpoint.index,
192
- encapsulated: keySet,
193
- alternativeNetworkKey: new Uint8Array(16).fill(0),
194
- });
195
- await this.host.sendCommand(cc, this.commandOptions);
196
- }
197
- async verifyNetworkKey() {
198
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeyVerify);
199
- const cc = new SecurityCCNetworkKeyVerify({
200
- nodeId: this.endpoint.nodeId,
201
- endpointIndex: this.endpoint.index,
202
- });
203
- await this.host.sendCommand(cc, this.commandOptions);
204
- }
205
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
206
- async getSupportedCommands() {
207
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedGet);
208
- const cc = new SecurityCCCommandsSupportedGet({
209
- nodeId: this.endpoint.nodeId,
210
- endpointIndex: this.endpoint.index,
211
- });
212
- const response = await this.host.sendCommand(cc, this.commandOptions);
213
- if (response) {
214
- return pick(response, ["supportedCCs", "controlledCCs"]);
199
+ async reportSecurityScheme(encapsulated) {
200
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeReport);
201
+ let cc = new SecurityCCSchemeReport({
202
+ nodeId: this.endpoint.nodeId,
203
+ endpointIndex: this.endpoint.index,
204
+ });
205
+ if (encapsulated) {
206
+ cc = new SecurityCCCommandEncapsulation({
207
+ nodeId: this.endpoint.nodeId,
208
+ endpointIndex: this.endpoint.index,
209
+ encapsulated: cc,
210
+ });
211
+ }
212
+ await this.host.sendCommand(cc, this.commandOptions);
215
213
  }
216
- }
217
- async reportSupportedCommands(supportedCCs, controlledCCs) {
218
- this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedReport);
219
- const cc = new SecurityCCCommandsSupportedReport({
220
- nodeId: this.endpoint.nodeId,
221
- endpointIndex: this.endpoint.index,
222
- supportedCCs,
223
- controlledCCs,
224
- reportsToFollow: 0,
225
- });
226
- await this.host.sendCommand(cc, this.commandOptions);
227
- }
228
- };
229
- SecurityCCAPI = __decorate([
230
- API(CommandClasses.Security)
231
- ], SecurityCCAPI);
214
+ async inheritSecurityScheme() {
215
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeInherit);
216
+ const cc = new SecurityCCSchemeInherit({
217
+ nodeId: this.endpoint.nodeId,
218
+ endpointIndex: this.endpoint.index,
219
+ });
220
+ await this.host.sendCommand(cc, this.commandOptions);
221
+ // There is only one scheme, so we don't return anything here
222
+ }
223
+ async setNetworkKey(networkKey) {
224
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeySet);
225
+ const keySet = new SecurityCCNetworkKeySet({
226
+ nodeId: this.endpoint.nodeId,
227
+ endpointIndex: this.endpoint.index,
228
+ networkKey,
229
+ });
230
+ const cc = new SecurityCCCommandEncapsulation({
231
+ nodeId: this.endpoint.nodeId,
232
+ endpointIndex: this.endpoint.index,
233
+ encapsulated: keySet,
234
+ alternativeNetworkKey: new Uint8Array(16).fill(0),
235
+ });
236
+ await this.host.sendCommand(cc, this.commandOptions);
237
+ }
238
+ async verifyNetworkKey() {
239
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeyVerify);
240
+ const cc = new SecurityCCNetworkKeyVerify({
241
+ nodeId: this.endpoint.nodeId,
242
+ endpointIndex: this.endpoint.index,
243
+ });
244
+ await this.host.sendCommand(cc, this.commandOptions);
245
+ }
246
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
247
+ async getSupportedCommands() {
248
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedGet);
249
+ const cc = new SecurityCCCommandsSupportedGet({
250
+ nodeId: this.endpoint.nodeId,
251
+ endpointIndex: this.endpoint.index,
252
+ });
253
+ const response = await this.host.sendCommand(cc, this.commandOptions);
254
+ if (response) {
255
+ return pick(response, ["supportedCCs", "controlledCCs"]);
256
+ }
257
+ }
258
+ async reportSupportedCommands(supportedCCs, controlledCCs) {
259
+ this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedReport);
260
+ const cc = new SecurityCCCommandsSupportedReport({
261
+ nodeId: this.endpoint.nodeId,
262
+ endpointIndex: this.endpoint.index,
263
+ supportedCCs,
264
+ controlledCCs,
265
+ reportsToFollow: 0,
266
+ });
267
+ await this.host.sendCommand(cc, this.commandOptions);
268
+ }
269
+ };
270
+ return SecurityCCAPI = _classThis;
271
+ })();
232
272
  export { SecurityCCAPI };
233
- let SecurityCC = SecurityCC_1 = class SecurityCC extends CommandClass {
234
- async interview(ctx) {
235
- const node = this.getNode(ctx);
236
- const endpoint = this.getEndpoint(ctx);
237
- const api = CCAPI.create(CommandClasses.Security, ctx, endpoint).withOptions({
238
- priority: MessagePriority.NodeQuery,
239
- });
240
- ctx.logNode(node.id, {
241
- message: "Querying securely supported commands (S0)...",
242
- direction: "outbound",
243
- });
244
- let supportedCCs;
245
- let controlledCCs;
246
- // Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class
247
- const MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;
248
- for (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {
249
- const resp = await api.getSupportedCommands();
250
- if (resp) {
251
- supportedCCs = resp.supportedCCs;
252
- controlledCCs = resp.controlledCCs;
253
- break;
273
+ let SecurityCC = (() => {
274
+ let _classDecorators = [commandClass(CommandClasses.Security), implementedVersion(1)];
275
+ let _classDescriptor;
276
+ let _classExtraInitializers = [];
277
+ let _classThis;
278
+ let _classSuper = CommandClass;
279
+ var SecurityCC = class extends _classSuper {
280
+ static { _classThis = this; }
281
+ static {
282
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
283
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
284
+ SecurityCC = _classThis = _classDescriptor.value;
285
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
286
+ __runInitializers(_classThis, _classExtraInitializers);
287
+ }
288
+ async interview(ctx) {
289
+ const node = this.getNode(ctx);
290
+ const endpoint = this.getEndpoint(ctx);
291
+ const api = CCAPI.create(CommandClasses.Security, ctx, endpoint).withOptions({
292
+ priority: MessagePriority.NodeQuery,
293
+ });
294
+ ctx.logNode(node.id, {
295
+ message: "Querying securely supported commands (S0)...",
296
+ direction: "outbound",
297
+ });
298
+ let supportedCCs;
299
+ let controlledCCs;
300
+ // Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class
301
+ const MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;
302
+ for (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {
303
+ const resp = await api.getSupportedCommands();
304
+ if (resp) {
305
+ supportedCCs = resp.supportedCCs;
306
+ controlledCCs = resp.controlledCCs;
307
+ break;
308
+ }
309
+ else if (attempts < MAX_ATTEMPTS) {
310
+ ctx.logNode(node.id, {
311
+ endpoint: this.endpointIndex,
312
+ message: `Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,
313
+ level: "warn",
314
+ });
315
+ await wait(500);
316
+ }
254
317
  }
255
- else if (attempts < MAX_ATTEMPTS) {
256
- ctx.logNode(node.id, {
257
- endpoint: this.endpointIndex,
258
- message: `Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,
259
- level: "warn",
260
- });
261
- await wait(500);
318
+ if (!supportedCCs || !controlledCCs) {
319
+ if (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {
320
+ ctx.logNode(node.id, {
321
+ endpoint: this.endpointIndex,
322
+ message: "Querying securely supported commands (S0) failed",
323
+ level: "warn",
324
+ });
325
+ // TODO: Abort interview?
326
+ }
327
+ else {
328
+ // We didn't know if the node was secure and it didn't respond,
329
+ // assume that it doesn't have the S0 security class
330
+ ctx.logNode(node.id, `The node was not granted the S0 security class. Continuing interview non-securely.`);
331
+ node.setSecurityClass(SecurityClass.S0_Legacy, false);
332
+ }
333
+ return;
262
334
  }
263
- }
264
- if (!supportedCCs || !controlledCCs) {
265
- if (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {
266
- ctx.logNode(node.id, {
267
- endpoint: this.endpointIndex,
268
- message: "Querying securely supported commands (S0) failed",
269
- level: "warn",
270
- });
271
- // TODO: Abort interview?
335
+ const logLines = [
336
+ "received secure commands (S0)",
337
+ "supported CCs:",
338
+ ];
339
+ for (const cc of supportedCCs) {
340
+ logLines.push(`· ${getCCName(cc)}`);
272
341
  }
273
- else {
274
- // We didn't know if the node was secure and it didn't respond,
275
- // assume that it doesn't have the S0 security class
276
- ctx.logNode(node.id, `The node was not granted the S0 security class. Continuing interview non-securely.`);
277
- node.setSecurityClass(SecurityClass.S0_Legacy, false);
342
+ logLines.push("controlled CCs:");
343
+ for (const cc of controlledCCs) {
344
+ logLines.push(`· ${getCCName(cc)}`);
345
+ }
346
+ ctx.logNode(node.id, {
347
+ message: logLines.join("\n"),
348
+ direction: "inbound",
349
+ });
350
+ // Remember which commands are supported securely
351
+ for (const cc of supportedCCs) {
352
+ // Basic CC has special rules for when it is considered supported
353
+ // Therefore we mark all other CCs as supported, but not Basic CC,
354
+ // for which support is determined later.
355
+ if (cc === CommandClasses.Basic) {
356
+ endpoint.addCC(cc, { secure: true });
357
+ }
358
+ else {
359
+ endpoint.addCC(cc, {
360
+ isSupported: true,
361
+ secure: true,
362
+ });
363
+ }
278
364
  }
279
- return;
280
- }
281
- const logLines = [
282
- "received secure commands (S0)",
283
- "supported CCs:",
284
- ];
285
- for (const cc of supportedCCs) {
286
- logLines.push(`· ${getCCName(cc)}`);
287
- }
288
- logLines.push("controlled CCs:");
289
- for (const cc of controlledCCs) {
290
- logLines.push(`· ${getCCName(cc)}`);
291
- }
292
- ctx.logNode(node.id, {
293
- message: logLines.join("\n"),
294
- direction: "inbound",
295
- });
296
- // Remember which commands are supported securely
297
- for (const cc of supportedCCs) {
298
- // Basic CC has special rules for when it is considered supported
299
- // Therefore we mark all other CCs as supported, but not Basic CC,
300
- // for which support is determined later.
301
- if (cc === CommandClasses.Basic) {
302
- endpoint.addCC(cc, { secure: true });
365
+ for (const cc of controlledCCs) {
366
+ // Basic CC has special rules for when it is considered supported
367
+ // Therefore we mark all other CCs as supported, but not Basic CC,
368
+ // for which support is determined later.
369
+ if (cc === CommandClasses.Basic) {
370
+ endpoint.addCC(cc, { secure: true });
371
+ }
372
+ else {
373
+ endpoint.addCC(cc, {
374
+ isControlled: true,
375
+ secure: true,
376
+ });
377
+ }
303
378
  }
304
- else {
305
- endpoint.addCC(cc, {
306
- isSupported: true,
307
- secure: true,
308
- });
379
+ // We know for sure that the node is included securely
380
+ if (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {
381
+ node.setSecurityClass(SecurityClass.S0_Legacy, true);
382
+ ctx.logNode(node.id, `The node was granted the S0 security class`);
309
383
  }
384
+ // Remember that the interview is complete
385
+ this.setInterviewComplete(ctx, true);
310
386
  }
311
- for (const cc of controlledCCs) {
312
- // Basic CC has special rules for when it is considered supported
313
- // Therefore we mark all other CCs as supported, but not Basic CC,
314
- // for which support is determined later.
315
- if (cc === CommandClasses.Basic) {
316
- endpoint.addCC(cc, { secure: true });
387
+ /** Tests if a command should be sent secure and thus requires encapsulation */
388
+ static requiresEncapsulation(cc) {
389
+ // No security flag -> no encapsulation
390
+ if (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {
391
+ return false;
317
392
  }
318
- else {
319
- endpoint.addCC(cc, {
320
- isControlled: true,
321
- secure: true,
322
- });
393
+ // S2, CRC16, Transport Service -> no S2 encapsulation
394
+ if (cc instanceof Security2CC
395
+ || cc instanceof CRC16CC
396
+ || cc instanceof TransportServiceCC) {
397
+ return false;
398
+ }
399
+ // S0: check command
400
+ if (cc instanceof SecurityCC) {
401
+ switch (cc.ccCommand) {
402
+ // Already encapsulated
403
+ case SecurityCommand.CommandEncapsulation:
404
+ case SecurityCommand.CommandEncapsulationNonceGet:
405
+ // Cannot be sent encapsulated:
406
+ case SecurityCommand.NonceGet:
407
+ case SecurityCommand.NonceReport:
408
+ case SecurityCommand.SchemeGet:
409
+ case SecurityCommand.SchemeReport:
410
+ return false;
411
+ default:
412
+ // All other commands must be encapsulated
413
+ return true;
414
+ }
323
415
  }
416
+ // Everything else needs to be encapsulated if the CC is secure
417
+ return true;
324
418
  }
325
- // We know for sure that the node is included securely
326
- if (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {
327
- node.setSecurityClass(SecurityClass.S0_Legacy, true);
328
- ctx.logNode(node.id, `The node was granted the S0 security class`);
419
+ /** Encapsulates a command that should be sent encrypted */
420
+ static encapsulate(ownNodeId, securityManager, cc) {
421
+ // TODO: When to return a SecurityCCCommandEncapsulationNonceGet?
422
+ const ret = new SecurityCCCommandEncapsulation({
423
+ nodeId: cc.nodeId,
424
+ encapsulated: cc,
425
+ });
426
+ // Copy the encapsulation flags from the encapsulated command
427
+ // but omit Security, since we're doing that right now
428
+ ret.encapsulationFlags = cc.encapsulationFlags
429
+ & ~EncapsulationFlags.Security;
430
+ return ret;
329
431
  }
330
- // Remember that the interview is complete
331
- this.setInterviewComplete(ctx, true);
332
- }
333
- /** Tests if a command should be sent secure and thus requires encapsulation */
334
- static requiresEncapsulation(cc) {
335
- // No security flag -> no encapsulation
336
- if (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {
337
- return false;
338
- }
339
- // S2, CRC16, Transport Service -> no S2 encapsulation
340
- if (cc instanceof Security2CC
341
- || cc instanceof CRC16CC
342
- || cc instanceof TransportServiceCC) {
343
- return false;
344
- }
345
- // S0: check command
346
- if (cc instanceof SecurityCC_1) {
347
- switch (cc.ccCommand) {
348
- // Already encapsulated
349
- case SecurityCommand.CommandEncapsulation:
350
- case SecurityCommand.CommandEncapsulationNonceGet:
351
- // Cannot be sent encapsulated:
352
- case SecurityCommand.NonceGet:
353
- case SecurityCommand.NonceReport:
354
- case SecurityCommand.SchemeGet:
355
- case SecurityCommand.SchemeReport:
356
- return false;
357
- default:
358
- // All other commands must be encapsulated
359
- return true;
432
+ };
433
+ return SecurityCC = _classThis;
434
+ })();
435
+ export { SecurityCC };
436
+ let SecurityCCNonceReport = (() => {
437
+ let _classDecorators = [CCCommand(SecurityCommand.NonceReport)];
438
+ let _classDescriptor;
439
+ let _classExtraInitializers = [];
440
+ let _classThis;
441
+ let _classSuper = SecurityCC;
442
+ var SecurityCCNonceReport = class extends _classSuper {
443
+ static { _classThis = this; }
444
+ static {
445
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
446
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
447
+ SecurityCCNonceReport = _classThis = _classDescriptor.value;
448
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
449
+ __runInitializers(_classThis, _classExtraInitializers);
450
+ }
451
+ constructor(options) {
452
+ super(options);
453
+ if (options.nonce.length !== HALF_NONCE_SIZE) {
454
+ throw new ZWaveError(`Nonce must have length ${HALF_NONCE_SIZE}!`, ZWaveErrorCodes.Argument_Invalid);
360
455
  }
456
+ this.nonce = options.nonce;
361
457
  }
362
- // Everything else needs to be encapsulated if the CC is secure
363
- return true;
364
- }
365
- /** Encapsulates a command that should be sent encrypted */
366
- static encapsulate(ownNodeId, securityManager, cc) {
367
- // TODO: When to return a SecurityCCCommandEncapsulationNonceGet?
368
- const ret = new SecurityCCCommandEncapsulation({
369
- nodeId: cc.nodeId,
370
- encapsulated: cc,
371
- });
372
- // Copy the encapsulation flags from the encapsulated command
373
- // but omit Security, since we're doing that right now
374
- ret.encapsulationFlags = cc.encapsulationFlags
375
- & ~EncapsulationFlags.Security;
376
- return ret;
377
- }
378
- };
379
- SecurityCC = SecurityCC_1 = __decorate([
380
- commandClass(CommandClasses.Security),
381
- implementedVersion(1)
382
- ], SecurityCC);
383
- export { SecurityCC };
384
- let SecurityCCNonceReport = SecurityCCNonceReport_1 = class SecurityCCNonceReport extends SecurityCC {
385
- constructor(options) {
386
- super(options);
387
- if (options.nonce.length !== HALF_NONCE_SIZE) {
388
- throw new ZWaveError(`Nonce must have length ${HALF_NONCE_SIZE}!`, ZWaveErrorCodes.Argument_Invalid);
458
+ static from(raw, ctx) {
459
+ validatePayload.withReason("Invalid nonce length")(raw.payload.length === HALF_NONCE_SIZE);
460
+ return new this({
461
+ nodeId: ctx.sourceNodeId,
462
+ nonce: raw.payload,
463
+ });
389
464
  }
390
- this.nonce = options.nonce;
391
- }
392
- static from(raw, ctx) {
393
- validatePayload.withReason("Invalid nonce length")(raw.payload.length === HALF_NONCE_SIZE);
394
- return new SecurityCCNonceReport_1({
395
- nodeId: ctx.sourceNodeId,
396
- nonce: raw.payload,
397
- });
398
- }
399
- nonce;
400
- serialize(ctx) {
401
- this.payload = Bytes.view(this.nonce);
402
- return super.serialize(ctx);
403
- }
404
- toLogEntry(ctx) {
405
- return {
406
- ...super.toLogEntry(ctx),
407
- message: { nonce: buffer2hex(this.nonce) },
408
- };
409
- }
410
- };
411
- SecurityCCNonceReport = SecurityCCNonceReport_1 = __decorate([
412
- CCCommand(SecurityCommand.NonceReport)
413
- ], SecurityCCNonceReport);
465
+ nonce;
466
+ serialize(ctx) {
467
+ this.payload = Bytes.view(this.nonce);
468
+ return super.serialize(ctx);
469
+ }
470
+ toLogEntry(ctx) {
471
+ return {
472
+ ...super.toLogEntry(ctx),
473
+ message: { nonce: buffer2hex(this.nonce) },
474
+ };
475
+ }
476
+ };
477
+ return SecurityCCNonceReport = _classThis;
478
+ })();
414
479
  export { SecurityCCNonceReport };
415
- let SecurityCCNonceGet = class SecurityCCNonceGet extends SecurityCC {
416
- };
417
- SecurityCCNonceGet = __decorate([
418
- CCCommand(SecurityCommand.NonceGet),
419
- expectedCCResponse(SecurityCCNonceReport)
420
- ], SecurityCCNonceGet);
480
+ let SecurityCCNonceGet = (() => {
481
+ let _classDecorators = [CCCommand(SecurityCommand.NonceGet), expectedCCResponse(SecurityCCNonceReport)];
482
+ let _classDescriptor;
483
+ let _classExtraInitializers = [];
484
+ let _classThis;
485
+ let _classSuper = SecurityCC;
486
+ var SecurityCCNonceGet = class extends _classSuper {
487
+ static { _classThis = this; }
488
+ static {
489
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
490
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
491
+ SecurityCCNonceGet = _classThis = _classDescriptor.value;
492
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
493
+ __runInitializers(_classThis, _classExtraInitializers);
494
+ }
495
+ };
496
+ return SecurityCCNonceGet = _classThis;
497
+ })();
421
498
  export { SecurityCCNonceGet };
422
499
  function getCCResponseForCommandEncapsulation(sent) {
423
500
  if (sent.encapsulated.expectsCCResponse()) {
424
501
  return SecurityCCCommandEncapsulation;
425
502
  }
426
503
  }
427
- let SecurityCCCommandEncapsulation = SecurityCCCommandEncapsulation_1 = class SecurityCCCommandEncapsulation extends SecurityCC {
428
- constructor(options) {
429
- super(options);
430
- if ("encapsulated" in options) {
431
- this.encapsulated = options.encapsulated;
432
- this.encapsulated.encapsulatingCC = this;
504
+ let SecurityCCCommandEncapsulation = (() => {
505
+ let _classDecorators = [CCCommand(SecurityCommand.CommandEncapsulation), expectedCCResponse(getCCResponseForCommandEncapsulation, () => "checkEncapsulated")];
506
+ let _classDescriptor;
507
+ let _classExtraInitializers = [];
508
+ let _classThis;
509
+ let _classSuper = SecurityCC;
510
+ var SecurityCCCommandEncapsulation = class extends _classSuper {
511
+ static { _classThis = this; }
512
+ static {
513
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
514
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
515
+ SecurityCCCommandEncapsulation = _classThis = _classDescriptor.value;
516
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
517
+ __runInitializers(_classThis, _classExtraInitializers);
433
518
  }
434
- else {
435
- this.decryptedCCBytes = options.decryptedCCBytes;
436
- this.sequenced = options.sequenced;
437
- this.secondFrame = options.secondFrame;
438
- this.sequenceCounter = options.sequenceCounter;
439
- }
440
- this.alternativeNetworkKey = options.alternativeNetworkKey;
441
- }
442
- static from(raw, ctx) {
443
- assertSecurityRX(ctx);
444
- // HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code
445
- validatePayload(raw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8);
446
- const iv = raw.payload.subarray(0, HALF_NONCE_SIZE);
447
- const encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);
448
- const nonceId = raw.payload.at(-9);
449
- const authCode = raw.payload.subarray(-8);
450
- // Retrieve the used nonce from the nonce store
451
- const nonce = ctx.securityManager.getNonce(nonceId);
452
- // Only accept the message if the nonce hasn't expired
453
- if (!nonce) {
454
- validatePayload.fail(`Nonce ${num2hex(nonceId)} expired, cannot decode security encapsulated command.`);
455
- }
456
- // and mark the nonce as used
457
- ctx.securityManager.deleteNonce(nonceId);
458
- // Validate the encrypted data
459
- const authData = getAuthenticationData(iv, nonce, SecurityCommand.CommandEncapsulation, ctx.sourceNodeId, ctx.ownNodeId, encryptedPayload);
460
- const expectedAuthCode = computeMAC(authData, ctx.securityManager.authKey);
461
- // Only accept messages with a correct auth code
462
- validatePayload.withReason("Invalid auth code, won't accept security encapsulated command.")(authCode.equals(expectedAuthCode));
463
- // Decrypt the encapsulated CC
464
- const frameControlAndDecryptedCC = decryptAES128OFB(encryptedPayload, ctx.securityManager.encryptionKey, Bytes.concat([iv, nonce]));
465
- const frameControl = frameControlAndDecryptedCC[0];
466
- const sequenceCounter = frameControl & 0b1111;
467
- const sequenced = !!(frameControl & 0b1_0000);
468
- const secondFrame = !!(frameControl & 0b10_0000);
469
- const decryptedCCBytes = frameControlAndDecryptedCC
470
- .subarray(1);
471
- const ret = new SecurityCCCommandEncapsulation_1({
472
- nodeId: ctx.sourceNodeId,
473
- sequenceCounter,
474
- sequenced,
475
- secondFrame,
476
- decryptedCCBytes,
477
- });
478
- ret.authData = authData;
479
- ret.authCode = authCode;
480
- ret.iv = iv;
481
- return ret;
482
- }
483
- sequenced;
484
- secondFrame;
485
- sequenceCounter;
486
- decryptedCCBytes;
487
- encapsulated;
488
- alternativeNetworkKey;
489
- get nonceId() {
490
- return this.nonce?.[0];
491
- }
492
- nonce;
493
- // Only used testing/for debugging purposes
494
- iv;
495
- authData;
496
- authCode;
497
- ciphertext;
498
- getPartialCCSessionId() {
499
- if (this.sequenced) {
500
- return {
501
- // Treat Encapsulation and EncapsulationNonceGet as one
502
- ccCommand: undefined,
503
- sequence: this.sequenceCounter,
504
- };
519
+ constructor(options) {
520
+ super(options);
521
+ if ("encapsulated" in options) {
522
+ this.encapsulated = options.encapsulated;
523
+ this.encapsulated.encapsulatingCC = this;
524
+ }
525
+ else {
526
+ this.decryptedCCBytes = options.decryptedCCBytes;
527
+ this.sequenced = options.sequenced;
528
+ this.secondFrame = options.secondFrame;
529
+ this.sequenceCounter = options.sequenceCounter;
530
+ }
531
+ this.alternativeNetworkKey = options.alternativeNetworkKey;
505
532
  }
506
- else {
507
- return {
508
- // Treat Encapsulation and EncapsulationNonceGet as one
509
- ccCommand: undefined,
510
- };
533
+ static from(raw, ctx) {
534
+ assertSecurityRX(ctx);
535
+ // HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code
536
+ validatePayload(raw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8);
537
+ const iv = raw.payload.subarray(0, HALF_NONCE_SIZE);
538
+ const encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);
539
+ const nonceId = raw.payload.at(-9);
540
+ const authCode = raw.payload.subarray(-8);
541
+ // Retrieve the used nonce from the nonce store
542
+ const nonce = ctx.securityManager.getNonce(nonceId);
543
+ // Only accept the message if the nonce hasn't expired
544
+ if (!nonce) {
545
+ validatePayload.fail(`Nonce ${num2hex(nonceId)} expired, cannot decode security encapsulated command.`);
546
+ }
547
+ // and mark the nonce as used
548
+ ctx.securityManager.deleteNonce(nonceId);
549
+ // Validate the encrypted data
550
+ const authData = getAuthenticationData(iv, nonce, SecurityCommand.CommandEncapsulation, ctx.sourceNodeId, ctx.ownNodeId, encryptedPayload);
551
+ const expectedAuthCode = computeMAC(authData, ctx.securityManager.authKey);
552
+ // Only accept messages with a correct auth code
553
+ validatePayload.withReason("Invalid auth code, won't accept security encapsulated command.")(authCode.equals(expectedAuthCode));
554
+ // Decrypt the encapsulated CC
555
+ const frameControlAndDecryptedCC = decryptAES128OFB(encryptedPayload, ctx.securityManager.encryptionKey, Bytes.concat([iv, nonce]));
556
+ const frameControl = frameControlAndDecryptedCC[0];
557
+ const sequenceCounter = frameControl & 0b1111;
558
+ const sequenced = !!(frameControl & 0b1_0000);
559
+ const secondFrame = !!(frameControl & 0b10_0000);
560
+ const decryptedCCBytes = frameControlAndDecryptedCC
561
+ .subarray(1);
562
+ const ret = new SecurityCCCommandEncapsulation({
563
+ nodeId: ctx.sourceNodeId,
564
+ sequenceCounter,
565
+ sequenced,
566
+ secondFrame,
567
+ decryptedCCBytes,
568
+ });
569
+ ret.authData = authData;
570
+ ret.authCode = authCode;
571
+ ret.iv = iv;
572
+ return ret;
511
573
  }
512
- }
513
- expectMoreMessages() {
514
- return !!this.sequenced && !this.secondFrame;
515
- }
516
- mergePartialCCs(partials, ctx) {
517
- // Concat the CC buffers
518
- this.decryptedCCBytes = Bytes.concat([...partials, this].map((cc) => cc.decryptedCCBytes));
519
- // make sure this contains a complete CC command that's worth splitting
520
- validatePayload(this.decryptedCCBytes.length >= 2);
521
- // and deserialize the CC
522
- this.encapsulated = CommandClass.parse(this.decryptedCCBytes, ctx);
523
- this.encapsulated.encapsulatingCC = this;
524
- }
525
- serialize(ctx) {
526
- if (!this.nonce)
527
- throwNoNonce();
528
- if (this.nonce.length !== HALF_NONCE_SIZE) {
529
- throwNoNonce("Invalid nonce size");
530
- }
531
- assertSecurityTX(ctx);
532
- let authKey;
533
- let encryptionKey;
534
- if (this.alternativeNetworkKey) {
535
- authKey = generateAuthKey(this.alternativeNetworkKey);
536
- encryptionKey = generateEncryptionKey(this.alternativeNetworkKey);
537
- }
538
- else {
539
- authKey = ctx.securityManager.authKey;
540
- encryptionKey = ctx.securityManager.encryptionKey;
541
- }
542
- const serializedCC = this.encapsulated.serialize(ctx);
543
- const plaintext = Bytes.concat([
544
- Bytes.from([0]), // TODO: frame control
545
- serializedCC,
546
- ]);
547
- // Encrypt the payload
548
- const senderNonce = randomBytes(HALF_NONCE_SIZE);
549
- const iv = Bytes.concat([senderNonce, this.nonce]);
550
- const ciphertext = encryptAES128OFB(plaintext, encryptionKey, iv);
551
- // And generate the auth code
552
- const authData = getAuthenticationData(senderNonce, this.nonce, this.ccCommand, ctx.ownNodeId, this.nodeId, ciphertext);
553
- const authCode = computeMAC(authData, authKey);
554
- // Remember for debugging purposes
555
- this.iv = iv;
556
- this.authData = authData;
557
- this.authCode = authCode;
558
- this.ciphertext = ciphertext;
559
- this.payload = Bytes.concat([
560
- senderNonce,
561
- ciphertext,
562
- Bytes.from([this.nonceId]),
563
- authCode,
564
- ]);
565
- return super.serialize(ctx);
566
- }
567
- computeEncapsulationOverhead() {
568
- // Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC
569
- return super.computeEncapsulationOverhead() + 18;
570
- }
571
- toLogEntry(ctx) {
572
- const message = {};
573
- if (this.nonceId != undefined) {
574
- message["nonce id"] = this.nonceId;
574
+ sequenced;
575
+ secondFrame;
576
+ sequenceCounter;
577
+ decryptedCCBytes;
578
+ encapsulated;
579
+ alternativeNetworkKey;
580
+ get nonceId() {
581
+ return this.nonce?.[0];
575
582
  }
576
- if (this.sequenced != undefined) {
577
- message.sequenced = this.sequenced;
583
+ nonce;
584
+ // Only used testing/for debugging purposes
585
+ iv;
586
+ authData;
587
+ authCode;
588
+ ciphertext;
589
+ getPartialCCSessionId() {
578
590
  if (this.sequenced) {
579
- if (this.secondFrame != undefined) {
580
- message["second frame"] = this.secondFrame;
581
- }
582
- if (this.sequenceCounter != undefined) {
583
- message["sequence counter"] = this.sequenceCounter;
584
- }
591
+ return {
592
+ // Treat Encapsulation and EncapsulationNonceGet as one
593
+ ccCommand: undefined,
594
+ sequence: this.sequenceCounter,
595
+ };
585
596
  }
597
+ else {
598
+ return {
599
+ // Treat Encapsulation and EncapsulationNonceGet as one
600
+ ccCommand: undefined,
601
+ };
602
+ }
603
+ }
604
+ expectMoreMessages() {
605
+ return !!this.sequenced && !this.secondFrame;
606
+ }
607
+ mergePartialCCs(partials, ctx) {
608
+ // Concat the CC buffers
609
+ this.decryptedCCBytes = Bytes.concat([...partials, this].map((cc) => cc.decryptedCCBytes));
610
+ // make sure this contains a complete CC command that's worth splitting
611
+ validatePayload(this.decryptedCCBytes.length >= 2);
612
+ // and deserialize the CC
613
+ this.encapsulated = CommandClass.parse(this.decryptedCCBytes, ctx);
614
+ this.encapsulated.encapsulatingCC = this;
586
615
  }
587
- // Log the plaintext in integration tests and development mode
588
- if (process.env.NODE_ENV === "test"
589
- || process.env.NODE_ENV === "development") {
590
- if (this.iv) {
591
- message.IV = buffer2hex(this.iv);
616
+ serialize(ctx) {
617
+ if (!this.nonce)
618
+ throwNoNonce();
619
+ if (this.nonce.length !== HALF_NONCE_SIZE) {
620
+ throwNoNonce("Invalid nonce size");
592
621
  }
593
- if (this.ciphertext) {
594
- message.ciphertext = buffer2hex(this.ciphertext);
622
+ assertSecurityTX(ctx);
623
+ let authKey;
624
+ let encryptionKey;
625
+ if (this.alternativeNetworkKey) {
626
+ authKey = generateAuthKey(this.alternativeNetworkKey);
627
+ encryptionKey = generateEncryptionKey(this.alternativeNetworkKey);
595
628
  }
596
- else if (this.decryptedCCBytes) {
597
- message.plaintext = buffer2hex(this.decryptedCCBytes);
629
+ else {
630
+ authKey = ctx.securityManager.authKey;
631
+ encryptionKey = ctx.securityManager.encryptionKey;
632
+ }
633
+ const serializedCC = this.encapsulated.serialize(ctx);
634
+ const plaintext = Bytes.concat([
635
+ Bytes.from([0]), // TODO: frame control
636
+ serializedCC,
637
+ ]);
638
+ // Encrypt the payload
639
+ const senderNonce = randomBytes(HALF_NONCE_SIZE);
640
+ const iv = Bytes.concat([senderNonce, this.nonce]);
641
+ const ciphertext = encryptAES128OFB(plaintext, encryptionKey, iv);
642
+ // And generate the auth code
643
+ const authData = getAuthenticationData(senderNonce, this.nonce, this.ccCommand, ctx.ownNodeId, this.nodeId, ciphertext);
644
+ const authCode = computeMAC(authData, authKey);
645
+ // Remember for debugging purposes
646
+ this.iv = iv;
647
+ this.authData = authData;
648
+ this.authCode = authCode;
649
+ this.ciphertext = ciphertext;
650
+ this.payload = Bytes.concat([
651
+ senderNonce,
652
+ ciphertext,
653
+ Bytes.from([this.nonceId]),
654
+ authCode,
655
+ ]);
656
+ return super.serialize(ctx);
657
+ }
658
+ computeEncapsulationOverhead() {
659
+ // Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC
660
+ return super.computeEncapsulationOverhead() + 18;
661
+ }
662
+ toLogEntry(ctx) {
663
+ const message = {};
664
+ if (this.nonceId != undefined) {
665
+ message["nonce id"] = this.nonceId;
598
666
  }
599
- if (this.authData) {
600
- message["auth data"] = buffer2hex(this.authData);
667
+ if (this.sequenced != undefined) {
668
+ message.sequenced = this.sequenced;
669
+ if (this.sequenced) {
670
+ if (this.secondFrame != undefined) {
671
+ message["second frame"] = this.secondFrame;
672
+ }
673
+ if (this.sequenceCounter != undefined) {
674
+ message["sequence counter"] = this.sequenceCounter;
675
+ }
676
+ }
601
677
  }
602
- if (this.authCode) {
603
- message["auth code"] = buffer2hex(this.authCode);
678
+ // Log the plaintext in integration tests and development mode
679
+ if (process.env.NODE_ENV === "test"
680
+ || process.env.NODE_ENV === "development") {
681
+ if (this.iv) {
682
+ message.IV = buffer2hex(this.iv);
683
+ }
684
+ if (this.ciphertext) {
685
+ message.ciphertext = buffer2hex(this.ciphertext);
686
+ }
687
+ else if (this.decryptedCCBytes) {
688
+ message.plaintext = buffer2hex(this.decryptedCCBytes);
689
+ }
690
+ if (this.authData) {
691
+ message["auth data"] = buffer2hex(this.authData);
692
+ }
693
+ if (this.authCode) {
694
+ message["auth code"] = buffer2hex(this.authCode);
695
+ }
604
696
  }
697
+ return {
698
+ ...super.toLogEntry(ctx),
699
+ message,
700
+ };
605
701
  }
606
- return {
607
- ...super.toLogEntry(ctx),
608
- message,
609
- };
610
- }
611
- };
612
- SecurityCCCommandEncapsulation = SecurityCCCommandEncapsulation_1 = __decorate([
613
- CCCommand(SecurityCommand.CommandEncapsulation),
614
- expectedCCResponse(getCCResponseForCommandEncapsulation, () => "checkEncapsulated")
615
- ], SecurityCCCommandEncapsulation);
702
+ };
703
+ return SecurityCCCommandEncapsulation = _classThis;
704
+ })();
616
705
  export { SecurityCCCommandEncapsulation };
617
706
  // This is the same message, but with another CC command
618
- let SecurityCCCommandEncapsulationNonceGet = class SecurityCCCommandEncapsulationNonceGet extends SecurityCCCommandEncapsulation {
619
- };
620
- SecurityCCCommandEncapsulationNonceGet = __decorate([
621
- CCCommand(SecurityCommand.CommandEncapsulationNonceGet)
622
- ], SecurityCCCommandEncapsulationNonceGet);
707
+ let SecurityCCCommandEncapsulationNonceGet = (() => {
708
+ let _classDecorators = [CCCommand(SecurityCommand.CommandEncapsulationNonceGet)];
709
+ let _classDescriptor;
710
+ let _classExtraInitializers = [];
711
+ let _classThis;
712
+ let _classSuper = SecurityCCCommandEncapsulation;
713
+ var SecurityCCCommandEncapsulationNonceGet = class extends _classSuper {
714
+ static { _classThis = this; }
715
+ static {
716
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
717
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
718
+ SecurityCCCommandEncapsulationNonceGet = _classThis = _classDescriptor.value;
719
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
720
+ __runInitializers(_classThis, _classExtraInitializers);
721
+ }
722
+ };
723
+ return SecurityCCCommandEncapsulationNonceGet = _classThis;
724
+ })();
623
725
  export { SecurityCCCommandEncapsulationNonceGet };
624
- let SecurityCCSchemeReport = SecurityCCSchemeReport_1 = class SecurityCCSchemeReport extends SecurityCC {
625
- static from(raw, ctx) {
626
- validatePayload(raw.payload.length >= 1);
627
- // The including controller MUST NOT perform any validation of the Supported Security Schemes byte
628
- return new SecurityCCSchemeReport_1({
629
- nodeId: ctx.sourceNodeId,
630
- });
631
- }
632
- serialize(ctx) {
633
- // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)
634
- this.payload = Bytes.from([0]);
635
- return super.serialize(ctx);
636
- }
637
- toLogEntry(ctx) {
638
- return {
639
- ...super.toLogEntry(ctx),
640
- // Hide the default payload line
641
- message: undefined,
642
- };
643
- }
644
- };
645
- SecurityCCSchemeReport = SecurityCCSchemeReport_1 = __decorate([
646
- CCCommand(SecurityCommand.SchemeReport)
647
- ], SecurityCCSchemeReport);
726
+ let SecurityCCSchemeReport = (() => {
727
+ let _classDecorators = [CCCommand(SecurityCommand.SchemeReport)];
728
+ let _classDescriptor;
729
+ let _classExtraInitializers = [];
730
+ let _classThis;
731
+ let _classSuper = SecurityCC;
732
+ var SecurityCCSchemeReport = class extends _classSuper {
733
+ static { _classThis = this; }
734
+ static {
735
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
736
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
737
+ SecurityCCSchemeReport = _classThis = _classDescriptor.value;
738
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
739
+ __runInitializers(_classThis, _classExtraInitializers);
740
+ }
741
+ static from(raw, ctx) {
742
+ validatePayload(raw.payload.length >= 1);
743
+ // The including controller MUST NOT perform any validation of the Supported Security Schemes byte
744
+ return new this({
745
+ nodeId: ctx.sourceNodeId,
746
+ });
747
+ }
748
+ serialize(ctx) {
749
+ // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)
750
+ this.payload = Bytes.from([0]);
751
+ return super.serialize(ctx);
752
+ }
753
+ toLogEntry(ctx) {
754
+ return {
755
+ ...super.toLogEntry(ctx),
756
+ // Hide the default payload line
757
+ message: undefined,
758
+ };
759
+ }
760
+ };
761
+ return SecurityCCSchemeReport = _classThis;
762
+ })();
648
763
  export { SecurityCCSchemeReport };
649
- let SecurityCCSchemeGet = class SecurityCCSchemeGet extends SecurityCC {
650
- serialize(ctx) {
651
- // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)
652
- this.payload = Bytes.from([0]);
653
- return super.serialize(ctx);
654
- }
655
- toLogEntry(ctx) {
656
- return {
657
- ...super.toLogEntry(ctx),
658
- // Hide the default payload line
659
- message: undefined,
660
- };
661
- }
662
- };
663
- SecurityCCSchemeGet = __decorate([
664
- CCCommand(SecurityCommand.SchemeGet),
665
- expectedCCResponse(SecurityCCSchemeReport)
666
- ], SecurityCCSchemeGet);
764
+ let SecurityCCSchemeGet = (() => {
765
+ let _classDecorators = [CCCommand(SecurityCommand.SchemeGet), expectedCCResponse(SecurityCCSchemeReport)];
766
+ let _classDescriptor;
767
+ let _classExtraInitializers = [];
768
+ let _classThis;
769
+ let _classSuper = SecurityCC;
770
+ var SecurityCCSchemeGet = class extends _classSuper {
771
+ static { _classThis = this; }
772
+ static {
773
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
774
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
775
+ SecurityCCSchemeGet = _classThis = _classDescriptor.value;
776
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
777
+ __runInitializers(_classThis, _classExtraInitializers);
778
+ }
779
+ serialize(ctx) {
780
+ // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)
781
+ this.payload = Bytes.from([0]);
782
+ return super.serialize(ctx);
783
+ }
784
+ toLogEntry(ctx) {
785
+ return {
786
+ ...super.toLogEntry(ctx),
787
+ // Hide the default payload line
788
+ message: undefined,
789
+ };
790
+ }
791
+ };
792
+ return SecurityCCSchemeGet = _classThis;
793
+ })();
667
794
  export { SecurityCCSchemeGet };
668
- let SecurityCCSchemeInherit = class SecurityCCSchemeInherit extends SecurityCC {
669
- serialize(ctx) {
670
- // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)
671
- this.payload = Bytes.from([0]);
672
- return super.serialize(ctx);
673
- }
674
- toLogEntry(ctx) {
675
- return {
676
- ...super.toLogEntry(ctx),
677
- // Hide the default payload line
678
- message: undefined,
679
- };
680
- }
681
- };
682
- SecurityCCSchemeInherit = __decorate([
683
- CCCommand(SecurityCommand.SchemeInherit),
684
- expectedCCResponse(SecurityCCSchemeReport)
685
- ], SecurityCCSchemeInherit);
795
+ let SecurityCCSchemeInherit = (() => {
796
+ let _classDecorators = [CCCommand(SecurityCommand.SchemeInherit), expectedCCResponse(SecurityCCSchemeReport)];
797
+ let _classDescriptor;
798
+ let _classExtraInitializers = [];
799
+ let _classThis;
800
+ let _classSuper = SecurityCC;
801
+ var SecurityCCSchemeInherit = class extends _classSuper {
802
+ static { _classThis = this; }
803
+ static {
804
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
805
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
806
+ SecurityCCSchemeInherit = _classThis = _classDescriptor.value;
807
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
808
+ __runInitializers(_classThis, _classExtraInitializers);
809
+ }
810
+ serialize(ctx) {
811
+ // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)
812
+ this.payload = Bytes.from([0]);
813
+ return super.serialize(ctx);
814
+ }
815
+ toLogEntry(ctx) {
816
+ return {
817
+ ...super.toLogEntry(ctx),
818
+ // Hide the default payload line
819
+ message: undefined,
820
+ };
821
+ }
822
+ };
823
+ return SecurityCCSchemeInherit = _classThis;
824
+ })();
686
825
  export { SecurityCCSchemeInherit };
687
- let SecurityCCNetworkKeyVerify = class SecurityCCNetworkKeyVerify extends SecurityCC {
688
- };
689
- SecurityCCNetworkKeyVerify = __decorate([
690
- CCCommand(SecurityCommand.NetworkKeyVerify)
691
- ], SecurityCCNetworkKeyVerify);
826
+ let SecurityCCNetworkKeyVerify = (() => {
827
+ let _classDecorators = [CCCommand(SecurityCommand.NetworkKeyVerify)];
828
+ let _classDescriptor;
829
+ let _classExtraInitializers = [];
830
+ let _classThis;
831
+ let _classSuper = SecurityCC;
832
+ var SecurityCCNetworkKeyVerify = class extends _classSuper {
833
+ static { _classThis = this; }
834
+ static {
835
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
836
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
837
+ SecurityCCNetworkKeyVerify = _classThis = _classDescriptor.value;
838
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
839
+ __runInitializers(_classThis, _classExtraInitializers);
840
+ }
841
+ };
842
+ return SecurityCCNetworkKeyVerify = _classThis;
843
+ })();
692
844
  export { SecurityCCNetworkKeyVerify };
693
- let SecurityCCNetworkKeySet = SecurityCCNetworkKeySet_1 = class SecurityCCNetworkKeySet extends SecurityCC {
694
- constructor(options) {
695
- super(options);
696
- if (options.networkKey.length !== 16) {
697
- throw new ZWaveError(`The network key must have length 16!`, ZWaveErrorCodes.Argument_Invalid);
845
+ let SecurityCCNetworkKeySet = (() => {
846
+ let _classDecorators = [CCCommand(SecurityCommand.NetworkKeySet), expectedCCResponse(SecurityCCNetworkKeyVerify)];
847
+ let _classDescriptor;
848
+ let _classExtraInitializers = [];
849
+ let _classThis;
850
+ let _classSuper = SecurityCC;
851
+ var SecurityCCNetworkKeySet = class extends _classSuper {
852
+ static { _classThis = this; }
853
+ static {
854
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
855
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
856
+ SecurityCCNetworkKeySet = _classThis = _classDescriptor.value;
857
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
858
+ __runInitializers(_classThis, _classExtraInitializers);
698
859
  }
699
- this.networkKey = options.networkKey;
700
- }
701
- static from(raw, ctx) {
702
- validatePayload(raw.payload.length >= 16);
703
- const networkKey = raw.payload.subarray(0, 16);
704
- return new SecurityCCNetworkKeySet_1({
705
- nodeId: ctx.sourceNodeId,
706
- networkKey,
707
- });
708
- }
709
- networkKey;
710
- serialize(ctx) {
711
- this.payload = Bytes.view(this.networkKey);
712
- return super.serialize(ctx);
713
- }
714
- toLogEntry(ctx) {
715
- // The network key shouldn't be logged, so users can safely post their logs online
716
- const { message, ...log } = super.toLogEntry(ctx);
717
- return log;
718
- }
719
- };
720
- SecurityCCNetworkKeySet = SecurityCCNetworkKeySet_1 = __decorate([
721
- CCCommand(SecurityCommand.NetworkKeySet),
722
- expectedCCResponse(SecurityCCNetworkKeyVerify)
723
- ], SecurityCCNetworkKeySet);
860
+ constructor(options) {
861
+ super(options);
862
+ if (options.networkKey.length !== 16) {
863
+ throw new ZWaveError(`The network key must have length 16!`, ZWaveErrorCodes.Argument_Invalid);
864
+ }
865
+ this.networkKey = options.networkKey;
866
+ }
867
+ static from(raw, ctx) {
868
+ validatePayload(raw.payload.length >= 16);
869
+ const networkKey = raw.payload.subarray(0, 16);
870
+ return new this({
871
+ nodeId: ctx.sourceNodeId,
872
+ networkKey,
873
+ });
874
+ }
875
+ networkKey;
876
+ serialize(ctx) {
877
+ this.payload = Bytes.view(this.networkKey);
878
+ return super.serialize(ctx);
879
+ }
880
+ toLogEntry(ctx) {
881
+ // The network key shouldn't be logged, so users can safely post their logs online
882
+ const { message, ...log } = super.toLogEntry(ctx);
883
+ return log;
884
+ }
885
+ };
886
+ return SecurityCCNetworkKeySet = _classThis;
887
+ })();
724
888
  export { SecurityCCNetworkKeySet };
725
- let SecurityCCCommandsSupportedReport = SecurityCCCommandsSupportedReport_1 = class SecurityCCCommandsSupportedReport extends SecurityCC {
726
- constructor(options) {
727
- super(options);
728
- this.supportedCCs = options.supportedCCs;
729
- this.controlledCCs = options.controlledCCs;
730
- // TODO: properly split the CCs into multiple reports
731
- this.reportsToFollow = options.reportsToFollow ?? 0;
732
- }
733
- static from(raw, ctx) {
734
- validatePayload(raw.payload.length >= 1);
735
- const reportsToFollow = raw.payload[0];
736
- const list = parseCCList(raw.payload.subarray(1));
737
- const supportedCCs = list.supportedCCs;
738
- const controlledCCs = list.controlledCCs;
739
- return new SecurityCCCommandsSupportedReport_1({
740
- nodeId: ctx.sourceNodeId,
741
- reportsToFollow,
742
- supportedCCs,
743
- controlledCCs,
744
- });
745
- }
746
- reportsToFollow;
747
- supportedCCs;
748
- controlledCCs;
749
- getPartialCCSessionId() {
750
- // Nothing special we can distinguish sessions with
751
- return {};
752
- }
753
- expectMoreMessages() {
754
- return this.reportsToFollow > 0;
755
- }
756
- mergePartialCCs(partials) {
757
- // Concat the lists of CCs
758
- this.supportedCCs = [...partials, this]
759
- .map((report) => report.supportedCCs)
760
- .reduce((prev, cur) => prev.concat(...cur), []);
761
- this.controlledCCs = [...partials, this]
762
- .map((report) => report.controlledCCs)
763
- .reduce((prev, cur) => prev.concat(...cur), []);
764
- }
765
- serialize(ctx) {
766
- this.payload = Bytes.concat([
767
- Bytes.from([this.reportsToFollow]),
768
- encodeCCList(this.supportedCCs, this.controlledCCs),
769
- ]);
770
- return super.serialize(ctx);
771
- }
772
- toLogEntry(ctx) {
773
- return {
774
- ...super.toLogEntry(ctx),
775
- message: {
776
- reportsToFollow: this.reportsToFollow,
777
- supportedCCs: this.supportedCCs
778
- .map((cc) => getCCName(cc))
779
- .map((cc) => `\n· ${cc}`)
780
- .join(""),
781
- controlledCCs: this.controlledCCs
782
- .map((cc) => getCCName(cc))
783
- .map((cc) => `\n· ${cc}`)
784
- .join(""),
785
- },
786
- };
787
- }
788
- };
789
- SecurityCCCommandsSupportedReport = SecurityCCCommandsSupportedReport_1 = __decorate([
790
- CCCommand(SecurityCommand.CommandsSupportedReport)
791
- ], SecurityCCCommandsSupportedReport);
889
+ let SecurityCCCommandsSupportedReport = (() => {
890
+ let _classDecorators = [CCCommand(SecurityCommand.CommandsSupportedReport)];
891
+ let _classDescriptor;
892
+ let _classExtraInitializers = [];
893
+ let _classThis;
894
+ let _classSuper = SecurityCC;
895
+ var SecurityCCCommandsSupportedReport = class extends _classSuper {
896
+ static { _classThis = this; }
897
+ static {
898
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
899
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
900
+ SecurityCCCommandsSupportedReport = _classThis = _classDescriptor.value;
901
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
902
+ __runInitializers(_classThis, _classExtraInitializers);
903
+ }
904
+ constructor(options) {
905
+ super(options);
906
+ this.supportedCCs = options.supportedCCs;
907
+ this.controlledCCs = options.controlledCCs;
908
+ // TODO: properly split the CCs into multiple reports
909
+ this.reportsToFollow = options.reportsToFollow ?? 0;
910
+ }
911
+ static from(raw, ctx) {
912
+ validatePayload(raw.payload.length >= 1);
913
+ const reportsToFollow = raw.payload[0];
914
+ const list = parseCCList(raw.payload.subarray(1));
915
+ const supportedCCs = list.supportedCCs;
916
+ const controlledCCs = list.controlledCCs;
917
+ return new this({
918
+ nodeId: ctx.sourceNodeId,
919
+ reportsToFollow,
920
+ supportedCCs,
921
+ controlledCCs,
922
+ });
923
+ }
924
+ reportsToFollow;
925
+ supportedCCs;
926
+ controlledCCs;
927
+ getPartialCCSessionId() {
928
+ // Nothing special we can distinguish sessions with
929
+ return {};
930
+ }
931
+ expectMoreMessages() {
932
+ return this.reportsToFollow > 0;
933
+ }
934
+ mergePartialCCs(partials) {
935
+ // Concat the lists of CCs
936
+ this.supportedCCs = [...partials, this]
937
+ .map((report) => report.supportedCCs)
938
+ .reduce((prev, cur) => prev.concat(...cur), []);
939
+ this.controlledCCs = [...partials, this]
940
+ .map((report) => report.controlledCCs)
941
+ .reduce((prev, cur) => prev.concat(...cur), []);
942
+ }
943
+ serialize(ctx) {
944
+ this.payload = Bytes.concat([
945
+ Bytes.from([this.reportsToFollow]),
946
+ encodeCCList(this.supportedCCs, this.controlledCCs),
947
+ ]);
948
+ return super.serialize(ctx);
949
+ }
950
+ toLogEntry(ctx) {
951
+ return {
952
+ ...super.toLogEntry(ctx),
953
+ message: {
954
+ reportsToFollow: this.reportsToFollow,
955
+ supportedCCs: this.supportedCCs
956
+ .map((cc) => getCCName(cc))
957
+ .map((cc) => `\n· ${cc}`)
958
+ .join(""),
959
+ controlledCCs: this.controlledCCs
960
+ .map((cc) => getCCName(cc))
961
+ .map((cc) => `\n· ${cc}`)
962
+ .join(""),
963
+ },
964
+ };
965
+ }
966
+ };
967
+ return SecurityCCCommandsSupportedReport = _classThis;
968
+ })();
792
969
  export { SecurityCCCommandsSupportedReport };
793
- let SecurityCCCommandsSupportedGet = class SecurityCCCommandsSupportedGet extends SecurityCC {
794
- };
795
- SecurityCCCommandsSupportedGet = __decorate([
796
- CCCommand(SecurityCommand.CommandsSupportedGet),
797
- expectedCCResponse(SecurityCCCommandsSupportedReport)
798
- ], SecurityCCCommandsSupportedGet);
970
+ let SecurityCCCommandsSupportedGet = (() => {
971
+ let _classDecorators = [CCCommand(SecurityCommand.CommandsSupportedGet), expectedCCResponse(SecurityCCCommandsSupportedReport)];
972
+ let _classDescriptor;
973
+ let _classExtraInitializers = [];
974
+ let _classThis;
975
+ let _classSuper = SecurityCC;
976
+ var SecurityCCCommandsSupportedGet = class extends _classSuper {
977
+ static { _classThis = this; }
978
+ static {
979
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
980
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
981
+ SecurityCCCommandsSupportedGet = _classThis = _classDescriptor.value;
982
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
983
+ __runInitializers(_classThis, _classExtraInitializers);
984
+ }
985
+ };
986
+ return SecurityCCCommandsSupportedGet = _classThis;
987
+ })();
799
988
  export { SecurityCCCommandsSupportedGet };
800
989
  //# sourceMappingURL=SecurityCC.js.map