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