@matter/protocol 0.16.0-alpha.0-20250812-285b75d83 → 0.16.0-alpha.0-20250815-ac9fd6eb0

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 (333) hide show
  1. package/dist/cjs/advertisement/ble/BleAdvertisement.js +1 -1
  2. package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts +2 -2
  3. package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
  4. package/dist/cjs/ble/Ble.d.ts +2 -2
  5. package/dist/cjs/ble/Ble.d.ts.map +1 -1
  6. package/dist/cjs/ble/Ble.js.map +1 -1
  7. package/dist/cjs/ble/BtpSessionHandler.d.ts +6 -6
  8. package/dist/cjs/ble/BtpSessionHandler.d.ts.map +1 -1
  9. package/dist/cjs/ble/BtpSessionHandler.js +9 -9
  10. package/dist/cjs/ble/BtpSessionHandler.js.map +1 -1
  11. package/dist/cjs/certificate/AttestationCertificateManager.d.ts +5 -5
  12. package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
  13. package/dist/cjs/certificate/AttestationCertificateManager.js +2 -2
  14. package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
  15. package/dist/cjs/certificate/CertificateAuthority.d.ts +5 -5
  16. package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
  17. package/dist/cjs/certificate/CertificateAuthority.js +6 -3
  18. package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
  19. package/dist/cjs/certificate/ChipPAAuthorities.d.ts +8 -8
  20. package/dist/cjs/certificate/DeviceCertification.d.ts +9 -9
  21. package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
  22. package/dist/cjs/certificate/DeviceCertification.js +2 -3
  23. package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
  24. package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +1 -1
  25. package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
  26. package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +1 -1
  27. package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +4 -4
  28. package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
  29. package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +1 -1
  30. package/dist/cjs/certificate/kinds/Icac.d.ts +3 -3
  31. package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -1
  32. package/dist/cjs/certificate/kinds/Icac.js +2 -2
  33. package/dist/cjs/certificate/kinds/Icac.js.map +1 -1
  34. package/dist/cjs/certificate/kinds/Noc.d.ts +3 -3
  35. package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -1
  36. package/dist/cjs/certificate/kinds/Noc.js +2 -2
  37. package/dist/cjs/certificate/kinds/Noc.js.map +1 -1
  38. package/dist/cjs/certificate/kinds/OperationalBase.d.ts +2 -1
  39. package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -1
  40. package/dist/cjs/certificate/kinds/OperationalBase.js +2 -2
  41. package/dist/cjs/certificate/kinds/OperationalBase.js.map +1 -1
  42. package/dist/cjs/certificate/kinds/Rcac.d.ts +3 -3
  43. package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -1
  44. package/dist/cjs/certificate/kinds/Rcac.js +2 -2
  45. package/dist/cjs/certificate/kinds/Rcac.js.map +1 -1
  46. package/dist/cjs/certificate/kinds/X509Base.d.ts +11 -11
  47. package/dist/cjs/certificate/kinds/X509Base.d.ts.map +1 -1
  48. package/dist/cjs/certificate/kinds/X509Base.js +1 -1
  49. package/dist/cjs/certificate/kinds/X509Base.js.map +1 -1
  50. package/dist/cjs/certificate/kinds/common.d.ts +2 -2
  51. package/dist/cjs/certificate/kinds/common.d.ts.map +1 -1
  52. package/dist/cjs/certificate/kinds/common.js +2 -2
  53. package/dist/cjs/certificate/kinds/common.js.map +1 -1
  54. package/dist/cjs/certificate/kinds/definitions/base.d.ts +7 -6
  55. package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -1
  56. package/dist/cjs/certificate/kinds/definitions/base.js.map +1 -1
  57. package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts +1 -1
  58. package/dist/cjs/certificate/kinds/definitions/operational.d.ts +21 -21
  59. package/dist/cjs/codec/BtpCodec.d.ts +12 -11
  60. package/dist/cjs/codec/BtpCodec.d.ts.map +1 -1
  61. package/dist/cjs/codec/BtpCodec.js +1 -1
  62. package/dist/cjs/codec/BtpCodec.js.map +1 -1
  63. package/dist/cjs/codec/MessageCodec.d.ts +8 -8
  64. package/dist/cjs/codec/MessageCodec.d.ts.map +1 -1
  65. package/dist/cjs/codec/MessageCodec.js +2 -2
  66. package/dist/cjs/codec/MessageCodec.js.map +1 -1
  67. package/dist/cjs/common/FailsafeContext.d.ts +8 -8
  68. package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
  69. package/dist/cjs/common/FailsafeContext.js.map +1 -1
  70. package/dist/cjs/common/OperationalCredentialsTypes.d.ts +8 -8
  71. package/dist/cjs/fabric/Fabric.d.ts +27 -27
  72. package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
  73. package/dist/cjs/fabric/Fabric.js +3 -6
  74. package/dist/cjs/fabric/Fabric.js.map +1 -1
  75. package/dist/cjs/fabric/FabricManager.d.ts +2 -2
  76. package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
  77. package/dist/cjs/fabric/FabricManager.js.map +1 -1
  78. package/dist/cjs/groups/FabricGroups.d.ts +4 -4
  79. package/dist/cjs/groups/FabricGroups.d.ts.map +1 -1
  80. package/dist/cjs/groups/Groups.d.ts +1 -1
  81. package/dist/cjs/groups/KeySets.d.ts +12 -12
  82. package/dist/cjs/groups/KeySets.d.ts.map +1 -1
  83. package/dist/cjs/groups/KeySets.js.map +1 -1
  84. package/dist/cjs/groups/MessagingState.d.ts +4 -4
  85. package/dist/cjs/groups/MessagingState.d.ts.map +1 -1
  86. package/dist/cjs/groups/MessagingState.js.map +1 -1
  87. package/dist/cjs/interaction/InteractionMessenger.d.ts +3 -2
  88. package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
  89. package/dist/cjs/interaction/InteractionMessenger.js +9 -9
  90. package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
  91. package/dist/cjs/mdns/MdnsClient.d.ts +2 -2
  92. package/dist/cjs/mdns/MdnsClient.d.ts.map +1 -1
  93. package/dist/cjs/mdns/MdnsClient.js.map +1 -1
  94. package/dist/cjs/mdns/MdnsSocket.d.ts.map +1 -1
  95. package/dist/cjs/mdns/MdnsSocket.js +5 -5
  96. package/dist/cjs/mdns/MdnsSocket.js.map +1 -1
  97. package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
  98. package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
  99. package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -2
  100. package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
  101. package/dist/cjs/protocol/ChannelManager.d.ts +2 -2
  102. package/dist/cjs/protocol/ChannelManager.d.ts.map +1 -1
  103. package/dist/cjs/protocol/ChannelManager.js.map +1 -1
  104. package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
  105. package/dist/cjs/protocol/ExchangeManager.js +4 -3
  106. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  107. package/dist/cjs/protocol/MessageChannel.d.ts +3 -3
  108. package/dist/cjs/protocol/MessageChannel.d.ts.map +1 -1
  109. package/dist/cjs/protocol/MessageChannel.js +2 -2
  110. package/dist/cjs/protocol/MessageChannel.js.map +1 -1
  111. package/dist/cjs/protocol/MessageExchange.d.ts +2 -2
  112. package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
  113. package/dist/cjs/protocol/MessageExchange.js.map +1 -1
  114. package/dist/cjs/protocol/ProtocolStatusMessage.d.ts +6 -5
  115. package/dist/cjs/protocol/ProtocolStatusMessage.d.ts.map +1 -1
  116. package/dist/cjs/protocol/ProtocolStatusMessage.js +1 -1
  117. package/dist/cjs/protocol/ProtocolStatusMessage.js.map +1 -1
  118. package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +1 -1
  119. package/dist/cjs/session/GroupSession.d.ts +5 -4
  120. package/dist/cjs/session/GroupSession.d.ts.map +1 -1
  121. package/dist/cjs/session/GroupSession.js.map +1 -1
  122. package/dist/cjs/session/InsecureSession.d.ts +1 -1
  123. package/dist/cjs/session/InsecureSession.d.ts.map +1 -1
  124. package/dist/cjs/session/InsecureSession.js.map +1 -1
  125. package/dist/cjs/session/NodeSession.d.ts +8 -8
  126. package/dist/cjs/session/NodeSession.d.ts.map +1 -1
  127. package/dist/cjs/session/NodeSession.js +7 -5
  128. package/dist/cjs/session/NodeSession.js.map +1 -1
  129. package/dist/cjs/session/Session.d.ts +4 -4
  130. package/dist/cjs/session/Session.d.ts.map +1 -1
  131. package/dist/cjs/session/Session.js.map +1 -1
  132. package/dist/cjs/session/SessionManager.d.ts +8 -8
  133. package/dist/cjs/session/SessionManager.d.ts.map +1 -1
  134. package/dist/cjs/session/SessionManager.js +1 -2
  135. package/dist/cjs/session/SessionManager.js.map +1 -1
  136. package/dist/cjs/session/case/CaseMessages.d.ts +30 -30
  137. package/dist/cjs/session/case/CaseMessages.d.ts.map +1 -1
  138. package/dist/cjs/session/case/CaseMessenger.d.ts +18 -18
  139. package/dist/cjs/session/pase/PaseClient.d.ts +1 -1
  140. package/dist/cjs/session/pase/PaseMessages.d.ts +8 -8
  141. package/dist/cjs/session/pase/PaseMessenger.d.ts +16 -16
  142. package/dist/cjs/session/pase/PaseMessenger.d.ts.map +1 -1
  143. package/dist/cjs/session/pase/PaseServer.d.ts +3 -3
  144. package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
  145. package/dist/cjs/session/pase/PaseServer.js +3 -2
  146. package/dist/cjs/session/pase/PaseServer.js.map +1 -1
  147. package/dist/esm/advertisement/ble/BleAdvertisement.js +1 -1
  148. package/dist/esm/advertisement/ble/BleAdvertiser.d.ts +2 -2
  149. package/dist/esm/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
  150. package/dist/esm/ble/Ble.d.ts +2 -2
  151. package/dist/esm/ble/Ble.d.ts.map +1 -1
  152. package/dist/esm/ble/Ble.js.map +1 -1
  153. package/dist/esm/ble/BtpSessionHandler.d.ts +6 -6
  154. package/dist/esm/ble/BtpSessionHandler.d.ts.map +1 -1
  155. package/dist/esm/ble/BtpSessionHandler.js +9 -9
  156. package/dist/esm/ble/BtpSessionHandler.js.map +1 -1
  157. package/dist/esm/certificate/AttestationCertificateManager.d.ts +5 -5
  158. package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
  159. package/dist/esm/certificate/AttestationCertificateManager.js +2 -2
  160. package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
  161. package/dist/esm/certificate/CertificateAuthority.d.ts +5 -5
  162. package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
  163. package/dist/esm/certificate/CertificateAuthority.js +6 -3
  164. package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
  165. package/dist/esm/certificate/ChipPAAuthorities.d.ts +8 -8
  166. package/dist/esm/certificate/DeviceCertification.d.ts +9 -9
  167. package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
  168. package/dist/esm/certificate/DeviceCertification.js +3 -4
  169. package/dist/esm/certificate/DeviceCertification.js.map +1 -1
  170. package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +1 -1
  171. package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
  172. package/dist/esm/certificate/kinds/AttestationCertificates.js.map +1 -1
  173. package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +4 -4
  174. package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
  175. package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +1 -1
  176. package/dist/esm/certificate/kinds/Icac.d.ts +3 -3
  177. package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -1
  178. package/dist/esm/certificate/kinds/Icac.js +2 -2
  179. package/dist/esm/certificate/kinds/Icac.js.map +1 -1
  180. package/dist/esm/certificate/kinds/Noc.d.ts +3 -3
  181. package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -1
  182. package/dist/esm/certificate/kinds/Noc.js +2 -2
  183. package/dist/esm/certificate/kinds/Noc.js.map +1 -1
  184. package/dist/esm/certificate/kinds/OperationalBase.d.ts +2 -1
  185. package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -1
  186. package/dist/esm/certificate/kinds/OperationalBase.js +2 -2
  187. package/dist/esm/certificate/kinds/OperationalBase.js.map +1 -1
  188. package/dist/esm/certificate/kinds/Rcac.d.ts +3 -3
  189. package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -1
  190. package/dist/esm/certificate/kinds/Rcac.js +2 -2
  191. package/dist/esm/certificate/kinds/Rcac.js.map +1 -1
  192. package/dist/esm/certificate/kinds/X509Base.d.ts +11 -11
  193. package/dist/esm/certificate/kinds/X509Base.d.ts.map +1 -1
  194. package/dist/esm/certificate/kinds/X509Base.js +1 -1
  195. package/dist/esm/certificate/kinds/X509Base.js.map +1 -1
  196. package/dist/esm/certificate/kinds/common.d.ts +2 -2
  197. package/dist/esm/certificate/kinds/common.d.ts.map +1 -1
  198. package/dist/esm/certificate/kinds/common.js +2 -2
  199. package/dist/esm/certificate/kinds/common.js.map +1 -1
  200. package/dist/esm/certificate/kinds/definitions/base.d.ts +7 -6
  201. package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -1
  202. package/dist/esm/certificate/kinds/definitions/base.js.map +1 -1
  203. package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts +1 -1
  204. package/dist/esm/certificate/kinds/definitions/operational.d.ts +21 -21
  205. package/dist/esm/codec/BtpCodec.d.ts +12 -11
  206. package/dist/esm/codec/BtpCodec.d.ts.map +1 -1
  207. package/dist/esm/codec/BtpCodec.js +1 -1
  208. package/dist/esm/codec/BtpCodec.js.map +1 -1
  209. package/dist/esm/codec/MessageCodec.d.ts +8 -8
  210. package/dist/esm/codec/MessageCodec.d.ts.map +1 -1
  211. package/dist/esm/codec/MessageCodec.js +2 -2
  212. package/dist/esm/codec/MessageCodec.js.map +1 -1
  213. package/dist/esm/common/FailsafeContext.d.ts +8 -8
  214. package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
  215. package/dist/esm/common/FailsafeContext.js.map +1 -1
  216. package/dist/esm/common/OperationalCredentialsTypes.d.ts +8 -8
  217. package/dist/esm/fabric/Fabric.d.ts +27 -27
  218. package/dist/esm/fabric/Fabric.d.ts.map +1 -1
  219. package/dist/esm/fabric/Fabric.js +3 -6
  220. package/dist/esm/fabric/Fabric.js.map +1 -1
  221. package/dist/esm/fabric/FabricManager.d.ts +2 -2
  222. package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
  223. package/dist/esm/fabric/FabricManager.js.map +1 -1
  224. package/dist/esm/groups/FabricGroups.d.ts +4 -4
  225. package/dist/esm/groups/FabricGroups.d.ts.map +1 -1
  226. package/dist/esm/groups/Groups.d.ts +1 -1
  227. package/dist/esm/groups/KeySets.d.ts +12 -12
  228. package/dist/esm/groups/KeySets.d.ts.map +1 -1
  229. package/dist/esm/groups/KeySets.js.map +1 -1
  230. package/dist/esm/groups/MessagingState.d.ts +4 -4
  231. package/dist/esm/groups/MessagingState.d.ts.map +1 -1
  232. package/dist/esm/groups/MessagingState.js.map +1 -1
  233. package/dist/esm/interaction/InteractionMessenger.d.ts +3 -2
  234. package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
  235. package/dist/esm/interaction/InteractionMessenger.js +9 -9
  236. package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
  237. package/dist/esm/mdns/MdnsClient.d.ts +2 -2
  238. package/dist/esm/mdns/MdnsClient.d.ts.map +1 -1
  239. package/dist/esm/mdns/MdnsClient.js.map +1 -1
  240. package/dist/esm/mdns/MdnsSocket.d.ts.map +1 -1
  241. package/dist/esm/mdns/MdnsSocket.js +5 -5
  242. package/dist/esm/mdns/MdnsSocket.js.map +1 -1
  243. package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
  244. package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
  245. package/dist/esm/peer/ControllerCommissioningFlow.js +2 -2
  246. package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
  247. package/dist/esm/protocol/ChannelManager.d.ts +2 -2
  248. package/dist/esm/protocol/ChannelManager.d.ts.map +1 -1
  249. package/dist/esm/protocol/ChannelManager.js.map +1 -1
  250. package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
  251. package/dist/esm/protocol/ExchangeManager.js +5 -3
  252. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  253. package/dist/esm/protocol/MessageChannel.d.ts +3 -3
  254. package/dist/esm/protocol/MessageChannel.d.ts.map +1 -1
  255. package/dist/esm/protocol/MessageChannel.js +2 -2
  256. package/dist/esm/protocol/MessageChannel.js.map +1 -1
  257. package/dist/esm/protocol/MessageExchange.d.ts +2 -2
  258. package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
  259. package/dist/esm/protocol/MessageExchange.js.map +1 -1
  260. package/dist/esm/protocol/ProtocolStatusMessage.d.ts +6 -5
  261. package/dist/esm/protocol/ProtocolStatusMessage.d.ts.map +1 -1
  262. package/dist/esm/protocol/ProtocolStatusMessage.js +1 -1
  263. package/dist/esm/protocol/ProtocolStatusMessage.js.map +1 -1
  264. package/dist/esm/securechannel/SecureChannelMessenger.d.ts +1 -1
  265. package/dist/esm/session/GroupSession.d.ts +5 -4
  266. package/dist/esm/session/GroupSession.d.ts.map +1 -1
  267. package/dist/esm/session/GroupSession.js.map +1 -1
  268. package/dist/esm/session/InsecureSession.d.ts +1 -1
  269. package/dist/esm/session/InsecureSession.d.ts.map +1 -1
  270. package/dist/esm/session/InsecureSession.js.map +1 -1
  271. package/dist/esm/session/NodeSession.d.ts +8 -8
  272. package/dist/esm/session/NodeSession.d.ts.map +1 -1
  273. package/dist/esm/session/NodeSession.js +7 -5
  274. package/dist/esm/session/NodeSession.js.map +1 -1
  275. package/dist/esm/session/Session.d.ts +4 -4
  276. package/dist/esm/session/Session.d.ts.map +1 -1
  277. package/dist/esm/session/Session.js.map +1 -1
  278. package/dist/esm/session/SessionManager.d.ts +8 -8
  279. package/dist/esm/session/SessionManager.d.ts.map +1 -1
  280. package/dist/esm/session/SessionManager.js +1 -2
  281. package/dist/esm/session/SessionManager.js.map +1 -1
  282. package/dist/esm/session/case/CaseMessages.d.ts +30 -30
  283. package/dist/esm/session/case/CaseMessages.d.ts.map +1 -1
  284. package/dist/esm/session/case/CaseMessenger.d.ts +18 -18
  285. package/dist/esm/session/pase/PaseClient.d.ts +1 -1
  286. package/dist/esm/session/pase/PaseMessages.d.ts +8 -8
  287. package/dist/esm/session/pase/PaseMessenger.d.ts +16 -16
  288. package/dist/esm/session/pase/PaseMessenger.d.ts.map +1 -1
  289. package/dist/esm/session/pase/PaseServer.d.ts +3 -3
  290. package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
  291. package/dist/esm/session/pase/PaseServer.js +3 -2
  292. package/dist/esm/session/pase/PaseServer.js.map +1 -1
  293. package/package.json +6 -6
  294. package/src/advertisement/ble/BleAdvertisement.ts +1 -1
  295. package/src/advertisement/ble/BleAdvertiser.ts +1 -1
  296. package/src/ble/Ble.ts +2 -2
  297. package/src/ble/BtpSessionHandler.ts +20 -20
  298. package/src/certificate/AttestationCertificateManager.ts +5 -5
  299. package/src/certificate/CertificateAuthority.ts +14 -11
  300. package/src/certificate/DeviceCertification.ts +11 -13
  301. package/src/certificate/kinds/AttestationCertificates.ts +1 -1
  302. package/src/certificate/kinds/CertificationDeclaration.ts +3 -6
  303. package/src/certificate/kinds/Icac.ts +3 -3
  304. package/src/certificate/kinds/Noc.ts +3 -3
  305. package/src/certificate/kinds/OperationalBase.ts +4 -4
  306. package/src/certificate/kinds/Rcac.ts +3 -3
  307. package/src/certificate/kinds/X509Base.ts +7 -7
  308. package/src/certificate/kinds/common.ts +4 -4
  309. package/src/certificate/kinds/definitions/base.ts +7 -6
  310. package/src/codec/BtpCodec.ts +13 -13
  311. package/src/codec/MessageCodec.ts +10 -10
  312. package/src/common/FailsafeContext.ts +6 -5
  313. package/src/fabric/Fabric.ts +31 -34
  314. package/src/fabric/FabricManager.ts +1 -1
  315. package/src/groups/KeySets.ts +6 -6
  316. package/src/groups/MessagingState.ts +3 -3
  317. package/src/interaction/InteractionMessenger.ts +12 -11
  318. package/src/mdns/MdnsClient.ts +2 -2
  319. package/src/mdns/MdnsSocket.ts +7 -6
  320. package/src/peer/ControllerCommissioner.ts +2 -1
  321. package/src/peer/ControllerCommissioningFlow.ts +5 -5
  322. package/src/protocol/ChannelManager.ts +3 -3
  323. package/src/protocol/ExchangeManager.ts +7 -5
  324. package/src/protocol/MessageChannel.ts +4 -4
  325. package/src/protocol/MessageExchange.ts +2 -1
  326. package/src/protocol/ProtocolStatusMessage.ts +6 -6
  327. package/src/session/GroupSession.ts +7 -7
  328. package/src/session/InsecureSession.ts +1 -1
  329. package/src/session/NodeSession.ts +17 -15
  330. package/src/session/Session.ts +3 -3
  331. package/src/session/SessionManager.ts +9 -10
  332. package/src/session/case/CaseServer.ts +8 -8
  333. package/src/session/pase/PaseServer.ts +5 -4
