@matter/protocol 0.15.1 → 0.15.2-alpha.0-20250703-2e16aba2b

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 (149) hide show
  1. package/dist/cjs/action/Val.d.ts +4 -0
  2. package/dist/cjs/action/Val.d.ts.map +1 -1
  3. package/dist/cjs/action/Val.js.map +1 -1
  4. package/dist/cjs/action/client/ClientInteraction.d.ts +10 -8
  5. package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
  6. package/dist/cjs/action/client/ClientInteraction.js +152 -80
  7. package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
  8. package/dist/cjs/action/client/ClientSubscription.d.ts +17 -0
  9. package/dist/cjs/action/client/ClientSubscription.d.ts.map +1 -0
  10. package/dist/cjs/action/client/ClientSubscription.js +22 -0
  11. package/dist/cjs/action/client/ClientSubscription.js.map +6 -0
  12. package/dist/cjs/action/client/ClientSubscriptionHandler.d.ts +20 -0
  13. package/dist/cjs/action/client/ClientSubscriptionHandler.d.ts.map +1 -0
  14. package/dist/cjs/action/client/ClientSubscriptionHandler.js +117 -0
  15. package/dist/cjs/action/client/ClientSubscriptionHandler.js.map +6 -0
  16. package/dist/cjs/action/client/ClientSubscriptions.d.ts +45 -0
  17. package/dist/cjs/action/client/ClientSubscriptions.d.ts.map +1 -0
  18. package/dist/cjs/action/client/ClientSubscriptions.js +141 -0
  19. package/dist/cjs/action/client/ClientSubscriptions.js.map +6 -0
  20. package/dist/cjs/action/client/InputChunk.d.ts +12 -0
  21. package/dist/cjs/action/client/InputChunk.d.ts.map +1 -0
  22. package/dist/cjs/action/client/InputChunk.js +89 -0
  23. package/dist/cjs/action/client/InputChunk.js.map +6 -0
  24. package/dist/cjs/action/client/ReadScope.d.ts +26 -0
  25. package/dist/cjs/action/client/ReadScope.d.ts.map +1 -0
  26. package/dist/cjs/action/client/ReadScope.js +87 -0
  27. package/dist/cjs/action/client/ReadScope.js.map +6 -0
  28. package/dist/cjs/action/client/index.d.ts +5 -0
  29. package/dist/cjs/action/client/index.d.ts.map +1 -1
  30. package/dist/cjs/action/client/index.js +5 -0
  31. package/dist/cjs/action/client/index.js.map +1 -1
  32. package/dist/cjs/action/request/Read.d.ts +0 -4
  33. package/dist/cjs/action/request/Read.d.ts.map +1 -1
  34. package/dist/cjs/action/request/Read.js.map +1 -1
  35. package/dist/cjs/action/request/Subscribe.d.ts +14 -1
  36. package/dist/cjs/action/request/Subscribe.d.ts.map +1 -1
  37. package/dist/cjs/action/request/Subscribe.js +2 -2
  38. package/dist/cjs/action/request/Subscribe.js.map +1 -1
  39. package/dist/cjs/action/response/SubscribeResult.d.ts +3 -5
  40. package/dist/cjs/action/response/SubscribeResult.d.ts.map +1 -1
  41. package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
  42. package/dist/cjs/common/FailsafeContext.js +0 -1
  43. package/dist/cjs/common/FailsafeContext.js.map +1 -1
  44. package/dist/cjs/fabric/FabricAuthority.d.ts +6 -1
  45. package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
  46. package/dist/cjs/fabric/FabricAuthority.js +16 -0
  47. package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
  48. package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
  49. package/dist/cjs/interaction/InteractionClient.js +8 -4
  50. package/dist/cjs/interaction/InteractionClient.js.map +1 -1
  51. package/dist/cjs/interaction/InteractionMessenger.d.ts +20 -16
  52. package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
  53. package/dist/cjs/interaction/InteractionMessenger.js +18 -10
  54. package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
  55. package/dist/cjs/mdns/MdnsScanner.d.ts +5 -6
  56. package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
  57. package/dist/cjs/mdns/MdnsScanner.js.map +1 -1
  58. package/dist/cjs/protocol/DeviceCommissioner.d.ts +1 -1
  59. package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
  60. package/dist/cjs/protocol/DeviceCommissioner.js +2 -5
  61. package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
  62. package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +3 -0
  63. package/dist/cjs/securechannel/SecureChannelMessenger.d.ts.map +1 -1
  64. package/dist/cjs/securechannel/SecureChannelMessenger.js +4 -0
  65. package/dist/cjs/securechannel/SecureChannelMessenger.js.map +1 -1
  66. package/dist/esm/action/Val.d.ts +4 -0
  67. package/dist/esm/action/Val.d.ts.map +1 -1
  68. package/dist/esm/action/Val.js.map +1 -1
  69. package/dist/esm/action/client/ClientInteraction.d.ts +10 -8
  70. package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
  71. package/dist/esm/action/client/ClientInteraction.js +154 -82
  72. package/dist/esm/action/client/ClientInteraction.js.map +1 -1
  73. package/dist/esm/action/client/ClientSubscription.d.ts +17 -0
  74. package/dist/esm/action/client/ClientSubscription.d.ts.map +1 -0
  75. package/dist/esm/action/client/ClientSubscription.js +6 -0
  76. package/dist/esm/action/client/ClientSubscription.js.map +6 -0
  77. package/dist/esm/action/client/ClientSubscriptionHandler.d.ts +20 -0
  78. package/dist/esm/action/client/ClientSubscriptionHandler.d.ts.map +1 -0
  79. package/dist/esm/action/client/ClientSubscriptionHandler.js +97 -0
  80. package/dist/esm/action/client/ClientSubscriptionHandler.js.map +6 -0
  81. package/dist/esm/action/client/ClientSubscriptions.d.ts +45 -0
  82. package/dist/esm/action/client/ClientSubscriptions.d.ts.map +1 -0
  83. package/dist/esm/action/client/ClientSubscriptions.js +129 -0
  84. package/dist/esm/action/client/ClientSubscriptions.js.map +6 -0
  85. package/dist/esm/action/client/InputChunk.d.ts +12 -0
  86. package/dist/esm/action/client/InputChunk.d.ts.map +1 -0
  87. package/dist/esm/action/client/InputChunk.js +69 -0
  88. package/dist/esm/action/client/InputChunk.js.map +6 -0
  89. package/dist/esm/action/client/ReadScope.d.ts +26 -0
  90. package/dist/esm/action/client/ReadScope.d.ts.map +1 -0
  91. package/dist/esm/action/client/ReadScope.js +67 -0
  92. package/dist/esm/action/client/ReadScope.js.map +6 -0
  93. package/dist/esm/action/client/index.d.ts +5 -0
  94. package/dist/esm/action/client/index.d.ts.map +1 -1
  95. package/dist/esm/action/client/index.js +5 -0
  96. package/dist/esm/action/client/index.js.map +1 -1
  97. package/dist/esm/action/request/Read.d.ts +0 -4
  98. package/dist/esm/action/request/Read.d.ts.map +1 -1
  99. package/dist/esm/action/request/Read.js.map +1 -1
  100. package/dist/esm/action/request/Subscribe.d.ts +14 -1
  101. package/dist/esm/action/request/Subscribe.d.ts.map +1 -1
  102. package/dist/esm/action/request/Subscribe.js +2 -2
  103. package/dist/esm/action/request/Subscribe.js.map +1 -1
  104. package/dist/esm/action/response/SubscribeResult.d.ts +3 -5
  105. package/dist/esm/action/response/SubscribeResult.d.ts.map +1 -1
  106. package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
  107. package/dist/esm/common/FailsafeContext.js +0 -1
  108. package/dist/esm/common/FailsafeContext.js.map +1 -1
  109. package/dist/esm/fabric/FabricAuthority.d.ts +6 -1
  110. package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
  111. package/dist/esm/fabric/FabricAuthority.js +25 -1
  112. package/dist/esm/fabric/FabricAuthority.js.map +1 -1
  113. package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
  114. package/dist/esm/interaction/InteractionClient.js +8 -4
  115. package/dist/esm/interaction/InteractionClient.js.map +1 -1
  116. package/dist/esm/interaction/InteractionMessenger.d.ts +20 -16
  117. package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
  118. package/dist/esm/interaction/InteractionMessenger.js +18 -10
  119. package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
  120. package/dist/esm/mdns/MdnsScanner.d.ts +5 -6
  121. package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
  122. package/dist/esm/mdns/MdnsScanner.js.map +1 -1
  123. package/dist/esm/protocol/DeviceCommissioner.d.ts +1 -1
  124. package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
  125. package/dist/esm/protocol/DeviceCommissioner.js +2 -5
  126. package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
  127. package/dist/esm/securechannel/SecureChannelMessenger.d.ts +3 -0
  128. package/dist/esm/securechannel/SecureChannelMessenger.d.ts.map +1 -1
  129. package/dist/esm/securechannel/SecureChannelMessenger.js +4 -0
  130. package/dist/esm/securechannel/SecureChannelMessenger.js.map +1 -1
  131. package/package.json +6 -6
  132. package/src/action/Val.ts +5 -0
  133. package/src/action/client/ClientInteraction.ts +178 -90
  134. package/src/action/client/ClientSubscription.ts +18 -0
  135. package/src/action/client/ClientSubscriptionHandler.ts +137 -0
  136. package/src/action/client/ClientSubscriptions.ts +172 -0
  137. package/src/action/client/InputChunk.ts +79 -0
  138. package/src/action/client/ReadScope.ts +107 -0
  139. package/src/action/client/index.ts +5 -0
  140. package/src/action/request/Read.ts +0 -5
  141. package/src/action/request/Subscribe.ts +17 -3
  142. package/src/action/response/SubscribeResult.ts +3 -4
  143. package/src/common/FailsafeContext.ts +0 -1
  144. package/src/fabric/FabricAuthority.ts +29 -1
  145. package/src/interaction/InteractionClient.ts +8 -4
  146. package/src/interaction/InteractionMessenger.ts +18 -11
  147. package/src/mdns/MdnsScanner.ts +5 -6
  148. package/src/protocol/DeviceCommissioner.ts +2 -7
  149. package/src/securechannel/SecureChannelMessenger.ts +4 -0
