@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
@@ -52,13 +52,45 @@ var import_CRC16CC = require("./CRC16CC.js");
52
52
  var import_MultiChannelCC = require("./MultiChannelCC.js");
53
53
  var import_SecurityCC = require("./SecurityCC.js");
54
54
  var import_TransportServiceCC = require("./TransportServiceCC.js");
55
- var __decorate = function(decorators, target, key, desc) {
56
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
57
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
58
- 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;
59
- return c > 3 && r && Object.defineProperty(target, key, r), r;
55
+ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
56
+ function accept(f) {
57
+ if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
58
+ return f;
59
+ }
60
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
61
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
62
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
63
+ var _, done = false;
64
+ for (var i = decorators.length - 1; i >= 0; i--) {
65
+ var context = {};
66
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
67
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
68
+ context.addInitializer = function(f) {
69
+ if (done) throw new TypeError("Cannot add initializers after decoration has completed");
70
+ extraInitializers.push(accept(f || null));
71
+ };
72
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
73
+ if (kind === "accessor") {
74
+ if (result === void 0) continue;
75
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
76
+ if (_ = accept(result.get)) descriptor.get = _;
77
+ if (_ = accept(result.set)) descriptor.set = _;
78
+ if (_ = accept(result.init)) initializers.unshift(_);
79
+ } else if (_ = accept(result)) {
80
+ if (kind === "field") initializers.unshift(_);
81
+ else descriptor[key] = _;
82
+ }
83
+ }
84
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
85
+ done = true;
86
+ };
87
+ var __runInitializers = function(thisArg, initializers, value) {
88
+ var useValue = arguments.length > 2;
89
+ for (var i = 0; i < initializers.length; i++) {
90
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
91
+ }
92
+ return useValue ? value : void 0;
60
93
  };
61
- var Security2CC_1, Security2CCMessageEncapsulation_1, Security2CCNonceReport_1, Security2CCNonceGet_1, Security2CCKEXReport_1, Security2CCKEXSet_1, Security2CCKEXFail_1, Security2CCPublicKeyReport_1, Security2CCNetworkKeyReport_1, Security2CCNetworkKeyGet_1, Security2CCTransferEnd_1, Security2CCCommandsSupportedReport_1;
62
94
  function securityClassToBitMask(key) {
63
95
  return (0, import_core.encodeBitMask)([key], import_core.SecurityClass.S0_Legacy, import_core.SecurityClass.S2_Unauthenticated);
64
96
  }
@@ -229,487 +261,516 @@ function getSenderEI(extensions) {
229
261
  const spanExtension = extensions.find((e) => e instanceof import_Extension.SPANExtension);
230
262
  return spanExtension?.senderEI;
231
263
  }
