@zwave-js/cc 10.0.0-beta.5 → 10.0.0-beta.8

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 (59) hide show
  1. package/build/cc/AlarmSensorCC.d.ts +2 -2
  2. package/build/cc/AssociationCC.d.ts +4 -4
  3. package/build/cc/AssociationGroupInfoCC.d.ts +4 -4
  4. package/build/cc/BarrierOperatorCC.d.ts +1 -1
  5. package/build/cc/BasicCC.d.ts +1 -1
  6. package/build/cc/BatteryCC.d.ts +10 -10
  7. package/build/cc/BinarySensorCC.d.ts +1 -1
  8. package/build/cc/BinarySwitchCC.d.ts +1 -1
  9. package/build/cc/CentralSceneCC.d.ts +3 -3
  10. package/build/cc/ColorSwitchCC.d.ts +2 -2
  11. package/build/cc/ConfigurationCC.js +4 -4
  12. package/build/cc/DoorLockCC.d.ts +14 -14
  13. package/build/cc/DoorLockLoggingCC.d.ts +1 -1
  14. package/build/cc/EntryControlCC.d.ts +3 -3
  15. package/build/cc/EntryControlCC.d.ts.map +1 -1
  16. package/build/cc/EntryControlCC.js +12 -4
  17. package/build/cc/EntryControlCC.js.map +1 -1
  18. package/build/cc/FirmwareUpdateMetaDataCC.d.ts +4 -4
  19. package/build/cc/HumidityControlModeCC.d.ts +1 -1
  20. package/build/cc/HumidityControlSetpointCC.d.ts +1 -1
  21. package/build/cc/IndicatorCC.d.ts +3 -3
  22. package/build/cc/IrrigationCC.d.ts +4 -4
  23. package/build/cc/ManufacturerSpecificCC.d.ts +1 -1
  24. package/build/cc/MeterCC.d.ts +4 -4
  25. package/build/cc/MultiChannelAssociationCC.d.ts +4 -4
  26. package/build/cc/MultiChannelCC.d.ts +3 -3
  27. package/build/cc/MultilevelSensorCC.d.ts +2 -2
  28. package/build/cc/MultilevelSwitchCC.d.ts +2 -2
  29. package/build/cc/NotificationCC.d.ts.map +1 -1
  30. package/build/cc/NotificationCC.js +5 -2
  31. package/build/cc/NotificationCC.js.map +1 -1
  32. package/build/cc/ProtectionCC.d.ts +7 -7
  33. package/build/cc/SceneActivationCC.d.ts +1 -1
  34. package/build/cc/Security2CC.d.ts +2 -1
  35. package/build/cc/Security2CC.d.ts.map +1 -1
  36. package/build/cc/Security2CC.js +87 -45
  37. package/build/cc/Security2CC.js.map +1 -1
  38. package/build/cc/SecurityCC.d.ts.map +1 -1
  39. package/build/cc/SecurityCC.js +4 -5
  40. package/build/cc/SecurityCC.js.map +1 -1
  41. package/build/cc/SoundSwitchCC.d.ts +1 -1
  42. package/build/cc/SupervisionCC.d.ts +0 -2
  43. package/build/cc/SupervisionCC.d.ts.map +1 -1
  44. package/build/cc/SupervisionCC.js +5 -13
  45. package/build/cc/SupervisionCC.js.map +1 -1
  46. package/build/cc/ThermostatFanModeCC.d.ts +2 -2
  47. package/build/cc/ThermostatModeCC.d.ts +1 -1
  48. package/build/cc/ThermostatSetpointCC.d.ts +3 -3
  49. package/build/cc/UserCodeCC.d.ts +13 -13
  50. package/build/cc/UserCodeCC.d.ts.map +1 -1
  51. package/build/cc/UserCodeCC.js +6 -7
  52. package/build/cc/UserCodeCC.js.map +1 -1
  53. package/build/cc/VersionCC.d.ts +1 -1
  54. package/build/cc/ZWavePlusCC.d.ts +2 -2
  55. package/build/lib/Values.d.ts +2 -2
  56. package/build/lib/_Types.d.ts +1 -82
  57. package/build/lib/_Types.d.ts.map +1 -1
  58. package/build/lib/_Types.js.map +1 -1
  59. package/package.json +7 -7
