@project-chip/matter.js 0.9.2 → 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.
Files changed (288) hide show
  1. package/dist/cjs/CommissioningServer.d.ts.map +1 -1
  2. package/dist/cjs/CommissioningServer.js +0 -1
  3. package/dist/cjs/CommissioningServer.js.map +2 -2
  4. package/dist/cjs/MatterDevice.d.ts +3 -0
  5. package/dist/cjs/MatterDevice.d.ts.map +1 -1
  6. package/dist/cjs/MatterDevice.js +21 -7
  7. package/dist/cjs/MatterDevice.js.map +2 -2
  8. package/dist/cjs/behavior/AccessControl.js +2 -2
  9. package/dist/cjs/behavior/AccessControl.js.map +2 -2
  10. package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts +1 -0
  11. package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts.map +1 -1
  12. package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js +14 -0
  13. package/dist/cjs/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js.map +2 -2
  14. package/dist/cjs/behavior/definitions/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
  15. package/dist/cjs/behavior/definitions/operational-credentials/OperationalCredentialsServer.js +11 -2
  16. package/dist/cjs/behavior/definitions/operational-credentials/OperationalCredentialsServer.js.map +2 -2
  17. package/dist/cjs/behavior/state/transaction/Transaction.d.ts +18 -18
  18. package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
  19. package/dist/cjs/certificate/CertificateManager.js +1 -0
  20. package/dist/cjs/certificate/CertificateManager.js.map +2 -2
  21. package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +1 -1
  22. package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +1 -1
  23. package/dist/cjs/certificate/CertificationDeclarationManager.js +3 -2
  24. package/dist/cjs/certificate/CertificationDeclarationManager.js.map +2 -2
  25. package/dist/cjs/cluster/server/AccessControlServer.js.map +1 -1
  26. package/dist/cjs/cluster/server/AttributeServer.d.ts +9 -0
  27. package/dist/cjs/cluster/server/AttributeServer.d.ts.map +1 -1
  28. package/dist/cjs/cluster/server/AttributeServer.js +62 -0
  29. package/dist/cjs/cluster/server/AttributeServer.js.map +3 -3
  30. package/dist/cjs/cluster/server/ClusterServer.d.ts.map +1 -1
  31. package/dist/cjs/cluster/server/ClusterServer.js +8 -1
  32. package/dist/cjs/cluster/server/ClusterServer.js.map +2 -2
  33. package/dist/cjs/cluster/server/ClusterServerTypes.d.ts +3 -3
  34. package/dist/cjs/cluster/server/ClusterServerTypes.d.ts.map +1 -1
  35. package/dist/cjs/cluster/server/ClusterServerTypes.js.map +1 -1
  36. package/dist/cjs/cluster/server/EventServer.d.ts +8 -2
  37. package/dist/cjs/cluster/server/EventServer.d.ts.map +1 -1
  38. package/dist/cjs/cluster/server/EventServer.js +33 -7
  39. package/dist/cjs/cluster/server/EventServer.js.map +2 -2
  40. package/dist/cjs/cluster/server/OperationalCredentialsServer.d.ts.map +1 -1
  41. package/dist/cjs/cluster/server/OperationalCredentialsServer.js +31 -8
  42. package/dist/cjs/cluster/server/OperationalCredentialsServer.js.map +2 -2
  43. package/dist/cjs/common/FailsafeContext.d.ts +1 -0
  44. package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
  45. package/dist/cjs/common/FailsafeContext.js +16 -2
  46. package/dist/cjs/common/FailsafeContext.js.map +2 -2
  47. package/dist/cjs/crypto/Crypto.d.ts +1 -1
  48. package/dist/cjs/crypto/Crypto.d.ts.map +1 -1
  49. package/dist/cjs/crypto/Crypto.js +2 -2
  50. package/dist/cjs/crypto/Crypto.js.map +2 -2
  51. package/dist/cjs/device/LegacyInteractionServer.d.ts +2 -2
  52. package/dist/cjs/device/LegacyInteractionServer.d.ts.map +1 -1
  53. package/dist/cjs/device/LegacyInteractionServer.js +13 -1
  54. package/dist/cjs/device/LegacyInteractionServer.js.map +2 -2
  55. package/dist/cjs/fabric/Fabric.d.ts +1 -0
  56. package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
  57. package/dist/cjs/fabric/Fabric.js +5 -0
  58. package/dist/cjs/fabric/Fabric.js.map +2 -2
  59. package/dist/cjs/fabric/FabricManager.d.ts +1 -0
  60. package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
  61. package/dist/cjs/fabric/FabricManager.js +2 -1
  62. package/dist/cjs/fabric/FabricManager.js.map +2 -2
  63. package/dist/cjs/model/models/EventModel.d.ts +1 -0
  64. package/dist/cjs/model/models/EventModel.d.ts.map +1 -1
  65. package/dist/cjs/model/models/EventModel.js +3 -0
  66. package/dist/cjs/model/models/EventModel.js.map +2 -2
  67. package/dist/cjs/model/models/FieldModel.d.ts +1 -0
  68. package/dist/cjs/model/models/FieldModel.d.ts.map +1 -1
  69. package/dist/cjs/model/models/FieldModel.js +3 -0
  70. package/dist/cjs/model/models/FieldModel.js.map +2 -2
  71. package/dist/cjs/node/server/TransactionalInteractionServer.d.ts +2 -2
  72. package/dist/cjs/node/server/TransactionalInteractionServer.d.ts.map +1 -1
  73. package/dist/cjs/node/server/TransactionalInteractionServer.js +0 -2
  74. package/dist/cjs/node/server/TransactionalInteractionServer.js.map +2 -2
  75. package/dist/cjs/protocol/interaction/AttributeDataEncoder.d.ts +6 -3
  76. package/dist/cjs/protocol/interaction/AttributeDataEncoder.d.ts.map +1 -1
  77. package/dist/cjs/protocol/interaction/AttributeDataEncoder.js +14 -8
  78. package/dist/cjs/protocol/interaction/AttributeDataEncoder.js.map +2 -2
  79. package/dist/cjs/protocol/interaction/EventHandler.d.ts.map +1 -1
  80. package/dist/cjs/protocol/interaction/EventHandler.js +1 -3
  81. package/dist/cjs/protocol/interaction/EventHandler.js.map +2 -2
  82. package/dist/cjs/protocol/interaction/InteractionClient.js +1 -1
  83. package/dist/cjs/protocol/interaction/InteractionClient.js.map +2 -2
  84. package/dist/cjs/protocol/interaction/InteractionEndpointStructure.d.ts +3 -3
  85. package/dist/cjs/protocol/interaction/InteractionEndpointStructure.d.ts.map +1 -1
  86. package/dist/cjs/protocol/interaction/InteractionEndpointStructure.js +1 -0
  87. package/dist/cjs/protocol/interaction/InteractionEndpointStructure.js.map +2 -2
  88. package/dist/cjs/protocol/interaction/InteractionMessenger.d.ts +1 -1
  89. package/dist/cjs/protocol/interaction/InteractionMessenger.d.ts.map +1 -1
  90. package/dist/cjs/protocol/interaction/InteractionMessenger.js +11 -4
  91. package/dist/cjs/protocol/interaction/InteractionMessenger.js.map +2 -2
  92. package/dist/cjs/protocol/interaction/InteractionServer.d.ts +5 -6
  93. package/dist/cjs/protocol/interaction/InteractionServer.d.ts.map +1 -1
  94. package/dist/cjs/protocol/interaction/InteractionServer.js +44 -37
  95. package/dist/cjs/protocol/interaction/InteractionServer.js.map +2 -2
  96. package/dist/cjs/protocol/interaction/SubscriptionHandler.d.ts +31 -12
  97. package/dist/cjs/protocol/interaction/SubscriptionHandler.d.ts.map +1 -1
  98. package/dist/cjs/protocol/interaction/SubscriptionHandler.js +161 -69
  99. package/dist/cjs/protocol/interaction/SubscriptionHandler.js.map +3 -3
  100. package/dist/cjs/session/SecureSession.d.ts.map +1 -1
  101. package/dist/cjs/session/SecureSession.js +2 -1
  102. package/dist/cjs/session/SecureSession.js.map +2 -2
  103. package/dist/cjs/session/SessionManager.d.ts +2 -0
  104. package/dist/cjs/session/SessionManager.d.ts.map +1 -1
  105. package/dist/cjs/session/SessionManager.js +7 -0
  106. package/dist/cjs/session/SessionManager.js.map +2 -2
  107. package/dist/cjs/tlv/TlvArray.d.ts +2 -2
  108. package/dist/cjs/tlv/TlvArray.d.ts.map +1 -1
  109. package/dist/cjs/tlv/TlvArray.js +2 -2
  110. package/dist/cjs/tlv/TlvArray.js.map +2 -2
  111. package/dist/cjs/tlv/TlvNullable.d.ts +2 -2
  112. package/dist/cjs/tlv/TlvNullable.d.ts.map +1 -1
  113. package/dist/cjs/tlv/TlvNullable.js +2 -2
  114. package/dist/cjs/tlv/TlvNullable.js.map +2 -2
  115. package/dist/cjs/tlv/TlvObject.d.ts +2 -2
  116. package/dist/cjs/tlv/TlvObject.d.ts.map +1 -1
  117. package/dist/cjs/tlv/TlvObject.js +18 -12
  118. package/dist/cjs/tlv/TlvObject.js.map +2 -2
  119. package/dist/cjs/tlv/TlvSchema.d.ts +14 -2
  120. package/dist/cjs/tlv/TlvSchema.d.ts.map +1 -1
  121. package/dist/cjs/tlv/TlvSchema.js +2 -2
  122. package/dist/cjs/tlv/TlvSchema.js.map +2 -2
  123. package/dist/cjs/tlv/TlvWrapper.d.ts +2 -2
  124. package/dist/cjs/tlv/TlvWrapper.d.ts.map +1 -1
  125. package/dist/cjs/tlv/TlvWrapper.js +2 -2
  126. package/dist/cjs/tlv/TlvWrapper.js.map +2 -2
  127. package/dist/esm/CommissioningServer.d.ts.map +1 -1
  128. package/dist/esm/CommissioningServer.js +0 -1
  129. package/dist/esm/CommissioningServer.js.map +2 -2
  130. package/dist/esm/MatterDevice.d.ts +3 -0
  131. package/dist/esm/MatterDevice.d.ts.map +1 -1
  132. package/dist/esm/MatterDevice.js +21 -7
  133. package/dist/esm/MatterDevice.js.map +2 -2
  134. package/dist/esm/behavior/AccessControl.js +2 -2
  135. package/dist/esm/behavior/AccessControl.js.map +2 -2
  136. package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts +1 -0
  137. package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.d.ts.map +1 -1
  138. package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js +15 -1
  139. package/dist/esm/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.js.map +2 -2
  140. package/dist/esm/behavior/definitions/operational-credentials/OperationalCredentialsServer.d.ts.map +1 -1
  141. package/dist/esm/behavior/definitions/operational-credentials/OperationalCredentialsServer.js +11 -2
  142. package/dist/esm/behavior/definitions/operational-credentials/OperationalCredentialsServer.js.map +2 -2
  143. package/dist/esm/behavior/state/transaction/Transaction.d.ts +18 -18
  144. package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
  145. package/dist/esm/certificate/CertificateManager.js +1 -0
  146. package/dist/esm/certificate/CertificateManager.js.map +2 -2
  147. package/dist/esm/certificate/CertificationDeclarationManager.d.ts +1 -1
  148. package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +1 -1
  149. package/dist/esm/certificate/CertificationDeclarationManager.js +3 -2
  150. package/dist/esm/certificate/CertificationDeclarationManager.js.map +2 -2
  151. package/dist/esm/cluster/server/AccessControlServer.js.map +1 -1
  152. package/dist/esm/cluster/server/AttributeServer.d.ts +9 -0
  153. package/dist/esm/cluster/server/AttributeServer.d.ts.map +1 -1
  154. package/dist/esm/cluster/server/AttributeServer.js +69 -1
  155. package/dist/esm/cluster/server/AttributeServer.js.map +2 -2
  156. package/dist/esm/cluster/server/ClusterServer.d.ts.map +1 -1
  157. package/dist/esm/cluster/server/ClusterServer.js +9 -2
  158. package/dist/esm/cluster/server/ClusterServer.js.map +2 -2
  159. package/dist/esm/cluster/server/ClusterServerTypes.d.ts +3 -3
  160. package/dist/esm/cluster/server/ClusterServerTypes.d.ts.map +1 -1
  161. package/dist/esm/cluster/server/ClusterServerTypes.js.map +1 -1
  162. package/dist/esm/cluster/server/EventServer.d.ts +8 -2
  163. package/dist/esm/cluster/server/EventServer.d.ts.map +1 -1
  164. package/dist/esm/cluster/server/EventServer.js +33 -7
  165. package/dist/esm/cluster/server/EventServer.js.map +2 -2
  166. package/dist/esm/cluster/server/OperationalCredentialsServer.d.ts.map +1 -1
  167. package/dist/esm/cluster/server/OperationalCredentialsServer.js +31 -8
  168. package/dist/esm/cluster/server/OperationalCredentialsServer.js.map +2 -2
  169. package/dist/esm/common/FailsafeContext.d.ts +1 -0
  170. package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
  171. package/dist/esm/common/FailsafeContext.js +17 -3
  172. package/dist/esm/common/FailsafeContext.js.map +2 -2
  173. package/dist/esm/crypto/Crypto.d.ts +1 -1
  174. package/dist/esm/crypto/Crypto.d.ts.map +1 -1
  175. package/dist/esm/crypto/Crypto.js +2 -2
  176. package/dist/esm/crypto/Crypto.js.map +2 -2
  177. package/dist/esm/device/LegacyInteractionServer.d.ts +2 -2
  178. package/dist/esm/device/LegacyInteractionServer.d.ts.map +1 -1
  179. package/dist/esm/device/LegacyInteractionServer.js +13 -1
  180. package/dist/esm/device/LegacyInteractionServer.js.map +2 -2
  181. package/dist/esm/fabric/Fabric.d.ts +1 -0
  182. package/dist/esm/fabric/Fabric.d.ts.map +1 -1
  183. package/dist/esm/fabric/Fabric.js +5 -0
  184. package/dist/esm/fabric/Fabric.js.map +2 -2
  185. package/dist/esm/fabric/FabricManager.d.ts +1 -0
  186. package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
  187. package/dist/esm/fabric/FabricManager.js +2 -1
  188. package/dist/esm/fabric/FabricManager.js.map +2 -2
  189. package/dist/esm/model/models/EventModel.d.ts +1 -0
  190. package/dist/esm/model/models/EventModel.d.ts.map +1 -1
  191. package/dist/esm/model/models/EventModel.js +3 -0
  192. package/dist/esm/model/models/EventModel.js.map +2 -2
  193. package/dist/esm/model/models/FieldModel.d.ts +1 -0
  194. package/dist/esm/model/models/FieldModel.d.ts.map +1 -1
  195. package/dist/esm/model/models/FieldModel.js +3 -0
  196. package/dist/esm/model/models/FieldModel.js.map +2 -2
  197. package/dist/esm/node/server/TransactionalInteractionServer.d.ts +2 -2
  198. package/dist/esm/node/server/TransactionalInteractionServer.d.ts.map +1 -1
  199. package/dist/esm/node/server/TransactionalInteractionServer.js +0 -2
  200. package/dist/esm/node/server/TransactionalInteractionServer.js.map +2 -2
  201. package/dist/esm/protocol/interaction/AttributeDataEncoder.d.ts +6 -3
  202. package/dist/esm/protocol/interaction/AttributeDataEncoder.d.ts.map +1 -1
  203. package/dist/esm/protocol/interaction/AttributeDataEncoder.js +14 -8
  204. package/dist/esm/protocol/interaction/AttributeDataEncoder.js.map +2 -2
  205. package/dist/esm/protocol/interaction/EventHandler.d.ts.map +1 -1
  206. package/dist/esm/protocol/interaction/EventHandler.js +1 -3
  207. package/dist/esm/protocol/interaction/EventHandler.js.map +2 -2
  208. package/dist/esm/protocol/interaction/InteractionClient.js +1 -1
  209. package/dist/esm/protocol/interaction/InteractionClient.js.map +2 -2
  210. package/dist/esm/protocol/interaction/InteractionEndpointStructure.d.ts +3 -3
  211. package/dist/esm/protocol/interaction/InteractionEndpointStructure.d.ts.map +1 -1
  212. package/dist/esm/protocol/interaction/InteractionEndpointStructure.js +1 -0
  213. package/dist/esm/protocol/interaction/InteractionEndpointStructure.js.map +2 -2
  214. package/dist/esm/protocol/interaction/InteractionMessenger.d.ts +1 -1
  215. package/dist/esm/protocol/interaction/InteractionMessenger.d.ts.map +1 -1
  216. package/dist/esm/protocol/interaction/InteractionMessenger.js +11 -4
  217. package/dist/esm/protocol/interaction/InteractionMessenger.js.map +2 -2
  218. package/dist/esm/protocol/interaction/InteractionServer.d.ts +5 -6
  219. package/dist/esm/protocol/interaction/InteractionServer.d.ts.map +1 -1
  220. package/dist/esm/protocol/interaction/InteractionServer.js +44 -37
  221. package/dist/esm/protocol/interaction/InteractionServer.js.map +2 -2
  222. package/dist/esm/protocol/interaction/SubscriptionHandler.d.ts +31 -12
  223. package/dist/esm/protocol/interaction/SubscriptionHandler.d.ts.map +1 -1
  224. package/dist/esm/protocol/interaction/SubscriptionHandler.js +161 -69
  225. package/dist/esm/protocol/interaction/SubscriptionHandler.js.map +3 -3
  226. package/dist/esm/session/SecureSession.d.ts.map +1 -1
  227. package/dist/esm/session/SecureSession.js +2 -1
  228. package/dist/esm/session/SecureSession.js.map +2 -2
  229. package/dist/esm/session/SessionManager.d.ts +2 -0
  230. package/dist/esm/session/SessionManager.d.ts.map +1 -1
  231. package/dist/esm/session/SessionManager.js +7 -0
  232. package/dist/esm/session/SessionManager.js.map +2 -2
  233. package/dist/esm/tlv/TlvArray.d.ts +2 -2
  234. package/dist/esm/tlv/TlvArray.d.ts.map +1 -1
  235. package/dist/esm/tlv/TlvArray.js +2 -2
  236. package/dist/esm/tlv/TlvArray.js.map +2 -2
  237. package/dist/esm/tlv/TlvNullable.d.ts +2 -2
  238. package/dist/esm/tlv/TlvNullable.d.ts.map +1 -1
  239. package/dist/esm/tlv/TlvNullable.js +2 -2
  240. package/dist/esm/tlv/TlvNullable.js.map +2 -2
  241. package/dist/esm/tlv/TlvObject.d.ts +2 -2
  242. package/dist/esm/tlv/TlvObject.d.ts.map +1 -1
  243. package/dist/esm/tlv/TlvObject.js +19 -13
  244. package/dist/esm/tlv/TlvObject.js.map +2 -2
  245. package/dist/esm/tlv/TlvSchema.d.ts +14 -2
  246. package/dist/esm/tlv/TlvSchema.d.ts.map +1 -1
  247. package/dist/esm/tlv/TlvSchema.js +2 -2
  248. package/dist/esm/tlv/TlvSchema.js.map +2 -2
  249. package/dist/esm/tlv/TlvWrapper.d.ts +2 -2
  250. package/dist/esm/tlv/TlvWrapper.d.ts.map +1 -1
  251. package/dist/esm/tlv/TlvWrapper.js +2 -2
  252. package/dist/esm/tlv/TlvWrapper.js.map +2 -2
  253. package/package.json +3 -3
  254. package/src/CommissioningServer.ts +0 -1
  255. package/src/MatterDevice.ts +34 -7
  256. package/src/behavior/AccessControl.ts +2 -2
  257. package/src/behavior/definitions/general-commissioning/ServerNodeFailsafeContext.ts +21 -1
  258. package/src/behavior/definitions/operational-credentials/OperationalCredentialsServer.ts +13 -0
  259. package/src/certificate/CertificateManager.ts +1 -2
  260. package/src/certificate/CertificationDeclarationManager.ts +2 -2
  261. package/src/cluster/server/AccessControlServer.ts +3 -3
  262. package/src/cluster/server/AttributeServer.ts +79 -1
  263. package/src/cluster/server/ClusterServer.ts +9 -2
  264. package/src/cluster/server/ClusterServerTypes.ts +3 -3
  265. package/src/cluster/server/EventServer.ts +57 -10
  266. package/src/cluster/server/OperationalCredentialsServer.ts +35 -5
  267. package/src/common/FailsafeContext.ts +19 -7
  268. package/src/crypto/Crypto.ts +1 -1
  269. package/src/device/LegacyInteractionServer.ts +15 -4
  270. package/src/fabric/Fabric.ts +6 -0
  271. package/src/fabric/FabricManager.ts +1 -0
  272. package/src/model/models/EventModel.ts +4 -0
  273. package/src/model/models/FieldModel.ts +4 -0
  274. package/src/node/server/TransactionalInteractionServer.ts +2 -4
  275. package/src/protocol/interaction/AttributeDataEncoder.ts +20 -9
  276. package/src/protocol/interaction/EventHandler.ts +1 -3
  277. package/src/protocol/interaction/InteractionClient.ts +1 -1
  278. package/src/protocol/interaction/InteractionEndpointStructure.ts +4 -4
  279. package/src/protocol/interaction/InteractionMessenger.ts +12 -3
  280. package/src/protocol/interaction/InteractionServer.ts +53 -52
  281. package/src/protocol/interaction/SubscriptionHandler.ts +215 -92
  282. package/src/session/SecureSession.ts +2 -1
  283. package/src/session/SessionManager.ts +9 -0
  284. package/src/tlv/TlvArray.ts +3 -3
  285. package/src/tlv/TlvNullable.ts +3 -3
  286. package/src/tlv/TlvObject.ts +20 -14
  287. package/src/tlv/TlvSchema.ts +17 -3
  288. package/src/tlv/TlvWrapper.ts +3 -3
