@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.
- package/dist/cjs/action/Val.d.ts +4 -0
- package/dist/cjs/action/Val.d.ts.map +1 -1
- package/dist/cjs/action/Val.js.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts +10 -8
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +152 -80
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/client/ClientSubscription.d.ts +17 -0
- package/dist/cjs/action/client/ClientSubscription.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientSubscription.js +22 -0
- package/dist/cjs/action/client/ClientSubscription.js.map +6 -0
- package/dist/cjs/action/client/ClientSubscriptionHandler.d.ts +20 -0
- package/dist/cjs/action/client/ClientSubscriptionHandler.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientSubscriptionHandler.js +117 -0
- package/dist/cjs/action/client/ClientSubscriptionHandler.js.map +6 -0
- package/dist/cjs/action/client/ClientSubscriptions.d.ts +45 -0
- package/dist/cjs/action/client/ClientSubscriptions.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientSubscriptions.js +141 -0
- package/dist/cjs/action/client/ClientSubscriptions.js.map +6 -0
- package/dist/cjs/action/client/InputChunk.d.ts +12 -0
- package/dist/cjs/action/client/InputChunk.d.ts.map +1 -0
- package/dist/cjs/action/client/InputChunk.js +89 -0
- package/dist/cjs/action/client/InputChunk.js.map +6 -0
- package/dist/cjs/action/client/ReadScope.d.ts +26 -0
- package/dist/cjs/action/client/ReadScope.d.ts.map +1 -0
- package/dist/cjs/action/client/ReadScope.js +87 -0
- package/dist/cjs/action/client/ReadScope.js.map +6 -0
- package/dist/cjs/action/client/index.d.ts +5 -0
- package/dist/cjs/action/client/index.d.ts.map +1 -1
- package/dist/cjs/action/client/index.js +5 -0
- package/dist/cjs/action/client/index.js.map +1 -1
- package/dist/cjs/action/request/Read.d.ts +0 -4
- package/dist/cjs/action/request/Read.d.ts.map +1 -1
- package/dist/cjs/action/request/Read.js.map +1 -1
- package/dist/cjs/action/request/Subscribe.d.ts +14 -1
- package/dist/cjs/action/request/Subscribe.d.ts.map +1 -1
- package/dist/cjs/action/request/Subscribe.js +2 -2
- package/dist/cjs/action/request/Subscribe.js.map +1 -1
- package/dist/cjs/action/response/SubscribeResult.d.ts +3 -5
- package/dist/cjs/action/response/SubscribeResult.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeContext.js +0 -1
- package/dist/cjs/common/FailsafeContext.js.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts +6 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.js +16 -0
- package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
- package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +8 -4
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +20 -16
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +18 -10
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts +5 -6
- package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.js.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.d.ts +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.js +2 -5
- package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +3 -0
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.js +4 -0
- package/dist/cjs/securechannel/SecureChannelMessenger.js.map +1 -1
- package/dist/esm/action/Val.d.ts +4 -0
- package/dist/esm/action/Val.d.ts.map +1 -1
- package/dist/esm/action/Val.js.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts +10 -8
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +154 -82
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/client/ClientSubscription.d.ts +17 -0
- package/dist/esm/action/client/ClientSubscription.d.ts.map +1 -0
- package/dist/esm/action/client/ClientSubscription.js +6 -0
- package/dist/esm/action/client/ClientSubscription.js.map +6 -0
- package/dist/esm/action/client/ClientSubscriptionHandler.d.ts +20 -0
- package/dist/esm/action/client/ClientSubscriptionHandler.d.ts.map +1 -0
- package/dist/esm/action/client/ClientSubscriptionHandler.js +97 -0
- package/dist/esm/action/client/ClientSubscriptionHandler.js.map +6 -0
- package/dist/esm/action/client/ClientSubscriptions.d.ts +45 -0
- package/dist/esm/action/client/ClientSubscriptions.d.ts.map +1 -0
- package/dist/esm/action/client/ClientSubscriptions.js +129 -0
- package/dist/esm/action/client/ClientSubscriptions.js.map +6 -0
- package/dist/esm/action/client/InputChunk.d.ts +12 -0
- package/dist/esm/action/client/InputChunk.d.ts.map +1 -0
- package/dist/esm/action/client/InputChunk.js +69 -0
- package/dist/esm/action/client/InputChunk.js.map +6 -0
- package/dist/esm/action/client/ReadScope.d.ts +26 -0
- package/dist/esm/action/client/ReadScope.d.ts.map +1 -0
- package/dist/esm/action/client/ReadScope.js +67 -0
- package/dist/esm/action/client/ReadScope.js.map +6 -0
- package/dist/esm/action/client/index.d.ts +5 -0
- package/dist/esm/action/client/index.d.ts.map +1 -1
- package/dist/esm/action/client/index.js +5 -0
- package/dist/esm/action/client/index.js.map +1 -1
- package/dist/esm/action/request/Read.d.ts +0 -4
- package/dist/esm/action/request/Read.d.ts.map +1 -1
- package/dist/esm/action/request/Read.js.map +1 -1
- package/dist/esm/action/request/Subscribe.d.ts +14 -1
- package/dist/esm/action/request/Subscribe.d.ts.map +1 -1
- package/dist/esm/action/request/Subscribe.js +2 -2
- package/dist/esm/action/request/Subscribe.js.map +1 -1
- package/dist/esm/action/response/SubscribeResult.d.ts +3 -5
- package/dist/esm/action/response/SubscribeResult.d.ts.map +1 -1
- package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
- package/dist/esm/common/FailsafeContext.js +0 -1
- package/dist/esm/common/FailsafeContext.js.map +1 -1
- package/dist/esm/fabric/FabricAuthority.d.ts +6 -1
- package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/esm/fabric/FabricAuthority.js +25 -1
- package/dist/esm/fabric/FabricAuthority.js.map +1 -1
- package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +8 -4
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +20 -16
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +18 -10
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/mdns/MdnsScanner.d.ts +5 -6
- package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsScanner.js.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.d.ts +1 -1
- package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.js +2 -5
- package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts +3 -0
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.js +4 -0
- package/dist/esm/securechannel/SecureChannelMessenger.js.map +1 -1
- package/package.json +6 -6
- package/src/action/Val.ts +5 -0
- package/src/action/client/ClientInteraction.ts +178 -90
- package/src/action/client/ClientSubscription.ts +18 -0
- package/src/action/client/ClientSubscriptionHandler.ts +137 -0
- package/src/action/client/ClientSubscriptions.ts +172 -0
- package/src/action/client/InputChunk.ts +79 -0
- package/src/action/client/ReadScope.ts +107 -0
- package/src/action/client/index.ts +5 -0
- package/src/action/request/Read.ts +0 -5
- package/src/action/request/Subscribe.ts +17 -3
- package/src/action/response/SubscribeResult.ts +3 -4
- package/src/common/FailsafeContext.ts +0 -1
- package/src/fabric/FabricAuthority.ts +29 -1
- package/src/interaction/InteractionClient.ts +8 -4
- package/src/interaction/InteractionMessenger.ts +18 -11
- package/src/mdns/MdnsScanner.ts +5 -6
- package/src/protocol/DeviceCommissioner.ts +2 -7
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
931
|
-
this.exchange = await this
|
|
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
|
|
package/src/mdns/MdnsScanner.ts
CHANGED
|
@@ -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
|
-
*
|
|
101
|
-
* and
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
*/
|