@@ -22,10 +22,10 @@ export declare const ProtectionCCValues: Readonly<{
22
22
  readonly writeable: true;
23
23
  };
24
24
  readonly options: {
25
- readonly supportsEndpoints: true;
26
25
  readonly minVersion: 1;
27
26
  readonly stateful: true;
28
27
  readonly secret: false;
28
+ readonly supportsEndpoints: true;
29
29
  readonly autoCreate: true;
30
30
  readonly internal: true;
31
31
  };
@@ -47,10 +47,10 @@ export declare const ProtectionCCValues: Readonly<{
47
47
  readonly writeable: true;
48
48
  };
49
49
  readonly options: {
50
- readonly supportsEndpoints: true;
51
50
  readonly minVersion: 1;
52
51
  readonly stateful: true;
53
52
  readonly secret: false;
53
+ readonly supportsEndpoints: true;
54
54
  readonly autoCreate: true;
55
55
  readonly internal: true;
56
56
  };
@@ -72,10 +72,10 @@ export declare const ProtectionCCValues: Readonly<{
72
72
  readonly writeable: true;
73
73
  };
74
74
  readonly options: {
75
- readonly supportsEndpoints: true;
76
75
  readonly minVersion: 1;
77
76
  readonly stateful: true;
78
77
  readonly secret: false;
78
+ readonly supportsEndpoints: true;
79
79
  readonly autoCreate: true;
80
80
  readonly internal: true;
81
81
  };
@@ -97,10 +97,10 @@ export declare const ProtectionCCValues: Readonly<{
97
97
  readonly writeable: true;
98
98
  };
99
99
  readonly options: {
100
- readonly supportsEndpoints: true;
101
100
  readonly minVersion: 1;
102
101
  readonly stateful: true;
103
102
  readonly secret: false;
103
+ readonly supportsEndpoints: true;
104
104
  readonly autoCreate: true;
105
105
  readonly internal: true;
106
106
  };
@@ -126,9 +126,9 @@ export declare const ProtectionCCValues: Readonly<{
126
126
  };
127
127
  readonly options: {
128
128
  readonly internal: false;
129
- readonly supportsEndpoints: true;
130
129
  readonly stateful: true;
131
130
  readonly secret: false;
131
+ readonly supportsEndpoints: true;
132
132
  readonly autoCreate: true;
133
133
  readonly minVersion: 2;
134
134
  };
@@ -155,9 +155,9 @@ export declare const ProtectionCCValues: Readonly<{
155
155
  };
156
156
  readonly options: {
157
157
  readonly internal: false;
158
- readonly supportsEndpoints: true;
159
158
  readonly stateful: true;
160
159
  readonly secret: false;
160
+ readonly supportsEndpoints: true;
161
161
  readonly autoCreate: true;
162
162
  readonly minVersion: 2;
163
163
  };
@@ -212,9 +212,9 @@ export declare const ProtectionCCValues: Readonly<{
212
212
  };
213
213
  readonly options: {
214
214
  readonly internal: false;
215
- readonly supportsEndpoints: true;
216
215
  readonly stateful: true;
217
216
  readonly secret: false;
217
+ readonly supportsEndpoints: true;
218
218
  readonly autoCreate: true;
219
219
  readonly minVersion: 2;
220
220
  };
@@ -54,9 +54,9 @@ export declare const SceneActivationCCValues: Readonly<{
54
54
  };
55
55
  readonly options: {
56
56
  readonly internal: false;
57
- readonly supportsEndpoints: true;
58
57
  readonly minVersion: 1;
59
58
  readonly secret: false;
59
+ readonly supportsEndpoints: true;
60
60
  readonly autoCreate: true;
61
61
  readonly stateful: false;
62
62
  };
