@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
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { Message, MessageCodec } from "#codec/MessageCodec.js";
8
- import { Bytes, Channel, Logger, MatterError, MatterFlowError } from "#general";
8
+ import { Bytes, Channel, Duration, Logger, MatterError, MatterFlowError, Millis, Seconds } from "#general";
9
9
  import type { ExchangeLogContext } from "#protocol/MessageExchange.js";
10
10
  import { Session, SessionParameters } from "#session/Session.js";
11
11
 
@@ -18,13 +18,13 @@ export class ChannelNotConnectedError extends MatterError {}
18
18
  * from chip implementation. This is basically the default used with different names, also kExpectedLowProcessingTime or
19
19
  * kExpectedSigma1ProcessingTime.
20
20
  */
21
- export const DEFAULT_EXPECTED_PROCESSING_TIME_MS = 2000;
21
+ export const DEFAULT_EXPECTED_PROCESSING_TIME = Seconds(2);
22
22
 
23
23
  /**
24
24
  * The buffer time in milliseconds to add to the peer response time to also consider network delays and other factors.
25
25
  * TODO: This is a pure guess and should be adjusted in the future.
26
26
  */
27
- const PEER_RESPONSE_TIME_BUFFER_MS = 5_000;
27
+ const PEER_RESPONSE_TIME_BUFFER = Seconds(5);
28
28
 
29
29
  export namespace MRP {
30
30
  /**
@@ -46,7 +46,7 @@ export namespace MRP {
46
46
  export const BACKOFF_THRESHOLD = 1;
47
47
 
48
48
  /** @see {@link MatterSpecification.v12.Core}, section 4.11.8 */
49
- export const STANDALONE_ACK_TIMEOUT_MS = 200;
49
+ export const STANDALONE_ACK_TIMEOUT = Millis(200);
50
50
  }
51
51
 
52
52
  export class MessageChannel implements Channel<Message> {
@@ -113,26 +113,29 @@ export class MessageChannel implements Channel<Message> {
113
113
  }
114
114
  }
115
115
 