232
- let Security2CCAPI = class Security2CCAPI2 extends import_API.CCAPI {
233
- supportsCommand(_cmd) {
234
- return true;
235
- }
236
- /**
237
- * Sends a nonce to the node, either in response to a NonceGet request or a message that failed to decrypt. The message is sent without any retransmission etc.
238
- * The return value indicates whether a nonce was successfully sent
239
- */
240
- async sendNonce() {
241
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NonceReport);
242
- this.assertPhysicalEndpoint(this.endpoint);
243
- const securityManager = getSecurityManager(this.host.ownNodeId, this.host, this.endpoint.nodeId);
244
- if (!securityManager) {
245
- throw new import_core.ZWaveError(`Nonces can only be sent if secure communication is set up!`, import_core.ZWaveErrorCodes.Driver_NoSecurity);
246
- }
247
- const receiverEI = securityManager.generateNonce(this.endpoint.nodeId);
248
- const cc = new Security2CCNonceReport({
249
- nodeId: this.endpoint.nodeId,
250
- endpointIndex: this.endpoint.index,
251
- SOS: true,
252
- MOS: false,
253
- receiverEI
254
- });
255
- try {
256
- await this.host.sendCommand(cc, {
257
- ...this.commandOptions,
258
- // Seems we need these options or some nodes won't accept the nonce
259
- transmitOptions: import_core.TransmitOptions.ACK | import_core.TransmitOptions.AutoRoute,
260
- // Only try sending a nonce once
261
- maxSendAttempts: 1,
262
- // Nonce requests must be handled immediately
263
- priority: import_core.MessagePriority.Immediate,
264
- // We don't want failures causing us to treat the node as asleep or dead
265
- changeNodeStatusOnMissingACK: false
266
- // And we need to react to
264
+ let Security2CCAPI = (() => {
265
+ let _classDecorators = [(0, import_CommandClassDecorators.API)(import_core.CommandClasses["Security 2"])];
266
+ let _classDescriptor;
267
+ let _classExtraInitializers = [];
268
+ let _classThis;
269
+ let _classSuper = import_API.CCAPI;
270
+ var Security2CCAPI2 = class extends _classSuper {
271
+ static {
272
+ _classThis = this;
273
+ }
274
+ static {
275
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
276
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
277
+ Security2CCAPI2 = _classThis = _classDescriptor.value;
278
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
279
+ __runInitializers(_classThis, _classExtraInitializers);
280
+ }
281
+ supportsCommand(_cmd) {
282
+ return true;
283
+ }
284
+ /**
285
+ * Sends a nonce to the node, either in response to a NonceGet request or a message that failed to decrypt. The message is sent without any retransmission etc.
286
+ * The return value indicates whether a nonce was successfully sent
287
+ */
288
+ async sendNonce() {
289
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NonceReport);
290
+ this.assertPhysicalEndpoint(this.endpoint);
291
+ const securityManager = getSecurityManager(this.host.ownNodeId, this.host, this.endpoint.nodeId);
292
+ if (!securityManager) {
293
+ throw new import_core.ZWaveError(`Nonces can only be sent if secure communication is set up!`, import_core.ZWaveErrorCodes.Driver_NoSecurity);
294
+ }
295
+ const receiverEI = securityManager.generateNonce(this.endpoint.nodeId);
296
+ const cc = new Security2CCNonceReport({
297
+ nodeId: this.endpoint.nodeId,
298
+ endpointIndex: this.endpoint.index,
299
+ SOS: true,
300
+ MOS: false,
301
+ receiverEI
267
302
  });
268
- } catch (e) {
269
- if ((0, import_core.isTransmissionError)(e)) {
270
- securityManager.deleteNonce(this.endpoint.nodeId);
271
- return false;
272
- } else {
273
- throw e;
303
+ try {
304
+ await this.host.sendCommand(cc, {
305
+ ...this.commandOptions,
306
+ // Seems we need these options or some nodes won't accept the nonce
307
+ transmitOptions: import_core.TransmitOptions.ACK | import_core.TransmitOptions.AutoRoute,
308
+ // Only try sending a nonce once
309
+ maxSendAttempts: 1,
310
+ // Nonce requests must be handled immediately
311
+ priority: import_core.MessagePriority.Immediate,
312
+ // We don't want failures causing us to treat the node as asleep or dead
313
+ changeNodeStatusOnMissingACK: false
314
+ // And we need to react to
315
+ });
316
+ } catch (e) {
317
+ if ((0, import_core.isTransmissionError)(e)) {
318
+ securityManager.deleteNonce(this.endpoint.nodeId);
319
+ return false;
320
+ } else {
321
+ throw e;
322
+ }
274
323
  }
324
+ return true;
275
325
  }
276
- return true;
277
- }
278
- /** Notifies the target node that the MPAN state is out of sync */
279
- async sendMOS() {
280
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NonceReport);
281
- this.assertPhysicalEndpoint(this.endpoint);
282
- const cc = new Security2CCNonceReport({
283
- nodeId: this.endpoint.nodeId,
284
- endpointIndex: this.endpoint.index,
285
- SOS: false,
286
- MOS: true
287
- });
288
- try {
289
- await this.host.sendCommand(cc, {
290
- ...this.commandOptions,
291
- // Seems we need these options or some nodes won't accept the nonce
292
- transmitOptions: import_core.TransmitOptions.ACK | import_core.TransmitOptions.AutoRoute,
293
- // Only try sending a nonce once
294
- maxSendAttempts: 1,
295
- // Nonce requests must be handled immediately
296
- priority: import_core.MessagePriority.Immediate,
297
- // We don't want failures causing us to treat the node as asleep or dead
298
- changeNodeStatusOnMissingACK: false
326
+ /** Notifies the target node that the MPAN state is out of sync */
327
+ async sendMOS() {
328
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NonceReport);
329
+ this.assertPhysicalEndpoint(this.endpoint);
330
+ const cc = new Security2CCNonceReport({
331
+ nodeId: this.endpoint.nodeId,
332
+ endpointIndex: this.endpoint.index,
333
+ SOS: false,
334
+ MOS: true
299
335
  });
300
- } catch (e) {
301
- if ((0, import_core.isTransmissionError)(e)) {
302
- return false;
303
- } else {
304
- throw e;
336
+ try {
337
+ await this.host.sendCommand(cc, {
338
+ ...this.commandOptions,
339
+ // Seems we need these options or some nodes won't accept the nonce
340
+ transmitOptions: import_core.TransmitOptions.ACK | import_core.TransmitOptions.AutoRoute,
341
+ // Only try sending a nonce once
342
+ maxSendAttempts: 1,
343
+ // Nonce requests must be handled immediately
344
+ priority: import_core.MessagePriority.Immediate,
345
+ // We don't want failures causing us to treat the node as asleep or dead
346
+ changeNodeStatusOnMissingACK: false
347
+ });
348
+ } catch (e) {
349
+ if ((0, import_core.isTransmissionError)(e)) {
350
+ return false;
351
+ } else {
352
+ throw e;
353
+ }
305
354
  }
355
+ return true;
306
356
  }
307
- return true;
308
- }
309
- /** Sends the given MPAN to the node */
310
- async sendMPAN(groupId, innerMPANState) {
311
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.MessageEncapsulation);
312
- this.assertPhysicalEndpoint(this.endpoint);
313
- const cc = new Security2CCMessageEncapsulation({
314
- nodeId: this.endpoint.nodeId,
315
- endpointIndex: this.endpoint.index,
316
- extensions: [
317
- new import_Extension.MPANExtension({
318
- groupId,
319
- innerMPANState
320
- })
321
- ]
322
- });
323
- try {
324
- await this.host.sendCommand(cc, {
357
+ /** Sends the given MPAN to the node */
358
+ async sendMPAN(groupId, innerMPANState) {
359
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.MessageEncapsulation);
360
+ this.assertPhysicalEndpoint(this.endpoint);
361
+ const cc = new Security2CCMessageEncapsulation({
362
+ nodeId: this.endpoint.nodeId,
363
+ endpointIndex: this.endpoint.index,
364
+ extensions: [
365
+ new import_Extension.MPANExtension({
366
+ groupId,
367
+ innerMPANState
368
+ })
369
+ ]
370
+ });
371
+ try {
372
+ await this.host.sendCommand(cc, {
373
+ ...this.commandOptions,
374
+ // Seems we need these options or some nodes won't accept the nonce
375
+ transmitOptions: import_core.TransmitOptions.ACK | import_core.TransmitOptions.AutoRoute,
376
+ // Only try sending a nonce once
377
+ maxSendAttempts: 1,
378
+ // Nonce requests must be handled immediately
379
+ priority: import_core.MessagePriority.Immediate,
380
+ // We don't want failures causing us to treat the node as asleep or dead
381
+ changeNodeStatusOnMissingACK: false
382
+ });
383
+ } catch (e) {
384
+ if ((0, import_core.isTransmissionError)(e)) {
385
+ return false;
386
+ } else {
387
+ throw e;
388
+ }
389
+ }
390
+ return true;
391
+ }
392
+ /**
393
+ * Queries the securely supported commands for the current security class
394
+ * @param securityClass Can be used to overwrite the security class to use. If this doesn't match the current one, new nonces will need to be exchanged.
395
+ */
396
+ async getSupportedCommands(securityClass) {
397
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.CommandsSupportedGet);
398
+ let cc = new Security2CCCommandsSupportedGet({
399
+ nodeId: this.endpoint.nodeId,
400
+ endpointIndex: this.endpoint.index
401
+ });
402
+ if (import_MultiChannelCC.MultiChannelCC.requiresEncapsulation(cc)) {
403
+ const multiChannelCCVersion = this.host.getSupportedCCVersion(import_core.CommandClasses["Multi Channel"], this.endpoint.nodeId);
404
+ cc = multiChannelCCVersion === 1 ? import_MultiChannelCC.MultiChannelCC.encapsulateV1(cc) : import_MultiChannelCC.MultiChannelCC.encapsulate(cc);
405
+ }
406
+ cc = Security2CC.encapsulate(cc, this.host.ownNodeId, this.host, { securityClass });
407
+ const response = await this.host.sendCommand(cc, {
325
408
  ...this.commandOptions,
326
- // Seems we need these options or some nodes won't accept the nonce
327
- transmitOptions: import_core.TransmitOptions.ACK | import_core.TransmitOptions.AutoRoute,
328
- // Only try sending a nonce once
329
- maxSendAttempts: 1,
330
- // Nonce requests must be handled immediately
331
- priority: import_core.MessagePriority.Immediate,
332
- // We don't want failures causing us to treat the node as asleep or dead
333
- changeNodeStatusOnMissingACK: false
409
+ autoEncapsulate: false
334
410
  });
335
- } catch (e) {
336
- if ((0, import_core.isTransmissionError)(e)) {
337
- return false;
338
- } else {
339
- throw e;
411
+ return response?.supportedCCs;
412
+ }
413
+ async reportSupportedCommands(supportedCCs) {
414
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.CommandsSupportedReport);
415
+ const cc = new Security2CCCommandsSupportedReport({
416
+ nodeId: this.endpoint.nodeId,
417
+ endpointIndex: this.endpoint.index,
418
+ supportedCCs
419
+ });
420
+ await this.host.sendCommand(cc, this.commandOptions);
421
+ }
422
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
423
+ async getKeyExchangeParameters() {
424
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXGet);
425
+ const cc = new Security2CCKEXGet({
426
+ nodeId: this.endpoint.nodeId,
427
+ endpointIndex: this.endpoint.index
428
+ });
429
+ const response = await this.host.sendCommand(cc, this.commandOptions);
430
+ if (response) {
431
+ return (0, import_safe3.pick)(response, [
432
+ "requestCSA",
433
+ "echo",
434
+ "supportedKEXSchemes",
435
+ "supportedECDHProfiles",
436
+ "requestedKeys",
437
+ "_reserved"
438
+ ]);
340
439
  }
341
440
  }
342
- return true;
343
- }
344
- /**
345
- * Queries the securely supported commands for the current security class
346
- * @param securityClass Can be used to overwrite the security class to use. If this doesn't match the current one, new nonces will need to be exchanged.
347
- */
348
- async getSupportedCommands(securityClass) {
349
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.CommandsSupportedGet);
350
- let cc = new Security2CCCommandsSupportedGet({
351
- nodeId: this.endpoint.nodeId,
352
- endpointIndex: this.endpoint.index
353
- });
354
- if (import_MultiChannelCC.MultiChannelCC.requiresEncapsulation(cc)) {
355
- const multiChannelCCVersion = this.host.getSupportedCCVersion(import_core.CommandClasses["Multi Channel"], this.endpoint.nodeId);
356
- cc = multiChannelCCVersion === 1 ? import_MultiChannelCC.MultiChannelCC.encapsulateV1(cc) : import_MultiChannelCC.MultiChannelCC.encapsulate(cc);
357
- }
358
- cc = Security2CC.encapsulate(cc, this.host.ownNodeId, this.host, { securityClass });
359
- const response = await this.host.sendCommand(cc, {
360
- ...this.commandOptions,
361
- autoEncapsulate: false
362
- });
363
- return response?.supportedCCs;
364
- }
365
- async reportSupportedCommands(supportedCCs) {
366
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.CommandsSupportedReport);
367
- const cc = new Security2CCCommandsSupportedReport({
368
- nodeId: this.endpoint.nodeId,
369
- endpointIndex: this.endpoint.index,
370
- supportedCCs
371
- });
372
- await this.host.sendCommand(cc, this.commandOptions);
373
- }
374
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
375
- async getKeyExchangeParameters() {
376
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXGet);
377
- const cc = new Security2CCKEXGet({
378
- nodeId: this.endpoint.nodeId,
379
- endpointIndex: this.endpoint.index
380
- });
381
- const response = await this.host.sendCommand(cc, this.commandOptions);
382
- if (response) {
383
- return (0, import_safe3.pick)(response, [
384
- "requestCSA",
385
- "echo",
386
- "supportedKEXSchemes",
387
- "supportedECDHProfiles",
388
- "requestedKeys",
389
- "_reserved"
390
- ]);
441
+ /** Requests the given keys from an including node */
442
+ async requestKeys(params) {
443
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXReport);
444
+ const cc = new Security2CCKEXReport({
445
+ nodeId: this.endpoint.nodeId,
446
+ endpointIndex: this.endpoint.index,
447
+ ...params,
448
+ echo: false
449
+ });
450
+ await this.host.sendCommand(cc, this.commandOptions);
391
451
  }
392
- }
393
- /** Requests the given keys from an including node */
394
- async requestKeys(params) {
395
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXReport);
396
- const cc = new Security2CCKEXReport({
397
- nodeId: this.endpoint.nodeId,
398
- endpointIndex: this.endpoint.index,
399
- ...params,
400
- echo: false
401
- });
402
- await this.host.sendCommand(cc, this.commandOptions);
403
- }
404
- /** Grants the joining node the given keys */
405
- async grantKeys(params) {
406
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXSet);
407
- const cc = new Security2CCKEXSet({
408
- nodeId: this.endpoint.nodeId,
409
- endpointIndex: this.endpoint.index,
410
- ...params,
411
- echo: false
412
- });
413
- await this.host.sendCommand(cc, this.commandOptions);
414
- }
415
- /** Confirms the keys that were requested by a node */
416
- async confirmRequestedKeys(params) {
417
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXReport);
418
- const cc = new Security2CCKEXReport({
419
- nodeId: this.endpoint.nodeId,
420
- endpointIndex: this.endpoint.index,
421
- ...params,
422
- echo: true
423
- });
424
- await this.host.sendCommand(cc, this.commandOptions);
425
- }
426
- /** Confirms the keys that were granted by the including node */
427
- async confirmGrantedKeys(params) {
428
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXSet);
429
- const cc = new Security2CCKEXSet({
430
- nodeId: this.endpoint.nodeId,
431
- endpointIndex: this.endpoint.index,
432
- ...params,
433
- echo: true
434
- });
435
- return this.host.sendCommand(cc, this.commandOptions);
436
- }
437
- /** Notifies the other node that the ongoing key exchange was aborted */
438
- async abortKeyExchange(failType) {
439
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXFail);
440
- const cc = new Security2CCKEXFail({
441
- nodeId: this.endpoint.nodeId,
442
- endpointIndex: this.endpoint.index,
443
- failType
444
- });
445
- await this.host.sendCommand(cc, this.commandOptions);
446
- }
447
- async sendPublicKey(publicKey, includingNode = true) {
448
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.PublicKeyReport);
449
- const cc = new Security2CCPublicKeyReport({
450
- nodeId: this.endpoint.nodeId,
451
- endpointIndex: this.endpoint.index,
452
- includingNode,
453
- publicKey
454
- });
455
- await this.host.sendCommand(cc, this.commandOptions);
456
- }
457
- async requestNetworkKey(securityClass) {
458
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NetworkKeyGet);
459
- const cc = new Security2CCNetworkKeyGet({
460
- nodeId: this.endpoint.nodeId,
461
- endpointIndex: this.endpoint.index,
462
- requestedKey: securityClass
463
- });
464
- await this.host.sendCommand(cc, this.commandOptions);
465
- }
466
- async sendNetworkKey(securityClass, networkKey) {
467
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NetworkKeyReport);
468
- const cc = new Security2CCNetworkKeyReport({
469
- nodeId: this.endpoint.nodeId,
470
- endpointIndex: this.endpoint.index,
471
- grantedKey: securityClass,
472
- networkKey
473
- });
474
- await this.host.sendCommand(cc, this.commandOptions);
475
- }
476
- async verifyNetworkKey() {
477
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NetworkKeyVerify);
478
- const cc = new Security2CCNetworkKeyVerify({
479
- nodeId: this.endpoint.nodeId,
480
- endpointIndex: this.endpoint.index
481
- });
482
- await this.host.sendCommand(cc, this.commandOptions);
483
- }
484
- async confirmKeyVerification() {
485
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.TransferEnd);
486
- const cc = new Security2CCTransferEnd({
487
- nodeId: this.endpoint.nodeId,
488
- endpointIndex: this.endpoint.index,
489
- keyVerified: true,
490
- keyRequestComplete: false
491
- });
492
- await this.host.sendCommand(cc, {
493
- ...this.commandOptions,
494
- // Don't wait for an ACK from the node
495
- transmitOptions: import_core.TransmitOptions.DEFAULT & ~import_core.TransmitOptions.ACK
496
- });
497
- }
498
- async endKeyExchange() {
499
- this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.TransferEnd);
500
- const cc = new Security2CCTransferEnd({
501
- nodeId: this.endpoint.nodeId,
502
- endpointIndex: this.endpoint.index,
503
- keyVerified: false,
504
- keyRequestComplete: true
505
- });
506
- await this.host.sendCommand(cc, this.commandOptions);
507
- }
508
- };
509
- Security2CCAPI = __decorate([
510
- (0, import_CommandClassDecorators.API)(import_core.CommandClasses["Security 2"])
511
- ], Security2CCAPI);
512
- let Security2CC = Security2CC_1 = class Security2CC2 extends import_CommandClass.CommandClass {
513
- async interview(ctx) {
514
- const securityManager = getSecurityManager(ctx.ownNodeId, ctx, this.nodeId);
515
- const node = this.getNode(ctx);
516
- const endpoint = this.getEndpoint(ctx);
517
- const api = import_API.CCAPI.create(import_core.CommandClasses["Security 2"], ctx, endpoint).withOptions({
518
- priority: import_core.MessagePriority.NodeQuery
519
- });
520
- const secClass = node.getHighestSecurityClass();
521
- let hasReceivedSecureCommands = false;
522
- let possibleSecurityClasses;
523
- if ((0, import_core.securityClassIsS2)(secClass)) {
524
- possibleSecurityClasses = [secClass];
525
- } else if (endpoint.index === 0) {
526
- possibleSecurityClasses = [
527
- import_core.SecurityClass.S2_Unauthenticated,
528
- import_core.SecurityClass.S2_Authenticated,
529
- import_core.SecurityClass.S2_AccessControl
530
- ];
531
- } else {
532
- ctx.logNode(node.id, {
533
- endpoint: endpoint.index,
534
- message: `Cannot query securely supported commands for endpoint because the node's security class isn't known...`,
535
- level: "error"
452
+ /** Grants the joining node the given keys */
453
+ async grantKeys(params) {
454
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXSet);
455
+ const cc = new Security2CCKEXSet({
456
+ nodeId: this.endpoint.nodeId,
457
+ endpointIndex: this.endpoint.index,
458
+ ...params,
459
+ echo: false
536
460
  });
537
- return;
461
+ await this.host.sendCommand(cc, this.commandOptions);
538
462
  }
539
- for (const secClass2 of possibleSecurityClasses) {
540
- if (node.hasSecurityClass(secClass2) === false)
541
- continue;
542
- if (!securityManager?.hasKeysForSecurityClass(secClass2)) {
463
+ /** Confirms the keys that were requested by a node */
464
+ async confirmRequestedKeys(params) {
465
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXReport);
466
+ const cc = new Security2CCKEXReport({
467
+ nodeId: this.endpoint.nodeId,
468
+ endpointIndex: this.endpoint.index,
469
+ ...params,
470
+ echo: true
471
+ });
472
+ await this.host.sendCommand(cc, this.commandOptions);
473
+ }
474
+ /** Confirms the keys that were granted by the including node */
475
+ async confirmGrantedKeys(params) {
476
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXSet);
477
+ const cc = new Security2CCKEXSet({
478
+ nodeId: this.endpoint.nodeId,
479
+ endpointIndex: this.endpoint.index,
480
+ ...params,
481
+ echo: true
482
+ });
483
+ return this.host.sendCommand(cc, this.commandOptions);
484
+ }
485
+ /** Notifies the other node that the ongoing key exchange was aborted */
486
+ async abortKeyExchange(failType) {
487
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.KEXFail);
488
+ const cc = new Security2CCKEXFail({
489
+ nodeId: this.endpoint.nodeId,
490
+ endpointIndex: this.endpoint.index,
491
+ failType
492
+ });
493
+ await this.host.sendCommand(cc, this.commandOptions);
494
+ }
495
+ async sendPublicKey(publicKey, includingNode = true) {
496
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.PublicKeyReport);
497
+ const cc = new Security2CCPublicKeyReport({
498
+ nodeId: this.endpoint.nodeId,
499
+ endpointIndex: this.endpoint.index,
500
+ includingNode,
501
+ publicKey
502
+ });
503
+ await this.host.sendCommand(cc, this.commandOptions);
504
+ }
505
+ async requestNetworkKey(securityClass) {
506
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NetworkKeyGet);
507
+ const cc = new Security2CCNetworkKeyGet({
508
+ nodeId: this.endpoint.nodeId,
509
+ endpointIndex: this.endpoint.index,
510
+ requestedKey: securityClass
511
+ });
512
+ await this.host.sendCommand(cc, this.commandOptions);
513
+ }
514
+ async sendNetworkKey(securityClass, networkKey) {
515
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NetworkKeyReport);
516
+ const cc = new Security2CCNetworkKeyReport({
517
+ nodeId: this.endpoint.nodeId,
518
+ endpointIndex: this.endpoint.index,
519
+ grantedKey: securityClass,
520
+ networkKey
521
+ });
522
+ await this.host.sendCommand(cc, this.commandOptions);
523
+ }
524
+ async verifyNetworkKey() {
525
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.NetworkKeyVerify);
526
+ const cc = new Security2CCNetworkKeyVerify({
527
+ nodeId: this.endpoint.nodeId,
528
+ endpointIndex: this.endpoint.index
529
+ });
530
+ await this.host.sendCommand(cc, this.commandOptions);
531
+ }
532
+ async confirmKeyVerification() {
533
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.TransferEnd);
534
+ const cc = new Security2CCTransferEnd({
535
+ nodeId: this.endpoint.nodeId,
536
+ endpointIndex: this.endpoint.index,
537
+ keyVerified: true,
538
+ keyRequestComplete: false
539
+ });
540
+ await this.host.sendCommand(cc, {
541
+ ...this.commandOptions,
542
+ // Don't wait for an ACK from the node
543
+ transmitOptions: import_core.TransmitOptions.DEFAULT & ~import_core.TransmitOptions.ACK
544
+ });
545
+ }
546
+ async endKeyExchange() {
547
+ this.assertSupportsCommand(import_Types.Security2Command, import_Types.Security2Command.TransferEnd);
548
+ const cc = new Security2CCTransferEnd({
549
+ nodeId: this.endpoint.nodeId,
550
+ endpointIndex: this.endpoint.index,
551
+ keyVerified: false,
552
+ keyRequestComplete: true
553
+ });
554
+ await this.host.sendCommand(cc, this.commandOptions);
555
+ }
556
+ };
557
+ return Security2CCAPI2 = _classThis;
558
+ })();
559
+ let Security2CC = (() => {
560
+ let _classDecorators = [(0, import_CommandClassDecorators.commandClass)(import_core.CommandClasses["Security 2"]), (0, import_CommandClassDecorators.implementedVersion)(1)];
561
+ let _classDescriptor;
562
+ let _classExtraInitializers = [];
563
+ let _classThis;
564
+ let _classSuper = import_CommandClass.CommandClass;
565
+ var Security2CC2 = class extends _classSuper {
566
+ static {
567
+ _classThis = this;
568
+ }
569
+ static {
570
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
571
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
572
+ Security2CC2 = _classThis = _classDescriptor.value;
573
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
574
+ __runInitializers(_classThis, _classExtraInitializers);
575
+ }
576
+ async interview(ctx) {
577
+ const securityManager = getSecurityManager(ctx.ownNodeId, ctx, this.nodeId);
578
+ const node = this.getNode(ctx);
579
+ const endpoint = this.getEndpoint(ctx);
580
+ const api = import_API.CCAPI.create(import_core.CommandClasses["Security 2"], ctx, endpoint).withOptions({
581
+ priority: import_core.MessagePriority.NodeQuery
582
+ });
583
+ const secClass = node.getHighestSecurityClass();
584
+ let hasReceivedSecureCommands = false;
585
+ let possibleSecurityClasses;
586
+ if ((0, import_core.securityClassIsS2)(secClass)) {
587
+ possibleSecurityClasses = [secClass];
588
+ } else if (endpoint.index === 0) {
589
+ possibleSecurityClasses = [
590
+ import_core.SecurityClass.S2_Unauthenticated,
591
+ import_core.SecurityClass.S2_Authenticated,
592
+ import_core.SecurityClass.S2_AccessControl
593
+ ];
594
+ } else {
543
595
  ctx.logNode(node.id, {
544
596
  endpoint: endpoint.index,
545
- message: `Cannot query securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}) - network key is not configured...`,
546
- level: "warn"
597
+ message: `Cannot query securely supported commands for endpoint because the node's security class isn't known...`,
598
+ level: "error"
547
599
  });
548
- continue;
600
+ return;
549
601
  }
550
- ctx.logNode(node.id, {
551
- endpoint: endpoint.index,
552
- message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)})...`,
553
- direction: "outbound"
554
- });
555
- let supportedCCs;
556
- const MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;
557
- for (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {
558
- try {
559
- supportedCCs = await api.getSupportedCommands(secClass2);
560
- } catch (e) {
561
- if ((0, import_core.isZWaveError)(e) && e.code === import_core.ZWaveErrorCodes.Security2CC_CannotDecode) {
562
- supportedCCs = void 0;
563
- } else {
564
- throw e;
565
- }
602
+ for (const secClass2 of possibleSecurityClasses) {
603
+ if (node.hasSecurityClass(secClass2) === false)
604
+ continue;
605
+ if (!securityManager?.hasKeysForSecurityClass(secClass2)) {
606
+ ctx.logNode(node.id, {
607
+ endpoint: endpoint.index,
608
+ message: `Cannot query securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}) - network key is not configured...`,
609
+ level: "warn"
610
+ });
611
+ continue;
566
612
  }
567
- if (supportedCCs == void 0 && possibleSecurityClasses.length === 1) {
568
- if (attempts < MAX_ATTEMPTS) {
569
- ctx.logNode(node.id, {
570
- endpoint: endpoint.index,
571
- message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,
572
- level: "warn"
573
- });
574
- await (0, import_async.wait)(500);
575
- continue;
576
- } else if (endpoint.index > 0) {
577
- ctx.logNode(node.id, {
578
- endpoint: endpoint.index,
579
- message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}) failed. Assuming the endpoint supports all its mandatory CCs securely...`,
580
- level: "warn"
581
- });
582
- for (const [ccId] of endpoint.getCCs()) {
583
- endpoint.addCC(ccId, { secure: true });
613
+ ctx.logNode(node.id, {
614
+ endpoint: endpoint.index,
615
+ message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)})...`,
616
+ direction: "outbound"
617
+ });
618
+ let supportedCCs;
619
+ const MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;
620
+ for (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {
621
+ try {
622
+ supportedCCs = await api.getSupportedCommands(secClass2);
623
+ } catch (e) {
624
+ if ((0, import_core.isZWaveError)(e) && e.code === import_core.ZWaveErrorCodes.Security2CC_CannotDecode) {
625
+ supportedCCs = void 0;
626
+ } else {
627
+ throw e;
628
+ }
629
+ }
630
+ if (supportedCCs == void 0 && possibleSecurityClasses.length === 1) {
631
+ if (attempts < MAX_ATTEMPTS) {
632
+ ctx.logNode(node.id, {
633
+ endpoint: endpoint.index,
634
+ message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,
635
+ level: "warn"
636
+ });
637
+ await (0, import_async.wait)(500);
638
+ continue;
639
+ } else if (endpoint.index > 0) {
640
+ ctx.logNode(node.id, {
641
+ endpoint: endpoint.index,
642
+ message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}) failed. Assuming the endpoint supports all its mandatory CCs securely...`,
643
+ level: "warn"
644
+ });
645
+ for (const [ccId] of endpoint.getCCs()) {
646
+ endpoint.addCC(ccId, { secure: true });
647
+ }
648
+ break;
649
+ } else {
650
+ ctx.logNode(node.id, {
651
+ endpoint: endpoint.index,
652
+ message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}) failed. Let's hope for the best...`,
653
+ level: "warn"
654
+ });
655
+ break;
584
656
  }