@@ -49,7 +49,8 @@ export declare class Security2CCMessageEncapsulation extends Security2CC {
49
49
  };
50
50
  constructor(host: ZWaveHost, options: CommandClassDeserializationOptions | Security2CCMessageEncapsulationOptions);
51
51
  private _securityClass?;
52
- readonly decryptionKey?: Buffer;
52
+ private key?;
53
+ private iv?;
53
54
  private _sequenceNumber;
54
55
  /**
55
56
  * Return the sequence number of this command.
@@ -1 +1 @@
1
- {"version":3,"file":"Security2CC.d.ts","sourceRoot":"","sources":["../../src/cc/Security2CC.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,cAAc,EAOd,KAAK,EACL,mBAAmB,EAMnB,aAAa,EAGb,gBAAgB,EAOhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACN,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,kCAAkC,EAEvC,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EAEN,kBAAkB,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAqEjD,qBACa,cAAe,SAAQ,KAAK;IACjC,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC;IAK9D;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAwD1C;;;OAGG;IACU,oBAAoB,CAChC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AE,oBAAoB,GAAG,mBAAmB;CAWtE;AAED,qBACa,2BAA4B,SAAQ,WAAW;CAAG;AAE/D,UAAU,6BAA8B,SAAQ,gBAAgB;IAC/D,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED,qBACa,sBAAuB,SAAQ,WAAW;gBAErD,IAAI,EAAE,SAAS,EACf,OAAO,EACJ,kCAAkC,GAClC,6BAA6B;IAa1B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAE5B,SAAS,IAAI,MAAM;IAOnB,UAAU,CAAC,QAAQ,EAAE,oBAAoB,GAAG,mBAAmB;CAStE;AAED,qBACa,kCAAmC,SAAQ,WAAW;gBAEjE,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,kCAAkC;IAY5C,SAAgB,YAAY,EAAE,cAAc,EAAE,CAAC;IAExC,UAAU,CAAC,QAAQ,EAAE,oBAAoB,GAAG,mBAAmB;CAWtE;AAED,qBAEa,+BAAgC,SAAQ,WAAW;CAAG"}
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Security2CCCommandsSupportedGet = exports.Security2CCCommandsSupportedReport = exports.Security2CCTransferEnd = exports.Security2CCNetworkKeyVerify = exports.Security2CCNetworkKeyGet = exports.Security2CCNetworkKeyReport = exports.Security2CCPublicKeyReport = exports.Security2CCKEXFail = exports.Security2CCKEXSet = exports.Security2CCKEXGet = exports.Security2CCKEXReport = exports.Security2CCNonceGet = exports.Security2CCNonceReport = exports.Security2CCMessageEncapsulation = exports.Security2CC = exports.Security2CCAPI = void 0;
11
11
  const core_1 = require("@zwave-js/core");
12
12
  const safe_1 = require("@zwave-js/core/safe");
13
- const serial_1 = require("@zwave-js/serial");
14
13
  const safe_2 = require("@zwave-js/shared/safe");
15
14
  const API_1 = require("../lib/API");
16
15
  const CommandClass_1 = require("../lib/CommandClass");
@@ -37,15 +36,14 @@ function getAuthenticationData(sendingNodeId, destination, homeId, commandLength
37
36
  unencryptedPayload.copy(ret, 8, 0);
38
37
  return ret;
39
38
  }
40
- /** Validates that a sequence number is not a duplicate and updates the SPAN table if it is accepted */
39
+ /** Validates that a sequence number is not a duplicate and updates the SPAN table if it is accepted. Returns the previous sequence number if there is one. */
41
40
  function validateSequenceNumber(sequenceNumber) {
42
- const peerNodeID = this.nodeId;
43
- core_1.validatePayload.withReason("Duplicate command")(!this.host.securityManager2.isDuplicateSinglecast(peerNodeID, sequenceNumber));
41
+ core_1.validatePayload.withReason("Duplicate command")(!this.host.securityManager2.isDuplicateSinglecast(this.nodeId, sequenceNumber));
44
42
  // Not a duplicate, store it
45
- this.host.securityManager2.storeSequenceNumber(peerNodeID, sequenceNumber);
43
+ return this.host.securityManager2.storeSequenceNumber(this.nodeId, sequenceNumber);
46
44
  }