116
- calculateMaximumPeerResponseTimeMs(
116
+ calculateMaximumPeerResponseTime(
117
117
  sessionParameters: SessionParameters,
118
- expectedProcessingTimeMs = DEFAULT_EXPECTED_PROCESSING_TIME_MS,
119
- ) {
118
+ expectedProcessingTime = DEFAULT_EXPECTED_PROCESSING_TIME,
119
+ ): Duration {
120
120
  switch (this.channel.type) {
121
121
  case "tcp":
122
122
  // TCP uses 30s timeout according to chip sdk implementation, so do the same
123
- return 30_000 + PEER_RESPONSE_TIME_BUFFER_MS;
123
+ return Millis(Seconds(30) + PEER_RESPONSE_TIME_BUFFER);
124
+
124
125
  case "udp":
125
126
  // UDP normally uses MRP, if not we have Group communication, which normally have no responses
126
127
  if (!this.usesMrp) {
127
128
  throw new MatterFlowError("No response expected for this message exchange because UDP and no MRP.");
128
129
  }
129
- return (
130
- this.#calculateMrpMaximumPeerResponseTime(sessionParameters, expectedProcessingTimeMs) +
131
- PEER_RESPONSE_TIME_BUFFER_MS
130
+ return Millis(
131
+ this.#calculateMrpMaximumPeerResponseTime(sessionParameters, expectedProcessingTime) +
132
+ PEER_RESPONSE_TIME_BUFFER,
132
133
  );
134
+
133
135
  case "ble":
134
136
  // chip sdk uses BTP_ACK_TIMEOUT_MS which is wrong in my eyes, so we use static 30s as like TCP here
135
- return 30_000 + PEER_RESPONSE_TIME_BUFFER_MS;
137
+ return Millis(Seconds(30) + PEER_RESPONSE_TIME_BUFFER);
138
+
136
139
  default:
137
140
  throw new MatterFlowError(
138
141
  `Can not calculate expected timeout for unknown channel type: ${this.channel.type}`,
@@ -149,27 +152,29 @@ export class MessageChannel implements Channel<Message> {
149
152
  * @see {@link MatterSpecification.v10.Core}, section 4.11.2.1
150
153
  */
151
154
  getMrpResubmissionBackOffTime(retransmissionCount: number, sessionParameters?: SessionParameters) {
152
- const { activeIntervalMs, idleIntervalMs } = sessionParameters ?? this.session.parameters;
155
+ const { activeInterval, idleInterval } = sessionParameters ?? this.session.parameters;
153
156
  const baseInterval =
154
- sessionParameters !== undefined || this.session.isPeerActive() ? activeIntervalMs : idleIntervalMs;
155
- return Math.floor(
156
- MRP.BACKOFF_MARGIN *
157
+ sessionParameters !== undefined || this.session.isPeerActive() ? activeInterval : idleInterval;
158
+ return Millis.floor(
159
+ Millis(
157
160
  baseInterval *
158
- Math.pow(MRP.BACKOFF_BASE, Math.max(0, retransmissionCount - MRP.BACKOFF_THRESHOLD)) *
159
- (1 + (sessionParameters !== undefined ? 1 : Math.random()) * MRP.BACKOFF_JITTER),
161
+ MRP.BACKOFF_MARGIN *
162
+ Math.pow(MRP.BACKOFF_BASE, Math.max(0, retransmissionCount - MRP.BACKOFF_THRESHOLD)) *
163
+ (1 + (sessionParameters !== undefined ? 1 : Math.random()) * MRP.BACKOFF_JITTER),
164
+ ),
160
165
  );
161
166
  }
162
167
 
163
168
  #calculateMrpMaximumPeerResponseTime(
164
169
  sessionParameters: SessionParameters,
165
- expectedProcessingTimeMs = DEFAULT_EXPECTED_PROCESSING_TIME_MS,
170
+ expectedProcessingTime = DEFAULT_EXPECTED_PROCESSING_TIME,
166
171
  ) {
167
172
  // We use the expected processing time and deduct the time we already waited since last resubmission
168
- let finalWaitTime = expectedProcessingTimeMs;
173
+ let finalWaitTime = expectedProcessingTime;
169
174
 
170
175
  // and then add the time the other side needs for a full resubmission cycle under the assumption we are active
171
176
  for (let i = 0; i < MRP.MAX_TRANSMISSIONS; i++) {
172
- finalWaitTime += this.getMrpResubmissionBackOffTime(i, sessionParameters);
177
+ finalWaitTime = Millis(finalWaitTime + this.getMrpResubmissionBackOffTime(i, sessionParameters));
173
178
  }
174
179
 
175
180
  // TODO: Also add any network latency buffer, for now lets consider it's included in the processing time already
@@ -12,17 +12,20 @@ import {
12
12
  CRYPTO_AEAD_MIC_LENGTH_BYTES,
13
13
  DataReadQueue,
14
14
  Diagnostic,
15
+ Duration,
16
+ Instant,
15
17
  InternalError,
16
18
  Logger,
17
19
  MatterError,
18
20
  MatterFlowError,
21
+ Millis,
19
22
  NoResponseTimeoutError,
20
23
  Time,
21
24
  Timer,
22
25
  } from "#general";
23
26
  import {
24
27
  ChannelNotConnectedError,
25
- DEFAULT_EXPECTED_PROCESSING_TIME_MS,
28
+ DEFAULT_EXPECTED_PROCESSING_TIME,
26
29
  MessageChannel,
27
30
  MRP,
28
31
  } from "#protocol/MessageChannel.js";
@@ -70,7 +73,7 @@ export type ExchangeSendOptions = {
70
73
  * Defined an expected processing time by the responder for the message. This is used to calculate the final
71
74
  * timeout for responses together with the normal retransmission logic when MRP is used.
72
75
  */
73
- expectedProcessingTimeMs?: number;
76
+ expectedProcessingTime?: Duration;
74
77
 
75
78
  /** Allows to specify if the send message requires to be acknowledged by the receiver or not. */
76
79
  requiresAck?: boolean;
@@ -137,12 +140,12 @@ export class MessageExchange {
137
140
  );
138
141
  }
139
142
 
140
- readonly #activeIntervalMs: number;
141
- readonly #idleIntervalMs: number;
142
- readonly #activeThresholdMs: number;
143
+ readonly #activeInterval: Duration;
144
+ readonly #idleInterval: Duration;
145
+ readonly #activeThreshold: Duration;
143
146
  readonly #messagesQueue = new DataReadQueue<Message>();
144
147
  #receivedMessageToAck: Message | undefined;
145
- #receivedMessageAckTimer = Time.getTimer("Ack receipt timeout", MRP.STANDALONE_ACK_TIMEOUT_MS, () => {
148
+ #receivedMessageAckTimer = Time.getTimer("Ack receipt timeout", MRP.STANDALONE_ACK_TIMEOUT, () => {
146
149
  if (this.#receivedMessageToAck !== undefined) {
147
150
  const messageToAck = this.#receivedMessageToAck;
148
151
  this.#receivedMessageToAck = undefined;
@@ -188,10 +191,10 @@ export class MessageExchange {
188
191
  this.#exchangeId = exchangeId;
189
192
  this.#protocolId = protocolId;
190
193
 
191
- const { activeIntervalMs, idleIntervalMs, activeThresholdMs } = SessionIntervals(session.parameters);
192
- this.#activeIntervalMs = activeIntervalMs;
193
- this.#idleIntervalMs = idleIntervalMs;
194
- this.#activeThresholdMs = activeThresholdMs;
194
+ const { activeInterval, idleInterval, activeThreshold } = SessionIntervals(session.parameters);
195
+ this.#activeInterval = activeInterval;
196
+ this.#idleInterval = idleInterval;
197
+ this.#activeThreshold = activeThreshold;
195
198
 
196
199
  this.#used = !isInitiator; // If we are the initiator then exchange was not used yet, so track it
197
200
 
@@ -203,9 +206,9 @@ export class MessageExchange {
203
206
  exId: this.#exchangeId,
204
207
  sess: session.name,
205
208
  peerSess: this.#peerSessionId,
206
- SAT: this.#activeThresholdMs,
207
- SAI: this.#activeIntervalMs,
208
- SII: this.#idleIntervalMs,
209
+ SAT: this.#activeThreshold,
210
+ SAI: this.#activeInterval,
211
+ SII: this.#idleInterval,
209
212
  maxTrans: MRP.MAX_TRANSMISSIONS,
210
213
  exchangeFlags: Diagnostic.asFlags({
211
214
  MRP: this.channel.usesMrp,
@@ -353,7 +356,7 @@ export class MessageExchange {
353
356
  const {
354
357
  expectAckOnly = false,
355
358
  disableMrpLogic,
356
- expectedProcessingTimeMs = DEFAULT_EXPECTED_PROCESSING_TIME_MS,
359
+ expectedProcessingTime = DEFAULT_EXPECTED_PROCESSING_TIME,
357
360
  requiresAck,
358
361
  includeAcknowledgeMessageId,
359
362
  logContext,
@@ -440,7 +443,7 @@ export class MessageExchange {
440
443
  this.#retransmissionTimer = Time.getTimer(
441
444
  `Message retransmission ${message.packetHeader.messageId}`,
442
445
  this.channel.getMrpResubmissionBackOffTime(0),
443
- () => this.#retransmitMessage(message, expectedProcessingTimeMs),
446
+ () => this.#retransmitMessage(message, expectedProcessingTime),
444
447
  );
445
448
  const { promise, resolver, rejecter } = createPromise<Message>();
446
449
  ackPromise = promise;
@@ -467,40 +470,41 @@ export class MessageExchange {
467
470
  }
468
471
  }
469
472
 
470
- nextMessage(options?: { expectedProcessingTimeMs?: number; timeoutMs?: number }) {
471
- let timeout: number;
472
- if (options?.timeoutMs !== undefined) {
473
- timeout = options.timeoutMs;
473
+ nextMessage(options?: { expectedProcessingTime?: Duration; timeout?: Duration }) {
474
+ let timeout: Duration;
475
+ if (options?.timeout !== undefined) {
476
+ timeout = options.timeout;
474
477
  } else if (this.#messagesQueue.size > 0) {
475
- timeout = 0; // If we have messages in the queue, we can return them immediately
478
+ timeout = Instant; // If we have messages in the queue, we can return them immediately
476
479
  } else {
477
- timeout = this.channel.calculateMaximumPeerResponseTimeMs(
480
+ timeout = this.channel.calculateMaximumPeerResponseTime(
478
481
  this.context.localSessionParameters,
479
- options?.expectedProcessingTimeMs,
482
+ options?.expectedProcessingTime,
480
483
  );
481
484
  }
482
485
  return this.#messagesQueue.read(timeout);
483
486
  }
484
487
 
485
- calculateMaximumPeerResponseTimeMs(expectedProcessingTimeMs = DEFAULT_EXPECTED_PROCESSING_TIME_MS) {
486
- return this.channel.calculateMaximumPeerResponseTimeMs(
488
+ calculateMaximumPeerResponseTimeMs(expectedProcessingTimeMs = DEFAULT_EXPECTED_PROCESSING_TIME) {
489
+ return this.channel.calculateMaximumPeerResponseTime(
487
490
  this.context.localSessionParameters,
488
491
  expectedProcessingTimeMs,
489
492
  );
490
493
  }
491
494
 
492
- #retransmitMessage(message: Message, expectedProcessingTimeMs?: number) {
495
+ #retransmitMessage(message: Message, expectedProcessingTime?: Duration) {
493
496
  this.#retransmissionCounter++;
494
497
  if (this.#retransmissionCounter >= MRP.MAX_TRANSMISSIONS) {
495
498
  // Ok all 4 resubmissions are done, but we need to wait a bit longer because of processing time and
496
499
  // the resubmissions from the other side
497
- if (expectedProcessingTimeMs !== undefined) {
500
+ if (expectedProcessingTime) {
498
501
  // We already have waited after the last message was sent, so deduct this time from the final wait time
499
- const finalWaitTime =
500
- this.channel.calculateMaximumPeerResponseTimeMs(
502
+ const finalWaitTime = Millis(
503
+ this.channel.calculateMaximumPeerResponseTime(
501
504
  this.context.localSessionParameters,
502
- expectedProcessingTimeMs,
503
- ) - (this.#retransmissionTimer?.intervalMs ?? 0);
505
+ expectedProcessingTime,
506
+ ) - (this.#retransmissionTimer?.interval ?? Instant),
507
+ );
504
508
  if (finalWaitTime > 0) {
505
509
  this.#retransmissionCounter--; // We will not resubmit the message again
506
510
  logger.debug(
@@ -539,18 +543,18 @@ export class MessageExchange {
539
543
 
540
544
  this.channel
541
545
  .send(message)
542
- .then(() => this.#initializeResubmission(message, resubmissionBackoffTime, expectedProcessingTimeMs))
546
+ .then(() => this.#initializeResubmission(message, resubmissionBackoffTime, expectedProcessingTime))
543
547
  .catch(error => {
544
548
  logger.error("An error happened when retransmitting a message", error);
545
549
  if (error instanceof ChannelNotConnectedError) {
546
550
  this.#close().catch(error => logger.error("An error happened when closing the exchange", error));
547
551
  } else {
548
- this.#initializeResubmission(message, resubmissionBackoffTime, expectedProcessingTimeMs);
552
+ this.#initializeResubmission(message, resubmissionBackoffTime, expectedProcessingTime);
549
553
  }
550
554
  });
551
555
  }
552
556
 
553
- #initializeResubmission(message: Message, resubmissionBackoffTime: number, expectedProcessingTimeMs?: number) {
557
+ #initializeResubmission(message: Message, resubmissionBackoffTime: Duration, expectedProcessingTimeMs?: Duration) {
554
558
  this.#retransmissionTimer = Time.getTimer("Message retransmission", resubmissionBackoffTime, () =>
555
559
  this.#retransmitMessage(message, expectedProcessingTimeMs),
556
560
  ).start();
@@ -570,7 +574,7 @@ export class MessageExchange {
570
574
  await this.#close();
571
575
  }
572
576
 
573
- startTimedInteraction(timeoutMs: number) {
577
+ startTimedInteraction(timeout: Duration) {
574
578
  if (this.#timedInteractionTimer !== undefined && this.#timedInteractionTimer.isRunning) {
575
579
  this.#timedInteractionTimer.stop();
576
580
  throw new StatusResponseError(
@@ -579,9 +583,9 @@ export class MessageExchange {
579
583
  );
580
584
  }
581
585
  logger.debug(
582
- `Starting timed interaction with Transaction ID ${this.#exchangeId} for ${timeoutMs}ms from ${this.channel.name}`,
586
+ `Starting timed interaction with Transaction ID ${this.#exchangeId} for ${Duration.format(timeout)} from ${this.channel.name}`,
583
587
  );
584
- this.#timedInteractionTimer = Time.getTimer("Timed interaction", timeoutMs, () => {
588
+ this.#timedInteractionTimer = Time.getTimer("Timed interaction", timeout, () => {
585
589
  logger.debug(
586
590
  `Timed interaction with Transaction ID ${this.#exchangeId} from ${this.channel.name} timed out`,
587
591
  );
@@ -653,9 +657,9 @@ export class MessageExchange {
653
657
  // Wait until all potential Resubmissions are done, also for Standalone-Acks.
654
658
  // We might wait a bit longer then needed but because this is mainly a failsafe mechanism it is acceptable.
655
659
  // in normal case this timer is cancelled before it triggers when all retries are done.
656
- let maxResubmissionTime = 0;
660
+ let maxResubmissionTime = Instant;
657
661
  for (let i = this.#retransmissionCounter; i <= MRP.MAX_TRANSMISSIONS; i++) {
658
- maxResubmissionTime += this.channel.getMrpResubmissionBackOffTime(i);
662
+ maxResubmissionTime = Millis(maxResubmissionTime + this.channel.getMrpResubmissionBackOffTime(i));
659
663
  }
660
664
  this.#closeTimer = Time.getTimer(
661
665
  `Message exchange cleanup ${this.session.name} / ${this.#exchangeId}`,
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { Diagnostic, MatterError, UnexpectedDataError } from "#general";
7
+ import { Diagnostic, Duration, MatterError, Seconds, UnexpectedDataError } from "#general";
8
8
  import { GeneralStatusCode, SecureChannelStatusCode, SecureMessageType, TlvSchema } from "#types";
9
9
  import { Message } from "../codec/MessageCodec.js";
10
10
  import { ExchangeSendOptions, MessageExchange } from "../protocol/MessageExchange.js";
@@ -24,19 +24,19 @@ export class ChannelStatusResponseError extends MatterError {
24
24
  }
25
25
 
26
26
  /** This value is used by chip SDK when performance wise heavy crypto operations are expected. */
27
- export const EXPECTED_CRYPTO_PROCESSING_TIME_MS = 30_000;
27
+ export const EXPECTED_CRYPTO_PROCESSING_TIME = Seconds(30);
28
28
 
29
29
  /** This value is used by chip SDK when normal processing time is expected. */
30
- export const DEFAULT_NORMAL_PROCESSING_TIME_MS = 2_000;
30
+ export const DEFAULT_NORMAL_PROCESSING_TIME = Seconds(2);
31
31
 
32
32
  export class SecureChannelMessenger {
33
- #defaultExpectedProcessingTimeMs: number;
33
+ #defaultExpectedProcessingTime: Duration;
34
34
 
35
35
  constructor(
36
36
  protected readonly exchange: MessageExchange,
37
- defaultExpectedProcessingTimeMs = EXPECTED_CRYPTO_PROCESSING_TIME_MS,
37
+ defaultExpectedProcessingTime = EXPECTED_CRYPTO_PROCESSING_TIME,
38
38
  ) {
39
- this.#defaultExpectedProcessingTimeMs = defaultExpectedProcessingTimeMs;
39
+ this.#defaultExpectedProcessingTime = defaultExpectedProcessingTime;
40
40
  }
41
41
 
42
42
  get channel() {
@@ -45,17 +45,14 @@ export class SecureChannelMessenger {
45
45
 
46
46
  async nextMessage(
47
47
  expectedMessageType: number,
48
- expectedProcessingTimeMs = this.#defaultExpectedProcessingTimeMs,
48
+ expectedProcessingTimeMs = this.#defaultExpectedProcessingTime,
49
49
  expectedMessageInfo?: string,
50
50
  ) {
51
51
  return this.#nextMessage(expectedMessageType, expectedProcessingTimeMs, expectedMessageInfo);
52
52
  }
53
53
 
54
- async anyNextMessage(
55
- expectedMessageInfo: string,
56
- expectedProcessingTimeMs = this.#defaultExpectedProcessingTimeMs,
57
- ) {
58
- return this.#nextMessage(undefined, expectedProcessingTimeMs, expectedMessageInfo);
54
+ async anyNextMessage(expectedMessageInfo: string, expectedProcessingTime = this.#defaultExpectedProcessingTime) {
55
+ return this.#nextMessage(undefined, expectedProcessingTime, expectedMessageInfo);
59
56
  }
60
57
 
61
58
  /**
@@ -65,10 +62,10 @@ export class SecureChannelMessenger {
65
62
  */
66
63
  async #nextMessage(
67
64
  expectedMessageType?: number,
68
- expectedProcessingTimeMs = this.#defaultExpectedProcessingTimeMs,
65
+ expectedProcessingTime = this.#defaultExpectedProcessingTime,
69
66
  expectedMessageInfo?: string,
70
67
  ) {
71
- const message = await this.exchange.nextMessage({ expectedProcessingTimeMs });
68
+ const message = await this.exchange.nextMessage({ expectedProcessingTime });
72
69
  const messageType = message.payloadHeader.messageType;
73
70
  if (expectedMessageType !== undefined && expectedMessageInfo === undefined) {
74
71
  expectedMessageInfo = SecureMessageType[expectedMessageType];
@@ -89,9 +86,9 @@ export class SecureChannelMessenger {
89
86
  async nextMessageDecoded<T>(
90
87
  expectedMessageType: number,
91
88
  schema: TlvSchema<T>,
92
- expectedProcessingTimeMs = this.#defaultExpectedProcessingTimeMs,
89
+ expectedProcessingTime = this.#defaultExpectedProcessingTime,
93
90
  ) {
94
- return schema.decode((await this.nextMessage(expectedMessageType, expectedProcessingTimeMs)).payload);
91
+ return schema.decode((await this.nextMessage(expectedMessageType, expectedProcessingTime)).payload);
95
92
  }
96
93
 
97
94
  /**
@@ -99,12 +96,9 @@ export class SecureChannelMessenger {
99
96
  *
100
97
  * When no expectedProcessingTimeMs is provided, the default value of EXPECTED_CRYPTO_PROCESSING_TIME_MS is used.
101
98
  */
102
- async waitForSuccess(
103
- expectedMessageInfo: string,
104
- expectedProcessingTimeMs = this.#defaultExpectedProcessingTimeMs,
105
- ) {
99
+ async waitForSuccess(expectedMessageInfo: string, expectedProcessingTime = this.#defaultExpectedProcessingTime) {
106
100
  // If the status is not Success, this would throw an Error.
107
- await this.nextMessage(SecureMessageType.StatusReport, expectedProcessingTimeMs, expectedMessageInfo);
101
+ await this.nextMessage(SecureMessageType.StatusReport, expectedProcessingTime, expectedMessageInfo);
108
102
  }
109
103
 
110
104
  /**
@@ -116,7 +110,7 @@ export class SecureChannelMessenger {
116
110
  async send<T>(message: T, type: number, schema: TlvSchema<T>, options?: ExchangeSendOptions) {
117
111
  options = {
118
112
  ...options,
119
- expectedProcessingTimeMs: options?.expectedProcessingTimeMs ?? this.#defaultExpectedProcessingTimeMs,
113
+ expectedProcessingTime: options?.expectedProcessingTime ?? this.#defaultExpectedProcessingTime,
120
114
  };
121
115
  const payload = schema.encode(message);
122
116
  await this.exchange.send(type, payload, options);
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { Crypto, Logger, MatterFlowError } from "#general";
7
+ import { Bytes, Crypto, Logger, MatterFlowError } from "#general";
8
8
  import { NodeId } from "#types";
9
9
  import { DecodedMessage, DecodedPacket, Message, MessageCodec, Packet, SessionType } from "../codec/MessageCodec.js";
10
10
  import { Fabric } from "../fabric/Fabric.js";
@@ -57,7 +57,7 @@ export class InsecureSession extends Session {
57
57
  return MessageCodec.encodePayload(message);
58
58
  }
59
59
 
60
- get attestationChallengeKey(): BufferSource {
60
+ get attestationChallengeKey(): Bytes {
61
61
  throw new MatterFlowError("Not supported on an unsecure session");
62
62
  }
63
63
 
@@ -176,9 +176,9 @@ export class NodeSession extends SecureSession {
176
176
  parameterDiagnostics() {
177
177
  return Diagnostic.dict(
178
178
  {
179
- SII: this.idleIntervalMs,
180
- SAI: this.activeIntervalMs,
181
- SAT: this.activeThresholdMs,
179
+ SII: this.idleInterval,
180
+ SAI: this.activeInterval,
181
+ SAT: this.activeThreshold,
182
182
  DMRev: this.dataModelRevision,
183
183
  IMRev: this.interactionModelRevision,
184
184
  spec: Diagnostic.hex(this.specificationVersion),
@@ -5,7 +5,17 @@
5
5
  */
6
6
 
7
7
  import { SupportedTransportsBitmap } from "#common/SupportedTransportsBitmap.js";
8
- import { AsyncObservable, Bytes, DataWriter, Endian, InternalError, Time } from "#general";
8
+ import {
9
+ AsyncObservable,
10
+ Bytes,
11
+ DataWriter,
12
+ Duration,
13
+ Endian,
14
+ InternalError,
15
+ Time,
16
+ Timespan,
17
+ Timestamp,
18
+ } from "#general";
9
19
  import { NodeId, TypeFromPartialBitSchema } from "#types";
10
20
  import { DecodedMessage, DecodedPacket, Message, Packet, SessionType } from "../codec/MessageCodec.js";
11
21
  import { Fabric } from "../fabric/Fabric.js";
@@ -64,13 +74,13 @@ export abstract class Session {
64
74
  abstract get name(): string;
65
75
  abstract get closingAfterExchangeFinished(): boolean;
66
76
  #manager?: SessionManager;
67
- timestamp = Time.nowMs();
68
- readonly createdAt = Time.nowMs();
69
- activeTimestamp = 0;
77
+ timestamp = Time.nowMs;
78
+ readonly createdAt = Time.nowMs;
79
+ activeTimestamp: Timestamp = 0;
70
80
  abstract type: SessionType;
71
- protected readonly idleIntervalMs: number;
72
- protected readonly activeIntervalMs: number;
73
- protected readonly activeThresholdMs: number;
81
+ protected readonly idleInterval: Duration;
82
+ protected readonly activeInterval: Duration;
83
+ protected readonly activeThreshold: Duration;
74
84
  protected readonly dataModelRevision: number;
75
85
  protected readonly interactionModelRevision: number;
76
86
  protected readonly specificationVersion: number;
@@ -100,9 +110,9 @@ export abstract class Session {
100
110
  messageCounter,
101
111
  messageReceptionState,
102
112
  sessionParameters: {
103
- idleIntervalMs = SessionIntervals.defaults.idleIntervalMs,
104
- activeIntervalMs = SessionIntervals.defaults.activeIntervalMs,
105
- activeThresholdMs = SessionIntervals.defaults.activeThresholdMs,
113
+ idleInterval = SessionIntervals.defaults.idleInterval,
114
+ activeInterval = SessionIntervals.defaults.activeInterval,
115
+ activeThreshold = SessionIntervals.defaults.activeThreshold,
106
116
  dataModelRevision = FALLBACK_DATAMODEL_REVISION,
107
117
  interactionModelRevision = FALLBACK_INTERACTIONMODEL_REVISION,
108
118
  specificationVersion = FALLBACK_SPECIFICATION_VERSION,
@@ -115,9 +125,9 @@ export abstract class Session {
115
125
  this.#manager = manager;
116
126
  this.messageCounter = messageCounter;
117
127
  this.messageReceptionState = messageReceptionState;
118
- this.idleIntervalMs = idleIntervalMs;
119
- this.activeIntervalMs = activeIntervalMs;
120
- this.activeThresholdMs = activeThresholdMs;
128
+ this.idleInterval = idleInterval;
129
+ this.activeInterval = activeInterval;
130
+ this.activeThreshold = activeThreshold;
121
131
  this.dataModelRevision = dataModelRevision;
122
132
  this.interactionModelRevision = interactionModelRevision;
123
133
  this.specificationVersion = specificationVersion;
@@ -134,7 +144,7 @@ export abstract class Session {
134
144
  }
135
145
 
136
146
  notifyActivity(messageReceived: boolean) {
137
- this.timestamp = Time.nowMs();
147
+ this.timestamp = Time.nowMs;
138
148
  if (messageReceived) {
139
149
  // only update active timestamp if we received a message
140
150
  this.activeTimestamp = this.timestamp;
@@ -142,7 +152,7 @@ export abstract class Session {
142
152
  }
143
153
 
144
154
  isPeerActive(): boolean {
145
- return Time.nowMs() - this.activeTimestamp < this.activeThresholdMs;
155
+ return Timespan(this.activeTimestamp, Time.nowMs).duration < this.activeThreshold;
146
156
  }
147
157
 
148
158
  getIncrementedMessageCounter() {
@@ -169,9 +179,9 @@ export abstract class Session {
169
179
  */
170
180
  get parameters(): SessionParameters {
171
181
  const {
172
- idleIntervalMs,
173
- activeIntervalMs,
174
- activeThresholdMs,
182
+ idleInterval,
183
+ activeInterval,
184
+ activeThreshold,
175
185
  dataModelRevision,
176
186
  interactionModelRevision,
177
187
  specificationVersion,
@@ -180,9 +190,9 @@ export abstract class Session {
180
190
  maxTcpMessageSize,
181
191
  } = this;
182
192
  return {
183
- idleIntervalMs,
184
- activeIntervalMs,
185
- activeThresholdMs,
193
+ idleInterval,
194
+ activeInterval,
195
+ activeThreshold,
186
196
  dataModelRevision,
187
197
  interactionModelRevision,
188
198
  specificationVersion,
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { ImplementationError } from "@matter/general";
7
+ import { Duration, Hours, ImplementationError, Millis, Seconds } from "#general";
8
8
 
9
9
  export interface SessionIntervals {
10
10
  /**
@@ -13,7 +13,7 @@ export interface SessionIntervals {
13
13
  *
14
14
  * Default: 500ms
15
15
  */
16
- idleIntervalMs: number;
16
+ idleInterval: Duration;
17
17
 
18
18
  /**
19
19
  * Minimum amount of time between sender retries when the destination node is active. This SHALL be greater than or
@@ -21,27 +21,27 @@ export interface SessionIntervals {
21
21
  *
22
22
  * Default: 300ms
23
23
  */
24
- activeIntervalMs: number;
24
+ activeInterval: Duration;
25
25
 
26
26
  /**
27
27
  * Minimum amount of time the node SHOULD stay active after network activity.
28
28
  *
29
29
  * Default: 4000ms
30
30
  */
31
- activeThresholdMs: number;
31
+ activeThreshold: Duration;
32
32
  }
33
33
 
34
34
  export function SessionIntervals(intervals?: Partial<SessionIntervals>): SessionIntervals {
35
35
  const reified = { ...SessionIntervals.defaults, ...intervals };
36
- const { idleIntervalMs, activeIntervalMs, activeThresholdMs } = reified;
36
+ const { idleInterval, activeInterval, activeThreshold } = reified;
37
37
 
38
- if (idleIntervalMs !== undefined && idleIntervalMs > 3600000) {
38
+ if (idleInterval && idleInterval > Hours.one) {
39
39
  throw new ImplementationError("Session Idle Interval must be less than 1 hour");
40
40
  }
41
- if (activeIntervalMs !== undefined && activeIntervalMs > 3600000) {
41
+ if (activeInterval && activeInterval > Hours.one) {
42
42
  throw new ImplementationError("Session Active Interval must be less than 1 hour");
43
43
  }
44
- if (activeThresholdMs !== undefined && activeThresholdMs > 65535) {
44
+ if (activeThreshold && activeThreshold > Seconds(65535)) {
45
45
  throw new ImplementationError("Session Active Threshold must be less than 65535 seconds");
46
46
  }
47
47
 
@@ -50,8 +50,8 @@ export function SessionIntervals(intervals?: Partial<SessionIntervals>): Session
50
50
 
51
51
  export namespace SessionIntervals {
52
52
  export const defaults = {
53
- idleIntervalMs: 500,
54
- activeIntervalMs: 300,
55
- activeThresholdMs: 4000,
53
+ idleInterval: Millis(500),
54
+ activeInterval: Millis(300),
55
+ activeThreshold: Seconds(4),
56
56
  };
57
57
  }