zwave-js 14.2.0 → 14.3.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.
@@ -1,7 +1,7 @@
1
1
  import { JsonlDB } from "@alcalzone/jsonl-db";
2
2
  import { CRC16CC, CRC16CCCommandEncapsulation, CommandClass, InvalidCC, KEXFailType, MultiChannelCC, NoOperationCC, Security2CC, Security2CCCommandsSupportedGet, Security2CCCommandsSupportedReport, Security2CCMessageEncapsulation, Security2CCNonceReport, Security2Command, SecurityCC, SecurityCCCommandEncapsulation, SecurityCCCommandEncapsulationNonceGet, SecurityCCCommandsSupportedGet, SecurityCCCommandsSupportedReport, SecurityCommand, SupervisionCC, SupervisionCCReport, TransportServiceCC, TransportServiceCCFirstSegment, TransportServiceCCSegmentComplete, TransportServiceCCSegmentRequest, TransportServiceCCSegmentWait, TransportServiceTimeouts, VersionCommand, WakeUpCCNoMoreInformation, WakeUpCCValues, getImplementedVersion, isEncapsulatingCommandClass, isMultiEncapsulatingCommandClass, isTransportServiceEncapsulation, } from "@zwave-js/cc";
3
3
  import { ConfigManager } from "@zwave-js/config";
4
- import { CommandClasses, ControllerLogger, ControllerRole, ControllerStatus, Duration, EncapsulationFlags, MAX_SUPERVISION_SESSION_ID, MAX_TRANSPORT_SERVICE_SESSION_ID, MPANState, MessagePriority, NUM_NODEMASK_BYTES, NodeIDType, RFRegion, SPANState, SecurityClass, SecurityManager, SecurityManager2, SupervisionStatus, TransactionState, TransmitOptions, TransmitStatus, ZWaveError, ZWaveErrorCodes, ZWaveLogContainer, deserializeCacheValue, extractRawECDHPrivateKey, generateECDHKeyPair, getCCName, highResTimestamp, isEncapsulationCC, isLongRangeNodeId, isMissingControllerACK, isMissingControllerCallback, isMissingControllerResponse, isZWaveError, keyPairFromRawECDHPrivateKey, messageRecordToLines, securityClassIsS2, securityClassOrder, serializeCacheValue, stripUndefined, timespan, wasControllerReset, } from "@zwave-js/core";
4
+ import { CommandClasses, ControllerLogger, ControllerRole, ControllerStatus, Duration, EncapsulationFlags, MAX_SUPERVISION_SESSION_ID, MAX_TRANSPORT_SERVICE_SESSION_ID, MPANState, MessagePriority, NUM_NODEMASK_BYTES, NodeIDType, RFRegion, SPANState, SecurityClass, SecurityManager, SecurityManager2, SupervisionStatus, TransactionState, TransmitOptions, TransmitStatus, ZWaveError, ZWaveErrorCodes, ZWaveLogContainer, deserializeCacheValue, extractRawECDHPrivateKeySync, generateECDHKeyPairSync, getCCName, highResTimestamp, isEncapsulationCC, isLongRangeNodeId, isMissingControllerACK, isMissingControllerCallback, isMissingControllerResponse, isZWaveError, keyPairFromRawECDHPrivateKeySync, messageRecordToLines, securityClassIsS2, securityClassOrder, serializeCacheValue, stripUndefined, timespan, wasControllerReset, } from "@zwave-js/core";
5
5
  import { BootloaderChunkType, FunctionType, Message, MessageHeaders, MessageType, XModemMessageHeaders, ZWaveSerialMode, ZWaveSerialPort, ZWaveSerialPortBase, ZWaveSocket, getDefaultPriority, hasNodeId, isSuccessIndicator, isZWaveSerialPortImplementation, } from "@zwave-js/serial";
6
6
  import { ApplicationUpdateRequest } from "@zwave-js/serial/serialapi";
7
7
  import { SerialAPIStartedRequest, SerialAPIWakeUpReason, } from "@zwave-js/serial/serialapi";
@@ -517,12 +517,12 @@ export class Driver extends TypedEventEmitter {
517
517
  const privateKey = this.cacheGet(cacheKeys.controller.privateKey);
518
518
  if (privateKey) {
519
519
  this._learnModeAuthenticatedKeyPair =
520
- keyPairFromRawECDHPrivateKey(privateKey);
520
+ keyPairFromRawECDHPrivateKeySync(privateKey);
521
521
  }
522
522
  else {
523
523
  // Not found in cache, create a new one and cache it
524
- this._learnModeAuthenticatedKeyPair = generateECDHKeyPair();
525
- this.cacheSet(cacheKeys.controller.privateKey, extractRawECDHPrivateKey(this._learnModeAuthenticatedKeyPair.privateKey));
524
+ this._learnModeAuthenticatedKeyPair = generateECDHKeyPairSync();
525
+ this.cacheSet(cacheKeys.controller.privateKey, extractRawECDHPrivateKeySync(this._learnModeAuthenticatedKeyPair.privateKey));
526
526
  }
527
527
  }
528
528
  return this._learnModeAuthenticatedKeyPair;
