@matter/node 0.16.0-alpha.0-20250814-484abe647 → 0.16.0-alpha.0-20250815-ac9fd6eb0

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 (73) hide show
  1. package/dist/cjs/behavior/state/validation/assertions.d.ts +2 -2
  2. package/dist/cjs/behavior/state/validation/assertions.d.ts.map +1 -1
  3. package/dist/cjs/behavior/state/validation/assertions.js +2 -2
  4. package/dist/cjs/behavior/state/validation/assertions.js.map +1 -1
  5. package/dist/cjs/behavior/state/validation/constraint.js +6 -4
  6. package/dist/cjs/behavior/state/validation/constraint.js.map +1 -1
  7. package/dist/cjs/behavior/system/commissioning/CommissioningServer.d.ts +1 -1
  8. package/dist/cjs/behavior/system/commissioning/CommissioningServer.d.ts.map +1 -1
  9. package/dist/cjs/behavior/system/commissioning/CommissioningServer.js.map +1 -1
  10. package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  11. package/dist/cjs/behaviors/access-control/AccessControlServer.js +2 -1
  12. package/dist/cjs/behaviors/access-control/AccessControlServer.js.map +1 -1
  13. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +2 -2
  14. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  15. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +2 -2
  16. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  17. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +8 -5
  18. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  19. package/dist/cjs/behaviors/groups/GroupsServer.d.ts.map +1 -1
  20. package/dist/cjs/behaviors/groups/GroupsServer.js +6 -2
  21. package/dist/cjs/behaviors/groups/GroupsServer.js.map +1 -1
  22. package/dist/cjs/behaviors/network-commissioning/NetworkCommissioningBehavior.d.ts +19 -19
  23. package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.d.ts +5 -5
  24. package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.js +2 -2
  25. package/dist/cjs/behaviors/operational-credentials/OperationalCredentialsServer.js.map +1 -1
  26. package/dist/cjs/behaviors/rvc-run-mode/RvcRunModeServer.d.ts.map +1 -1
  27. package/dist/cjs/behaviors/rvc-run-mode/RvcRunModeServer.js +0 -5
  28. package/dist/cjs/behaviors/rvc-run-mode/RvcRunModeServer.js.map +1 -1
  29. package/dist/cjs/behaviors/thermostat/ThermostatBehavior.d.ts +8 -8
  30. package/dist/cjs/devices/water-heater.d.ts +16 -16
  31. package/dist/cjs/node/server/InteractionServer.js +2 -2
  32. package/dist/esm/behavior/state/validation/assertions.d.ts +2 -2
  33. package/dist/esm/behavior/state/validation/assertions.d.ts.map +1 -1
  34. package/dist/esm/behavior/state/validation/assertions.js +3 -3
  35. package/dist/esm/behavior/state/validation/assertions.js.map +1 -1
  36. package/dist/esm/behavior/state/validation/constraint.js +6 -4
  37. package/dist/esm/behavior/state/validation/constraint.js.map +1 -1
  38. package/dist/esm/behavior/system/commissioning/CommissioningServer.d.ts +1 -1
  39. package/dist/esm/behavior/system/commissioning/CommissioningServer.d.ts.map +1 -1
  40. package/dist/esm/behavior/system/commissioning/CommissioningServer.js.map +1 -1
  41. package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  42. package/dist/esm/behaviors/access-control/AccessControlServer.js +3 -2
  43. package/dist/esm/behaviors/access-control/AccessControlServer.js.map +1 -1
  44. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +2 -2
  45. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  46. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +2 -2
  47. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  48. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +8 -5
  49. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  50. package/dist/esm/behaviors/groups/GroupsServer.d.ts.map +1 -1
  51. package/dist/esm/behaviors/groups/GroupsServer.js +6 -2
  52. package/dist/esm/behaviors/groups/GroupsServer.js.map +1 -1
  53. package/dist/esm/behaviors/network-commissioning/NetworkCommissioningBehavior.d.ts +19 -19
  54. package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.d.ts +5 -5
  55. package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.js +2 -2
  56. package/dist/esm/behaviors/operational-credentials/OperationalCredentialsServer.js.map +1 -1
  57. package/dist/esm/behaviors/rvc-run-mode/RvcRunModeServer.d.ts.map +1 -1
  58. package/dist/esm/behaviors/rvc-run-mode/RvcRunModeServer.js +0 -5
  59. package/dist/esm/behaviors/rvc-run-mode/RvcRunModeServer.js.map +1 -1
  60. package/dist/esm/behaviors/thermostat/ThermostatBehavior.d.ts +8 -8
  61. package/dist/esm/devices/water-heater.d.ts +16 -16
  62. package/dist/esm/node/server/InteractionServer.js +2 -2
  63. package/package.json +7 -7
  64. package/src/behavior/state/validation/assertions.ts +5 -5
  65. package/src/behavior/state/validation/constraint.ts +6 -4
  66. package/src/behavior/system/commissioning/CommissioningServer.ts +1 -1
  67. package/src/behaviors/access-control/AccessControlServer.ts +7 -2
  68. package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +2 -2
  69. package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +10 -7
  70. package/src/behaviors/groups/GroupsServer.ts +6 -2
  71. package/src/behaviors/operational-credentials/OperationalCredentialsServer.ts +2 -2
  72. package/src/behaviors/rvc-run-mode/RvcRunModeServer.ts +0 -7
  73. package/src/node/server/InteractionServer.ts +2 -2