@@ -13,7 +13,13 @@ import { AttributeId } from "../../datatype/AttributeId.js";
13
13
  import { Endpoint as EndpointInterface } from "../../device/Endpoint.js";
14
14
  import { Fabric } from "../../fabric/Fabric.js";
15
15
  import { Logger } from "../../log/Logger.js";
16
- import { Globals } from "../../model/index.js";
16
+ import {
17
+ AttributeModel,
18
+ ClusterModel,
19
+ DatatypeModel,
20
+ Globals,
21
+ MatterModel as MatterModelObj,
22
+ } from "../../model/index.js";
17
23
  import { StatusCode, StatusResponseError } from "../../protocol/interaction/StatusCode.js";
18
24
  import { BitSchema, TypeFromPartialBitSchema } from "../../schema/BitmapSchema.js";
19
25
  import { NoAssociatedFabricError, SecureSession, assertSecureSession } from "../../session/SecureSession.js";
@@ -21,11 +27,15 @@ import { Session } from "../../session/Session.js";
21
27
  import { TlvSchema } from "../../tlv/TlvSchema.js";
22
28
  import { isDeepEqual } from "../../util/DeepEqual.js";
23
29
  import { MaybePromise } from "../../util/Promises.js";
30
+ import { camelize } from "../../util/String.js";
24
31
  import { AccessLevel, Attribute, Attributes, Cluster, Commands, Events } from "../Cluster.js";