@@ -1085,7 +1085,7 @@ export class Driver extends TypedEventEmitter {
1085
1085
  && key in SecurityClass
1086
1086
  && securityClassIsS2(SecurityClass[key]))) {
1087
1087
  this.driverLog.print("At least one network key for S2 configured, enabling S2 security manager...");
1088
- this._securityManager2 = new SecurityManager2();
1088
+ this._securityManager2 = await SecurityManager2.create();
1089
1089
  // Set up all keys
1090
1090
  for (const secClass of [
1091
1091
  "S2_Unauthenticated",
@@ -1095,7 +1095,7 @@ export class Driver extends TypedEventEmitter {
1095
1095
  ]) {
1096
1096
  const key = this._options.securityKeys[secClass];
1097
1097
  if (key) {
1098
- this._securityManager2.setKey(SecurityClass[secClass], key);
1098
+ await this._securityManager2.setKeyAsync(SecurityClass[secClass], key);
1099
1099
  }
1100
1100
  }
1101
1101
  }
@@ -1105,12 +1105,12 @@ export class Driver extends TypedEventEmitter {
1105
1105
  if (this._options.securityKeysLongRange?.S2_AccessControl
1106
1106
  || this._options.securityKeysLongRange?.S2_Authenticated) {
1107
1107
  this.driverLog.print("At least one network key for Z-Wave Long Range configured, enabling security manager...");
1108
- this._securityManagerLR = new SecurityManager2();
1108
+ this._securityManagerLR = await SecurityManager2.create();
1109
1109
  if (this._options.securityKeysLongRange?.S2_AccessControl) {
1110
- this._securityManagerLR.setKey(SecurityClass.S2_AccessControl, this._options.securityKeysLongRange.S2_AccessControl);
1110
+ await this._securityManagerLR.setKeyAsync(SecurityClass.S2_AccessControl, this._options.securityKeysLongRange.S2_AccessControl);
1111
1111
  }
1112
1112
  if (this._options.securityKeysLongRange?.S2_Authenticated) {
1113
- this._securityManagerLR.setKey(SecurityClass.S2_Authenticated, this._options.securityKeysLongRange.S2_Authenticated);
1113
+ await this._securityManagerLR.setKeyAsync(SecurityClass.S2_Authenticated, this._options.securityKeysLongRange.S2_Authenticated);
1114
1114
  }
1115
1115
  }
1116
1116
  else {
@@ -1131,21 +1131,21 @@ export class Driver extends TypedEventEmitter {
1131
1131
  ]).filter((v) => v[1] != undefined);
1132
1132
  if (securityKeysLongRange.length) {
1133
1133
  this.driverLog.print("At least one network key for Z-Wave Long Range found in cache, enabling security manager...");
1134
- this._securityManagerLR = new SecurityManager2();
1134
+ this._securityManagerLR = await SecurityManager2.create();
1135
1135
  for (const [sc, key] of securityKeysLongRange) {
1136
- this._securityManagerLR.setKey(sc, key);
1136
+ await this._securityManagerLR.setKeyAsync(sc, key);
1137
1137
  }
1138
1138
  }
1139
1139
  else if (this._options.securityKeysLongRange?.S2_AccessControl
1140
1140
  || this._options.securityKeysLongRange?.S2_Authenticated) {
1141
1141
  this.driverLog.print("Fallback to configured network keys for Z-Wave Long Range, enabling security manager...");
1142
- this._securityManagerLR = new SecurityManager2();
1142
+ this._securityManagerLR = await SecurityManager2.create();
1143
1143
  if (this._options.securityKeysLongRange?.S2_AccessControl) {
1144
- this._securityManagerLR.setKey(SecurityClass.S2_AccessControl, this._options.securityKeysLongRange
1144
+ await this._securityManagerLR.setKeyAsync(SecurityClass.S2_AccessControl, this._options.securityKeysLongRange
1145
1145
  .S2_AccessControl);
1146
1146
  }
1147
1147
  if (this._options.securityKeysLongRange?.S2_Authenticated) {
1148
- this._securityManagerLR.setKey(SecurityClass.S2_Authenticated, this._options.securityKeysLongRange
1148
+ await this._securityManagerLR.setKeyAsync(SecurityClass.S2_Authenticated, this._options.securityKeysLongRange
1149
1149
  .S2_Authenticated);
1150
1150
  }
1151
1151
  }
@@ -1180,9 +1180,9 @@ export class Driver extends TypedEventEmitter {
1180
1180
  ]).filter((v) => v[1] != undefined);
1181
1181
  if (securityKeys.length) {
1182
1182
  this.driverLog.print("At least one network key for S2 found in cache, enabling S2 security manager...");
1183
- this._securityManager2 = new SecurityManager2();
1183
+ this._securityManager2 = await SecurityManager2.create();
1184
1184
  for (const [sc, key] of securityKeys) {
1185
- this._securityManager2.setKey(sc, key);
1185
+ await this._securityManager2.setKeyAsync(sc, key);
1186
1186
  }
1187
1187
  }
1188
1188
  else if (this._options.securityKeys
@@ -1190,7 +1190,7 @@ export class Driver extends TypedEventEmitter {
1190
1190
  && key in SecurityClass
1191
1191
  && securityClassIsS2(SecurityClass[key]))) {
1192
1192
  this.driverLog.print("Fallback to configured network keys for S2, enabling S2 security manager...");
1193
- this._securityManager2 = new SecurityManager2();
1193
+ this._securityManager2 = await SecurityManager2.create();
1194
1194
  // Set up all keys
1195
1195
  for (const secClass of [
1196
1196
  "S2_Unauthenticated",
@@ -1200,7 +1200,7 @@ export class Driver extends TypedEventEmitter {
1200
1200
  ]) {
1201
1201
  const key = this._options.securityKeys[secClass];
1202
1202
  if (key) {
1203
- this._securityManager2.setKey(SecurityClass[secClass], key);
1203
+ await this._securityManager2.setKeyAsync(SecurityClass[secClass], key);
1204
1204
  }
1205
1205
  }
1206
1206
  }