@matter/protocol 0.16.0-alpha.0-20251213-e83db3732 → 0.16.0-alpha.0-20251217-038f88085

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 (309) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/action/client/ClientInteraction.d.ts +12 -5
  3. package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
  4. package/dist/cjs/action/client/ClientInteraction.js +39 -15
  5. package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
  6. package/dist/cjs/action/client/ClientRead.d.ts +10 -0
  7. package/dist/cjs/action/client/ClientRead.d.ts.map +1 -0
  8. package/dist/cjs/action/client/ClientRead.js +22 -0
  9. package/dist/cjs/action/client/ClientRead.js.map +6 -0
  10. package/dist/cjs/action/client/ClientRequest.d.ts +20 -0
  11. package/dist/cjs/action/client/ClientRequest.d.ts.map +1 -0
  12. package/dist/cjs/action/client/ClientRequest.js +22 -0
  13. package/dist/cjs/action/client/ClientRequest.js.map +6 -0
  14. package/dist/cjs/action/client/ClientWrite.d.ts +10 -0
  15. package/dist/cjs/action/client/ClientWrite.d.ts.map +1 -0
  16. package/dist/cjs/action/client/ClientWrite.js +22 -0
  17. package/dist/cjs/action/client/ClientWrite.js.map +6 -0
  18. package/dist/cjs/action/client/QueuedClientInteraction.d.ts +49 -0
  19. package/dist/cjs/action/client/QueuedClientInteraction.d.ts.map +1 -0
  20. package/dist/cjs/action/client/QueuedClientInteraction.js +160 -0
  21. package/dist/cjs/action/client/QueuedClientInteraction.js.map +6 -0
  22. package/dist/cjs/action/client/index.d.ts +4 -0
  23. package/dist/cjs/action/client/index.d.ts.map +1 -1
  24. package/dist/cjs/action/client/index.js +4 -0
  25. package/dist/cjs/action/client/index.js.map +1 -1
  26. package/dist/cjs/action/client/subscription/ClientSubscribe.d.ts +2 -1
  27. package/dist/cjs/action/client/subscription/ClientSubscribe.d.ts.map +1 -1
  28. package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
  29. package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +14 -3
  30. package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
  31. package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts +1 -1
  32. package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
  33. package/dist/cjs/action/client/subscription/SustainedSubscription.js +1 -4
  34. package/dist/cjs/action/client/subscription/SustainedSubscription.js.map +1 -1
  35. package/dist/cjs/action/request/Invoke.d.ts +7 -1
  36. package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
  37. package/dist/cjs/action/request/Invoke.js +0 -3
  38. package/dist/cjs/action/request/Invoke.js.map +1 -1
  39. package/dist/cjs/action/request/Read.d.ts.map +1 -1
  40. package/dist/cjs/action/request/Read.js +3 -2
  41. package/dist/cjs/action/request/Read.js.map +1 -1
  42. package/dist/cjs/action/request/Specifier.d.ts +1 -1
  43. package/dist/cjs/action/request/Specifier.d.ts.map +1 -1
  44. package/dist/cjs/action/request/Specifier.js +3 -0
  45. package/dist/cjs/action/request/Specifier.js.map +1 -1
  46. package/dist/cjs/action/request/Write.d.ts +1 -0
  47. package/dist/cjs/action/request/Write.d.ts.map +1 -1
  48. package/dist/cjs/action/request/Write.js +10 -2
  49. package/dist/cjs/action/request/Write.js.map +1 -1
  50. package/dist/cjs/action/response/ReadResult.d.ts +1 -1
  51. package/dist/cjs/action/response/ReadResult.d.ts.map +1 -1
  52. package/dist/cjs/cluster/client/ClusterClientTypes.d.ts +37 -8
  53. package/dist/cjs/cluster/client/ClusterClientTypes.d.ts.map +1 -1
  54. package/dist/cjs/cluster/client/index.d.ts +0 -3
  55. package/dist/cjs/cluster/client/index.d.ts.map +1 -1
  56. package/dist/cjs/cluster/client/index.js +0 -3
  57. package/dist/cjs/cluster/client/index.js.map +1 -1
  58. package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
  59. package/dist/cjs/interaction/InteractionMessenger.js +3 -2
  60. package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
  61. package/dist/cjs/interaction/SubscriptionClient.d.ts.map +1 -1
  62. package/dist/cjs/interaction/SubscriptionClient.js +2 -1
  63. package/dist/cjs/interaction/SubscriptionClient.js.map +1 -1
  64. package/dist/cjs/interaction/index.d.ts +1 -1
  65. package/dist/cjs/interaction/index.d.ts.map +1 -1
  66. package/dist/cjs/interaction/index.js +1 -1
  67. package/dist/cjs/interaction/index.js.map +1 -1
  68. package/dist/cjs/peer/CommissioningError.d.ts +13 -0
  69. package/dist/cjs/peer/CommissioningError.d.ts.map +1 -0
  70. package/dist/cjs/peer/CommissioningError.js +32 -0
  71. package/dist/cjs/peer/CommissioningError.js.map +6 -0
  72. package/dist/cjs/peer/ControllerCommissioner.d.ts +2 -3
  73. package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
  74. package/dist/cjs/peer/ControllerCommissioner.js +20 -13
  75. package/dist/cjs/peer/ControllerCommissioner.js.map +2 -2
  76. package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +7 -16
  77. package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  78. package/dist/cjs/peer/ControllerCommissioningFlow.js +395 -178
  79. package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
  80. package/dist/cjs/peer/ControllerDiscovery.d.ts +4 -0
  81. package/dist/cjs/peer/ControllerDiscovery.d.ts.map +1 -1
  82. package/dist/cjs/peer/ControllerDiscovery.js +6 -3
  83. package/dist/cjs/peer/ControllerDiscovery.js.map +1 -1
  84. package/dist/cjs/peer/InteractionQueue.d.ts +2 -2
  85. package/dist/cjs/peer/InteractionQueue.d.ts.map +1 -1
  86. package/dist/cjs/peer/InteractionQueue.js +1 -1
  87. package/dist/cjs/peer/InteractionQueue.js.map +1 -1
  88. package/dist/cjs/peer/PeerAddressStore.d.ts +0 -9
  89. package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -1
  90. package/dist/cjs/peer/PeerAddressStore.js.map +1 -1
  91. package/dist/cjs/peer/PeerSet.d.ts +0 -2
  92. package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
  93. package/dist/cjs/peer/PeerSet.js +32 -18
  94. package/dist/cjs/peer/PeerSet.js.map +1 -1
  95. package/dist/cjs/peer/PhysicalDeviceProperties.js +1 -1
  96. package/dist/cjs/peer/PhysicalDeviceProperties.js.map +1 -1
  97. package/dist/cjs/peer/index.d.ts +1 -0
  98. package/dist/cjs/peer/index.d.ts.map +1 -1
  99. package/dist/cjs/peer/index.js +1 -0
  100. package/dist/cjs/peer/index.js.map +1 -1
  101. package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
  102. package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
  103. package/dist/cjs/protocol/ExchangeManager.js +2 -2
  104. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  105. package/dist/cjs/protocol/ExchangeProvider.d.ts +13 -4
  106. package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
  107. package/dist/cjs/protocol/ExchangeProvider.js +5 -3
  108. package/dist/cjs/protocol/ExchangeProvider.js.map +1 -1
  109. package/dist/cjs/session/NodeSession.d.ts +5 -2
  110. package/dist/cjs/session/NodeSession.d.ts.map +1 -1
  111. package/dist/cjs/session/NodeSession.js +5 -4
  112. package/dist/cjs/session/NodeSession.js.map +1 -1
  113. package/dist/cjs/session/Session.d.ts +5 -3
  114. package/dist/cjs/session/Session.d.ts.map +1 -1
  115. package/dist/cjs/session/Session.js +8 -4
  116. package/dist/cjs/session/Session.js.map +1 -1
  117. package/dist/cjs/session/SessionManager.d.ts +8 -0
  118. package/dist/cjs/session/SessionManager.d.ts.map +1 -1
  119. package/dist/cjs/session/SessionManager.js +16 -2
  120. package/dist/cjs/session/SessionManager.js.map +1 -1
  121. package/dist/esm/action/client/ClientInteraction.d.ts +12 -5
  122. package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
  123. package/dist/esm/action/client/ClientInteraction.js +42 -16
  124. package/dist/esm/action/client/ClientInteraction.js.map +1 -1
  125. package/dist/esm/action/client/ClientRead.d.ts +10 -0
  126. package/dist/esm/action/client/ClientRead.d.ts.map +1 -0
  127. package/dist/esm/action/client/ClientRead.js +6 -0
  128. package/dist/esm/action/client/ClientRead.js.map +6 -0
  129. package/dist/esm/action/client/ClientRequest.d.ts +20 -0
  130. package/dist/esm/action/client/ClientRequest.d.ts.map +1 -0
  131. package/dist/esm/action/client/ClientRequest.js +6 -0
  132. package/dist/esm/action/client/ClientRequest.js.map +6 -0
  133. package/dist/esm/action/client/ClientWrite.d.ts +10 -0
  134. package/dist/esm/action/client/ClientWrite.d.ts.map +1 -0
  135. package/dist/esm/action/client/ClientWrite.js +6 -0
  136. package/dist/esm/action/client/ClientWrite.js.map +6 -0
  137. package/dist/esm/action/client/QueuedClientInteraction.d.ts +49 -0
  138. package/dist/esm/action/client/QueuedClientInteraction.d.ts.map +1 -0
  139. package/dist/esm/action/client/QueuedClientInteraction.js +140 -0
  140. package/dist/esm/action/client/QueuedClientInteraction.js.map +6 -0
  141. package/dist/esm/action/client/index.d.ts +4 -0
  142. package/dist/esm/action/client/index.d.ts.map +1 -1
  143. package/dist/esm/action/client/index.js +4 -0
  144. package/dist/esm/action/client/index.js.map +1 -1
  145. package/dist/esm/action/client/subscription/ClientSubscribe.d.ts +2 -1
  146. package/dist/esm/action/client/subscription/ClientSubscribe.d.ts.map +1 -1
  147. package/dist/esm/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
  148. package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +14 -3
  149. package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
  150. package/dist/esm/action/client/subscription/SustainedSubscription.d.ts +1 -1
  151. package/dist/esm/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
  152. package/dist/esm/action/client/subscription/SustainedSubscription.js +1 -4
  153. package/dist/esm/action/client/subscription/SustainedSubscription.js.map +1 -1
  154. package/dist/esm/action/request/Invoke.d.ts +7 -1
  155. package/dist/esm/action/request/Invoke.d.ts.map +1 -1
  156. package/dist/esm/action/request/Invoke.js +0 -3
  157. package/dist/esm/action/request/Invoke.js.map +1 -1
  158. package/dist/esm/action/request/Read.d.ts.map +1 -1
  159. package/dist/esm/action/request/Read.js +3 -2
  160. package/dist/esm/action/request/Read.js.map +1 -1
  161. package/dist/esm/action/request/Specifier.d.ts +1 -1
  162. package/dist/esm/action/request/Specifier.d.ts.map +1 -1
  163. package/dist/esm/action/request/Specifier.js +3 -0
  164. package/dist/esm/action/request/Specifier.js.map +1 -1
  165. package/dist/esm/action/request/Write.d.ts +1 -0
  166. package/dist/esm/action/request/Write.d.ts.map +1 -1
  167. package/dist/esm/action/request/Write.js +10 -2
  168. package/dist/esm/action/request/Write.js.map +1 -1
  169. package/dist/esm/action/response/ReadResult.d.ts +1 -1
  170. package/dist/esm/action/response/ReadResult.d.ts.map +1 -1
  171. package/dist/esm/cluster/client/ClusterClientTypes.d.ts +37 -8
  172. package/dist/esm/cluster/client/ClusterClientTypes.d.ts.map +1 -1
  173. package/dist/esm/cluster/client/index.d.ts +0 -3
  174. package/dist/esm/cluster/client/index.d.ts.map +1 -1
  175. package/dist/esm/cluster/client/index.js +0 -3
  176. package/dist/esm/cluster/client/index.js.map +1 -1
  177. package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
  178. package/dist/esm/interaction/InteractionMessenger.js +4 -3
  179. package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
  180. package/dist/esm/interaction/SubscriptionClient.d.ts.map +1 -1
  181. package/dist/esm/interaction/SubscriptionClient.js +2 -1
  182. package/dist/esm/interaction/SubscriptionClient.js.map +1 -1
  183. package/dist/esm/interaction/index.d.ts +1 -1
  184. package/dist/esm/interaction/index.d.ts.map +1 -1
  185. package/dist/esm/interaction/index.js +1 -1
  186. package/dist/esm/peer/CommissioningError.d.ts +13 -0
  187. package/dist/esm/peer/CommissioningError.d.ts.map +1 -0
  188. package/dist/esm/peer/CommissioningError.js +12 -0
  189. package/dist/esm/peer/CommissioningError.js.map +6 -0
  190. package/dist/esm/peer/ControllerCommissioner.d.ts +2 -3
  191. package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
  192. package/dist/esm/peer/ControllerCommissioner.js +19 -13
  193. package/dist/esm/peer/ControllerCommissioner.js.map +2 -2
  194. package/dist/esm/peer/ControllerCommissioningFlow.d.ts +7 -16
  195. package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  196. package/dist/esm/peer/ControllerCommissioningFlow.js +380 -162
  197. package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
  198. package/dist/esm/peer/ControllerDiscovery.d.ts +4 -0
  199. package/dist/esm/peer/ControllerDiscovery.d.ts.map +1 -1
  200. package/dist/esm/peer/ControllerDiscovery.js +4 -1
  201. package/dist/esm/peer/ControllerDiscovery.js.map +1 -1
  202. package/dist/esm/peer/InteractionQueue.d.ts +2 -2
  203. package/dist/esm/peer/InteractionQueue.d.ts.map +1 -1
  204. package/dist/esm/peer/InteractionQueue.js +2 -2
  205. package/dist/esm/peer/InteractionQueue.js.map +1 -1
  206. package/dist/esm/peer/PeerAddressStore.d.ts +0 -9
  207. package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -1
  208. package/dist/esm/peer/PeerAddressStore.js.map +1 -1
  209. package/dist/esm/peer/PeerSet.d.ts +0 -2
  210. package/dist/esm/peer/PeerSet.d.ts.map +1 -1
  211. package/dist/esm/peer/PeerSet.js +32 -18
  212. package/dist/esm/peer/PeerSet.js.map +1 -1
  213. package/dist/esm/peer/PhysicalDeviceProperties.js +1 -1
  214. package/dist/esm/peer/PhysicalDeviceProperties.js.map +1 -1
  215. package/dist/esm/peer/index.d.ts +1 -0
  216. package/dist/esm/peer/index.d.ts.map +1 -1
  217. package/dist/esm/peer/index.js +1 -0
  218. package/dist/esm/peer/index.js.map +1 -1
  219. package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
  220. package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
  221. package/dist/esm/protocol/ExchangeManager.js +2 -2
  222. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  223. package/dist/esm/protocol/ExchangeProvider.d.ts +13 -4
  224. package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
  225. package/dist/esm/protocol/ExchangeProvider.js +5 -3
  226. package/dist/esm/protocol/ExchangeProvider.js.map +1 -1
  227. package/dist/esm/session/NodeSession.d.ts +5 -2
  228. package/dist/esm/session/NodeSession.d.ts.map +1 -1
  229. package/dist/esm/session/NodeSession.js +5 -4
  230. package/dist/esm/session/NodeSession.js.map +1 -1
  231. package/dist/esm/session/Session.d.ts +5 -3
  232. package/dist/esm/session/Session.d.ts.map +1 -1
  233. package/dist/esm/session/Session.js +8 -4
  234. package/dist/esm/session/Session.js.map +1 -1
  235. package/dist/esm/session/SessionManager.d.ts +8 -0
  236. package/dist/esm/session/SessionManager.d.ts.map +1 -1
  237. package/dist/esm/session/SessionManager.js +17 -2
  238. package/dist/esm/session/SessionManager.js.map +1 -1
  239. package/package.json +6 -6
  240. package/src/action/client/ClientInteraction.ts +58 -19
  241. package/src/action/client/ClientRead.ts +10 -0
  242. package/src/action/client/ClientRequest.ts +20 -0
  243. package/src/action/client/ClientWrite.ts +10 -0
  244. package/src/action/client/QueuedClientInteraction.ts +91 -0
  245. package/src/action/client/index.ts +4 -0
  246. package/src/action/client/subscription/ClientSubscribe.ts +2 -1
  247. package/src/action/client/subscription/ClientSubscriptionHandler.ts +14 -3
  248. package/src/action/client/subscription/SustainedSubscription.ts +6 -9
  249. package/src/action/request/Invoke.ts +11 -4
  250. package/src/action/request/Read.ts +3 -2
  251. package/src/action/request/Specifier.ts +4 -1
  252. package/src/action/request/Write.ts +11 -2
  253. package/src/action/response/ReadResult.ts +1 -1
  254. package/src/cluster/client/ClusterClientTypes.ts +47 -7
  255. package/src/cluster/client/index.ts +0 -3
  256. package/src/interaction/InteractionMessenger.ts +5 -4
  257. package/src/interaction/SubscriptionClient.ts +2 -1
  258. package/src/interaction/index.ts +1 -1
  259. package/src/peer/CommissioningError.ts +13 -0
  260. package/src/peer/ControllerCommissioner.ts +21 -13
  261. package/src/peer/ControllerCommissioningFlow.ts +418 -186
  262. package/src/peer/ControllerDiscovery.ts +4 -1
  263. package/src/peer/InteractionQueue.ts +2 -2
  264. package/src/peer/PeerAddressStore.ts +0 -9
  265. package/src/peer/PeerSet.ts +56 -23
  266. package/src/peer/PhysicalDeviceProperties.ts +1 -1
  267. package/src/peer/index.ts +1 -0
  268. package/src/protocol/DeviceCommissioner.ts +0 -1
  269. package/src/protocol/ExchangeManager.ts +2 -2
  270. package/src/protocol/ExchangeProvider.ts +9 -7
  271. package/src/session/NodeSession.ts +5 -4
  272. package/src/session/Session.ts +8 -4
  273. package/src/session/SessionManager.ts +19 -2
  274. package/dist/cjs/cluster/client/AttributeClient.d.ts +0 -75
  275. package/dist/cjs/cluster/client/AttributeClient.d.ts.map +0 -1
  276. package/dist/cjs/cluster/client/AttributeClient.js +0 -209
  277. package/dist/cjs/cluster/client/AttributeClient.js.map +0 -6
  278. package/dist/cjs/cluster/client/ClusterClient.d.ts +0 -11
  279. package/dist/cjs/cluster/client/ClusterClient.d.ts.map +0 -1
  280. package/dist/cjs/cluster/client/ClusterClient.js +0 -335
  281. package/dist/cjs/cluster/client/ClusterClient.js.map +0 -6
  282. package/dist/cjs/cluster/client/EventClient.d.ts +0 -33
  283. package/dist/cjs/cluster/client/EventClient.d.ts.map +0 -1
  284. package/dist/cjs/cluster/client/EventClient.js +0 -89
  285. package/dist/cjs/cluster/client/EventClient.js.map +0 -6
  286. package/dist/cjs/interaction/InteractionClient.d.ts +0 -375
  287. package/dist/cjs/interaction/InteractionClient.d.ts.map +0 -1
  288. package/dist/cjs/interaction/InteractionClient.js +0 -1046
  289. package/dist/cjs/interaction/InteractionClient.js.map +0 -6
  290. package/dist/esm/cluster/client/AttributeClient.d.ts +0 -75
  291. package/dist/esm/cluster/client/AttributeClient.d.ts.map +0 -1
  292. package/dist/esm/cluster/client/AttributeClient.js +0 -189
  293. package/dist/esm/cluster/client/AttributeClient.js.map +0 -6
  294. package/dist/esm/cluster/client/ClusterClient.d.ts +0 -11
  295. package/dist/esm/cluster/client/ClusterClient.d.ts.map +0 -1
  296. package/dist/esm/cluster/client/ClusterClient.js +0 -320
  297. package/dist/esm/cluster/client/ClusterClient.js.map +0 -6
  298. package/dist/esm/cluster/client/EventClient.d.ts +0 -33
  299. package/dist/esm/cluster/client/EventClient.d.ts.map +0 -1
  300. package/dist/esm/cluster/client/EventClient.js +0 -69
  301. package/dist/esm/cluster/client/EventClient.js.map +0 -6
  302. package/dist/esm/interaction/InteractionClient.d.ts +0 -375
  303. package/dist/esm/interaction/InteractionClient.d.ts.map +0 -1
  304. package/dist/esm/interaction/InteractionClient.js +0 -1047
  305. package/dist/esm/interaction/InteractionClient.js.map +0 -6
  306. package/src/cluster/client/AttributeClient.ts +0 -230
  307. package/src/cluster/client/ClusterClient.ts +0 -433
  308. package/src/cluster/client/EventClient.ts +0 -99
  309. package/src/interaction/InteractionClient.ts +0 -1614
