@matter/protocol 0.16.0-alpha.0-20250816-d22ad240d → 0.16.0-alpha.0-20250819-0a388db8b

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 (392) hide show
  1. package/dist/cjs/action/Val.d.ts +6 -0
  2. package/dist/cjs/action/Val.d.ts.map +1 -1
  3. package/dist/cjs/action/Val.js.map +1 -1
  4. package/dist/cjs/action/client/ClientInteraction.d.ts +1 -1
  5. package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
  6. package/dist/cjs/action/client/ClientInteraction.js +4 -4
  7. package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
  8. package/dist/cjs/action/client/ClientSubscription.d.ts +2 -1
  9. package/dist/cjs/action/client/ClientSubscription.d.ts.map +1 -1
  10. package/dist/cjs/action/client/ClientSubscriptionHandler.js +2 -2
  11. package/dist/cjs/action/client/ClientSubscriptionHandler.js.map +1 -1
  12. package/dist/cjs/action/client/ClientSubscriptions.d.ts.map +1 -1
  13. package/dist/cjs/action/client/ClientSubscriptions.js +11 -7
  14. package/dist/cjs/action/client/ClientSubscriptions.js.map +1 -1
  15. package/dist/cjs/action/request/Subscribe.d.ts +6 -6
  16. package/dist/cjs/action/request/Subscribe.d.ts.map +1 -1
  17. package/dist/cjs/action/request/Subscribe.js +11 -9
  18. package/dist/cjs/action/request/Subscribe.js.map +1 -1
  19. package/dist/cjs/advertisement/Advertisement.d.ts +3 -3
  20. package/dist/cjs/advertisement/Advertisement.d.ts.map +1 -1
  21. package/dist/cjs/advertisement/Advertisement.js +5 -5
  22. package/dist/cjs/advertisement/Advertisement.js.map +1 -1
  23. package/dist/cjs/advertisement/ble/BleAdvertisement.d.ts.map +1 -1
  24. package/dist/cjs/advertisement/ble/BleAdvertisement.js +7 -6
  25. package/dist/cjs/advertisement/ble/BleAdvertisement.js.map +1 -1
  26. package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts +11 -10
  27. package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
  28. package/dist/cjs/advertisement/ble/BleAdvertiser.js +4 -4
  29. package/dist/cjs/advertisement/ble/BleAdvertiser.js.map +1 -1
  30. package/dist/cjs/advertisement/mdns/MdnsAdvertisement.d.ts.map +1 -1
  31. package/dist/cjs/advertisement/mdns/MdnsAdvertisement.js +7 -7
  32. package/dist/cjs/advertisement/mdns/MdnsAdvertisement.js.map +1 -1
  33. package/dist/cjs/advertisement/mdns/MdnsAdvertiser.d.ts +2 -2
  34. package/dist/cjs/advertisement/mdns/MdnsAdvertiser.d.ts.map +1 -1
  35. package/dist/cjs/advertisement/mdns/MdnsAdvertiser.js +4 -4
  36. package/dist/cjs/advertisement/mdns/MdnsAdvertiser.js.map +1 -1
  37. package/dist/cjs/ble/Ble.d.ts +2 -2
  38. package/dist/cjs/ble/Ble.d.ts.map +1 -1
  39. package/dist/cjs/ble/Ble.js.map +1 -1
  40. package/dist/cjs/ble/BleConsts.d.ts +4 -4
  41. package/dist/cjs/ble/BleConsts.d.ts.map +1 -1
  42. package/dist/cjs/ble/BleConsts.js +7 -7
  43. package/dist/cjs/ble/BleConsts.js.map +1 -1
  44. package/dist/cjs/ble/BtpSessionHandler.js +2 -2
  45. package/dist/cjs/ble/BtpSessionHandler.js.map +1 -1
  46. package/dist/cjs/certificate/AttestationCertificateManager.js +3 -3
  47. package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
  48. package/dist/cjs/certificate/CertificateAuthority.js +2 -2
  49. package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
  50. package/dist/cjs/certificate/kinds/OperationalBase.js +2 -2
  51. package/dist/cjs/certificate/kinds/OperationalBase.js.map +1 -1
  52. package/dist/cjs/cluster/client/ClusterClient.js +5 -5
  53. package/dist/cjs/cluster/client/ClusterClient.js.map +1 -1
  54. package/dist/cjs/cluster/client/ClusterClientTypes.d.ts +3 -3
  55. package/dist/cjs/cluster/client/ClusterClientTypes.d.ts.map +1 -1
  56. package/dist/cjs/cluster/client/EventClient.d.ts +2 -1
  57. package/dist/cjs/cluster/client/EventClient.d.ts.map +1 -1
  58. package/dist/cjs/cluster/client/EventClient.js +3 -3
  59. package/dist/cjs/cluster/client/EventClient.js.map +1 -1
  60. package/dist/cjs/common/FailsafeContext.d.ts +4 -4
  61. package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
  62. package/dist/cjs/common/FailsafeContext.js +8 -8
  63. package/dist/cjs/common/FailsafeContext.js.map +1 -1
  64. package/dist/cjs/common/FailsafeTimer.d.ts +3 -3
  65. package/dist/cjs/common/FailsafeTimer.d.ts.map +1 -1
  66. package/dist/cjs/common/FailsafeTimer.js +8 -8
  67. package/dist/cjs/common/FailsafeTimer.js.map +1 -1
  68. package/dist/cjs/common/Scanner.d.ts +7 -7
  69. package/dist/cjs/common/Scanner.d.ts.map +1 -1
  70. package/dist/cjs/common/Scanner.js.map +1 -1
  71. package/dist/cjs/events/OccurrenceManager.js +1 -1
  72. package/dist/cjs/events/OccurrenceManager.js.map +1 -1
  73. package/dist/cjs/groups/FabricGroups.d.ts +1 -1
  74. package/dist/cjs/groups/FabricGroups.js +1 -1
  75. package/dist/cjs/groups/Groups.d.ts +1 -1
  76. package/dist/cjs/groups/KeySets.d.ts +3 -3
  77. package/dist/cjs/groups/KeySets.d.ts.map +1 -1
  78. package/dist/cjs/groups/KeySets.js +12 -4
  79. package/dist/cjs/groups/KeySets.js.map +1 -1
  80. package/dist/cjs/interaction/InteractionClient.d.ts +9 -9
  81. package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
  82. package/dist/cjs/interaction/InteractionClient.js +33 -33
  83. package/dist/cjs/interaction/InteractionClient.js.map +1 -1
  84. package/dist/cjs/interaction/InteractionMessenger.d.ts +10 -10
  85. package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
  86. package/dist/cjs/interaction/InteractionMessenger.js +15 -15
  87. package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
  88. package/dist/cjs/interaction/Subscription.d.ts +3 -4
  89. package/dist/cjs/interaction/Subscription.d.ts.map +1 -1
  90. package/dist/cjs/interaction/Subscription.js +9 -12
  91. package/dist/cjs/interaction/Subscription.js.map +1 -1
  92. package/dist/cjs/interaction/SubscriptionClient.d.ts +3 -3
  93. package/dist/cjs/interaction/SubscriptionClient.d.ts.map +1 -1
  94. package/dist/cjs/interaction/SubscriptionClient.js +3 -3
  95. package/dist/cjs/interaction/SubscriptionClient.js.map +1 -1
  96. package/dist/cjs/mdns/MdnsClient.d.ts +9 -9
  97. package/dist/cjs/mdns/MdnsClient.d.ts.map +1 -1
  98. package/dist/cjs/mdns/MdnsClient.js +86 -82
  99. package/dist/cjs/mdns/MdnsClient.js.map +1 -1
  100. package/dist/cjs/mdns/MdnsServer.d.ts.map +1 -1
  101. package/dist/cjs/mdns/MdnsServer.js +11 -9
  102. package/dist/cjs/mdns/MdnsServer.js.map +1 -1
  103. package/dist/cjs/peer/ControllerCommissioner.d.ts +2 -2
  104. package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
  105. package/dist/cjs/peer/ControllerCommissioner.js +7 -7
  106. package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
  107. package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  108. package/dist/cjs/peer/ControllerCommissioningFlow.js +37 -35
  109. package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
  110. package/dist/cjs/peer/ControllerDiscovery.d.ts +4 -4
  111. package/dist/cjs/peer/ControllerDiscovery.d.ts.map +1 -1
  112. package/dist/cjs/peer/ControllerDiscovery.js +12 -17
  113. package/dist/cjs/peer/ControllerDiscovery.js.map +1 -1
  114. package/dist/cjs/peer/InteractionQueue.d.ts.map +1 -1
  115. package/dist/cjs/peer/InteractionQueue.js +2 -2
  116. package/dist/cjs/peer/InteractionQueue.js.map +1 -1
  117. package/dist/cjs/peer/PeerSet.d.ts +2 -2
  118. package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
  119. package/dist/cjs/peer/PeerSet.js +25 -25
  120. package/dist/cjs/peer/PeerSet.js.map +1 -1
  121. package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
  122. package/dist/cjs/protocol/DeviceCommissioner.js +1 -1
  123. package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
  124. package/dist/cjs/protocol/ExchangeManager.d.ts +1 -1
  125. package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
  126. package/dist/cjs/protocol/ExchangeManager.js +2 -5
  127. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  128. package/dist/cjs/protocol/ExchangeProvider.d.ts +4 -4
  129. package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
  130. package/dist/cjs/protocol/ExchangeProvider.js +3 -3
  131. package/dist/cjs/protocol/ExchangeProvider.js.map +1 -1
  132. package/dist/cjs/protocol/MessageChannel.d.ts +5 -5
  133. package/dist/cjs/protocol/MessageChannel.d.ts.map +1 -1
  134. package/dist/cjs/protocol/MessageChannel.js +19 -15
  135. package/dist/cjs/protocol/MessageChannel.js.map +1 -1
  136. package/dist/cjs/protocol/MessageExchange.d.ts +6 -6
  137. package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
  138. package/dist/cjs/protocol/MessageExchange.js +35 -33
  139. package/dist/cjs/protocol/MessageExchange.js.map +1 -1
  140. package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +8 -8
  141. package/dist/cjs/securechannel/SecureChannelMessenger.d.ts.map +1 -1
  142. package/dist/cjs/securechannel/SecureChannelMessenger.js +17 -17
  143. package/dist/cjs/securechannel/SecureChannelMessenger.js.map +1 -1
  144. package/dist/cjs/session/InsecureSession.d.ts +2 -2
  145. package/dist/cjs/session/InsecureSession.d.ts.map +1 -1
  146. package/dist/cjs/session/InsecureSession.js.map +1 -1
  147. package/dist/cjs/session/NodeSession.js +3 -3
  148. package/dist/cjs/session/Session.d.ts +7 -7
  149. package/dist/cjs/session/Session.d.ts.map +1 -1
  150. package/dist/cjs/session/Session.js +19 -19
  151. package/dist/cjs/session/Session.js.map +1 -1
  152. package/dist/cjs/session/SessionIntervals.d.ts +7 -6
  153. package/dist/cjs/session/SessionIntervals.d.ts.map +1 -1
  154. package/dist/cjs/session/SessionIntervals.js +8 -8
  155. package/dist/cjs/session/SessionIntervals.js.map +1 -1
  156. package/dist/cjs/session/SessionManager.d.ts +2 -2
  157. package/dist/cjs/session/SessionManager.d.ts.map +1 -1
  158. package/dist/cjs/session/SessionManager.js +6 -6
  159. package/dist/cjs/session/SessionManager.js.map +1 -1
  160. package/dist/cjs/session/case/CaseClient.d.ts +2 -1
  161. package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
  162. package/dist/cjs/session/case/CaseClient.js +2 -2
  163. package/dist/cjs/session/case/CaseClient.js.map +1 -1
  164. package/dist/cjs/session/pase/PaseMessenger.d.ts.map +1 -1
  165. package/dist/cjs/session/pase/PaseMessenger.js +4 -7
  166. package/dist/cjs/session/pase/PaseMessenger.js.map +1 -1
  167. package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
  168. package/dist/cjs/session/pase/PaseServer.js +1 -1
  169. package/dist/cjs/session/pase/PaseServer.js.map +1 -1
  170. package/dist/esm/action/Val.d.ts +6 -0
  171. package/dist/esm/action/Val.d.ts.map +1 -1
  172. package/dist/esm/action/Val.js.map +1 -1
  173. package/dist/esm/action/client/ClientInteraction.d.ts +1 -1
  174. package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
  175. package/dist/esm/action/client/ClientInteraction.js +5 -5
  176. package/dist/esm/action/client/ClientInteraction.js.map +1 -1
  177. package/dist/esm/action/client/ClientSubscription.d.ts +2 -1
  178. package/dist/esm/action/client/ClientSubscription.d.ts.map +1 -1
  179. package/dist/esm/action/client/ClientSubscriptionHandler.js +2 -2
  180. package/dist/esm/action/client/ClientSubscriptionHandler.js.map +1 -1
  181. package/dist/esm/action/client/ClientSubscriptions.d.ts.map +1 -1
  182. package/dist/esm/action/client/ClientSubscriptions.js +14 -8
  183. package/dist/esm/action/client/ClientSubscriptions.js.map +1 -1
  184. package/dist/esm/action/request/Subscribe.d.ts +6 -6
  185. package/dist/esm/action/request/Subscribe.d.ts.map +1 -1
  186. package/dist/esm/action/request/Subscribe.js +12 -10
  187. package/dist/esm/action/request/Subscribe.js.map +1 -1
  188. package/dist/esm/advertisement/Advertisement.d.ts +3 -3
  189. package/dist/esm/advertisement/Advertisement.d.ts.map +1 -1
  190. package/dist/esm/advertisement/Advertisement.js +16 -7
  191. package/dist/esm/advertisement/Advertisement.js.map +1 -1
  192. package/dist/esm/advertisement/ble/BleAdvertisement.d.ts.map +1 -1
  193. package/dist/esm/advertisement/ble/BleAdvertisement.js +7 -6
  194. package/dist/esm/advertisement/ble/BleAdvertisement.js.map +1 -1
  195. package/dist/esm/advertisement/ble/BleAdvertiser.d.ts +11 -10
  196. package/dist/esm/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
  197. package/dist/esm/advertisement/ble/BleAdvertiser.js +6 -6
  198. package/dist/esm/advertisement/ble/BleAdvertiser.js.map +1 -1
  199. package/dist/esm/advertisement/mdns/MdnsAdvertisement.d.ts.map +1 -1
  200. package/dist/esm/advertisement/mdns/MdnsAdvertisement.js +17 -8
  201. package/dist/esm/advertisement/mdns/MdnsAdvertisement.js.map +1 -1
  202. package/dist/esm/advertisement/mdns/MdnsAdvertiser.d.ts +2 -2
  203. package/dist/esm/advertisement/mdns/MdnsAdvertiser.d.ts.map +1 -1
  204. package/dist/esm/advertisement/mdns/MdnsAdvertiser.js +14 -6
  205. package/dist/esm/advertisement/mdns/MdnsAdvertiser.js.map +1 -1
  206. package/dist/esm/ble/Ble.d.ts +2 -2
  207. package/dist/esm/ble/Ble.d.ts.map +1 -1
  208. package/dist/esm/ble/Ble.js +5 -1
  209. package/dist/esm/ble/Ble.js.map +1 -1
  210. package/dist/esm/ble/BleConsts.d.ts +4 -4
  211. package/dist/esm/ble/BleConsts.d.ts.map +1 -1
  212. package/dist/esm/ble/BleConsts.js +8 -8
  213. package/dist/esm/ble/BleConsts.js.map +1 -1
  214. package/dist/esm/ble/BtpSessionHandler.js +4 -4
  215. package/dist/esm/ble/BtpSessionHandler.js.map +1 -1
  216. package/dist/esm/certificate/AttestationCertificateManager.js +3 -3
  217. package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
  218. package/dist/esm/certificate/CertificateAuthority.js +2 -2
  219. package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
  220. package/dist/esm/certificate/kinds/OperationalBase.js +2 -2
  221. package/dist/esm/certificate/kinds/OperationalBase.js.map +1 -1
  222. package/dist/esm/cluster/client/ClusterClient.js +5 -5
  223. package/dist/esm/cluster/client/ClusterClient.js.map +1 -1
  224. package/dist/esm/cluster/client/ClusterClientTypes.d.ts +3 -3
  225. package/dist/esm/cluster/client/ClusterClientTypes.d.ts.map +1 -1
  226. package/dist/esm/cluster/client/EventClient.d.ts +2 -1
  227. package/dist/esm/cluster/client/EventClient.d.ts.map +1 -1
  228. package/dist/esm/cluster/client/EventClient.js +3 -3
  229. package/dist/esm/cluster/client/EventClient.js.map +1 -1
  230. package/dist/esm/common/FailsafeContext.d.ts +4 -4
  231. package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
  232. package/dist/esm/common/FailsafeContext.js +9 -8
  233. package/dist/esm/common/FailsafeContext.js.map +1 -1
  234. package/dist/esm/common/FailsafeTimer.d.ts +3 -3
  235. package/dist/esm/common/FailsafeTimer.d.ts.map +1 -1
  236. package/dist/esm/common/FailsafeTimer.js +8 -8
  237. package/dist/esm/common/FailsafeTimer.js.map +1 -1
  238. package/dist/esm/common/Scanner.d.ts +7 -7
  239. package/dist/esm/common/Scanner.d.ts.map +1 -1
  240. package/dist/esm/common/Scanner.js +5 -1
  241. package/dist/esm/common/Scanner.js.map +1 -1
  242. package/dist/esm/events/OccurrenceManager.js +1 -1
  243. package/dist/esm/events/OccurrenceManager.js.map +1 -1
  244. package/dist/esm/groups/FabricGroups.d.ts +1 -1
  245. package/dist/esm/groups/FabricGroups.js +1 -1
  246. package/dist/esm/groups/Groups.d.ts +1 -1
  247. package/dist/esm/groups/KeySets.d.ts +3 -3
  248. package/dist/esm/groups/KeySets.d.ts.map +1 -1
  249. package/dist/esm/groups/KeySets.js +13 -5
  250. package/dist/esm/groups/KeySets.js.map +1 -1
  251. package/dist/esm/interaction/InteractionClient.d.ts +9 -9
  252. package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
  253. package/dist/esm/interaction/InteractionClient.js +34 -33
  254. package/dist/esm/interaction/InteractionClient.js.map +1 -1
  255. package/dist/esm/interaction/InteractionMessenger.d.ts +10 -10
  256. package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
  257. package/dist/esm/interaction/InteractionMessenger.js +16 -15
  258. package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
  259. package/dist/esm/interaction/Subscription.d.ts +3 -4
  260. package/dist/esm/interaction/Subscription.d.ts.map +1 -1
  261. package/dist/esm/interaction/Subscription.js +9 -12
  262. package/dist/esm/interaction/Subscription.js.map +1 -1
  263. package/dist/esm/interaction/SubscriptionClient.d.ts +3 -3
  264. package/dist/esm/interaction/SubscriptionClient.d.ts.map +1 -1
  265. package/dist/esm/interaction/SubscriptionClient.js +4 -4
  266. package/dist/esm/interaction/SubscriptionClient.js.map +1 -1
  267. package/dist/esm/mdns/MdnsClient.d.ts +9 -9
  268. package/dist/esm/mdns/MdnsClient.d.ts.map +1 -1
  269. package/dist/esm/mdns/MdnsClient.js +94 -82
  270. package/dist/esm/mdns/MdnsClient.js.map +1 -1
  271. package/dist/esm/mdns/MdnsServer.d.ts.map +1 -1
  272. package/dist/esm/mdns/MdnsServer.js +14 -9
  273. package/dist/esm/mdns/MdnsServer.js.map +1 -1
  274. package/dist/esm/peer/ControllerCommissioner.d.ts +2 -2
  275. package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
  276. package/dist/esm/peer/ControllerCommissioner.js +11 -8
  277. package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
  278. package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  279. package/dist/esm/peer/ControllerCommissioningFlow.js +44 -35
  280. package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
  281. package/dist/esm/peer/ControllerDiscovery.d.ts +4 -4
  282. package/dist/esm/peer/ControllerDiscovery.d.ts.map +1 -1
  283. package/dist/esm/peer/ControllerDiscovery.js +20 -18
  284. package/dist/esm/peer/ControllerDiscovery.js.map +1 -1
  285. package/dist/esm/peer/InteractionQueue.d.ts.map +1 -1
  286. package/dist/esm/peer/InteractionQueue.js +3 -3
  287. package/dist/esm/peer/InteractionQueue.js.map +1 -1
  288. package/dist/esm/peer/PeerSet.d.ts +2 -2
  289. package/dist/esm/peer/PeerSet.d.ts.map +1 -1
  290. package/dist/esm/peer/PeerSet.js +29 -26
  291. package/dist/esm/peer/PeerSet.js.map +1 -1
  292. package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
  293. package/dist/esm/protocol/DeviceCommissioner.js +2 -2
  294. package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
  295. package/dist/esm/protocol/ExchangeManager.d.ts +1 -1
  296. package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
  297. package/dist/esm/protocol/ExchangeManager.js +3 -6
  298. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  299. package/dist/esm/protocol/ExchangeProvider.d.ts +4 -4
  300. package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
  301. package/dist/esm/protocol/ExchangeProvider.js +4 -4
  302. package/dist/esm/protocol/ExchangeProvider.js.map +1 -1
  303. package/dist/esm/protocol/MessageChannel.d.ts +5 -5
  304. package/dist/esm/protocol/MessageChannel.d.ts.map +1 -1
  305. package/dist/esm/protocol/MessageChannel.js +20 -16
  306. package/dist/esm/protocol/MessageChannel.js.map +1 -1
  307. package/dist/esm/protocol/MessageExchange.d.ts +6 -6
  308. package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
  309. package/dist/esm/protocol/MessageExchange.js +39 -34
  310. package/dist/esm/protocol/MessageExchange.js.map +1 -1
  311. package/dist/esm/securechannel/SecureChannelMessenger.d.ts +8 -8
  312. package/dist/esm/securechannel/SecureChannelMessenger.d.ts.map +1 -1
  313. package/dist/esm/securechannel/SecureChannelMessenger.js +18 -18
  314. package/dist/esm/securechannel/SecureChannelMessenger.js.map +1 -1
  315. package/dist/esm/session/InsecureSession.d.ts +2 -2
  316. package/dist/esm/session/InsecureSession.d.ts.map +1 -1
  317. package/dist/esm/session/InsecureSession.js.map +1 -1
  318. package/dist/esm/session/NodeSession.js +3 -3
  319. package/dist/esm/session/Session.d.ts +7 -7
  320. package/dist/esm/session/Session.d.ts.map +1 -1
  321. package/dist/esm/session/Session.js +27 -20
  322. package/dist/esm/session/Session.js.map +1 -1
  323. package/dist/esm/session/SessionIntervals.d.ts +7 -6
  324. package/dist/esm/session/SessionIntervals.d.ts.map +1 -1
  325. package/dist/esm/session/SessionIntervals.js +8 -8
  326. package/dist/esm/session/SessionIntervals.js.map +1 -1
  327. package/dist/esm/session/SessionManager.d.ts +2 -2
  328. package/dist/esm/session/SessionManager.d.ts.map +1 -1
  329. package/dist/esm/session/SessionManager.js +6 -6
  330. package/dist/esm/session/SessionManager.js.map +1 -1
  331. package/dist/esm/session/case/CaseClient.d.ts +2 -1
  332. package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
  333. package/dist/esm/session/case/CaseClient.js +2 -2
  334. package/dist/esm/session/case/CaseClient.js.map +1 -1
  335. package/dist/esm/session/pase/PaseMessenger.d.ts.map +1 -1
  336. package/dist/esm/session/pase/PaseMessenger.js +5 -11
  337. package/dist/esm/session/pase/PaseMessenger.js.map +1 -1
  338. package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
  339. package/dist/esm/session/pase/PaseServer.js +2 -1
  340. package/dist/esm/session/pase/PaseServer.js.map +1 -1
  341. package/package.json +6 -6
  342. package/src/action/Val.ts +5 -0
  343. package/src/action/client/ClientInteraction.ts +4 -4
  344. package/src/action/client/ClientSubscription.ts +2 -1
  345. package/src/action/client/ClientSubscriptionHandler.ts +2 -2
  346. package/src/action/client/ClientSubscriptions.ts +14 -8
  347. package/src/action/request/Subscribe.ts +17 -15
  348. package/src/advertisement/Advertisement.ts +18 -8
  349. package/src/advertisement/ble/BleAdvertisement.ts +7 -6
  350. package/src/advertisement/ble/BleAdvertiser.ts +11 -11
  351. package/src/advertisement/mdns/MdnsAdvertisement.ts +20 -9
  352. package/src/advertisement/mdns/MdnsAdvertiser.ts +17 -7
  353. package/src/ble/Ble.ts +11 -2
  354. package/src/ble/BleConsts.ts +5 -5
  355. package/src/ble/BtpSessionHandler.ts +4 -4
  356. package/src/certificate/AttestationCertificateManager.ts +3 -3
  357. package/src/certificate/CertificateAuthority.ts +2 -2
  358. package/src/certificate/kinds/OperationalBase.ts +3 -3
  359. package/src/cluster/client/ClusterClient.ts +8 -8
  360. package/src/cluster/client/ClusterClientTypes.ts +3 -3
  361. package/src/cluster/client/EventClient.ts +5 -5
  362. package/src/common/FailsafeContext.ts +11 -13
  363. package/src/common/FailsafeTimer.ts +11 -13
  364. package/src/common/Scanner.ts +16 -7
  365. package/src/events/OccurrenceManager.ts +1 -1
  366. package/src/groups/FabricGroups.ts +1 -1
  367. package/src/groups/KeySets.ts +14 -6
  368. package/src/interaction/InteractionClient.ts +46 -44
  369. package/src/interaction/InteractionMessenger.ts +24 -22
  370. package/src/interaction/Subscription.ts +10 -14
  371. package/src/interaction/SubscriptionClient.ts +6 -6
  372. package/src/mdns/MdnsClient.ts +105 -82
  373. package/src/mdns/MdnsServer.ts +14 -9
  374. package/src/peer/ControllerCommissioner.ts +12 -9
  375. package/src/peer/ControllerCommissioningFlow.ts +48 -39
  376. package/src/peer/ControllerDiscovery.ts +22 -18
  377. package/src/peer/InteractionQueue.ts +3 -3
  378. package/src/peer/PeerSet.ts +34 -28
  379. package/src/protocol/DeviceCommissioner.ts +2 -2
  380. package/src/protocol/ExchangeManager.ts +3 -6
  381. package/src/protocol/ExchangeProvider.ts +6 -6
  382. package/src/protocol/MessageChannel.ts +26 -21
  383. package/src/protocol/MessageExchange.ts +42 -38
  384. package/src/securechannel/SecureChannelMessenger.ts +16 -22
  385. package/src/session/InsecureSession.ts +2 -2
  386. package/src/session/NodeSession.ts +3 -3
  387. package/src/session/Session.ts +31 -21
  388. package/src/session/SessionIntervals.ts +11 -11
  389. package/src/session/SessionManager.ts +10 -9
  390. package/src/session/case/CaseClient.ts +3 -3
  391. package/src/session/pase/PaseMessenger.ts +5 -11
  392. package/src/session/pase/PaseServer.ts +2 -1