585
- break;
586
657
  } else {
658
+ break;
659
+ }
660
+ }
661
+ if (supportedCCs == void 0) {
662
+ if (endpoint.index === 0 && possibleSecurityClasses.length > 1) {
663
+ node.setSecurityClass(secClass2, false);
587
664
  ctx.logNode(node.id, {
588
- endpoint: endpoint.index,
589
- message: `Querying securely supported commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}) failed. Let's hope for the best...`,
590
- level: "warn"
665
+ message: `The node was NOT granted the security class ${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}`,
666
+ direction: "inbound"
591
667
  });
592
- break;
593
668
  }
594
- } else {
595
- break;
669
+ continue;
596
670
  }
597
- }
598
- if (supportedCCs == void 0) {
599
671
  if (endpoint.index === 0 && possibleSecurityClasses.length > 1) {
600
- node.setSecurityClass(secClass2, false);
672
+ node.setSecurityClass(secClass2, true);
601
673
  ctx.logNode(node.id, {
602
- message: `The node was NOT granted the security class ${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}`,
674
+ message: `The node was granted the security class ${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}`,
603
675
  direction: "inbound"
604
676
  });
605
677
  }
606
- continue;
607
- }
608
- if (endpoint.index === 0 && possibleSecurityClasses.length > 1) {
609
- node.setSecurityClass(secClass2, true);
610
- ctx.logNode(node.id, {
611
- message: `The node was granted the security class ${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)}`,
612
- direction: "inbound"
613
- });
614
- }
615
- if (!hasReceivedSecureCommands && supportedCCs.length > 0) {
616
- hasReceivedSecureCommands = true;
617
- const logLines = [
618
- `received secure commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)})`,
619
- "supported CCs:"
620
- ];
621
- for (const cc of supportedCCs) {
622
- logLines.push(`\xB7 ${(0, import_core.getCCName)(cc)}`);
623
- }
624
- ctx.logNode(node.id, {
625
- endpoint: endpoint.index,
626
- message: logLines.join("\n"),
627
- direction: "inbound"
628
- });
629
- for (const cc of supportedCCs) {
630
- if (cc === import_core.CommandClasses.Basic) {
631
- endpoint.addCC(cc, { secure: true });
632
- } else {
633
- endpoint.addCC(cc, {
634
- isSupported: true,
635
- secure: true
636
- });
678
+ if (!hasReceivedSecureCommands && supportedCCs.length > 0) {
679
+ hasReceivedSecureCommands = true;
680
+ const logLines = [
681
+ `received secure commands (${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, secClass2)})`,
682
+ "supported CCs:"
683
+ ];
684
+ for (const cc of supportedCCs) {
685
+ logLines.push(`\xB7 ${(0, import_core.getCCName)(cc)}`);
686
+ }
687
+ ctx.logNode(node.id, {
688
+ endpoint: endpoint.index,
689
+ message: logLines.join("\n"),
690
+ direction: "inbound"
691
+ });
692
+ for (const cc of supportedCCs) {
693
+ if (cc === import_core.CommandClasses.Basic) {
694
+ endpoint.addCC(cc, { secure: true });
695
+ } else {
696
+ endpoint.addCC(cc, {
697
+ isSupported: true,
698
+ secure: true
699
+ });
700
+ }
637
701
  }
638
702
  }
639
703
  }
704
+ this.setInterviewComplete(ctx, true);
640
705
  }
641
- this.setInterviewComplete(ctx, true);
642
- }
643
- /** Tests if a command should be sent secure and thus requires encapsulation */
644
- static requiresEncapsulation(cc) {
645
- if (!(cc.encapsulationFlags & import_safe.EncapsulationFlags.Security)) {
646
- return false;
647
- }
648
- if (cc instanceof import_SecurityCC.SecurityCC || cc instanceof import_CRC16CC.CRC16CC || cc instanceof import_TransportServiceCC.TransportServiceCC) {
649
- return false;
650
- }
651
- if (cc instanceof Security2CC_1) {
652
- switch (cc.ccCommand) {
653
- case import_Types.Security2Command.CommandsSupportedGet:
654
- case import_Types.Security2Command.CommandsSupportedReport:
655
- case import_Types.Security2Command.NetworkKeyGet:
656
- case import_Types.Security2Command.NetworkKeyReport:
657
- case import_Types.Security2Command.NetworkKeyVerify:
658
- case import_Types.Security2Command.TransferEnd:
659
- return true;
660
- case import_Types.Security2Command.KEXSet:
661
- case import_Types.Security2Command.KEXReport:
662
- return cc.echo;
663
- case import_Types.Security2Command.KEXFail: {
664
- switch (cc.failType) {
665
- case import_shared.KEXFailType.Decrypt:
666
- case import_shared.KEXFailType.WrongSecurityLevel:
667
- case import_shared.KEXFailType.KeyNotGranted:
668
- case import_shared.KEXFailType.NoVerify:
669
- return true;
670
- default:
671
- return false;
706
+ /** Tests if a command should be sent secure and thus requires encapsulation */
707
+ static requiresEncapsulation(cc) {
708
+ if (!(cc.encapsulationFlags & import_safe.EncapsulationFlags.Security)) {
709
+ return false;
710
+ }
711
+ if (cc instanceof import_SecurityCC.SecurityCC || cc instanceof import_CRC16CC.CRC16CC || cc instanceof import_TransportServiceCC.TransportServiceCC) {
712
+ return false;
713
+ }
714
+ if (cc instanceof Security2CC2) {
715
+ switch (cc.ccCommand) {
716
+ case import_Types.Security2Command.CommandsSupportedGet:
717
+ case import_Types.Security2Command.CommandsSupportedReport:
718
+ case import_Types.Security2Command.NetworkKeyGet:
719
+ case import_Types.Security2Command.NetworkKeyReport:
720
+ case import_Types.Security2Command.NetworkKeyVerify:
721
+ case import_Types.Security2Command.TransferEnd:
722
+ return true;
723
+ case import_Types.Security2Command.KEXSet:
724
+ case import_Types.Security2Command.KEXReport:
725
+ return cc.echo;
726
+ case import_Types.Security2Command.KEXFail: {
727
+ switch (cc.failType) {
728
+ case import_shared.KEXFailType.Decrypt:
729
+ case import_shared.KEXFailType.WrongSecurityLevel:
730
+ case import_shared.KEXFailType.KeyNotGranted:
731
+ case import_shared.KEXFailType.NoVerify:
732
+ return true;
733
+ default:
734
+ return false;
735
+ }
672
736
  }
673
737
  }
738
+ return false;
674
739
  }
675
- return false;
740
+ return true;
676
741
  }
677
- return true;
678
- }
679
- /** Encapsulates a command that should be sent encrypted */
680
- static encapsulate(cc, ownNodeId, securityManagers, options) {
681
- const extensions = [];
682
- if (options?.multicastOutOfSync) {
683
- extensions.push(new import_Extension.MOSExtension());
684
- }
685
- if (options?.multicastGroupId != void 0) {
686
- extensions.push(new import_Extension.MGRPExtension({ groupId: options.multicastGroupId }));
687
- }
688
- let nodeId;
689
- if (cc.isMulticast()) {
690
- if (cc.nodeId.some((nodeId2) => (0, import_core.isLongRangeNodeId)(nodeId2))) {
691
- nodeId = import_safe.NODE_ID_BROADCAST_LR;
742
+ /** Encapsulates a command that should be sent encrypted */
743
+ static encapsulate(cc, ownNodeId, securityManagers, options) {
744
+ const extensions = [];
745
+ if (options?.multicastOutOfSync) {
746
+ extensions.push(new import_Extension.MOSExtension());
747
+ }
748
+ if (options?.multicastGroupId != void 0) {
749
+ extensions.push(new import_Extension.MGRPExtension({ groupId: options.multicastGroupId }));
750
+ }
751
+ let nodeId;
752
+ if (cc.isMulticast()) {
753
+ if (cc.nodeId.some((nodeId2) => (0, import_core.isLongRangeNodeId)(nodeId2))) {
754
+ nodeId = import_safe.NODE_ID_BROADCAST_LR;
755
+ } else {
756
+ nodeId = import_safe.NODE_ID_BROADCAST;
757
+ }
692
758
  } else {
693
- nodeId = import_safe.NODE_ID_BROADCAST;
759
+ nodeId = cc.nodeId;
694
760
  }
695
- } else {
696
- nodeId = cc.nodeId;
697
- }
698
- const ret = new Security2CCMessageEncapsulation({
699
- nodeId,
700
- encapsulated: cc,
701
- securityClass: options?.securityClass,
702
- extensions,
703
- verifyDelivery: options?.verifyDelivery
704
- });
705
- ret.encapsulationFlags = cc.encapsulationFlags & ~import_safe.EncapsulationFlags.Security;
706
- return ret;
707
- }
708
- };
709
- Security2CC = Security2CC_1 = __decorate([
710
- (0, import_CommandClassDecorators.commandClass)(import_core.CommandClasses["Security 2"]),
711
- (0, import_CommandClassDecorators.implementedVersion)(1)
712
- ], Security2CC);
761
+ const ret = new Security2CCMessageEncapsulation({
762
+ nodeId,
763
+ encapsulated: cc,
764
+ securityClass: options?.securityClass,
765
+ extensions,
766
+ verifyDelivery: options?.verifyDelivery
767
+ });
768
+ ret.encapsulationFlags = cc.encapsulationFlags & ~import_safe.EncapsulationFlags.Security;
769
+ return ret;
770
+ }
771
+ };
772
+ return Security2CC2 = _classThis;
773
+ })();
713
774
  function failNoSPAN() {
714
775
  import_core.validatePayload.fail(import_core.ZWaveErrorCodes.Security2CC_NoSPAN);
715
776
  }
@@ -737,535 +798,607 @@ function testCCResponseForMessageEncapsulation(sent, received) {
737
798
  return received.SOS && !!received.receiverEI;
738
799
  }
739
800
  }