47
45
  function assertSecurity(options) {
48
- const verb = (0, serial_1.gotDeserializationOptions)(options) ? "decoded" : "sent";
46
+ const verb = (0, CommandClass_1.gotDeserializationOptions)(options) ? "decoded" : "sent";
49
47
  if (!this.host.ownNodeId) {
50
48
  throw new core_1.ZWaveError(`Secure commands (S2) can only be ${verb} when the controller's node id is known!`, core_1.ZWaveErrorCodes.Driver_NotReady);
51
49
  }
@@ -410,18 +408,18 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
410
408
  super(host, options);
411
409
  // Make sure that we can send/receive secure commands
412
410
  assertSecurity.call(this, options);
413
- if ((0, serial_1.gotDeserializationOptions)(options)) {
411
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
414
412
  (0, core_1.validatePayload)(this.payload.length >= 2);
415
413
  // Check the sequence number to avoid duplicates
416
414
  // TODO: distinguish between multicast and singlecast
417
415
  this._sequenceNumber = this.payload[0];
416
+ const sendingNodeId = this.nodeId;
418
417
  // Don't accept duplicate commands
419
- validateSequenceNumber.call(this, this._sequenceNumber);
418
+ const prevSequenceNumber = validateSequenceNumber.call(this, this._sequenceNumber);
420
419
  // Ensure the node has a security class
421
- const peerNodeID = this.nodeId;
422
420
  // const node = this.getNode()!;
423
421
  // validatePayload.withReason("The node is not included")(!!node);
424
- const securityClass = this.host.getHighestSecurityClass(peerNodeID);
422
+ const securityClass = this.host.getHighestSecurityClass(sendingNodeId);
425
423
  core_1.validatePayload.withReason("No security class granted")(securityClass !== core_1.SecurityClass.None);
426
424
  const hasExtensions = !!(this.payload[1] & 0b1);
427
425
  const hasEncryptedExtensions = !!(this.payload[1] & 0b10);
@@ -447,9 +445,9 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
447
445
  const ciphertext = this.payload.slice(offset, -core_1.SECURITY_S2_AUTH_TAG_LENGTH);
448
446
  const authTag = this.payload.slice(-core_1.SECURITY_S2_AUTH_TAG_LENGTH);
449
447
  const messageLength = super.computeEncapsulationOverhead() + this.payload.length;
450
- const authData = getAuthenticationData(this.nodeId, this.getDestinationIDRX(), this.host.homeId, messageLength, unencryptedPayload);
448
+ const authData = getAuthenticationData(sendingNodeId, this.getDestinationIDRX(), this.host.homeId, messageLength, unencryptedPayload);
451
449
  // Decrypt payload and verify integrity
452
- const spanState = this.host.securityManager2.getSPANState(peerNodeID);
450
+ const spanState = this.host.securityManager2.getSPANState(sendingNodeId);
453
451
  const failNoSPAN = () => {
454
452
  return core_1.validatePayload.fail(core_1.ZWaveErrorCodes.Security2CC_NoSPAN);
455
453
  };
@@ -463,15 +461,43 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
463
461
  return failNoSPAN();
464
462
  }
465
463
  const decrypt = () => {
466
- const getNonceAndDecrypt = () => {
467
- const iv = this.host.securityManager2.nextNonce(peerNodeID);
468
- const { keyCCM: key } = this.host.securityManager2.getKeysForNode(peerNodeID);
464
+ const decryptWithNonce = (nonce) => {
465
+ const { keyCCM: key } = this.host.securityManager2.getKeysForNode(sendingNodeId);
466
+ const iv = nonce;
469
467
  return {
470
- decryptionKey: key,
468
+ key,
469
+ iv,
471
470
  ...(0, core_1.decryptAES128CCM)(key, iv, ciphertext, authData, authTag),
472
471
  };
473
472
  };
473
+ const getNonceAndDecrypt = () => {
474
+ const iv = this.host.securityManager2.nextNonce(sendingNodeId);
475
+ return decryptWithNonce(iv);
476
+ };
474
477
  if (spanState.type === core_1.SPANState.SPAN) {
478
+ // There SHOULD be a shared SPAN between both parties. But experience has shown that both could have
479
+ // sent a command at roughly the same time, using the same SPAN for encryption.
480
+ // To avoid a nasty desync and both nodes trying to resync at the same time, causing message loss,
481
+ // we accept commands encrypted with the previous SPAN under very specific circumstances:
482
+ if (
483
+ // The previous SPAN is still known, i.e. the node didn't send another command that was successfully decrypted
484
+ !!spanState.currentSPAN &&
485
+ // it is still valid
486
+ spanState.currentSPAN.expires > (0, core_1.highResTimestamp)() &&
487
+ // The received command is exactly the next, expected one
488
+ prevSequenceNumber != undefined &&
489
+ this._sequenceNumber ===
490
+ ((prevSequenceNumber + 1) & 0xff) &&
491
+ // And in case of a mock-based test, do this only on the controller
492
+ !this.host.__internalIsMockNode) {
493
+ const nonce = spanState.currentSPAN.nonce;
494
+ spanState.currentSPAN = undefined;
495
+ return decryptWithNonce(nonce);
496
+ }
497
+ else {
498
+ // forgetting the current SPAN shouldn't be necessary but better be safe than sorry
499
+ spanState.currentSPAN = undefined;
500
+ }
475
501
  // This can only happen if the security class is known
476
502
  return getNonceAndDecrypt();
477
503
  }
@@ -483,18 +509,18 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
483
509
  return failNoSPAN();
484
510
  const receiverEI = spanState.receiverEI;
485
511
  // How we do this depends on whether we know the security class of the other node
486
- if (this.host.securityManager2.tempKeys.has(peerNodeID)) {
512
+ if (this.host.securityManager2.tempKeys.has(sendingNodeId)) {
487
513
  // We're currently bootstrapping the node, it might be using a temporary key
488
- this.host.securityManager2.initializeTempSPAN(peerNodeID, senderEI, receiverEI);
514
+ this.host.securityManager2.initializeTempSPAN(sendingNodeId, senderEI, receiverEI);
489
515
  const ret = getNonceAndDecrypt();
490
516
  // Decryption with the temporary key worked
491
517
  if (ret.authOK)
492
518
  return ret;
493
519
  // Reset the SPAN state and try with the recently granted security class
494
- this.host.securityManager2.setSPANState(peerNodeID, spanState);
520
+ this.host.securityManager2.setSPANState(sendingNodeId, spanState);
495
521
  }
496
522
  if (securityClass != undefined) {
497
- this.host.securityManager2.initializeSPAN(peerNodeID, securityClass, senderEI, receiverEI);
523
+ this.host.securityManager2.initializeSPAN(sendingNodeId, securityClass, senderEI, receiverEI);
498
524
  return getNonceAndDecrypt();
499
525
  }
500
526
  else {
@@ -502,18 +528,18 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
502
528
  // Try multiple security classes
503
529
  const possibleSecurityClasses = core_1.securityClassOrder
504
530
  .filter((s) => (0, core_1.securityClassIsS2)(s))
505
- .filter((s) => this.host.hasSecurityClass(peerNodeID, s) !== false);
531
+ .filter((s) => this.host.hasSecurityClass(sendingNodeId, s) !== false);
506
532
  for (const secClass of possibleSecurityClasses) {
507
533
  // Initialize an SPAN with that security class
508
- this.host.securityManager2.initializeSPAN(peerNodeID, secClass, senderEI, receiverEI);
534
+ this.host.securityManager2.initializeSPAN(sendingNodeId, secClass, senderEI, receiverEI);
509
535
  const ret = getNonceAndDecrypt();
510
536
  // It worked, return the result and remember the security class
511
537
  if (ret.authOK) {
512
- this.host.setSecurityClass(peerNodeID, secClass, true);
538
+ this.host.setSecurityClass(sendingNodeId, secClass, true);
513
539
  return ret;
514
540
  }
515
541
  // Reset the SPAN state and try with the next security class
516
- this.host.securityManager2.setSPANState(peerNodeID, spanState);
542
+ this.host.securityManager2.setSPANState(sendingNodeId, spanState);
517
543
  }
518
544
  }
519
545
  }
@@ -522,12 +548,13 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
522
548
  };
523
549
  let plaintext;
524
550
  let authOK = false;
525
- let decryptionKey;
551
+ let key;
552
+ let iv;
526
553
  // If the Receiver is unable to authenticate the singlecast message with the current SPAN,
527
554
  // the Receiver SHOULD try decrypting the message with one or more of the following SPAN values,
528
555
  // stopping when decryption is successful or the maximum number of iterations is reached.
529
556
  for (let i = 0; i < DECRYPT_ATTEMPTS; i++) {
530
- ({ plaintext, authOK, decryptionKey } = decrypt());
557
+ ({ plaintext, authOK, key, iv } = decrypt());
531
558
  if (!!authOK && !!plaintext)
532
559
  break;
533
560
  }
@@ -551,7 +578,8 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
551
578
  encapCC: this,
552
579
  });