@@ -579,7 +579,7 @@ class InteractionServer {
579
579
  // Assume for now we have multiple responses when having multiple invokes
580
580
  };
581
581
  const emptyInvokeResponseBytes = TlvInvokeResponseForSend.encode(invokeResponseMessage);
582
- let messageSize = emptyInvokeResponseBytes.length;
582
+ let messageSize = emptyInvokeResponseBytes.byteLength;
583
583
  let invokeResultsProcessed = 0;
584
584
  const processResponseResult = async (invokeResponse) => {
585
585
  invokeResultsProcessed++;
@@ -617,7 +617,7 @@ class InteractionServer {
617
617
  }
618
618
  );
619
619
  invokeResponseMessage.invokeResponses = [];
620
- messageSize = emptyInvokeResponseBytes.length;
620
+ messageSize = emptyInvokeResponseBytes.byteLength;
621
621
  }
622
622
  if (!lastMessageProcessed) {
623
623
  invokeResultsProcessed--;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matter/node",
3
- "version": "0.16.0-alpha.0-20250814-484abe647",
3
+ "version": "0.16.0-alpha.0-20250815-ac9fd6eb0",
4
4
  "description": "API for building Matter nodes",
5
5
  "keywords": [
6
6
  "iot",
@@ -42,14 +42,14 @@
42
42
  "#*": "./src/*"
43
43
  },
44
44
  "dependencies": {
45
- "@matter/general": "0.16.0-alpha.0-20250814-484abe647",
46
- "@matter/model": "0.16.0-alpha.0-20250814-484abe647",
47
- "@matter/types": "0.16.0-alpha.0-20250814-484abe647",
48
- "@matter/protocol": "0.16.0-alpha.0-20250814-484abe647"
45
+ "@matter/general": "0.16.0-alpha.0-20250815-ac9fd6eb0",
46
+ "@matter/model": "0.16.0-alpha.0-20250815-ac9fd6eb0",
47
+ "@matter/types": "0.16.0-alpha.0-20250815-ac9fd6eb0",
48
+ "@matter/protocol": "0.16.0-alpha.0-20250815-ac9fd6eb0"
49
49
  },
50
50
  "devDependencies": {
51
- "@matter/tools": "0.16.0-alpha.0-20250814-484abe647",
52
- "@matter/testing": "0.16.0-alpha.0-20250814-484abe647"
51
+ "@matter/tools": "0.16.0-alpha.0-20250815-ac9fd6eb0",
52
+ "@matter/testing": "0.16.0-alpha.0-20250815-ac9fd6eb0"
53
53
  },
54
54
  "files": [
55
55
  "dist/**/*",
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { isObject } from "#general";
7
+ import { Bytes, isObject } from "#general";
8
8
  import { SchemaErrorPath } from "#model";
9
9
  import { DatatypeError, Val } from "#protocol";
10
10
 
@@ -43,15 +43,15 @@ export function assertString(value: Val, path: SchemaErrorPath): asserts value i
43
43
  throw new DatatypeError(path, "a string", value);
44
44
  }
45
45
 
46
- export function assertBytes(value: Val, path: SchemaErrorPath): asserts value is Uint8Array {
47
- if (value instanceof Uint8Array) {
46
+ export function assertBytes(value: Val, path: SchemaErrorPath): asserts value is BufferSource {
47
+ if (Bytes.isBytes(value)) {
48
48
  return;
49
49
  }
50
50
  throw new DatatypeError(path, "a byte array", value);
51
51
  }
52
52
 
53
- export function assertSequence(value: Val, path: SchemaErrorPath): asserts value is string | Uint8Array {
54
- if (typeof value === "string" || value instanceof Uint8Array) {
53
+ export function assertSequence(value: Val, path: SchemaErrorPath): asserts value is string | BufferSource {
54
+ if (typeof value === "string" || Bytes.isBytes(value)) {
55
55
  return;
56
56
  }
57
57
  throw new DatatypeError(path, "a string or byte array", value);
@@ -97,11 +97,12 @@ function create(
97
97
  case Metatype.string: {
98
98
  const validateLength: ValueSupervisor.Validate = (value: Val, _session, location) => {
99
99
  assertSequence(value, location);
100
- if (!constraint.test(value.length, nameResolverFactory(location))) {
100
+ const length = typeof value === "string" ? value.length : value.byteLength;
101
+ if (!constraint.test(length, nameResolverFactory(location))) {
101
102
  throw new ConstraintError(
102
103
  schema,
103
104
  location,
104
- `String length of ${value.length} is not within bounds defined by constraint`,
105
+ `String length of ${length} is not within bounds defined by constraint`,
105
106
  );
106
107
  }
107
108
  };
@@ -129,11 +130,12 @@ function create(
129
130
  case Metatype.bytes:
130
131
  return (value: Val, _session, location) => {
131
132
  assertSequence(value, location);
132
- if (!constraint.test(value.length, nameResolverFactory(location))) {
133
+ const length = typeof value === "string" ? value.length : value.byteLength;
134
+ if (!constraint.test(length, nameResolverFactory(location))) {
133
135
  throw new ConstraintError(
134
136
  schema,
135
137
  location,
136
- `Byte length of ${value.length} is not within bounds defined by constraint`,
138
+ `Byte length of ${length} is not within bounds defined by constraint`,
137
139
  );
138
140
  }
139
141
  };
@@ -374,7 +374,7 @@ export namespace CommissioningServer {
374
374
  passcode = -1;
375
375
  discriminator = -1;
376
376
  flowType = CommissioningFlowType.Standard;
377
- additionalBleAdvertisementData?: Uint8Array = undefined;
377
+ additionalBleAdvertisementData?: BufferSource = undefined;
378
378
  pairingCodes = {} as PairingCodes;
379
379
  mdns?: MdnsAdvertiser.Options;
380
380
  ble?: BleAdvertiser.Options;
@@ -6,7 +6,7 @@
6
6
 
7
7
  import { ActionContext } from "#behavior/context/ActionContext.js";
8
8
  import { AccessControl as AccessControlTypes } from "#clusters/access-control";
9
- import { deepCopy, InternalError, Logger, MaybePromise } from "#general";
9
+ import { Bytes, deepCopy, InternalError, Logger, MaybePromise } from "#general";
10
10
  import { NodeLifecycle } from "#node/NodeLifecycle.js";
11
11
  import {
12
12
  AccessControl,
@@ -401,7 +401,12 @@ export class AccessControlServer extends AccessControlBehavior.with("Extension")
401
401
  */
402
402
  protected extensionEntryValidator(extension: AccessControlTypes.AccessControlExtension) {
403
403
  const { data } = extension;
404
- if (data.length < 2 || data[0] !== TlvType.List || data[data.length - 1] !== TlvType.EndOfContainer) {
404
+ const extensionBytes = Bytes.of(data);
405
+ if (
406
+ extensionBytes.length < 2 ||
407
+ extensionBytes[0] !== TlvType.List ||
408
+ extensionBytes[extensionBytes.length - 1] !== TlvType.EndOfContainer
409
+ ) {
405
410
  // Easier to check that way that it is an Listen without any tags in general
406
411
  throw new StatusResponseError("Extension must be a valid TLV", StatusCode.ConstraintError);
407
412
  }
@@ -74,13 +74,13 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
74
74
  commissioningTimeout,
75
75
  }: AdministratorCommissioning.OpenCommissioningWindowRequest) {
76
76
  // We monkey patched the Tlv definition above, so take care about correct error handling
77
- if (pakePasscodeVerifier.length !== PAKE_PASSCODE_VERIFIER_LENGTH) {
77
+ if (pakePasscodeVerifier.byteLength !== PAKE_PASSCODE_VERIFIER_LENGTH) {
78
78
  throw new AdministratorCommissioning.PakeParameterError("PAKE passcode verifier length is invalid");
79
79
  }
80
80
  if (iterations < 1000 || iterations > 100_000) {
81
81
  throw new AdministratorCommissioning.PakeParameterError("PAKE iterations invalid");
82
82
  }
83
- if (salt.length < 16 || salt.length > 32) {
83
+ if (salt.byteLength < 16 || salt.byteLength > 32) {
84
84
  throw new AdministratorCommissioning.PakeParameterError("PAKE salt has invalid length.");
85
85
  }
86
86
 
@@ -53,7 +53,8 @@ export class GeneralDiagnosticsServer extends Base {
53
53
  if (this.state.testEventTriggersEnabled === undefined) {
54
54
  this.state.testEventTriggersEnabled = false;
55
55
  } else if (this.state.testEventTriggersEnabled) {
56
- if (this.state.deviceTestEnableKey.every(byte => byte === 0)) {
56
+ const enableKey = Bytes.of(this.state.deviceTestEnableKey);
57
+ if (enableKey.every(byte => byte === 0)) {
57
58
  throw new ImplementationError("Test event triggers are enabled but no deviceTestEnableKey is set.");
58
59
  }
59
60
  logger.warn("Test event triggers are enabled. Make sure to disable them in production.");
@@ -80,12 +81,14 @@ export class GeneralDiagnosticsServer extends Base {
80
81
  }
81
82
  }
82
83
 
83
- #validateTestEnabledKey(enableKey: Uint8Array) {
84
- if (enableKey.every(byte => byte === 0)) {
84
+ #validateTestEnabledKey(enableKey: Bytes) {
85
+ const keyData = Bytes.of(enableKey);
86
+ if (keyData.every(byte => byte === 0)) {
85
87
  throw new StatusResponseError("Invalid test enable key, all zeros", StatusCode.ConstraintError);
86
88
  }
87
- enableKey.forEach((byte, index) => {
88
- if (byte !== this.state.deviceTestEnableKey[index]) {
89
+ const expectedKeyData = Bytes.of(this.state.deviceTestEnableKey);
90
+ keyData.forEach((byte, index) => {
91
+ if (byte !== expectedKeyData[index]) {
89
92
  throw new StatusResponseError("Invalid test enable key", StatusCode.ConstraintError);
90
93
  }
91
94
  });
@@ -154,7 +157,7 @@ export class GeneralDiagnosticsServer extends Base {
154
157
  },
155
158
  },
156
159
  ],
157
- }).length;
160
+ }).byteLength;
158
161
 
159
162
  const exchange = this.context.exchange;
160
163
  if (exchange === undefined) {
@@ -390,7 +393,7 @@ export namespace GeneralDiagnosticsServer {
390
393
  totalOperationalHoursCounter: number = 0;
391
394
 
392
395
  /** The TestEnableKey set for this device for the test commands. Default means "not enabled"." */
393
- deviceTestEnableKey = new Uint8Array(16).fill(0);
396
+ deviceTestEnableKey: Bytes = new Uint8Array(16).fill(0);
394
397
 
395
398
  [Val.properties](endpoint: Endpoint, _session: ValueSupervisor.Session) {
396
399
  return {
@@ -75,8 +75,12 @@ export class GroupsServer extends GroupsBase {
75
75
  return rootEndpoint;
76
76
  }
77
77
 
78
- #actOnGroupKeyManagement(act: (groupKeyManagement: GroupKeyManagementServer) => unknown) {
79
- return this.#rootEndpoint().act(agent => act(agent.get(GroupKeyManagementServer)));
78
+ async #actOnGroupKeyManagement<T>(act: (groupKeyManagement: GroupKeyManagementServer) => T): Promise<T> {
79
+ const agent = this.context.agentFor(this.#rootEndpoint());
80
+ const gkm = agent.get(GroupKeyManagementServer);
81
+ await agent.context.transaction.addResources(gkm);
82
+ await agent.context.transaction.begin();
83
+ return act(gkm);
80
84
  }
81
85
 
82
86
  override async addGroup({ groupId, groupName }: Groups.AddGroupRequest): Promise<Groups.AddGroupResponse> {
@@ -94,7 +94,7 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
94
94
  }
95
95
 
96
96
  override async attestationRequest({ attestationNonce }: OperationalCredentials.AttestationRequest) {
97
- if (attestationNonce.length !== 32) {
97
+ if (attestationNonce.byteLength !== 32) {
98
98
  throw new StatusResponseError("Invalid attestation nonce length", StatusCode.InvalidCommand);
99
99
  }
100
100
 
@@ -115,7 +115,7 @@ export class OperationalCredentialsServer extends OperationalCredentialsBehavior
115
115
  }
116
116
 
117
117
  override async csrRequest({ csrNonce, isForUpdateNoc }: OperationalCredentials.CsrRequest) {
118
- if (csrNonce.length !== 32) {
118
+ if (csrNonce.byteLength !== 32) {
119
119
  throw new StatusResponseError("Invalid csr nonce length", StatusCode.InvalidCommand);
120
120
  }
121
121
 
@@ -36,13 +36,6 @@ export class RvcRunModeServer extends RvcRunModeBehavior {
36
36
  ) {
37
37
  throw new ImplementationError("Provided supportedModes need to include at least one Cleaning mode tag");
38
38
  }
39
- if (
40
- !this.state.supportedModes.some(({ modeTags }) =>
41
- modeTags.some(({ value }) => value === RvcRunMode.ModeTag.Cleaning),
42
- )
43
- ) {
44
- throw new ImplementationError("Provided supportedModes need to include at least one Cleaning mode tag");
45
- }
46
39
  if (
47
40
  this.state.supportedModes.some(({ modeTags }) => {
48
41
  let exclusiveModeCounter = 0;
@@ -714,7 +714,7 @@ export class InteractionServer implements ProtocolHandler, InteractionRecipient
714
714
  moreChunkedMessages: invokeRequests.length > 1, // Assume for now we have multiple responses when having multiple invokes
715
715
  };
716
716
  const emptyInvokeResponseBytes = TlvInvokeResponseForSend.encode(invokeResponseMessage);
717
- let messageSize = emptyInvokeResponseBytes.length;
717
+ let messageSize = emptyInvokeResponseBytes.byteLength;
718
718
  let invokeResultsProcessed = 0;
719
719
 
720
720
  // To lower potential latency when we would process all invoke messages and just send responses at the end we
@@ -766,7 +766,7 @@ export class InteractionServer implements ProtocolHandler, InteractionRecipient
766
766
  },
767
767
  );
768
768
  invokeResponseMessage.invokeResponses = [];
769
- messageSize = emptyInvokeResponseBytes.length;
769
+ messageSize = emptyInvokeResponseBytes.byteLength;
770
770
  }
771
771
  if (!lastMessageProcessed) {
772
772
  invokeResultsProcessed--; // Correct counter again because we recall the method