@matter/protocol 0.15.4 → 0.15.5
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/client/ReadScope.d.ts +4 -0
- package/dist/cjs/action/client/ReadScope.d.ts.map +1 -1
- package/dist/cjs/action/client/ReadScope.js +2 -1
- package/dist/cjs/action/client/ReadScope.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts +0 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.js +2 -3
- package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
- package/dist/cjs/fabric/TestFabric.d.ts.map +1 -1
- package/dist/cjs/fabric/TestFabric.js +2 -1
- package/dist/cjs/fabric/TestFabric.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataDecoder.d.ts +9 -7
- package/dist/cjs/interaction/AttributeDataDecoder.d.ts.map +1 -1
- package/dist/cjs/interaction/AttributeDataDecoder.js.map +1 -1
- package/dist/cjs/interaction/DecodedDataReport.d.ts +1 -0
- package/dist/cjs/interaction/DecodedDataReport.d.ts.map +1 -1
- package/dist/cjs/interaction/DecodedDataReport.js.map +1 -1
- package/dist/cjs/interaction/InteractionClient.d.ts +12 -2
- package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +94 -67
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +10 -90
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +98 -22
- package/dist/cjs/interaction/InteractionMessenger.js.map +2 -2
- package/dist/cjs/interaction/SubscriptionClient.d.ts +2 -2
- package/dist/cjs/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/SubscriptionClient.js +1 -1
- package/dist/cjs/interaction/SubscriptionClient.js.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.js +1 -2
- package/dist/cjs/mdns/MdnsScanner.js.map +1 -1
- package/dist/cjs/mdns/MdnsServer.js +1 -1
- package/dist/cjs/mdns/MdnsServer.js.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts +3 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +17 -9
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseServer.js +2 -1
- package/dist/cjs/session/pase/PaseServer.js.map +1 -1
- package/dist/esm/action/client/ReadScope.d.ts +4 -0
- package/dist/esm/action/client/ReadScope.d.ts.map +1 -1
- package/dist/esm/action/client/ReadScope.js +2 -1
- package/dist/esm/action/client/ReadScope.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricAuthority.d.ts +0 -1
- package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/esm/fabric/FabricAuthority.js +2 -3
- package/dist/esm/fabric/FabricAuthority.js.map +1 -1
- package/dist/esm/fabric/TestFabric.d.ts.map +1 -1
- package/dist/esm/fabric/TestFabric.js +3 -2
- package/dist/esm/fabric/TestFabric.js.map +1 -1
- package/dist/esm/interaction/AttributeDataDecoder.d.ts +9 -7
- package/dist/esm/interaction/AttributeDataDecoder.d.ts.map +1 -1
- package/dist/esm/interaction/AttributeDataDecoder.js.map +1 -1
- package/dist/esm/interaction/DecodedDataReport.d.ts +1 -0
- package/dist/esm/interaction/DecodedDataReport.d.ts.map +1 -1
- package/dist/esm/interaction/DecodedDataReport.js.map +1 -1
- package/dist/esm/interaction/InteractionClient.d.ts +12 -2
- package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +96 -68
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +10 -90
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +98 -22
- package/dist/esm/interaction/InteractionMessenger.js.map +2 -2
- package/dist/esm/interaction/SubscriptionClient.d.ts +2 -2
- package/dist/esm/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/esm/interaction/SubscriptionClient.js +1 -1
- package/dist/esm/interaction/SubscriptionClient.js.map +1 -1
- package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsScanner.js +1 -2
- package/dist/esm/mdns/MdnsScanner.js.map +1 -1
- package/dist/esm/mdns/MdnsServer.js +1 -1
- package/dist/esm/mdns/MdnsServer.js.map +1 -1
- package/dist/esm/peer/PeerAddressStore.d.ts +3 -1
- package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/esm/peer/PeerAddressStore.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +19 -10
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseServer.js +2 -1
- package/dist/esm/session/pase/PaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/action/client/ReadScope.ts +7 -0
- package/src/fabric/Fabric.ts +1 -1
- package/src/fabric/FabricAuthority.ts +2 -2
- package/src/fabric/TestFabric.ts +2 -1
- package/src/interaction/AttributeDataDecoder.ts +4 -1
- package/src/interaction/DecodedDataReport.ts +1 -0
- package/src/interaction/InteractionClient.ts +152 -77
- package/src/interaction/InteractionMessenger.ts +126 -22
- package/src/interaction/SubscriptionClient.ts +6 -5
- package/src/mdns/MdnsScanner.ts +1 -2
- package/src/mdns/MdnsServer.ts +2 -2
- package/src/peer/PeerAddressStore.ts +3 -1
- package/src/session/SessionManager.ts +35 -24
- package/src/session/pase/PaseServer.ts +2 -1
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Environment, Environmental, Logger, MaybePromise, Time, Timer } from "#general";
|
|
8
|
+
import { DecodedDataReport } from "#interaction/DecodedDataReport.js";
|
|
8
9
|
import { MessageExchange } from "#protocol/MessageExchange.js";
|
|
9
10
|
import { ProtocolHandler } from "#protocol/ProtocolHandler.js";
|
|
10
11
|
import { INTERACTION_PROTOCOL_ID } from "#types";
|
|
11
|
-
import {
|
|
12
|
+
import { IncomingInteractionClientMessenger } from "./InteractionMessenger.js";
|
|
12
13
|
|
|
13
14
|
const logger = Logger.get("SubscriptionClient");
|
|
14
15
|
|
|
@@ -16,7 +17,7 @@ export interface RegisteredSubscription {
|
|
|
16
17
|
id: number;
|
|
17
18
|
maximumPeerResponseTimeMs: number;
|
|
18
19
|
maxIntervalS: number;
|
|
19
|
-
onData: (dataReport:
|
|
20
|
+
onData: (dataReport: DecodedDataReport) => MaybePromise<void>;
|
|
20
21
|
onTimeout?: () => void;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -28,7 +29,7 @@ export interface RegisteredSubscription {
|
|
|
28
29
|
export class SubscriptionClient implements ProtocolHandler {
|
|
29
30
|
readonly id = INTERACTION_PROTOCOL_ID;
|
|
30
31
|
readonly requiresSecureSession = true;
|
|
31
|
-
readonly #listeners = new Map<number, (dataReport:
|
|
32
|
+
readonly #listeners = new Map<number, (dataReport: DecodedDataReport) => MaybePromise<void>>();
|
|
32
33
|
readonly #timeouts = new Map<number, Timer>();
|
|
33
34
|
|
|
34
35
|
constructor() {}
|
|
@@ -80,10 +81,10 @@ export class SubscriptionClient implements ProtocolHandler {
|
|
|
80
81
|
async onNewExchange(exchange: MessageExchange) {
|
|
81
82
|
const messenger = new IncomingInteractionClientMessenger(exchange);
|
|
82
83
|
|
|
83
|
-
let dataReport:
|
|
84
|
+
let dataReport: DecodedDataReport;
|
|
84
85
|
try {
|
|
85
86
|
// TODO Adjust this to getting packages as callback when received to handle error cases and checks outside
|
|
86
|
-
dataReport = await messenger.readAggregateDataReport([...this.#listeners.keys()]);
|
|
87
|
+
dataReport = await messenger.readAggregateDataReport(undefined, [...this.#listeners.keys()]);
|
|
87
88
|
} finally {
|
|
88
89
|
messenger.close().catch(error => logger.info("Error closing client messenger", error));
|
|
89
90
|
}
|
package/src/mdns/MdnsScanner.ts
CHANGED
|
@@ -1042,8 +1042,7 @@ export class MdnsScanner implements Scanner {
|
|
|
1042
1042
|
if (this.#closing) return;
|
|
1043
1043
|
const message = DnsCodec.decode(messageBytes);
|
|
1044
1044
|
if (message === undefined) return; // The message cannot be parsed
|
|
1045
|
-
if (
|
|
1046
|
-
return;
|
|
1045
|
+
if (!DnsMessageType.isResponse(message.messageType)) return;
|
|
1047
1046
|
|
|
1048
1047
|
const answers = this.#structureAnswers([...message.answers, ...message.additionalRecords]);
|
|
1049
1048
|
|
package/src/mdns/MdnsServer.ts
CHANGED
|
@@ -100,8 +100,8 @@ export class MdnsServer {
|
|
|
100
100
|
const message = DnsCodec.decode(messageBytes);
|
|
101
101
|
if (message === undefined) return; // The message cannot be parsed
|
|
102
102
|
const { transactionId, messageType, queries, answers: knownAnswers } = message;
|
|
103
|
-
if (
|
|
104
|
-
if (queries.length === 0) return; //
|
|
103
|
+
if (!DnsMessageType.isQuery(messageType)) return;
|
|
104
|
+
if (queries.length === 0) return; // TODO correctly handle TruncatedQueries by waiting and combining multiple queries
|
|
105
105
|
for (const portRecords of records.values()) {
|
|
106
106
|
let answers = queries.flatMap(query => this.#queryRecords(query, portRecords));
|
|
107
107
|
if (answers.length === 0) continue;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { ReadScope } from "#action/client/ReadScope.js";
|
|
7
8
|
import { Construction, MaybePromise } from "#general";
|
|
8
9
|
import { DecodedAttributeReportValue } from "#interaction/AttributeDataDecoder.js";
|
|
9
10
|
import { AttributeId, ClusterId, EndpointNumber, EventNumber } from "#types";
|
|
@@ -27,7 +28,7 @@ export abstract class PeerDataStore {
|
|
|
27
28
|
abstract maxEventNumber: EventNumber;
|
|
28
29
|
abstract updateLastEventNumber(eventNumber: EventNumber): MaybePromise<void>;
|
|
29
30
|
|
|
30
|
-
abstract persistAttributes(attributes: DecodedAttributeReportValue<any>[]): MaybePromise<void>;
|
|
31
|
+
abstract persistAttributes(attributes: DecodedAttributeReportValue<any>[], scope: ReadScope): MaybePromise<void>;
|
|
31
32
|
|
|
32
33
|
// TODO: Find a maybe better way to achieve this without functions
|
|
33
34
|
abstract retrieveAttribute(
|
|
@@ -41,4 +42,5 @@ export abstract class PeerDataStore {
|
|
|
41
42
|
filterEndpointId?: EndpointNumber,
|
|
42
43
|
filterClusterId?: ClusterId,
|
|
43
44
|
): { endpointId: EndpointNumber; clusterId: ClusterId; dataVersion: number }[];
|
|
45
|
+
abstract cleanupAttributeData(endpointId: EndpointNumber, clusterIds?: ClusterId[]): MaybePromise<void>;
|
|
44
46
|
}
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
ObserverGroup,
|
|
22
22
|
StorageContext,
|
|
23
23
|
StorageManager,
|
|
24
|
+
toHex,
|
|
24
25
|
} from "#general";
|
|
25
26
|
import { Subscription } from "#interaction/Subscription.js";
|
|
26
27
|
import { Specification } from "#model";
|
|
@@ -76,6 +77,7 @@ type ResumptionStorageRecord = {
|
|
|
76
77
|
sharedSecret: Uint8Array;
|
|
77
78
|
resumptionId: Uint8Array;
|
|
78
79
|
fabricId: FabricId;
|
|
80
|
+
fabricIndex: FabricIndex;
|
|
79
81
|
peerNodeId: NodeId;
|
|
80
82
|
sessionParameters: {
|
|
81
83
|
idleIntervalMs: number;
|
|
@@ -545,21 +547,21 @@ export class SessionManager {
|
|
|
545
547
|
([
|
|
546
548
|
address,
|
|
547
549
|
{ sharedSecret, resumptionId, peerNodeId, fabric, sessionParameters, caseAuthenticatedTags },
|
|
548
|
-
]) =>
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
550
|
+
]): ResumptionStorageRecord => ({
|
|
551
|
+
nodeId: address.nodeId,
|
|
552
|
+
sharedSecret,
|
|
553
|
+
resumptionId,
|
|
554
|
+
fabricId: fabric.fabricId,
|
|
555
|
+
fabricIndex: fabric.fabricIndex,
|
|
556
|
+
peerNodeId: peerNodeId,
|
|
557
|
+
sessionParameters: {
|
|
558
|
+
...sessionParameters,
|
|
559
|
+
supportedTransports: sessionParameters.supportedTransports
|
|
560
|
+
? SupportedTransportsSchema.encode(sessionParameters.supportedTransports)
|
|
561
|
+
: undefined,
|
|
562
|
+
},
|
|
563
|
+
caseAuthenticatedTags,
|
|
564
|
+
}),
|
|
563
565
|
),
|
|
564
566
|
);
|
|
565
567
|
}
|
|
@@ -578,6 +580,7 @@ export class SessionManager {
|
|
|
578
580
|
sharedSecret,
|
|
579
581
|
resumptionId,
|
|
580
582
|
fabricId,
|
|
583
|
+
fabricIndex,
|
|
581
584
|
peerNodeId,
|
|
582
585
|
sessionParameters: {
|
|
583
586
|
idleIntervalMs,
|
|
@@ -592,19 +595,27 @@ export class SessionManager {
|
|
|
592
595
|
} = {},
|
|
593
596
|
caseAuthenticatedTags,
|
|
594
597
|
}) => {
|
|
595
|
-
const fabric = this.#context.fabrics.find(
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
peerNodeId,
|
|
601
|
-
"for fabric index",
|
|
602
|
-
fabric?.fabricIndex,
|
|
598
|
+
const fabric = this.#context.fabrics.find(
|
|
599
|
+
fabric =>
|
|
600
|
+
fabric.fabricId === fabricId &&
|
|
601
|
+
// Backward compatibility logic: fabricIndex was added later (0.15.5), so it might be undefined in older records
|
|
602
|
+
(fabricIndex === undefined || fabric.fabricIndex === fabricIndex),
|
|
603
603
|
);
|
|
604
604
|
if (!fabric) {
|
|
605
|
-
logger.
|
|
605
|
+
logger.warn(
|
|
606
|
+
`Ignoring resumption record for fabric 0x${toHex(fabricId)} and index ${fabricIndex} because we cannot find a matching fabric`,
|
|
607
|
+
);
|
|
606
608
|
return;
|
|
607
609
|
}
|
|
610
|
+
logger.info(
|
|
611
|
+
"restoring resumption record for node",
|
|
612
|
+
fabric.addressOf(nodeId).toString(),
|
|
613
|
+
"and peer node",
|
|
614
|
+
fabric.addressOf(peerNodeId).toString(),
|
|
615
|
+
"for fabric id",
|
|
616
|
+
`0x${toHex(fabric.fabricId)}`,
|
|
617
|
+
`(0x${toHex(fabric.rootVendorId)}, "${fabric?.label}")`,
|
|
618
|
+
);
|
|
608
619
|
this.#resumptionRecords.set(fabric.addressOf(nodeId), {
|
|
609
620
|
sharedSecret,
|
|
610
621
|
resumptionId,
|
|
@@ -68,7 +68,8 @@ export class PaseServer implements ProtocolHandler {
|
|
|
68
68
|
// successfully established a session, the Commissionee SHALL NOT accept any more requests for new PASE
|
|
69
69
|
// sessions until session establishment fails or the successfully established PASE session is terminated on
|
|
70
70
|
// the commissioning channel.
|
|
71
|
-
|
|
71
|
+
const paseSession = this.sessions.getPaseSession();
|
|
72
|
+
if (paseSession !== undefined && !paseSession.isClosing) {
|
|
72
73
|
logger.info("Pase server: Pairing already in progress (PASE session exists), ignoring new exchange.");
|
|
73
74
|
} else if (this.#pairingTimer?.isRunning) {
|
|
74
75
|
logger.info(
|