@@ -14,15 +14,23 @@ import {
14
14
  DnsRecord,
15
15
  DnsRecordClass,
16
16
  DnsRecordType,
17
+ Duration,
18
+ Hours,
17
19
  ImplementationError,
20
+ Instant,
18
21
  InternalError,
19
22
  Lifespan,
20
23
  Logger,
24
+ Millis,
25
+ Minutes,
21
26
  ObserverGroup,
27
+ Seconds,
28
+ ServerAddress,
22
29
  ServerAddressIp,
23
30
  SrvRecordValue,
24
31
  Time,
25
32
  Timer,
33
+ Timespan,
26
34
  createPromise,
27
35
  isIPv6,
28
36
  } from "#general";
@@ -86,7 +94,7 @@ type StructuredDnsAnswers = {
86
94
  } & StructuredDnsAddressAnswers;
87
95
 
88
96
  /** The initial number of seconds between two announcements. MDNS specs require 1-2 seconds, so lets use the middle. */
89
- const START_ANNOUNCE_INTERVAL_SECONDS = 1.5;
97
+ const START_ANNOUNCE_INTERVAL = Seconds(1.5);
90
98
 
91
99
  /**
92
100
  * Interface to add criteria for MDNS discovery a node is interested in
@@ -141,7 +149,7 @@ export class MdnsClient implements Scanner {
141
149
  >();
142
150
 
143
151
  #queryTimer?: Timer;
144
- #nextAnnounceIntervalSeconds = START_ANNOUNCE_INTERVAL_SECONDS;
152
+ #nextAnnounceInterval = START_ANNOUNCE_INTERVAL;
145
153
  readonly #periodicTimer: Timer;
146
154
  #closing = false;
147
155
  readonly #socket: MdnsSocket;
@@ -158,7 +166,7 @@ export class MdnsClient implements Scanner {
158
166
  constructor(socket: MdnsSocket) {
159
167
  this.#socket = socket;
160
168
  this.#observers.on(this.#socket.receipt, this.#handleMessage.bind(this));
161
- this.#periodicTimer = Time.getPeriodicTimer("Discovered node expiration", 60 * 1000 /* 1 mn */, () =>
169
+ this.#periodicTimer = Time.getPeriodicTimer("Discovered node expiration", Minutes.one, () =>
162
170
  this.#expire(),