553
580
  }
554
- this.decryptionKey = decryptionKey;
581
+ this.key = key;
582
+ this.iv = iv;
555
583
  }
556
584
  else {
557
585
  this._securityClass = options.securityClass;
@@ -601,9 +629,9 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
601
629
  }
602
630
  serialize() {
603
631
  // TODO: Support Multicast
604
- const nodeId = this.nodeId;
605
632
  // Include Sender EI in the command if we only have the receiver's EI
606
- const spanState = this.host.securityManager2.getSPANState(nodeId);
633
+ const receiverNodeId = this.getDestinationIDTX();
634
+ const spanState = this.host.securityManager2.getSPANState(receiverNodeId);
607
635
  if (spanState.type === core_1.SPANState.None ||
608
636
  spanState.type === core_1.SPANState.LocalEI) {
609
637
  // Can't do anything here if we don't have the receiver's EI
@@ -616,16 +644,16 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
616
644
  const receiverEI = spanState.receiverEI;
617
645
  // While bootstrapping a node, the controller only sends commands encrypted
618
646
  // with the temporary key
619
- if (this.host.securityManager2.tempKeys.has(nodeId)) {
620
- this.host.securityManager2.initializeTempSPAN(nodeId, senderEI, receiverEI);
647
+ if (this.host.securityManager2.tempKeys.has(receiverNodeId)) {
648
+ this.host.securityManager2.initializeTempSPAN(receiverNodeId, senderEI, receiverEI);
621
649
  }
622
650
  else {
623
651
  const securityClass = this._securityClass ??
624
- this.host.getHighestSecurityClass(nodeId);
652
+ this.host.getHighestSecurityClass(receiverNodeId);
625
653
  if (securityClass == undefined) {
626
654
  throw new core_1.ZWaveError("No security class defined for this command!", core_1.ZWaveErrorCodes.Security2CC_NoSPAN);
627
655
  }
628
- this.host.securityManager2.initializeSPAN(nodeId, securityClass, senderEI, receiverEI);
656
+ this.host.securityManager2.initializeSPAN(receiverNodeId, securityClass, senderEI, receiverEI);
629
657
  }
630
658
  // Add or update the SPAN extension
631
659
  let spanExtension = this.extensions.find((e) => e instanceof Extension_1.SPANExtension);
@@ -654,14 +682,19 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
654
682
  ]);
655
683
  // Generate the authentication data for CCM encryption
656
684
  const messageLength = this.computeEncapsulationOverhead() + serializedCC.length;
657
- const authData = getAuthenticationData(this.host.ownNodeId, this.getDestinationIDTX(), this.host.homeId, messageLength, unencryptedPayload);
658
- const iv = this.host.securityManager2.nextNonce(nodeId);
685
+ const authData = getAuthenticationData(this.host.ownNodeId, receiverNodeId, this.host.homeId, messageLength, unencryptedPayload);
686
+ // Generate a nonce for encryption, and remember it to attempt decryption
687
+ // of potential in-flight messages from the target node.
688
+ const iv = this.host.securityManager2.nextNonce(receiverNodeId, true);
659
689
  const { keyCCM: key } =
660
690
  // Prefer the overridden security class if it was given
661
691
  this._securityClass != undefined
662
692
  ? this.host.securityManager2.getKeysForSecurityClass(this._securityClass)
663
- : this.host.securityManager2.getKeysForNode(nodeId);
693
+ : this.host.securityManager2.getKeysForNode(receiverNodeId);
664
694
  const { ciphertext: ciphertextPayload, authTag } = (0, core_1.encryptAES128CCM)(key, iv, plaintextPayload, authData, core_1.SECURITY_S2_AUTH_TAG_LENGTH);
695
+ // Remember key and IV for debugging purposes
696
+ this.key = key;
697
+ this.iv = iv;
665
698
  this.payload = Buffer.concat([
666
699
  unencryptedPayload,
667
700
  ciphertextPayload,
@@ -692,6 +725,15 @@ let Security2CCMessageEncapsulation = class Security2CCMessageEncapsulation exte
692
725
  .map((e) => e.toLogEntry())
693
726
  .join("");
694
727
  }
728
+ // Log the used keys in integration tests
729
+ if (process.env.NODE_ENV === "test") {
730
+ if (this.key) {
731
+ message.key = (0, safe_2.buffer2hex)(this.key);
732
+ }
733
+ if (this.iv) {
734
+ message.IV = (0, safe_2.buffer2hex)(this.iv);
735
+ }
736
+ }
695
737
  return {
696
738
  ...super.toLogEntry(applHost),
697
739
  message,
@@ -708,7 +750,7 @@ let Security2CCNonceReport = class Security2CCNonceReport extends Security2CC {
708
750
  super(host, options);
709
751
  // Make sure that we can send/receive secure commands
710
752
  assertSecurity.call(this, options);
711
- if ((0, serial_1.gotDeserializationOptions)(options)) {
753
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
712
754
  (0, core_1.validatePayload)(this.payload.length >= 2);
713
755
  this._sequenceNumber = this.payload[0];
714
756
  // Don't accept duplicate commands
@@ -779,7 +821,7 @@ let Security2CCNonceGet = class Security2CCNonceGet extends Security2CC {
779
821
  super(host, options);
780
822
  // Make sure that we can send/receive secure commands
781
823
  assertSecurity.call(this, options);
782
- if ((0, serial_1.gotDeserializationOptions)(options)) {
824
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
783
825
  (0, core_1.validatePayload)(this.payload.length >= 1);
784
826
  this._sequenceNumber = this.payload[0];
785
827
  // Don't accept duplicate commands
@@ -821,7 +863,7 @@ exports.Security2CCNonceGet = Security2CCNonceGet;
821
863
  let Security2CCKEXReport = class Security2CCKEXReport extends Security2CC {
822
864
  constructor(host, options) {
823
865
  super(host, options);
824
- if ((0, serial_1.gotDeserializationOptions)(options)) {
866
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
825
867
  (0, core_1.validatePayload)(this.payload.length >= 4);
826
868
  this.requestCSA = !!(this.payload[0] & 0b10);
827
869
  this.echo = !!(this.payload[0] & 0b1);
@@ -881,7 +923,7 @@ exports.Security2CCKEXGet = Security2CCKEXGet;
881
923
  let Security2CCKEXSet = class Security2CCKEXSet extends Security2CC {
882
924
  constructor(host, options) {
883
925
  super(host, options);
884
- if ((0, serial_1.gotDeserializationOptions)(options)) {
926
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
885
927
  (0, core_1.validatePayload)(this.payload.length >= 4);
886
928
  this.permitCSA = !!(this.payload[0] & 0b10);
887
929
  this.echo = !!(this.payload[0] & 0b1);
@@ -934,7 +976,7 @@ exports.Security2CCKEXSet = Security2CCKEXSet;
934
976
  let Security2CCKEXFail = class Security2CCKEXFail extends Security2CC {
935
977
  constructor(host, options) {
936
978
  super(host, options);
937
- if ((0, serial_1.gotDeserializationOptions)(options)) {
979
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
938
980
  (0, core_1.validatePayload)(this.payload.length >= 1);
939
981
  this.failType = this.payload[0];
940
982
  }
@@ -960,7 +1002,7 @@ exports.Security2CCKEXFail = Security2CCKEXFail;
960
1002
  let Security2CCPublicKeyReport = class Security2CCPublicKeyReport extends Security2CC {
961
1003
  constructor(host, options) {
962
1004
  super(host, options);
963
- if ((0, serial_1.gotDeserializationOptions)(options)) {
1005
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
964
1006
  (0, core_1.validatePayload)(this.payload.length >= 17);
965
1007
  this.includingNode = !!(this.payload[0] & 0b1);
966
1008
  this.publicKey = this.payload.slice(1);
@@ -994,7 +1036,7 @@ exports.Security2CCPublicKeyReport = Security2CCPublicKeyReport;
994
1036
  let Security2CCNetworkKeyReport = class Security2CCNetworkKeyReport extends Security2CC {
995
1037
  constructor(host, options) {
996
1038
  super(host, options);
997
- if ((0, serial_1.gotDeserializationOptions)(options)) {
1039
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
998
1040
  // TODO: Deserialize payload
999
1041
  throw new core_1.ZWaveError(`${this.constructor.name}: deserialization not implemented`, core_1.ZWaveErrorCodes.Deserialization_NotImplemented);
1000
1042
  }
@@ -1028,7 +1070,7 @@ exports.Security2CCNetworkKeyReport = Security2CCNetworkKeyReport;
1028
1070
  let Security2CCNetworkKeyGet = class Security2CCNetworkKeyGet extends Security2CC {
1029
1071
  constructor(host, options) {
1030
1072
  super(host, options);
1031
- if ((0, serial_1.gotDeserializationOptions)(options)) {
1073
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1032
1074
  (0, core_1.validatePayload)(this.payload.length >= 1);
1033
1075
  this.requestedKey = bitMaskToSecurityClass(this.payload, 0);
1034
1076
  }
@@ -1063,7 +1105,7 @@ exports.Security2CCNetworkKeyVerify = Security2CCNetworkKeyVerify;
1063
1105
  let Security2CCTransferEnd = class Security2CCTransferEnd extends Security2CC {
1064
1106
  constructor(host, options) {
1065
1107
  super(host, options);
1066
- if ((0, serial_1.gotDeserializationOptions)(options)) {
1108
+ if ((0, CommandClass_1.gotDeserializationOptions)(options)) {
1067
1109
  (0, core_1.validatePayload)(this.payload.length >= 1);
1068
1110
  this.keyVerified = !!(this.payload[0] & 0b10);
1069
1111
  this.keyRequestComplete = !!(this.payload[0] & 0b1);