@zwave-js/cc 15.23.1 → 15.23.3

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 (31) hide show
  1. package/build/cjs/cc/NotificationCC.js +4 -0
  2. package/build/cjs/cc/NotificationCC.js.map +2 -2
  3. package/build/cjs/cc/UserCredentialCC._validateArgs.js +4 -4
  4. package/build/cjs/cc/UserCredentialCC._validateArgs.js.map +2 -2
  5. package/build/cjs/cc/UserCredentialCC.d.ts +75 -37
  6. package/build/cjs/cc/UserCredentialCC.js +203 -156
  7. package/build/cjs/cc/UserCredentialCC.js.map +3 -3
  8. package/build/cjs/cc/_CCValues.generated.d.ts +62 -6
  9. package/build/cjs/cc/_CCValues.generated.js +38 -6
  10. package/build/cjs/cc/_CCValues.generated.js.map +2 -2
  11. package/build/cjs/cc/index.d.ts +3 -3
  12. package/build/cjs/cc/index.js +6 -6
  13. package/build/cjs/cc/index.js.map +1 -1
  14. package/build/esm/cc/NotificationCC.d.ts.map +1 -1
  15. package/build/esm/cc/NotificationCC.js +6 -1
  16. package/build/esm/cc/NotificationCC.js.map +1 -1
  17. package/build/esm/cc/UserCredentialCC._validateArgs.js +4 -4
  18. package/build/esm/cc/UserCredentialCC._validateArgs.js.map +1 -1
  19. package/build/esm/cc/UserCredentialCC.d.ts +75 -37
  20. package/build/esm/cc/UserCredentialCC.d.ts.map +1 -1
  21. package/build/esm/cc/UserCredentialCC.js +237 -152
  22. package/build/esm/cc/UserCredentialCC.js.map +1 -1
  23. package/build/esm/cc/_CCValues.generated.d.ts +62 -6
  24. package/build/esm/cc/_CCValues.generated.d.ts.map +1 -1
  25. package/build/esm/cc/_CCValues.generated.js +41 -6
  26. package/build/esm/cc/_CCValues.generated.js.map +1 -1
  27. package/build/esm/cc/index.d.ts +3 -3
  28. package/build/esm/cc/index.d.ts.map +1 -1
  29. package/build/esm/cc/index.js +4 -4
  30. package/build/esm/cc/index.js.map +1 -1
  31. package/package.json +2 -2