@@ -26,7 +26,7 @@ const logger = Logger.get("BtpSessionHandler");
26
26
 
27
27
  export class BtpSessionHandler {
28
28
  private currentIncomingSegmentedMsgLength: number | undefined;
29
- private currentIncomingSegmentedPayload: Uint8Array | undefined;
29
+ private currentIncomingSegmentedPayload: Bytes | undefined;
30
30
  private prevIncomingSequenceNumber = 255; // Incoming Sequence Number received. Set to 255 to start at 0
31
31
  private prevIncomingAckNumber = -1; // Previous ackNumber received
32
32
  private readonly ackReceiveTimer = Time.getTimer("BTP ack timeout", BTP_ACK_TIMEOUT_MS, () =>
@@ -49,10 +49,10 @@ export class BtpSessionHandler {
49
49
  /** Factory method to create a new BTPSessionHandler from a received handshake request */
50
50
  static async createFromHandshakeRequest(
51
51
  maxDataSize: number | undefined,
52
- handshakeRequestPayload: Uint8Array,
53
- writeBleCallback: (data: Uint8Array) => Promise<void>,
52
+ handshakeRequestPayload: Bytes,
53
+ writeBleCallback: (data: Bytes) => Promise<void>,
54
54
  disconnectBleCallback: () => Promise<void>,
55
- handleMatterMessagePayload: (data: Uint8Array) => Promise<void>,
55
+ handleMatterMessagePayload: (data: Bytes) => Promise<void>,
56
56
  ): Promise<BtpSessionHandler> {
57
57
  // Decode handshake request
58
58
  const handshakeRequest = BtpCodec.decodeBtpHandshakeRequest(handshakeRequestPayload);
@@ -117,10 +117,10 @@ export class BtpSessionHandler {
117
117
  }
118
118
 
119
119
  static async createAsCentral(
120
- handshakeResponsePayload: Uint8Array,
121
- writeBleCallback: (data: Uint8Array) => Promise<void>,
120
+ handshakeResponsePayload: Bytes,
121
+ writeBleCallback: (data: Bytes) => Promise<void>,
122
122
  disconnectBleCallback: () => Promise<void>,
123
- handleMatterMessagePayload: (data: Uint8Array) => Promise<void>,
123
+ handleMatterMessagePayload: (data: Bytes) => Promise<void>,
124
124
  ) {
125
125
  const handshakeRequest = BtpCodec.decodeBtpHandshakeResponsePayload(handshakeResponsePayload);
126
126
 
@@ -156,9 +156,9 @@ export class BtpSessionHandler {
156
156
  btpVersion: number,
157
157
  private readonly fragmentSize: number,
158
158
  private readonly clientWindowSize: number,
159
- private readonly writeBleCallback: (data: Uint8Array) => Promise<void>,
159
+ private readonly writeBleCallback: (data: Bytes) => Promise<void>,
160
160
  private readonly disconnectBleCallback: () => Promise<void>,
161
- private readonly handleMatterMessagePayload: (data: Uint8Array) => Promise<void>,
161
+ private readonly handleMatterMessagePayload: (data: Bytes) => Promise<void>,
162
162
  ) {
163
163
  if (btpVersion !== 4) {
164
164
  throw new BtpProtocolError(`Unsupported BTP version ${btpVersion}`);
@@ -179,21 +179,21 @@ export class BtpSessionHandler {
179
179
  *
180
180
  * @param data ByteArray containing the data
181
181
  */
182
- public async handleIncomingBleData(data: Uint8Array) {
182
+ public async handleIncomingBleData(data: Bytes) {
183
183
  if (!this.isActive) {
184
184
  logger.debug(`BTP session is not active, ignoring incoming BLE data`);
185
185
  return;
186
186
  }
187
187
  try {
188
- if (data.length > this.fragmentSize) {
188
+ if (data.byteLength > this.fragmentSize) {
189
189
  // Apple seems to interpret the ATT_MTU as the maximum size of a single ATT packet
190
- if (data.length > this.fragmentSize + 3) {
190
+ if (data.byteLength > this.fragmentSize + 3) {
191
191
  throw new BtpProtocolError(
192
- `Received data ${data.length} bytes exceeds fragment size of ${this.fragmentSize} bytes`,
192
+ `Received data ${data.byteLength} bytes exceeds fragment size of ${this.fragmentSize} bytes`,
193
193
  );
194
194
  } else {
195
195
  logger.warn(
196
- `Received data ${data.length} bytes exceeds fragment size of ${this.fragmentSize} bytes, still accepting`,
196
+ `Received data ${data.byteLength} bytes exceeds fragment size of ${this.fragmentSize} bytes, still accepting`,
197
197
  );
198
198
  }
199
199
  }
@@ -214,7 +214,7 @@ export class BtpSessionHandler {
214
214
  if (isHandshakeRequest || hasManagementOpcode) {
215
215
  throw new BtpProtocolError("BTP packet must not be a handshake request or have a management opcode.");
216
216
  }
217
- if (segmentPayload.length === 0 && !hasAckNumber) {
217
+ if (segmentPayload.byteLength === 0 && !hasAckNumber) {
218
218
  throw new BtpProtocolError("BTP packet must have a segment payload or an ack number.");
219
219
  }
220
220
 
@@ -261,7 +261,7 @@ export class BtpSessionHandler {
261
261
  if (this.currentIncomingSegmentedPayload === undefined) {
262
262
  throw new BtpProtocolError(`BTP Continuing or ending packet received without beginning packet.`);
263
263
  }
264
- if (segmentPayload.length === 0) {
264
+ if (segmentPayload.byteLength === 0) {
265
265
  throw new BtpProtocolError(`BTP Continuing or ending packet received without payload.`);
266
266
  }
267
267
  this.currentIncomingSegmentedPayload = Bytes.concat(
@@ -277,9 +277,9 @@ export class BtpSessionHandler {
277
277
  ) {
278
278
  throw new BtpProtocolError("BTP beginning packet missing but ending packet received.");
279
279
  }
280
- if (this.currentIncomingSegmentedPayload.length !== this.currentIncomingSegmentedMsgLength) {
280
+ if (this.currentIncomingSegmentedPayload.byteLength !== this.currentIncomingSegmentedMsgLength) {
281
281
  throw new BtpProtocolError(
282
- `BTP packet payload length does not match message length: ${this.currentIncomingSegmentedPayload.length} !== ${this.currentIncomingSegmentedMsgLength}`,
282
+ `BTP packet payload length does not match message length: ${this.currentIncomingSegmentedPayload.byteLength} !== ${this.currentIncomingSegmentedMsgLength}`,
283
283
  );
284
284
  }
285
285
 
@@ -306,13 +306,13 @@ export class BtpSessionHandler {
306
306
  *
307
307
  * @param data ByteArray containing the Matter message
308
308
  */
309
- public async sendMatterMessage(data: Uint8Array) {
309
+ public async sendMatterMessage(data: Bytes) {
310
310
  if (!this.isActive) {
311
311
  throw new BtpFlowError("BTP session is not active");
312
312
  }
313
313
  logger.debug(`Got Matter message to send via BLE transport: ${Bytes.toHex(data)}`);
314
314
 
315
- if (data.length === 0) {
315
+ if (data.byteLength === 0) {
316
316
  throw new BtpFlowError("BTP packet must not be empty");
317
317
  }
318
318
  const dataReader = new DataReader(data, Endian.Little);
@@ -40,13 +40,13 @@ export class AttestationCertificateManager {
40
40
  readonly #crypto: Crypto;
41
41
  readonly #vendorId: VendorId;
42
42
  readonly #paiKeyPair: PrivateKey;
43
- readonly #paiKeyIdentifier: Uint8Array;
43
+ readonly #paiKeyIdentifier: Bytes;
44
44
  readonly #paaKeyIdentifier = TestCert_PAA_NoVID_SKID;
45
45
  readonly #paiCertId = BigInt(1);
46
46
  readonly #paiCertBytes;
47
47
  #nextCertificateId = 2;
48
48
 
49
- constructor(crypto: Crypto, vendorId: VendorId, paiKeyPair: PrivateKey, paiKeyIdentifier: Uint8Array) {
49
+ constructor(crypto: Crypto, vendorId: VendorId, paiKeyPair: PrivateKey, paiKeyIdentifier: Bytes) {
50
50
  this.#crypto = crypto;
51
51
  this.#vendorId = vendorId;
52
52
  this.#paiKeyPair = paiKeyPair;
@@ -56,7 +56,7 @@ export class AttestationCertificateManager {
56
56
 
57
57
  static async create(crypto: Crypto, vendorId: VendorId) {
58
58
  const key = await crypto.createKeyPair();
59
- const identifier = await crypto.computeSha256(key.publicKey);
59
+ const identifier = Bytes.of(await crypto.computeSha256(key.publicKey));
60
60
  return new AttestationCertificateManager(crypto, vendorId, key, identifier.slice(0, 20));
61
61
  }
62
62
 
@@ -145,7 +145,7 @@ export class AttestationCertificateManager {
145
145
  return cert.asSignedAsn1();
146
146
  }
147
147
 
148
- async generateDaCert(publicKey: Uint8Array, vendorId: VendorId, productId: number) {
148
+ async generateDaCert(publicKey: Bytes, vendorId: VendorId, productId: number) {
149
149
  const now = Time.get().now();
150
150
  const certId = this.#nextCertificateId++;
151
151
  const cert = new Dac({
@@ -172,7 +172,7 @@ export class AttestationCertificateManager {
172
172
  keyUsage: {
173
173
  digitalSignature: true,
174
174
  },
175
- subjectKeyIdentifier: (await this.#crypto.computeSha256(publicKey)).slice(0, 20),
175
+ subjectKeyIdentifier: Bytes.of(await this.#crypto.computeSha256(publicKey)).slice(0, 20),
176
176
  authorityKeyIdentifier: this.#paiKeyIdentifier,
177
177
  },
178
178
  });
@@ -35,8 +35,8 @@ export class CertificateAuthority {
35
35
  #crypto: Crypto;
36
36
  #rootCertId = BigInt(0);
37
37
  #rootKeyPair?: PrivateKey;
38
- #rootKeyIdentifier?: Uint8Array<ArrayBufferLike>;
39
- #rootCertBytes?: Uint8Array<ArrayBufferLike>;
38
+ #rootKeyIdentifier?: Bytes;
39
+ #rootCertBytes?: Bytes;
40
40
  #nextCertificateId = BigInt(1);
41
41
  #construction: Construction<CertificateAuthority>;
42
42
 
@@ -59,14 +59,17 @@ export class CertificateAuthority {
59
59
  const certValues = options instanceof StorageContext ? await options.values() : (options ?? {});
60
60
 
61
61
  this.#rootKeyPair = await this.#crypto.createKeyPair();
62
- this.#rootKeyIdentifier = (await this.#crypto.computeSha256(this.#rootKeyPair.publicKey)).slice(0, 20);
62
+ this.#rootKeyIdentifier = Bytes.of(await this.#crypto.computeSha256(this.#rootKeyPair.publicKey)).slice(
63
+ 0,
64
+ 20,
65
+ );
63
66
  this.#rootCertBytes = await this.#generateRootCert();
64
67
 
65
68
  if (
66
69
  (typeof certValues.rootCertId === "number" || typeof certValues.rootCertId === "bigint") &&
67
- (ArrayBuffer.isView(certValues.rootKeyPair) || typeof certValues.rootKeyPair === "object") &&
68
- ArrayBuffer.isView(certValues.rootKeyIdentifier) &&
69
- ArrayBuffer.isView(certValues.rootCertBytes) &&
70
+ (Bytes.isBytes(certValues.rootKeyPair) || typeof certValues.rootKeyPair === "object") &&
71
+ Bytes.isBytes(certValues.rootKeyIdentifier) &&
72
+ Bytes.isBytes(certValues.rootCertBytes) &&
70
73
  (typeof certValues.nextCertificateId === "number" || typeof certValues.nextCertificateId === "bigint")
71
74
  ) {
72
75
  this.#rootCertId = BigInt(certValues.rootCertId);
@@ -99,7 +102,7 @@ export class CertificateAuthority {
99
102
  return instance;
100
103
  }
101
104
 
102
- get rootCert() {
105
+ get rootCert(): Bytes {
103
106
  return this.#construction.assert("root cert", this.#rootCertBytes);
104
107
  }
105
108
 
@@ -140,7 +143,7 @@ export class CertificateAuthority {
140
143
  }
141
144
 
142
145
  async generateNoc(
143
- publicKey: Uint8Array,
146
+ publicKey: Bytes,
144
147
  fabricId: FabricId,
145
148
  nodeId: NodeId,
146
149
  caseAuthenticatedTags?: CaseAuthenticatedTag[],
@@ -163,7 +166,7 @@ export class CertificateAuthority {
163
166
  digitalSignature: true,
164
167
  },
165
168
  extendedKeyUsage: [2, 1],
166
- subjectKeyIdentifier: (await this.#crypto.computeSha256(publicKey)).slice(0, 20),
169
+ subjectKeyIdentifier: Bytes.of(await this.#crypto.computeSha256(publicKey)).slice(0, 20),
167
170
  authorityKeyIdentifier: this.#initializedRootKeyIdentifier,
168
171
  },
169
172
  });
@@ -190,8 +193,8 @@ export namespace CertificateAuthority {
190
193
  export type Configuration = {
191
194
  rootCertId: bigint;
192
195
  rootKeyPair: BinaryKeyPair;
193
- rootKeyIdentifier: Uint8Array;
194
- rootCertBytes: Uint8Array;
196
+ rootKeyIdentifier: Bytes;
197
+ rootCertBytes: Bytes;
195
198
  nextCertificateId: bigint;
196
199
  };
197
200
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { CertificationDeclaration } from "#certificate/kinds/CertificationDeclaration.js";
8
- import { Construction, Crypto, ImplementationError, InternalError, PrivateKey } from "#general";
8
+ import { Bytes, Construction, Crypto, ImplementationError, InternalError, PrivateKey } from "#general";
9
9
  import { NodeSession } from "#session/NodeSession.js";
10
10
  import { ProductDescription } from "#types";
11
11
  import { AttestationCertificateManager } from "./AttestationCertificateManager.js";
@@ -16,9 +16,9 @@ import { AttestationCertificateManager } from "./AttestationCertificateManager.j
16
16
  export class DeviceCertification {
17
17
  #crypto: Crypto;
18
18
  #privateKey?: PrivateKey;
19
- #certificate?: Uint8Array;
20
- #intermediateCertificate?: Uint8Array;
21
- #declaration?: Uint8Array;
19
+ #certificate?: Bytes;
20
+ #intermediateCertificate?: Bytes;
21
+ #declaration?: Bytes;
22
22
  readonly #construction: Construction<DeviceCertification>;
23
23
 
24
24
  get construction() {
@@ -65,18 +65,16 @@ export class DeviceCertification {
65
65
  this.#construction = Construction(this, async () => {
66
66
  const config = await configProvider();
67
67
 
68
- this.#privateKey =
69
- config.privateKey instanceof Uint8Array ? PrivateKey(config.privateKey) : config.privateKey;
68
+ this.#privateKey = Bytes.isBytes(config.privateKey) ? PrivateKey(config.privateKey) : config.privateKey;
70
69
  this.#certificate = config.certificate;
71
70
  this.#intermediateCertificate = config.intermediateCertificate;
72
71
  this.#declaration = config.declaration;
73
72
  });
74
73
  }
75
74
 
76
- async sign(session: NodeSession, data: Uint8Array) {
75
+ async sign(session: NodeSession, data: Bytes) {
77
76
  const { privateKey } = this.#assertInitialized();
78
- const signature = await this.#crypto.signEcdsa(privateKey, [data, session.attestationChallengeKey]);
79
- return signature;
77
+ return this.#crypto.signEcdsa(privateKey, [data, session.attestationChallengeKey]);
80
78
  }
81
79
 
82
80
  /**
@@ -106,10 +104,10 @@ export class DeviceCertification {
106
104
 
107
105
  export namespace DeviceCertification {
108
106
  export interface Configuration {
109
- privateKey: PrivateKey | Uint8Array;
110
- certificate: Uint8Array;
111
- intermediateCertificate: Uint8Array;
112
- declaration: Uint8Array;
107
+ privateKey: PrivateKey | Bytes;
108
+ certificate: Bytes;
109
+ intermediateCertificate: Bytes;
110
+ declaration: Bytes;
113
111
  }
114
112
 
115
113
  export type Definition = Configuration | (() => Promise<Configuration>);
@@ -26,7 +26,7 @@ export abstract class AttestationBaseCertificate<CT extends X509Certificate> ext
26
26
  * Returns the signed certificate in ASN.1 DER format.
27
27
  * If the certificate is not signed, it throws a CertificateError.
28
28
  */
29
- asSignedAsn1(): Uint8Array<ArrayBufferLike> {
29
+ asSignedAsn1() {
30
30
  const certificate = this.genericBuildAsn1Structure(this.cert);
31
31
  const certBytes = DerCodec.encode({
32
32
  certificate,
@@ -32,8 +32,8 @@ const TestCMS_SignerSubjectKeyIdentifier = Bytes.fromHex("62FA823359ACFAA9963E1C
32
32
 
33
33
  /** A Matter Certification Declaration */
34
34
  export class CertificationDeclaration {
35
- #eContent: Uint8Array;
36
- #subjectKeyIdentifier: Uint8Array;
35
+ #eContent: Bytes;
36
+ #subjectKeyIdentifier: Bytes;
37
37
 
38
38
  /**
39
39
  * Generator which is the main usage for the class from outside.
@@ -58,10 +58,7 @@ export class CertificationDeclaration {
58
58
  return cd.asSignedAsn1(crypto, PrivateKey(TestCMS_SignerPrivateKey));
59
59
  }
60
60
 
61
- constructor(
62
- content: TypeFromBitmapSchema<typeof CertificationDeclarationDef.TlvDc>,
63
- subjectKeyIdentifier: Uint8Array,
64
- ) {
61
+ constructor(content: TypeFromBitmapSchema<typeof CertificationDeclarationDef.TlvDc>, subjectKeyIdentifier: Bytes) {
65
62
  this.#eContent = CertificationDeclarationDef.TlvDc.encode(content);
66
63
  this.#subjectKeyIdentifier = subjectKeyIdentifier;
67
64
  }
@@ -17,7 +17,7 @@ import { Rcac } from "./Rcac.js";
17
17
  */
18
18
  export class Icac extends OperationalBase<OperationalCertificate.Icac> {
19
19
  /** Construct the class from a Tlv version of the certificate */
20
- static fromTlv(tlv: Uint8Array): Icac {
20
+ static fromTlv(tlv: Bytes): Icac {
21
21
  return new Icac(OperationalCertificate.TlvIcac.decode(tlv));
22
22
  }
23
23
 
@@ -132,7 +132,7 @@ export class Icac extends OperationalBase<OperationalCertificate.Icac> {
132
132
  if (subjectKeyIdentifier === undefined) {
133
133
  throw new CertificateError(`Ica certificate must have subjectKeyIdentifier set.`);
134
134
  }
135
- if (subjectKeyIdentifier.length !== 20) {
135
+ if (subjectKeyIdentifier.byteLength !== 20) {
136
136
  throw new CertificateError(`Ica certificate subjectKeyIdentifier must be 160 bit.`);
137
137
  }
138
138
 
@@ -140,7 +140,7 @@ export class Icac extends OperationalBase<OperationalCertificate.Icac> {
140
140
  if (authorityKeyIdentifier === undefined) {
141
141
  throw new CertificateError(`Ica certificate must have authorityKeyIdentifier set.`);
142
142
  }
143
- if (authorityKeyIdentifier.length !== 20) {
143
+ if (authorityKeyIdentifier.byteLength !== 20) {
144
144
  throw new CertificateError(`Ica certificate authorityKeyIdentifier must be 160 bit.`);
145
145
  }
146
146
 
@@ -14,7 +14,7 @@ import { Rcac } from "./Rcac.js";
14
14
 
15
15
  export class Noc extends OperationalBase<OperationalCertificate.Noc> {
16
16
  /** Construct the class from a Tlv version of the certificate */
17
- static fromTlv(tlv: Uint8Array) {
17
+ static fromTlv(tlv: Bytes) {
18
18
  return new Noc(OperationalCertificate.TlvNoc.decode(tlv));
19
19
  }
20
20
 
@@ -136,7 +136,7 @@ export class Noc extends OperationalBase<OperationalCertificate.Noc> {
136
136
  if (subjectKeyIdentifier === undefined) {
137
137
  throw new CertificateError(`Noc certificate must have subjectKeyIdentifier set.`);
138
138
  }
139
- if (subjectKeyIdentifier.length !== 20) {
139
+ if (subjectKeyIdentifier.byteLength !== 20) {
140
140
  throw new CertificateError(`Noc certificate subjectKeyIdentifier must be 160 bit.`);
141
141
  }
142
142
 
@@ -144,7 +144,7 @@ export class Noc extends OperationalBase<OperationalCertificate.Noc> {
144
144
  if (authorityKeyIdentifier === undefined) {
145
145
  throw new CertificateError(`Noc certificate must have authorityKeyIdentifier set.`);
146
146
  }
147
- if (authorityKeyIdentifier.length !== 20) {
147
+ if (authorityKeyIdentifier.byteLength !== 20) {
148
148
  throw new CertificateError(`Noc certificate authorityKeyIdentifier must be 160 bit.`);
149
149
  }
150
150
 
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { Logger, Time } from "#general";
7
+ import { Bytes, Logger, Time } from "#general";
8
8
  import { X509Base } from "./X509Base.js";
9
9
  import { CertificateError, Unsigned } from "./common.js";
10
10
  import { X509Certificate } from "./definitions/base.js";
@@ -24,7 +24,7 @@ export abstract class OperationalBase<CT extends X509Certificate> extends X509Ba
24
24
  protected abstract validateFields(): void;
25
25
 
26
26
  /** Encodes the signed certificate into the Matter TLV format. */
27
- abstract asSignedTlv(signature: Uint8Array<ArrayBufferLike>): Uint8Array;
27
+ abstract asSignedTlv(signature: Bytes): Bytes;
28
28
 
29
29
  /**
30
30
  * Verifies general requirements a Matter certificate fields must fulfill.
@@ -32,9 +32,9 @@ export abstract class OperationalBase<CT extends X509Certificate> extends X509Ba
32
32
  */
33
33
  generalVerify() {
34
34
  const cert = this.cert;
35
- if (cert.serialNumber.length > 20)
35
+ if (cert.serialNumber.byteLength > 20)
36
36
  throw new CertificateError(
37
- `Serial number must not be longer then 20 octets. Current serial number has ${cert.serialNumber.length} octets.`,
37
+ `Serial number must not be longer then 20 octets. Current serial number has ${cert.serialNumber.byteLength} octets.`,
38
38
  );
39
39
 
40
40
  if (cert.signatureAlgorithm !== 1) {
@@ -13,7 +13,7 @@ import { OperationalBase } from "./OperationalBase.js";
13
13
 
14
14
  export class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
15
15
  /** Construct the class from a Tlv version of the certificate */
16
- static fromTlv(tlv: Uint8Array): Rcac {
16
+ static fromTlv(tlv: Bytes): Rcac {
17
17
  return new Rcac(OperationalCertificate.TlvRcac.decode(tlv));
18
18
  }
19
19
 
@@ -102,7 +102,7 @@ export class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
102
102
  if (subjectKeyIdentifier === undefined) {
103
103
  throw new CertificateError(`Root certificate must have subjectKeyIdentifier set.`);
104
104
  }
105
- if (subjectKeyIdentifier.length !== 20) {
105
+ if (subjectKeyIdentifier.byteLength !== 20) {
106
106
  throw new CertificateError(`Root certificate subjectKeyIdentifier must be 160 bit.`);
107
107
  }
108
108
 
@@ -110,7 +110,7 @@ export class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
110
110
  if (authorityKeyIdentifier === undefined) {
111
111
  throw new CertificateError(`Root certificate must have authorityKeyIdentifier set.`);
112
112
  }
113
- if (authorityKeyIdentifier.length !== 20) {
113
+ if (authorityKeyIdentifier.byteLength !== 20) {
114
114
  throw new CertificateError(`Root certificate authorityKeyIdentifier must be 160 bit.`);
115
115
  }
116
116
 
@@ -42,7 +42,7 @@ import { CertificateExtension } from "./definitions/operational.js";
42
42
  * from a CSR.
43
43
  */
44
44
  export abstract class X509Base<CT extends X509Certificate> {
45
- #signature?: Uint8Array;
45
+ #signature?: Bytes;
46
46
  #cert: Unsigned<CT>;
47
47
 
48
48
  constructor(cert: CT | Unsigned<CT>) {
@@ -75,7 +75,7 @@ export abstract class X509Base<CT extends X509Certificate> {
75
75
  * Set the signature of the certificate.
76
76
  * If the certificate is already signed, it throws a CertificateError.
77
77
  */
78
- set signature(signature: Uint8Array) {
78
+ set signature(signature: Bytes) {
79
79
  if (this.isSigned) {
80
80
  throw new CertificateError("Certificate is already signed");
81
81
  }
@@ -93,7 +93,7 @@ export abstract class X509Base<CT extends X509Certificate> {
93
93
  /**
94
94
  * Convert the certificate to ASN.1 DER format without signature.
95
95
  */
96
- asUnsignedAsn1(): Uint8Array<ArrayBufferLike> {
96
+ asUnsignedAsn1(): Bytes {
97
97
  const certBytes = DerCodec.encode(this.genericBuildAsn1Structure(this.cert));
98
98
  assertCertificateDerSize(certBytes);
99
99
  return certBytes;
@@ -273,10 +273,10 @@ export abstract class X509Base<CT extends X509Certificate> {
273
273
  asn.extendedKeyUsage = X509.ExtendedKeyUsage(value as number[] | undefined);
274
274
  break;
275
275
  case "subjectKeyIdentifier":
276
- asn.subjectKeyIdentifier = X509.SubjectKeyIdentifier(value as Uint8Array);
276
+ asn.subjectKeyIdentifier = X509.SubjectKeyIdentifier(value as Bytes);
277
277
  break;
278
278
  case "authorityKeyIdentifier":
279
- asn.authorityKeyIdentifier = X509.AuthorityKeyIdentifier(value as Uint8Array);
279
+ asn.authorityKeyIdentifier = X509.AuthorityKeyIdentifier(value as Bytes);
280
280
  break;
281
281
  case "futureExtension":
282
282
  asn.futureExtension = RawBytes(Bytes.concat(...((value as Uint8Array[] | undefined) ?? [])));
@@ -340,7 +340,7 @@ export abstract class X509Base<CT extends X509Certificate> {
340
340
  /**
341
341
  * Extract the public key from a Certificate Signing Request (CSR) in ASN.1 DER format.
342
342
  */
343
- static async getPublicKeyFromCsr(crypto: Crypto, encodedCsr: Uint8Array) {
343
+ static async getPublicKeyFromCsr(crypto: Crypto, encodedCsr: Bytes) {
344
344
  const { [DerKey.Elements]: rootElements } = DerCodec.decode(encodedCsr);
345
345
  if (rootElements?.length !== 3) {
346
346
  throw new CertificateError("Invalid CSR data");
@@ -353,7 +353,7 @@ export abstract class X509Base<CT extends X509Certificate> {
353
353
  throw new CertificateError("Invalid CSR data");
354
354
  }
355
355
  const [versionNode, subjectNode, publicKeyNode] = requestElements;
356
- const requestVersionBytes = versionNode[DerKey.Bytes];
356
+ const requestVersionBytes = Bytes.of(versionNode[DerKey.Bytes]);
357
357
  if (requestVersionBytes.length !== 1 || requestVersionBytes[0] !== 0) {
358
358
  throw new CertificateError(`Unsupported CSR version ${requestVersionBytes[0]}`);
359
359
  }
@@ -3,7 +3,7 @@
3
3
  * Copyright 2022-2025 Matter.js Authors
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { ImplementationError, MatterError } from "#general";
6
+ import { Bytes, ImplementationError, MatterError } from "#general";
7
7
 
8
8
  /**
9
9
  * Matter specific Certificate Sizes
@@ -15,10 +15,10 @@ export class CertificateError extends MatterError {}
15
15
 
16
16
  export type Unsigned<Type> = { [Property in keyof Type as Exclude<Property, "signature">]: Type[Property] };
17
17
 
18
- export function assertCertificateDerSize(certBytes: Uint8Array) {
19
- if (certBytes.length > MAX_DER_CERTIFICATE_SIZE) {
18
+ export function assertCertificateDerSize(certBytes: Bytes) {
19
+ if (certBytes.byteLength > MAX_DER_CERTIFICATE_SIZE) {
20
20
  throw new ImplementationError(
21
- `Certificate to generate is too big: ${certBytes.length} bytes instead of max ${MAX_DER_CERTIFICATE_SIZE} bytes`,
21
+ `Certificate to generate is too big: ${certBytes.byteLength} bytes instead of max ${MAX_DER_CERTIFICATE_SIZE} bytes`,
22
22
  );
23
23
  }
24
24
  }
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { BitFlag, BitmapSchema, TypeFromPartialBitSchema } from "#types";
7
+ import { Bytes } from "@matter/general";
7
8
 
8
9
  export const ExtensionKeyUsageBitmap = {
9
10
  digitalSignature: BitFlag(0),
@@ -19,7 +20,7 @@ export const ExtensionKeyUsageBitmap = {
19
20
  export const ExtensionKeyUsageSchema = BitmapSchema(ExtensionKeyUsageBitmap);
20
21
 
21
22
  export interface X509Certificate {
22
- serialNumber: Uint8Array;
23
+ serialNumber: Bytes;
23
24
  signatureAlgorithm: number;
24
25
  issuer: {};
25
26
  notBefore: number;
@@ -27,7 +28,7 @@ export interface X509Certificate {
27
28
  subject: {};
28
29
  publicKeyAlgorithm: number;
29
30
  ellipticCurveIdentifier: number;
30
- ellipticCurvePublicKey: Uint8Array;
31
+ ellipticCurvePublicKey: Bytes;
31
32
  extensions: {
32
33
  basicConstraints: {
33
34
  isCa: boolean;
@@ -35,9 +36,9 @@ export interface X509Certificate {
35
36
  };
36
37
  keyUsage: TypeFromPartialBitSchema<typeof ExtensionKeyUsageBitmap>;
37
38
  extendedKeyUsage?: number[];
38
- subjectKeyIdentifier: Uint8Array;
39
- authorityKeyIdentifier: Uint8Array;
40
- futureExtension?: Uint8Array[];
39
+ subjectKeyIdentifier: Bytes;
40
+ authorityKeyIdentifier: Bytes;
41
+ futureExtension?: Bytes[];
41
42
  };
42
- signature: Uint8Array;
43
+ signature: Bytes;
43
44
  }
@@ -24,11 +24,11 @@ export interface BtpPacketPayload {
24
24
  ackNumber?: number;
25
25
  sequenceNumber: number;
26
26
  messageLength?: number;
27
- segmentPayload?: Uint8Array;
27
+ segmentPayload?: Bytes;
28
28
  }
29
29
 
30
30
  export interface DecodedBtpPacketPayload extends BtpPacketPayload {
31
- segmentPayload: Uint8Array;
31
+ segmentPayload: Bytes;
32
32
  }
33
33
 
34
34
  export interface BtpHeader {
@@ -66,12 +66,12 @@ export enum BtpOpcode {
66
66
  const HANDSHAKE_HEADER = 0b01100101;
67
67
 
68
68
  export class BtpCodec {
69
- static decodeBtpHandshakeRequest(data: Uint8Array): BtpHandshakeRequest {
69
+ static decodeBtpHandshakeRequest(data: Bytes): BtpHandshakeRequest {
70
70
  const reader = new DataReader(data, Endian.Little);
71
71
  return this.decodeHandshakeRequestPayload(reader);
72
72
  }
73
73
 
74
- static decodeBtpPacket(data: Uint8Array): DecodedBtpPacket {
74
+ static decodeBtpPacket(data: Bytes): DecodedBtpPacket {
75
75
  const reader = new DataReader(data, Endian.Little);
76
76
 
77
77
  const header = this.decodeBtpPacketHeader(reader);
@@ -82,11 +82,11 @@ export class BtpCodec {
82
82
  };
83
83
  }
84
84
 
85
- static encodeBtpPacket({ header, payload }: BtpPacket): Uint8Array {
85
+ static encodeBtpPacket({ header, payload }: BtpPacket): Bytes {
86
86
  return Bytes.concat(this.encodeBtpPacketHeader(header), this.encodeBtpPacketPayload(header, payload));
87
87
  }
88
88
 
89
- static encodeBtpHandshakeRequest({ versions, attMtu, clientWindowSize }: BtpHandshakeRequest): Uint8Array {
89
+ static encodeBtpHandshakeRequest({ versions, attMtu, clientWindowSize }: BtpHandshakeRequest): Bytes {
90
90
  const writer = new DataWriter(Endian.Little);
91
91
  writer.writeUInt8(HANDSHAKE_HEADER);
92
92
  writer.writeUInt8(BtpOpcode.HandshakeManagementOpcode);
@@ -99,7 +99,7 @@ export class BtpCodec {
99
99
  return writer.toByteArray();
100
100
  }
101
101
 
102
- static encodeBtpHandshakeResponse({ version, attMtu, windowSize }: BtpHandshakeResponse): Uint8Array {
102
+ static encodeBtpHandshakeResponse({ version, attMtu, windowSize }: BtpHandshakeResponse): Bytes {
103
103
  const writer = new DataWriter(Endian.Little);
104
104
  writer.writeUInt8(HANDSHAKE_HEADER);
105
105
  writer.writeUInt8(BtpOpcode.HandshakeManagementOpcode);
@@ -125,7 +125,7 @@ export class BtpCodec {
125
125
  private static encodeBtpPacketPayload(
126
126
  { hasAckNumber, isBeginningSegment, isContinuingSegment, isEndingSegment }: BtpHeader,
127
127
  { ackNumber, sequenceNumber, messageLength, segmentPayload }: BtpPacketPayload,
128
- ): Uint8Array {
128
+ ): Bytes {
129
129
  const writer = new DataWriter(Endian.Little);
130
130
 
131
131
  // Validate Header against Payload fields to make sure they match together
@@ -143,7 +143,7 @@ export class BtpCodec {
143
143
  }
144
144
  if (
145
145
  (isBeginningSegment || isContinuingSegment) &&
146
- (segmentPayload === undefined || segmentPayload.length === 0)
146
+ (segmentPayload === undefined || segmentPayload.byteLength === 0)
147
147
  ) {
148
148
  throw new BtpProtocolError("Payload needs to be set because header flag indicates a message with payload.");
149
149
  }
@@ -211,7 +211,7 @@ export class BtpCodec {
211
211
  return { versions, attMtu, clientWindowSize };
212
212
  }
213
213
 
214
- static decodeBtpHandshakeResponsePayload(data: Uint8Array): BtpHandshakeResponse {
214
+ static decodeBtpHandshakeResponsePayload(data: Bytes): BtpHandshakeResponse {
215
215
  const reader = new DataReader(data, Endian.Little);
216
216
  const header = reader.readUInt8();
217
217
  if (header !== HANDSHAKE_HEADER) {
@@ -259,7 +259,7 @@ export class BtpCodec {
259
259
  isEndingSegment,
260
260
  isContinuingSegment,
261
261
  isBeginningSegment,
262
- }: BtpHeader): Uint8Array {
262
+ }: BtpHeader): Bytes {
263
263
  const writer = new DataWriter(Endian.Little);
264
264
 
265
265
  if (isHandshakeRequest || hasManagementOpcode) {
@@ -300,7 +300,7 @@ export class BtpCodec {
300
300
  return writer.toByteArray();
301
301
  }
302
302
 
303
- static decodeBleAdvertisementData(data: Uint8Array) {
303
+ static decodeBleAdvertisementData(data: Bytes) {
304
304
  const reader = new DataReader(data, Endian.Little);
305
305
  if (
306
306
  reader.readUInt8() !== 0x02 ||
@@ -320,7 +320,7 @@ export class BtpCodec {
320
320
  return { discriminator, vendorId, productId, hasAdditionalAdvertisementData };
321
321
  }
322
322
 
323
- static decodeBleAdvertisementServiceData(data: Uint8Array) {
323
+ static decodeBleAdvertisementServiceData(data: Bytes) {
324
324
  const reader = new DataReader(data, Endian.Little);
325
325
  if (reader.readUInt8() !== 0x00) {
326
326
  throw new BleError("Invalid BLE advertisement data");