163
171
  ).start();
164
172
 
@@ -230,8 +238,8 @@ export class MdnsClient implements Scanner {
230
238
  }
231
239
  }
232
240
 
233
- #effectiveTTL(ttl: number) {
234
- return Math.ceil(ttl * MDNS_EXPIRY_GRACE_PERIOD_FACTOR);
241
+ #effectiveTTL(ttl: Duration) {
242
+ return Millis(ttl * MDNS_EXPIRY_GRACE_PERIOD_FACTOR);
235
243
  }
236
244
 
237
245
  /**
@@ -250,16 +258,16 @@ export class MdnsClient implements Scanner {
250
258
  ),
251
259
  );
252
260
 
253
- this.#queryTimer = Time.getTimer("MDNS discovery", this.#nextAnnounceIntervalSeconds * 1000, () =>
261
+ this.#queryTimer = Time.getTimer("MDNS discovery", this.#nextAnnounceInterval, () =>
254
262
  this.#sendQueries(),
255
263
  ).start();
256
264
 
257
265
  logger.debug(
258
- `Sending ${queries.length} query records for ${this.#activeAnnounceQueries.size} queries with ${answers.length} known answers. Re-Announce in ${this.#nextAnnounceIntervalSeconds} seconds`,
266
+ `Sending ${queries.length} query records for ${this.#activeAnnounceQueries.size} queries with ${answers.length} known answers. Re-Announce in ${Duration.format(this.#nextAnnounceInterval)}`,
259
267
  );
260
268
 
261
- const nextAnnounceInterval = this.#nextAnnounceIntervalSeconds * 2;
262
- this.#nextAnnounceIntervalSeconds = Math.min(nextAnnounceInterval, 60 * 60 /* 1 hour */);
269
+ const nextAnnounceInterval = Millis(this.#nextAnnounceInterval * 2);
270
+ this.#nextAnnounceInterval = Duration.min(nextAnnounceInterval, Hours.one);
263
271
 
264
272
  await this.#socket.send({
265
273
  messageType: DnsMessageType.Query,
@@ -298,8 +306,8 @@ export class MdnsClient implements Scanner {
298
306
  this.#activeAnnounceQueries.set(queryId, { queries, answers });
299
307
  logger.debug(`Set ${queries.length} query records for query ${queryId}: ${Diagnostic.json(queries)}`);
300
308
  this.#queryTimer?.stop();
301
- this.#nextAnnounceIntervalSeconds = START_ANNOUNCE_INTERVAL_SECONDS; // Reset query interval
302
- this.#queryTimer = Time.getTimer("MDNS discovery", 0, () => this.#sendQueries()).start();
309
+ this.#nextAnnounceInterval = START_ANNOUNCE_INTERVAL; // Reset query interval
310
+ this.#queryTimer = Time.getTimer("MDNS discovery", Instant, () => this.#sendQueries()).start();
303
311
  }
304
312
 
305
313
  /**
@@ -322,7 +330,7 @@ export class MdnsClient implements Scanner {
322
330
  if (this.#activeAnnounceQueries.size === 0) {
323
331
  logger.debug(`Removing last query ${queryId} and stopping announce timer`);
324
332
  this.#queryTimer?.stop();
325
- this.#nextAnnounceIntervalSeconds = START_ANNOUNCE_INTERVAL_SECONDS;
333
+ this.#nextAnnounceInterval = START_ANNOUNCE_INTERVAL;
326
334
  } else {
327
335
  logger.debug(`Removing query ${queryId}`);
328
336
  }
@@ -395,14 +403,14 @@ export class MdnsClient implements Scanner {
395
403
  async #registerWaiterPromise(
396
404
  queryId: string,
397
405
  commissionable: boolean,
398
- timeoutSeconds?: number,
406
+ timeout?: Duration,
399
407
  resolveOnUpdatedRecords = true,
400
408
  cancelResolver?: (value: void) => void,
401
409
  ) {
402
410
  const { promise, resolver } = createPromise<void>();
403
411
  const timer =
404
- timeoutSeconds !== undefined
405
- ? Time.getTimer("MDNS timeout", timeoutSeconds * 1000, () => {
412
+ timeout !== undefined
413
+ ? Time.getTimer("MDNS timeout", timeout, () => {
406
414
  cancelResolver?.();
407
415
  this.#finishWaiter(queryId, true);
408
416
  }).start()
@@ -415,7 +423,7 @@ export class MdnsClient implements Scanner {
415
423
  }
416
424
  logger.debug(
417
425
  `Registered waiter for query ${queryId} with ${
418
- timeoutSeconds !== undefined ? `timeout ${timeoutSeconds} seconds` : "no timeout"
426
+ timeout !== undefined ? `timeout ${timeout}` : "no timeout"
419
427
  }${resolveOnUpdatedRecords ? "" : " (not resolving on updated records)"}`,
420
428
  );
421
429
  await promise;
@@ -482,7 +490,7 @@ export class MdnsClient implements Scanner {
482
490
  async findOperationalDevice(
483
491
  { operationalId }: Fabric,
484
492
  nodeId: NodeId,
485
- timeoutSeconds?: number,
493
+ timeout?: Duration,
486
494
  ignoreExistingRecords = false,
487
495
  ): Promise<OperationalDevice | undefined> {
488
496
  if (this.#closing) {
@@ -492,7 +500,7 @@ export class MdnsClient implements Scanner {
492
500
 
493
501
  let storedDevice = ignoreExistingRecords ? undefined : this.#getOperationalDeviceRecords(deviceMatterQname);
494
502
  if (storedDevice === undefined) {
495
- const promise = this.#registerWaiterPromise(deviceMatterQname, false, timeoutSeconds);
503
+ const promise = this.#registerWaiterPromise(deviceMatterQname, false, timeout);
496
504
 
497
505
  this.#setQueryRecords(deviceMatterQname, [
498
506
  {
@@ -711,7 +719,7 @@ export class MdnsClient implements Scanner {
711
719
  */
712
720
  async findCommissionableDevices(
713
721
  identifier: CommissionableDeviceIdentifiers,
714
- timeoutSeconds = 5,
722
+ timeout = Seconds(5),
715
723
  ignoreExistingRecords = false,
716
724
  ): Promise<CommissionableDevice[]> {
717
725
  let storedRecords = ignoreExistingRecords
@@ -719,7 +727,7 @@ export class MdnsClient implements Scanner {
719
727
  : this.#getCommissionableDeviceRecords(identifier).filter(({ addresses }) => addresses.length > 0);
720
728
  if (storedRecords.length === 0) {
721
729
  const queryId = this.#buildCommissionableQueryIdentifier(identifier);
722
- const promise = this.#registerWaiterPromise(queryId, true, timeoutSeconds);
730
+ const promise = this.#registerWaiterPromise(queryId, true, timeout);
723
731
 
724
732
  this.#setQueryRecords(queryId, this.#getCommissionableQueryRecords(identifier));
725
733
 
@@ -737,12 +745,12 @@ export class MdnsClient implements Scanner {
737
745
  async findCommissionableDevicesContinuously(
738
746
  identifier: CommissionableDeviceIdentifiers,
739
747
  callback: (device: CommissionableDevice) => void,
740
- timeoutSeconds?: number,
748
+ timeout?: Duration,
741
749
  cancelSignal?: Promise<void>,
742
750
  ): Promise<CommissionableDevice[]> {
743
751
  const discoveredDevices = new Set<string>();
744
752
 
745
- const discoveryEndTime = timeoutSeconds ? Time.nowMs() + timeoutSeconds * 1000 : undefined;
753
+ const discoveryEndTime = timeout ? Time.nowMs + timeout : undefined;
746
754
  const queryId = this.#buildCommissionableQueryIdentifier(identifier);
747
755
  this.#setQueryRecords(queryId, this.#getCommissionableQueryRecords(identifier));
748
756
 
@@ -778,7 +786,7 @@ export class MdnsClient implements Scanner {
778
786
 
779
787
  let remainingTime;
780
788
  if (discoveryEndTime !== undefined) {
781
- remainingTime = Math.ceil((discoveryEndTime - Time.nowMs()) / 1000);
789
+ remainingTime = Seconds.ceil(Timespan(Time.nowMs, discoveryEndTime).duration);
782
790
  if (remainingTime <= 0) {
783
791
  break;
784
792
  }
@@ -810,7 +818,7 @@ export class MdnsClient implements Scanner {
810
818
  #structureAnswers(...answersList: DnsRecord<any>[][]): StructuredDnsAnswers {
811
819
  const structuredAnswers: StructuredDnsAnswers = {};
812
820
 
813
- const discoveredAt = Time.nowMs();
821
+ const discoveredAt = Time.nowMs;
814
822
  answersList.forEach(answers =>
815
823
  answers.forEach(answer => {
816
824
  const { name, recordType } = answer;
@@ -1055,7 +1063,7 @@ export class MdnsClient implements Scanner {
1055
1063
  answers: StructuredDnsAnswers[],
1056
1064
  target: string,
1057
1065
  netInterface: string,
1058
- ): { value: string; ttl: number }[] {
1066
+ ): { value: string; ttl: Duration }[] {
1059
1067
  const ipRecords = new Array<AnyDnsRecordWithExpiry>();
1060
1068
  answers.forEach(answer => {
1061
1069
  if (answer.addressesV6?.[target]) {
@@ -1073,7 +1081,7 @@ export class MdnsClient implements Scanner {
1073
1081
  this.#registerIpRecords(ipRecords, netInterface); // Register for potential later usage
1074
1082
 
1075
1083
  // If an IP is included multiple times we only keep the latest record
1076
- const collectedIps = new Map<string, { value: string; ttl: number }>();
1084
+ const collectedIps = new Map<string, { value: string; ttl: Duration }>();
1077
1085
  ipRecords.forEach(record => {
1078
1086
  const { value, ttl } = record as DnsRecord<string>;
1079
1087
  if (value.startsWith("fe80::")) {
@@ -1123,7 +1131,7 @@ export class MdnsClient implements Scanner {
1123
1131
 
1124
1132
  #handleOperationalTxtRecord(record: DnsRecord<any>, netInterface: string) {
1125
1133
  const { name: matterName, value, ttl } = record as DnsRecord<string[]>;
1126
- const discoveredAt = Time.nowMs();
1134
+ const discoveredAt = Time.nowMs;
1127
1135
 
1128
1136
  // we got an expiry info, so we can remove the record if we know it already and are done
1129
1137
  if (ttl === 0) {
@@ -1151,19 +1159,16 @@ export class MdnsClient implements Scanner {
1151
1159
  device = {
1152
1160
  ...device,
1153
1161
  discoveredAt,
1154
- ttl: ttl * 1000,
1162
+ ttl,
1155
1163
  ...txtData,
1156
1164
  };
1157
1165
  } else {
1158
- logger.debug(
1159
- `Adding operational device ${matterName} in cache (interface ${netInterface}, ttl=${ttl}) with TXT data:`,
1160
- MdnsClient.discoveryDataDiagnostics(txtData),
1161
- );
1166
+ logNewService(matterName, "operational", txtData);
1162
1167
  device = {
1163
1168
  deviceIdentifier: matterName,
1164
1169
  addresses: new Map<string, MatterServerRecordWithExpire>(),
1165
1170
  discoveredAt,
1166
- ttl: ttl * 1000,
1171
+ ttl,
1167
1172
  ...txtData,
1168
1173
  };
1169
1174
  }
@@ -1203,12 +1208,12 @@ export class MdnsClient implements Scanner {
1203
1208
  return;
1204
1209
  }
1205
1210
 
1206
- const discoveredAt = Time.nowMs();
1211
+ const discoveredAt = Time.nowMs;
1207
1212
  const device = this.#operationalDeviceRecords.get(matterName) ?? {
1208
1213
  deviceIdentifier: matterName,
1209
1214
  addresses: new Map<string, MatterServerRecordWithExpire>(),
1210
1215
  discoveredAt,
1211
- ttl: ttl * 1000,
1216
+ ttl,
1212
1217
  };
1213
1218
  const ipsInitiallyEmpty = device.addresses.size === 0;
1214
1219
  const { addresses } = device;
@@ -1223,16 +1228,13 @@ export class MdnsClient implements Scanner {
1223
1228
  }
1224
1229
  const address = addresses.get(ip) ?? ({ ip, port, type: "udp" } as MatterServerRecordWithExpire);
1225
1230
  address.discoveredAt = discoveredAt;
1226
- address.ttl = ttl * 1000;
1231
+ address.ttl = ttl;
1227
1232
 
1228
1233
  addresses.set(address.ip, address);
1229
1234
  }
1230
1235
  device.addresses = addresses;
1231
1236
  if (ipsInitiallyEmpty) {
1232
- logger.debug(
1233
- `Added ${addresses.size} IPs for operational device ${matterName} to cache (interface ${netInterface}):`,
1234
- ...MdnsClient.deviceAddressDiagnostics(addresses),
1235
- );
1237
+ logNewAddresses(matterName, "operational", netInterface, addresses);
1236
1238
  }
1237
1239
  this.#operationalDeviceRecords.set(matterName, device);
1238
1240
  }
@@ -1305,10 +1307,7 @@ export class MdnsClient implements Scanner {
1305
1307
  if (storedRecord === undefined) {
1306
1308
  queryMissingDataForInstances.add(name);
1307
1309
 
1308
- logger.debug(
1309
- `Found commissionable device ${name} with data:`,
1310
- MdnsClient.discoveryDataDiagnostics(parsedRecord),
1311
- );
1310
+ logNewService(name, "commissionable", parsedRecord);
1312
1311
  } else {
1313
1312
  parsedRecord.addresses = storedRecord.addresses;
1314
1313
  }
@@ -1346,8 +1345,8 @@ export class MdnsClient implements Scanner {
1346
1345
  }
1347
1346
  const matterServer =
1348
1347
  storedRecord.addresses.get(ip) ?? ({ ip, port, type: "udp" } as MatterServerRecordWithExpire);
1349
- matterServer.discoveredAt = Time.nowMs();
1350
- matterServer.ttl = ttl * 1000;
1348
+ matterServer.discoveredAt = Time.nowMs;
1349
+ matterServer.ttl = ttl;
1351
1350
 
1352
1351
  storedRecord.addresses.set(ip, matterServer);
1353
1352
  }
@@ -1366,10 +1365,7 @@ export class MdnsClient implements Scanner {
1366
1365
  );
1367
1366
  this.#setQueryRecords(queryId, queries, answers);
1368
1367
  } else if (!recordAddressesKnown) {
1369
- logger.debug(
1370
- `Added ${storedRecord.addresses.size} IPs for commissionable device ${record.name} to cache (interface ${netInterface}):`,
1371
- ...MdnsClient.deviceAddressDiagnostics(storedRecord.addresses),
1372
- );
1368
+ logNewAddresses(record.name, "commissionable", netInterface, storedRecord.addresses);
1373
1369
  }
1374
1370
  if (storedRecord.addresses.size === 0) continue;
1375
1371
 
@@ -1404,12 +1400,17 @@ export class MdnsClient implements Scanner {
1404
1400
  for (const item of value) {
1405
1401
  const [key, value] = item.split("=");
1406
1402
  if (key === undefined || value === undefined) continue;
1407
- if (["SII", "SAI", "SAT", "T", "D", "CM", "DT", "PH", "ICD"].includes(key)) {
1403
+ if (["T", "D", "CM", "DT", "PH", "ICD"].includes(key)) {
1408
1404
  const intValue = parseInt(value);
1409
1405
  if (isNaN(intValue)) continue;
1410
1406
  result[key] = intValue;
1411
1407
  } else if (["VP", "DN", "RI", "PI"].includes(key)) {
1412
1408
  result[key] = value;
1409
+ } else if (["SII", "SAI", "SAT"].includes(key)) {
1410
+ const intValue = parseInt(value);
1411
+ if (isNaN(intValue)) continue;
1412
+ result[key] = intValue;
1413
+ result[key] = Millis(intValue);
1413
1414
  }
1414
1415
  }
1415
1416
  }
@@ -1439,14 +1440,14 @@ export class MdnsClient implements Scanner {
1439
1440
  }
1440
1441
  return {
1441
1442
  addresses: new Map<string, MatterServerRecordWithExpire>(),
1442
- discoveredAt: Time.nowMs(),
1443
- ttl: ttl * 1000,
1443
+ discoveredAt: Time.nowMs,
1444
+ ttl,
1444
1445
  ...txtRecord,
1445
1446
  };
1446
1447
  }
1447
1448
 
1448
1449
  #expire() {
1449
- const now = Time.nowMs();
1450
+ const now = Time.nowMs;
1450
1451
  [...this.#operationalDeviceRecords.entries()].forEach(([recordKey, { addresses, discoveredAt, ttl }]) => {
1451
1452
  const expires = discoveredAt + this.#effectiveTTL(ttl);
1452
1453
  if (now <= expires) {
@@ -1486,7 +1487,7 @@ export class MdnsClient implements Scanner {
1486
1487
  Object.keys(data.operational).forEach(recordType => {
1487
1488
  const type = parseInt(recordType);
1488
1489
  data.operational![type] = data.operational![type].filter(
1489
- ({ discoveredAt, ttl }) => now < discoveredAt + this.#effectiveTTL(ttl * 1000),
1490
+ ({ discoveredAt, ttl }) => now < discoveredAt + this.#effectiveTTL(ttl),
1490
1491
  );
1491
1492
  if (data.operational![type].length === 0) {
1492
1493
  delete data.operational![type];
@@ -1497,7 +1498,7 @@ export class MdnsClient implements Scanner {
1497
1498
  Object.keys(data.commissionable).forEach(recordType => {
1498
1499
  const type = parseInt(recordType);
1499
1500
  data.commissionable![type] = data.commissionable![type].filter(
1500
- ({ discoveredAt, ttl }) => now < discoveredAt + this.#effectiveTTL(ttl * 1000),
1501
+ ({ discoveredAt, ttl }) => now < discoveredAt + this.#effectiveTTL(ttl),
1501
1502
  );
1502
1503
  if (data.commissionable![type].length === 0) {
1503
1504
  delete data.commissionable![type];
@@ -1507,7 +1508,7 @@ export class MdnsClient implements Scanner {
1507
1508
  if (data.addressesV6) {
1508
1509
  Object.keys(data.addressesV6).forEach(name => {
1509
1510
  for (const [ip, { discoveredAt, ttl }] of data.addressesV6![name].entries()) {
1510
- if (now < discoveredAt + this.#effectiveTTL(ttl * 1000)) continue; // not expired yet
1511
+ if (now < discoveredAt + this.#effectiveTTL(ttl)) continue; // not expired yet
1511
1512
  data.addressesV6![name].delete(ip);
1512
1513
  }
1513
1514
  if (data.addressesV6![name].size === 0) {
@@ -1518,7 +1519,7 @@ export class MdnsClient implements Scanner {
1518
1519
  if (data.addressesV4) {
1519
1520
  Object.keys(data.addressesV4).forEach(name => {
1520
1521
  for (const [ip, { discoveredAt, ttl }] of data.addressesV4![name].entries()) {
1521
- if (now < discoveredAt + this.#effectiveTTL(ttl * 1000)) continue; // not expired yet
1522
+ if (now < discoveredAt + this.#effectiveTTL(ttl)) continue; // not expired yet
1522
1523
  data.addressesV4![name].delete(ip);
1523
1524
  }
1524
1525
  if (data.addressesV4![name].size === 0) {
@@ -1528,32 +1529,54 @@ export class MdnsClient implements Scanner {
1528
1529
  }
1529
1530
  }
1530
1531
 
1531
- static discoveryDataDiagnostics(data: DiscoveryData) {
1532
- return Diagnostic.dict(
1533
- {
1534
- SII: data.SII,
1535
- SAI: data.SAI,
1536
- SAT: data.SAT,
1537
- T: data.T,
1538
- DT: data.DT,
1539
- PH: data.PH,
1540
- ICD: data.ICD,
1541
- VP: data.VP,
1542
- DN: data.DN,
1543
- RI: data.RI,
1544
- PI: data.PI,
1545
- },
1546
- true,
1547
- );
1532
+ static discoveryDataDiagnostics(data: DiscoveryData, kind?: string) {
1533
+ return Diagnostic.dict({
1534
+ kind,
1535
+ SII: Duration.format(data.SII),
1536
+ SAI: Duration.format(data.SAI),
1537
+ SAT: Duration.format(data.SAT),
1538
+ T: data.T,
1539
+ DT: data.DT,
1540
+ PH: data.PH,
1541
+ ICD: data.ICD,
1542
+ VP: data.VP,
1543
+ DN: data.DN,
1544
+ RI: data.RI,
1545
+ PI: data.PI,
1546
+ });
1548
1547
  }
1549
1548
 
1550
1549
  static deviceAddressDiagnostics(addresses: Map<string, MatterServerRecordWithExpire>) {
1551
- return Array.from(addresses.values()).map(address =>
1552
- Diagnostic.dict({
1553
- type: address.type,
1554
- ip: address.ip,
1555
- port: address.port,
1556
- }),
1557
- );
1550
+ const diagnostic = Array<unknown>();
1551
+ for (const address of addresses.values()) {
1552
+ if (diagnostic.length) {
1553
+ diagnostic.push(", ");
1554
+ }
1555
+ diagnostic.push(ServerAddress.diagnosticFor(address));
1556
+ }
1557
+ return Diagnostic.squash(...diagnostic);
1558
1558
  }
1559
1559
  }
1560
+
1561
+ function logNewService(service: string, kind: string, data: DiscoveryData) {
1562
+ logger.debug("Found device", Diagnostic.strong(service), MdnsClient.discoveryDataDiagnostics(data, kind));
1563
+ }
1564
+
1565
+ function logNewAddresses(
1566
+ service: string,
1567
+ kind: string,
1568
+ intf: string,
1569
+ addresses: Map<string, MatterServerRecordWithExpire>,
1570
+ ) {
1571
+ logger.debug(
1572
+ "Added",
1573
+ addresses.size,
1574
+ "addresses for",
1575
+ Diagnostic.strong(service),
1576
+ Diagnostic.dict({
1577
+ kind,
1578
+ addrs: MdnsClient.deviceAddressDiagnostics(addresses),
1579
+ intf,
1580
+ }),
1581
+ );
1582
+ }
@@ -9,9 +9,12 @@ import {
9
9
  DnsMessageType,
10
10
  DnsRecord,
11
11
  DnsRecordType,
12
+ Instant,
12
13
  isDeepEqual,
13
14
  Logger,
14
15
  MatterAggregateError,
16
+ Millis,
17
+ Minutes,
15
18
  NetworkInterfaceDetails,
16
19
  ObserverGroup,
17
20
  Time,
@@ -38,7 +41,7 @@ export class MdnsServer {
38
41
 
39
42
  return serviceRecords;
40
43
  },
41
- 15 * 60 * 1000 /* 15mn - also matches maximum commissioning window time. */,
44
+ Minutes(15) /* matches maximum standard commissioning window time */,
42
45
  );
43
46
  readonly #recordLastSentAsMulticastAnswer = new Map<string, number>();
44
47
 
@@ -96,12 +99,13 @@ export class MdnsServer {
96
99
  }
97
100
  }
98
101
 
99
- const now = Time.nowMs();
102
+ const now = Time.nowMs;
100
103
  let uniCastResponse = queries.filter(query => !query.uniCastResponse).length === 0;
101
104
  const answersTimeSinceLastSent = answers.map(answer => ({
102
- timeSinceLastMultiCast:
105
+ timeSinceLastMultiCast: Millis(
103
106
  now - (this.#recordLastSentAsMulticastAnswer.get(this.buildDnsRecordKey(answer, sourceIntf)) ?? 0),
104
- ttl: answer.ttl * 1000,
107
+ ),
108
+ ttl: answer.ttl,
105
109
  }));
106
110
  if (
107
111
  uniCastResponse &&
@@ -112,7 +116,8 @@ export class MdnsServer {
112
116
  }
113
117
  if (!uniCastResponse) {
114
118
  answers = answers.filter(
115
- (_, index) => answersTimeSinceLastSent[index].timeSinceLastMultiCast >= 900, // The last time sent as multicast was more than 900 ms ago
119
+ // The last time sent as multicast was more than 900 ms ago
120
+ (_, index) => answersTimeSinceLastSent[index].timeSinceLastMultiCast >= Millis(900),
116
121
  );
117
122
  if (answers.length === 0) continue; // Nothing to send
118
123
 
@@ -135,7 +140,7 @@ export class MdnsServer {
135
140
  .catch(error => {
136
141
  logger.warn(`Failed to send mDNS response to ${sourceIp}`, error);
137
142
  });
138
- await Time.sleep("MDNS delay", 20 + Math.floor(Math.random() * 100)); // as per DNS-SD spec wait 20-120ms before sending more packets
143
+ await Time.sleep("MDNS delay", Millis(20 + Math.floor(Math.random() * 100))); // as per DNS-SD spec wait 20-120ms before sending more packets
139
144
  }
140
145
  }
141
146
 
@@ -162,7 +167,7 @@ export class MdnsServer {
162
167
 
163
168
  // TODO: try to combine the messages to avoid sending multiple messages but keep under 1500 bytes per message
164
169
  await this.#announceRecordsForInterface(netInterface, serviceRecords);
165
- await Time.sleep("MDNS delay", 20 + Math.floor(Math.random() * 100)); // as per DNS-SD spec wait 20-120ms before sending more packets
170
+ await Time.sleep("MDNS delay", Millis(20 + Math.floor(Math.random() * 100))); // as per DNS-SD spec wait 20-120ms before sending more packets
166
171
  }
167
172
  }),
168
173
  "Error announcing MDNS messages",
@@ -177,7 +182,7 @@ export class MdnsServer {
177
182
  if (services.length && !services.includes(service)) continue;
178
183
  const instanceSet = new Set<string>();
179
184
  serviceRecords.forEach(record => {
180
- record.ttl = 0;
185
+ record.ttl = Instant;
181
186
  if (record.recordType === DnsRecordType.TXT) {
182
187
  instanceSet.add(record.name);
183
188
  }
@@ -186,7 +191,7 @@ export class MdnsServer {
186
191
  // TODO: try to combine the messages to avoid sending multiple messages but keep under 1500 bytes per message
187
192
  await this.#announceRecordsForInterface(netInterface, serviceRecords);
188
193
  this.#recordsGenerator.delete(service);
189
- await Time.sleep("MDNS delay", 20 + Math.floor(Math.random() * 100)); // as per DNS-SD spec wait 20-120ms before sending more packets
194
+ await Time.sleep("MDNS delay", Millis(20 + Math.floor(Math.random() * 100))); // as per DNS-SD spec wait 20-120ms before sending more packets
190
195
  }
191
196
  }),
192
197
  "Error happened when expiring MDNS announcements",
@@ -14,14 +14,17 @@ import {
14
14
  ChannelType,
15
15
  ClassExtends,
16
16
  Diagnostic,
17
+ Duration,
17
18
  Environment,
18
19
  Environmental,
19
20
  isIPv6,
20
21
  Logger,
22
+ Millis,
23
+ Minutes,
21
24
  NetInterfaceSet,
22
25
  NoResponseTimeoutError,
26
+ Seconds,
23
27
  ServerAddress,
24
- serverAddressToString,
25
28
  } from "#general";
26
29
  import { InteractionClient, InteractionClientProvider } from "#interaction/InteractionClient.js";
27
30
  import { MdnsClient } from "#mdns/MdnsClient.js";
@@ -115,7 +118,7 @@ export interface DiscoveryAndCommissioningOptions extends CommissioningOptions {
115
118
  knownAddress?: ServerAddress;
116
119
 
117
120
  /** Timeout in seconds for the discovery process. Default: 30 seconds */
118
- timeoutSeconds?: number;
121
+ timeout?: Duration;
119
122
  };
120
123
  }
121
124
 
@@ -179,7 +182,7 @@ export class ControllerCommissioner {
179
182
  channel = await this.#initializePaseSecureChannel(address, passcode, discoveryData);
180
183
  } catch (e) {
181
184
  NoResponseTimeoutError.accept(e);
182
- logger.warn(`Could not connect to ${serverAddressToString(address)}: ${e.message}`);
185
+ logger.warn(`Could not connect to ${ServerAddress.urlFor(address)}: ${e.message}`);
183
186
  }
184
187
  }
185
188
 
@@ -197,7 +200,7 @@ export class ControllerCommissioner {
197
200
  options: DiscoveryAndCommissioningOptions,
198
201
  ): Promise<{ paseSecureChannel: MessageChannel; discoveryData?: DiscoveryData }> {
199
202
  const {
200
- discovery: { timeoutSeconds = 30 },
203
+ discovery: { timeout = Seconds(30) },
201
204
  passcode,
202
205
  } = options;
203
206
 
@@ -256,7 +259,7 @@ export class ControllerCommissioner {
256
259
  const discoveredDevices = await ControllerDiscovery.discoverDeviceAddressesByIdentifier(
257
260
  scannersToUse,
258
261
  identifierData,
259
- timeoutSeconds,
262
+ timeout,
260
263
  );
261
264
 
262
265
  const { result } = await ControllerDiscovery.iterateServerAddresses(
@@ -339,9 +342,9 @@ export class ControllerCommissioner {
339
342
  const unsecureSession = this.#context.sessions.createInsecureSession({
340
343
  // Use the session parameters from MDNS announcements when available and rest is assumed to be fallbacks
341
344
  sessionParameters: {
342
- idleIntervalMs: device?.SII,
343
- activeIntervalMs: device?.SAI,
344
- activeThresholdMs: device?.SAT,
345
+ idleInterval: Millis(device?.SII),
346
+ activeInterval: Millis(device?.SAI),
347
+ activeThreshold: Millis(device?.SAT),
345
348
  },
346
349
  isInitiator: true,
347
350
  });
@@ -478,7 +481,7 @@ export class ControllerCommissioner {
478
481
  return await this.#context.clients.connect(address, {
479
482
  discoveryOptions: {
480
483
  discoveryType: NodeDiscoveryType.TimedDiscovery,
481
- timeoutSeconds: 120,
484
+ timeout: Minutes(2),
482
485
  discoveryData,
483
486
  },
484
487
  allowUnknownPeer: true,