@@ -509,7 +509,8 @@ export class InteractionClient {
509
509
  .join(", ")} and events ${eventRequests?.map(path => resolveEventName(path)).join(", ")}`,
510
510
  );
511
511
  // Send read request and combine all (potentially chunked) responses
512
- const response = await messenger.sendReadRequest(request);
512
+ await messenger.sendReadRequest(request);
513
+ const response = await messenger.readAggregateDataReport();
513
514
 
514
515
  // Normalize and decode the response
515
516
  const normalizedResult = DecodedDataReport(response);
@@ -752,7 +753,7 @@ export class InteractionClient {
752
753
  report: DataReport;
753
754
  maximumPeerResponseTimeMs: number;
754
755
  }>(async messenger => {
755
- const { subscribeResponse, report } = await messenger.sendSubscribeRequest({
756
+ await messenger.sendSubscribeRequest({
756
757
  interactionModelRevision: Specification.INTERACTION_MODEL_REVISION,
757
758
  attributeRequests: [{ endpointId, clusterId, attributeId }],
758
759
  dataVersionFilters:
@@ -764,6 +765,7 @@ export class InteractionClient {
764
765
  maxIntervalCeilingSeconds,
765
766
  isFabricFiltered,
766
767
  });
768
+ const { subscribeResponse, report } = await messenger.readAggregateSubscribeResponse();
767
769
  return {
768
770
  subscribeResponse,
769
771
  report,
@@ -863,7 +865,7 @@ export class InteractionClient {
863
865
  report: DataReport;
864
866
  maximumPeerResponseTimeMs: number;
865
867
  }>(async messenger => {
866
- const { subscribeResponse, report } = await messenger.sendSubscribeRequest({
868
+ await messenger.sendSubscribeRequest({
867
869
  interactionModelRevision: Specification.INTERACTION_MODEL_REVISION,
868
870
  eventRequests: [{ endpointId, clusterId, eventId, isUrgent }],
869
871
  eventFilters: minimumEventNumber !== undefined ? [{ eventMin: minimumEventNumber }] : undefined,
@@ -872,6 +874,7 @@ export class InteractionClient {
872
874
  maxIntervalCeilingSeconds,
873
875
  isFabricFiltered,
874
876
  });
877
+ const { subscribeResponse, report } = await messenger.readAggregateSubscribeResponse();
875
878
  return {
876
879
  subscribeResponse,
877
880
  report,
@@ -1030,7 +1033,7 @@ export class InteractionClient {
1030
1033
  report: DataReport;
1031
1034
  maximumPeerResponseTimeMs: number;
1032
1035
  }>(async messenger => {
1033
- const { subscribeResponse, report } = await messenger.sendSubscribeRequest({
1036
+ await messenger.sendSubscribeRequest({
1034
1037
  interactionModelRevision: Specification.INTERACTION_MODEL_REVISION,
1035
1038
  attributeRequests,
1036
1039
  eventRequests,
@@ -1044,6 +1047,7 @@ export class InteractionClient {
1044
1047
  dataVersion,
1045
1048
  })),
1046
1049
  });
1050
+ const { subscribeResponse, report } = await messenger.readAggregateSubscribeResponse();
1047
1051
  return {
1048
1052
  subscribeResponse,
1049
1053
  report,
@@ -848,6 +848,14 @@ export class IncomingInteractionClientMessenger extends InteractionMessenger {
848
848
  return result;
849
849
  }
850
850
 
851
+ /**
852
+ * Read a single data report.
853
+ */
854
+ async readDataReport() {
855
+ const dataReportMessage = await this.waitFor("DataReport", MessageType.ReportData);
856
+ return TlvDataReport.decode(dataReportMessage.payload);
857
+ }
858
+
851
859
  /**
852
860
  * Read data reports as they come in on the wire.
853
861
  *
@@ -855,8 +863,7 @@ export class IncomingInteractionClientMessenger extends InteractionMessenger {
855
863
  */
856
864
  async *readDataReports() {
857
865
  while (true) {
858
- const dataReportMessage = await this.waitFor("DataReport", MessageType.ReportData);
859
- const report = TlvDataReport.decode(dataReportMessage.payload);
866
+ const report = await this.readDataReport();
860
867
 
861
868
  yield report;
862
869
 
@@ -895,16 +902,16 @@ export class IncomingInteractionClientMessenger extends InteractionMessenger {
895
902
  }
896
903
 
897
904
  export class InteractionClientMessenger extends IncomingInteractionClientMessenger {
905
+ #exchangeProvider: ExchangeProvider;
906
+
898
907
  static async create(exchangeProvider: ExchangeProvider) {
899
908
  const exchange = await exchangeProvider.initiateExchange();
900
909
  return new this(exchange, exchangeProvider);
901
910
  }
902
911
 
903
- constructor(
904
- exchange: MessageExchange,
905
- private readonly exchangeProvider: ExchangeProvider,
906
- ) {
912
+ constructor(exchange: MessageExchange, exchangeProvider: ExchangeProvider) {
907
913
  super(exchange);
914
+ this.#exchangeProvider = exchangeProvider;
908
915
  }
909
916
 
910
917
  /** Implements a send method with an automatic reconnection mechanism */
@@ -917,7 +924,7 @@ export class InteractionClientMessenger extends IncomingInteractionClientMesseng
917
924
  return await this.exchange.send(messageType, payload, options);
918
925
  } catch (error) {
919
926
  if (
920
- this.exchangeProvider.supportsReconnect &&
927
+ this.#exchangeProvider.supportsReconnect &&
921
928
  (error instanceof RetransmissionLimitReachedError || error instanceof ChannelNotConnectedError) &&
922
929
  !options?.multipleMessageInteraction
923
930
  ) {
@@ -927,8 +934,8 @@ export class InteractionClientMessenger extends IncomingInteractionClientMesseng
927
934
  `${error instanceof RetransmissionLimitReachedError ? "Retransmission limit reached" : "Channel not connected"}, trying to reconnect and resend the message.`,
928
935
  );
929
936
  await this.exchange.close();
930
- if (await this.exchangeProvider.reconnectChannel()) {
931
- this.exchange = await this.exchangeProvider.initiateExchange();
937
+ if (await this.#exchangeProvider.reconnectChannel()) {
938
+ this.exchange = await this.#exchangeProvider.initiateExchange();
932
939
  return await this.exchange.send(messageType, payload, options);
933
940
  }
934
941
  } else {
@@ -939,8 +946,6 @@ export class InteractionClientMessenger extends IncomingInteractionClientMesseng
939
946
 
940
947
  async sendReadRequest(readRequest: ReadRequest) {
941
948
  await this.send(MessageType.ReadRequest, this.#encodeReadingRequest(TlvReadRequest, readRequest));
942
-
943
- return this.readAggregateDataReport();
944
949
  }
945
950
 
946
951
  #encodeReadingRequest<T extends TlvSchema<any>>(schema: T, request: TypeFromSchema<T>) {
@@ -1000,7 +1005,9 @@ export class InteractionClientMessenger extends IncomingInteractionClientMesseng
1000
1005
  async sendSubscribeRequest(subscribeRequest: SubscribeRequest) {
1001
1006
  const request = this.#encodeReadingRequest(TlvSubscribeRequest, subscribeRequest);
1002
1007
  await this.send(MessageType.SubscribeRequest, request);
1008
+ }
1003
1009
 
1010
+ async readAggregateSubscribeResponse() {
1004
1011
  const report = await this.readAggregateDataReport();
1005
1012
  const { subscriptionId } = report;
1006
1013
 
@@ -96,13 +96,12 @@ const START_ANNOUNCE_INTERVAL_SECONDS = 1.5;
96
96
  /**
97
97
  * Interface to add criteria for MDNS discovery a node is interested in
98
98
  *
99
- * This interface is used to define criteria for mDNS scanner targets.
100
- * It includes the information if commissionable devices are relevant for the target
101
- * and a list of operational targets. Operational targets can consist of operational IDs
102
- * and optional node IDs.
99
+ * This interface is used to define criteria for mDNS scanner targets. It includes the information if commissionable
100
+ * devices are relevant for the target and a list of operational targets. Operational targets can consist of operational
101
+ * IDs and optional node IDs.
103
102
  *
104
- * When no commissionable devices are relevant and no operational targets are defined, it is
105
- * not required to add a criteria to the scanner.
103
+ * When no commissionable devices are relevant and no operational targets are defined, it is not required to add a
104
+ * criteria to the scanner.
106
105
  */
107
106
  export interface MdnsScannerTargetCriteria {
108
107
  /** Are commissionable MDNS records relevant? */
@@ -162,9 +162,7 @@ export class DeviceCommissioner {
162
162
  );
163
163
  }
164
164
 
165
- async beginTimed(failsafeContext: FailsafeContext) {
166
- await failsafeContext.construction;
167
-
165
+ beginTimed(failsafeContext: FailsafeContext) {
168
166
  this.#failsafeContext = failsafeContext;
169
167
 
170
168
  this.#context.fabrics.events.added.on(fabric => {
@@ -246,10 +244,7 @@ export class DeviceCommissioner {
246
244
  this.#activeDiscriminator = discriminator;
247
245
 
248
246
  // MDNS is sent in parallel
249
- // TODO - untracked promise
250
- this.#enterCommissioningMode(windowStatus, discriminator).catch(error =>
251
- logger.warn("Error sending announcement:", error),
252
- );
247
+ await this.#enterCommissioningMode(windowStatus, discriminator);
253
248
  }
254
249
 
255
250
  async endCommissioning() {
@@ -60,6 +60,7 @@ export class SecureChannelMessenger {
60
60
 
61
61
  /**
62
62
  * Waits for the next message and returns it.
63
+ *
63
64
  * When no expectedProcessingTimeMs is provided, the default value of EXPECTED_CRYPTO_PROCESSING_TIME_MS is used.
64
65
  */
65
66
  async #nextMessage(
@@ -82,6 +83,7 @@ export class SecureChannelMessenger {
82
83
 
83
84
  /**
84
85
  * Waits for the next message and decodes it.
86
+ *
85
87
  * When no expectedProcessingTimeMs is provided, the default value of EXPECTED_CRYPTO_PROCESSING_TIME_MS is used.
86
88
  */
87
89
  async nextMessageDecoded<T>(
@@ -94,6 +96,7 @@ export class SecureChannelMessenger {
94
96
 
95
97
  /**
96
98
  * Waits for the next message and returns it.
99
+ *
97
100
  * When no expectedProcessingTimeMs is provided, the default value of EXPECTED_CRYPTO_PROCESSING_TIME_MS is used.
98
101
  */
99
102
  async waitForSuccess(
@@ -106,6 +109,7 @@ export class SecureChannelMessenger {
106
109
 
107
110
  /**
108
111
  * Sends a message of the given type with the given payload.
112
+ *
109
113
  * If no ExchangeSendOptions are provided, the expectedProcessingTimeMs will be set to
110
114
  * EXPECTED_CRYPTO_PROCESSING_TIME_MS.
111
115
  */