740
- let Security2CCMessageEncapsulation = Security2CCMessageEncapsulation_1 = class Security2CCMessageEncapsulation2 extends Security2CC {
741
- constructor(options) {
742
- super(options);
743
- if (!options.encapsulated && !options.extensions?.length) {
744
- throw new import_core.ZWaveError("Security S2 encapsulation requires an encapsulated CC and/or extensions", import_core.ZWaveErrorCodes.Argument_Invalid);
745
- }
746
- this.sequenceNumber = options.sequenceNumber;
747
- this.securityClass = options.securityClass;
748
- if (options.encapsulated) {
749
- this.encapsulated = options.encapsulated;
750
- options.encapsulated.encapsulatingCC = this;
751
- }
752
- this.verifyDelivery = options.verifyDelivery !== false;
753
- this.extensions = options.extensions ?? [];
754
- if (typeof this.nodeId !== "number" && !this.extensions.some((e) => e instanceof import_Extension.MGRPExtension)) {
755
- throw new import_core.ZWaveError("Multicast Security S2 encapsulation requires the MGRP extension", import_core.ZWaveErrorCodes.Security2CC_MissingExtension);
801
+ let Security2CCMessageEncapsulation = (() => {
802
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.MessageEncapsulation), (0, import_CommandClassDecorators.expectedCCResponse)(getCCResponseForMessageEncapsulation, testCCResponseForMessageEncapsulation)];
803
+ let _classDescriptor;
804
+ let _classExtraInitializers = [];
805
+ let _classThis;
806
+ let _classSuper = Security2CC;
807
+ var Security2CCMessageEncapsulation2 = class extends _classSuper {
808
+ static {
809
+ _classThis = this;
756
810
  }
757
- }
758
- static from(raw, ctx) {
759
- const securityManager = assertSecurityRX(ctx);
760
- (0, import_core.validatePayload)(raw.payload.length >= 2);
761
- const sequenceNumber = raw.payload[0];
762
- import_core.validatePayload.withReason("No security class granted")(ctx.getHighestSecurityClass(ctx.sourceNodeId) !== import_core.SecurityClass.None);
763
- const hasExtensions = !!(raw.payload[1] & 1);
764
- const hasEncryptedExtensions = !!(raw.payload[1] & 2);
765
- let offset = 2;
766
- const extensions = [];
767
- let mustDiscardCommand = false;
768
- const parseExtensions = (buffer, wasEncrypted) => {
769
- while (true) {
770
- if (buffer.length < offset + 2) {
771
- mustDiscardCommand = true;
772
- return;
773
- }
774
- const { actual: actualLength, expected: expectedLength } = import_Extension.Security2Extension.getExtensionLength(buffer.subarray(offset));
775
- const extensionLength = expectedLength ?? actualLength;
776
- if (extensionLength < 2) {
777
- mustDiscardCommand = true;
778
- return;
779
- } else if (extensionLength > buffer.length - offset - (wasEncrypted ? 0 : import_core.SECURITY_S2_AUTH_TAG_LENGTH)) {
780
- mustDiscardCommand = true;
781
- return;
782
- }
783
- const extensionData = buffer.subarray(offset, offset + extensionLength);
784
- offset += extensionLength;
785
- const ext = import_Extension.Security2Extension.parse(extensionData);
786
- switch ((0, import_Extension.validateS2Extension)(ext, wasEncrypted)) {
787
- case import_Extension.ValidateS2ExtensionResult.OK:
788
- if (expectedLength != void 0 && actualLength !== expectedLength) {
789
- } else {
790
- extensions.push(ext);
791
- }
792
- break;
793
- case import_Extension.ValidateS2ExtensionResult.DiscardExtension:
794
- break;
795
- case import_Extension.ValidateS2ExtensionResult.DiscardCommand:
811
+ static {
812
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
813
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
814
+ Security2CCMessageEncapsulation2 = _classThis = _classDescriptor.value;
815
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
816
+ __runInitializers(_classThis, _classExtraInitializers);
817
+ }
818
+ constructor(options) {
819
+ super(options);
820
+ if (!options.encapsulated && !options.extensions?.length) {
821
+ throw new import_core.ZWaveError("Security S2 encapsulation requires an encapsulated CC and/or extensions", import_core.ZWaveErrorCodes.Argument_Invalid);
822
+ }
823
+ this.sequenceNumber = options.sequenceNumber;
824
+ this.securityClass = options.securityClass;
825
+ if (options.encapsulated) {
826
+ this.encapsulated = options.encapsulated;
827
+ options.encapsulated.encapsulatingCC = this;
828
+ }
829
+ this.verifyDelivery = options.verifyDelivery !== false;
830
+ this.extensions = options.extensions ?? [];
831
+ if (typeof this.nodeId !== "number" && !this.extensions.some((e) => e instanceof import_Extension.MGRPExtension)) {
832
+ throw new import_core.ZWaveError("Multicast Security S2 encapsulation requires the MGRP extension", import_core.ZWaveErrorCodes.Security2CC_MissingExtension);
833
+ }
834
+ }
835
+ static from(raw, ctx) {
836
+ const securityManager = assertSecurityRX(ctx);
837
+ (0, import_core.validatePayload)(raw.payload.length >= 2);
838
+ const sequenceNumber = raw.payload[0];
839
+ import_core.validatePayload.withReason("No security class granted")(ctx.getHighestSecurityClass(ctx.sourceNodeId) !== import_core.SecurityClass.None);
840
+ const hasExtensions = !!(raw.payload[1] & 1);
841
+ const hasEncryptedExtensions = !!(raw.payload[1] & 2);
842
+ let offset = 2;
843
+ const extensions = [];
844
+ let mustDiscardCommand = false;
845
+ const parseExtensions = (buffer, wasEncrypted) => {
846
+ while (true) {
847
+ if (buffer.length < offset + 2) {
796
848
  mustDiscardCommand = true;
849
+ return;
850
+ }
851
+ const { actual: actualLength, expected: expectedLength } = import_Extension.Security2Extension.getExtensionLength(buffer.subarray(offset));
852
+ const extensionLength = expectedLength ?? actualLength;
853
+ if (extensionLength < 2) {
854
+ mustDiscardCommand = true;
855
+ return;
856
+ } else if (extensionLength > buffer.length - offset - (wasEncrypted ? 0 : import_core.SECURITY_S2_AUTH_TAG_LENGTH)) {
857
+ mustDiscardCommand = true;
858
+ return;
859
+ }
860
+ const extensionData = buffer.subarray(offset, offset + extensionLength);
861
+ offset += extensionLength;
862
+ const ext = import_Extension.Security2Extension.parse(extensionData);
863
+ switch ((0, import_Extension.validateS2Extension)(ext, wasEncrypted)) {
864
+ case import_Extension.ValidateS2ExtensionResult.OK:
865
+ if (expectedLength != void 0 && actualLength !== expectedLength) {
866
+ } else {
867
+ extensions.push(ext);
868
+ }
869
+ break;
870
+ case import_Extension.ValidateS2ExtensionResult.DiscardExtension:
871
+ break;
872
+ case import_Extension.ValidateS2ExtensionResult.DiscardCommand:
873
+ mustDiscardCommand = true;
874
+ break;
875
+ }
876
+ if (!ext.moreToFollow)
797
877
  break;
798
878
  }
799
- if (!ext.moreToFollow)
800
- break;
801
- }
802
- };
803
- if (hasExtensions)
804
- parseExtensions(raw.payload, false);
805
- const mcctx = (() => {
806
- const multicastGroupId = getMulticastGroupId(extensions);
807
- if (ctx.frameType === "multicast" || ctx.frameType === "broadcast") {
808
- if (multicastGroupId == void 0) {
809
- import_core.validatePayload.fail("Multicast frames without MGRP extension");
879
+ };
880
+ if (hasExtensions)
881
+ parseExtensions(raw.payload, false);
882
+ const mcctx = (() => {
883
+ const multicastGroupId = getMulticastGroupId(extensions);
884
+ if (ctx.frameType === "multicast" || ctx.frameType === "broadcast") {
885
+ if (multicastGroupId == void 0) {
886
+ import_core.validatePayload.fail("Multicast frames without MGRP extension");
887
+ }
888
+ return {
889
+ isMulticast: true,
890
+ groupId: multicastGroupId
891
+ };
892
+ } else {
893
+ return { isMulticast: false, groupId: multicastGroupId };
810
894
  }
811
- return {
812
- isMulticast: true,
813
- groupId: multicastGroupId
814
- };
895
+ })();
896
+ if (mustDiscardCommand) {
897
+ if (mcctx.isMulticast) {
898
+ securityManager.nextPeerMPAN(ctx.sourceNodeId, mcctx.groupId);
899
+ } else {
900
+ securityManager.nextNonce(ctx.sourceNodeId);
901
+ }
902
+ import_core.validatePayload.fail("Invalid S2 extension");
903
+ }
904
+ let prevSequenceNumber;
905
+ let mpanState;
906
+ if (mcctx.isMulticast) {
907
+ mpanState = securityManager.getPeerMPAN(ctx.sourceNodeId, mcctx.groupId);
815
908
  } else {
816
- return { isMulticast: false, groupId: multicastGroupId };
909
+ prevSequenceNumber = validateSequenceNumber(securityManager, ctx.sourceNodeId, sequenceNumber);
910
+ if (mcctx.groupId == void 0) {
911
+ securityManager.resetOutOfSyncMPANs(ctx.sourceNodeId);
912
+ }
817
913
  }
818
- })();
819
- if (mustDiscardCommand) {
914
+ const unencryptedPayload = raw.payload.subarray(0, offset);
915
+ const ciphertext = raw.payload.subarray(offset, -import_core.SECURITY_S2_AUTH_TAG_LENGTH);
916
+ const authTag = raw.payload.subarray(-import_core.SECURITY_S2_AUTH_TAG_LENGTH);
917
+ const messageLength = 2 + raw.payload.length;
918
+ const authData = getAuthenticationData(ctx.sourceNodeId, getDestinationIDRX(ctx, extensions), ctx.homeId, messageLength, unencryptedPayload);
919
+ let decrypt;
820
920
  if (mcctx.isMulticast) {
821
- securityManager.nextPeerMPAN(ctx.sourceNodeId, mcctx.groupId);
921
+ if (mpanState?.type !== import_core.MPANState.MPAN) {
922
+ securityManager.storePeerMPAN(ctx.sourceNodeId, mcctx.groupId, { type: import_core.MPANState.OutOfSync });
923
+ failNoMPAN();
924
+ }
925
+ decrypt = () => decryptMulticast(ctx.sourceNodeId, securityManager, mcctx.groupId, ciphertext, authData, authTag);
822
926
  } else {
823
- securityManager.nextNonce(ctx.sourceNodeId);
927
+ const spanState = securityManager.getSPANState(ctx.sourceNodeId);
928
+ if (spanState.type === import_core.SPANState.None) {
929
+ failNoSPAN();
930
+ } else if (spanState.type === import_core.SPANState.RemoteEI) {
931
+ failNoSPAN();
932
+ }
933
+ decrypt = () => decryptSinglecast(ctx, securityManager, ctx.sourceNodeId, sequenceNumber, prevSequenceNumber, ciphertext, authData, authTag, spanState, extensions);
824
934
  }
825
- import_core.validatePayload.fail("Invalid S2 extension");
826
- }
827
- let prevSequenceNumber;
828
- let mpanState;
829
- if (mcctx.isMulticast) {
830
- mpanState = securityManager.getPeerMPAN(ctx.sourceNodeId, mcctx.groupId);
831
- } else {
832
- prevSequenceNumber = validateSequenceNumber(securityManager, ctx.sourceNodeId, sequenceNumber);
833
- if (mcctx.groupId == void 0) {
834
- securityManager.resetOutOfSyncMPANs(ctx.sourceNodeId);
935
+ let plaintext;
936
+ let authOK = false;
937
+ let key;
938
+ let iv;
939
+ let decryptionSecurityClass;
940
+ const decryptAttempts = mcctx.isMulticast ? MAX_DECRYPT_ATTEMPTS_MULTICAST : mcctx.groupId != void 0 ? MAX_DECRYPT_ATTEMPTS_SC_FOLLOWUP : MAX_DECRYPT_ATTEMPTS_SINGLECAST;
941
+ for (let i = 0; i < decryptAttempts; i++) {
942
+ ({
943
+ plaintext,
944
+ authOK,
945
+ key,
946
+ iv,
947
+ securityClass: decryptionSecurityClass
948
+ } = decrypt());
949
+ if (!!authOK && !!plaintext)
950
+ break;
951
+ if (!!getSenderEI(extensions))
952
+ break;
835
953
  }
836
- }
837
- const unencryptedPayload = raw.payload.subarray(0, offset);
838
- const ciphertext = raw.payload.subarray(offset, -import_core.SECURITY_S2_AUTH_TAG_LENGTH);
839
- const authTag = raw.payload.subarray(-import_core.SECURITY_S2_AUTH_TAG_LENGTH);
840
- const messageLength = 2 + raw.payload.length;
841
- const authData = getAuthenticationData(ctx.sourceNodeId, getDestinationIDRX(ctx, extensions), ctx.homeId, messageLength, unencryptedPayload);
842
- let decrypt;
843
- if (mcctx.isMulticast) {
844
- if (mpanState?.type !== import_core.MPANState.MPAN) {
845
- securityManager.storePeerMPAN(ctx.sourceNodeId, mcctx.groupId, { type: import_core.MPANState.OutOfSync });
846
- failNoMPAN();
954
+ if (!authOK || !plaintext) {
955
+ if (mcctx.isMulticast) {
956
+ securityManager.storePeerMPAN(ctx.sourceNodeId, mcctx.groupId, { type: import_core.MPANState.OutOfSync });
957
+ import_core.validatePayload.fail(import_core.ZWaveErrorCodes.Security2CC_CannotDecodeMulticast);
958
+ } else {
959
+ import_core.validatePayload.fail(import_core.ZWaveErrorCodes.Security2CC_CannotDecode);
960
+ }
961
+ } else if (!mcctx.isMulticast && mcctx.groupId != void 0) {
962
+ securityManager.tryIncrementPeerMPAN(ctx.sourceNodeId, mcctx.groupId);
847
963
  }
848
- decrypt = () => decryptMulticast(ctx.sourceNodeId, securityManager, mcctx.groupId, ciphertext, authData, authTag);
849
- } else {
850
- const spanState = securityManager.getSPANState(ctx.sourceNodeId);
851
- if (spanState.type === import_core.SPANState.None) {
852
- failNoSPAN();
853
- } else if (spanState.type === import_core.SPANState.RemoteEI) {
854
- failNoSPAN();
964
+ const securityClass = decryptionSecurityClass;
965
+ offset = 0;
966
+ if (hasEncryptedExtensions)
967
+ parseExtensions(plaintext, true);
968
+ if (mustDiscardCommand) {
969
+ import_core.validatePayload.fail("Invalid extension");
855
970
  }
856
- decrypt = () => decryptSinglecast(ctx, securityManager, ctx.sourceNodeId, sequenceNumber, prevSequenceNumber, ciphertext, authData, authTag, spanState, extensions);
857
- }
858
- let plaintext;
859
- let authOK = false;
860
- let key;
861
- let iv;
862
- let decryptionSecurityClass;
863
- const decryptAttempts = mcctx.isMulticast ? MAX_DECRYPT_ATTEMPTS_MULTICAST : mcctx.groupId != void 0 ? MAX_DECRYPT_ATTEMPTS_SC_FOLLOWUP : MAX_DECRYPT_ATTEMPTS_SINGLECAST;
864
- for (let i = 0; i < decryptAttempts; i++) {
865
- ({
866
- plaintext,
867
- authOK,
868
- key,
869
- iv,
870
- securityClass: decryptionSecurityClass
871
- } = decrypt());
872
- if (!!authOK && !!plaintext)
873
- break;
874
- if (!!getSenderEI(extensions))
875
- break;
876
- }
877
- if (!authOK || !plaintext) {
878
- if (mcctx.isMulticast) {
879
- securityManager.storePeerMPAN(ctx.sourceNodeId, mcctx.groupId, { type: import_core.MPANState.OutOfSync });
880
- import_core.validatePayload.fail(import_core.ZWaveErrorCodes.Security2CC_CannotDecodeMulticast);
881
- } else {
882
- import_core.validatePayload.fail(import_core.ZWaveErrorCodes.Security2CC_CannotDecode);
971
+ if (!mcctx.isMulticast) {
972
+ const mpanExtension = extensions.find((e) => e instanceof import_Extension.MPANExtension);
973
+ if (mpanExtension) {
974
+ securityManager.storePeerMPAN(ctx.sourceNodeId, mpanExtension.groupId, {
975
+ type: import_core.MPANState.MPAN,
976
+ currentMPAN: mpanExtension.innerMPANState
977
+ });
978
+ }
883
979
  }
884
- } else if (!mcctx.isMulticast && mcctx.groupId != void 0) {
885
- securityManager.tryIncrementPeerMPAN(ctx.sourceNodeId, mcctx.groupId);
886
- }
887
- const securityClass = decryptionSecurityClass;
888
- offset = 0;
889
- if (hasEncryptedExtensions)
890
- parseExtensions(plaintext, true);
891
- if (mustDiscardCommand) {
892
- import_core.validatePayload.fail("Invalid extension");
893
- }
894
- if (!mcctx.isMulticast) {
895
- const mpanExtension = extensions.find((e) => e instanceof import_Extension.MPANExtension);
896
- if (mpanExtension) {
897
- securityManager.storePeerMPAN(ctx.sourceNodeId, mpanExtension.groupId, {
898
- type: import_core.MPANState.MPAN,
899
- currentMPAN: mpanExtension.innerMPANState
900
- });
980
+ const decryptedCCBytes = plaintext.subarray(offset);
981
+ let encapsulated;
982
+ if (decryptedCCBytes.length > 0) {
983
+ (0, import_core.validatePayload)(decryptedCCBytes.length >= 2);
984
+ encapsulated = import_CommandClass.CommandClass.parse(decryptedCCBytes, ctx);
901
985
  }
986
+ const ret = new Security2CCMessageEncapsulation2({
987
+ nodeId: ctx.sourceNodeId,
988
+ sequenceNumber,
989
+ securityClass,
990
+ extensions,
991
+ encapsulated
992
+ });
993
+ ret.key = key;
994
+ ret.iv = iv;
995
+ ret.authData = authData;
996
+ ret.authTag = authTag;
997
+ ret.plaintext = decryptedCCBytes;
998
+ return ret;
902
999
  }
903
- const decryptedCCBytes = plaintext.subarray(offset);
904
- let encapsulated;
905
- if (decryptedCCBytes.length > 0) {
906
- (0, import_core.validatePayload)(decryptedCCBytes.length >= 2);
907
- encapsulated = import_CommandClass.CommandClass.parse(decryptedCCBytes, ctx);
908
- }
909
- const ret = new Security2CCMessageEncapsulation_1({
910
- nodeId: ctx.sourceNodeId,
911
- sequenceNumber,
912
- securityClass,
913
- extensions,
914
- encapsulated
915
- });
916
- ret.key = key;
917
- ret.iv = iv;
918
- ret.authData = authData;
919
- ret.authTag = authTag;
920
- ret.plaintext = decryptedCCBytes;
921
- return ret;
922
- }
923
- securityClass;
924
- // Only used for testing/debugging purposes
925
- key;
926
- iv;
927
- authData;
928
- authTag;
929
- ciphertext;
930
- plaintext;
931
- verifyDelivery = true;
932
- sequenceNumber;
933
- ensureSequenceNumber(securityManager) {
934
- if (this.sequenceNumber == void 0) {
935
- if (this.isSinglecast()) {
936
- this.sequenceNumber = securityManager.nextSequenceNumber(this.nodeId);
937
- } else {
938
- const groupId = getDestinationIDTX.call(this);
939
- this.sequenceNumber = securityManager.nextMulticastSequenceNumber(groupId);
1000
+ securityClass;
1001
+ // Only used for testing/debugging purposes
1002
+ key;
1003
+ iv;
1004
+ authData;
1005
+ authTag;
1006
+ ciphertext;
1007
+ plaintext;
1008
+ verifyDelivery = true;
1009
+ sequenceNumber;
1010
+ ensureSequenceNumber(securityManager) {
1011
+ if (this.sequenceNumber == void 0) {
1012
+ if (this.isSinglecast()) {
1013
+ this.sequenceNumber = securityManager.nextSequenceNumber(this.nodeId);
1014
+ } else {
1015
+ const groupId = getDestinationIDTX.call(this);
1016
+ this.sequenceNumber = securityManager.nextMulticastSequenceNumber(groupId);
1017
+ }
940
1018
  }
941
1019
  }
942
- }
943
- encapsulated;
944
- extensions;
945
- prepareRetransmission() {
946
- super.prepareRetransmission();
947
- this.sequenceNumber = void 0;
948
- }
949
- hasMOSExtension() {
950
- return this.extensions.some((e) => e instanceof import_Extension.MOSExtension);
951
- }
952
- /** Returns the Sender's Entropy Input if this command contains an SPAN extension */
953
- getSenderEI() {
954
- return getSenderEI(this.extensions);
955
- }
956
- /** Returns the multicast group ID if this command contains an MGRP extension */
957
- getMulticastGroupId() {
958
- return getMulticastGroupId(this.extensions);
959
- }
960
- maybeAddSPANExtension(ctx, securityManager) {
961
- if (!this.isSinglecast())
962
- return;
963
- const receiverNodeId = this.nodeId;
964
- const spanState = securityManager.getSPANState(receiverNodeId);
965
- if (spanState.type === import_core.SPANState.None || spanState.type === import_core.SPANState.LocalEI) {
966
- throw new import_core.ZWaveError(`Security S2 CC requires the receiver's nonce to be sent!`, import_core.ZWaveErrorCodes.Security2CC_NoSPAN);
967
- } else if (spanState.type === import_core.SPANState.RemoteEI) {
968
- const senderEI = securityManager.generateNonce(void 0);
969
- const receiverEI = spanState.receiverEI;
970
- if (this.securityClass == void 0 && securityManager.tempKeys.has(receiverNodeId)) {
971
- securityManager.initializeTempSPAN(receiverNodeId, senderEI, receiverEI);
972
- } else {
973
- const securityClass = this.securityClass ?? ctx.getHighestSecurityClass(receiverNodeId);
974
- if (securityClass == void 0) {
975
- throw new import_core.ZWaveError("No security class defined for this command!", import_core.ZWaveErrorCodes.Security2CC_NoSPAN);
1020
+ encapsulated;
1021
+ extensions;
1022
+ prepareRetransmission() {
1023
+ super.prepareRetransmission();
1024
+ this.sequenceNumber = void 0;
1025
+ }
1026
+ hasMOSExtension() {
1027
+ return this.extensions.some((e) => e instanceof import_Extension.MOSExtension);
1028
+ }
1029
+ /** Returns the Sender's Entropy Input if this command contains an SPAN extension */
1030
+ getSenderEI() {
1031
+ return getSenderEI(this.extensions);
1032
+ }
1033
+ /** Returns the multicast group ID if this command contains an MGRP extension */
1034
+ getMulticastGroupId() {
1035
+ return getMulticastGroupId(this.extensions);
1036
+ }
1037
+ maybeAddSPANExtension(ctx, securityManager) {
1038
+ if (!this.isSinglecast())
1039
+ return;
1040
+ const receiverNodeId = this.nodeId;
1041
+ const spanState = securityManager.getSPANState(receiverNodeId);
1042
+ if (spanState.type === import_core.SPANState.None || spanState.type === import_core.SPANState.LocalEI) {
1043
+ throw new import_core.ZWaveError(`Security S2 CC requires the receiver's nonce to be sent!`, import_core.ZWaveErrorCodes.Security2CC_NoSPAN);
1044
+ } else if (spanState.type === import_core.SPANState.RemoteEI) {
1045
+ const senderEI = securityManager.generateNonce(void 0);
1046
+ const receiverEI = spanState.receiverEI;
1047
+ if (this.securityClass == void 0 && securityManager.tempKeys.has(receiverNodeId)) {
1048
+ securityManager.initializeTempSPAN(receiverNodeId, senderEI, receiverEI);
1049
+ } else {
1050
+ const securityClass = this.securityClass ?? ctx.getHighestSecurityClass(receiverNodeId);
1051
+ if (securityClass == void 0) {
1052
+ throw new import_core.ZWaveError("No security class defined for this command!", import_core.ZWaveErrorCodes.Security2CC_NoSPAN);
1053
+ }
1054
+ securityManager.initializeSPAN(receiverNodeId, securityClass, senderEI, receiverEI);
1055
+ }
1056
+ let spanExtension = this.extensions.find((e) => e instanceof import_Extension.SPANExtension);
1057
+ if (spanExtension) {
1058
+ spanExtension.senderEI = senderEI;
1059
+ } else {
1060
+ spanExtension = new import_Extension.SPANExtension({ senderEI });
1061
+ this.extensions.push(spanExtension);
976
1062
  }
977
- securityManager.initializeSPAN(receiverNodeId, securityClass, senderEI, receiverEI);
978
1063
  }
979
- let spanExtension = this.extensions.find((e) => e instanceof import_Extension.SPANExtension);
980
- if (spanExtension) {
981
- spanExtension.senderEI = senderEI;
1064
+ }
1065
+ serialize(ctx) {
1066
+ const securityManager = assertSecurityTX(ctx, this.nodeId);
1067
+ this.ensureSequenceNumber(securityManager);
1068
+ this.maybeAddSPANExtension(ctx, securityManager);
1069
+ const unencryptedExtensions = this.extensions.filter((e) => !e.isEncrypted());
1070
+ const encryptedExtensions = this.extensions.filter((e) => e.isEncrypted());
1071
+ const unencryptedPayload = import_safe2.Bytes.concat([
1072
+ import_safe2.Bytes.from([
1073
+ this.sequenceNumber,
1074
+ (encryptedExtensions.length > 0 ? 2 : 0) | (unencryptedExtensions.length > 0 ? 1 : 0)
1075
+ ]),
1076
+ ...unencryptedExtensions.map((e, index) => e.serialize(index < unencryptedExtensions.length - 1))
1077
+ ]);
1078
+ const serializedCC = this.encapsulated?.serialize(ctx) ?? new import_safe2.Bytes();
1079
+ const plaintextPayload = import_safe2.Bytes.concat([
1080
+ ...encryptedExtensions.map((e, index) => e.serialize(index < encryptedExtensions.length - 1)),
1081
+ serializedCC
1082
+ ]);
1083
+ const destinationTag = getDestinationIDTX.call(this);
1084
+ const messageLength = this.computeEncapsulationOverhead() + serializedCC.length;
1085
+ const authData = getAuthenticationData(ctx.ownNodeId, destinationTag, ctx.homeId, messageLength, unencryptedPayload);
1086
+ let key;
1087
+ let iv;
1088
+ if (this.isSinglecast()) {
1089
+ iv = securityManager.nextNonce(this.nodeId, true);
1090
+ const { keyCCM } = (
1091
+ // Prefer the overridden security class if it was given
1092
+ this.securityClass != void 0 ? securityManager.getKeysForSecurityClass(this.securityClass) : securityManager.getKeysForNode(this.nodeId)
1093
+ );
1094
+ key = keyCCM;
982
1095
  } else {
983
- spanExtension = new import_Extension.SPANExtension({ senderEI });
984
- this.extensions.push(spanExtension);
1096
+ const keyAndIV = securityManager.getMulticastKeyAndIV(destinationTag);
1097
+ key = keyAndIV.key;
1098
+ iv = keyAndIV.iv;
985
1099
  }
1100
+ const { ciphertext: ciphertextPayload, authTag } = (0, import_core.encryptAES128CCM)(key, iv, plaintextPayload, authData, import_core.SECURITY_S2_AUTH_TAG_LENGTH);
1101
+ this.key = key;
1102
+ this.iv = iv;
1103
+ this.authData = authData;
1104
+ this.authTag = authTag;
1105
+ this.ciphertext = ciphertextPayload;
1106
+ this.payload = import_safe2.Bytes.concat([
1107
+ unencryptedPayload,
1108
+ ciphertextPayload,
1109
+ authTag
1110
+ ]);
1111
+ return super.serialize(ctx);
986
1112
  }
987
- }
988
- serialize(ctx) {
989
- const securityManager = assertSecurityTX(ctx, this.nodeId);
990
- this.ensureSequenceNumber(securityManager);
991
- this.maybeAddSPANExtension(ctx, securityManager);
992
- const unencryptedExtensions = this.extensions.filter((e) => !e.isEncrypted());
993
- const encryptedExtensions = this.extensions.filter((e) => e.isEncrypted());
994
- const unencryptedPayload = import_safe2.Bytes.concat([
995
- import_safe2.Bytes.from([
996
- this.sequenceNumber,
997
- (encryptedExtensions.length > 0 ? 2 : 0) | (unencryptedExtensions.length > 0 ? 1 : 0)
998
- ]),
999
- ...unencryptedExtensions.map((e, index) => e.serialize(index < unencryptedExtensions.length - 1))
1000
- ]);
1001
- const serializedCC = this.encapsulated?.serialize(ctx) ?? new import_safe2.Bytes();
1002
- const plaintextPayload = import_safe2.Bytes.concat([
1003
- ...encryptedExtensions.map((e, index) => e.serialize(index < encryptedExtensions.length - 1)),
1004
- serializedCC
1005
- ]);
1006
- const destinationTag = getDestinationIDTX.call(this);
1007
- const messageLength = this.computeEncapsulationOverhead() + serializedCC.length;
1008
- const authData = getAuthenticationData(ctx.ownNodeId, destinationTag, ctx.homeId, messageLength, unencryptedPayload);
1009
- let key;
1010
- let iv;
1011
- if (this.isSinglecast()) {
1012
- iv = securityManager.nextNonce(this.nodeId, true);
1013
- const { keyCCM } = (
1014
- // Prefer the overridden security class if it was given
1015
- this.securityClass != void 0 ? securityManager.getKeysForSecurityClass(this.securityClass) : securityManager.getKeysForNode(this.nodeId)
1016
- );
1017
- key = keyCCM;
1018
- } else {
1019
- const keyAndIV = securityManager.getMulticastKeyAndIV(destinationTag);
1020
- key = keyAndIV.key;
1021
- iv = keyAndIV.iv;
1022
- }
1023
- const { ciphertext: ciphertextPayload, authTag } = (0, import_core.encryptAES128CCM)(key, iv, plaintextPayload, authData, import_core.SECURITY_S2_AUTH_TAG_LENGTH);
1024
- this.key = key;
1025
- this.iv = iv;
1026
- this.authData = authData;
1027
- this.authTag = authTag;
1028
- this.ciphertext = ciphertextPayload;
1029
- this.payload = import_safe2.Bytes.concat([
1030
- unencryptedPayload,
1031
- ciphertextPayload,
1032
- authTag
1033
- ]);
1034
- return super.serialize(ctx);
1035
- }
1036
- computeEncapsulationOverhead() {
1037
- const extensionBytes = this.extensions.map((e) => e.computeLength()).reduce((a, b) => a + b, 0);
1038
- return super.computeEncapsulationOverhead() + 2 + import_core.SECURITY_S2_AUTH_TAG_LENGTH + extensionBytes;
1039
- }
1040
- toLogEntry(ctx) {
1041
- const message = {
1042
- "sequence number": this.sequenceNumber ?? "(not set)"
1043
- };
1044
- if (this.extensions.length > 0) {
1045
- message.extensions = this.extensions.map((e) => e.toLogEntry()).join("");
1113
+ computeEncapsulationOverhead() {
1114
+ const extensionBytes = this.extensions.map((e) => e.computeLength()).reduce((a, b) => a + b, 0);
1115
+ return super.computeEncapsulationOverhead() + 2 + import_core.SECURITY_S2_AUTH_TAG_LENGTH + extensionBytes;
1046
1116
  }
1047
- if (process.env.NODE_ENV === "test" || process.env.NODE_ENV === "development") {
1048
- if (this.key) {
1049
- message.key = (0, import_safe3.buffer2hex)(this.key);
1117
+ toLogEntry(ctx) {
1118
+ const message = {
1119
+ "sequence number": this.sequenceNumber ?? "(not set)"
1120
+ };
1121
+ if (this.extensions.length > 0) {
1122
+ message.extensions = this.extensions.map((e) => e.toLogEntry()).join("");
1050
1123
  }
1051
- if (this.iv) {
1052
- message.IV = (0, import_safe3.buffer2hex)(this.iv);
1124
+ if (process.env.NODE_ENV === "test" || process.env.NODE_ENV === "development") {
1125
+ if (this.key) {
1126
+ message.key = (0, import_safe3.buffer2hex)(this.key);
1127
+ }
1128
+ if (this.iv) {
1129
+ message.IV = (0, import_safe3.buffer2hex)(this.iv);
1130
+ }
1131
+ if (this.ciphertext) {
1132
+ message.ciphertext = (0, import_safe3.buffer2hex)(this.ciphertext);
1133
+ } else if (this.plaintext) {
1134
+ message.plaintext = (0, import_safe3.buffer2hex)(this.plaintext);
1135
+ }
1136
+ if (this.authData) {
1137
+ message["auth data"] = (0, import_safe3.buffer2hex)(this.authData);
1138
+ }
1139
+ if (this.authTag) {
1140
+ message["auth tag"] = (0, import_safe3.buffer2hex)(this.authTag);
1141
+ }
1142
+ }
1143
+ if (this.securityClass != void 0) {
1144
+ message["security class"] = (0, import_safe3.getEnumMemberName)(import_core.SecurityClass, this.securityClass);
1145
+ }
1146
+ return {
1147
+ ...super.toLogEntry(ctx),
1148
+ message
1149
+ };
1150
+ }
1151
+ };
1152
+ return Security2CCMessageEncapsulation2 = _classThis;
1153
+ })();
1154
+ let Security2CCNonceReport = (() => {
1155
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NonceReport)];
1156
+ let _classDescriptor;
1157
+ let _classExtraInitializers = [];
1158
+ let _classThis;
1159
+ let _classSuper = Security2CC;
1160
+ var Security2CCNonceReport2 = class extends _classSuper {
1161
+ static {
1162
+ _classThis = this;
1163
+ }
1164
+ static {
1165
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1166
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1167
+ Security2CCNonceReport2 = _classThis = _classDescriptor.value;
1168
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1169
+ __runInitializers(_classThis, _classExtraInitializers);
1170
+ }
1171
+ constructor(options) {
1172
+ super(options);
1173
+ this.SOS = options.SOS;
1174
+ this.MOS = options.MOS;
1175
+ this.sequenceNumber = options.sequenceNumber;
1176
+ if (options.SOS)
1177
+ this.receiverEI = options.receiverEI;
1178
+ }
1179
+ static from(raw, ctx) {
1180
+ const securityManager = assertSecurityRX(ctx);
1181
+ (0, import_core.validatePayload)(raw.payload.length >= 2);
1182
+ const sequenceNumber = raw.payload[0];
1183
+ validateSequenceNumber(securityManager, ctx.sourceNodeId, sequenceNumber);
1184
+ const MOS = !!(raw.payload[1] & 2);
1185
+ const SOS = !!(raw.payload[1] & 1);
1186
+ if (SOS) {
1187
+ (0, import_core.validatePayload)(raw.payload.length >= 18);
1188
+ const receiverEI = raw.payload.subarray(2, 18);
1189
+ securityManager.storeRemoteEI(ctx.sourceNodeId, receiverEI);
1190
+ return new this({
1191
+ nodeId: ctx.sourceNodeId,
1192
+ sequenceNumber,
1193
+ MOS,
1194
+ SOS,
1195
+ receiverEI
1196
+ });
1197
+ } else if (MOS) {
1198
+ return new this({
1199
+ nodeId: ctx.sourceNodeId,
1200
+ sequenceNumber,
1201
+ MOS,
1202
+ SOS: false
1203
+ });
1204
+ } else {
1205
+ import_core.validatePayload.fail("Either MOS or SOS must be set");
1053
1206
  }
1054
- if (this.ciphertext) {
1055
- message.ciphertext = (0, import_safe3.buffer2hex)(this.ciphertext);
1056
- } else if (this.plaintext) {
1057
- message.plaintext = (0, import_safe3.buffer2hex)(this.plaintext);
1207
+ }
1208
+ sequenceNumber;
1209
+ ensureSequenceNumber(securityManager) {
1210
+ if (this.sequenceNumber == void 0) {
1211
+ this.sequenceNumber = securityManager.nextSequenceNumber(this.nodeId);
1058
1212
  }
1059
- if (this.authData) {
1060
- message["auth data"] = (0, import_safe3.buffer2hex)(this.authData);
1213
+ }
1214
+ SOS;
1215
+ MOS;
1216
+ receiverEI;
1217
+ serialize(ctx) {
1218
+ const securityManager = assertSecurityTX(ctx, this.nodeId);
1219
+ this.ensureSequenceNumber(securityManager);
1220
+ this.payload = import_safe2.Bytes.from([
1221
+ this.sequenceNumber,
1222
+ (this.MOS ? 2 : 0) + (this.SOS ? 1 : 0)
1223
+ ]);
1224
+ if (this.SOS) {
1225
+ this.payload = import_safe2.Bytes.concat([this.payload, this.receiverEI]);
1061
1226
  }
1062
- if (this.authTag) {
1063
- message["auth tag"] = (0, import_safe3.buffer2hex)(this.authTag);
1227
+ return super.serialize(ctx);
1228
+ }
1229
+ toLogEntry(ctx) {
1230
+ const message = {
1231
+ "sequence number": this.sequenceNumber ?? "(not set)",
1232
+ SOS: this.SOS,
1233
+ MOS: this.MOS
1234
+ };
1235
+ if (this.receiverEI) {
1236
+ message["receiver entropy"] = (0, import_safe3.buffer2hex)(this.receiverEI);
1064
1237
  }
1238
+ return {
1239
+ ...super.toLogEntry(ctx),
1240
+ message
1241
+ };
1065
1242
  }
1066
- if (this.securityClass != void 0) {
1067
- message["security class"] = (0, import_safe3.getEnumMemberName)(import_core.SecurityClass, this.securityClass);
1243
+ };
1244
+ return Security2CCNonceReport2 = _classThis;
1245
+ })();
1246
+ let Security2CCNonceGet = (() => {
1247
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NonceGet), (0, import_CommandClassDecorators.expectedCCResponse)(Security2CCNonceReport)];
1248
+ let _classDescriptor;
1249
+ let _classExtraInitializers = [];
1250
+ let _classThis;
1251
+ let _classSuper = Security2CC;
1252
+ var Security2CCNonceGet2 = class extends _classSuper {
1253
+ static {
1254
+ _classThis = this;
1068
1255
  }
1069
- return {
1070
- ...super.toLogEntry(ctx),
1071
- message
1072
- };
1073
- }
1074
- };
1075
- Security2CCMessageEncapsulation = Security2CCMessageEncapsulation_1 = __decorate([
1076
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.MessageEncapsulation),
1077
- (0, import_CommandClassDecorators.expectedCCResponse)(getCCResponseForMessageEncapsulation, testCCResponseForMessageEncapsulation)
1078
- ], Security2CCMessageEncapsulation);
1079
- let Security2CCNonceReport = Security2CCNonceReport_1 = class Security2CCNonceReport2 extends Security2CC {
1080
- constructor(options) {
1081
- super(options);
1082
- this.SOS = options.SOS;
1083
- this.MOS = options.MOS;
1084
- this.sequenceNumber = options.sequenceNumber;
1085
- if (options.SOS)
1086
- this.receiverEI = options.receiverEI;
1087
- }
1088
- static from(raw, ctx) {
1089
- const securityManager = assertSecurityRX(ctx);
1090
- (0, import_core.validatePayload)(raw.payload.length >= 2);
1091
- const sequenceNumber = raw.payload[0];
1092
- validateSequenceNumber(securityManager, ctx.sourceNodeId, sequenceNumber);
1093
- const MOS = !!(raw.payload[1] & 2);
1094
- const SOS = !!(raw.payload[1] & 1);
1095
- if (SOS) {
1096
- (0, import_core.validatePayload)(raw.payload.length >= 18);
1097
- const receiverEI = raw.payload.subarray(2, 18);
1098
- securityManager.storeRemoteEI(ctx.sourceNodeId, receiverEI);
1099
- return new Security2CCNonceReport_1({
1100
- nodeId: ctx.sourceNodeId,
1101
- sequenceNumber,
1102
- MOS,
1103
- SOS,
1104
- receiverEI
1105
- });
1106
- } else if (MOS) {
1107
- return new Security2CCNonceReport_1({
1256
+ static {
1257
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1258
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1259
+ Security2CCNonceGet2 = _classThis = _classDescriptor.value;
1260
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1261
+ __runInitializers(_classThis, _classExtraInitializers);
1262
+ }
1263
+ // TODO: A node sending this command MUST accept a delay up to <Previous Round-trip-time to peer node> +
1264
+ // 250 ms before receiving the Security 2 Nonce Report Command.
1265
+ constructor(options) {
1266
+ super(options);
1267
+ this.sequenceNumber = options.sequenceNumber;
1268
+ }
1269
+ static from(raw, ctx) {
1270
+ const securityManager = assertSecurityRX(ctx);
1271
+ (0, import_core.validatePayload)(raw.payload.length >= 1);
1272
+ const sequenceNumber = raw.payload[0];
1273
+ validateSequenceNumber(securityManager, ctx.sourceNodeId, sequenceNumber);
1274
+ return new this({
1108
1275
  nodeId: ctx.sourceNodeId,
1109
- sequenceNumber,
1110
- MOS,
1111
- SOS: false
1276
+ sequenceNumber
1112
1277
  });
1113
- } else {
1114
- import_core.validatePayload.fail("Either MOS or SOS must be set");
1115
1278
  }
1116
- }
1117
- sequenceNumber;
1118
- ensureSequenceNumber(securityManager) {
1119
- if (this.sequenceNumber == void 0) {
1120
- this.sequenceNumber = securityManager.nextSequenceNumber(this.nodeId);
1279
+ sequenceNumber;
1280
+ ensureSequenceNumber(securityManager) {
1281
+ if (this.sequenceNumber == void 0) {
1282
+ this.sequenceNumber = securityManager.nextSequenceNumber(this.nodeId);
1283
+ }
1121
1284
  }
1122
- }
1123
- SOS;
1124
- MOS;
1125
- receiverEI;
1126
- serialize(ctx) {
1127
- const securityManager = assertSecurityTX(ctx, this.nodeId);
1128
- this.ensureSequenceNumber(securityManager);
1129
- this.payload = import_safe2.Bytes.from([
1130
- this.sequenceNumber,
1131
- (this.MOS ? 2 : 0) + (this.SOS ? 1 : 0)
1132
- ]);
1133
- if (this.SOS) {
1134
- this.payload = import_safe2.Bytes.concat([this.payload, this.receiverEI]);
1135
- }
1136
- return super.serialize(ctx);
1137
- }
1138
- toLogEntry(ctx) {
1139
- const message = {
1140
- "sequence number": this.sequenceNumber ?? "(not set)",
1141
- SOS: this.SOS,
1142
- MOS: this.MOS
1143
- };
1144
- if (this.receiverEI) {
1145
- message["receiver entropy"] = (0, import_safe3.buffer2hex)(this.receiverEI);
1285
+ serialize(ctx) {
1286
+ const securityManager = assertSecurityTX(ctx, this.nodeId);
1287
+ this.ensureSequenceNumber(securityManager);
1288
+ this.payload = import_safe2.Bytes.from([this.sequenceNumber]);
1289
+ return super.serialize(ctx);
1146
1290
  }
1147
- return {
1148
- ...super.toLogEntry(ctx),
1149
- message
1150
- };
1151
- }
1152
- };
1153
- Security2CCNonceReport = Security2CCNonceReport_1 = __decorate([
1154
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NonceReport)
1155
- ], Security2CCNonceReport);
1156
- let Security2CCNonceGet = Security2CCNonceGet_1 = class Security2CCNonceGet2 extends Security2CC {
1157
- // TODO: A node sending this command MUST accept a delay up to <Previous Round-trip-time to peer node> +
1158
- // 250 ms before receiving the Security 2 Nonce Report Command.
1159
- constructor(options) {
1160
- super(options);
1161
- this.sequenceNumber = options.sequenceNumber;
1162
- }
1163
- static from(raw, ctx) {
1164
- const securityManager = assertSecurityRX(ctx);
1165
- (0, import_core.validatePayload)(raw.payload.length >= 1);
1166
- const sequenceNumber = raw.payload[0];
1167
- validateSequenceNumber(securityManager, ctx.sourceNodeId, sequenceNumber);
1168
- return new Security2CCNonceGet_1({
1169
- nodeId: ctx.sourceNodeId,
1170
- sequenceNumber
1171
- });
1172
- }
1173
- sequenceNumber;
1174
- ensureSequenceNumber(securityManager) {
1175
- if (this.sequenceNumber == void 0) {
1176
- this.sequenceNumber = securityManager.nextSequenceNumber(this.nodeId);
1291
+ toLogEntry(ctx) {
1292
+ return {
1293
+ ...super.toLogEntry(ctx),
1294
+ message: {
1295
+ "sequence number": this.sequenceNumber ?? "(not set)"
1296
+ }
1297
+ };
1177
1298
  }
1178
- }
1179
- serialize(ctx) {
1180
- const securityManager = assertSecurityTX(ctx, this.nodeId);
1181
- this.ensureSequenceNumber(securityManager);
1182
- this.payload = import_safe2.Bytes.from([this.sequenceNumber]);
1183
- return super.serialize(ctx);
1184
- }
1185
- toLogEntry(ctx) {
1186
- return {
1187
- ...super.toLogEntry(ctx),
1188
- message: {
1189
- "sequence number": this.sequenceNumber ?? "(not set)"
1190
- }
1191
- };
1192
- }
1193
- };
1194
- Security2CCNonceGet = Security2CCNonceGet_1 = __decorate([
1195
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NonceGet),
1196
- (0, import_CommandClassDecorators.expectedCCResponse)(Security2CCNonceReport)
1197
- ], Security2CCNonceGet);
1198
- let Security2CCKEXReport = Security2CCKEXReport_1 = class Security2CCKEXReport2 extends Security2CC {
1199
- constructor(options) {
1200
- super(options);
1201
- this.requestCSA = options.requestCSA;
1202
- this.echo = options.echo;
1203
- this._reserved = options._reserved ?? 0;
1204
- this.supportedKEXSchemes = options.supportedKEXSchemes;
1205
- this.supportedECDHProfiles = options.supportedECDHProfiles;
1206
- this.requestedKeys = options.requestedKeys;
1207
- }
1208
- static from(raw, ctx) {
1209
- (0, import_core.validatePayload)(raw.payload.length >= 4);
1210
- const requestCSA = !!(raw.payload[0] & 2);
1211
- const echo = !!(raw.payload[0] & 1);
1212
- const _reserved = raw.payload[0] & 252;
1213
- const supportedKEXSchemes = (0, import_core.parseBitMask)(raw.payload.subarray(1, 2), 0).filter((s) => s !== 0);
1214
- const supportedECDHProfiles = (0, import_core.parseBitMask)(raw.payload.subarray(2, 3), import_shared.ECDHProfiles.Curve25519);
1215
- const requestedKeys = (0, import_core.parseBitMask)(raw.payload.subarray(3, 4), import_core.SecurityClass.S2_Unauthenticated);
1216
- return new Security2CCKEXReport_1({
1217
- nodeId: ctx.sourceNodeId,
1218
- requestCSA,
1219
- echo,
1220
- _reserved,
1221
- supportedKEXSchemes,
1222
- supportedECDHProfiles,
1223
- requestedKeys
1224
- });
1225
- }
1226
- _reserved;
1227
- requestCSA;
1228
- echo;
1229
- supportedKEXSchemes;
1230
- supportedECDHProfiles;
1231
- requestedKeys;
1232
- serialize(ctx) {
1233
- this.payload = import_safe2.Bytes.concat([
1234
- import_safe2.Bytes.from([
1235
- this._reserved + (this.requestCSA ? 2 : 0) + (this.echo ? 1 : 0)
1236
- ]),
1237
- // The bit mask starts at 0, but bit 0 is not used
1238
- (0, import_core.encodeBitMask)(this.supportedKEXSchemes, 7, 0),
1239
- (0, import_core.encodeBitMask)(this.supportedECDHProfiles, 7, import_shared.ECDHProfiles.Curve25519),
1240
- (0, import_core.encodeBitMask)(this.requestedKeys, import_core.SecurityClass.S0_Legacy, import_core.SecurityClass.S2_Unauthenticated)
1241
- ]);
1242
- return super.serialize(ctx);
1243
- }
1244
- toLogEntry(ctx) {
1245
- return {
1246
- ...super.toLogEntry(ctx),
1247
- message: {
1248
- echo: this.echo,
1249
- "supported schemes": this.supportedKEXSchemes.map((s) => `
1299
+ };
1300
+ return Security2CCNonceGet2 = _classThis;
1301
+ })();
1302
+ let Security2CCKEXReport = (() => {
1303
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXReport)];
1304
+ let _classDescriptor;
1305
+ let _classExtraInitializers = [];
1306
+ let _classThis;
1307
+ let _classSuper = Security2CC;
1308
+ var Security2CCKEXReport2 = class extends _classSuper {
1309
+ static {
1310
+ _classThis = this;
1311
+ }
1312
+ static {
1313
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1314
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1315
+ Security2CCKEXReport2 = _classThis = _classDescriptor.value;
1316
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1317
+ __runInitializers(_classThis, _classExtraInitializers);
1318
+ }
1319
+ constructor(options) {
1320
+ super(options);
1321
+ this.requestCSA = options.requestCSA;
1322
+ this.echo = options.echo;
1323
+ this._reserved = options._reserved ?? 0;
1324
+ this.supportedKEXSchemes = options.supportedKEXSchemes;
1325
+ this.supportedECDHProfiles = options.supportedECDHProfiles;
1326
+ this.requestedKeys = options.requestedKeys;
1327
+ }
1328
+ static from(raw, ctx) {
1329
+ (0, import_core.validatePayload)(raw.payload.length >= 4);
1330
+ const requestCSA = !!(raw.payload[0] & 2);
1331
+ const echo = !!(raw.payload[0] & 1);
1332
+ const _reserved = raw.payload[0] & 252;
1333
+ const supportedKEXSchemes = (0, import_core.parseBitMask)(raw.payload.subarray(1, 2), 0).filter((s) => s !== 0);
1334
+ const supportedECDHProfiles = (0, import_core.parseBitMask)(raw.payload.subarray(2, 3), import_shared.ECDHProfiles.Curve25519);
1335
+ const requestedKeys = (0, import_core.parseBitMask)(raw.payload.subarray(3, 4), import_core.SecurityClass.S2_Unauthenticated);
1336
+ return new this({
1337
+ nodeId: ctx.sourceNodeId,
1338
+ requestCSA,
1339
+ echo,
1340
+ _reserved,
1341
+ supportedKEXSchemes,
1342
+ supportedECDHProfiles,
1343
+ requestedKeys
1344
+ });
1345
+ }
1346
+ _reserved;
1347
+ requestCSA;
1348
+ echo;
1349
+ supportedKEXSchemes;
1350
+ supportedECDHProfiles;
1351
+ requestedKeys;
1352
+ serialize(ctx) {
1353
+ this.payload = import_safe2.Bytes.concat([
1354
+ import_safe2.Bytes.from([
1355
+ this._reserved + (this.requestCSA ? 2 : 0) + (this.echo ? 1 : 0)
1356
+ ]),
1357
+ // The bit mask starts at 0, but bit 0 is not used
1358
+ (0, import_core.encodeBitMask)(this.supportedKEXSchemes, 7, 0),
1359
+ (0, import_core.encodeBitMask)(this.supportedECDHProfiles, 7, import_shared.ECDHProfiles.Curve25519),
1360
+ (0, import_core.encodeBitMask)(this.requestedKeys, import_core.SecurityClass.S0_Legacy, import_core.SecurityClass.S2_Unauthenticated)
1361
+ ]);
1362
+ return super.serialize(ctx);
1363
+ }
1364
+ toLogEntry(ctx) {
1365
+ return {
1366
+ ...super.toLogEntry(ctx),
1367
+ message: {
1368
+ echo: this.echo,
1369
+ "supported schemes": this.supportedKEXSchemes.map((s) => `
1250
1370
  \xB7 ${(0, import_safe3.getEnumMemberName)(import_shared.KEXSchemes, s)}`).join(""),
1251
- "supported ECDH profiles": this.supportedECDHProfiles.map((s) => `
1371
+ "supported ECDH profiles": this.supportedECDHProfiles.map((s) => `
1252
1372
  \xB7 ${(0, import_safe3.getEnumMemberName)(import_shared.ECDHProfiles, s)}`).join(""),
1253
- "CSA requested": this.requestCSA,
1254
- "requested security classes": this.requestedKeys.map((s) => `
1373
+ "CSA requested": this.requestCSA,
1374
+ "requested security classes": this.requestedKeys.map((s) => `
1255
1375
  \xB7 ${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, s)}`).join("")
1256
- }
1257
- };
1258
- }
1259
- };
1260
- Security2CCKEXReport = Security2CCKEXReport_1 = __decorate([
1261
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXReport)
1262
- ], Security2CCKEXReport);
1263
- let Security2CCKEXGet = class Security2CCKEXGet2 extends Security2CC {
1264
- };
1265
- Security2CCKEXGet = __decorate([
1266
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXGet),
1267
- (0, import_CommandClassDecorators.expectedCCResponse)(Security2CCKEXReport)
1268
- ], Security2CCKEXGet);
1376
+ }
1377
+ };
1378
+ }
1379
+ };
1380
+ return Security2CCKEXReport2 = _classThis;
1381
+ })();
1382
+ let Security2CCKEXGet = (() => {
1383
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXGet), (0, import_CommandClassDecorators.expectedCCResponse)(Security2CCKEXReport)];
1384
+ let _classDescriptor;
1385
+ let _classExtraInitializers = [];
1386
+ let _classThis;
1387
+ let _classSuper = Security2CC;
1388
+ var Security2CCKEXGet2 = class extends _classSuper {
1389
+ static {
1390
+ _classThis = this;
1391
+ }
1392
+ static {
1393
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1394
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1395
+ Security2CCKEXGet2 = _classThis = _classDescriptor.value;
1396
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1397
+ __runInitializers(_classThis, _classExtraInitializers);
1398
+ }
1399
+ };
1400
+ return Security2CCKEXGet2 = _classThis;
1401
+ })();
1269
1402
  function getExpectedResponseForKEXSet(sent) {
1270
1403
  if (sent.echo) {
1271
1404
  return [Security2CCKEXReport, Security2CCKEXFail];
@@ -1283,290 +1416,421 @@ function testExpectedResponseForKEXSet(sent, received) {
1283
1416
  }
1284
1417
  return false;
1285
1418
  }
1286
- let Security2CCKEXSet = Security2CCKEXSet_1 = class Security2CCKEXSet2 extends Security2CC {
1287
- constructor(options) {
1288
- super(options);
1289
- this.permitCSA = options.permitCSA;
1290
- this.echo = options.echo;
1291
- this._reserved = options._reserved ?? 0;
1292
- this.selectedKEXScheme = options.selectedKEXScheme;
1293
- this.selectedECDHProfile = options.selectedECDHProfile;
1294
- this.grantedKeys = options.grantedKeys;
1295
- }
1296
- static from(raw, ctx) {
1297
- (0, import_core.validatePayload)(raw.payload.length >= 4);
1298
- const _reserved = raw.payload[0] & 252;
1299
- const permitCSA = !!(raw.payload[0] & 2);
1300
- const echo = !!(raw.payload[0] & 1);
1301
- const selectedKEXSchemes = (0, import_core.parseBitMask)(raw.payload.subarray(1, 2), 0).filter((s) => s !== 0);
1302
- (0, import_core.validatePayload)(selectedKEXSchemes.length === 1);
1303
- const selectedKEXScheme = selectedKEXSchemes[0];
1304
- const selectedECDHProfiles = (0, import_core.parseBitMask)(raw.payload.subarray(2, 3), import_shared.ECDHProfiles.Curve25519);
1305
- (0, import_core.validatePayload)(selectedECDHProfiles.length === 1);
1306
- const selectedECDHProfile = selectedECDHProfiles[0];
1307
- const grantedKeys = (0, import_core.parseBitMask)(raw.payload.subarray(3, 4), import_core.SecurityClass.S2_Unauthenticated);
1308
- return new Security2CCKEXSet_1({
1309
- nodeId: ctx.sourceNodeId,
1310
- _reserved,
1311
- permitCSA,
1312
- echo,
1313
- selectedKEXScheme,
1314
- selectedECDHProfile,
1315
- grantedKeys
1316
- });
1317
- }
1318
- _reserved;
1319
- permitCSA;
1320
- echo;
1321
- selectedKEXScheme;
1322
- selectedECDHProfile;
1323
- grantedKeys;
1324
- serialize(ctx) {
1325
- this.payload = import_safe2.Bytes.concat([
1326
- import_safe2.Bytes.from([
1327
- this._reserved + (this.permitCSA ? 2 : 0) + (this.echo ? 1 : 0)
1328
- ]),
1329
- // The bit mask starts at 0, but bit 0 is not used
1330
- (0, import_core.encodeBitMask)([this.selectedKEXScheme], 7, 0),
1331
- (0, import_core.encodeBitMask)([this.selectedECDHProfile], 7, import_shared.ECDHProfiles.Curve25519),
1332
- (0, import_core.encodeBitMask)(this.grantedKeys, import_core.SecurityClass.S0_Legacy, import_core.SecurityClass.S2_Unauthenticated)
1333
- ]);
1334
- return super.serialize(ctx);
1335
- }
1336
- toLogEntry(ctx) {
1337
- return {
1338
- ...super.toLogEntry(ctx),
1339
- message: {
1340
- echo: this.echo,
1341
- "selected scheme": (0, import_safe3.getEnumMemberName)(import_shared.KEXSchemes, this.selectedKEXScheme),
1342
- "selected ECDH profile": (0, import_safe3.getEnumMemberName)(import_shared.ECDHProfiles, this.selectedECDHProfile),
1343
- "CSA permitted": this.permitCSA,
1344
- "granted security classes": this.grantedKeys.map((s) => `
1419
+ let Security2CCKEXSet = (() => {
1420
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXSet), (0, import_CommandClassDecorators.expectedCCResponse)(getExpectedResponseForKEXSet, testExpectedResponseForKEXSet)];
1421
+ let _classDescriptor;
1422
+ let _classExtraInitializers = [];
1423
+ let _classThis;
1424
+ let _classSuper = Security2CC;
1425
+ var Security2CCKEXSet2 = class extends _classSuper {
1426
+ static {
1427
+ _classThis = this;
1428
+ }
1429
+ static {
1430
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1431
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1432
+ Security2CCKEXSet2 = _classThis = _classDescriptor.value;
1433
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1434
+ __runInitializers(_classThis, _classExtraInitializers);
1435
+ }
1436
+ constructor(options) {
1437
+ super(options);
1438
+ this.permitCSA = options.permitCSA;
1439
+ this.echo = options.echo;
1440
+ this._reserved = options._reserved ?? 0;
1441
+ this.selectedKEXScheme = options.selectedKEXScheme;
1442
+ this.selectedECDHProfile = options.selectedECDHProfile;
1443
+ this.grantedKeys = options.grantedKeys;
1444
+ }
1445
+ static from(raw, ctx) {
1446
+ (0, import_core.validatePayload)(raw.payload.length >= 4);
1447
+ const _reserved = raw.payload[0] & 252;
1448
+ const permitCSA = !!(raw.payload[0] & 2);
1449
+ const echo = !!(raw.payload[0] & 1);
1450
+ const selectedKEXSchemes = (0, import_core.parseBitMask)(raw.payload.subarray(1, 2), 0).filter((s) => s !== 0);
1451
+ (0, import_core.validatePayload)(selectedKEXSchemes.length === 1);
1452
+ const selectedKEXScheme = selectedKEXSchemes[0];
1453
+ const selectedECDHProfiles = (0, import_core.parseBitMask)(raw.payload.subarray(2, 3), import_shared.ECDHProfiles.Curve25519);
1454
+ (0, import_core.validatePayload)(selectedECDHProfiles.length === 1);
1455
+ const selectedECDHProfile = selectedECDHProfiles[0];
1456
+ const grantedKeys = (0, import_core.parseBitMask)(raw.payload.subarray(3, 4), import_core.SecurityClass.S2_Unauthenticated);
1457
+ return new this({
1458
+ nodeId: ctx.sourceNodeId,
1459
+ _reserved,
1460
+ permitCSA,
1461
+ echo,
1462
+ selectedKEXScheme,
1463
+ selectedECDHProfile,
1464
+ grantedKeys
1465
+ });
1466
+ }
1467
+ _reserved;
1468
+ permitCSA;
1469
+ echo;
1470
+ selectedKEXScheme;
1471
+ selectedECDHProfile;
1472
+ grantedKeys;
1473
+ serialize(ctx) {
1474
+ this.payload = import_safe2.Bytes.concat([
1475
+ import_safe2.Bytes.from([
1476
+ this._reserved + (this.permitCSA ? 2 : 0) + (this.echo ? 1 : 0)
1477
+ ]),
1478
+ // The bit mask starts at 0, but bit 0 is not used
1479
+ (0, import_core.encodeBitMask)([this.selectedKEXScheme], 7, 0),
1480
+ (0, import_core.encodeBitMask)([this.selectedECDHProfile], 7, import_shared.ECDHProfiles.Curve25519),
1481
+ (0, import_core.encodeBitMask)(this.grantedKeys, import_core.SecurityClass.S0_Legacy, import_core.SecurityClass.S2_Unauthenticated)
1482
+ ]);
1483
+ return super.serialize(ctx);
1484
+ }
1485
+ toLogEntry(ctx) {
1486
+ return {
1487
+ ...super.toLogEntry(ctx),
1488
+ message: {
1489
+ echo: this.echo,
1490
+ "selected scheme": (0, import_safe3.getEnumMemberName)(import_shared.KEXSchemes, this.selectedKEXScheme),
1491
+ "selected ECDH profile": (0, import_safe3.getEnumMemberName)(import_shared.ECDHProfiles, this.selectedECDHProfile),
1492
+ "CSA permitted": this.permitCSA,
1493
+ "granted security classes": this.grantedKeys.map((s) => `
1345
1494
  \xB7 ${(0, import_safe3.getEnumMemberName)(import_core.SecurityClass, s)}`).join("")
1346
- }
1347
- };
1348
- }
1349
- };
1350
- Security2CCKEXSet = Security2CCKEXSet_1 = __decorate([
1351
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXSet),
1352
- (0, import_CommandClassDecorators.expectedCCResponse)(getExpectedResponseForKEXSet, testExpectedResponseForKEXSet)
1353
- ], Security2CCKEXSet);
1354
- let Security2CCKEXFail = Security2CCKEXFail_1 = class Security2CCKEXFail2 extends Security2CC {
1355
- constructor(options) {
1356
- super(options);
1357
- this.failType = options.failType;
1358
- }
1359
- static from(raw, ctx) {
1360
- (0, import_core.validatePayload)(raw.payload.length >= 1);
1361
- const failType = raw.payload[0];
1362
- return new Security2CCKEXFail_1({
1363
- nodeId: ctx.sourceNodeId,
1364
- failType
1365
- });
1366
- }
1367
- failType;
1368
- serialize(ctx) {
1369
- this.payload = import_safe2.Bytes.from([this.failType]);
1370
- return super.serialize(ctx);
1371
- }
1372
- toLogEntry(ctx) {
1373
- return {
1374
- ...super.toLogEntry(ctx),
1375
- message: { reason: (0, import_safe3.getEnumMemberName)(import_shared.KEXFailType, this.failType) }
1376
- };
1377
- }
1378
- };
1379
- Security2CCKEXFail = Security2CCKEXFail_1 = __decorate([
1380
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXFail)
1381
- ], Security2CCKEXFail);
1382
- let Security2CCPublicKeyReport = Security2CCPublicKeyReport_1 = class Security2CCPublicKeyReport2 extends Security2CC {
1383
- constructor(options) {
1384
- super(options);
1385
- this.includingNode = options.includingNode;
1386
- this.publicKey = options.publicKey;
1387
- }
1388
- static from(raw, ctx) {
1389
- (0, import_core.validatePayload)(raw.payload.length >= 17);
1390
- const includingNode = !!(raw.payload[0] & 1);
1391
- const publicKey = raw.payload.subarray(1);
1392
- return new Security2CCPublicKeyReport_1({
1393
- nodeId: ctx.sourceNodeId,
1394
- includingNode,
1395
- publicKey
1396
- });
1397
- }
1398
- includingNode;
1399
- publicKey;
1400
- serialize(ctx) {
1401
- this.payload = import_safe2.Bytes.concat([
1402
- import_safe2.Bytes.from([this.includingNode ? 1 : 0]),
1403
- this.publicKey
1404
- ]);
1405
- return super.serialize(ctx);
1406
- }
1407
- toLogEntry(ctx) {
1408
- return {
1409
- ...super.toLogEntry(ctx),
1410
- message: {
1411
- "is including node": this.includingNode,
1412
- "public key": (0, import_safe3.buffer2hex)(this.publicKey)
1413
- }
1414
- };
1415
- }
1416
- };
1417
- Security2CCPublicKeyReport = Security2CCPublicKeyReport_1 = __decorate([
1418
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.PublicKeyReport)
1419
- ], Security2CCPublicKeyReport);
1420
- let Security2CCNetworkKeyReport = Security2CCNetworkKeyReport_1 = class Security2CCNetworkKeyReport2 extends Security2CC {
1421
- constructor(options) {
1422
- super(options);
1423
- this.grantedKey = options.grantedKey;
1424
- this.networkKey = options.networkKey;
1425
- }
1426
- static from(raw, ctx) {
1427
- (0, import_core.validatePayload)(raw.payload.length >= 17);
1428
- const grantedKey = bitMaskToSecurityClass(raw.payload, 0);
1429
- const networkKey = raw.payload.subarray(1, 17);
1430
- return new Security2CCNetworkKeyReport_1({
1431
- nodeId: ctx.sourceNodeId,
1432
- grantedKey,
1433
- networkKey
1434
- });
1435
- }
1436
- grantedKey;
1437
- networkKey;
1438
- serialize(ctx) {
1439
- this.payload = import_safe2.Bytes.concat([
1440
- securityClassToBitMask(this.grantedKey),
1441
- this.networkKey
1442
- ]);
1443
- return super.serialize(ctx);
1444
- }
1445
- toLogEntry(ctx) {
1446
- return {
1447
- ...super.toLogEntry(ctx),
1448
- message: {
1449
- "security class": (0, import_safe3.getEnumMemberName)(import_core.SecurityClass, this.grantedKey)
1450
- // This shouldn't be logged, so users can safely post their logs online
1451
- // "network key": buffer2hex(this.networkKey),
1452
- }
1453
- };
1454
- }
1455
- };
1456
- Security2CCNetworkKeyReport = Security2CCNetworkKeyReport_1 = __decorate([
1457
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NetworkKeyReport)
1458
- ], Security2CCNetworkKeyReport);
1459
- let Security2CCNetworkKeyGet = Security2CCNetworkKeyGet_1 = class Security2CCNetworkKeyGet2 extends Security2CC {
1460
- constructor(options) {
1461
- super(options);
1462
- this.requestedKey = options.requestedKey;
1463
- }
1464
- static from(raw, ctx) {
1465
- (0, import_core.validatePayload)(raw.payload.length >= 1);
1466
- const requestedKey = bitMaskToSecurityClass(raw.payload, 0);
1467
- return new Security2CCNetworkKeyGet_1({
1468
- nodeId: ctx.sourceNodeId,
1469
- requestedKey
1470
- });
1471
- }
1472
- requestedKey;
1473
- serialize(ctx) {
1474
- this.payload = securityClassToBitMask(this.requestedKey);
1475
- return super.serialize(ctx);
1476
- }
1477
- toLogEntry(ctx) {
1478
- return {
1479
- ...super.toLogEntry(ctx),
1480
- message: {
1481
- "security class": (0, import_safe3.getEnumMemberName)(import_core.SecurityClass, this.requestedKey)
1482
- }
1483
- };
1484
- }
1485
- };
1486
- Security2CCNetworkKeyGet = Security2CCNetworkKeyGet_1 = __decorate([
1487
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NetworkKeyGet)
1488
- // Don't expect a response - we need to distinguish between Report and Fail
1489
- // FIXME: maybe use the dynamic @expectedCCResponse instead?
1490
- ], Security2CCNetworkKeyGet);
1491
- let Security2CCNetworkKeyVerify = class Security2CCNetworkKeyVerify2 extends Security2CC {
1492
- };
1493
- Security2CCNetworkKeyVerify = __decorate([
1494
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NetworkKeyVerify)
1495
- ], Security2CCNetworkKeyVerify);
1496
- let Security2CCTransferEnd = Security2CCTransferEnd_1 = class Security2CCTransferEnd2 extends Security2CC {
1497
- constructor(options) {
1498
- super(options);
1499
- this.keyVerified = options.keyVerified;
1500
- this.keyRequestComplete = options.keyRequestComplete;
1501
- }
1502
- static from(raw, ctx) {
1503
- (0, import_core.validatePayload)(raw.payload.length >= 1);
1504
- const keyVerified = !!(raw.payload[0] & 2);
1505
- const keyRequestComplete = !!(raw.payload[0] & 1);
1506
- return new Security2CCTransferEnd_1({
1507
- nodeId: ctx.sourceNodeId,
1508
- keyVerified,
1509
- keyRequestComplete
1510
- });
1511
- }
1512
- keyVerified;
1513
- keyRequestComplete;
1514
- serialize(ctx) {
1515
- this.payload = import_safe2.Bytes.from([
1516
- (this.keyVerified ? 2 : 0) + (this.keyRequestComplete ? 1 : 0)
1517
- ]);
1518
- return super.serialize(ctx);
1519
- }
1520
- toLogEntry(ctx) {
1521
- return {
1522
- ...super.toLogEntry(ctx),
1523
- message: {
1524
- "key verified": this.keyVerified,
1525
- "request complete": this.keyRequestComplete
1526
- }
1527
- };
1528
- }
1529
- };
1530
- Security2CCTransferEnd = Security2CCTransferEnd_1 = __decorate([
1531
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.TransferEnd)
1532
- ], Security2CCTransferEnd);
1533
- let Security2CCCommandsSupportedReport = Security2CCCommandsSupportedReport_1 = class Security2CCCommandsSupportedReport2 extends Security2CC {
1534
- constructor(options) {
1535
- super(options);
1536
- this.supportedCCs = options.supportedCCs;
1537
- }
1538
- static from(raw, ctx) {
1539
- const CCs = (0, import_core.parseCCList)(raw.payload);
1540
- const supportedCCs = CCs.supportedCCs;
1541
- return new Security2CCCommandsSupportedReport_1({
1542
- nodeId: ctx.sourceNodeId,
1543
- supportedCCs
1544
- });
1545
- }
1546
- supportedCCs;
1547
- serialize(ctx) {
1548
- this.payload = (0, import_safe.encodeCCList)(this.supportedCCs, []);
1549
- return super.serialize(ctx);
1550
- }
1551
- toLogEntry(ctx) {
1552
- return {
1553
- ...super.toLogEntry(ctx),
1554
- message: {
1555
- "supported CCs": this.supportedCCs.map((cc) => (0, import_core.getCCName)(cc)).map((cc) => `
1495
+ }
1496
+ };
1497
+ }
1498
+ };
1499
+ return Security2CCKEXSet2 = _classThis;
1500
+ })();
1501
+ let Security2CCKEXFail = (() => {
1502
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.KEXFail)];
1503
+ let _classDescriptor;
1504
+ let _classExtraInitializers = [];
1505
+ let _classThis;
1506
+ let _classSuper = Security2CC;
1507
+ var Security2CCKEXFail2 = class extends _classSuper {
1508
+ static {
1509
+ _classThis = this;
1510
+ }
1511
+ static {
1512
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1513
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1514
+ Security2CCKEXFail2 = _classThis = _classDescriptor.value;
1515
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1516
+ __runInitializers(_classThis, _classExtraInitializers);
1517
+ }
1518
+ constructor(options) {
1519
+ super(options);
1520
+ this.failType = options.failType;
1521
+ }
1522
+ static from(raw, ctx) {
1523
+ (0, import_core.validatePayload)(raw.payload.length >= 1);
1524
+ const failType = raw.payload[0];
1525
+ return new this({
1526
+ nodeId: ctx.sourceNodeId,
1527
+ failType
1528
+ });
1529
+ }
1530
+ failType;
1531
+ serialize(ctx) {
1532
+ this.payload = import_safe2.Bytes.from([this.failType]);
1533
+ return super.serialize(ctx);
1534
+ }
1535
+ toLogEntry(ctx) {
1536
+ return {
1537
+ ...super.toLogEntry(ctx),
1538
+ message: { reason: (0, import_safe3.getEnumMemberName)(import_shared.KEXFailType, this.failType) }
1539
+ };
1540
+ }
1541
+ };
1542
+ return Security2CCKEXFail2 = _classThis;
1543
+ })();
1544
+ let Security2CCPublicKeyReport = (() => {
1545
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.PublicKeyReport)];
1546
+ let _classDescriptor;
1547
+ let _classExtraInitializers = [];
1548
+ let _classThis;
1549
+ let _classSuper = Security2CC;
1550
+ var Security2CCPublicKeyReport2 = class extends _classSuper {
1551
+ static {
1552
+ _classThis = this;
1553
+ }
1554
+ static {
1555
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1556
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1557
+ Security2CCPublicKeyReport2 = _classThis = _classDescriptor.value;
1558
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1559
+ __runInitializers(_classThis, _classExtraInitializers);
1560
+ }
1561
+ constructor(options) {
1562
+ super(options);
1563
+ this.includingNode = options.includingNode;
1564
+ this.publicKey = options.publicKey;
1565
+ }
1566
+ static from(raw, ctx) {
1567
+ (0, import_core.validatePayload)(raw.payload.length >= 17);
1568
+ const includingNode = !!(raw.payload[0] & 1);
1569
+ const publicKey = raw.payload.subarray(1);
1570
+ return new this({
1571
+ nodeId: ctx.sourceNodeId,
1572
+ includingNode,
1573
+ publicKey
1574
+ });
1575
+ }
1576
+ includingNode;
1577
+ publicKey;
1578
+ serialize(ctx) {
1579
+ this.payload = import_safe2.Bytes.concat([
1580
+ import_safe2.Bytes.from([this.includingNode ? 1 : 0]),
1581
+ this.publicKey
1582
+ ]);
1583
+ return super.serialize(ctx);
1584
+ }
1585
+ toLogEntry(ctx) {
1586
+ return {
1587
+ ...super.toLogEntry(ctx),
1588
+ message: {
1589
+ "is including node": this.includingNode,
1590
+ "public key": (0, import_safe3.buffer2hex)(this.publicKey)
1591
+ }
1592
+ };
1593
+ }
1594
+ };
1595
+ return Security2CCPublicKeyReport2 = _classThis;
1596
+ })();
1597
+ let Security2CCNetworkKeyReport = (() => {
1598
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NetworkKeyReport)];
1599
+ let _classDescriptor;
1600
+ let _classExtraInitializers = [];
1601
+ let _classThis;
1602
+ let _classSuper = Security2CC;
1603
+ var Security2CCNetworkKeyReport2 = class extends _classSuper {
1604
+ static {
1605
+ _classThis = this;
1606
+ }
1607
+ static {
1608
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1609
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1610
+ Security2CCNetworkKeyReport2 = _classThis = _classDescriptor.value;
1611
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1612
+ __runInitializers(_classThis, _classExtraInitializers);
1613
+ }
1614
+ constructor(options) {
1615
+ super(options);
1616
+ this.grantedKey = options.grantedKey;
1617
+ this.networkKey = options.networkKey;
1618
+ }
1619
+ static from(raw, ctx) {
1620
+ (0, import_core.validatePayload)(raw.payload.length >= 17);
1621
+ const grantedKey = bitMaskToSecurityClass(raw.payload, 0);
1622
+ const networkKey = raw.payload.subarray(1, 17);
1623
+ return new this({
1624
+ nodeId: ctx.sourceNodeId,
1625
+ grantedKey,
1626
+ networkKey
1627
+ });
1628
+ }
1629
+ grantedKey;
1630
+ networkKey;
1631
+ serialize(ctx) {
1632
+ this.payload = import_safe2.Bytes.concat([
1633
+ securityClassToBitMask(this.grantedKey),
1634
+ this.networkKey
1635
+ ]);
1636
+ return super.serialize(ctx);
1637
+ }
1638
+ toLogEntry(ctx) {
1639
+ return {
1640
+ ...super.toLogEntry(ctx),
1641
+ message: {
1642
+ "security class": (0, import_safe3.getEnumMemberName)(import_core.SecurityClass, this.grantedKey)
1643
+ // This shouldn't be logged, so users can safely post their logs online
1644
+ // "network key": buffer2hex(this.networkKey),
1645
+ }
1646
+ };
1647
+ }
1648
+ };
1649
+ return Security2CCNetworkKeyReport2 = _classThis;
1650
+ })();
1651
+ let Security2CCNetworkKeyGet = (() => {
1652
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NetworkKeyGet)];
1653
+ let _classDescriptor;
1654
+ let _classExtraInitializers = [];
1655
+ let _classThis;
1656
+ let _classSuper = Security2CC;
1657
+ var Security2CCNetworkKeyGet2 = class extends _classSuper {
1658
+ static {
1659
+ _classThis = this;
1660
+ }
1661
+ static {
1662
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1663
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1664
+ Security2CCNetworkKeyGet2 = _classThis = _classDescriptor.value;
1665
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1666
+ __runInitializers(_classThis, _classExtraInitializers);
1667
+ }
1668
+ constructor(options) {
1669
+ super(options);
1670
+ this.requestedKey = options.requestedKey;
1671
+ }
1672
+ static from(raw, ctx) {
1673
+ (0, import_core.validatePayload)(raw.payload.length >= 1);
1674
+ const requestedKey = bitMaskToSecurityClass(raw.payload, 0);
1675
+ return new this({
1676
+ nodeId: ctx.sourceNodeId,
1677
+ requestedKey
1678
+ });
1679
+ }
1680
+ requestedKey;
1681
+ serialize(ctx) {
1682
+ this.payload = securityClassToBitMask(this.requestedKey);
1683
+ return super.serialize(ctx);
1684
+ }
1685
+ toLogEntry(ctx) {
1686
+ return {
1687
+ ...super.toLogEntry(ctx),
1688
+ message: {
1689
+ "security class": (0, import_safe3.getEnumMemberName)(import_core.SecurityClass, this.requestedKey)
1690
+ }
1691
+ };
1692
+ }
1693
+ };
1694
+ return Security2CCNetworkKeyGet2 = _classThis;
1695
+ })();
1696
+ let Security2CCNetworkKeyVerify = (() => {
1697
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.NetworkKeyVerify)];
1698
+ let _classDescriptor;
1699
+ let _classExtraInitializers = [];
1700
+ let _classThis;
1701
+ let _classSuper = Security2CC;
1702
+ var Security2CCNetworkKeyVerify2 = class extends _classSuper {
1703
+ static {
1704
+ _classThis = this;
1705
+ }
1706
+ static {
1707
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1708
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1709
+ Security2CCNetworkKeyVerify2 = _classThis = _classDescriptor.value;
1710
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1711
+ __runInitializers(_classThis, _classExtraInitializers);
1712
+ }
1713
+ };
1714
+ return Security2CCNetworkKeyVerify2 = _classThis;
1715
+ })();
1716
+ let Security2CCTransferEnd = (() => {
1717
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.TransferEnd)];
1718
+ let _classDescriptor;
1719
+ let _classExtraInitializers = [];
1720
+ let _classThis;
1721
+ let _classSuper = Security2CC;
1722
+ var Security2CCTransferEnd2 = class extends _classSuper {
1723
+ static {
1724
+ _classThis = this;
1725
+ }
1726
+ static {
1727
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1728
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1729
+ Security2CCTransferEnd2 = _classThis = _classDescriptor.value;
1730
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1731
+ __runInitializers(_classThis, _classExtraInitializers);
1732
+ }
1733
+ constructor(options) {
1734
+ super(options);
1735
+ this.keyVerified = options.keyVerified;
1736
+ this.keyRequestComplete = options.keyRequestComplete;
1737
+ }
1738
+ static from(raw, ctx) {
1739
+ (0, import_core.validatePayload)(raw.payload.length >= 1);
1740
+ const keyVerified = !!(raw.payload[0] & 2);
1741
+ const keyRequestComplete = !!(raw.payload[0] & 1);
1742
+ return new this({
1743
+ nodeId: ctx.sourceNodeId,
1744
+ keyVerified,
1745
+ keyRequestComplete
1746
+ });
1747
+ }
1748
+ keyVerified;
1749
+ keyRequestComplete;
1750
+ serialize(ctx) {
1751
+ this.payload = import_safe2.Bytes.from([
1752
+ (this.keyVerified ? 2 : 0) + (this.keyRequestComplete ? 1 : 0)
1753
+ ]);
1754
+ return super.serialize(ctx);
1755
+ }
1756
+ toLogEntry(ctx) {
1757
+ return {
1758
+ ...super.toLogEntry(ctx),
1759
+ message: {
1760
+ "key verified": this.keyVerified,
1761
+ "request complete": this.keyRequestComplete
1762
+ }
1763
+ };
1764
+ }
1765
+ };
1766
+ return Security2CCTransferEnd2 = _classThis;
1767
+ })();
1768
+ let Security2CCCommandsSupportedReport = (() => {
1769
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.CommandsSupportedReport)];
1770
+ let _classDescriptor;
1771
+ let _classExtraInitializers = [];
1772
+ let _classThis;
1773
+ let _classSuper = Security2CC;
1774
+ var Security2CCCommandsSupportedReport2 = class extends _classSuper {
1775
+ static {
1776
+ _classThis = this;
1777
+ }
1778
+ static {
1779
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1780
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1781
+ Security2CCCommandsSupportedReport2 = _classThis = _classDescriptor.value;
1782
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1783
+ __runInitializers(_classThis, _classExtraInitializers);
1784
+ }
1785
+ constructor(options) {
1786
+ super(options);
1787
+ this.supportedCCs = options.supportedCCs;
1788
+ }
1789
+ static from(raw, ctx) {
1790
+ const CCs = (0, import_core.parseCCList)(raw.payload);
1791
+ const supportedCCs = CCs.supportedCCs;
1792
+ return new this({
1793
+ nodeId: ctx.sourceNodeId,
1794
+ supportedCCs
1795
+ });
1796
+ }
1797
+ supportedCCs;
1798
+ serialize(ctx) {
1799
+ this.payload = (0, import_safe.encodeCCList)(this.supportedCCs, []);
1800
+ return super.serialize(ctx);
1801
+ }
1802
+ toLogEntry(ctx) {
1803
+ return {
1804
+ ...super.toLogEntry(ctx),
1805
+ message: {
1806
+ "supported CCs": this.supportedCCs.map((cc) => (0, import_core.getCCName)(cc)).map((cc) => `
1556
1807
  \xB7 ${cc}`).join("")
1557
- }
1558
- };
1559
- }
1560
- };
1561
- Security2CCCommandsSupportedReport = Security2CCCommandsSupportedReport_1 = __decorate([
1562
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.CommandsSupportedReport)
1563
- ], Security2CCCommandsSupportedReport);
1564
- let Security2CCCommandsSupportedGet = class Security2CCCommandsSupportedGet2 extends Security2CC {
1565
- };
1566
- Security2CCCommandsSupportedGet = __decorate([
1567
- (0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.CommandsSupportedGet),
1568
- (0, import_CommandClassDecorators.expectedCCResponse)(Security2CCCommandsSupportedReport)
1569
- ], Security2CCCommandsSupportedGet);
1808
+ }
1809
+ };
1810
+ }
1811
+ };
1812
+ return Security2CCCommandsSupportedReport2 = _classThis;
1813
+ })();
1814
+ let Security2CCCommandsSupportedGet = (() => {
1815
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.Security2Command.CommandsSupportedGet), (0, import_CommandClassDecorators.expectedCCResponse)(Security2CCCommandsSupportedReport)];
1816
+ let _classDescriptor;
1817
+ let _classExtraInitializers = [];
1818
+ let _classThis;
1819
+ let _classSuper = Security2CC;
1820
+ var Security2CCCommandsSupportedGet2 = class extends _classSuper {
1821
+ static {
1822
+ _classThis = this;
1823
+ }
1824
+ static {
1825
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1826
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
1827
+ Security2CCCommandsSupportedGet2 = _classThis = _classDescriptor.value;
1828
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1829
+ __runInitializers(_classThis, _classExtraInitializers);
1830
+ }
1831
+ };
1832
+ return Security2CCCommandsSupportedGet2 = _classThis;
1833
+ })();
1570
1834
  // Annotate the CommonJS export names for ESM import in node:
1571
1835
  0 && (module.exports = {
1572
1836
  Security2CC,