@project-chip/matter.js 0.9.3 → 0.9.4
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/CommissioningServer.d.ts.map +1 -1
- package/dist/cjs/CommissioningServer.js +0 -1
- package/dist/cjs/CommissioningServer.js.map +2 -2
- package/dist/cjs/MatterDevice.d.ts +3 -1
- package/dist/cjs/MatterDevice.d.ts.map +1 -1
- package/dist/cjs/MatterDevice.js +20 -9
- package/dist/cjs/MatterDevice.js.map +2 -2
- package/dist/cjs/behavior/AccessControl.js +2 -2
- package/dist/cjs/behavior/AccessControl.js.map +2 -2
- package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts +1 -0
- package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts.map +1 -1
- package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js +14 -0
- package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js.map +2 -2
- package/dist/cjs/behavior/definitions/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
- package/dist/cjs/behavior/definitions/operational-credentials/OperationalCredentialsServer.js +11 -2
- package/dist/cjs/behavior/definitions/operational-credentials/OperationalCredentialsServer.js.map +2 -2
- package/dist/cjs/behavior/state/transaction/Transaction.d.ts +18 -18
- package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateManager.js +1 -0
- package/dist/cjs/certificate/CertificateManager.js.map +2 -2
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +1 -1
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificationDeclarationManager.js +3 -2
- package/dist/cjs/certificate/CertificationDeclarationManager.js.map +2 -2
- package/dist/cjs/cluster/server/AccessControlServer.js.map +1 -1
- package/dist/cjs/cluster/server/AttributeServer.d.ts +9 -0
- package/dist/cjs/cluster/server/AttributeServer.d.ts.map +1 -1
- package/dist/cjs/cluster/server/AttributeServer.js +62 -0
- package/dist/cjs/cluster/server/AttributeServer.js.map +3 -3
- package/dist/cjs/cluster/server/ClusterServer.d.ts.map +1 -1
- package/dist/cjs/cluster/server/ClusterServer.js +8 -1
- package/dist/cjs/cluster/server/ClusterServer.js.map +2 -2
- package/dist/cjs/cluster/server/ClusterServerTypes.d.ts +3 -3
- package/dist/cjs/cluster/server/ClusterServerTypes.d.ts.map +1 -1
- package/dist/cjs/cluster/server/ClusterServerTypes.js.map +1 -1
- package/dist/cjs/cluster/server/EventServer.d.ts +8 -2
- package/dist/cjs/cluster/server/EventServer.d.ts.map +1 -1
- package/dist/cjs/cluster/server/EventServer.js +33 -7
- package/dist/cjs/cluster/server/EventServer.js.map +2 -2
- package/dist/cjs/cluster/server/OperationalCredentialsServer.d.ts.map +1 -1
- package/dist/cjs/cluster/server/OperationalCredentialsServer.js +31 -8
- package/dist/cjs/cluster/server/OperationalCredentialsServer.js.map +2 -2
- package/dist/cjs/common/FailsafeContext.d.ts +1 -0
- package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeContext.js +16 -2
- package/dist/cjs/common/FailsafeContext.js.map +2 -2
- package/dist/cjs/crypto/Crypto.d.ts +1 -1
- package/dist/cjs/crypto/Crypto.d.ts.map +1 -1
- package/dist/cjs/crypto/Crypto.js +2 -2
- package/dist/cjs/crypto/Crypto.js.map +2 -2
- package/dist/cjs/device/LegacyInteractionServer.d.ts +2 -2
- package/dist/cjs/device/LegacyInteractionServer.d.ts.map +1 -1
- package/dist/cjs/device/LegacyInteractionServer.js +13 -1
- package/dist/cjs/device/LegacyInteractionServer.js.map +2 -2
- package/dist/cjs/fabric/Fabric.d.ts +1 -0
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +5 -0
- package/dist/cjs/fabric/Fabric.js.map +2 -2
- package/dist/cjs/fabric/FabricManager.d.ts +1 -0
- package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricManager.js +2 -1
- package/dist/cjs/fabric/FabricManager.js.map +2 -2
- package/dist/cjs/model/models/EventModel.d.ts +1 -0
- package/dist/cjs/model/models/EventModel.d.ts.map +1 -1
- package/dist/cjs/model/models/EventModel.js +3 -0
- package/dist/cjs/model/models/EventModel.js.map +2 -2
- package/dist/cjs/model/models/FieldModel.d.ts +1 -0
- package/dist/cjs/model/models/FieldModel.d.ts.map +1 -1
- package/dist/cjs/model/models/FieldModel.js +3 -0
- package/dist/cjs/model/models/FieldModel.js.map +2 -2
- package/dist/cjs/node/server/TransactionalInteractionServer.d.ts +2 -2
- package/dist/cjs/node/server/TransactionalInteractionServer.d.ts.map +1 -1
- package/dist/cjs/node/server/TransactionalInteractionServer.js +0 -2
- package/dist/cjs/node/server/TransactionalInteractionServer.js.map +2 -2
- package/dist/cjs/protocol/interaction/AttributeDataEncoder.d.ts +6 -3
- package/dist/cjs/protocol/interaction/AttributeDataEncoder.d.ts.map +1 -1
- package/dist/cjs/protocol/interaction/AttributeDataEncoder.js +14 -8
- package/dist/cjs/protocol/interaction/AttributeDataEncoder.js.map +2 -2
- package/dist/cjs/protocol/interaction/EventHandler.d.ts.map +1 -1
- package/dist/cjs/protocol/interaction/EventHandler.js +1 -3
- package/dist/cjs/protocol/interaction/EventHandler.js.map +2 -2
- package/dist/cjs/protocol/interaction/InteractionClient.js +1 -1
- package/dist/cjs/protocol/interaction/InteractionClient.js.map +2 -2
- package/dist/cjs/protocol/interaction/InteractionEndpointStructure.d.ts +3 -3
- package/dist/cjs/protocol/interaction/InteractionEndpointStructure.d.ts.map +1 -1
- package/dist/cjs/protocol/interaction/InteractionEndpointStructure.js +1 -0
- package/dist/cjs/protocol/interaction/InteractionEndpointStructure.js.map +2 -2
- package/dist/cjs/protocol/interaction/InteractionMessenger.d.ts +1 -1
- package/dist/cjs/protocol/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/protocol/interaction/InteractionMessenger.js +11 -4
- package/dist/cjs/protocol/interaction/InteractionMessenger.js.map +2 -2
- package/dist/cjs/protocol/interaction/InteractionServer.d.ts +5 -6
- package/dist/cjs/protocol/interaction/InteractionServer.d.ts.map +1 -1
- package/dist/cjs/protocol/interaction/InteractionServer.js +41 -36
- package/dist/cjs/protocol/interaction/InteractionServer.js.map +2 -2
- package/dist/cjs/protocol/interaction/SubscriptionHandler.d.ts +31 -12
- package/dist/cjs/protocol/interaction/SubscriptionHandler.d.ts.map +1 -1
- package/dist/cjs/protocol/interaction/SubscriptionHandler.js +161 -69
- package/dist/cjs/protocol/interaction/SubscriptionHandler.js.map +3 -3
- package/dist/cjs/session/SessionManager.d.ts +2 -1
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +2 -2
- package/dist/cjs/session/SessionManager.js.map +2 -2
- package/dist/cjs/tlv/TlvArray.d.ts +2 -2
- package/dist/cjs/tlv/TlvArray.d.ts.map +1 -1
- package/dist/cjs/tlv/TlvArray.js +2 -2
- package/dist/cjs/tlv/TlvArray.js.map +2 -2
- package/dist/cjs/tlv/TlvNullable.d.ts +2 -2
- package/dist/cjs/tlv/TlvNullable.d.ts.map +1 -1
- package/dist/cjs/tlv/TlvNullable.js +2 -2
- package/dist/cjs/tlv/TlvNullable.js.map +2 -2
- package/dist/cjs/tlv/TlvObject.d.ts +2 -2
- package/dist/cjs/tlv/TlvObject.d.ts.map +1 -1
- package/dist/cjs/tlv/TlvObject.js +18 -12
- package/dist/cjs/tlv/TlvObject.js.map +2 -2
- package/dist/cjs/tlv/TlvSchema.d.ts +14 -2
- package/dist/cjs/tlv/TlvSchema.d.ts.map +1 -1
- package/dist/cjs/tlv/TlvSchema.js +2 -2
- package/dist/cjs/tlv/TlvSchema.js.map +2 -2
- package/dist/cjs/tlv/TlvWrapper.d.ts +2 -2
- package/dist/cjs/tlv/TlvWrapper.d.ts.map +1 -1
- package/dist/cjs/tlv/TlvWrapper.js +2 -2
- package/dist/cjs/tlv/TlvWrapper.js.map +2 -2
- package/dist/esm/CommissioningServer.d.ts.map +1 -1
- package/dist/esm/CommissioningServer.js +0 -1
- package/dist/esm/CommissioningServer.js.map +2 -2
- package/dist/esm/MatterDevice.d.ts +3 -1
- package/dist/esm/MatterDevice.d.ts.map +1 -1
- package/dist/esm/MatterDevice.js +20 -9
- package/dist/esm/MatterDevice.js.map +2 -2
- package/dist/esm/behavior/AccessControl.js +2 -2
- package/dist/esm/behavior/AccessControl.js.map +2 -2
- package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts +1 -0
- package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts.map +1 -1
- package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js +15 -1
- package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js.map +2 -2
- package/dist/esm/behavior/definitions/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
- package/dist/esm/behavior/definitions/operational-credentials/OperationalCredentialsServer.js +11 -2
- package/dist/esm/behavior/definitions/operational-credentials/OperationalCredentialsServer.js.map +2 -2
- package/dist/esm/behavior/state/transaction/Transaction.d.ts +18 -18
- package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateManager.js +1 -0
- package/dist/esm/certificate/CertificateManager.js.map +2 -2
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts +1 -1
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +1 -1
- package/dist/esm/certificate/CertificationDeclarationManager.js +3 -2
- package/dist/esm/certificate/CertificationDeclarationManager.js.map +2 -2
- package/dist/esm/cluster/server/AccessControlServer.js.map +1 -1
- package/dist/esm/cluster/server/AttributeServer.d.ts +9 -0
- package/dist/esm/cluster/server/AttributeServer.d.ts.map +1 -1
- package/dist/esm/cluster/server/AttributeServer.js +69 -1
- package/dist/esm/cluster/server/AttributeServer.js.map +2 -2
- package/dist/esm/cluster/server/ClusterServer.d.ts.map +1 -1
- package/dist/esm/cluster/server/ClusterServer.js +9 -2
- package/dist/esm/cluster/server/ClusterServer.js.map +2 -2
- package/dist/esm/cluster/server/ClusterServerTypes.d.ts +3 -3
- package/dist/esm/cluster/server/ClusterServerTypes.d.ts.map +1 -1
- package/dist/esm/cluster/server/ClusterServerTypes.js.map +1 -1
- package/dist/esm/cluster/server/EventServer.d.ts +8 -2
- package/dist/esm/cluster/server/EventServer.d.ts.map +1 -1
- package/dist/esm/cluster/server/EventServer.js +33 -7
- package/dist/esm/cluster/server/EventServer.js.map +2 -2
- package/dist/esm/cluster/server/OperationalCredentialsServer.d.ts.map +1 -1
- package/dist/esm/cluster/server/OperationalCredentialsServer.js +31 -8
- package/dist/esm/cluster/server/OperationalCredentialsServer.js.map +2 -2
- package/dist/esm/common/FailsafeContext.d.ts +1 -0
- package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
- package/dist/esm/common/FailsafeContext.js +17 -3
- package/dist/esm/common/FailsafeContext.js.map +2 -2
- package/dist/esm/crypto/Crypto.d.ts +1 -1
- package/dist/esm/crypto/Crypto.d.ts.map +1 -1
- package/dist/esm/crypto/Crypto.js +2 -2
- package/dist/esm/crypto/Crypto.js.map +2 -2
- package/dist/esm/device/LegacyInteractionServer.d.ts +2 -2
- package/dist/esm/device/LegacyInteractionServer.d.ts.map +1 -1
- package/dist/esm/device/LegacyInteractionServer.js +13 -1
- package/dist/esm/device/LegacyInteractionServer.js.map +2 -2
- package/dist/esm/fabric/Fabric.d.ts +1 -0
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +5 -0
- package/dist/esm/fabric/Fabric.js.map +2 -2
- package/dist/esm/fabric/FabricManager.d.ts +1 -0
- package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
- package/dist/esm/fabric/FabricManager.js +2 -1
- package/dist/esm/fabric/FabricManager.js.map +2 -2
- package/dist/esm/model/models/EventModel.d.ts +1 -0
- package/dist/esm/model/models/EventModel.d.ts.map +1 -1
- package/dist/esm/model/models/EventModel.js +3 -0
- package/dist/esm/model/models/EventModel.js.map +2 -2
- package/dist/esm/model/models/FieldModel.d.ts +1 -0
- package/dist/esm/model/models/FieldModel.d.ts.map +1 -1
- package/dist/esm/model/models/FieldModel.js +3 -0
- package/dist/esm/model/models/FieldModel.js.map +2 -2
- package/dist/esm/node/server/TransactionalInteractionServer.d.ts +2 -2
- package/dist/esm/node/server/TransactionalInteractionServer.d.ts.map +1 -1
- package/dist/esm/node/server/TransactionalInteractionServer.js +0 -2
- package/dist/esm/node/server/TransactionalInteractionServer.js.map +2 -2
- package/dist/esm/protocol/interaction/AttributeDataEncoder.d.ts +6 -3
- package/dist/esm/protocol/interaction/AttributeDataEncoder.d.ts.map +1 -1
- package/dist/esm/protocol/interaction/AttributeDataEncoder.js +14 -8
- package/dist/esm/protocol/interaction/AttributeDataEncoder.js.map +2 -2
- package/dist/esm/protocol/interaction/EventHandler.d.ts.map +1 -1
- package/dist/esm/protocol/interaction/EventHandler.js +1 -3
- package/dist/esm/protocol/interaction/EventHandler.js.map +2 -2
- package/dist/esm/protocol/interaction/InteractionClient.js +1 -1
- package/dist/esm/protocol/interaction/InteractionClient.js.map +2 -2
- package/dist/esm/protocol/interaction/InteractionEndpointStructure.d.ts +3 -3
- package/dist/esm/protocol/interaction/InteractionEndpointStructure.d.ts.map +1 -1
- package/dist/esm/protocol/interaction/InteractionEndpointStructure.js +1 -0
- package/dist/esm/protocol/interaction/InteractionEndpointStructure.js.map +2 -2
- package/dist/esm/protocol/interaction/InteractionMessenger.d.ts +1 -1
- package/dist/esm/protocol/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/protocol/interaction/InteractionMessenger.js +11 -4
- package/dist/esm/protocol/interaction/InteractionMessenger.js.map +2 -2
- package/dist/esm/protocol/interaction/InteractionServer.d.ts +5 -6
- package/dist/esm/protocol/interaction/InteractionServer.d.ts.map +1 -1
- package/dist/esm/protocol/interaction/InteractionServer.js +41 -36
- package/dist/esm/protocol/interaction/InteractionServer.js.map +2 -2
- package/dist/esm/protocol/interaction/SubscriptionHandler.d.ts +31 -12
- package/dist/esm/protocol/interaction/SubscriptionHandler.d.ts.map +1 -1
- package/dist/esm/protocol/interaction/SubscriptionHandler.js +161 -69
- package/dist/esm/protocol/interaction/SubscriptionHandler.js.map +3 -3
- package/dist/esm/session/SessionManager.d.ts +2 -1
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +2 -2
- package/dist/esm/session/SessionManager.js.map +2 -2
- package/dist/esm/tlv/TlvArray.d.ts +2 -2
- package/dist/esm/tlv/TlvArray.d.ts.map +1 -1
- package/dist/esm/tlv/TlvArray.js +2 -2
- package/dist/esm/tlv/TlvArray.js.map +2 -2
- package/dist/esm/tlv/TlvNullable.d.ts +2 -2
- package/dist/esm/tlv/TlvNullable.d.ts.map +1 -1
- package/dist/esm/tlv/TlvNullable.js +2 -2
- package/dist/esm/tlv/TlvNullable.js.map +2 -2
- package/dist/esm/tlv/TlvObject.d.ts +2 -2
- package/dist/esm/tlv/TlvObject.d.ts.map +1 -1
- package/dist/esm/tlv/TlvObject.js +19 -13
- package/dist/esm/tlv/TlvObject.js.map +2 -2
- package/dist/esm/tlv/TlvSchema.d.ts +14 -2
- package/dist/esm/tlv/TlvSchema.d.ts.map +1 -1
- package/dist/esm/tlv/TlvSchema.js +2 -2
- package/dist/esm/tlv/TlvSchema.js.map +2 -2
- package/dist/esm/tlv/TlvWrapper.d.ts +2 -2
- package/dist/esm/tlv/TlvWrapper.d.ts.map +1 -1
- package/dist/esm/tlv/TlvWrapper.js +2 -2
- package/dist/esm/tlv/TlvWrapper.js.map +2 -2
- package/package.json +3 -3
- package/src/CommissioningServer.ts +0 -1
- package/src/MatterDevice.ts +32 -9
- package/src/behavior/AccessControl.ts +2 -2
- package/src/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.ts +21 -1
- package/src/behavior/definitions/operational-credentials/OperationalCredentialsServer.ts +13 -0
- package/src/certificate/CertificateManager.ts +1 -2
- package/src/certificate/CertificationDeclarationManager.ts +2 -2
- package/src/cluster/server/AccessControlServer.ts +3 -3
- package/src/cluster/server/AttributeServer.ts +79 -1
- package/src/cluster/server/ClusterServer.ts +9 -2
- package/src/cluster/server/ClusterServerTypes.ts +3 -3
- package/src/cluster/server/EventServer.ts +57 -10
- package/src/cluster/server/OperationalCredentialsServer.ts +35 -5
- package/src/common/FailsafeContext.ts +19 -7
- package/src/crypto/Crypto.ts +1 -1
- package/src/device/LegacyInteractionServer.ts +15 -4
- package/src/fabric/Fabric.ts +6 -0
- package/src/fabric/FabricManager.ts +1 -0
- package/src/model/models/EventModel.ts +4 -0
- package/src/model/models/FieldModel.ts +4 -0
- package/src/node/server/TransactionalInteractionServer.ts +2 -4
- package/src/protocol/interaction/AttributeDataEncoder.ts +20 -9
- package/src/protocol/interaction/EventHandler.ts +1 -3
- package/src/protocol/interaction/InteractionClient.ts +1 -1
- package/src/protocol/interaction/InteractionEndpointStructure.ts +4 -4
- package/src/protocol/interaction/InteractionMessenger.ts +12 -3
- package/src/protocol/interaction/InteractionServer.ts +50 -51
- package/src/protocol/interaction/SubscriptionHandler.ts +215 -92
- package/src/session/SessionManager.ts +3 -2
- package/src/tlv/TlvArray.ts +3 -3
- package/src/tlv/TlvNullable.ts +3 -3
- package/src/tlv/TlvObject.ts +20 -14
- package/src/tlv/TlvSchema.ts +17 -3
- package/src/tlv/TlvWrapper.ts +3 -3
|
@@ -9,16 +9,52 @@ import { Message } from "../../codec/MessageCodec.js";
|
|
|
9
9
|
import { ImplementationError, InternalError } from "../../common/MatterError.js";
|
|
10
10
|
import { ClusterId } from "../../datatype/ClusterId.js";
|
|
11
11
|
import { EventId } from "../../datatype/EventId.js";
|
|
12
|
+
import { FabricIndex } from "../../datatype/FabricIndex.js";
|
|
12
13
|
import { Endpoint } from "../../device/Endpoint.js";
|
|
14
|
+
import { ClusterModel, EventModel, MatterModel } from "../../model/index.js";
|
|
13
15
|
import { EventData, EventHandler, EventStorageData } from "../../protocol/interaction/EventHandler.js";
|
|
14
16
|
import { TlvEventFilter } from "../../protocol/interaction/InteractionProtocol.js";
|
|
17
|
+
import { BitSchema, TypeFromPartialBitSchema } from "../../schema/BitmapSchema.js";
|
|
15
18
|
import { SecureSession } from "../../session/SecureSession.js";
|
|
16
19
|
import { Session } from "../../session/Session.js";
|
|
17
20
|
import { Storage, StorageOperationResult } from "../../storage/Storage.js";
|
|
18
21
|
import { Time } from "../../time/Time.js";
|
|
19
22
|
import { TlvSchema, TypeFromSchema } from "../../tlv/TlvSchema.js";
|
|
20
23
|
import { MaybePromise } from "../../util/Promises.js";
|
|
21
|
-
import {
|
|
24
|
+
import { isObject } from "../../util/Type.js";
|
|
25
|
+
import { AccessLevel, Attributes, Cluster, Commands, Event, EventPriority, Events } from "../Cluster.js";
|
|
26
|
+
|
|
27
|
+
export type AnyEventServer<T, S extends Storage> = EventServer<T, S> | FabricSensitiveEventServer<T, S>;
|
|
28
|
+
|
|
29
|
+
export function createEventServer<
|
|
30
|
+
T,
|
|
31
|
+
F extends BitSchema,
|
|
32
|
+
SF extends TypeFromPartialBitSchema<F>,
|
|
33
|
+
A extends Attributes,
|
|
34
|
+
C extends Commands,
|
|
35
|
+
E extends Events,
|
|
36
|
+
S extends Storage,
|
|
37
|
+
>(
|
|
38
|
+
clusterDef: Cluster<F, SF, A, C, E>,
|
|
39
|
+
eventDef: Event<T, F>,
|
|
40
|
+
eventName: string,
|
|
41
|
+
schema: TlvSchema<T>,
|
|
42
|
+
priority: EventPriority,
|
|
43
|
+
readAcl: AccessLevel | undefined,
|
|
44
|
+
): EventServer<T, S> {
|
|
45
|
+
let fabricSensitive = false;
|
|
46
|
+
const clusterFromModel = new MatterModel().get(ClusterModel, clusterDef.id);
|
|
47
|
+
if (clusterFromModel !== undefined) {
|
|
48
|
+
const eventModel = clusterFromModel.get(EventModel, eventDef.id);
|
|
49
|
+
if (eventModel !== undefined) {
|
|
50
|
+
fabricSensitive = eventModel.fabricSensitive;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (fabricSensitive) {
|
|
54
|
+
return new FabricSensitiveEventServer(eventDef.id, clusterDef.id, eventName, schema, priority, readAcl);
|
|
55
|
+
}
|
|
56
|
+
return new EventServer(eventDef.id, clusterDef.id, eventName, schema, priority, readAcl);
|
|
57
|
+
}
|
|
22
58
|
|
|
23
59
|
export class EventServer<T, S extends Storage> {
|
|
24
60
|
private eventList = new Array<EventData<T>>();
|
|
@@ -26,6 +62,7 @@ export class EventServer<T, S extends Storage> {
|
|
|
26
62
|
protected endpoint?: Endpoint;
|
|
27
63
|
protected eventHandler?: EventHandler;
|
|
28
64
|
#readAcl: AccessLevel | undefined;
|
|
65
|
+
hasFabricSensitiveData = false;
|
|
29
66
|
|
|
30
67
|
constructor(
|
|
31
68
|
readonly id: EventId,
|
|
@@ -114,25 +151,35 @@ export class EventServer<T, S extends Storage> {
|
|
|
114
151
|
if (this.endpoint === undefined) {
|
|
115
152
|
throw new InternalError("EventServer not bound to Endpoint");
|
|
116
153
|
}
|
|
154
|
+
|
|
117
155
|
return this.eventHandler.getEvents(
|
|
118
156
|
{ endpointId: this.endpoint.number, clusterId: this.clusterId, eventId: this.id },
|
|
119
157
|
filters,
|
|
120
|
-
//
|
|
121
|
-
isFabricFiltered
|
|
122
|
-
? session.associatedFabric.fabricIndex
|
|
123
|
-
: undefined,
|
|
158
|
+
// When request is fabric filtered or the event is Fabric sensitive then filter the events for the fabrics
|
|
159
|
+
isFabricFiltered ? (session as SecureSession<any>).fabric?.fabricIndex ?? FabricIndex.NO_FABRIC : undefined,
|
|
124
160
|
);
|
|
125
161
|
}
|
|
126
162
|
}
|
|
127
163
|
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
export class FabricSensitiveEventServer<T, S extends Storage> extends EventServer<T, S> {
|
|
165
|
+
override hasFabricSensitiveData = true;
|
|
166
|
+
|
|
167
|
+
override get(
|
|
168
|
+
session: Session<MatterDevice>,
|
|
169
|
+
_isFabricFiltered: boolean,
|
|
170
|
+
message?: Message,
|
|
171
|
+
filters?: TypeFromSchema<typeof TlvEventFilter>[],
|
|
172
|
+
) {
|
|
173
|
+
// because the event is fabric sensitive it is always filtered out when another fabric tries to access it
|
|
174
|
+
return super.get(session, true, message, filters);
|
|
175
|
+
}
|
|
176
|
+
|
|
130
177
|
override triggerEvent(data: T) {
|
|
131
|
-
if (
|
|
132
|
-
throw new ImplementationError("
|
|
178
|
+
if (!isObject(data) || data === null) {
|
|
179
|
+
throw new ImplementationError("FabricSensitive events need to have an object as data.");
|
|
133
180
|
}
|
|
134
181
|
if (!("fabricIndex" in data)) {
|
|
135
|
-
throw new InternalError("
|
|
182
|
+
throw new InternalError("FabricSensitive events requires fabricIndex in data.");
|
|
136
183
|
}
|
|
137
184
|
return super.triggerEvent(data);
|
|
138
185
|
}
|
|
@@ -18,6 +18,7 @@ import { MatterFabricConflictError } from "../../common/FailsafeTimer.js";
|
|
|
18
18
|
import { MatterFlowError, UnexpectedDataError } from "../../common/MatterError.js";
|
|
19
19
|
import { tryCatch } from "../../common/TryCatchHandler.js";
|
|
20
20
|
import { ValidationError } from "../../common/ValidationError.js";
|
|
21
|
+
import { CryptoVerifyError } from "../../crypto/Crypto.js";
|
|
21
22
|
import { FabricIndex } from "../../datatype/FabricIndex.js";
|
|
22
23
|
import { PublicKeyError } from "../../fabric/Fabric.js";
|
|
23
24
|
import { FabricTableFullError } from "../../fabric/FabricManager.js";
|
|
@@ -209,6 +210,7 @@ export const OperationalCredentialsClusterHandler: (
|
|
|
209
210
|
debugText: error.message,
|
|
210
211
|
};
|
|
211
212
|
} else if (
|
|
213
|
+
error instanceof CryptoVerifyError ||
|
|
212
214
|
error instanceof CertificateError ||
|
|
213
215
|
error instanceof ValidationError ||
|
|
214
216
|
error instanceof UnexpectedDataError
|
|
@@ -317,10 +319,28 @@ export const OperationalCredentialsClusterHandler: (
|
|
|
317
319
|
return session.context.getFabrics().length;
|
|
318
320
|
},
|
|
319
321
|
|
|
320
|
-
trustedRootCertificatesAttributeGetter: ({ session
|
|
321
|
-
if (session === undefined || !session.isSecure)
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
trustedRootCertificatesAttributeGetter: ({ session }) => {
|
|
323
|
+
if (session === undefined || !session.isSecure) {
|
|
324
|
+
logger.debug(`trustedRootCertificatesAttributeGetter: session not set or not secure ${!!session}`);
|
|
325
|
+
return [];
|
|
326
|
+
} // ???
|
|
327
|
+
if (!session.isSecure)
|
|
328
|
+
throw new MatterFlowError("addOperationalCert should be called on a secure session.");
|
|
329
|
+
|
|
330
|
+
const rootCerts = session.context.getFabrics().map(fabric => fabric.rootCert);
|
|
331
|
+
|
|
332
|
+
const device = session.context;
|
|
333
|
+
if (device.isFailsafeArmed()) {
|
|
334
|
+
const failsafeContext = device.failsafeContext;
|
|
335
|
+
const temporaryRootCert = failsafeContext.rootCert;
|
|
336
|
+
if (temporaryRootCert !== undefined) {
|
|
337
|
+
logger.debug(`Add temporary trusted root certificate to the list.`);
|
|
338
|
+
rootCerts.push(temporaryRootCert);
|
|
339
|
+
} else {
|
|
340
|
+
logger.debug(`No temporary trusted root certificate to be added.`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return rootCerts;
|
|
324
344
|
},
|
|
325
345
|
|
|
326
346
|
currentFabricIndexAttributeGetter: ({ session }) => {
|
|
@@ -394,6 +414,7 @@ export const OperationalCredentialsClusterHandler: (
|
|
|
394
414
|
} catch (error) {
|
|
395
415
|
logger.info("building fabric for update failed", error);
|
|
396
416
|
if (
|
|
417
|
+
error instanceof CryptoVerifyError ||
|
|
397
418
|
error instanceof CertificateError ||
|
|
398
419
|
error instanceof ValidationError ||
|
|
399
420
|
error instanceof UnexpectedDataError
|
|
@@ -476,7 +497,13 @@ export const OperationalCredentialsClusterHandler: (
|
|
|
476
497
|
};
|
|
477
498
|
},
|
|
478
499
|
|
|
479
|
-
addTrustedRootCertificate: async ({
|
|
500
|
+
addTrustedRootCertificate: async ({
|
|
501
|
+
request: { rootCaCertificate },
|
|
502
|
+
attributes: { trustedRootCertificates },
|
|
503
|
+
session,
|
|
504
|
+
}) => {
|
|
505
|
+
assertSecureSession(session);
|
|
506
|
+
|
|
480
507
|
const failsafeContext = session.context.failsafeContext;
|
|
481
508
|
|
|
482
509
|
if (failsafeContext.hasRootCert) {
|
|
@@ -498,6 +525,7 @@ export const OperationalCredentialsClusterHandler: (
|
|
|
498
525
|
} catch (error) {
|
|
499
526
|
logger.info("setting root certificate failed", error);
|
|
500
527
|
if (
|
|
528
|
+
error instanceof CryptoVerifyError ||
|
|
501
529
|
error instanceof CertificateError ||
|
|
502
530
|
error instanceof ValidationError ||
|
|
503
531
|
error instanceof UnexpectedDataError
|
|
@@ -506,6 +534,8 @@ export const OperationalCredentialsClusterHandler: (
|
|
|
506
534
|
}
|
|
507
535
|
throw error;
|
|
508
536
|
}
|
|
537
|
+
|
|
538
|
+
trustedRootCertificates.updated(session);
|
|
509
539
|
},
|
|
510
540
|
};
|
|
511
541
|
};
|
|
@@ -17,7 +17,8 @@ import { AsyncConstruction } from "../util/AsyncConstruction.js";
|
|
|
17
17
|
import { ByteArray } from "../util/ByteArray.js";
|
|
18
18
|
import { AsyncObservable } from "../util/Observable.js";
|
|
19
19
|
import { FailsafeTimer, MatterFabricConflictError } from "./FailsafeTimer.js";
|
|
20
|
-
import { MatterFlowError } from "./MatterError.js";
|
|
20
|
+
import { MatterFlowError, UnexpectedDataError } from "./MatterError.js";
|
|
21
|
+
import { ValidationError } from "./ValidationError.js";
|
|
21
22
|
|
|
22
23
|
const logger = Logger.get("FailsafeContext");
|
|
23
24
|
|
|
@@ -105,6 +106,10 @@ export abstract class FailsafeContext {
|
|
|
105
106
|
return this.#fabricBuilder.hasRootCert();
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
get rootCert() {
|
|
110
|
+
return this.#fabricBuilder.rootCert;
|
|
111
|
+
}
|
|
112
|
+
|
|
108
113
|
async completeCommission() {
|
|
109
114
|
// 1. The Fail-Safe timer associated with the current Fail-Safe context SHALL be disarmed.
|
|
110
115
|
if (this.#failsafe === undefined) {
|
|
@@ -215,12 +220,19 @@ export abstract class FailsafeContext {
|
|
|
215
220
|
const { nocValue, icacValue, adminVendorId, ipkValue, caseAdminSubject } = nocData;
|
|
216
221
|
|
|
217
222
|
// Handle error if the CaseAdminSubject field is not a valid ACL subject in the context of AuthMode set to CASE
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
if (!NodeId.isOperationalNodeId(caseAdminSubject) && !NodeId.isCaseAuthenticatedTag(caseAdminSubject)) {
|
|
224
|
+
try {
|
|
225
|
+
if (CaseAuthenticatedTag.getVersion(NodeId.extractAsCaseAuthenticatedTag(caseAdminSubject)) === 0) {
|
|
226
|
+
throw new MatterFabricInvalidAdminSubjectError();
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
// Validation error can happen when parsing the CaseAuthenticatedTag, then it is invalid too
|
|
230
|
+
if (error instanceof ValidationError || error instanceof UnexpectedDataError) {
|
|
231
|
+
throw new MatterFabricInvalidAdminSubjectError();
|
|
232
|
+
} else {
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
224
236
|
}
|
|
225
237
|
|
|
226
238
|
builder.setOperationalCert(nocValue, icacValue);
|
package/src/crypto/Crypto.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const CRYPTO_AUTH_TAG_LENGTH = 16;
|
|
|
27
27
|
export const CRYPTO_SYMMETRIC_KEY_LENGTH = 16;
|
|
28
28
|
export type CryptoDsaEncoding = "ieee-p1363" | "der";
|
|
29
29
|
|
|
30
|
-
export class
|
|
30
|
+
export class CryptoVerifyError extends MatterError {}
|
|
31
31
|
|
|
32
32
|
export abstract class Crypto {
|
|
33
33
|
static get: () => Crypto = () => {
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import { MatterDevice } from "../MatterDevice.js";
|
|
8
8
|
import { AccessLevel } from "../cluster/Cluster.js";
|
|
9
9
|
import { AccessControlCluster } from "../cluster/definitions/index.js";
|
|
10
|
-
import { AnyAttributeServer, AttributeServer } from "../cluster/server/AttributeServer.js";
|
|
10
|
+
import { AnyAttributeServer, AttributeServer, FabricScopedAttributeServer } from "../cluster/server/AttributeServer.js";
|
|
11
11
|
import { CommandServer } from "../cluster/server/CommandServer.js";
|
|
12
|
-
import {
|
|
12
|
+
import { AnyEventServer } from "../cluster/server/EventServer.js";
|
|
13
13
|
import { Message } from "../codec/MessageCodec.js";
|
|
14
14
|
import { InternalError } from "../common/MatterError.js";
|
|
15
15
|
import { EndpointNumber } from "../datatype/EndpointNumber.js";
|
|
@@ -92,13 +92,24 @@ export class LegacyInteractionServer extends InteractionServer {
|
|
|
92
92
|
endpoint: EndpointInterface,
|
|
93
93
|
) {
|
|
94
94
|
this.#assertAccess(path, exchange, attribute.readAcl);
|
|
95
|
-
|
|
95
|
+
const data = await super.readAttribute(path, attribute, exchange, isFabricFiltered, message, endpoint);
|
|
96
|
+
if (attribute instanceof FabricScopedAttributeServer && !isFabricFiltered) {
|
|
97
|
+
const { value, version } = data;
|
|
98
|
+
return {
|
|
99
|
+
value: attribute.sanitizeFabricSensitiveFields(
|
|
100
|
+
value,
|
|
101
|
+
(exchange.session as SecureSession<MatterDevice>).fabric,
|
|
102
|
+
),
|
|
103
|
+
version,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return data;
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
protected override async readEvent(
|
|
99
110
|
path: EventPath,
|
|
100
111
|
eventFilters: TypeFromSchema<typeof TlvEventFilter>[] | undefined,
|
|
101
|
-
event:
|
|
112
|
+
event: AnyEventServer<any, any>,
|
|
102
113
|
exchange: MessageExchange<MatterDevice>,
|
|
103
114
|
isFabricFiltered: boolean,
|
|
104
115
|
message: Message,
|
package/src/fabric/Fabric.ts
CHANGED
|
@@ -381,11 +381,17 @@ export class FabricBuilder {
|
|
|
381
381
|
|
|
382
382
|
setRootCert(rootCert: ByteArray) {
|
|
383
383
|
const decodedRootCertificate = TlvRootCertificate.decode(rootCert);
|
|
384
|
+
CertificateManager.verifyRootCertificate(decodedRootCertificate);
|
|
384
385
|
this.#rootCert = rootCert;
|
|
385
386
|
this.#rootPublicKey = decodedRootCertificate.ellipticCurvePublicKey;
|
|
386
387
|
return this;
|
|
387
388
|
}
|
|
388
389
|
|
|
390
|
+
// TODO Remove when legacy API gets removed because then no longer needed
|
|
391
|
+
get rootCert() {
|
|
392
|
+
return this.#rootCert;
|
|
393
|
+
}
|
|
394
|
+
|
|
389
395
|
hasRootCert() {
|
|
390
396
|
return this.#rootCert !== undefined;
|
|
391
397
|
}
|
|
@@ -20,6 +20,10 @@ export class FieldModel extends PropertyModel implements FieldElement {
|
|
|
20
20
|
super(definition);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
get fabricSensitive() {
|
|
24
|
+
return this.effectiveAccess.fabricSensitive;
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
/**
|
|
24
28
|
* Fields may omit their ID. In this case we use their index within the parent as the ID.
|
|
25
29
|
*/
|
|
@@ -14,7 +14,7 @@ import { AccessControlServer } from "../../behavior/definitions/access-control/A
|
|
|
14
14
|
import { AccessControlCluster } from "../../cluster/definitions/AccessControlCluster.js";
|
|
15
15
|
import { AnyAttributeServer, AttributeServer } from "../../cluster/server/AttributeServer.js";
|
|
16
16
|
import { CommandServer } from "../../cluster/server/CommandServer.js";
|
|
17
|
-
import {
|
|
17
|
+
import { AnyEventServer } from "../../cluster/server/EventServer.js";
|
|
18
18
|
import { Message } from "../../codec/MessageCodec.js";
|
|
19
19
|
import { InternalError } from "../../common/MatterError.js";
|
|
20
20
|
import { Endpoint } from "../../endpoint/Endpoint.js";
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
import { TypeFromSchema } from "../../tlv/TlvSchema.js";
|
|
42
42
|
import { MaybePromise } from "../../util/Promises.js";
|
|
43
43
|
import { ServerNode } from "../ServerNode.js";
|
|
44
|
-
import { ServerStore } from "./storage/ServerStore.js";
|
|
45
44
|
|
|
46
45
|
const activityKey = Symbol("activity");
|
|
47
46
|
|
|
@@ -77,7 +76,6 @@ export class TransactionalInteractionServer extends InteractionServer {
|
|
|
77
76
|
const structure = new InteractionEndpointStructure();
|
|
78
77
|
|
|
79
78
|
super({
|
|
80
|
-
eventHandler: endpoint.env.get(ServerStore).eventHandler,
|
|
81
79
|
endpointStructure: structure,
|
|
82
80
|
subscriptionOptions: endpoint.state.network.subscriptionOptions,
|
|
83
81
|
});
|
|
@@ -166,7 +164,7 @@ export class TransactionalInteractionServer extends InteractionServer {
|
|
|
166
164
|
protected override async readEvent(
|
|
167
165
|
path: EventPath,
|
|
168
166
|
eventFilters: TypeFromSchema<typeof TlvEventFilter>[] | undefined,
|
|
169
|
-
event:
|
|
167
|
+
event: AnyEventServer<any, any>,
|
|
170
168
|
exchange: MessageExchange<MatterDevice>,
|
|
171
169
|
fabricFiltered: boolean,
|
|
172
170
|
message: Message,
|
|
@@ -10,7 +10,7 @@ import { EndpointNumber } from "../../datatype/EndpointNumber.js";
|
|
|
10
10
|
import { NodeId } from "../../datatype/NodeId.js";
|
|
11
11
|
import { Logger } from "../../log/Logger.js";
|
|
12
12
|
import { ArraySchema } from "../../tlv/TlvArray.js";
|
|
13
|
-
import { TlvSchema, TlvStream, TypeFromSchema } from "../../tlv/TlvSchema.js";
|
|
13
|
+
import { TlvEncodingOptions, TlvSchema, TlvStream, TypeFromSchema } from "../../tlv/TlvSchema.js";
|
|
14
14
|
import {
|
|
15
15
|
TlvAttributePath,
|
|
16
16
|
TlvAttributeReport,
|
|
@@ -31,6 +31,7 @@ type FullAttributePath = {
|
|
|
31
31
|
/** Type for TlvAttributeReport where the real data are represented with the schema and the JS value. */
|
|
32
32
|
export type AttributeReportPayload = Omit<TypeFromSchema<typeof TlvAttributeReport>, "attributeData"> & {
|
|
33
33
|
attributeData?: AttributeDataPayload;
|
|
34
|
+
hasFabricSensitiveData: boolean;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
/** Type for TlvAttributeReportData where the real data are represented with the schema and the JS value. */
|
|
@@ -42,6 +43,7 @@ type AttributeDataPayload = Omit<TypeFromSchema<typeof TlvAttributeReportData>,
|
|
|
42
43
|
/** Type for TlvEventReport where the real data are represented with the schema and the JS value. */
|
|
43
44
|
export type EventReportPayload = Omit<TypeFromSchema<typeof TlvEventReport>, "eventData"> & {
|
|
44
45
|
eventData?: EventDataPayload;
|
|
46
|
+
hasFabricSensitiveData: boolean;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
/** Type for TlvEventData where the real data are represented with the schema and the JS value. */
|
|
@@ -57,18 +59,23 @@ export type DataReportPayload = Omit<TypeFromSchema<typeof TlvDataReport>, "attr
|
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
/** Encodes an AttributeReportPayload into a TlvStream (used for TlvAny type). */
|
|
60
|
-
export function encodeAttributePayload(
|
|
62
|
+
export function encodeAttributePayload(
|
|
63
|
+
attributePayload: AttributeReportPayload,
|
|
64
|
+
options?: TlvEncodingOptions,
|
|
65
|
+
): TlvStream {
|
|
61
66
|
const { attributeData, attributeStatus } = attributePayload;
|
|
62
67
|
if (attributeData === undefined) {
|
|
63
68
|
return TlvAttributeReport.encodeTlv({ attributeStatus });
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
const { path, schema, payload, dataVersion } = attributeData;
|
|
67
|
-
return TlvAttributeReport.encodeTlv({
|
|
72
|
+
return TlvAttributeReport.encodeTlv({
|
|
73
|
+
attributeData: { path, data: schema.encodeTlv(payload, options), dataVersion },
|
|
74
|
+
});
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
/** Encodes an EventReportPayload into a TlvStream (used for TlvAny type). */
|
|
71
|
-
export function encodeEventPayload(eventPayload: EventReportPayload): TlvStream {
|
|
78
|
+
export function encodeEventPayload(eventPayload: EventReportPayload, options?: TlvEncodingOptions): TlvStream {
|
|
72
79
|
const { eventData, eventStatus } = eventPayload;
|
|
73
80
|
if (eventData === undefined) {
|
|
74
81
|
return TlvEventReport.encodeTlv({ eventStatus });
|
|
@@ -88,7 +95,7 @@ export function encodeEventPayload(eventPayload: EventReportPayload): TlvStream
|
|
|
88
95
|
return TlvEventReport.encodeTlv({
|
|
89
96
|
eventData: {
|
|
90
97
|
path,
|
|
91
|
-
data: schema.encodeTlv(payload),
|
|
98
|
+
data: schema.encodeTlv(payload, options),
|
|
92
99
|
priority,
|
|
93
100
|
systemTimestamp,
|
|
94
101
|
deltaSystemTimestamp,
|
|
@@ -115,7 +122,7 @@ export function canAttributePayloadBeChunked(attributePayload: AttributeReportPa
|
|
|
115
122
|
|
|
116
123
|
/** Chunk an AttributeReportPayload into multiple AttributeReportPayloads. */
|
|
117
124
|
export function chunkAttributePayload(attributePayload: AttributeReportPayload): AttributeReportPayload[] {
|
|
118
|
-
const { attributeData } = attributePayload;
|
|
125
|
+
const { hasFabricSensitiveData, attributeData } = attributePayload;
|
|
119
126
|
if (attributeData === undefined) {
|
|
120
127
|
throw new MatterFlowError(
|
|
121
128
|
`Can not chunk an AttributePayload with just a attributeStatus: ${Logger.toJSON(attributePayload)}`,
|
|
@@ -130,9 +137,13 @@ export function chunkAttributePayload(attributePayload: AttributeReportPayload):
|
|
|
130
137
|
);
|
|
131
138
|
}
|
|
132
139
|
const chunks = new Array<AttributeReportPayload>();
|
|
133
|
-
chunks.push({
|
|
140
|
+
chunks.push({
|
|
141
|
+
hasFabricSensitiveData: hasFabricSensitiveData,
|
|
142
|
+
attributeData: { schema, path: { ...path, listIndex: undefined }, payload: [], dataVersion },
|
|
143
|
+
});
|
|
134
144
|
payload.forEach(element => {
|
|
135
145
|
chunks.push({
|
|
146
|
+
hasFabricSensitiveData: hasFabricSensitiveData,
|
|
136
147
|
attributeData: {
|
|
137
148
|
schema: schema.elementSchema,
|
|
138
149
|
path: { ...path, listIndex: null },
|
|
@@ -183,7 +194,7 @@ export function sortAttributeDataByPath(data1: AttributeReportPayload, data2: At
|
|
|
183
194
|
export function compressAttributeDataReportTags(data: AttributeReportPayload[]) {
|
|
184
195
|
let lastFullPath: FullAttributePath | undefined;
|
|
185
196
|
|
|
186
|
-
return data.sort(sortAttributeDataByPath).map(({ attributeData, attributeStatus }) => {
|
|
197
|
+
return data.sort(sortAttributeDataByPath).map(({ hasFabricSensitiveData, attributeData, attributeStatus }) => {
|
|
187
198
|
if (attributeData !== undefined) {
|
|
188
199
|
const { path, dataVersion } = attributeData;
|
|
189
200
|
const compressedPath = compressPath(path, dataVersion, lastFullPath);
|
|
@@ -201,7 +212,7 @@ export function compressAttributeDataReportTags(data: AttributeReportPayload[])
|
|
|
201
212
|
attributeStatus = { ...attributeStatus, path: compressedPath.path };
|
|
202
213
|
lastFullPath = compressedPath.lastFullPath;
|
|
203
214
|
}
|
|
204
|
-
return { attributeData, attributeStatus };
|
|
215
|
+
return { hasFabricSensitiveData, attributeData, attributeStatus };
|
|
205
216
|
});
|
|
206
217
|
}
|
|
207
218
|
|
|
@@ -102,9 +102,7 @@ export class EventHandler<S extends Storage = any> {
|
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
if (filterForFabricIndex !== undefined) {
|
|
105
|
-
return events.filter(
|
|
106
|
-
event => !("fabricIndex" in event.data) || event.data.fabricIndex === filterForFabricIndex,
|
|
107
|
-
);
|
|
105
|
+
return events.filter(({ data }) => !("fabricIndex" in data) || data.fabricIndex === filterForFabricIndex);
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
return events;
|
|
@@ -460,7 +460,7 @@ export class InteractionClient {
|
|
|
460
460
|
const writeRequests = attributes.map(
|
|
461
461
|
({ endpointId, clusterId, attribute: { id, schema }, value, dataVersion }) => ({
|
|
462
462
|
path: { endpointId, clusterId, attributeId: id },
|
|
463
|
-
data: schema.encodeTlv(value, true),
|
|
463
|
+
data: schema.encodeTlv(value, { forWriteInteraction: true }),
|
|
464
464
|
dataVersion,
|
|
465
465
|
}),
|
|
466
466
|
);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { AnyAttributeServer } from "../../cluster/server/AttributeServer.js";
|
|
8
8
|
import { ClusterServerObj, asClusterServerInternal } from "../../cluster/server/ClusterServerTypes.js";
|
|
9
9
|
import { CommandServer } from "../../cluster/server/CommandServer.js";
|
|
10
|
-
import {
|
|
10
|
+
import { AnyEventServer } from "../../cluster/server/EventServer.js";
|
|
11
11
|
import { ImplementationError, InternalError } from "../../common/MatterError.js";
|
|
12
12
|
import { AttributeId } from "../../datatype/AttributeId.js";
|
|
13
13
|
import { ClusterId } from "../../datatype/ClusterId.js";
|
|
@@ -37,11 +37,11 @@ export class InteractionEndpointStructure {
|
|
|
37
37
|
endpoints = new Map<EndpointNumber, EndpointInterface>();
|
|
38
38
|
attributes = new Map<string, AnyAttributeServer<any>>();
|
|
39
39
|
attributePaths = new Array<AttributePath>();
|
|
40
|
-
events = new Map<string,
|
|
40
|
+
events = new Map<string, AnyEventServer<any, any>>();
|
|
41
41
|
eventPaths = new Array<EventPath>();
|
|
42
42
|
commands = new Map<string, CommandServer<any, any>>();
|
|
43
43
|
commandPaths = new Array<CommandPath>();
|
|
44
|
-
change = new Observable();
|
|
44
|
+
change = new Observable(); // TODO adjust to AsyncObservable when we remove legacy API
|
|
45
45
|
|
|
46
46
|
public clear() {
|
|
47
47
|
this.endpoints.clear();
|
|
@@ -220,7 +220,7 @@ export class InteractionEndpointStructure {
|
|
|
220
220
|
throw new StatusResponseError(`Attribute ${attributeId} does not exist`, StatusCode.UnsupportedAttribute);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
getEvent(endpointId: EndpointNumber, clusterId: ClusterId, eventId: EventId):
|
|
223
|
+
getEvent(endpointId: EndpointNumber, clusterId: ClusterId, eventId: EventId): AnyEventServer<any, any> | undefined {
|
|
224
224
|
return this.events.get(eventPathToId({ endpointId, clusterId, eventId }));
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -166,6 +166,7 @@ export class InteractionServerMessenger extends InteractionMessenger<MatterDevic
|
|
|
166
166
|
const readRequest = TlvReadRequest.decode(message.payload);
|
|
167
167
|
await this.sendDataReport(
|
|
168
168
|
await recipient.handleReadRequest(this.exchange, readRequest, message),
|
|
169
|
+
readRequest.isFabricFiltered,
|
|
169
170
|
);
|
|
170
171
|
break;
|
|
171
172
|
}
|
|
@@ -229,7 +230,7 @@ export class InteractionServerMessenger extends InteractionMessenger<MatterDevic
|
|
|
229
230
|
* Handle DataReportPayload with the content of a DataReport to send, split them into multiple DataReport
|
|
230
231
|
* messages and send them out based on the size.
|
|
231
232
|
*/
|
|
232
|
-
async sendDataReport(dataReportPayload: DataReportPayload) {
|
|
233
|
+
async sendDataReport(dataReportPayload: DataReportPayload, forFabricFilteredRead: boolean) {
|
|
233
234
|
const {
|
|
234
235
|
subscriptionId,
|
|
235
236
|
attributeReportsPayload,
|
|
@@ -272,7 +273,11 @@ export class InteractionServerMessenger extends InteractionMessenger<MatterDevic
|
|
|
272
273
|
firstAttributeAddedToReportMessage = true;
|
|
273
274
|
messageSize += 3; // Array element is added now which needs 3 bytes
|
|
274
275
|
}
|
|
275
|
-
const
|
|
276
|
+
const allowMissingFieldsForNonFabricFilteredRead =
|
|
277
|
+
!forFabricFilteredRead && attributeReport.hasFabricSensitiveData;
|
|
278
|
+
const encodedAttribute = encodeAttributePayload(attributeReport, {
|
|
279
|
+
allowMissingFieldsForNonFabricFilteredRead,
|
|
280
|
+
});
|
|
276
281
|
const attributeReportBytes = TlvAny.getEncodedByteLength(encodedAttribute);
|
|
277
282
|
if (messageSize + attributeReportBytes > MAX_SPDU_LENGTH) {
|
|
278
283
|
if (canAttributePayloadBeChunked(attributeReport)) {
|
|
@@ -297,7 +302,11 @@ export class InteractionServerMessenger extends InteractionMessenger<MatterDevic
|
|
|
297
302
|
firstEventAddedToReportMessage = true;
|
|
298
303
|
messageSize += 3; // Array element is added now which needs 3 bytes
|
|
299
304
|
}
|
|
300
|
-
const
|
|
305
|
+
const allowMissingFieldsForNonFabricFilteredRead =
|
|
306
|
+
!forFabricFilteredRead && eventReport.hasFabricSensitiveData;
|
|
307
|
+
const encodedEvent = encodeEventPayload(eventReport, {
|
|
308
|
+
allowMissingFieldsForNonFabricFilteredRead,
|
|
309
|
+
});
|
|
301
310
|
const eventReportBytes = TlvAny.getEncodedByteLength(encodedEvent);
|
|
302
311
|
if (messageSize + eventReportBytes > MAX_SPDU_LENGTH) {
|
|
303
312
|
await sendAndResetReport();
|