@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
@@ -1 +1 @@
1
- {"version":3,"file":"AttributeServer.d.ts","sourceRoot":"","sources":["../../../../src/cluster/server/AttributeServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAsC,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG9F,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIhD,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAA2B,aAAa,EAAuB,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA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CAAC,EACzG,MAAM,CAAC,EAAE,CACL,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAC/B,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,OAAO,CAAC,EAAE,OAAO,KAChB,OAAO,EACZ,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,EAAE,iBAAiB,KAAK,IAAI;IA0GjG,IAAa,sBAAsB,YAElC;IAED;;;OAGG;IACH,6BAA6B,CAAC,KAAK,EAAE,CAAC,EAAE,gBAAgB,CAAC,EAAE,MAAM;IAiBjE;;;OAGG;IACM,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS;IAMlC;;OAEG;IACM,GAAG,CACR,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,EAC9B,OAAO,EAAE,OAAO,EAChB,iBAAiB,UAAQ,EACzB,mBAAmB,UAAQ;IAS/B;;;OAGG;cACgB,SAAS,CACxB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,EAC9B,OAAO,EAAE,OAAO,EAChB,iBAAiB,UAAQ,EACzB,mBAAmB,UAAQ;IAc/B;;OAEG;IACM,QAAQ,CAAC,MAAM,EAAE,CAAC;IAM3B;;;;;;OAMG;IACH,iBAAiB,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM;IAqB1C;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM;IAUpC;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;CAQvC"}
@@ -39,6 +39,7 @@ var import_StatusCode = require("../../protocol/interaction/StatusCode.js");
39
39
  var import_SecureSession = require("../../session/SecureSession.js");
40
40
  var import_DeepEqual = require("../../util/DeepEqual.js");
41
41
  var import_Promises = require("../../util/Promises.js");
42
+ var import_String = require("../../util/String.js");
42
43
  var import_Cluster = require("../Cluster.js");
43
44
  /**
44
45
  * @license
@@ -46,6 +47,8 @@ var import_Cluster = require("../Cluster.js");
46
47
  * SPDX-License-Identifier: Apache-2.0
47
48
  */
48
49
  const logger = import_Logger.Logger.get("AttributeServer");
50
+ const FabricIndexName = "fabricIndex";
51
+ const MatterModel = new import_model.MatterModel();
49
52
  class FabricScopeError extends import_MatterError.MatterError {
50
53
  }
51
54
  function createAttributeServer(clusterDef, attributeDef, attributeName, initValue, datasource, getter, setter, validator) {
@@ -146,6 +149,9 @@ class BaseAttributeServer {
146
149
  }
147
150
  #readAcl;
148
151
  #writeAcl;
152
+ get hasFabricSensitiveData() {
153
+ return false;
154
+ }
149
155
  validateWithSchema(value) {
150
156
  try {
151
157
  this.schema.validate(value);
@@ -569,8 +575,64 @@ class FabricScopedAttributeServer extends AttributeServer {
569
575
  validator
570
576
  );
571
577
  this.cluster = cluster;
578
+ this.fabricSensitiveElementsToRemove = new Array();
572
579
  this.isCustomGetter = isCustomGetter;
573
580
  this.isCustomSetter = isCustomSetter;
581
+ this.#determineSensitiveFieldsToRemove();
582
+ }
583
+ #determineSensitiveFieldsToRemove() {
584
+ const clusterFromModel = MatterModel.get(import_model.ClusterModel, this.cluster.id);
585
+ if (clusterFromModel === void 0) {
586
+ logger.debug(`${this.cluster.name}: Cluster for Fabric scoped element not found in Model, ignore`);
587
+ return;
588
+ }
589
+ const attributeFromModel = clusterFromModel.get(import_model.AttributeModel, this.id);
590
+ if (attributeFromModel === void 0) {
591
+ logger.debug(
592
+ `${this.cluster.name}.${this.id}: Attribute for Fabric scoped element not found in Model, ignore`
593
+ );
594
+ return;
595
+ }
596
+ if (!attributeFromModel.fabricScoped) {
597
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute is not Fabric scoped in model, ignore`);
598
+ return;
599
+ }
600
+ if (attributeFromModel.children.length !== 1) {
601
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute has not exactly one child, ignore`);
602
+ return;
603
+ }
604
+ const type = attributeFromModel.children[0].type;
605
+ if (type === void 0) {
606
+ logger.debug(`${this.cluster.name}.${this.id}: Attribute field has no type, ignore`);
607
+ return;
608
+ }
609
+ const dataType = clusterFromModel.get(import_model.DatatypeModel, type);
610
+ if (dataType === void 0) {
611
+ logger.debug(`${this.cluster.name}.${this.id}: DataType ${type} not found in model, ignore`);
612
+ return;
613
+ }
614
+ dataType.children.filter((field) => field.fabricSensitive).forEach((field) => this.fabricSensitiveElementsToRemove.push((0, import_String.camelize)(field.name)));
615
+ }
616
+ get hasFabricSensitiveData() {
617
+ return this.fabricSensitiveElementsToRemove.length > 0;
618
+ }
619
+ /**
620
+ * Sanitize the value of the attribute by removing fabric sensitive fields that do not belong to the
621
+ * associated fabric
622
+ */
623
+ sanitizeFabricSensitiveFields(value, associatedFabric) {
624
+ if (this.fabricSensitiveElementsToRemove.length && Array.isArray(value)) {
625
+ const associatedFabricIndex = associatedFabric?.fabricIndex ?? -1;
626
+ return value.map((data) => {
627
+ if (data[FabricIndexName] !== associatedFabricIndex) {
628
+ const result = { ...data };
629
+ this.fabricSensitiveElementsToRemove.forEach((fieldName) => delete result[fieldName]);
630
+ return result;
631
+ }
632
+ return data;
633
+ });
634
+ }
635
+ return value;
574
636
  }
575
637
  /**
576
638
  * Initialize the attribute with a value. Because the value is stored on fabric level this method only initializes
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cluster/server/AttributeServer.ts"],
4
- "sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { MatterDevice } from \"../../MatterDevice.js\";\nimport { Message } from \"../../codec/MessageCodec.js\";\nimport { ImplementationError, InternalError, MatterError } from \"../../common/MatterError.js\";\nimport { tryCatch } from \"../../common/TryCatchHandler.js\";\nimport { ValidationError } from \"../../common/ValidationError.js\";\nimport { AttributeId } from \"../../datatype/AttributeId.js\";\nimport { Endpoint as EndpointInterface } from \"../../device/Endpoint.js\";\nimport { Fabric } from \"../../fabric/Fabric.js\";\nimport { Logger } from \"../../log/Logger.js\";\nimport { Globals } from \"../../model/index.js\";\nimport { StatusCode, StatusResponseError } from \"../../protocol/interaction/StatusCode.js\";\nimport { BitSchema, TypeFromPartialBitSchema } from \"../../schema/BitmapSchema.js\";\nimport { NoAssociatedFabricError, SecureSession, assertSecureSession } from \"../../session/SecureSession.js\";\nimport { Session } from \"../../session/Session.js\";\nimport { TlvSchema } from \"../../tlv/TlvSchema.js\";\nimport { isDeepEqual } from \"../../util/DeepEqual.js\";\nimport { MaybePromise } from \"../../util/Promises.js\";\nimport { AccessLevel, Attribute, Attributes, Cluster, Commands, Events } from \"../Cluster.js\";\nimport { ClusterDatasource } from \"./ClusterServerTypes.js\";\n\nconst logger = Logger.get(\"AttributeServer\");\n\n/**\n * Thrown when an operation cannot complete because fabric information is\n * unavailable.\n */\nexport class FabricScopeError extends MatterError {}\n\nexport type AnyAttributeServer<T> = AttributeServer<T> | FabricScopedAttributeServer<T> | FixedAttributeServer<T>;\n\ntype DelayedChangeData = {\n oldValue: any;\n newValue: any;\n changed: boolean;\n};\n\n/**\n * Factory function to create an attribute server.\n */\nexport function createAttributeServer<\n T,\n F extends BitSchema,\n SF extends TypeFromPartialBitSchema<F>,\n A extends Attributes,\n C extends Commands,\n E extends Events,\n>(\n clusterDef: Cluster<F, SF, A, C, E>,\n attributeDef: Attribute<T, F>,\n attributeName: string,\n initValue: T,\n datasource: ClusterDatasource,\n getter?: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T,\n setter?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface, message?: Message) => boolean,\n validator?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void,\n) {\n const {\n id,\n schema,\n writable,\n fabricScoped,\n fixed,\n omitChanges,\n timed,\n default: defaultValue,\n readAcl,\n writeAcl,\n } = attributeDef;\n\n if (fixed) {\n return new FixedAttributeServer(\n id,\n attributeName,\n readAcl,\n writeAcl,\n schema,\n writable,\n false,\n timed,\n initValue,\n defaultValue,\n datasource,\n getter,\n );\n }\n\n if (fabricScoped) {\n return new FabricScopedAttributeServer(\n id,\n attributeName,\n readAcl,\n writeAcl,\n schema,\n writable,\n !omitChanges,\n timed,\n initValue,\n defaultValue,\n clusterDef,\n datasource,\n getter,\n setter,\n validator,\n );\n }\n\n return new AttributeServer(\n id,\n attributeName,\n readAcl,\n writeAcl,\n schema,\n writable,\n !omitChanges,\n timed,\n initValue,\n defaultValue,\n datasource,\n getter,\n setter,\n validator,\n );\n}\n\n/**\n * Base class for all attribute servers.\n */\nexport abstract class BaseAttributeServer<T> {\n /**\n * The value is undefined when getter/setter are used. But we still handle the version number here.\n */\n protected value: T | undefined = undefined;\n protected endpoint?: EndpointInterface;\n readonly defaultValue: T;\n #readAcl: AccessLevel | undefined;\n #writeAcl: AccessLevel | undefined;\n\n constructor(\n readonly id: AttributeId,\n readonly name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n readonly schema: TlvSchema<T>,\n readonly isWritable: boolean,\n readonly isSubscribable: boolean,\n readonly requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n ) {\n this.#readAcl = readAcl;\n this.#writeAcl = writeAcl;\n try {\n this.validateWithSchema(initValue);\n this.value = initValue;\n } catch (error) {\n logger.warn(\n `Attribute value to initialize for ${name} has an invalid value ${Logger.toJSON(\n initValue,\n )}. Restore to default ${Logger.toJSON(defaultValue)}`,\n );\n if (defaultValue === undefined) {\n throw new ImplementationError(`Attribute value to initialize for ${name} can not be undefined.`);\n }\n this.validateWithSchema(defaultValue);\n this.value = defaultValue;\n }\n this.defaultValue = this.value;\n }\n\n validateWithSchema(value: T) {\n try {\n this.schema.validate(value);\n } catch (error) {\n if (error instanceof ValidationError) {\n error.message = `Validation error for attribute \"${this.name}\"${error.fieldName !== undefined ? ` in field ${error.fieldName}` : \"\"}: ${error.message}`;\n }\n throw error;\n }\n }\n\n assignToEndpoint(endpoint: EndpointInterface) {\n this.endpoint = endpoint;\n }\n\n /**\n * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be\n * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!\n */\n abstract init(value: T | undefined): void;\n\n get writeAcl() {\n return this.#writeAcl ?? AccessLevel.Operate; // ???\n }\n\n get readAcl() {\n return this.#readAcl ?? AccessLevel.View; // ???\n }\n}\n\n/**\n * Attribute server class that handled fixed attribute values that never change and is the base class for other\n * Attribute server types.\n */\nexport class FixedAttributeServer<T> extends BaseAttributeServer<T> {\n readonly isFixed: boolean = true;\n protected readonly getter: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T;\n\n constructor(\n id: AttributeId,\n name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n schema: TlvSchema<T>,\n isWritable: boolean,\n isSubscribable: boolean,\n requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n protected readonly datasource: ClusterDatasource,\n\n /**\n * Optional getter function to handle special requirements or the data are stored in different places.\n *\n * @param session the session that is requesting the value (if any)\n * @param endpoint the endpoint the cluster server of this attribute is assigned to\n * @param isFabricFiltered whether the read request is fabric scoped or not\n * @param message the wire message that initiated the request (if any)\n */\n getter?: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T,\n ) {\n super(\n id,\n name,\n readAcl,\n writeAcl,\n schema,\n isWritable,\n isSubscribable,\n requiresTimedInteraction,\n initValue,\n defaultValue,\n ); // Fixed attributes do not change, so are not subscribable\n\n if (getter === undefined) {\n this.getter = () => {\n if (this.value === undefined) {\n // Should not happen\n throw new InternalError(`Attribute value for attribute \"${name}\" is not initialized.`);\n }\n return this.value;\n };\n } else {\n this.getter = getter;\n }\n }\n\n /**\n * Get the value of the attribute. This method is used by the Interaction model to read the value of the attribute\n * and includes the ACL check. It should not be used locally in the code!\n *\n * If a getter is defined the value is determined by that getter method.\n */\n get(session: Session<MatterDevice>, isFabricFiltered: boolean, message?: Message): T {\n // TODO: check ACL\n\n return this.getter(session, this.endpoint, isFabricFiltered, message);\n }\n\n /**\n * Get the value of the attribute including the version number. This method is used by the Interaction model to read\n * the value of the attribute and includes the ACL check. It should not be used locally in the code!\n *\n * If a getter is defined the value is determined by that getter method. The version number is always 0 for fixed\n * attributes.\n */\n getWithVersion(session: Session<MatterDevice>, isFabricFiltered: boolean, message?: Message) {\n return { version: this.datasource.version, value: this.get(session, isFabricFiltered, message) };\n }\n\n /**\n * Get the value of the attribute locally. This method should be used locally in the code and does not include the\n * ACL check.\n * If a getter is defined the value is determined by that getter method.\n */\n getLocal(): T {\n return this.getter(undefined, this.endpoint);\n }\n\n /**\n * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be\n * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!\n * If a getter or setter is defined the value must be undefined The version number must also be undefined.\n */\n init(value: T | undefined) {\n if (value === undefined) {\n throw new InternalError(`Can not initialize fixed attribute \"${this.name}\" with undefined value.`);\n }\n this.validateWithSchema(value);\n this.value = value;\n }\n\n /**\n * Add an internal listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the version number.\n */\n addValueChangeListener(_listener: (value: T, version: number) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Remove an internal listener.\n */\n removeValueChangeListener(_listener: (value: T, version: number) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value.\n */\n addValueSetListener(_listener: (newValue: T, oldValue: T) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value. This method is a convenient alias for addValueSetListener.\n */\n subscribe(_listener: (newValue: T, oldValue: T) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Remove an external listener.\n */\n removeValueSetListener(_listener: (newValue: T, oldValue: T) => void) {\n /** Fixed attributes do not change. */\n }\n}\n\n/**\n * Attribute server for normal attributes that can be read and written.\n */\nexport class AttributeServer<T> extends FixedAttributeServer<T> {\n override readonly isFixed = false;\n protected readonly valueChangeListeners = new Array<(value: T, version: number) => void>();\n protected readonly valueSetListeners = new Array<(newValue: T, oldValue: T) => void>();\n protected readonly setter: (\n value: T,\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n message?: Message,\n ) => boolean;\n protected readonly validator: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void;\n protected delayedChangeData?: DelayedChangeData = undefined;\n\n constructor(\n id: AttributeId,\n name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n schema: TlvSchema<T>,\n isWritable: boolean,\n isSubscribable: boolean,\n requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n datasource: ClusterDatasource,\n getter?: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T,\n\n /**\n * Optional setter function to handle special requirements or the data are stored in different places. If a\n * setter method is used for a writable attribute, the getter method must be implemented as well. The method\n * needs to return if the stored value has changed or not.\n *\n * @param value the value to be set.\n * @param session the session that is requesting the value (if any).\n * @param endpoint the endpoint the cluster server of this attribute is assigned to.\n * @returns true if the value has changed, false otherwise.\n */\n setter?: (\n value: T,\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n message?: Message,\n ) => boolean,\n\n /**\n * Optional Validator function to handle special requirements for verification of stored data. The method should\n * throw an error if the value is not valid. If a StatusResponseError is thrown this one is also returned to the\n * client.\n *\n * If a setter is used then no validator should be used as the setter should handle the validation itself!\n *\n * @param value the value to be set.\n * @param session the session that is requesting the value (if any).\n * @param endpoint the endpoint the cluster server of this attribute is assigned to.\n */\n validator?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void,\n ) {\n if (\n isWritable &&\n (getter === undefined || setter === undefined) &&\n !(getter === undefined && setter === undefined)\n ) {\n throw new ImplementationError(\n `Getter and setter must be implemented together for writeable attribute \"${name}\".`,\n );\n }\n\n super(\n id,\n name,\n readAcl,\n writeAcl,\n schema,\n isWritable,\n isSubscribable,\n requiresTimedInteraction,\n initValue,\n defaultValue,\n datasource,\n getter,\n );\n\n if (setter === undefined) {\n this.setter = value => {\n const oldValue = this.value;\n this.value = value;\n return !isDeepEqual(value, oldValue);\n };\n } else {\n this.setter = setter;\n }\n\n this.validator = (value, session, endpoint) => {\n this.validateWithSchema(value);\n if (validator !== undefined) {\n validator(value, session, endpoint);\n }\n };\n }\n\n /**\n * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be\n * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!\n */\n override init(value: T | undefined) {\n if (value === undefined) {\n value = this.getter(undefined, this.endpoint);\n }\n if (value === undefined) {\n throw new InternalError(`Can not initialize attribute \"${this.name}\" with undefined value.`);\n }\n this.validator(value, undefined, this.endpoint);\n this.value = value;\n }\n\n /**\n * Set the value of the attribute. This method is used by the Interaction model to write the value of the attribute\n * and includes the ACL check. It should not be used locally in the code!\n *\n * If a setter is defined this setter method is called to store the value.\n *\n * Listeners are called when the value changes (internal listeners) or in any case (external listeners).\n */\n set(value: T, session: Session<MatterDevice>, message?: Message, delayChangeEvents = false) {\n if (!this.isWritable) {\n throw new StatusResponseError(`Attribute \"${this.name}\" is not writable.`, StatusCode.UnsupportedWrite);\n }\n\n this.setRemote(value, session, message, delayChangeEvents);\n }\n\n /**\n * Method that contains the logic to set a value \"from remote\" (e.g. from a client).\n */\n protected setRemote(value: T, session: Session<MatterDevice>, message?: Message, delayChangeEvents = false) {\n this.processSet(value, session, message, delayChangeEvents);\n this.value = value;\n }\n\n /**\n * Set the value of the attribute locally. This method should be used locally in the code and does not include the\n * ACL check.\n *\n * If a setter is defined this setter method is called to validate and store the value.\n *\n * Else if a validator is defined the value is validated before it is stored.\n *\n * Listeners are called when the value changes (internal listeners) or in any case (external listeners).\n */\n setLocal(value: T) {\n this.processSet(value, undefined);\n this.value = value;\n }\n\n /**\n * Helper Method to process the set of a value in a generic way. This method is used internally.\n */\n protected processSet(value: T, session?: Session<MatterDevice>, message?: Message, delayChangeEvents = false) {\n this.validator(value, session, this.endpoint);\n const oldValue = this.getter(session, this.endpoint, undefined, message);\n const valueChanged = this.setter(value, session, this.endpoint, message);\n if (delayChangeEvents) {\n this.delayedChangeData = {\n oldValue: this.delayedChangeData?.oldValue ?? oldValue, // We keep the oldest value\n newValue: value,\n changed: !!this.delayedChangeData?.changed || valueChanged, // We combine the changed flag\n };\n logger.info(`Delay change for attribute \"${this.name}\" with value ${Logger.toJSON(value)}`);\n } else {\n this.handleVersionAndTriggerListeners(value, oldValue, valueChanged);\n }\n }\n\n triggerDelayedChangeEvents() {\n if (this.delayedChangeData !== undefined) {\n const { oldValue, newValue, changed } = this.delayedChangeData;\n this.delayedChangeData = undefined;\n logger.info(`Trigger delayed change for attribute \"${this.name}\" with value ${Logger.toJSON(newValue)}`);\n this.handleVersionAndTriggerListeners(newValue, oldValue, changed);\n }\n }\n\n /**\n * Helper Method to handle needed version increases and trigger the relevant listeners. This method is used\n * internally.\n */\n protected handleVersionAndTriggerListeners(value: T, oldValue: T | undefined, considerVersionChanged: boolean) {\n if (considerVersionChanged) {\n const version = this.datasource.increaseVersion();\n this.valueChangeListeners.forEach(listener => listener(value, version));\n }\n if (oldValue !== undefined) {\n this.valueSetListeners.forEach(listener => listener(value, oldValue));\n }\n }\n\n /**\n * When the value is handled by getter or setter methods and is changed by other processes this method can be used\n * to notify the attribute server that the value has changed. This will increase the version number and trigger the\n * listeners.\n *\n * ACL checks needs to be performed before calling this method.\n */\n updated(session: SecureSession<MatterDevice>) {\n const oldValue = this.value ?? this.defaultValue;\n this.value = tryCatch(\n () => this.get(session, false),\n NoAssociatedFabricError, // Handle potential error cases where the session does not have a fabric assigned.\n this.value ?? this.defaultValue,\n );\n this.handleVersionAndTriggerListeners(this.value, oldValue, true);\n }\n\n /**\n * When the value is handled by getter or setter methods and is changed by other processes and no session from the\n * originating process is known this method can be used to notify the attribute server that the value has changed.\n * This will increase the version number and trigger the listeners.\n *\n * ACL checks needs to be performed before calling this method.\n */\n updatedLocal() {\n const oldValue = this.value ?? this.defaultValue;\n this.value = this.getLocal();\n this.handleVersionAndTriggerListeners(this.value, oldValue, true);\n }\n\n /**\n * Add an internal listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the version number.\n */\n override addValueChangeListener(listener: (value: T, version: number) => void) {\n this.valueChangeListeners.push(listener);\n }\n\n /**\n * Remove an internal listener.\n */\n override removeValueChangeListener(listener: (value: T, version: number) => void) {\n const entryIndex = this.valueChangeListeners.indexOf(listener);\n if (entryIndex !== -1) {\n this.valueChangeListeners.splice(entryIndex, 1);\n }\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value.\n */\n override addValueSetListener(listener: (newValue: T, oldValue: T) => void) {\n this.valueSetListeners.push(listener);\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value. This method is a convenient alias for addValueSetListener.\n */\n override subscribe(listener: (newValue: T, oldValue: T) => void) {\n this.addValueSetListener(listener);\n }\n\n /**\n * Remove an external listener.\n */\n override removeValueSetListener(listener: (newValue: T, oldValue: T) => void) {\n const entryIndex = this.valueSetListeners.indexOf(listener);\n if (entryIndex !== -1) {\n this.valueSetListeners.splice(entryIndex, 1);\n }\n }\n}\n\nexport function genericFabricScopedAttributeGetterFromFabric<T>(\n fabric: Fabric,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n defaultValue: T,\n) {\n const data = fabric.getScopedClusterDataValue<{ value: T }>(cluster, attributeName);\n return data?.value ?? defaultValue;\n}\n\nexport function genericFabricScopedAttributeGetter<T>(\n session: Session<MatterDevice> | undefined,\n isFabricFiltered: boolean,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n defaultValue: T,\n) {\n if (session === undefined) {\n throw new FabricScopeError(`Session is required for fabric scoped attribute ${attributeName}`);\n }\n\n if (isFabricFiltered) {\n assertSecureSession(session);\n return genericFabricScopedAttributeGetterFromFabric(\n session.associatedFabric,\n cluster,\n attributeName,\n defaultValue,\n );\n } else {\n const fabrics = session.context.getFabrics();\n const values = new Array<any>();\n for (const fabric of fabrics) {\n const value = genericFabricScopedAttributeGetterFromFabric(fabric, cluster, attributeName, defaultValue);\n if (!Array.isArray(value)) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${attributeName}\" can only be read for all fabrics if they are arrays.`,\n );\n }\n values.push(...value);\n }\n return values as T;\n }\n}\n\nexport function genericFabricScopedAttributeSetterForFabric<T>(\n fabric: Fabric,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n value: T,\n defaultValue?: T,\n) {\n const oldValue = genericFabricScopedAttributeGetterFromFabric(fabric, cluster, attributeName, defaultValue);\n if (!isDeepEqual(value, oldValue)) {\n const setResult = fabric.setScopedClusterDataValue(cluster, attributeName, { value });\n if (MaybePromise.is(setResult)) {\n throw new ImplementationError(\n \"Seems like an Asynchronous Storage is used with Legacy code paths which is forbidden!\",\n );\n }\n return true;\n }\n return false;\n}\n\nexport function genericFabricScopedAttributeSetter<T>(\n value: T,\n session: Session<MatterDevice> | undefined,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n defaultValue?: T,\n) {\n if (session === undefined) {\n throw new FabricScopeError(`Session is required for fabric scoped attribute \"${attributeName}\".`);\n }\n\n assertSecureSession(session);\n const fabric = session.associatedFabric;\n\n return genericFabricScopedAttributeSetterForFabric(fabric, cluster, attributeName, value, defaultValue);\n}\n\n/**\n * Attribute server which is getting and setting the value for a defined fabric. The values are automatically persisted\n * on fabric level if no custom getter or setter is defined.\n */\nexport class FabricScopedAttributeServer<T> extends AttributeServer<T> {\n private readonly isCustomGetter: boolean;\n private readonly isCustomSetter: boolean;\n\n constructor(\n id: AttributeId,\n name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n schema: TlvSchema<T>,\n isWritable: boolean,\n isSubscribable: boolean,\n requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n readonly cluster: Cluster<any, any, any, any, any>,\n datasource: ClusterDatasource,\n getter?: (session?: Session<MatterDevice>, endpoint?: EndpointInterface, isFabricFiltered?: boolean) => T,\n setter?: (\n value: T,\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n message?: Message,\n ) => boolean,\n validator?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void,\n ) {\n if (\n isWritable &&\n (getter === undefined || setter === undefined) &&\n !(getter === undefined && setter === undefined)\n ) {\n throw new ImplementationError(\n `Getter and setter must be implemented together for writeable fabric scoped attribute \"${name}\".`,\n );\n }\n\n let isCustomGetter = false;\n if (getter === undefined) {\n getter = (session, _endpoint, isFabricFiltered) => {\n if (session === undefined)\n throw new FabricScopeError(`Session is required for fabric scoped attribute ${name}`);\n\n if (isFabricFiltered === true) {\n assertSecureSession(session);\n return this.getLocalForFabric(session.associatedFabric);\n } else {\n const fabrics = session.context.getFabrics();\n const values = new Array<any>();\n for (const fabric of fabrics) {\n const value = this.getLocalForFabric(fabric);\n if (!Array.isArray(value)) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${name}\" can only be read for all fabrics if they are arrays.`,\n );\n }\n values.push(...value);\n }\n return values as T;\n }\n };\n } else {\n isCustomGetter = true;\n }\n\n let isCustomSetter = false;\n if (setter === undefined) {\n setter = (value, session) =>\n genericFabricScopedAttributeSetter(value, session, this.cluster, this.name, this.defaultValue);\n } else {\n isCustomSetter = true;\n }\n\n super(\n id,\n name,\n readAcl,\n writeAcl,\n schema,\n isWritable,\n isSubscribable,\n requiresTimedInteraction,\n initValue,\n defaultValue,\n datasource,\n getter,\n setter,\n validator,\n );\n this.isCustomGetter = isCustomGetter;\n this.isCustomSetter = isCustomSetter;\n }\n\n /**\n * Initialize the attribute with a value. Because the value is stored on fabric level this method only initializes\n * the version number.\n */\n override init(value: T | undefined) {\n if (value !== undefined) {\n throw new InternalError(`Can not initialize fabric scoped attribute \"${this.name}\" with a value.`);\n }\n }\n\n /**\n * Fabric scoped enhancement of set to allow setting special fabricindex locally.\n */\n override set(\n value: T,\n session: Session<MatterDevice>,\n message: Message,\n delayChangeEvents = false,\n preserveFabricIndex = false,\n ) {\n if (!this.isWritable) {\n throw new StatusResponseError(`Attribute \"${this.name}\" is not writable.`, StatusCode.UnsupportedWrite);\n }\n\n this.setRemote(value, session, message, delayChangeEvents, preserveFabricIndex);\n }\n\n /**\n * Method that contains the logic to set a value \"from remote\" (e.g. from a client). For Fabric scoped attributes\n * we need to inject the fabric index into the value.\n */\n protected override setRemote(\n value: T,\n session: Session<MatterDevice>,\n message: Message,\n delayChangeEvents = false,\n preserveFabricIndex = false,\n ) {\n // Inject fabric index into structures in general if undefined, if set it will be used\n value = this.schema.injectField(\n value,\n <number>Globals.FabricIndex.id,\n session.associatedFabric.fabricIndex,\n () => !preserveFabricIndex, // Noone should send any index and if we simply SHALL ignore it, biuut internally we might need it\n );\n logger.info(`Set remote value for fabric scoped attribute \"${this.name}\" to ${Logger.toJSON(value)}`);\n\n super.setRemote(value, session, message, delayChangeEvents);\n }\n\n /**\n * Set Local is not allowed for fabric scoped attributes. Use setLocalForFabric instead.\n */\n override setLocal(_value: T) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${this.name}\" can only be set locally by providing a Fabric. Use setLocalForFabric instead.`,\n );\n }\n\n /**\n * Set the value of the attribute locally for a fabric. This method should be used locally in the code and does not\n * include the ACL check.\n * If a setter is defined this method can not be used!\n * If a validator is defined the value is validated before it is stored.\n * Listeners are called when the value changes (internal listeners) or in any case (external listeners).\n */\n setLocalForFabric(value: T, fabric: Fabric) {\n if (this.isCustomSetter) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${this.name}\" can not be set locally when a custom setter is defined.`,\n );\n }\n this.validator(value, undefined, this.endpoint);\n\n const oldValue = this.getLocalForFabric(fabric);\n const valueChanged = !isDeepEqual(value, oldValue);\n if (valueChanged) {\n const setResult = fabric.setScopedClusterDataValue(this.cluster, this.name, { value });\n if (MaybePromise.is(setResult)) {\n throw new ImplementationError(\n \"Seems like an Asynchronous Storage is used with Legacy code paths which is forbidden!\",\n );\n }\n }\n this.handleVersionAndTriggerListeners(value, oldValue, valueChanged); // TODO Make callbacks sense without fabric, but then they would have other signature?\n }\n\n /**\n * When the value is handled by getter or setter methods and is changed by other processes and no session from the\n * originating process is known this method can be used to notify the attribute server that the value has changed.\n * This will increase the version number and trigger the listeners.\n * ACL checks needs to be performed before calling this method.\n */\n updatedLocalForFabric(fabric: Fabric) {\n const oldValue = this.value ?? this.defaultValue;\n this.value = tryCatch(\n () => this.getLocalForFabric(fabric),\n FabricScopeError, // Handle potential error cases where a custom getter is used.\n this.value ?? this.defaultValue,\n );\n this.handleVersionAndTriggerListeners(this.value, oldValue, true);\n }\n\n /**\n * Get the value of the attribute locally for a special Fabric. This method should be used locally in the code and\n * does not include the ACL check.\n * If a getter is defined this method returns an error and the value should be retrieved directly internally.\n */\n getLocalForFabric(fabric: Fabric): T {\n if (this.isCustomGetter) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${this.name}\" can not be read locally when a custom getter is defined.`,\n );\n }\n return genericFabricScopedAttributeGetterFromFabric(fabric, this.cluster, this.name, this.defaultValue);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,yBAAgE;AAChE,6BAAyB;AACzB,6BAAgC;AAIhC,oBAAuB;AACvB,mBAAwB;AACxB,wBAAgD;AAEhD,2BAA4E;AAG5E,uBAA4B;AAC5B,sBAA6B;AAC7B,qBAA8E;AAvB9E;AAAA;AAAA;AAAA;AAAA;AA0BA,MAAM,SAAS,qBAAO,I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AAM,eAAe,KAAC,8BAAY,OAAO,QAAQ;AACjD,QAAI,cAAc;AACd,YAAM,YAAY,OAAO,0BAA0B,KAAK,SAAS,KAAK,MAAM,EAAE,MAAM,CAAC;AACrF,UAAI,6BAAa,GAAG,SAAS,GAAG;AAC5B,cAAM,IAAI;AAAA,UACN;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AACA,SAAK,iCAAiC,OAAO,UAAU,YAAY;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,sBAAsB,QAAgB;AAClC,UAAM,WAAW,KAAK,SAAS,KAAK;AACpC,SAAK,YAAQ;AAAA,MACT,MAAM,KAAK,kBAAkB,MAAM;AAAA,MACnC;AAAA;AAAA,MACA,KAAK,SAAS,KAAK;AAAA,IACvB;AACA,SAAK,iCAAiC,KAAK,OAAO,UAAU,IAAI;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkB,QAAmB;AACjC,QAAI,KAAK,gBAAgB;AACrB,YAAM,IAAI;AAAA,QACN,4BAA4B,KAAK,IAAI;AAAA,MACzC;AAAA,IACJ;AACA,WAAO,6CAA6C,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,YAAY;AAAA,EAC1G;AACJ;",
6
- "names": []
4
+ "sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { MatterDevice } from \"../../MatterDevice.js\";\nimport { Message } from \"../../codec/MessageCodec.js\";\nimport { ImplementationError, InternalError, MatterError } from \"../../common/MatterError.js\";\nimport { tryCatch } from \"../../common/TryCatchHandler.js\";\nimport { ValidationError } from \"../../common/ValidationError.js\";\nimport { AttributeId } from \"../../datatype/AttributeId.js\";\nimport { Endpoint as EndpointInterface } from \"../../device/Endpoint.js\";\nimport { Fabric } from \"../../fabric/Fabric.js\";\nimport { Logger } from \"../../log/Logger.js\";\nimport {\n AttributeModel,\n ClusterModel,\n DatatypeModel,\n Globals,\n MatterModel as MatterModelObj,\n} from \"../../model/index.js\";\nimport { StatusCode, StatusResponseError } from \"../../protocol/interaction/StatusCode.js\";\nimport { BitSchema, TypeFromPartialBitSchema } from \"../../schema/BitmapSchema.js\";\nimport { NoAssociatedFabricError, SecureSession, assertSecureSession } from \"../../session/SecureSession.js\";\nimport { Session } from \"../../session/Session.js\";\nimport { TlvSchema } from \"../../tlv/TlvSchema.js\";\nimport { isDeepEqual } from \"../../util/DeepEqual.js\";\nimport { MaybePromise } from \"../../util/Promises.js\";\nimport { camelize } from \"../../util/String.js\";\nimport { AccessLevel, Attribute, Attributes, Cluster, Commands, Events } from \"../Cluster.js\";\nimport { ClusterDatasource } from \"./ClusterServerTypes.js\";\n\nconst logger = Logger.get(\"AttributeServer\");\n\nconst FabricIndexName = \"fabricIndex\";\nconst MatterModel = new MatterModelObj();\n\n/**\n * Thrown when an operation cannot complete because fabric information is\n * unavailable.\n */\nexport class FabricScopeError extends MatterError {}\n\nexport type AnyAttributeServer<T> = AttributeServer<T> | FabricScopedAttributeServer<T> | FixedAttributeServer<T>;\n\ntype DelayedChangeData = {\n oldValue: any;\n newValue: any;\n changed: boolean;\n};\n\n/**\n * Factory function to create an attribute server.\n */\nexport function createAttributeServer<\n T,\n F extends BitSchema,\n SF extends TypeFromPartialBitSchema<F>,\n A extends Attributes,\n C extends Commands,\n E extends Events,\n>(\n clusterDef: Cluster<F, SF, A, C, E>,\n attributeDef: Attribute<T, F>,\n attributeName: string,\n initValue: T,\n datasource: ClusterDatasource,\n getter?: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T,\n setter?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface, message?: Message) => boolean,\n validator?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void,\n) {\n const {\n id,\n schema,\n writable,\n fabricScoped,\n fixed,\n omitChanges,\n timed,\n default: defaultValue,\n readAcl,\n writeAcl,\n } = attributeDef;\n\n if (fixed) {\n return new FixedAttributeServer(\n id,\n attributeName,\n readAcl,\n writeAcl,\n schema,\n writable,\n false,\n timed,\n initValue,\n defaultValue,\n datasource,\n getter,\n );\n }\n\n if (fabricScoped) {\n return new FabricScopedAttributeServer(\n id,\n attributeName,\n readAcl,\n writeAcl,\n schema,\n writable,\n !omitChanges,\n timed,\n initValue,\n defaultValue,\n clusterDef,\n datasource,\n getter,\n setter,\n validator,\n );\n }\n\n return new AttributeServer(\n id,\n attributeName,\n readAcl,\n writeAcl,\n schema,\n writable,\n !omitChanges,\n timed,\n initValue,\n defaultValue,\n datasource,\n getter,\n setter,\n validator,\n );\n}\n\n/**\n * Base class for all attribute servers.\n */\nexport abstract class BaseAttributeServer<T> {\n /**\n * The value is undefined when getter/setter are used. But we still handle the version number here.\n */\n protected value: T | undefined = undefined;\n protected endpoint?: EndpointInterface;\n readonly defaultValue: T;\n #readAcl: AccessLevel | undefined;\n #writeAcl: AccessLevel | undefined;\n\n constructor(\n readonly id: AttributeId,\n readonly name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n readonly schema: TlvSchema<T>,\n readonly isWritable: boolean,\n readonly isSubscribable: boolean,\n readonly requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n ) {\n this.#readAcl = readAcl;\n this.#writeAcl = writeAcl;\n try {\n this.validateWithSchema(initValue);\n this.value = initValue;\n } catch (error) {\n logger.warn(\n `Attribute value to initialize for ${name} has an invalid value ${Logger.toJSON(\n initValue,\n )}. Restore to default ${Logger.toJSON(defaultValue)}`,\n );\n if (defaultValue === undefined) {\n throw new ImplementationError(`Attribute value to initialize for ${name} can not be undefined.`);\n }\n this.validateWithSchema(defaultValue);\n this.value = defaultValue;\n }\n this.defaultValue = this.value;\n }\n\n get hasFabricSensitiveData() {\n return false;\n }\n\n validateWithSchema(value: T) {\n try {\n this.schema.validate(value);\n } catch (error) {\n if (error instanceof ValidationError) {\n error.message = `Validation error for attribute \"${this.name}\"${error.fieldName !== undefined ? ` in field ${error.fieldName}` : \"\"}: ${error.message}`;\n }\n throw error;\n }\n }\n\n assignToEndpoint(endpoint: EndpointInterface) {\n this.endpoint = endpoint;\n }\n\n /**\n * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be\n * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!\n */\n abstract init(value: T | undefined): void;\n\n get writeAcl() {\n return this.#writeAcl ?? AccessLevel.Operate; // ???\n }\n\n get readAcl() {\n return this.#readAcl ?? AccessLevel.View; // ???\n }\n}\n\n/**\n * Attribute server class that handled fixed attribute values that never change and is the base class for other\n * Attribute server types.\n */\nexport class FixedAttributeServer<T> extends BaseAttributeServer<T> {\n readonly isFixed: boolean = true;\n protected readonly getter: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T;\n\n constructor(\n id: AttributeId,\n name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n schema: TlvSchema<T>,\n isWritable: boolean,\n isSubscribable: boolean,\n requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n protected readonly datasource: ClusterDatasource,\n\n /**\n * Optional getter function to handle special requirements or the data are stored in different places.\n *\n * @param session the session that is requesting the value (if any)\n * @param endpoint the endpoint the cluster server of this attribute is assigned to\n * @param isFabricFiltered whether the read request is fabric scoped or not\n * @param message the wire message that initiated the request (if any)\n */\n getter?: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T,\n ) {\n super(\n id,\n name,\n readAcl,\n writeAcl,\n schema,\n isWritable,\n isSubscribable,\n requiresTimedInteraction,\n initValue,\n defaultValue,\n ); // Fixed attributes do not change, so are not subscribable\n\n if (getter === undefined) {\n this.getter = () => {\n if (this.value === undefined) {\n // Should not happen\n throw new InternalError(`Attribute value for attribute \"${name}\" is not initialized.`);\n }\n return this.value;\n };\n } else {\n this.getter = getter;\n }\n }\n\n /**\n * Get the value of the attribute. This method is used by the Interaction model to read the value of the attribute\n * and includes the ACL check. It should not be used locally in the code!\n *\n * If a getter is defined the value is determined by that getter method.\n */\n get(session: Session<MatterDevice>, isFabricFiltered: boolean, message?: Message): T {\n // TODO: check ACL\n\n return this.getter(session, this.endpoint, isFabricFiltered, message);\n }\n\n /**\n * Get the value of the attribute including the version number. This method is used by the Interaction model to read\n * the value of the attribute and includes the ACL check. It should not be used locally in the code!\n *\n * If a getter is defined the value is determined by that getter method. The version number is always 0 for fixed\n * attributes.\n */\n getWithVersion(session: Session<MatterDevice>, isFabricFiltered: boolean, message?: Message) {\n return { version: this.datasource.version, value: this.get(session, isFabricFiltered, message) };\n }\n\n /**\n * Get the value of the attribute locally. This method should be used locally in the code and does not include the\n * ACL check.\n * If a getter is defined the value is determined by that getter method.\n */\n getLocal(): T {\n return this.getter(undefined, this.endpoint);\n }\n\n /**\n * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be\n * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!\n * If a getter or setter is defined the value must be undefined The version number must also be undefined.\n */\n init(value: T | undefined) {\n if (value === undefined) {\n throw new InternalError(`Can not initialize fixed attribute \"${this.name}\" with undefined value.`);\n }\n this.validateWithSchema(value);\n this.value = value;\n }\n\n /**\n * Add an internal listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the version number.\n */\n addValueChangeListener(_listener: (value: T, version: number) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Remove an internal listener.\n */\n removeValueChangeListener(_listener: (value: T, version: number) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value.\n */\n addValueSetListener(_listener: (newValue: T, oldValue: T) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value. This method is a convenient alias for addValueSetListener.\n */\n subscribe(_listener: (newValue: T, oldValue: T) => void) {\n /** Fixed attributes do not change. */\n }\n\n /**\n * Remove an external listener.\n */\n removeValueSetListener(_listener: (newValue: T, oldValue: T) => void) {\n /** Fixed attributes do not change. */\n }\n}\n\n/**\n * Attribute server for normal attributes that can be read and written.\n */\nexport class AttributeServer<T> extends FixedAttributeServer<T> {\n override readonly isFixed = false;\n protected readonly valueChangeListeners = new Array<(value: T, version: number) => void>();\n protected readonly valueSetListeners = new Array<(newValue: T, oldValue: T) => void>();\n protected readonly setter: (\n value: T,\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n message?: Message,\n ) => boolean;\n protected readonly validator: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void;\n protected delayedChangeData?: DelayedChangeData = undefined;\n\n constructor(\n id: AttributeId,\n name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n schema: TlvSchema<T>,\n isWritable: boolean,\n isSubscribable: boolean,\n requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n datasource: ClusterDatasource,\n getter?: (\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n isFabricFiltered?: boolean,\n message?: Message,\n ) => T,\n\n /**\n * Optional setter function to handle special requirements or the data are stored in different places. If a\n * setter method is used for a writable attribute, the getter method must be implemented as well. The method\n * needs to return if the stored value has changed or not.\n *\n * @param value the value to be set.\n * @param session the session that is requesting the value (if any).\n * @param endpoint the endpoint the cluster server of this attribute is assigned to.\n * @returns true if the value has changed, false otherwise.\n */\n setter?: (\n value: T,\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n message?: Message,\n ) => boolean,\n\n /**\n * Optional Validator function to handle special requirements for verification of stored data. The method should\n * throw an error if the value is not valid. If a StatusResponseError is thrown this one is also returned to the\n * client.\n *\n * If a setter is used then no validator should be used as the setter should handle the validation itself!\n *\n * @param value the value to be set.\n * @param session the session that is requesting the value (if any).\n * @param endpoint the endpoint the cluster server of this attribute is assigned to.\n */\n validator?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void,\n ) {\n if (\n isWritable &&\n (getter === undefined || setter === undefined) &&\n !(getter === undefined && setter === undefined)\n ) {\n throw new ImplementationError(\n `Getter and setter must be implemented together for writeable attribute \"${name}\".`,\n );\n }\n\n super(\n id,\n name,\n readAcl,\n writeAcl,\n schema,\n isWritable,\n isSubscribable,\n requiresTimedInteraction,\n initValue,\n defaultValue,\n datasource,\n getter,\n );\n\n if (setter === undefined) {\n this.setter = value => {\n const oldValue = this.value;\n this.value = value;\n return !isDeepEqual(value, oldValue);\n };\n } else {\n this.setter = setter;\n }\n\n this.validator = (value, session, endpoint) => {\n this.validateWithSchema(value);\n if (validator !== undefined) {\n validator(value, session, endpoint);\n }\n };\n }\n\n /**\n * Initialize the value of the attribute, used when a persisted value is set initially or when values needs to be\n * adjusted before the Device gets announced. Do not use this method to change values when the device is in use!\n */\n override init(value: T | undefined) {\n if (value === undefined) {\n value = this.getter(undefined, this.endpoint);\n }\n if (value === undefined) {\n throw new InternalError(`Can not initialize attribute \"${this.name}\" with undefined value.`);\n }\n this.validator(value, undefined, this.endpoint);\n this.value = value;\n }\n\n /**\n * Set the value of the attribute. This method is used by the Interaction model to write the value of the attribute\n * and includes the ACL check. It should not be used locally in the code!\n *\n * If a setter is defined this setter method is called to store the value.\n *\n * Listeners are called when the value changes (internal listeners) or in any case (external listeners).\n */\n set(value: T, session: Session<MatterDevice>, message?: Message, delayChangeEvents = false) {\n if (!this.isWritable) {\n throw new StatusResponseError(`Attribute \"${this.name}\" is not writable.`, StatusCode.UnsupportedWrite);\n }\n\n this.setRemote(value, session, message, delayChangeEvents);\n }\n\n /**\n * Method that contains the logic to set a value \"from remote\" (e.g. from a client).\n */\n protected setRemote(value: T, session: Session<MatterDevice>, message?: Message, delayChangeEvents = false) {\n this.processSet(value, session, message, delayChangeEvents);\n this.value = value;\n }\n\n /**\n * Set the value of the attribute locally. This method should be used locally in the code and does not include the\n * ACL check.\n *\n * If a setter is defined this setter method is called to validate and store the value.\n *\n * Else if a validator is defined the value is validated before it is stored.\n *\n * Listeners are called when the value changes (internal listeners) or in any case (external listeners).\n */\n setLocal(value: T) {\n this.processSet(value, undefined);\n this.value = value;\n }\n\n /**\n * Helper Method to process the set of a value in a generic way. This method is used internally.\n */\n protected processSet(value: T, session?: Session<MatterDevice>, message?: Message, delayChangeEvents = false) {\n this.validator(value, session, this.endpoint);\n const oldValue = this.getter(session, this.endpoint, undefined, message);\n const valueChanged = this.setter(value, session, this.endpoint, message);\n if (delayChangeEvents) {\n this.delayedChangeData = {\n oldValue: this.delayedChangeData?.oldValue ?? oldValue, // We keep the oldest value\n newValue: value,\n changed: !!this.delayedChangeData?.changed || valueChanged, // We combine the changed flag\n };\n logger.info(`Delay change for attribute \"${this.name}\" with value ${Logger.toJSON(value)}`);\n } else {\n this.handleVersionAndTriggerListeners(value, oldValue, valueChanged);\n }\n }\n\n triggerDelayedChangeEvents() {\n if (this.delayedChangeData !== undefined) {\n const { oldValue, newValue, changed } = this.delayedChangeData;\n this.delayedChangeData = undefined;\n logger.info(`Trigger delayed change for attribute \"${this.name}\" with value ${Logger.toJSON(newValue)}`);\n this.handleVersionAndTriggerListeners(newValue, oldValue, changed);\n }\n }\n\n /**\n * Helper Method to handle needed version increases and trigger the relevant listeners. This method is used\n * internally.\n */\n protected handleVersionAndTriggerListeners(value: T, oldValue: T | undefined, considerVersionChanged: boolean) {\n if (considerVersionChanged) {\n const version = this.datasource.increaseVersion();\n this.valueChangeListeners.forEach(listener => listener(value, version));\n }\n if (oldValue !== undefined) {\n this.valueSetListeners.forEach(listener => listener(value, oldValue));\n }\n }\n\n /**\n * When the value is handled by getter or setter methods and is changed by other processes this method can be used\n * to notify the attribute server that the value has changed. This will increase the version number and trigger the\n * listeners.\n *\n * ACL checks needs to be performed before calling this method.\n */\n updated(session: SecureSession<MatterDevice>) {\n const oldValue = this.value ?? this.defaultValue;\n this.value = tryCatch(\n () => this.get(session, false),\n NoAssociatedFabricError, // Handle potential error cases where the session does not have a fabric assigned.\n this.value ?? this.defaultValue,\n );\n this.handleVersionAndTriggerListeners(this.value, oldValue, true);\n }\n\n /**\n * When the value is handled by getter or setter methods and is changed by other processes and no session from the\n * originating process is known this method can be used to notify the attribute server that the value has changed.\n * This will increase the version number and trigger the listeners.\n *\n * ACL checks needs to be performed before calling this method.\n */\n updatedLocal() {\n const oldValue = this.value ?? this.defaultValue;\n this.value = this.getLocal();\n this.handleVersionAndTriggerListeners(this.value, oldValue, true);\n }\n\n /**\n * Add an internal listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the version number.\n */\n override addValueChangeListener(listener: (value: T, version: number) => void) {\n this.valueChangeListeners.push(listener);\n }\n\n /**\n * Remove an internal listener.\n */\n override removeValueChangeListener(listener: (value: T, version: number) => void) {\n const entryIndex = this.valueChangeListeners.indexOf(listener);\n if (entryIndex !== -1) {\n this.valueChangeListeners.splice(entryIndex, 1);\n }\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value.\n */\n override addValueSetListener(listener: (newValue: T, oldValue: T) => void) {\n this.valueSetListeners.push(listener);\n }\n\n /**\n * Add an external listener that is called when the value of the attribute changes. The listener is called with the\n * new value and the old value. This method is a convenient alias for addValueSetListener.\n */\n override subscribe(listener: (newValue: T, oldValue: T) => void) {\n this.addValueSetListener(listener);\n }\n\n /**\n * Remove an external listener.\n */\n override removeValueSetListener(listener: (newValue: T, oldValue: T) => void) {\n const entryIndex = this.valueSetListeners.indexOf(listener);\n if (entryIndex !== -1) {\n this.valueSetListeners.splice(entryIndex, 1);\n }\n }\n}\n\nexport function genericFabricScopedAttributeGetterFromFabric<T>(\n fabric: Fabric,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n defaultValue: T,\n) {\n const data = fabric.getScopedClusterDataValue<{ value: T }>(cluster, attributeName);\n return data?.value ?? defaultValue;\n}\n\nexport function genericFabricScopedAttributeGetter<T>(\n session: Session<MatterDevice> | undefined,\n isFabricFiltered: boolean,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n defaultValue: T,\n) {\n if (session === undefined) {\n throw new FabricScopeError(`Session is required for fabric scoped attribute ${attributeName}`);\n }\n\n if (isFabricFiltered) {\n assertSecureSession(session);\n return genericFabricScopedAttributeGetterFromFabric(\n session.associatedFabric,\n cluster,\n attributeName,\n defaultValue,\n );\n } else {\n const fabrics = session.context.getFabrics();\n const values = new Array<any>();\n for (const fabric of fabrics) {\n const value = genericFabricScopedAttributeGetterFromFabric(fabric, cluster, attributeName, defaultValue);\n if (!Array.isArray(value)) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${attributeName}\" can only be read for all fabrics if they are arrays.`,\n );\n }\n values.push(...value);\n }\n return values as T;\n }\n}\n\nexport function genericFabricScopedAttributeSetterForFabric<T>(\n fabric: Fabric,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n value: T,\n defaultValue?: T,\n) {\n const oldValue = genericFabricScopedAttributeGetterFromFabric(fabric, cluster, attributeName, defaultValue);\n if (!isDeepEqual(value, oldValue)) {\n const setResult = fabric.setScopedClusterDataValue(cluster, attributeName, { value });\n if (MaybePromise.is(setResult)) {\n throw new ImplementationError(\n \"Seems like an Asynchronous Storage is used with Legacy code paths which is forbidden!\",\n );\n }\n return true;\n }\n return false;\n}\n\nexport function genericFabricScopedAttributeSetter<T>(\n value: T,\n session: Session<MatterDevice> | undefined,\n cluster: Cluster<any, any, any, any, any>,\n attributeName: string,\n defaultValue?: T,\n) {\n if (session === undefined) {\n throw new FabricScopeError(`Session is required for fabric scoped attribute \"${attributeName}\".`);\n }\n\n assertSecureSession(session);\n const fabric = session.associatedFabric;\n\n return genericFabricScopedAttributeSetterForFabric(fabric, cluster, attributeName, value, defaultValue);\n}\n\n/**\n * Attribute server which is getting and setting the value for a defined fabric. The values are automatically persisted\n * on fabric level if no custom getter or setter is defined.\n */\nexport class FabricScopedAttributeServer<T> extends AttributeServer<T> {\n private readonly isCustomGetter: boolean;\n private readonly isCustomSetter: boolean;\n private readonly fabricSensitiveElementsToRemove = new Array<string>();\n\n constructor(\n id: AttributeId,\n name: string,\n readAcl: AccessLevel | undefined,\n writeAcl: AccessLevel | undefined,\n schema: TlvSchema<T>,\n isWritable: boolean,\n isSubscribable: boolean,\n requiresTimedInteraction: boolean,\n initValue: T,\n defaultValue: T | undefined,\n readonly cluster: Cluster<any, any, any, any, any>,\n datasource: ClusterDatasource,\n getter?: (session?: Session<MatterDevice>, endpoint?: EndpointInterface, isFabricFiltered?: boolean) => T,\n setter?: (\n value: T,\n session?: Session<MatterDevice>,\n endpoint?: EndpointInterface,\n message?: Message,\n ) => boolean,\n validator?: (value: T, session?: Session<MatterDevice>, endpoint?: EndpointInterface) => void,\n ) {\n if (\n isWritable &&\n (getter === undefined || setter === undefined) &&\n !(getter === undefined && setter === undefined)\n ) {\n throw new ImplementationError(\n `Getter and setter must be implemented together for writeable fabric scoped attribute \"${name}\".`,\n );\n }\n\n let isCustomGetter = false;\n if (getter === undefined) {\n getter = (session, _endpoint, isFabricFiltered) => {\n if (session === undefined)\n throw new FabricScopeError(`Session is required for fabric scoped attribute ${name}`);\n\n if (isFabricFiltered === true) {\n assertSecureSession(session);\n return this.getLocalForFabric(session.associatedFabric);\n } else {\n const fabrics = session.context.getFabrics();\n const values = new Array<any>();\n for (const fabric of fabrics) {\n const value = this.getLocalForFabric(fabric);\n if (!Array.isArray(value)) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${name}\" can only be read for all fabrics if they are arrays.`,\n );\n }\n values.push(...value);\n }\n return values as T;\n }\n };\n } else {\n isCustomGetter = true;\n }\n\n let isCustomSetter = false;\n if (setter === undefined) {\n setter = (value, session) =>\n genericFabricScopedAttributeSetter(value, session, this.cluster, this.name, this.defaultValue);\n } else {\n isCustomSetter = true;\n }\n\n super(\n id,\n name,\n readAcl,\n writeAcl,\n schema,\n isWritable,\n isSubscribable,\n requiresTimedInteraction,\n initValue,\n defaultValue,\n datasource,\n getter,\n setter,\n validator,\n );\n this.isCustomGetter = isCustomGetter;\n this.isCustomSetter = isCustomSetter;\n\n this.#determineSensitiveFieldsToRemove();\n }\n\n #determineSensitiveFieldsToRemove() {\n const clusterFromModel = MatterModel.get(ClusterModel, this.cluster.id);\n if (clusterFromModel === undefined) {\n logger.debug(`${this.cluster.name}: Cluster for Fabric scoped element not found in Model, ignore`);\n return;\n }\n const attributeFromModel = clusterFromModel.get(AttributeModel, this.id);\n if (attributeFromModel === undefined) {\n logger.debug(\n `${this.cluster.name}.${this.id}: Attribute for Fabric scoped element not found in Model, ignore`,\n );\n return;\n }\n if (!attributeFromModel.fabricScoped) {\n logger.debug(`${this.cluster.name}.${this.id}: Attribute is not Fabric scoped in model, ignore`);\n return;\n }\n if (attributeFromModel.children.length !== 1) {\n logger.debug(`${this.cluster.name}.${this.id}: Attribute has not exactly one child, ignore`);\n return;\n }\n const type = attributeFromModel.children[0].type;\n if (type === undefined) {\n logger.debug(`${this.cluster.name}.${this.id}: Attribute field has no type, ignore`);\n return;\n }\n const dataType = clusterFromModel.get(DatatypeModel, type);\n if (dataType === undefined) {\n logger.debug(`${this.cluster.name}.${this.id}: DataType ${type} not found in model, ignore`);\n return;\n }\n dataType.children\n .filter(field => field.fabricSensitive)\n .forEach(field => this.fabricSensitiveElementsToRemove.push(camelize(field.name)));\n }\n\n override get hasFabricSensitiveData() {\n return this.fabricSensitiveElementsToRemove.length > 0;\n }\n\n /**\n * Sanitize the value of the attribute by removing fabric sensitive fields that do not belong to the\n * associated fabric\n */\n sanitizeFabricSensitiveFields(value: T, associatedFabric?: Fabric) {\n if (this.fabricSensitiveElementsToRemove.length && Array.isArray(value)) {\n // Get the associated Fabric Index or uses -1 when no Fabric is associated because this value will\n // never be in the struct\n const associatedFabricIndex = associatedFabric?.fabricIndex ?? -1;\n return value.map(data => {\n if (data[FabricIndexName] !== associatedFabricIndex) {\n const result = { ...data };\n this.fabricSensitiveElementsToRemove.forEach(fieldName => delete result[fieldName]);\n return result;\n }\n return data;\n });\n }\n return value;\n }\n\n /**\n * Initialize the attribute with a value. Because the value is stored on fabric level this method only initializes\n * the version number.\n */\n override init(value: T | undefined) {\n if (value !== undefined) {\n throw new InternalError(`Can not initialize fabric scoped attribute \"${this.name}\" with a value.`);\n }\n }\n\n /**\n * Fabric scoped enhancement of set to allow setting special fabricindex locally.\n */\n override set(\n value: T,\n session: Session<MatterDevice>,\n message: Message,\n delayChangeEvents = false,\n preserveFabricIndex = false,\n ) {\n if (!this.isWritable) {\n throw new StatusResponseError(`Attribute \"${this.name}\" is not writable.`, StatusCode.UnsupportedWrite);\n }\n\n this.setRemote(value, session, message, delayChangeEvents, preserveFabricIndex);\n }\n\n /**\n * Method that contains the logic to set a value \"from remote\" (e.g. from a client). For Fabric scoped attributes\n * we need to inject the fabric index into the value.\n */\n protected override setRemote(\n value: T,\n session: Session<MatterDevice>,\n message: Message,\n delayChangeEvents = false,\n preserveFabricIndex = false,\n ) {\n // Inject fabric index into structures in general if undefined, if set it will be used\n value = this.schema.injectField(\n value,\n <number>Globals.FabricIndex.id,\n session.associatedFabric.fabricIndex,\n () => !preserveFabricIndex, // Noone should send any index and if we simply SHALL ignore it, biuut internally we might need it\n );\n logger.info(`Set remote value for fabric scoped attribute \"${this.name}\" to ${Logger.toJSON(value)}`);\n\n super.setRemote(value, session, message, delayChangeEvents);\n }\n\n /**\n * Set Local is not allowed for fabric scoped attributes. Use setLocalForFabric instead.\n */\n override setLocal(_value: T) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${this.name}\" can only be set locally by providing a Fabric. Use setLocalForFabric instead.`,\n );\n }\n\n /**\n * Set the value of the attribute locally for a fabric. This method should be used locally in the code and does not\n * include the ACL check.\n * If a setter is defined this method can not be used!\n * If a validator is defined the value is validated before it is stored.\n * Listeners are called when the value changes (internal listeners) or in any case (external listeners).\n */\n setLocalForFabric(value: T, fabric: Fabric) {\n if (this.isCustomSetter) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${this.name}\" can not be set locally when a custom setter is defined.`,\n );\n }\n this.validator(value, undefined, this.endpoint);\n\n const oldValue = this.getLocalForFabric(fabric);\n const valueChanged = !isDeepEqual(value, oldValue);\n if (valueChanged) {\n const setResult = fabric.setScopedClusterDataValue(this.cluster, this.name, { value });\n if (MaybePromise.is(setResult)) {\n throw new ImplementationError(\n \"Seems like an Asynchronous Storage is used with Legacy code paths which is forbidden!\",\n );\n }\n }\n this.handleVersionAndTriggerListeners(value, oldValue, valueChanged); // TODO Make callbacks sense without fabric, but then they would have other signature?\n }\n\n /**\n * When the value is handled by getter or setter methods and is changed by other processes and no session from the\n * originating process is known this method can be used to notify the attribute server that the value has changed.\n * This will increase the version number and trigger the listeners.\n * ACL checks needs to be performed before calling this method.\n */\n updatedLocalForFabric(fabric: Fabric) {\n const oldValue = this.value ?? this.defaultValue;\n this.value = tryCatch(\n () => this.getLocalForFabric(fabric),\n FabricScopeError, // Handle potential error cases where a custom getter is used.\n this.value ?? this.defaultValue,\n );\n this.handleVersionAndTriggerListeners(this.value, oldValue, true);\n }\n\n /**\n * Get the value of the attribute locally for a special Fabric. This method should be used locally in the code and\n * does not include the ACL check.\n * If a getter is defined this method returns an error and the value should be retrieved directly internally.\n */\n getLocalForFabric(fabric: Fabric): T {\n if (this.isCustomGetter) {\n throw new FabricScopeError(\n `Fabric scoped attribute \"${this.name}\" can not be read locally when a custom getter is defined.`,\n );\n }\n return genericFabricScopedAttributeGetterFromFabric(fabric, this.cluster, this.name, this.defaultValue);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,yBAAgE;AAChE,6BAAyB;AACzB,6BAAgC;AAIhC,oBAAuB;AACvB,mBAMO;AACP,wBAAgD;AAEhD,2BAA4E;AAG5E,uBAA4B;AAC5B,sBAA6B;AAC7B,oBAAyB;AACzB,qBAA8E;AA9B9E;AAAA;AAAA;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Q,KAAK,SAAS,KAAK,MAAM,KAAK,YAAY;AAAA,EAC1G;AACJ;",
6
+ "names": ["MatterModelObj"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ClusterServer.d.ts","sourceRoot":"","sources":["../../../../src/cluster/server/ClusterServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAInF,OAAO,EAEH,UAAU,EACV,OAAO,EACP,QAAQ,EAER,MAAM,EAET,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,sBAAsB,EAGtB,qBAAqB,EACrB,gBAAgB,EAGhB,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;AAkBjC,wBAAgB,aAAa,CACzB,CAAC,SAAS,SAAS,EACnB,EAAE,SAAS,wBAAwB,CAAC,CAAC,CAAC,EACtC,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAExD,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnC,uBAAuB,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAClD,QAAQ,EAAE,CAAC,EACX,eAAe,GAAE,mBAAmB,CAAC,CAAC,CAA8B,GACrE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAqcxB"}
1
+ {"version":3,"file":"ClusterServer.d.ts","sourceRoot":"","sources":["../../../../src/cluster/server/ClusterServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAInF,OAAO,EAEH,UAAU,EACV,OAAO,EACP,QAAQ,EAER,MAAM,EAET,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,sBAAsB,EAGtB,qBAAqB,EACrB,gBAAgB,EAGhB,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;AAkBjC,wBAAgB,aAAa,CACzB,CAAC,SAAS,SAAS,EACnB,EAAE,SAAS,wBAAwB,CAAC,CAAC,CAAC,EACtC,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAExD,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnC,uBAAuB,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAClD,QAAQ,EAAE,CAAC,EACX,eAAe,GAAE,mBAAmB,CAAC,CAAC,CAA8B,GACrE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CA4cxB"}
@@ -399,7 +399,14 @@ function ClusterServer(clusterDef, attributesInitialValues, handlers, supportedE
399
399
  }
400
400
  }
401
401
  if (supportedEvents[eventName] === true) {
402
- events[eventName] = new import_EventServer.EventServer(id, clusterId, eventName, schema, priority, readAcl);
402
+ events[eventName] = (0, import_EventServer.createEventServer)(
403
+ clusterDef,
404
+ eventDef[eventName],
405
+ eventName,
406
+ schema,
407
+ priority,
408
+ readAcl
409
+ );
403
410
  const capitalizedEventName = (0, import_String.capitalize)(eventName);
404
411
  result[`trigger${capitalizedEventName}Event`] = (event) => events[eventName].triggerEvent(event);
405
412
  eventList.push(id);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cluster/server/ClusterServer.ts"],
4
- "sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ImplementationError, InternalError } from \"../../common/MatterError.js\";\nimport { AttributeId } from \"../../datatype/AttributeId.js\";\nimport { CommandId } from \"../../datatype/CommandId.js\";\nimport { EventId } from \"../../datatype/EventId.js\";\nimport { EndpointInterface } from \"../../endpoint/EndpointInterface.js\";\nimport { Fabric } from \"../../fabric/Fabric.js\";\nimport { Logger } from \"../../log/Logger.js\";\nimport { BitSchema, TypeFromPartialBitSchema } from \"../../schema/BitmapSchema.js\";\nimport { TypeFromSchema } from \"../../tlv/TlvSchema.js\";\nimport { MaybePromise } from \"../../util/Promises.js\";\nimport { capitalize } from \"../../util/String.js\";\nimport {\n AccessLevel,\n Attributes,\n Cluster,\n Commands,\n ConditionalFeatureList,\n Events,\n TlvNoResponse,\n} from \"../Cluster.js\";\nimport { Scenes } from \"../definitions/ScenesCluster.js\";\nimport { createAttributeServer } from \"./AttributeServer.js\";\nimport {\n AttributeInitialValues,\n AttributeServers,\n ClusterDatasource,\n ClusterServerHandlers,\n ClusterServerObj,\n CommandServers,\n EventServers,\n SupportedEventsList,\n} from \"./ClusterServerTypes.js\";\nimport { CommandServer } from \"./CommandServer.js\";\nimport { EventServer } from \"./EventServer.js\";\n\nconst logger = Logger.get(\"ClusterServer\");\n\nfunction isConditionMatching<F extends BitSchema, SF extends TypeFromPartialBitSchema<F>>(\n featureSets: ConditionalFeatureList<F>,\n supportedFeatures: SF,\n): boolean {\n for (const features of featureSets) {\n if (Object.keys(features).every(feature => !!features[feature] === !!supportedFeatures[feature])) {\n return true;\n }\n }\n return false;\n}\n\nexport function ClusterServer<\n F extends BitSchema,\n SF extends TypeFromPartialBitSchema<F>,\n A extends Attributes,\n C extends Commands,\n E extends Events,\n H extends ClusterServerHandlers<Cluster<F, SF, A, C, E>>,\n>(\n clusterDef: Cluster<F, SF, A, C, E>,\n attributesInitialValues: AttributeInitialValues<A>,\n handlers: H,\n supportedEvents: SupportedEventsList<E> = <SupportedEventsList<E>>{},\n): ClusterServerObj<A, E> {\n const {\n id: clusterId,\n name,\n commands: commandDef,\n attributes: attributeDef,\n events: eventDef,\n supportedFeatures,\n } = clusterDef;\n let datasource: ClusterDatasource | undefined;\n const sceneAttributeList = new Array<string>();\n const attributes = <AttributeServers<A>>{};\n const commands = <CommandServers<C>>{};\n const events = <EventServers<E>>{};\n let assignedEndpoint: EndpointInterface | undefined = undefined;\n\n // We pass a proxy into attribute servers so we can swap out our datasource\n // without updating all servers\n //\n // There should always be a datasource when the server is online, so if\n // there is no datasource we just report version as 0 rather than assigning\n // a random version that will be overwritten when we receive a datasource\n const datasourceProxy: ClusterDatasource = {\n get version() {\n return datasource?.version ?? 0;\n },\n\n get eventHandler() {\n return datasource?.eventHandler;\n },\n\n increaseVersion() {\n return datasource?.increaseVersion() ?? 0;\n },\n\n changed(key, value) {\n datasource?.changed(key, value);\n },\n };\n\n const result: any = {\n id: clusterId,\n name,\n _type: \"ClusterServer\",\n attributes,\n _commands: commands,\n _events: events,\n\n get datasource() {\n return datasource;\n },\n\n set datasource(newDatasource: ClusterDatasource<any> | undefined) {\n // This is not legal but TS requires setters to accept getter type\n if (newDatasource === undefined) {\n throw new InternalError(\"Cluster datasource cannot be unset\");\n }\n\n datasource = newDatasource;\n\n if (assignedEndpoint === undefined) {\n throw new InternalError(\n \"The Endpoint always needs to be existing before storage is initialized for an Endpoint.\",\n );\n }\n\n if (typeof handlers.initializeClusterServer === \"function\") {\n handlers.initializeClusterServer({\n attributes,\n events,\n endpoint: assignedEndpoint,\n });\n }\n\n if (datasource.eventHandler) {\n for (const eventName in events) {\n const bindResult = (events as any)[eventName].bindToEventHandler(datasource.eventHandler);\n if (bindResult !== undefined && MaybePromise.is(bindResult)) {\n throw new InternalError(\"Binding events to event handler should never return a promise\");\n }\n }\n }\n },\n\n _assignToEndpoint: (endpoint: EndpointInterface) => {\n for (const name in attributes) {\n (attributes as any)[name].assignToEndpoint(endpoint);\n }\n for (const name in events) {\n (events as any)[name].assignToEndpoint(endpoint);\n }\n assignedEndpoint = endpoint;\n },\n\n _close: () => {\n if (typeof handlers.destroyClusterServer === \"function\") {\n handlers.destroyClusterServer();\n }\n },\n\n _getSceneExtensionFieldSets: () => {\n const values = new Array<TypeFromSchema<typeof Scenes.TlvAttributeValuePair>>();\n for (const name of sceneAttributeList) {\n const attributeServer = (attributes as any)[name];\n values.push({\n attributeId: attributeServer.id,\n attributeValue: attributeServer.schema.encodeTlv(attributeServer.get()),\n });\n }\n return values;\n },\n\n _setSceneExtensionFieldSets: (\n values: TypeFromSchema<typeof Scenes.TlvAttributeValuePair>[],\n _transitionTime: number,\n ) => {\n // TODO It is recommended that, where possible (e.g., it is not possible for attributes with Boolean data type),\n // a gradual transition SHOULD take place from the old to the new state over this time. However, the exact\n // transition is manufacturer dependent.\n\n for (const { attributeId, attributeValue } of values) {\n if (attributeId === undefined) {\n logger.warn(`Empty attributeId in scene extension field not supported for \"set\" yet`);\n continue;\n }\n const attributeName = sceneAttributeList.find(name => (attributes as any)[name].id === attributeId);\n if (attributeName) {\n const attributeServer = (attributes as any)[attributeName];\n attributeServer.setLocal(attributeServer.schema.decodeTlv(attributeValue));\n }\n }\n },\n\n _verifySceneExtensionFieldSets(values: TypeFromSchema<typeof Scenes.TlvAttributeValuePair>[]) {\n for (const { attributeId, attributeValue } of values) {\n if (attributeId === undefined) {\n logger.warn(`Empty attributeId in scene extension field not supported for \"verify\" yet`);\n continue;\n }\n const attributeName = sceneAttributeList.find(name => (attributes as any)[name].id === attributeId);\n if (attributeName) {\n const attributeServer = (attributes as any)[attributeName];\n if (attributeServer.getLocal() !== attributeServer.schema.decodeTlv(attributeValue)) return false;\n }\n }\n return true;\n },\n\n isAttributeSupported: (attributeId: AttributeId) => {\n return (attributes as any).attributeList.getLocal().includes(attributeId);\n },\n\n isAttributeSupportedByName: (attributeName: string) => {\n return (attributesInitialValues as any)[attributeName] !== undefined;\n },\n\n isEventSupported: (eventId: EventId) => {\n return (attributes as any).eventList.getLocal().includes(eventId);\n },\n\n isEventSupportedByName: (eventName: string) => {\n return (supportedEvents as any)[eventName] === true;\n },\n\n isCommandSupported: (commandId: CommandId) => {\n return (attributes as any).acceptedCommandList.getLocal().includes(commandId);\n },\n\n isCommandSupportedByName: (commandName: string) => {\n return (commands as any)[commandName] !== undefined;\n },\n };\n\n // Create attributes\n attributesInitialValues = {\n ...attributesInitialValues,\n clusterRevision: clusterDef.revision,\n featureMap: supportedFeatures,\n attributeList: new Array<AttributeId>(),\n acceptedCommandList: new Array<CommandId>(),\n generatedCommandList: new Array<CommandId>(),\n eventList: new Array<EventId>(),\n };\n\n const attributeList = new Array<AttributeId>();\n for (const attributeName in attributeDef) {\n const capitalizedAttributeName = capitalize(attributeName);\n\n // logger.info(`check this for REQUIRED Attributes ${Logger.toJSON(attributeName)}`)\n if (attributeDef[attributeName].isConditional) {\n const { mandatoryIf, optionalIf } = attributeDef[attributeName];\n let conditionHasMatched = false;\n if (mandatoryIf !== undefined && mandatoryIf.length > 0) {\n // Check if mandatoryIf is relevant for current feature combination and the attribute initial value is set\n const conditionMatched = isConditionMatching(mandatoryIf, supportedFeatures);\n if (conditionMatched && (attributesInitialValues as any)[attributeName] === undefined) {\n logger.warn(\n `InitialAttributeValue for \"${\n clusterDef.name\n }/${attributeName}\" is REQUIRED by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n // TODO Remove optional info/checks\n if (!conditionHasMatched && optionalIf !== undefined && optionalIf.length > 0) {\n const conditionMatched = isConditionMatching(optionalIf, supportedFeatures);\n if (conditionMatched && (attributesInitialValues as any)[attributeName] === undefined) {\n logger.debug(\n `InitialAttributeValue for \"${\n clusterDef.name\n }/${attributeName}\" is optional by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} and is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n\n if (!conditionHasMatched && (attributesInitialValues as any)[attributeName] !== undefined) {\n logger.warn(\n `InitialAttributeValue for \"${\n clusterDef.name\n }/${attributeName}\" is provided but it's neither optional or mandatory for supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is set!`,\n );\n }\n }\n\n const { id, persistent, fabricScoped, scene, fixed } = attributeDef[attributeName];\n if ((attributesInitialValues as any)[attributeName] !== undefined) {\n // Get the handlers for this attribute if present\n const getter = (handlers as any)[`${attributeName}AttributeGetter`];\n const setter = (handlers as any)[`${attributeName}AttributeSetter`];\n const validator = (handlers as any)[`${attributeName}AttributeValidator`];\n\n (attributes as any)[attributeName] = createAttributeServer(\n clusterDef,\n attributeDef[attributeName],\n attributeName,\n (attributesInitialValues as any)[attributeName],\n datasourceProxy,\n getter\n ? (session, endpoint, isFabricFiltered, message) =>\n getter({\n attributes,\n endpoint,\n session,\n isFabricFiltered,\n message,\n })\n : undefined,\n setter\n ? (value, session, endpoint, message) =>\n setter(value, {\n attributes,\n endpoint,\n session,\n message,\n })\n : undefined,\n validator\n ? (value, session, endpoint) =>\n validator(value, {\n attributes,\n endpoint,\n session,\n })\n : undefined,\n );\n\n // Add the relevant convenient methods to the ClusterServerObj\n if (fixed) {\n result[`get${capitalizedAttributeName}Attribute`] = () => (attributes as any)[attributeName].getLocal();\n } else if (fabricScoped) {\n result[`get${capitalizedAttributeName}Attribute`] = (fabric: Fabric) =>\n (attributes as any)[attributeName].getLocalForFabric(fabric);\n result[`set${capitalizedAttributeName}Attribute`] = <T>(value: T, fabric: Fabric) =>\n (attributes as any)[attributeName].setLocalForFabric(value, fabric);\n result[`subscribe${capitalizedAttributeName}Attribute`] = <T>(\n listener: (newValue: T, oldValue: T) => void,\n ) => (attributes as any)[attributeName].addValueSetListener(listener);\n } else {\n if (scene) {\n sceneAttributeList.push(attributeName);\n }\n result[`get${capitalizedAttributeName}Attribute`] = () => (attributes as any)[attributeName].getLocal();\n result[`set${capitalizedAttributeName}Attribute`] = <T>(value: T) =>\n (attributes as any)[attributeName].setLocal(value);\n result[`subscribe${capitalizedAttributeName}Attribute`] = <T>(\n listener: (newValue: T, oldValue: T) => void,\n ) => (attributes as any)[attributeName].addValueSetListener(listener);\n }\n if (persistent || getter || setter) {\n const listener = (value: any) =>\n datasource?.changed(attributeName, fabricScoped || getter || setter ? undefined : value);\n (attributes as any)[attributeName].addValueChangeListener(listener);\n }\n attributeList.push(AttributeId(id));\n } else {\n // TODO: Find maybe a better way to do this including strong typing according to attribute initial values set?\n result[`get${capitalizedAttributeName}Attribute`] = () => undefined;\n if (!fixed) {\n result[`set${capitalizedAttributeName}Attribute`] = () => {\n throw new ImplementationError(\n `Attribute ${attributeName} is optional and not initialized. To use it please initialize it first.`,\n );\n };\n result[`subscribe${capitalizedAttributeName}Attribute`] = () => {\n throw new ImplementationError(\n `Attribute ${attributeName} is optional and not initialized. To use it please initialize it first.`,\n );\n };\n }\n }\n }\n (attributes as any).attributeList.setLocal(attributeList.sort((a, b) => a - b));\n\n // Create commands\n const acceptedCommandList = new Array<CommandId>();\n const generatedCommandList = new Array<CommandId>();\n for (const name in commandDef) {\n const handler = (handlers as any)[name];\n\n if (commandDef[name].isConditional) {\n const { mandatoryIf, optionalIf } = commandDef[name];\n let conditionHasMatched = false;\n if (mandatoryIf !== undefined && mandatoryIf.length > 0) {\n const conditionMatched = isConditionMatching(mandatoryIf, supportedFeatures);\n if (conditionMatched && handler === undefined) {\n logger.warn(\n `Command \"${clusterDef.name}/${name}\" is REQUIRED by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n // TODO Remove optional info/checks\n if (!conditionHasMatched && optionalIf !== undefined && optionalIf.length > 0) {\n const conditionMatched = isConditionMatching(optionalIf, supportedFeatures);\n if (conditionMatched && handler === undefined) {\n logger.debug(\n `Command \"${clusterDef.name}/${name}\" is optional by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} and is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n\n if (!conditionHasMatched && handler !== undefined) {\n logger.warn(\n `Command \"${\n clusterDef.name\n }/${name}\" is provided but it's neither optional nor mandatory for supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is set!`,\n );\n }\n }\n\n if (handler === undefined) continue;\n const { requestId, requestSchema, responseId, responseSchema, timed, invokeAcl } = commandDef[name];\n (commands as any)[name] = new CommandServer(\n requestId,\n responseId,\n name,\n requestSchema,\n responseSchema,\n timed,\n invokeAcl ?? AccessLevel.Operate, //????\n (request, session, message, endpoint) =>\n handler({\n request,\n attributes,\n events,\n session,\n message,\n endpoint,\n }),\n );\n if (!acceptedCommandList.includes(requestId)) {\n acceptedCommandList.push(requestId);\n }\n if (responseSchema !== TlvNoResponse) {\n if (!generatedCommandList.includes(responseId)) {\n generatedCommandList.push(responseId);\n }\n }\n }\n (attributes as any).acceptedCommandList.setLocal(acceptedCommandList.sort((a, b) => a - b));\n (attributes as any).generatedCommandList.setLocal(generatedCommandList.sort((a, b) => a - b));\n\n const eventList = new Array<EventId>();\n for (const eventName in eventDef) {\n const { id, schema, priority, optional, readAcl } = eventDef[eventName];\n if (!optional && (supportedEvents as any)[eventName] !== true) {\n throw new ImplementationError(`Event ${eventName} needs to be supported by cluster ${name} (${clusterId})`);\n }\n\n if (eventDef[eventName].isConditional) {\n const { mandatoryIf, optionalIf } = eventDef[eventName];\n let conditionHasMatched = false;\n if (mandatoryIf !== undefined) {\n const conditionMatched = isConditionMatching(mandatoryIf, supportedFeatures);\n if (conditionMatched && (supportedEvents as any)[eventName] === undefined) {\n logger.warn(\n `Event \"${clusterDef.name}/${eventName}\" is REQUIRED by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n // TODO Remove optional info/checks\n if (!conditionHasMatched && optionalIf !== undefined && optionalIf.length > 0) {\n const conditionMatched = isConditionMatching(optionalIf, supportedFeatures);\n if (conditionMatched && (supportedEvents as any)[eventName] === undefined) {\n logger.debug(\n `Event \"${clusterDef.name}/${eventName}\" is optional by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} and is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n\n if (!conditionHasMatched && (supportedEvents as any)[eventName] !== undefined) {\n logger.warn(\n `Event \"${\n clusterDef.name\n }/${eventName}\" is provided but it's neither optional or mandatory for supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is set!`,\n );\n }\n }\n\n if ((supportedEvents as any)[eventName] === true) {\n (events as any)[eventName] = new EventServer(id, clusterId, eventName, schema, priority, readAcl);\n const capitalizedEventName = capitalize(eventName);\n result[`trigger${capitalizedEventName}Event`] = <T>(event: T) =>\n (events as any)[eventName].triggerEvent(event);\n eventList.push(id);\n }\n }\n (attributes as any).eventList.setLocal(eventList.sort((a, b) => a - b));\n\n return result as ClusterServerObj<A, E>;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAAmD;AACnD,yBAA4B;AAK5B,oBAAuB;AAGvB,sBAA6B;AAC7B,oBAA2B;AAC3B,qBAQO;AAEP,6BAAsC;AAWtC,2BAA8B;AAC9B,yBAA4B;AAvC5B;AAAA;AAAA;AAAA;AAAA;AAyCA,MAAM,SAAS,qBAAO,IAAI,eAAe;AAEzC,SAAS,oBACL,aACA,mBACO;AACP,aAAW,YAAY,aAAa;AAChC,QAAI,OAAO,KAAK,QAAQ,EAAE,MAAM,aAAW,CAAC,CAAC,SAAS,OAAO,MAAM,CAAC,CAAC,kBAAkB,OAAO,CAAC,GAAG;AAC9F,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;AAEO,SAAS,cAQZ,YACA,yBACA,UACA,kBAAkE,CAAC,GAC7C;AACtB,QAAM;AAAA,IACF,IAAI;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR;AAAA,EACJ,IAAI;AACJ,MAAI;AACJ,QAAM,qBAAqB,IAAI,MAAc;AAC7C,Q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qBAAO;AAAA,cAChF;AAAA,YACJ,CAAC;AAAA,UACL;AAAA,QACJ;AACA,8BAAsB,uBAAuB;AAAA,MACjD;AAEA,UAAI,CAAC,uBAAuB,eAAe,UAAa,WAAW,SAAS,GAAG;AAC3E,cAAM,mBAAmB,oBAAoB,YAAY,iBAAiB;AAC1E,YAAI,oBAAqB,gBAAwB,SAAS,MAAM,QAAW;AACvE,iBAAO;AAAA,YACH,UAAU,WAAW,IAAI,IAAI,SAAS,uCAAuC,qBAAO;AAAA,cAChF;AAAA,YACJ,CAAC;AAAA,UACL;AAAA,QACJ;AACA,8BAAsB,uBAAuB;AAAA,MACjD;AAEA,UAAI,CAAC,uBAAwB,gBAAwB,SAAS,MAAM,QAAW;AAC3E,eAAO;AAAA,UACH,UACI,WAAW,IACf,IAAI,SAAS,+EAA+E,qBAAO;AAAA,YAC/F;AAAA,UACJ,CAAC;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAEA,QAAK,gBAAwB,SAAS,MAAM,MAAM;AAC9C,MAAC,OAAe,SAAS,IAAI,IAAI,+BAAY,IAAI,WAAW,WAAW,QAAQ,UAAU,OAAO;AAChG,YAAM,2BAAuB,0BAAW,SAAS;AACjD,aAAO,UAAU,oBAAoB,OAAO,IAAI,CAAI,UAC/C,OAAe,SAAS,EAAE,aAAa,KAAK;AACjD,gBAAU,KAAK,EAAE;AAAA,IACrB;AAAA,EACJ;AACA,EAAC,WAAmB,UAAU,SAAS,UAAU,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC;AAEtE,SAAO;AACX;",
4
+ "sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ImplementationError, InternalError } from \"../../common/MatterError.js\";\nimport { AttributeId } from \"../../datatype/AttributeId.js\";\nimport { CommandId } from \"../../datatype/CommandId.js\";\nimport { EventId } from \"../../datatype/EventId.js\";\nimport { EndpointInterface } from \"../../endpoint/EndpointInterface.js\";\nimport { Fabric } from \"../../fabric/Fabric.js\";\nimport { Logger } from \"../../log/Logger.js\";\nimport { BitSchema, TypeFromPartialBitSchema } from \"../../schema/BitmapSchema.js\";\nimport { TypeFromSchema } from \"../../tlv/TlvSchema.js\";\nimport { MaybePromise } from \"../../util/Promises.js\";\nimport { capitalize } from \"../../util/String.js\";\nimport {\n AccessLevel,\n Attributes,\n Cluster,\n Commands,\n ConditionalFeatureList,\n Events,\n TlvNoResponse,\n} from \"../Cluster.js\";\nimport { Scenes } from \"../definitions/ScenesCluster.js\";\nimport { createAttributeServer } from \"./AttributeServer.js\";\nimport {\n AttributeInitialValues,\n AttributeServers,\n ClusterDatasource,\n ClusterServerHandlers,\n ClusterServerObj,\n CommandServers,\n EventServers,\n SupportedEventsList,\n} from \"./ClusterServerTypes.js\";\nimport { CommandServer } from \"./CommandServer.js\";\nimport { createEventServer } from \"./EventServer.js\";\n\nconst logger = Logger.get(\"ClusterServer\");\n\nfunction isConditionMatching<F extends BitSchema, SF extends TypeFromPartialBitSchema<F>>(\n featureSets: ConditionalFeatureList<F>,\n supportedFeatures: SF,\n): boolean {\n for (const features of featureSets) {\n if (Object.keys(features).every(feature => !!features[feature] === !!supportedFeatures[feature])) {\n return true;\n }\n }\n return false;\n}\n\nexport function ClusterServer<\n F extends BitSchema,\n SF extends TypeFromPartialBitSchema<F>,\n A extends Attributes,\n C extends Commands,\n E extends Events,\n H extends ClusterServerHandlers<Cluster<F, SF, A, C, E>>,\n>(\n clusterDef: Cluster<F, SF, A, C, E>,\n attributesInitialValues: AttributeInitialValues<A>,\n handlers: H,\n supportedEvents: SupportedEventsList<E> = <SupportedEventsList<E>>{},\n): ClusterServerObj<A, E> {\n const {\n id: clusterId,\n name,\n commands: commandDef,\n attributes: attributeDef,\n events: eventDef,\n supportedFeatures,\n } = clusterDef;\n let datasource: ClusterDatasource | undefined;\n const sceneAttributeList = new Array<string>();\n const attributes = <AttributeServers<A>>{};\n const commands = <CommandServers<C>>{};\n const events = <EventServers<E>>{};\n let assignedEndpoint: EndpointInterface | undefined = undefined;\n\n // We pass a proxy into attribute servers so we can swap out our datasource\n // without updating all servers\n //\n // There should always be a datasource when the server is online, so if\n // there is no datasource we just report version as 0 rather than assigning\n // a random version that will be overwritten when we receive a datasource\n const datasourceProxy: ClusterDatasource = {\n get version() {\n return datasource?.version ?? 0;\n },\n\n get eventHandler() {\n return datasource?.eventHandler;\n },\n\n increaseVersion() {\n return datasource?.increaseVersion() ?? 0;\n },\n\n changed(key, value) {\n datasource?.changed(key, value);\n },\n };\n\n const result: any = {\n id: clusterId,\n name,\n _type: \"ClusterServer\",\n attributes,\n _commands: commands,\n _events: events,\n\n get datasource() {\n return datasource;\n },\n\n set datasource(newDatasource: ClusterDatasource<any> | undefined) {\n // This is not legal but TS requires setters to accept getter type\n if (newDatasource === undefined) {\n throw new InternalError(\"Cluster datasource cannot be unset\");\n }\n\n datasource = newDatasource;\n\n if (assignedEndpoint === undefined) {\n throw new InternalError(\n \"The Endpoint always needs to be existing before storage is initialized for an Endpoint.\",\n );\n }\n\n if (typeof handlers.initializeClusterServer === \"function\") {\n handlers.initializeClusterServer({\n attributes,\n events,\n endpoint: assignedEndpoint,\n });\n }\n\n if (datasource.eventHandler) {\n for (const eventName in events) {\n const bindResult = (events as any)[eventName].bindToEventHandler(datasource.eventHandler);\n if (bindResult !== undefined && MaybePromise.is(bindResult)) {\n throw new InternalError(\"Binding events to event handler should never return a promise\");\n }\n }\n }\n },\n\n _assignToEndpoint: (endpoint: EndpointInterface) => {\n for (const name in attributes) {\n (attributes as any)[name].assignToEndpoint(endpoint);\n }\n for (const name in events) {\n (events as any)[name].assignToEndpoint(endpoint);\n }\n assignedEndpoint = endpoint;\n },\n\n _close: () => {\n if (typeof handlers.destroyClusterServer === \"function\") {\n handlers.destroyClusterServer();\n }\n },\n\n _getSceneExtensionFieldSets: () => {\n const values = new Array<TypeFromSchema<typeof Scenes.TlvAttributeValuePair>>();\n for (const name of sceneAttributeList) {\n const attributeServer = (attributes as any)[name];\n values.push({\n attributeId: attributeServer.id,\n attributeValue: attributeServer.schema.encodeTlv(attributeServer.get()),\n });\n }\n return values;\n },\n\n _setSceneExtensionFieldSets: (\n values: TypeFromSchema<typeof Scenes.TlvAttributeValuePair>[],\n _transitionTime: number,\n ) => {\n // TODO It is recommended that, where possible (e.g., it is not possible for attributes with Boolean data type),\n // a gradual transition SHOULD take place from the old to the new state over this time. However, the exact\n // transition is manufacturer dependent.\n\n for (const { attributeId, attributeValue } of values) {\n if (attributeId === undefined) {\n logger.warn(`Empty attributeId in scene extension field not supported for \"set\" yet`);\n continue;\n }\n const attributeName = sceneAttributeList.find(name => (attributes as any)[name].id === attributeId);\n if (attributeName) {\n const attributeServer = (attributes as any)[attributeName];\n attributeServer.setLocal(attributeServer.schema.decodeTlv(attributeValue));\n }\n }\n },\n\n _verifySceneExtensionFieldSets(values: TypeFromSchema<typeof Scenes.TlvAttributeValuePair>[]) {\n for (const { attributeId, attributeValue } of values) {\n if (attributeId === undefined) {\n logger.warn(`Empty attributeId in scene extension field not supported for \"verify\" yet`);\n continue;\n }\n const attributeName = sceneAttributeList.find(name => (attributes as any)[name].id === attributeId);\n if (attributeName) {\n const attributeServer = (attributes as any)[attributeName];\n if (attributeServer.getLocal() !== attributeServer.schema.decodeTlv(attributeValue)) return false;\n }\n }\n return true;\n },\n\n isAttributeSupported: (attributeId: AttributeId) => {\n return (attributes as any).attributeList.getLocal().includes(attributeId);\n },\n\n isAttributeSupportedByName: (attributeName: string) => {\n return (attributesInitialValues as any)[attributeName] !== undefined;\n },\n\n isEventSupported: (eventId: EventId) => {\n return (attributes as any).eventList.getLocal().includes(eventId);\n },\n\n isEventSupportedByName: (eventName: string) => {\n return (supportedEvents as any)[eventName] === true;\n },\n\n isCommandSupported: (commandId: CommandId) => {\n return (attributes as any).acceptedCommandList.getLocal().includes(commandId);\n },\n\n isCommandSupportedByName: (commandName: string) => {\n return (commands as any)[commandName] !== undefined;\n },\n };\n\n // Create attributes\n attributesInitialValues = {\n ...attributesInitialValues,\n clusterRevision: clusterDef.revision,\n featureMap: supportedFeatures,\n attributeList: new Array<AttributeId>(),\n acceptedCommandList: new Array<CommandId>(),\n generatedCommandList: new Array<CommandId>(),\n eventList: new Array<EventId>(),\n };\n\n const attributeList = new Array<AttributeId>();\n for (const attributeName in attributeDef) {\n const capitalizedAttributeName = capitalize(attributeName);\n\n // logger.info(`check this for REQUIRED Attributes ${Logger.toJSON(attributeName)}`)\n if (attributeDef[attributeName].isConditional) {\n const { mandatoryIf, optionalIf } = attributeDef[attributeName];\n let conditionHasMatched = false;\n if (mandatoryIf !== undefined && mandatoryIf.length > 0) {\n // Check if mandatoryIf is relevant for current feature combination and the attribute initial value is set\n const conditionMatched = isConditionMatching(mandatoryIf, supportedFeatures);\n if (conditionMatched && (attributesInitialValues as any)[attributeName] === undefined) {\n logger.warn(\n `InitialAttributeValue for \"${\n clusterDef.name\n }/${attributeName}\" is REQUIRED by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n // TODO Remove optional info/checks\n if (!conditionHasMatched && optionalIf !== undefined && optionalIf.length > 0) {\n const conditionMatched = isConditionMatching(optionalIf, supportedFeatures);\n if (conditionMatched && (attributesInitialValues as any)[attributeName] === undefined) {\n logger.debug(\n `InitialAttributeValue for \"${\n clusterDef.name\n }/${attributeName}\" is optional by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} and is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n\n if (!conditionHasMatched && (attributesInitialValues as any)[attributeName] !== undefined) {\n logger.warn(\n `InitialAttributeValue for \"${\n clusterDef.name\n }/${attributeName}\" is provided but it's neither optional or mandatory for supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is set!`,\n );\n }\n }\n\n const { id, persistent, fabricScoped, scene, fixed } = attributeDef[attributeName];\n if ((attributesInitialValues as any)[attributeName] !== undefined) {\n // Get the handlers for this attribute if present\n const getter = (handlers as any)[`${attributeName}AttributeGetter`];\n const setter = (handlers as any)[`${attributeName}AttributeSetter`];\n const validator = (handlers as any)[`${attributeName}AttributeValidator`];\n\n (attributes as any)[attributeName] = createAttributeServer(\n clusterDef,\n attributeDef[attributeName],\n attributeName,\n (attributesInitialValues as any)[attributeName],\n datasourceProxy,\n getter\n ? (session, endpoint, isFabricFiltered, message) =>\n getter({\n attributes,\n endpoint,\n session,\n isFabricFiltered,\n message,\n })\n : undefined,\n setter\n ? (value, session, endpoint, message) =>\n setter(value, {\n attributes,\n endpoint,\n session,\n message,\n })\n : undefined,\n validator\n ? (value, session, endpoint) =>\n validator(value, {\n attributes,\n endpoint,\n session,\n })\n : undefined,\n );\n\n // Add the relevant convenient methods to the ClusterServerObj\n if (fixed) {\n result[`get${capitalizedAttributeName}Attribute`] = () => (attributes as any)[attributeName].getLocal();\n } else if (fabricScoped) {\n result[`get${capitalizedAttributeName}Attribute`] = (fabric: Fabric) =>\n (attributes as any)[attributeName].getLocalForFabric(fabric);\n result[`set${capitalizedAttributeName}Attribute`] = <T>(value: T, fabric: Fabric) =>\n (attributes as any)[attributeName].setLocalForFabric(value, fabric);\n result[`subscribe${capitalizedAttributeName}Attribute`] = <T>(\n listener: (newValue: T, oldValue: T) => void,\n ) => (attributes as any)[attributeName].addValueSetListener(listener);\n } else {\n if (scene) {\n sceneAttributeList.push(attributeName);\n }\n result[`get${capitalizedAttributeName}Attribute`] = () => (attributes as any)[attributeName].getLocal();\n result[`set${capitalizedAttributeName}Attribute`] = <T>(value: T) =>\n (attributes as any)[attributeName].setLocal(value);\n result[`subscribe${capitalizedAttributeName}Attribute`] = <T>(\n listener: (newValue: T, oldValue: T) => void,\n ) => (attributes as any)[attributeName].addValueSetListener(listener);\n }\n if (persistent || getter || setter) {\n const listener = (value: any) =>\n datasource?.changed(attributeName, fabricScoped || getter || setter ? undefined : value);\n (attributes as any)[attributeName].addValueChangeListener(listener);\n }\n attributeList.push(AttributeId(id));\n } else {\n // TODO: Find maybe a better way to do this including strong typing according to attribute initial values set?\n result[`get${capitalizedAttributeName}Attribute`] = () => undefined;\n if (!fixed) {\n result[`set${capitalizedAttributeName}Attribute`] = () => {\n throw new ImplementationError(\n `Attribute ${attributeName} is optional and not initialized. To use it please initialize it first.`,\n );\n };\n result[`subscribe${capitalizedAttributeName}Attribute`] = () => {\n throw new ImplementationError(\n `Attribute ${attributeName} is optional and not initialized. To use it please initialize it first.`,\n );\n };\n }\n }\n }\n (attributes as any).attributeList.setLocal(attributeList.sort((a, b) => a - b));\n\n // Create commands\n const acceptedCommandList = new Array<CommandId>();\n const generatedCommandList = new Array<CommandId>();\n for (const name in commandDef) {\n const handler = (handlers as any)[name];\n\n if (commandDef[name].isConditional) {\n const { mandatoryIf, optionalIf } = commandDef[name];\n let conditionHasMatched = false;\n if (mandatoryIf !== undefined && mandatoryIf.length > 0) {\n const conditionMatched = isConditionMatching(mandatoryIf, supportedFeatures);\n if (conditionMatched && handler === undefined) {\n logger.warn(\n `Command \"${clusterDef.name}/${name}\" is REQUIRED by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n // TODO Remove optional info/checks\n if (!conditionHasMatched && optionalIf !== undefined && optionalIf.length > 0) {\n const conditionMatched = isConditionMatching(optionalIf, supportedFeatures);\n if (conditionMatched && handler === undefined) {\n logger.debug(\n `Command \"${clusterDef.name}/${name}\" is optional by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} and is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n\n if (!conditionHasMatched && handler !== undefined) {\n logger.warn(\n `Command \"${\n clusterDef.name\n }/${name}\" is provided but it's neither optional nor mandatory for supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is set!`,\n );\n }\n }\n\n if (handler === undefined) continue;\n const { requestId, requestSchema, responseId, responseSchema, timed, invokeAcl } = commandDef[name];\n (commands as any)[name] = new CommandServer(\n requestId,\n responseId,\n name,\n requestSchema,\n responseSchema,\n timed,\n invokeAcl ?? AccessLevel.Operate, //????\n (request, session, message, endpoint) =>\n handler({\n request,\n attributes,\n events,\n session,\n message,\n endpoint,\n }),\n );\n if (!acceptedCommandList.includes(requestId)) {\n acceptedCommandList.push(requestId);\n }\n if (responseSchema !== TlvNoResponse) {\n if (!generatedCommandList.includes(responseId)) {\n generatedCommandList.push(responseId);\n }\n }\n }\n (attributes as any).acceptedCommandList.setLocal(acceptedCommandList.sort((a, b) => a - b));\n (attributes as any).generatedCommandList.setLocal(generatedCommandList.sort((a, b) => a - b));\n\n const eventList = new Array<EventId>();\n for (const eventName in eventDef) {\n const { id, schema, priority, optional, readAcl } = eventDef[eventName];\n if (!optional && (supportedEvents as any)[eventName] !== true) {\n throw new ImplementationError(`Event ${eventName} needs to be supported by cluster ${name} (${clusterId})`);\n }\n\n if (eventDef[eventName].isConditional) {\n const { mandatoryIf, optionalIf } = eventDef[eventName];\n let conditionHasMatched = false;\n if (mandatoryIf !== undefined) {\n const conditionMatched = isConditionMatching(mandatoryIf, supportedFeatures);\n if (conditionMatched && (supportedEvents as any)[eventName] === undefined) {\n logger.warn(\n `Event \"${clusterDef.name}/${eventName}\" is REQUIRED by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n // TODO Remove optional info/checks\n if (!conditionHasMatched && optionalIf !== undefined && optionalIf.length > 0) {\n const conditionMatched = isConditionMatching(optionalIf, supportedFeatures);\n if (conditionMatched && (supportedEvents as any)[eventName] === undefined) {\n logger.debug(\n `Event \"${clusterDef.name}/${eventName}\" is optional by supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} and is not set!`,\n );\n }\n conditionHasMatched = conditionHasMatched || conditionMatched;\n }\n\n if (!conditionHasMatched && (supportedEvents as any)[eventName] !== undefined) {\n logger.warn(\n `Event \"${\n clusterDef.name\n }/${eventName}\" is provided but it's neither optional or mandatory for supportedFeatures: ${Logger.toJSON(\n supportedFeatures,\n )} but is set!`,\n );\n }\n }\n\n if ((supportedEvents as any)[eventName] === true) {\n (events as any)[eventName] = createEventServer(\n clusterDef,\n eventDef[eventName],\n eventName,\n schema,\n priority,\n readAcl,\n );\n const capitalizedEventName = capitalize(eventName);\n result[`trigger${capitalizedEventName}Event`] = <T>(event: T) =>\n (events as any)[eventName].triggerEvent(event);\n eventList.push(id);\n }\n }\n (attributes as any).eventList.setLocal(eventList.sort((a, b) => a - b));\n\n return result as ClusterServerObj<A, E>;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAAmD;AACnD,yBAA4B;AAK5B,oBAAuB;AAGvB,sBAA6B;AAC7B,oBAA2B;AAC3B,qBAQO;AAEP,6BAAsC;AAWtC,2BAA8B;AAC9B,yBAAkC;AAvClC;AAAA;AAAA;AAAA;AAAA;AAyCA,MAAM,SAAS,qBAAO,IAAI,eAAe;AAEzC,SAAS,oBACL,aACA,mBACO;AACP,aAAW,YAAY,aAAa;AAChC,QAAI,OAAO,KAAK,QAAQ,EAAE,MAAM,aAAW,CAAC,CAAC,SAAS,OAAO,MAAM,CAAC,CAAC,kBAAkB,OAAO,CAAC,GAAG;AAC9F,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;AAEO,SAAS,cAQZ,YACA,yBACA,UACA,kBAAkE,CAAC,GAC7C;AACtB,QAAM;AAAA,IACF,IAAI;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR;AAAA,EACJ,IAAI;AACJ,MAAI;AACJ,QAAM,qBAAqB,IAAI,MAAc;AAC7C,QAAM,aAAkC,CAAC;AACzC,QAAM,WAA8B,CAAC;AACrC,QAAM,SAA0B,CAAC;AACjC,MAAI,mBAAkD;AAQtD,QAAM,kBAAqC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C,uBAAuB,eAAe,UAAa,WAAW,SAAS,GAAG;AAC3E,cAAM,mBAAmB,oBAAoB,YAAY,iBAAiB;AAC1E,YAAI,oBAAqB,gBAAwB,SAAS,MAAM,QAAW;AACvE,iBAAO;AAAA,YACH,UAAU,WAAW,IAAI,IAAI,SAAS,uCAAuC,qBAAO;AAAA,cAChF;AAAA,YACJ,CAAC;AAAA,UACL;AAAA,QACJ;AACA,8BAAsB,uBAAuB;AAAA,MACjD;AAEA,UAAI,CAAC,uBAAwB,gBAAwB,SAAS,MAAM,QAAW;AAC3E,eAAO;AAAA,UACH,UACI,WAAW,IACf,IAAI,SAAS,+EAA+E,qBAAO;AAAA,YAC/F;AAAA,UACJ,CAAC;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAEA,QAAK,gBAAwB,SAAS,MAAM,MAAM;AAC9C,MAAC,OAAe,SAAS,QAAI;AAAA,QACzB;AAAA,QACA,SAAS,SAAS;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ;AACA,YAAM,2BAAuB,0BAAW,SAAS;AACjD,aAAO,UAAU,oBAAoB,OAAO,IAAI,CAAI,UAC/C,OAAe,SAAS,EAAE,aAAa,KAAK;AACjD,gBAAU,KAAK,EAAE;AAAA,IACrB;AAAA,EACJ;AACA,EAAC,WAAmB,UAAU,SAAS,UAAU,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC;AAEtE,SAAO;AACX;",
6
6
  "names": ["name"]
7
7
  }
@@ -23,7 +23,7 @@ import { Attribute, AttributeJsType, Attributes, Cluster, Command, Commands, Eve
23
23
  import { Scenes } from "../definitions/ScenesCluster.js";
24
24
  import { AttributeServer, FabricScopedAttributeServer, FixedAttributeServer } from "./AttributeServer.js";
25
25
  import { CommandServer } from "./CommandServer.js";
26
- import { EventServer } from "./EventServer.js";
26
+ import { AnyEventServer } from "./EventServer.js";
27
27
  /** Cluster attributes accessible on the cluster server */
28
28
  type MandatoryAttributeServers<A extends Attributes> = Omit<{
29
29
  [P in MandatoryAttributeNames<A>]: A[P] extends FabricScopedAttribute<any, any> ? FabricScopedAttributeServer<AttributeJsType<A[P]>> : A[P] extends WritableFabricScopedAttribute<any, any> ? FabricScopedAttributeServer<AttributeJsType<A[P]>> : A[P] extends FixedAttribute<any, any> ? FixedAttributeServer<AttributeJsType<A[P]>> : AttributeServer<AttributeJsType<A[P]>>;
@@ -135,9 +135,9 @@ type ServerAttributeSubscribers<A extends Attributes> = {
135
135
  [P in FabricScopedAttributeNames<A> as `subscribe${Capitalize<string & P>}Attribute`]: (listener: (newValue: AttributeJsType<A[P]>, oldValue: AttributeJsType<A[P]>) => void, fabric: Fabric) => void;
136
136
  };
137
137
  export type EventServers<E extends Events> = Merge<{
138
- [P in MandatoryEventNames<E>]: EventServer<EventType<E[P]>, any>;
138
+ [P in MandatoryEventNames<E>]: AnyEventServer<EventType<E[P]>, any>;
139
139
  }, {
140
- [P in OptionalEventNames<E>]?: EventServer<EventType<E[P]>, any>;
140
+ [P in OptionalEventNames<E>]?: AnyEventServer<EventType<E[P]>, any>;
141
141
  }>;
142
142
  type ServerEventTriggers<E extends Events> = {
143
143
  [P in MandatoryEventNames<E> as `trigger${Capitalize<string & P>}Event`]: (event: EventType<E[P]>) => void;