@@ -3,6 +3,8 @@
3
3
  * Copyright 2022-2025 Matter.js Authors
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { Invoke } from "#action/request/Invoke.js";
7
+ import { Read } from "#action/request/Read.js";
6
8
  import { Certificate } from "#certificate/kinds/Certificate.js";
7
9
  import { BasicInformation } from "#clusters/basic-information";
8
10
  import { Descriptor } from "#clusters/descriptor";
@@ -15,9 +17,9 @@ import {
15
17
  ChannelType,
16
18
  Diagnostic,
17
19
  Duration,
20
+ ImplementationError,
18
21
  Instant,
19
22
  Logger,
20
- MatterError,
21
23
  Millis,
22
24
  Minutes,
23
25
  repackErrorAs,
@@ -29,10 +31,11 @@ import {
29
31
  } from "#general";
30
32
  import {
31
33
  EndpointNumber,
34
+ Status,
32
35
  StatusResponseError
33
36
  } from "#types";
34
- import { ClusterClient } from "../cluster/client/ClusterClient.js";
35
37
  import { TlvCertSigningRequest } from "../common/OperationalCredentialsTypes.js";
38
+ import { CommissioningError } from "./CommissioningError.js";
36
39
  const logger = Logger.get("ControllerCommissioner");
37
40
  var CommissioningStepResultCode = /* @__PURE__ */ ((CommissioningStepResultCode2) => {
38
41
  CommissioningStepResultCode2[CommissioningStepResultCode2["Success"] = 0] = "Success";
@@ -41,8 +44,6 @@ var CommissioningStepResultCode = /* @__PURE__ */ ((CommissioningStepResultCode2
41
44
  CommissioningStepResultCode2[CommissioningStepResultCode2["Stop"] = 3] = "Stop";
42
45
  return CommissioningStepResultCode2;
43
46
  })(CommissioningStepResultCode || {});
44
- class CommissioningError extends MatterError {
45
- }
46
47
  class MaximumCommissionedFabricsReachedError extends CommissioningError {
47
48
  }
48
49
  class CommissioningTimeoutError extends CommissioningError {
@@ -59,15 +60,14 @@ class ThreadNetworkSetupFailedError extends CommissioningError {
59
60
  }
60
61
  class NodeIdConflictError extends CommissioningError {
61
62
  }
62
- class CommissionableDeviceDiscoveryFailedError extends CommissioningError {
63
- }
64
63
  class OperativeConnectionFailedError extends CommissioningError {
65
64
  }
66
65
  class RecoverableCommissioningError extends CommissioningError {
67
66
  }
68
67
  const DEFAULT_FAILSAFE_TIME = Minutes.one;
68
+ const RootEndpointNumber = EndpointNumber(0);
69
69
  class ControllerCommissioningFlow {
70
- interactionClient;
70
+ interaction;
71
71
  ca;
72
72
  fabric;
73
73
  transitionToCase;
@@ -81,8 +81,8 @@ class ControllerCommissioningFlow {
81
81
  lastBreadcrumb = 1;
82
82
  collectedCommissioningData = {};
83
83
  #defaultFailSafeTime = DEFAULT_FAILSAFE_TIME;
84
- constructor(interactionClient, ca, fabric, commissioningOptions, transitionToCase) {
85
- this.interactionClient = interactionClient;
84
+ constructor(interaction, ca, fabric, commissioningOptions, transitionToCase) {
85
+ this.interaction = interaction;
86
86
  this.ca = ca;
87
87
  this.fabric = fabric;
88
88
  this.transitionToCase = transitionToCase;
@@ -150,24 +150,58 @@ class ControllerCommissioningFlow {
150
150
  }
151
151
  }
152
152
  /**
153
- * Helper method to create ClusterClients. If not feature specific and for the Root Endpoint they are also reused.
153
+ * Convenience method to get a number of attributes in a read and return exactly these values in the order as
154
+ * defined in the request
154
155
  */
155
- #getClusterClient(cluster, endpointId = EndpointNumber(0), isFeatureSpecific = false) {
156
- if (!isFeatureSpecific && endpointId === 0) {
157
- const clusterClient = this.#clusterClients.get(cluster.id);
158
- if (clusterClient !== void 0) {
159
- logger.debug(
160
- `Returning existing cluster client for cluster ${cluster.name} (endpoint ${endpointId}, isFeatureSpecific ${isFeatureSpecific})`
161
- );
162
- return clusterClient;
156
+ async #readConcreteAttributeValues(request) {
157
+ const attributeMap = /* @__PURE__ */ new Map();
158
+ if (request.attributeRequests === void 0) {
159
+ throw new ImplementationError("Can only handle Attribute reads");
160
+ }
161
+ for (const { endpointId, clusterId, attributeId } of request.attributeRequests) {
162
+ if (endpointId === void 0 || clusterId === void 0) {
163
+ continue;
164
+ }
165
+ attributeMap.set(`${endpointId}-${clusterId}-${attributeId}`, void 0);
166
+ }
167
+ for await (const data of this.interaction.read(request)) {
168
+ for (const entry of data) {
169
+ if (entry.kind !== "attr-value") {
170
+ continue;
171
+ }
172
+ const {
173
+ path: { endpointId, clusterId, attributeId },
174
+ value
175
+ } = entry;
176
+ const key = `${endpointId}-${clusterId}-${attributeId}`;
177
+ if (!attributeMap.has(key)) {
178
+ continue;
179
+ }
180
+ attributeMap.set(key, value);
181
+ }
182
+ }
183
+ return [...attributeMap.values()];
184
+ }
185
+ // TODO improve response typing
186
+ async #invokeCommand(request, options = {}) {
187
+ for await (const data of this.interaction.invoke(
188
+ Invoke({
189
+ commands: [request],
190
+ ...options
191
+ })
192
+ )) {
193
+ for (const entry of data) {
194
+ switch (entry.kind) {
195
+ case "cmd-status":
196
+ if (entry.status !== Status.Success) {
197
+ throw StatusResponseError.create(entry.status, void 0, entry.clusterStatus);
198
+ }
199
+ return;
200
+ case "cmd-response":
201
+ return entry.data;
202
+ }
163
203
  }
164
204
  }
165
- logger.debug(
166
- `Creating new cluster client for cluster ${cluster.name} (endpoint ${endpointId}, isFeatureSpecific ${isFeatureSpecific})`
167
- );
168
- const client = ClusterClient(cluster, endpointId, this.interactionClient);
169
- this.#clusterClients.set(cluster.id, client);
170
- return client;
171
205
  }
172
206
  /**
173
207
  * Initialize commissioning steps and add them in the default order as defined by
@@ -218,7 +252,7 @@ class ControllerCommissioningFlow {
218
252
  name: "AccessControl",
219
253
  stepLogic: () => this.#configureAccessControlLists()
220
254
  });
221
- if (this.interactionClient.channelType === ChannelType.BLE) {
255
+ if (this.interaction.channelType === ChannelType.BLE) {
222
256
  this.commissioningSteps.push({
223
257
  stepNumber: 16,
224
258
  subStepNumber: 1,
@@ -247,7 +281,7 @@ class ControllerCommissioningFlow {
247
281
  }
248
282
  } else {
249
283
  logger.info(
250
- `Skipping NetworkCommissioning steps because the device is already on IP network (${this.interactionClient.channelType})`
284
+ `Skipping NetworkCommissioning steps because the device is already on IP network (${this.interaction.channelType})`
251
285
  );
252
286
  }
253
287
  this.commissioningSteps.push({
@@ -321,49 +355,84 @@ class ControllerCommissioningFlow {
321
355
  * Initial Step to receive some common data used by other steps
322
356
  */
323
357
  async #getInitialData() {
324
- const operationalCredentialsClient = this.#getClusterClient(OperationalCredentials.Cluster);
325
- const supportedFabrics = await operationalCredentialsClient.getSupportedFabricsAttribute();
326
- const commissionedFabrics = await operationalCredentialsClient.getCommissionedFabricsAttribute();
358
+ const [
359
+ supportedFabrics,
360
+ commissionedFabrics,
361
+ rootPartsList,
362
+ rootServerList,
363
+ vendorId,
364
+ productId,
365
+ productName,
366
+ supportsConcurrentConnection
367
+ ] = await this.#readConcreteAttributeValues(
368
+ Read(
369
+ Read.Attribute({
370
+ endpoint: RootEndpointNumber,
371
+ cluster: OperationalCredentials.Complete,
372
+ attributes: ["supportedFabrics", "commissionedFabrics"]
373
+ }),
374
+ Read.Attribute({
375
+ endpoint: RootEndpointNumber,
376
+ cluster: Descriptor.Complete,
377
+ attributes: ["partsList", "serverList"]
378
+ }),
379
+ Read.Attribute({
380
+ endpoint: RootEndpointNumber,
381
+ cluster: BasicInformation.Complete,
382
+ attributes: ["vendorId", "productId", "productName"]
383
+ }),
384
+ Read.Attribute({
385
+ endpoint: RootEndpointNumber,
386
+ cluster: GeneralCommissioning.Complete,
387
+ attributes: ["supportsConcurrentConnection"]
388
+ })
389
+ )
390
+ );
327
391
  if (commissionedFabrics >= supportedFabrics) {
328
392
  throw new MaximumCommissionedFabricsReachedError(
329
393
  `Commissioned fabrics (${commissionedFabrics}) exceed supported fabrics (${supportedFabrics}). Please remove some fabrics before commissioning.`
330
394
  );
331
395
  }
332
- const descriptorClient = this.#getClusterClient(Descriptor.Cluster);
333
- this.collectedCommissioningData.rootPartsList = await descriptorClient.getPartsListAttribute();
334
- this.collectedCommissioningData.rootServerList = await descriptorClient.getServerListAttribute();
335
- const networkData = await this.interactionClient.getMultipleAttributes({
336
- attributes: [
337
- {
338
- clusterId: NetworkCommissioning.Complete.id,
339
- attributeId: NetworkCommissioning.Complete.attributes.featureMap.id
340
- },
341
- {
342
- clusterId: NetworkCommissioning.Complete.id,
343
- attributeId: NetworkCommissioning.Complete.attributes.networks.id
344
- }
345
- ]
346
- });
396
+ this.collectedCommissioningData.rootPartsList = rootPartsList;
397
+ this.collectedCommissioningData.rootServerList = rootServerList;
398
+ this.collectedCommissioningData.vendorId = vendorId;
399
+ this.collectedCommissioningData.productId = productId;
400
+ this.collectedCommissioningData.productName = productName;
401
+ this.collectedCommissioningData.supportsConcurrentConnection = supportsConcurrentConnection;
402
+ const networkData = this.interaction.read(
403
+ Read(
404
+ Read.Attribute({
405
+ cluster: NetworkCommissioning.Complete,
406
+ attributes: ["featureMap", "networks"]
407
+ })
408
+ )
409
+ );
347
410
  const networkFeatures = new Array();
348
411
  const networkStatus = new Array();
349
- for (const {
350
- path: { endpointId, attributeId },
351
- value
352
- } of networkData) {
353
- if (attributeId === NetworkCommissioning.Complete.attributes.featureMap.id) {
354
- networkFeatures.push({ endpointId, value });
355
- } else if (attributeId === NetworkCommissioning.Complete.attributes.networks.id) {
356
- networkStatus.push({ endpointId, value });
412
+ for await (const data of networkData) {
413
+ for (const entry of data) {
414
+ if (entry.kind !== "attr-value") {
415
+ continue;
416
+ }
417
+ const {
418
+ path: { endpointId, attributeId },
419
+ value
420
+ } = entry;
421
+ if (attributeId === NetworkCommissioning.Complete.attributes.featureMap.id) {
422
+ networkFeatures.push({
423
+ endpointId,
424
+ value
425
+ });
426
+ } else if (attributeId === NetworkCommissioning.Complete.attributes.networks.id) {
427
+ networkStatus.push({
428
+ endpointId,
429
+ value
430
+ });
431
+ }
357
432
  }
358
433
  }
359
434
  this.collectedCommissioningData.networkFeatures = networkFeatures;
360
435
  this.collectedCommissioningData.networkStatus = networkStatus;
361
- const basicInfoClient = this.#getClusterClient(BasicInformation.Cluster);
362
- this.collectedCommissioningData.vendorId = await basicInfoClient.getVendorIdAttribute();
363
- this.collectedCommissioningData.productId = await basicInfoClient.getProductIdAttribute();
364
- this.collectedCommissioningData.productName = await basicInfoClient.getProductNameAttribute();
365
- const generalCommissioningClient = this.#getClusterClient(GeneralCommissioning.Cluster);
366
- this.collectedCommissioningData.supportsConcurrentConnection = await generalCommissioningClient.getSupportsConcurrentConnectionAttribute();
367
436
  return {
368
437
  code: 0 /* Success */,
369
438
  breadcrumb: this.lastBreadcrumb
@@ -379,9 +448,16 @@ class ControllerCommissioningFlow {
379
448
  * Attribute”) prior to invoking the ArmFailSafe command.
380
449
  */
381
450
  async #armFailsafe(time) {
382
- const client = this.#getClusterClient(GeneralCommissioning.Cluster);
383
451
  if (this.collectedCommissioningData.basicCommissioningInfo === void 0) {
384
- const basicCommissioningInfo = await client.getBasicCommissioningInfoAttribute();
452
+ const [basicCommissioningInfo] = await this.#readConcreteAttributeValues(
453
+ Read(
454
+ Read.Attribute({
455
+ endpoint: RootEndpointNumber,
456
+ cluster: GeneralCommissioning.Complete,
457
+ attributes: ["basicCommissioningInfo"]
458
+ })
459
+ )
460
+ );
385
461
  this.collectedCommissioningData.basicCommissioningInfo = basicCommissioningInfo;
386
462
  this.#defaultFailSafeTime = Seconds(basicCommissioningInfo.failSafeExpiryLengthSeconds);
387
463
  this.#commissioningStartedTime = Time.nowMs;
@@ -392,9 +468,14 @@ class ControllerCommissioningFlow {
392
468
  const expiryLength = time ?? this.#defaultFailSafeTime;
393
469
  this.#ensureGeneralCommissioningSuccess(
394
470
  "armFailSafe",
395
- await client.armFailSafe({
396
- breadcrumb: this.lastBreadcrumb,
397
- expiryLengthSeconds: Seconds.of(expiryLength)
471
+ await this.#invokeCommand({
472
+ endpoint: RootEndpointNumber,
473
+ cluster: GeneralCommissioning.Complete,
474
+ command: "armFailSafe",
475
+ fields: {
476
+ breadcrumb: this.lastBreadcrumb,
477
+ expiryLengthSeconds: Seconds.of(expiryLength)
478
+ }
398
479
  })
399
480
  );
400
481
  this.#currentFailSafeEndTime = Timestamp(Time.nowMs + expiryLength);
@@ -410,22 +491,26 @@ class ControllerCommissioningFlow {
410
491
  return Duration.max(Timespan(Time.nowMs, this.#currentFailSafeEndTime).duration, 0);
411
492
  }
412
493
  async #ensureFailsafeTimerFor(maxProcessingTime) {
413
- const minFailsafeTime = this.interactionClient.maximumPeerResponseTime(maxProcessingTime);
494
+ const minFailsafeTime = this.interaction.maximumPeerResponseTime(maxProcessingTime);
414
495
  const timeLeft = this.#failSafeTimeLeft;
415
496
  if (timeLeft < minFailsafeTime) {
416
497
  logger.debug(`Failsafe timer has only ${timeLeft}s left, re-arming for at least ${minFailsafeTime}`);
417
498
  await this.#armFailsafe(Duration.max(minFailsafeTime, this.#defaultFailSafeTime));
418
499
  } else {
419
- logger.debug(`Failsafe timer is already set for at least ${timeLeft}s`);
500
+ logger.debug(`Failsafe timer is already set for at least ${Seconds.of(timeLeft)}s`);
420
501
  }
421
502
  }
422
503
  async #resetFailsafeTimer() {
423
504
  if (this.#currentFailSafeEndTime === void 0) return;
424
505
  try {
425
- const client = this.#getClusterClient(GeneralCommissioning.Cluster);
426
- await client.armFailSafe({
427
- breadcrumb: this.lastBreadcrumb,
428
- expiryLengthSeconds: 0
506
+ await this.#invokeCommand({
507
+ endpoint: RootEndpointNumber,
508
+ cluster: GeneralCommissioning.Complete,
509
+ command: "armFailSafe",
510
+ fields: {
511
+ breadcrumb: this.lastBreadcrumb,
512
+ expiryLengthSeconds: 0
513
+ }
429
514
  });
430
515
  this.#currentFailSafeEndTime = void 0;
431
516
  } catch (error) {
@@ -449,8 +534,15 @@ class ControllerCommissioningFlow {
449
534
  ({ value: { wiFiNetworkInterface, threadNetworkInterface } }) => wiFiNetworkInterface || threadNetworkInterface
450
535
  );
451
536
  if (hasRadioNetwork) {
452
- const client = this.#getClusterClient(GeneralCommissioning.Cluster);
453
- let locationCapability = await client.getLocationCapabilityAttribute();
537
+ let [locationCapability] = await this.#readConcreteAttributeValues(
538
+ Read(
539
+ Read.Attribute({
540
+ endpoint: RootEndpointNumber,
541
+ cluster: GeneralCommissioning.Complete,
542
+ attributes: ["locationCapability"]
543
+ })
544
+ )
545
+ );
454
546
  if (locationCapability === GeneralCommissioning.RegulatoryLocationType.IndoorOutdoor) {
455
547
  locationCapability = this.commissioningOptions.regulatoryLocation;
456
548
  } else {
@@ -459,13 +551,20 @@ class ControllerCommissioningFlow {
459
551
  );
460
552
  }
461
553
  let countryCode = this.commissioningOptions.regulatoryCountryCode;
462
- const regulatoryResult = await client.setRegulatoryConfig(
554
+ const regulatoryResult = await this.#invokeCommand(
463
555
  {
464
- breadcrumb: this.lastBreadcrumb++,
465
- newRegulatoryConfig: locationCapability,
466
- countryCode
556
+ endpoint: RootEndpointNumber,
557
+ cluster: GeneralCommissioning.Complete,
558
+ command: "setRegulatoryConfig",
559
+ fields: {
560
+ breadcrumb: this.lastBreadcrumb++,
561
+ newRegulatoryConfig: locationCapability,
562
+ countryCode
563
+ }
467
564
  },
468
- { useExtendedFailSafeMessageResponseTimeout: true }
565
+ {
566
+ useExtendedFailSafeMessageResponseTimeout: true
567
+ }
469
568
  );
470
569
  if (regulatoryResult.errorCode === GeneralCommissioning.CommissioningError.ValueOutsideRange && countryCode !== "XX") {
471
570
  logger.debug(
@@ -474,13 +573,20 @@ class ControllerCommissioningFlow {
474
573
  countryCode = "XX";
475
574
  this.#ensureGeneralCommissioningSuccess(
476
575
  "setRegulatoryConfig",
477
- await client.setRegulatoryConfig(
576
+ await this.#invokeCommand(
478
577
  {
479
- breadcrumb: this.lastBreadcrumb,
480
- newRegulatoryConfig: locationCapability,
481
- countryCode
578
+ endpoint: RootEndpointNumber,
579
+ cluster: GeneralCommissioning.Complete,
580
+ command: "setRegulatoryConfig",
581
+ fields: {
582
+ breadcrumb: this.lastBreadcrumb,
583
+ newRegulatoryConfig: locationCapability,
584
+ countryCode
585
+ }
482
586
  },
483
- { useExtendedFailSafeMessageResponseTimeout: true }
587
+ {
588
+ useExtendedFailSafeMessageResponseTimeout: true
589
+ }
484
590
  )
485
591
  );
486
592
  } else {
@@ -522,24 +628,44 @@ class ControllerCommissioningFlow {
522
628
  * (see Section 6.2.3, “Device Attestation Procedure”).
523
629
  */
524
630
  async #deviceAttestation() {
525
- const operationalCredentialsClusterClient = this.#getClusterClient(OperationalCredentials.Cluster);
526
- const { certificate: deviceAttestation } = await operationalCredentialsClusterClient.certificateChainRequest(
631
+ const { certificate: deviceAttestation } = await this.#invokeCommand(
527
632
  {
528
- certificateType: OperationalCredentials.CertificateChainType.DacCertificate
633
+ endpoint: RootEndpointNumber,
634
+ cluster: OperationalCredentials.Complete,
635
+ command: "certificateChainRequest",
636
+ fields: {
637
+ certificateType: OperationalCredentials.CertificateChainType.DacCertificate
638
+ }
529
639
  },
530
- { useExtendedFailSafeMessageResponseTimeout: true }
640
+ {
641
+ useExtendedFailSafeMessageResponseTimeout: true
642
+ }
531
643
  );
532
- const { certificate: productAttestation } = await operationalCredentialsClusterClient.certificateChainRequest(
644
+ const { certificate: productAttestation } = await this.#invokeCommand(
533
645
  {
534
- certificateType: OperationalCredentials.CertificateChainType.PaiCertificate
646
+ endpoint: RootEndpointNumber,
647
+ cluster: OperationalCredentials.Complete,
648
+ command: "certificateChainRequest",
649
+ fields: {
650
+ certificateType: OperationalCredentials.CertificateChainType.PaiCertificate
651
+ }
535
652
  },
536
- { useExtendedFailSafeMessageResponseTimeout: true }
653
+ {
654
+ useExtendedFailSafeMessageResponseTimeout: true
655
+ }
537
656
  );
538
- const { attestationElements, attestationSignature } = await operationalCredentialsClusterClient.attestationRequest(
657
+ const { attestationElements, attestationSignature } = await this.#invokeCommand(
539
658
  {
540
- attestationNonce: this.fabric.crypto.randomBytes(32)
659
+ endpoint: RootEndpointNumber,
660
+ cluster: OperationalCredentials.Complete,
661
+ command: "attestationRequest",
662
+ fields: {
663
+ attestationNonce: this.fabric.crypto.randomBytes(32)
664
+ }
541
665
  },
542
- { useExtendedFailSafeMessageResponseTimeout: true }
666
+ {
667
+ useExtendedFailSafeMessageResponseTimeout: true
668
+ }
543
669
  );
544
670
  if (deviceAttestation.byteLength === 0 || productAttestation.byteLength === 0 || attestationElements.byteLength === 0 || attestationSignature.byteLength === 0) {
545
671
  throw new CommissioningError("Device Attestation data missing from device");
@@ -566,36 +692,56 @@ class ControllerCommissioningFlow {
566
692
  * DCL contains the name and other information of the Commissioner’s manufacturer.
567
693
  */
568
694
  async #certificates() {
569
- const operationalCredentialsClusterClient = this.#getClusterClient(OperationalCredentials.Cluster);
570
- const { nocsrElements, attestationSignature: csrSignature } = await operationalCredentialsClusterClient.csrRequest(
571
- { csrNonce: this.fabric.crypto.randomBytes(32) },
572
- { useExtendedFailSafeMessageResponseTimeout: true }
695
+ const { nocsrElements, attestationSignature: csrSignature } = await this.#invokeCommand(
696
+ {
697
+ endpoint: RootEndpointNumber,
698
+ cluster: OperationalCredentials.Complete,
699
+ command: "csrRequest",
700
+ fields: { csrNonce: this.fabric.crypto.randomBytes(32) }
701
+ },
702
+ {
703
+ useExtendedFailSafeMessageResponseTimeout: true
704
+ }
573
705
  );
574
706
  if (nocsrElements.byteLength === 0 || csrSignature.byteLength === 0) {
575
707
  throw new UnexpectedDataError("Invalid response from device");
576
708
  }
577
709
  const { certSigningRequest } = TlvCertSigningRequest.decode(nocsrElements);
578
710
  const operationalPublicKey = await Certificate.getPublicKeyFromCsr(this.ca.crypto, certSigningRequest);
579
- await operationalCredentialsClusterClient.addTrustedRootCertificate(
711
+ await this.#invokeCommand(
580
712
  {
581
- rootCaCertificate: this.ca.rootCert
713
+ endpoint: RootEndpointNumber,
714
+ cluster: OperationalCredentials.Complete,
715
+ command: "addTrustedRootCertificate",
716
+ fields: {
717
+ rootCaCertificate: this.ca.rootCert
718
+ }
582
719
  },
583
- { useExtendedFailSafeMessageResponseTimeout: true }
720
+ {
721
+ useExtendedFailSafeMessageResponseTimeout: true
722
+ }
584
723
  );
585
724
  const peerOperationalCert = await this.ca.generateNoc(
586
725
  operationalPublicKey,
587
726
  this.fabric.fabricId,
588
- this.interactionClient.address.nodeId
727
+ this.interaction.address.nodeId
589
728
  );
590
- const addNocResponse = await operationalCredentialsClusterClient.addNoc(
729
+ const addNocResponse = await this.#invokeCommand(
591
730
  {
592
- nocValue: peerOperationalCert,
593
- icacValue: this.ca.icacCert ?? new Uint8Array(0),
594
- ipkValue: this.fabric.identityProtectionKey,
595
- adminVendorId: this.fabric.rootVendorId,
596
- caseAdminSubject: this.fabric.rootNodeId
731
+ endpoint: RootEndpointNumber,
732
+ cluster: OperationalCredentials.Complete,
733
+ command: "addNoc",
734
+ fields: {
735
+ nocValue: peerOperationalCert,
736
+ icacValue: this.ca.icacCert ?? new Uint8Array(0),
737
+ ipkValue: this.fabric.identityProtectionKey,
738
+ adminVendorId: this.fabric.rootVendorId,
739
+ caseAdminSubject: this.fabric.rootNodeId
740
+ }
597
741
  },
598
- { useExtendedFailSafeMessageResponseTimeout: true }
742
+ {
743
+ useExtendedFailSafeMessageResponseTimeout: true
744
+ }
599
745
  );
600
746
  this.#ensureOperationalCredentialsSuccess("addNoc", addNocResponse);
601
747
  const { fabricIndex } = addNocResponse;
@@ -621,13 +767,17 @@ class ControllerCommissioningFlow {
621
767
  breadcrumb: this.lastBreadcrumb
622
768
  };
623
769
  }
624
- const operationalCredentialCluster = this.#getClusterClient(OperationalCredentials.Cluster);
625
770
  try {
626
771
  this.#ensureOperationalCredentialsSuccess(
627
772
  "updateFabricLabel",
628
- await operationalCredentialCluster.updateFabricLabel({
629
- label: this.fabric.label,
630
- fabricIndex
773
+ await this.#invokeCommand({
774
+ endpoint: RootEndpointNumber,
775
+ cluster: OperationalCredentials.Complete,
776
+ command: "updateFabricLabel",
777
+ fields: {
778
+ label: this.fabric.label,
779
+ fabricIndex
780
+ }
631
781
  })
632
782
  );
633
783
  } catch (error) {
@@ -723,22 +873,32 @@ class ControllerCommissioningFlow {
723
873
  }
724
874
  }
725
875
  logger.debug("Configuring WiFi network ...");
726
- const networkCommissioningClusterClient = this.#getClusterClient(
727
- NetworkCommissioning.Cluster.with("WiFiNetworkInterface"),
728
- EndpointNumber(0),
729
- true
730
- );
731
876
  const ssid = Bytes.fromString(this.commissioningOptions.wifiNetwork.wifiSsid);
732
877
  const credentials = Bytes.fromString(this.commissioningOptions.wifiNetwork.wifiCredentials);
878
+ const [scanMaxTimeSeconds, connectMaxTimeSeconds] = await this.#readConcreteAttributeValues(
879
+ Read(
880
+ Read.Attribute({
881
+ endpoint: RootEndpointNumber,
882
+ cluster: NetworkCommissioning.Complete,
883
+ attributes: ["scanMaxTimeSeconds", "connectMaxTimeSeconds"]
884
+ })
885
+ )
886
+ );
733
887
  if (this.collectedCommissioningData.supportsConcurrentConnection !== false) {
734
- const scanMaxTime = Seconds(await networkCommissioningClusterClient.getScanMaxTimeSecondsAttribute());
735
- await this.#ensureFailsafeTimerFor(scanMaxTime);
736
- const { networkingStatus, wiFiScanResults, debugText } = await networkCommissioningClusterClient.scanNetworks(
888
+ await this.#ensureFailsafeTimerFor(Seconds(scanMaxTimeSeconds));
889
+ const { networkingStatus, wiFiScanResults, debugText } = await this.#invokeCommand(
737
890
  {
738
- ssid,
739
- breadcrumb: this.lastBreadcrumb++
891
+ endpoint: RootEndpointNumber,
892
+ cluster: NetworkCommissioning.Complete,
893
+ command: "scanNetworks",
894
+ fields: {
895
+ ssid,
896
+ breadcrumb: this.lastBreadcrumb++
897
+ }
740
898
  },
741
- { expectedProcessingTime: scanMaxTime }
899
+ {
900
+ expectedProcessingTime: Seconds(scanMaxTimeSeconds)
901
+ }
742
902
  );
743
903
  if (networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
744
904
  throw new WifiNetworkSetupFailedError(`Commissionee failed to scan for WiFi networks: ${debugText}`);
@@ -753,13 +913,20 @@ class ControllerCommissioningFlow {
753
913
  networkingStatus: addNetworkingStatus,
754
914
  debugText: addDebugText,
755
915
  networkIndex
756
- } = await networkCommissioningClusterClient.addOrUpdateWiFiNetwork(
916
+ } = await this.#invokeCommand(
757
917
  {
758
- ssid,
759
- credentials,
760
- breadcrumb: this.lastBreadcrumb++
918
+ endpoint: RootEndpointNumber,
919
+ cluster: NetworkCommissioning.Complete,
920
+ command: "addOrUpdateWiFiNetwork",
921
+ fields: {
922
+ ssid,
923
+ credentials,
924
+ breadcrumb: this.lastBreadcrumb++
925
+ }
761
926
  },
762
- { useExtendedFailSafeMessageResponseTimeout: true }
927
+ {
928
+ useExtendedFailSafeMessageResponseTimeout: true
929
+ }
763
930
  );
764
931
  if (addNetworkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
765
932
  throw new WifiNetworkSetupFailedError(`Commissionee failed to add WiFi network: ${addDebugText}`);
@@ -770,7 +937,15 @@ class ControllerCommissioningFlow {
770
937
  logger.debug(
771
938
  `Commissionee added WiFi network ${this.commissioningOptions.wifiNetwork.wifiSsid} with network index ${networkIndex}`
772
939
  );
773
- const updatedNetworks = await networkCommissioningClusterClient.getNetworksAttribute();
940
+ const [updatedNetworks] = await this.#readConcreteAttributeValues(
941
+ Read(
942
+ Read.Attribute({
943
+ endpoint: RootEndpointNumber,
944
+ cluster: NetworkCommissioning.Complete,
945
+ attributes: ["networks"]
946
+ })
947
+ )
948
+ );
774
949
  if (updatedNetworks[networkIndex] === void 0) {
775
950
  throw new WifiNetworkSetupFailedError(`Commissionee did not return network with index ${networkIndex}`);
776
951
  }
@@ -785,14 +960,20 @@ class ControllerCommissioningFlow {
785
960
  breadcrumb: this.lastBreadcrumb
786
961
  };
787
962
  }
788
- const connectMaxTime = Seconds(await networkCommissioningClusterClient.getConnectMaxTimeSecondsAttribute());
789
- await this.#ensureFailsafeTimerFor(connectMaxTime);
790
- const connectResult = await networkCommissioningClusterClient.connectNetwork(
963
+ await this.#ensureFailsafeTimerFor(Seconds(connectMaxTimeSeconds));
964
+ const connectResult = await this.#invokeCommand(
791
965
  {
792
- networkId,
793
- breadcrumb: this.lastBreadcrumb++
966
+ endpoint: RootEndpointNumber,
967
+ cluster: NetworkCommissioning.Complete,
968
+ command: "connectNetwork",
969
+ fields: {
970
+ networkId,
971
+ breadcrumb: this.lastBreadcrumb++
972
+ }
794
973
  },
795
- { expectedProcessingTime: connectMaxTime }
974
+ {
975
+ expectedProcessingTime: Seconds(connectMaxTimeSeconds)
976
+ }
796
977
  );
797
978
  if (connectResult.networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
798
979
  throw new WifiNetworkSetupFailedError(
@@ -849,17 +1030,29 @@ class ControllerCommissioningFlow {
849
1030
  }
850
1031
  }
851
1032
  logger.debug("Configuring Thread network ...");
852
- const networkCommissioningClusterClient = this.#getClusterClient(
853
- NetworkCommissioning.Cluster.with("ThreadNetworkInterface"),
854
- EndpointNumber(0),
855
- true
1033
+ const [scanMaxTimeSeconds, connectMaxTimeSeconds] = await this.#readConcreteAttributeValues(
1034
+ Read(
1035
+ Read.Attribute({
1036
+ endpoint: RootEndpointNumber,
1037
+ cluster: NetworkCommissioning.Complete,
1038
+ attributes: ["scanMaxTimeSeconds", "connectMaxTimeSeconds"]
1039
+ })
1040
+ )
856
1041
  );
857
- if (this.collectedCommissioningData.supportsConcurrentConnection !== false) {
858
- const scanMaxTime = Seconds(await networkCommissioningClusterClient.getScanMaxTimeSecondsAttribute());
859
- await this.#ensureFailsafeTimerFor(scanMaxTime);
860
- const { networkingStatus, threadScanResults, debugText } = await networkCommissioningClusterClient.scanNetworks(
861
- { breadcrumb: this.lastBreadcrumb++ },
862
- { expectedProcessingTime: scanMaxTime }
1042
+ if (!this.commissioningOptions.threadNetwork?.networkName) {
1043
+ logger.info("Thread network name is not configured. Skip scanning for it.");
1044
+ } else if (this.collectedCommissioningData.supportsConcurrentConnection !== false) {
1045
+ await this.#ensureFailsafeTimerFor(Seconds(scanMaxTimeSeconds));
1046
+ const { networkingStatus, threadScanResults, debugText } = await this.#invokeCommand(
1047
+ {
1048
+ endpoint: RootEndpointNumber,
1049
+ cluster: NetworkCommissioning.Complete,
1050
+ command: "scanNetworks",
1051
+ fields: { breadcrumb: this.lastBreadcrumb++ }
1052
+ },
1053
+ {
1054
+ expectedProcessingTime: Seconds(scanMaxTimeSeconds)
1055
+ }
863
1056
  );
864
1057
  if (networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
865
1058
  throw new ThreadNetworkSetupFailedError(
@@ -887,12 +1080,19 @@ class ControllerCommissioningFlow {
887
1080
  networkingStatus: addNetworkingStatus,
888
1081
  debugText: addDebugText,
889
1082
  networkIndex
890
- } = await networkCommissioningClusterClient.addOrUpdateThreadNetwork(
1083
+ } = await this.#invokeCommand(
891
1084
  {
892
- operationalDataset: Bytes.fromHex(this.commissioningOptions.threadNetwork.operationalDataset),
893
- breadcrumb: this.lastBreadcrumb++
1085
+ endpoint: RootEndpointNumber,
1086
+ cluster: NetworkCommissioning.Complete,
1087
+ command: "addOrUpdateThreadNetwork",
1088
+ fields: {
1089
+ operationalDataset: Bytes.fromHex(this.commissioningOptions.threadNetwork.operationalDataset),
1090
+ breadcrumb: this.lastBreadcrumb++
1091
+ }
894
1092
  },
895
- { useExtendedFailSafeMessageResponseTimeout: true }
1093
+ {
1094
+ useExtendedFailSafeMessageResponseTimeout: true
1095
+ }
896
1096
  );
897
1097
  if (addNetworkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
898
1098
  throw new ThreadNetworkSetupFailedError(`Commissionee failed to add Thread network: ${addDebugText}`);
@@ -903,7 +1103,15 @@ class ControllerCommissioningFlow {
903
1103
  logger.debug(
904
1104
  `Commissionee added Thread network ${this.commissioningOptions.threadNetwork.networkName} with network index ${networkIndex}`
905
1105
  );
906
- const updatedNetworks = await networkCommissioningClusterClient.getNetworksAttribute();
1106
+ const updatedNetworks = await this.#readConcreteAttributeValues(
1107
+ Read(
1108
+ Read.Attribute({
1109
+ endpoint: RootEndpointNumber,
1110
+ cluster: NetworkCommissioning.Complete,
1111
+ attributes: ["networks"]
1112
+ })
1113
+ )
1114
+ );
907
1115
  if (updatedNetworks[networkIndex] === void 0) {
908
1116
  throw new ThreadNetworkSetupFailedError(`Commissionee did not return network with index ${networkIndex}`);
909
1117
  }
@@ -917,14 +1125,20 @@ class ControllerCommissioningFlow {
917
1125
  breadcrumb: this.lastBreadcrumb
918
1126
  };
919
1127
  }
920
- const connectMaxTime = Seconds(await networkCommissioningClusterClient.getConnectMaxTimeSecondsAttribute());
921
- await this.#ensureFailsafeTimerFor(connectMaxTime);
922
- const connectResult = await networkCommissioningClusterClient.connectNetwork(
1128
+ await this.#ensureFailsafeTimerFor(Seconds(connectMaxTimeSeconds));
1129
+ const connectResult = await this.#invokeCommand(
923
1130
  {
924
- networkId,
925
- breadcrumb: this.lastBreadcrumb++
1131
+ endpoint: RootEndpointNumber,
1132
+ cluster: NetworkCommissioning.Complete,
1133
+ command: "connectNetwork",
1134
+ fields: {
1135
+ networkId,
1136
+ breadcrumb: this.lastBreadcrumb++
1137
+ }
926
1138
  },
927
- { expectedProcessingTime: connectMaxTime }
1139
+ {
1140
+ expectedProcessingTime: Seconds(connectMaxTimeSeconds)
1141
+ }
928
1142
  );
929
1143
  if (connectResult.networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
930
1144
  throw new ThreadNetworkSetupFailedError(
@@ -974,7 +1188,7 @@ class ControllerCommissioningFlow {
974
1188
  let transitionResult;
975
1189
  try {
976
1190
  transitionResult = await this.transitionToCase(
977
- this.interactionClient.address,
1191
+ this.interaction.address,
978
1192
  // Assume concurrent connections are supported if not know (which should not be the case when we came here)
979
1193
  isConcurrentFlow
980
1194
  );
@@ -989,7 +1203,7 @@ class ControllerCommissioningFlow {
989
1203
  breadcrumb: this.lastBreadcrumb
990
1204
  };
991
1205
  }
992
- this.interactionClient = transitionResult;
1206
+ this.interaction = transitionResult;
993
1207
  this.#clusterClients.clear();
994
1208
  logger.debug("Successfully reconnected with device ...");
995
1209
  return {
@@ -1005,12 +1219,18 @@ class ControllerCommissioningFlow {
1005
1219
  * the commissioning process.
1006
1220
  */
1007
1221
  async #completeCommissioning() {
1008
- const generalCommissioningClusterClient = this.#getClusterClient(GeneralCommissioning.Cluster);
1009
1222
  this.#ensureGeneralCommissioningSuccess(
1010
1223
  "commissioningComplete",
1011
- await generalCommissioningClusterClient.commissioningComplete(void 0, {
1012
- useExtendedFailSafeMessageResponseTimeout: true
1013
- })
1224
+ await this.#invokeCommand(
1225
+ {
1226
+ endpoint: RootEndpointNumber,
1227
+ cluster: GeneralCommissioning.Complete,
1228
+ command: "commissioningComplete"
1229
+ },
1230
+ {
1231
+ useExtendedFailSafeMessageResponseTimeout: true
1232
+ }
1233
+ )
1014
1234
  );
1015
1235
  this.#currentFailSafeEndTime = void 0;
1016
1236
  return {
@@ -1020,8 +1240,6 @@ class ControllerCommissioningFlow {
1020
1240
  }
1021
1241
  }
1022
1242
  export {
1023
- CommissionableDeviceDiscoveryFailedError,
1024
- CommissioningError,
1025
1243
  CommissioningTimeoutError,
1026
1244
  ControllerCommissioningFlow,
1027
1245
  DeviceAlreadyCommissionedToThisFabricError,