25
32
  import { ClusterDatasource } from "./ClusterServerTypes.js";
26
33
 
27
34
  const logger = Logger.get("AttributeServer");
28
35
 
36
+ const FabricIndexName = "fabricIndex";
37
+ const MatterModel = new MatterModelObj();
38
+
29
39
  /**
30
40
  * Thrown when an operation cannot complete because fabric information is
31
41
  * unavailable.
@@ -178,6 +188,10 @@ export abstract class BaseAttributeServer<T> {
178
188
  this.defaultValue = this.value;
179
189
  }
180
190
 
191
+ get hasFabricSensitiveData() {
192
+ return false;
193
+ }
194
+
181
195
  validateWithSchema(value: T) {
182
196
  try {
183
197
  this.schema.validate(value);
@@ -727,6 +741,7 @@ export function genericFabricScopedAttributeSetter<T>(
727
741
  export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
728
742
  private readonly isCustomGetter: boolean;
729
743
  private readonly isCustomSetter: boolean;
744
+ private readonly fabricSensitiveElementsToRemove = new Array<string>();
730
745
 
731
746
  constructor(
732
747
  id: AttributeId,
@@ -814,6 +829,69 @@ export class FabricScopedAttributeServer<T> extends AttributeServer<T> {
814
829
  );
815
830
  this.isCustomGetter = isCustomGetter;
816
831
  this.isCustomSetter = isCustomSetter;
832
+
833
+ this.#determineSensitiveFieldsToRemove();
834
+ }
835
+
836
+ #determineSensitiveFieldsToRemove() {
837
+ const clusterFromModel = MatterModel.get(ClusterModel, this.cluster.id);
838
+ if (clusterFromModel === undefined) {
839
+ logger.debug(`${this.cluster.name}: Cluster for Fabric scoped element not found in Model, ignore`);
840
+ return;
841
+ }
842
+ const attributeFromModel = clusterFromModel.get(AttributeModel, this.id);
843
+ if (attributeFromModel === undefined) {
844
+ logger.debug(
845
+ `${this.cluster.name}.${this.id}: Attribute for Fabric scoped element not found in Model, ignore`,
846
+ );
847
+ return;
848
+ }
849
+ if (!attributeFromModel.fabricScoped) {
850
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute is not Fabric scoped in model, ignore`);
851
+ return;
852
+ }
853
+ if (attributeFromModel.children.length !== 1) {
854
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute has not exactly one child, ignore`);
855
+ return;
856
+ }
857
+ const type = attributeFromModel.children[0].type;
858
+ if (type === undefined) {
859
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute field has no type, ignore`);
860
+ return;
861
+ }
862
+ const dataType = clusterFromModel.get(DatatypeModel, type);
863
+ if (dataType === undefined) {
864
+ logger.debug(`${this.cluster.name}.${this.id}: DataType ${type} not found in model, ignore`);
865
+ return;
866
+ }
867
+ dataType.children
868
+ .filter(field => field.fabricSensitive)
869
+ .forEach(field => this.fabricSensitiveElementsToRemove.push(camelize(field.name)));
870
+ }
871
+
872
+ override get hasFabricSensitiveData() {
873
+ return this.fabricSensitiveElementsToRemove.length > 0;
874
+ }
875
+
876
+ /**
877
+ * Sanitize the value of the attribute by removing fabric sensitive fields that do not belong to the
878
+ * associated fabric
879
+ */
880
+ sanitizeFabricSensitiveFields(value: T, associatedFabric?: Fabric) {
881
+ if (this.fabricSensitiveElementsToRemove.length && Array.isArray(value)) {
882
+ // Get the associated Fabric Index or uses -1 when no Fabric is associated because this value will
883
+ // never be in the struct
884
+ const associatedFabricIndex = associatedFabric?.fabricIndex ?? -1;
885
+ return value.map(data => {
886
+ if (data[FabricIndexName] !== associatedFabricIndex) {
887
+ const result = { ...data };
888
+ this.fabricSensitiveElementsToRemove.forEach(fieldName => delete result[fieldName]);
889
+ return result;
890
+ }
891
+ return data;
892
+ });
893
+ }
894
+ return value;
817
895
  }