@@ -36,6 +36,8 @@ __export(UserCredentialCC_exports, {
36
36
  UserCredentialCCAdminPinCodeSet: () => UserCredentialCCAdminPinCodeSet,
37
37
  UserCredentialCCAllUsersChecksumGet: () => UserCredentialCCAllUsersChecksumGet,
38
38
  UserCredentialCCAllUsersChecksumReport: () => UserCredentialCCAllUsersChecksumReport,
39
+ UserCredentialCCAssociationReport: () => UserCredentialCCAssociationReport,
40
+ UserCredentialCCAssociationSet: () => UserCredentialCCAssociationSet,
39
41
  UserCredentialCCCredentialCapabilitiesGet: () => UserCredentialCCCredentialCapabilitiesGet,
40
42
  UserCredentialCCCredentialCapabilitiesReport: () => UserCredentialCCCredentialCapabilitiesReport,
41
43
  UserCredentialCCCredentialChecksumGet: () => UserCredentialCCCredentialChecksumGet,
@@ -55,12 +57,11 @@ __export(UserCredentialCC_exports, {
55
57
  UserCredentialCCUserCapabilitiesReport: () => UserCredentialCCUserCapabilitiesReport,
56
58
  UserCredentialCCUserChecksumGet: () => UserCredentialCCUserChecksumGet,
57
59
  UserCredentialCCUserChecksumReport: () => UserCredentialCCUserChecksumReport,
58
- UserCredentialCCUserCredentialAssociationReport: () => UserCredentialCCUserCredentialAssociationReport,
59
- UserCredentialCCUserCredentialAssociationSet: () => UserCredentialCCUserCredentialAssociationSet,
60
60
  UserCredentialCCUserGet: () => UserCredentialCCUserGet,
61
61
  UserCredentialCCUserReport: () => UserCredentialCCUserReport,
62
62
  UserCredentialCCUserSet: () => UserCredentialCCUserSet,
63
- UserCredentialCCValues: () => import_CCValues_generated.UserCredentialCCValues
63
+ UserCredentialCCValues: () => import_CCValues_generated.UserCredentialCCValues,
64
+ normalizeCredentialData: () => normalizeCredentialData
64
65
  });
65
66
  module.exports = __toCommonJS(UserCredentialCC_exports);
66
67
  var import_tslib = require("tslib");
@@ -79,6 +80,13 @@ function credentialToLogString(credential) {
79
80
  return "*".repeat(credential.length);
80
81
  }
81
82
  __name(credentialToLogString, "credentialToLogString");
83
+ function normalizeCredentialData(credentialType, credentialData) {
84
+ if (credentialType === import_Types.UserCredentialType.PINCode || credentialType === import_Types.UserCredentialType.Password) {
85
+ return credentialData.toString("utf8");
86
+ }
87
+ return credentialData;
88
+ }
89
+ __name(normalizeCredentialData, "normalizeCredentialData");
82
90
  let UserCredentialCCAPI = (() => {
83
91
  let _classDecorators = [(0, import_CommandClassDecorators.API)(import_core.CommandClasses["User Credential"])];
84
92
  let _classDescriptor;
@@ -264,6 +272,10 @@ let UserCredentialCCAPI = (() => {
264
272
  return response?.keyLockerCapabilities;
265
273
  }
266
274
  // User Management
275
+ /**
276
+ * Applications should not use this method directly. Prefer the
277
+ * `endpoint.accessControl` API for managing users.
278
+ */
267
279
  async setUser(options) {
268
280
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.UserSet);
269
281
  const cc = new UserCredentialCCUserSet({
@@ -273,6 +285,10 @@ let UserCredentialCCAPI = (() => {
273
285
  });
274
286
  return this.host.sendCommand(cc, this.commandOptions);
275
287
  }
288
+ /**
289
+ * Applications should not use this method directly. Prefer the
290
+ * `endpoint.accessControl` API for querying users.
291
+ */
276
292
  async getUser(userId) {
277
293
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.UserGet);
278
294
  const cc = new UserCredentialCCUserGet({
@@ -280,23 +296,13 @@ let UserCredentialCCAPI = (() => {
280
296
  endpointIndex: this.endpoint.index,
281
297
  userId
282
298
  });
283
- const response = await this.host.sendCommand(cc, this.commandOptions);
284
- if (response) {
285
- return (0, import_shared.pick)(response, [
286
- "nextUserId",
287
- "modifierType",
288
- "modifierNodeId",
289
- "userId",
290
- "userType",
291
- "active",
292
- "credentialRule",
293
- "expiringTimeoutMinutes",
294
- "nameEncoding",
295
- "userName"
296
- ]);
297
- }
299
+ return this.host.sendCommand(cc, this.commandOptions);
298
300
  }
299
301
  // Credential Management
302
+ /**
303
+ * Applications should not use this method directly. Prefer the
304
+ * `endpoint.accessControl` API for managing credentials.
305
+ */
300
306
  async setCredential(options) {
301
307
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.CredentialSet);
302
308
  const cc = new UserCredentialCCCredentialSet({
@@ -306,6 +312,10 @@ let UserCredentialCCAPI = (() => {
306
312
  });
307
313
  return this.host.sendCommand(cc, this.commandOptions);
308
314
  }
315
+ /**
316
+ * Applications should not use this method directly. Prefer the
317
+ * `endpoint.accessControl` API for querying credentials.
318
+ */
309
319
  async getCredential(userId, credentialType, credentialSlot) {
310
320
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.CredentialGet);
311
321
  const cc = new UserCredentialCCCredentialGet({
@@ -315,24 +325,7 @@ let UserCredentialCCAPI = (() => {
315
325
  credentialType,
316
326
  credentialSlot
317
327
  });
318
- const response = await this.host.sendCommand(cc, this.commandOptions);
319
- if (response) {
320
- return (0, import_shared.pick)(response, [
321
- // UserId, credential type and slot can be zero in the
322
- // request to return the first credential, so we cannot
323
- // simply omit them here
324
- "userId",
325
- "credentialType",
326
- "credentialSlot",
327
- "credentialReadBack",
328
- "credentialLength",
329
- "credentialData",
330
- "modifierType",
331
- "modifierNodeId",
332
- "nextCredentialType",
333
- "nextCredentialSlot"
334
- ]);
335
- }
328
+ return this.host.sendCommand(cc, this.commandOptions);
336
329
  }
337
330
  async startCredentialLearn(options) {
338
331
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.CredentialLearnStart);
@@ -355,9 +348,13 @@ let UserCredentialCCAPI = (() => {
355
348
  });
356
349
  return this.host.sendCommand(cc, this.commandOptions);
357
350
  }
351
+ /**
352
+ * Applications should not use this method directly. Prefer the
353
+ * `endpoint.accessControl` API for reassigning credentials between users.
354
+ */
358
355
  async setUserCredentialAssociation(options) {
359
356
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.UserCredentialAssociationSet);
360
- const cc = new UserCredentialCCUserCredentialAssociationSet({
357
+ const cc = new UserCredentialCCAssociationSet({
361
358
  nodeId: this.endpoint.nodeId,
362
359
  endpointIndex: this.endpoint.index,
363
360
  ...options
@@ -501,7 +498,7 @@ let UserCredentialCCAPI = (() => {
501
498
  }
502
499
  async sendUserCredentialAssociationReport(options) {
503
500
  this.assertSupportsCommand(import_Types.UserCredentialCommand, import_Types.UserCredentialCommand.UserCredentialAssociationReport);
504
- const cc = new UserCredentialCCUserCredentialAssociationReport({
501
+ const cc = new UserCredentialCCAssociationReport({
505
502
  nodeId: this.endpoint.nodeId,
506
503
  endpointIndex: this.endpoint.index,
507
504
  ...options
@@ -686,7 +683,7 @@ let UserCredentialCC = (() => {
686
683
  }
687
684
  }
688
685
  previousUserId = currentUserId;
689
- nextUserId = user.nextUserId;
686
+ nextUserId = user.nextUserId ?? 0;
690
687
  } while (nextUserId > 0);
691
688
  }
692
689
  if (allUsersChecksum != void 0) {
@@ -726,14 +723,17 @@ let UserCredentialCC = (() => {
726
723
  this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.userModifierNodeId(userId));
727
724
  this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.userChecksum(userId));
728
725
  const valueDB = this.getValueDB(ctx);
729
- const credentialValues = valueDB.findValues((vid) => (import_CCValues_generated.UserCredentialCCValues.credential.is(vid) || import_CCValues_generated.UserCredentialCCValues.credentialModifierType.is(vid) || import_CCValues_generated.UserCredentialCCValues.credentialModifierNodeId.is(vid)) && vid.propertyKey >> 24 === userId);
730
- for (const { commandClass: commandClass2, endpoint, property, propertyKey } of credentialValues) {
731
- valueDB.removeValue({
732
- commandClass: commandClass2,
733
- endpoint,
734
- property,
735
- propertyKey
736
- });
726
+ const credentialOwners = valueDB.findValues((vid) => import_CCValues_generated.UserCredentialCCValues.credentialOwner.is(vid) && vid.endpoint === this.endpointIndex);
727
+ for (const { endpoint, propertyKey, value } of credentialOwners) {
728
+ if (value !== userId)
729
+ continue;
730
+ const key = propertyKey;
731
+ const credentialType = key >>> 16;
732
+ const credentialSlot = key & 65535;
733
+ valueDB.removeValue(import_CCValues_generated.UserCredentialCCValues.credential(credentialType, credentialSlot).endpoint(endpoint));
734
+ valueDB.removeValue(import_CCValues_generated.UserCredentialCCValues.credentialOwner(credentialType, credentialSlot).endpoint(endpoint));
735
+ valueDB.removeValue(import_CCValues_generated.UserCredentialCCValues.credentialModifierType(credentialType, credentialSlot).endpoint(endpoint));
736
+ valueDB.removeValue(import_CCValues_generated.UserCredentialCCValues.credentialModifierNodeId(credentialType, credentialSlot).endpoint(endpoint));
737
737
  }
738
738
  }
739
739
  async queryCredentialsForUser(ctx, api, nodeId, userId) {
@@ -748,8 +748,8 @@ let UserCredentialCC = (() => {
748
748
  const cred = await api.getCredential(userId, nextCredType, nextCredSlot);
749
749
  if (!cred?.credentialSlot)
750
750
  break;
751
- nextCredType = cred.nextCredentialType;
752
- nextCredSlot = cred.nextCredentialSlot;
751
+ nextCredType = cred.nextCredentialType ?? import_Types.UserCredentialType.None;
752
+ nextCredSlot = cred.nextCredentialSlot ?? 0;
753
753
  } while (nextCredType !== import_Types.UserCredentialType.None || nextCredSlot !== 0);
754
754
  }
755
755
  static getSupportedUsersCached(ctx, endpoint) {
@@ -1180,8 +1180,12 @@ let UserCredentialCCKeyLockerCapabilitiesGet = (() => {
1180
1180
  };
1181
1181
  return UserCredentialCCKeyLockerCapabilitiesGet2 = _classThis;
1182
1182
  })();
1183
+ function testResponseForUserCredentialUserSet(sent, received) {
1184
+ return received.reportType !== import_Types.UserCredentialUserReportType.ResponseToGet && received.userId === sent.userId;
1185
+ }
1186
+ __name(testResponseForUserCredentialUserSet, "testResponseForUserCredentialUserSet");
1183
1187
  let UserCredentialCCUserSet = (() => {
1184
- let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.UserSet), (0, import_CommandClassDecorators.useSupervision)()];
1188
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.UserSet), (0, import_CommandClassDecorators.expectedCCResponse)(() => UserCredentialCCUserReport, testResponseForUserCredentialUserSet)];
1185
1189
  let _classDescriptor;
1186
1190
  let _classExtraInitializers = [];
1187
1191
  let _classThis;
@@ -1372,7 +1376,9 @@ let UserCredentialCCUserReport = (() => {
1372
1376
  constructor(options) {
1373
1377
  super(options);
1374
1378
  this.reportType = options.reportType;
1375
- this.nextUserId = options.nextUserId;
1379
+ if (options.reportType === import_Types.UserCredentialUserReportType.ResponseToGet) {
1380
+ this.nextUserId = options.nextUserId;
1381
+ }
1376
1382
  this.modifierType = options.modifierType;
1377
1383
  this.modifierNodeId = options.modifierNodeId;
1378
1384
  this.userId = options.userId;
@@ -1404,10 +1410,8 @@ let UserCredentialCCUserReport = (() => {
1404
1410
  } else {
1405
1411
  userName = raw.payload.subarray(15, 15 + nameLength).toString("ascii");
1406
1412
  }
1407
- return new this({
1413
+ const common = {
1408
1414
  nodeId: ctx.sourceNodeId,
1409
- reportType,
1410
- nextUserId,
1411
1415
  modifierType,
1412
1416
  modifierNodeId,
1413
1417
  userId,
@@ -1417,7 +1421,11 @@ let UserCredentialCCUserReport = (() => {
1417
1421
  expiringTimeoutMinutes,
1418
1422
  nameEncoding,
1419
1423
  userName
1420
- });
1424
+ };
1425
+ if (reportType === import_Types.UserCredentialUserReportType.ResponseToGet) {
1426
+ return new this({ ...common, reportType, nextUserId });
1427
+ }
1428
+ return new this({ ...common, reportType });
1421
1429
  }
1422
1430
  reportType;
1423
1431
  nextUserId;
@@ -1439,7 +1447,7 @@ let UserCredentialCCUserReport = (() => {
1439
1447
  }
1440
1448
  this.payload = import_shared.Bytes.alloc(15 + nameBuffer.length);
1441
1449
  this.payload[0] = this.reportType;
1442
- this.payload.writeUInt16BE(this.nextUserId, 1);
1450
+ this.payload.writeUInt16BE(this.nextUserId ?? 0, 1);
1443
1451
  this.payload[3] = this.modifierType;
1444
1452
  this.payload.writeUInt16BE(this.modifierNodeId, 4);
1445
1453
  this.payload.writeUInt16BE(this.userId, 6);
@@ -1459,7 +1467,7 @@ let UserCredentialCCUserReport = (() => {
1459
1467
  return false;
1460
1468
  if (this.userId === 0)
1461
1469
  return true;
1462
- if (this.reportType === import_Types.UserCredentialUserReportType.UserDeleted) {
1470
+ if (this.reportType === import_Types.UserCredentialUserReportType.UserDeleted || this.reportType === import_Types.UserCredentialUserReportType.UserModifyRejectedLocationEmpty) {
1463
1471
  const userId2 = this.userId;
1464
1472
  this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.userType(userId2));
1465
1473
  this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.userActive(userId2));
@@ -1470,7 +1478,7 @@ let UserCredentialCCUserReport = (() => {
1470
1478
  this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.userModifierNodeId(userId2));
1471
1479
  return true;
1472
1480
  }
1473
- if (this.reportType !== import_Types.UserCredentialUserReportType.ResponseToGet && this.reportType !== import_Types.UserCredentialUserReportType.UserAdded && this.reportType !== import_Types.UserCredentialUserReportType.UserModified) {
1481
+ if (this.reportType !== import_Types.UserCredentialUserReportType.ResponseToGet && this.reportType !== import_Types.UserCredentialUserReportType.UserAdded && this.reportType !== import_Types.UserCredentialUserReportType.UserModified && this.reportType !== import_Types.UserCredentialUserReportType.UserAddRejectedLocationOccupied) {
1474
1482
  return true;
1475
1483
  }
1476
1484
  const userId = this.userId;
@@ -1489,22 +1497,22 @@ let UserCredentialCCUserReport = (() => {
1489
1497
  return true;
1490
1498
  }
1491
1499
  toLogEntry(ctx) {
1492
- return {
1493
- ...super.toLogEntry(ctx),
1494
- message: {
1495
- "report type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialUserReportType, this.reportType),
1496
- "next user ID": this.nextUserId,
1497
- "modifier type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialModifierType, this.modifierType),
1498
- "modifier node id": this.modifierNodeId,
1499
- "user ID": this.userId,
1500
- "user type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialUserType, this.userType),
1501
- active: this.active,
1502
- "credential rule": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialRule, this.credentialRule),
1503
- "expiring timeout (minutes)": this.expiringTimeoutMinutes,
1504
- "name encoding": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialNameEncoding, this.nameEncoding),
1505
- "user name": this.userName
1506
- }
1500
+ const message = {
1501
+ "report type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialUserReportType, this.reportType)
1507
1502
  };
1503
+ if (this.nextUserId != void 0) {
1504
+ message["next user ID"] = this.nextUserId;
1505
+ }
1506
+ message["modifier type"] = (0, import_shared.getEnumMemberName)(import_Types.UserCredentialModifierType, this.modifierType);
1507
+ message["modifier node id"] = this.modifierNodeId;
1508
+ message["user ID"] = this.userId;
1509
+ message["user type"] = (0, import_shared.getEnumMemberName)(import_Types.UserCredentialUserType, this.userType);
1510
+ message.active = this.active;
1511
+ message["credential rule"] = (0, import_shared.getEnumMemberName)(import_Types.UserCredentialRule, this.credentialRule);
1512
+ message["expiring timeout (minutes)"] = this.expiringTimeoutMinutes;
1513
+ message["name encoding"] = (0, import_shared.getEnumMemberName)(import_Types.UserCredentialNameEncoding, this.nameEncoding);
1514
+ message["user name"] = this.userName;
1515
+ return { ...super.toLogEntry(ctx), message };
1508
1516
  }
1509
1517
  };
1510
1518
  return UserCredentialCCUserReport2 = _classThis;
@@ -1562,8 +1570,12 @@ let UserCredentialCCUserGet = (() => {
1562
1570
  };
1563
1571
  return UserCredentialCCUserGet2 = _classThis;
1564
1572
  })();
1573
+ function testResponseForUserCredentialCredentialSet(sent, received) {
1574
+ return received.reportType !== import_Types.UserCredentialCredentialReportType.ResponseToGet && received.credentialType === sent.credentialType && received.credentialSlot === sent.credentialSlot;
1575
+ }
1576
+ __name(testResponseForUserCredentialCredentialSet, "testResponseForUserCredentialCredentialSet");
1565
1577
  let UserCredentialCCCredentialSet = (() => {
1566
- let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.CredentialSet), (0, import_CommandClassDecorators.useSupervision)()];
1578
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.CredentialSet), (0, import_CommandClassDecorators.expectedCCResponse)(() => UserCredentialCCCredentialReport, testResponseForUserCredentialCredentialSet)];
1567
1579
  let _classDescriptor;
1568
1580
  let _classExtraInitializers = [];
1569
1581
  let _classThis;
@@ -1692,12 +1704,15 @@ let UserCredentialCCCredentialReport = (() => {
1692
1704
  this.credentialType = options.credentialType;
1693
1705
  this.credentialSlot = options.credentialSlot;
1694
1706
  this.credentialReadBack = options.credentialReadBack;
1695
- this.credentialLength = options.credentialLength;
1696
- this.credentialData = options.credentialData;
1707
+ if (options.credentialReadBack) {
1708
+ this.credentialData = options.credentialData;
1709
+ }
1697
1710
  this.modifierType = options.modifierType;
1698
1711
  this.modifierNodeId = options.modifierNodeId;
1699
- this.nextCredentialType = options.nextCredentialType;
1700
- this.nextCredentialSlot = options.nextCredentialSlot;
1712
+ if (options.reportType === import_Types.UserCredentialCredentialReportType.ResponseToGet) {
1713
+ this.nextCredentialType = options.nextCredentialType;
1714
+ this.nextCredentialSlot = options.nextCredentialSlot;
1715
+ }
1701
1716
  }
1702
1717
  static from(raw, ctx) {
1703
1718
  (0, import_core.validatePayload)(raw.payload.length >= 8);
@@ -1708,25 +1723,34 @@ let UserCredentialCCCredentialReport = (() => {
1708
1723
  const credentialReadBack = !!(raw.payload[6] & 128);
1709
1724
  const credentialLength = raw.payload[7];
1710
1725
  (0, import_core.validatePayload)(raw.payload.length >= 8 + credentialLength + 6);
1711
- const credentialData = import_shared.Bytes.from(raw.payload.subarray(8, 8 + credentialLength));
1712
- let offset = 8 + credentialLength;
1726
+ const offset = 8 + credentialLength;
1713
1727
  const modifierType = raw.payload[offset];
1714
1728
  const modifierNodeId = raw.payload.readUInt16BE(offset + 1);
1715
- const nextCredentialType = raw.payload[offset + 3];
1716
- const nextCredentialSlot = raw.payload.readUInt16BE(offset + 4);
1717
- return new this({
1729
+ const common = {
1718
1730
  nodeId: ctx.sourceNodeId,
1719
- reportType,
1720
1731
  userId,
1721
1732
  credentialType,
1722
1733
  credentialSlot,
1723
- credentialReadBack,
1724
- credentialLength,
1725
- credentialData,
1726
1734
  modifierType,
1727
- modifierNodeId,
1728
- nextCredentialType,
1729
- nextCredentialSlot
1735
+ modifierNodeId
1736
+ };
1737
+ const dataOptions = credentialReadBack ? {
1738
+ credentialReadBack: true,
1739
+ credentialData: import_shared.Bytes.from(raw.payload.subarray(8, 8 + credentialLength))
1740
+ } : { credentialReadBack: false };
1741
+ if (reportType === import_Types.UserCredentialCredentialReportType.ResponseToGet) {
1742
+ return new this({
1743
+ ...common,
1744
+ ...dataOptions,
1745
+ reportType,
1746
+ nextCredentialType: raw.payload[offset + 3],
1747
+ nextCredentialSlot: raw.payload.readUInt16BE(offset + 4)
1748
+ });
1749
+ }
1750
+ return new this({
1751
+ ...common,
1752
+ ...dataOptions,
1753
+ reportType
1730
1754
  });
1731
1755
  }
1732
1756
  reportType;
@@ -1734,28 +1758,28 @@ let UserCredentialCCCredentialReport = (() => {
1734
1758
  credentialType;
1735
1759
  credentialSlot;
1736
1760
  credentialReadBack;
1737
- credentialLength;
1738
1761
  credentialData;
1739
1762
  modifierType;
1740
1763
  modifierNodeId;
1741
1764
  nextCredentialType;
1742
1765
  nextCredentialSlot;
1743
1766
  serialize(ctx) {
1744
- this.payload = import_shared.Bytes.alloc(14 + this.credentialData.length);
1767
+ const credentialData = this.credentialData ?? new import_shared.Bytes();
1768
+ this.payload = import_shared.Bytes.alloc(14 + credentialData.length);
1745
1769
  this.payload[0] = this.reportType;
1746
1770
  this.payload.writeUInt16BE(this.userId, 1);
1747
1771
  this.payload[3] = this.credentialType;
1748
1772
  this.payload.writeUInt16BE(this.credentialSlot, 4);
1749
1773
  this.payload[6] = this.credentialReadBack ? 128 : 0;
1750
- this.payload[7] = this.credentialData.length;
1751
- if (this.credentialData.length > 0) {
1752
- this.payload.set(this.credentialData, 8);
1774
+ this.payload[7] = credentialData.length;
1775
+ if (credentialData.length > 0) {
1776
+ this.payload.set(credentialData, 8);
1753
1777
  }
1754
- let offset = 8 + this.credentialData.length;
1778
+ const offset = 8 + credentialData.length;
1755
1779
  this.payload[offset] = this.modifierType;
1756
1780
  this.payload.writeUInt16BE(this.modifierNodeId, offset + 1);
1757
- this.payload[offset + 3] = this.nextCredentialType;
1758
- this.payload.writeUInt16BE(this.nextCredentialSlot, offset + 4);
1781
+ this.payload[offset + 3] = this.nextCredentialType ?? import_Types.UserCredentialType.None;
1782
+ this.payload.writeUInt16BE(this.nextCredentialSlot ?? 0, offset + 4);
1759
1783
  return super.serialize(ctx);
1760
1784
  }
1761
1785
  persistValues(ctx) {
@@ -1764,37 +1788,46 @@ let UserCredentialCCCredentialReport = (() => {
1764
1788
  if (this.credentialType === import_Types.UserCredentialType.None || this.credentialSlot === 0) {
1765
1789
  return true;
1766
1790
  }
1767
- if (this.reportType === import_Types.UserCredentialCredentialReportType.CredentialDeleted) {
1768
- this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credential(this.userId, this.credentialType, this.credentialSlot));
1769
- this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierType(this.userId, this.credentialType, this.credentialSlot));
1770
- this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierNodeId(this.userId, this.credentialType, this.credentialSlot));
1791
+ if (this.reportType === import_Types.UserCredentialCredentialReportType.CredentialDeleted || this.reportType === import_Types.UserCredentialCredentialReportType.CredentialModifyRejectedLocationEmpty) {
1792
+ this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credential(this.credentialType, this.credentialSlot));
1793
+ this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialOwner(this.credentialType, this.credentialSlot));
1794
+ this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierType(this.credentialType, this.credentialSlot));
1795
+ this.removeValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierNodeId(this.credentialType, this.credentialSlot));
1771
1796
  return true;
1772
1797
  }
1773
- if (this.reportType !== import_Types.UserCredentialCredentialReportType.ResponseToGet && this.reportType !== import_Types.UserCredentialCredentialReportType.CredentialAdded && this.reportType !== import_Types.UserCredentialCredentialReportType.CredentialModified) {
1798
+ const isRejectionWithReadback = this.reportType === import_Types.UserCredentialCredentialReportType.CredentialAddRejectedLocationOccupied && this.credentialReadBack;
1799
+ if (this.reportType !== import_Types.UserCredentialCredentialReportType.ResponseToGet && this.reportType !== import_Types.UserCredentialCredentialReportType.CredentialAdded && this.reportType !== import_Types.UserCredentialCredentialReportType.CredentialModified && !isRejectionWithReadback) {
1774
1800
  return true;
1775
1801
  }
1776
- this.ensureMetadata(ctx, import_CCValues_generated.UserCredentialCCValues.credential(this.userId, this.credentialType, this.credentialSlot));
1777
- this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credential(this.userId, this.credentialType, this.credentialSlot), this.credentialData);
1778
- this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierType(this.userId, this.credentialType, this.credentialSlot), this.modifierType);
1779
- this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierNodeId(this.userId, this.credentialType, this.credentialSlot), this.modifierNodeId);
1802
+ if (this.credentialData != void 0) {
1803
+ this.ensureMetadata(ctx, import_CCValues_generated.UserCredentialCCValues.credential(this.credentialType, this.credentialSlot));
1804
+ this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credential(this.credentialType, this.credentialSlot), normalizeCredentialData(this.credentialType, this.credentialData));
1805
+ }
1806
+ this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialOwner(this.credentialType, this.credentialSlot), this.userId);
1807
+ this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierType(this.credentialType, this.credentialSlot), this.modifierType);
1808
+ this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialModifierNodeId(this.credentialType, this.credentialSlot), this.modifierNodeId);
1780
1809
  return true;
1781
1810
  }
1782
1811
  toLogEntry(ctx) {
1783
- return {
1784
- ...super.toLogEntry(ctx),
1785
- message: {
1786
- "report type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialCredentialReportType, this.reportType),
1787
- "user ID": this.userId,
1788
- "credential type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialType, this.credentialType),
1789
- "credential slot": this.credentialSlot,
1790
- "credential read-back": this.credentialReadBack,
1791
- "credential data": credentialToLogString(this.credentialData),
1792
- "modifier type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialModifierType, this.modifierType),
1793
- "modifier node id": this.modifierNodeId,
1794
- "next credential type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialType, this.nextCredentialType),
1795
- "next credential slot": this.nextCredentialSlot
1796
- }
1812
+ const message = {
1813
+ "report type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialCredentialReportType, this.reportType),
1814
+ "user ID": this.userId,
1815
+ "credential type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialType, this.credentialType),
1816
+ "credential slot": this.credentialSlot,
1817
+ "credential read-back": this.credentialReadBack
1797
1818
  };
1819
+ if (this.credentialData != void 0) {
1820
+ message["credential data"] = credentialToLogString(this.credentialData);
1821
+ }
1822
+ message["modifier type"] = (0, import_shared.getEnumMemberName)(import_Types.UserCredentialModifierType, this.modifierType);
1823
+ message["modifier node id"] = this.modifierNodeId;
1824
+ if (this.nextCredentialType != void 0) {
1825
+ message["next credential type"] = (0, import_shared.getEnumMemberName)(import_Types.UserCredentialType, this.nextCredentialType);
1826
+ }
1827
+ if (this.nextCredentialSlot != void 0) {
1828
+ message["next credential slot"] = this.nextCredentialSlot;
1829
+ }
1830
+ return { ...super.toLogEntry(ctx), message };
1798
1831
  }
1799
1832
  };
1800
1833
  return UserCredentialCCCredentialReport2 = _classThis;
@@ -2033,15 +2066,15 @@ let UserCredentialCCCredentialLearnReport = (() => {
2033
2066
  };
2034
2067
  return UserCredentialCCCredentialLearnReport2 = _classThis;
2035
2068
  })();
2036
- let UserCredentialCCUserCredentialAssociationSet = (() => {
2037
- let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.UserCredentialAssociationSet), (0, import_CommandClassDecorators.useSupervision)()];
2069
+ let UserCredentialCCAssociationReport = (() => {
2070
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.UserCredentialAssociationReport)];
2038
2071
  let _classDescriptor;
2039
2072
  let _classExtraInitializers = [];
2040
2073
  let _classThis;
2041
2074
  let _classSuper = UserCredentialCC;
2042
- var UserCredentialCCUserCredentialAssociationSet2 = class extends _classSuper {
2075
+ var UserCredentialCCAssociationReport2 = class extends _classSuper {
2043
2076
  static {
2044
- __name(this, "UserCredentialCCUserCredentialAssociationSet");
2077
+ __name(this, "UserCredentialCCAssociationReport");
2045
2078
  }
2046
2079
  static {
2047
2080
  _classThis = this;
@@ -2049,7 +2082,7 @@ let UserCredentialCCUserCredentialAssociationSet = (() => {
2049
2082
  static {
2050
2083
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
2051
2084
  (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
2052
- UserCredentialCCUserCredentialAssociationSet2 = _classThis = _classDescriptor.value;
2085
+ UserCredentialCCAssociationReport2 = _classThis = _classDescriptor.value;
2053
2086
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
2054
2087
  (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
2055
2088
  }
@@ -2058,51 +2091,70 @@ let UserCredentialCCUserCredentialAssociationSet = (() => {
2058
2091
  this.credentialType = options.credentialType;
2059
2092
  this.credentialSlot = options.credentialSlot;
2060
2093
  this.destinationUserId = options.destinationUserId;
2094
+ this.status = options.status;
2061
2095
  }
2062
- credentialType;
2063
- credentialSlot;
2064
- destinationUserId;
2065
2096
  static from(raw, ctx) {
2066
- (0, import_core.validatePayload)(raw.payload.length >= 5);
2097
+ (0, import_core.validatePayload)(raw.payload.length >= 6);
2067
2098
  const credentialType = raw.payload[0];
2068
2099
  const credentialSlot = raw.payload.readUInt16BE(1);
2069
2100
  const destinationUserId = raw.payload.readUInt16BE(3);
2101
+ const status = raw.payload[5];
2070
2102
  return new this({
2071
2103
  nodeId: ctx.sourceNodeId,
2072
2104
  credentialType,
2073
2105
  credentialSlot,
2074
- destinationUserId
2106
+ destinationUserId,
2107
+ status
2075
2108
  });
2076
2109
  }
2110
+ credentialType;
2111
+ credentialSlot;
2112
+ destinationUserId;
2113
+ status;
2077
2114
  serialize(ctx) {
2078
- this.payload = import_shared.Bytes.alloc(5);
2115
+ this.payload = import_shared.Bytes.alloc(6);
2079
2116
  this.payload[0] = this.credentialType;
2080
2117
  this.payload.writeUInt16BE(this.credentialSlot, 1);
2081
2118
  this.payload.writeUInt16BE(this.destinationUserId, 3);
2119
+ this.payload[5] = this.status;
2082
2120
  return super.serialize(ctx);
2083
2121
  }
2122
+ persistValues(ctx) {
2123
+ if (!super.persistValues(ctx))
2124
+ return false;
2125
+ if (this.status !== 0 || this.credentialType === import_Types.UserCredentialType.None || this.credentialSlot === 0) {
2126
+ return true;
2127
+ }
2128
+ this.setValue(ctx, import_CCValues_generated.UserCredentialCCValues.credentialOwner(this.credentialType, this.credentialSlot), this.destinationUserId);
2129
+ return true;
2130
+ }
2084
2131
  toLogEntry(ctx) {
2085
2132
  return {
2086
2133
  ...super.toLogEntry(ctx),
2087
2134
  message: {
2088
2135
  "credential type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialType, this.credentialType),
2089
2136
  "credential slot": this.credentialSlot,
2090
- "destination user ID": this.destinationUserId
2137
+ "destination user ID": this.destinationUserId,
2138
+ status: this.status
2091
2139
  }
2092
2140
  };
2093
2141
  }
2094
2142
  };
2095
- return UserCredentialCCUserCredentialAssociationSet2 = _classThis;
2143
+ return UserCredentialCCAssociationReport2 = _classThis;
2096
2144
  })();
2097
- let UserCredentialCCUserCredentialAssociationReport = (() => {
2098
- let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.UserCredentialAssociationReport)];
2145
+ function testResponseForUserCredentialAssociationSet(sent, received) {
2146
+ return sent.credentialType === received.credentialType && sent.credentialSlot === received.credentialSlot;
2147
+ }
2148
+ __name(testResponseForUserCredentialAssociationSet, "testResponseForUserCredentialAssociationSet");
2149
+ let UserCredentialCCAssociationSet = (() => {
2150
+ let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.UserCredentialAssociationSet), (0, import_CommandClassDecorators.expectedCCResponse)(UserCredentialCCAssociationReport, testResponseForUserCredentialAssociationSet)];
2099
2151
  let _classDescriptor;
2100
2152
  let _classExtraInitializers = [];
2101
2153
  let _classThis;
2102
2154
  let _classSuper = UserCredentialCC;
2103
- var UserCredentialCCUserCredentialAssociationReport2 = class extends _classSuper {
2155
+ var UserCredentialCCAssociationSet2 = class extends _classSuper {
2104
2156
  static {
2105
- __name(this, "UserCredentialCCUserCredentialAssociationReport");
2157
+ __name(this, "UserCredentialCCAssociationSet");
2106
2158
  }
2107
2159
  static {
2108
2160
  _classThis = this;
@@ -2110,7 +2162,7 @@ let UserCredentialCCUserCredentialAssociationReport = (() => {
2110
2162
  static {
2111
2163
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
2112
2164
  (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
2113
- UserCredentialCCUserCredentialAssociationReport2 = _classThis = _classDescriptor.value;
2165
+ UserCredentialCCAssociationSet2 = _classThis = _classDescriptor.value;
2114
2166
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
2115
2167
  (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
2116
2168
  }
@@ -2119,32 +2171,27 @@ let UserCredentialCCUserCredentialAssociationReport = (() => {
2119
2171
  this.credentialType = options.credentialType;
2120
2172
  this.credentialSlot = options.credentialSlot;
2121
2173
  this.destinationUserId = options.destinationUserId;
2122
- this.status = options.status;
2123
2174
  }
2175
+ credentialType;
2176
+ credentialSlot;
2177
+ destinationUserId;
2124
2178
  static from(raw, ctx) {
2125
- (0, import_core.validatePayload)(raw.payload.length >= 6);
2179
+ (0, import_core.validatePayload)(raw.payload.length >= 5);
2126
2180
  const credentialType = raw.payload[0];
2127
2181
  const credentialSlot = raw.payload.readUInt16BE(1);
2128
2182
  const destinationUserId = raw.payload.readUInt16BE(3);
2129
- const status = raw.payload[5];
2130
2183
  return new this({
2131
2184
  nodeId: ctx.sourceNodeId,
2132
2185
  credentialType,
2133
2186
  credentialSlot,
2134
- destinationUserId,
2135
- status
2187
+ destinationUserId
2136
2188
  });
2137
2189
  }
2138
- credentialType;
2139
- credentialSlot;
2140
- destinationUserId;
2141
- status;
2142
2190
  serialize(ctx) {
2143
- this.payload = import_shared.Bytes.alloc(6);
2191
+ this.payload = import_shared.Bytes.alloc(5);
2144
2192
  this.payload[0] = this.credentialType;
2145
2193
  this.payload.writeUInt16BE(this.credentialSlot, 1);
2146
2194
  this.payload.writeUInt16BE(this.destinationUserId, 3);
2147
- this.payload[5] = this.status;
2148
2195
  return super.serialize(ctx);
2149
2196
  }
2150
2197
  toLogEntry(ctx) {
@@ -2153,13 +2200,12 @@ let UserCredentialCCUserCredentialAssociationReport = (() => {
2153
2200
  message: {
2154
2201
  "credential type": (0, import_shared.getEnumMemberName)(import_Types.UserCredentialType, this.credentialType),
2155
2202
  "credential slot": this.credentialSlot,
2156
- "destination user ID": this.destinationUserId,
2157
- status: this.status
2203
+ "destination user ID": this.destinationUserId
2158
2204
  }
2159
2205
  };
2160
2206
  }
2161
2207
  };
2162
- return UserCredentialCCUserCredentialAssociationReport2 = _classThis;
2208
+ return UserCredentialCCAssociationSet2 = _classThis;
2163
2209
  })();
2164
2210
  let UserCredentialCCAllUsersChecksumReport = (() => {
2165
2211
  let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.UserCredentialCommand.AllUsersChecksumReport)];
@@ -2826,6 +2872,8 @@ let UserCredentialCCKeyLockerEntryGet = (() => {
2826
2872
  UserCredentialCCAdminPinCodeSet,
2827
2873
  UserCredentialCCAllUsersChecksumGet,
2828
2874
  UserCredentialCCAllUsersChecksumReport,
2875
+ UserCredentialCCAssociationReport,
2876
+ UserCredentialCCAssociationSet,
2829
2877
  UserCredentialCCCredentialCapabilitiesGet,
2830
2878
  UserCredentialCCCredentialCapabilitiesReport,
2831
2879
  UserCredentialCCCredentialChecksumGet,
@@ -2845,11 +2893,10 @@ let UserCredentialCCKeyLockerEntryGet = (() => {
2845
2893
  UserCredentialCCUserCapabilitiesReport,
2846
2894
  UserCredentialCCUserChecksumGet,
2847
2895
  UserCredentialCCUserChecksumReport,
2848
- UserCredentialCCUserCredentialAssociationReport,
2849
- UserCredentialCCUserCredentialAssociationSet,
2850
2896
  UserCredentialCCUserGet,
2851
2897
  UserCredentialCCUserReport,
2852
2898
  UserCredentialCCUserSet,
2853
- UserCredentialCCValues
2899
+ UserCredentialCCValues,
2900
+ normalizeCredentialData
2854
2901
  });
2855
2902
  //# sourceMappingURL=UserCredentialCC.js.map