818
896
 
819
897
  /**
@@ -37,7 +37,7 @@ import {
37
37
  SupportedEventsList,
38
38
  } from "./ClusterServerTypes.js";
39
39
  import { CommandServer } from "./CommandServer.js";
40
- import { EventServer } from "./EventServer.js";
40
+ import { createEventServer } from "./EventServer.js";
41
41
 
42
42
  const logger = Logger.get("ClusterServer");
43
43
 
@@ -508,7 +508,14 @@ export function ClusterServer<
508
508
  }
509
509
 
510
510
  if ((supportedEvents as any)[eventName] === true) {
511
- (events as any)[eventName] = new EventServer(id, clusterId, eventName, schema, priority, readAcl);
511
+ (events as any)[eventName] = createEventServer(
512
+ clusterDef,
513
+ eventDef[eventName],
514
+ eventName,
515
+ schema,
516
+ priority,
517
+ readAcl,
518
+ );
512
519
  const capitalizedEventName = capitalize(eventName);
513
520
  result[`trigger${capitalizedEventName}Event`] = <T>(event: T) =>
514
521
  (events as any)[eventName].triggerEvent(event);
@@ -49,7 +49,7 @@ import {
49
49
  import { Scenes } from "../definitions/ScenesCluster.js";
50
50
  import { AttributeServer, FabricScopedAttributeServer, FixedAttributeServer } from "./AttributeServer.js";
51
51
  import { CommandServer } from "./CommandServer.js";
52
- import { EventServer } from "./EventServer.js";
52
+ import { AnyEventServer } from "./EventServer.js";
53
53
 
54
54
  /** Cluster attributes accessible on the cluster server */
55
55
  type MandatoryAttributeServers<A extends Attributes> = Omit<
@@ -243,8 +243,8 @@ type ServerAttributeSubscribers<A extends Attributes> = {
243
243
  };
244
244
 
245
245
  export type EventServers<E extends Events> = Merge<
246
- { [P in MandatoryEventNames<E>]: EventServer<EventType<E[P]>, any> },
247
- { [P in OptionalEventNames<E>]?: EventServer<EventType<E[P]>, any> }
246
+ { [P in MandatoryEventNames<E>]: AnyEventServer<EventType<E[P]>, any> },
247
+ { [P in OptionalEventNames<E>]?: AnyEventServer<EventType<E[P]>, any> }
248
248
  >;
249
249
  type ServerEventTriggers<E extends Events> = {
250
250
  [P in MandatoryEventNames<E> as `trigger${Capitalize<string & P>}Event`]: (event: EventType<E[P]>) => void;
@@ -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 { AccessLevel, EventPriority } from "../Cluster.js";
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
- // TODO When not fabricscoped event later then only pass isFabricFiltered through for fabric filtered variant
121
- isFabricFiltered && (session as SecureSession<any>).fabric
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
- // TODO this can be added and used once we generate fabric scoped property in the Event definition
129
- export class FabricScopedEventServer<T, S extends Storage> extends EventServer<T, S> {
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 (typeof data !== "object" || data === null) {
132
- throw new ImplementationError("FabricScoped events need to have an object as data.");
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("FabricScoped events requires fabricIndex in data.");
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, isFabricFiltered }) => {
321
- if (session === undefined || !session.isSecure) return []; // ???
322
- const fabrics = isFabricFiltered ? [session.associatedFabric] : session.context.getFabrics();
323
- return fabrics.map(fabric => fabric.rootCert);
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 ({ request: { rootCaCertificate }, session }) => {
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
- !NodeId.isOperationalNodeId(caseAdminSubject) &&
220
- !NodeId.isCaseAuthenticatedTag(caseAdminSubject) &&
221
- CaseAuthenticatedTag.getVersion(NodeId.extractAsCaseAuthenticatedTag(caseAdminSubject)) === 0
222
- ) {
223
- throw new MatterFabricInvalidAdminSubjectError();
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);
@@ -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 CryptoError extends MatterError {}
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 { EventServer } from "../cluster/server/EventServer.js";
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
- return super.readAttribute(path, attribute, exchange, isFabricFiltered, message, endpoint);
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: EventServer<any, any>,
112
+ event: AnyEventServer<any, any>,
102
113
  exchange: MessageExchange<MatterDevice>,
103
114
  isFabricFiltered: boolean,
104
115
  message: Message,
@@ -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
  }
@@ -32,6 +32,7 @@ export class FabricManager {
32
32
  added: Observable<[fabric: Fabric]>(),
33
33
  updated: Observable<[fabric: Fabric]>(),
34
34
  deleted: Observable<[fabric: Fabric]>(),
35
+ failsafeClosed: Observable<[]>(),
35
36
  };
36
37
 
37
38
  constructor(fabricStorage: StorageContext) {
@@ -17,6 +17,10 @@ export class EventModel extends ValueModel implements EventElement {
17
17
  super(definition);
18
18
  }
19
19
 
20
+ get fabricSensitive(): boolean {
21
+ return this.effectiveAccess.fabricSensitive;
22
+ }
23
+
20
24
  static {
21
25
  Model.types[EventElement.Tag] = this;
22
26
  }
@@ -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 { EventServer } from "../../cluster/server/EventServer.js";
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: EventServer<any, any>,
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(attributePayload: AttributeReportPayload): TlvStream {
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({ attributeData: { path, data: schema.encodeTlv(payload), dataVersion } });
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({ attributeData: { schema, path: { ...path, listIndex: undefined }, payload: [], dataVersion } });
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;