matterbridge 3.4.7 → 3.5.0-dev-20260113-29ad318

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 (449) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/broadcastServer.d.ts +0 -115
  3. package/dist/broadcastServer.js +0 -117
  4. package/dist/broadcastServerTypes.d.ts +0 -43
  5. package/dist/broadcastServerTypes.js +0 -24
  6. package/dist/cli.d.ts +0 -24
  7. package/dist/cli.js +1 -97
  8. package/dist/cliEmitter.d.ts +0 -36
  9. package/dist/cliEmitter.js +0 -37
  10. package/dist/cliHistory.d.ts +0 -42
  11. package/dist/cliHistory.js +0 -38
  12. package/dist/clusters/export.d.ts +0 -1
  13. package/dist/clusters/export.js +0 -2
  14. package/dist/deviceManager.d.ts +0 -108
  15. package/dist/deviceManager.js +1 -113
  16. package/dist/devices/airConditioner.d.ts +0 -75
  17. package/dist/devices/airConditioner.js +0 -57
  18. package/dist/devices/batteryStorage.d.ts +0 -43
  19. package/dist/devices/batteryStorage.js +1 -48
  20. package/dist/devices/cooktop.d.ts +0 -55
  21. package/dist/devices/cooktop.js +0 -56
  22. package/dist/devices/dishwasher.d.ts +0 -55
  23. package/dist/devices/dishwasher.js +0 -57
  24. package/dist/devices/evse.d.ts +0 -57
  25. package/dist/devices/evse.js +10 -74
  26. package/dist/devices/export.d.ts +0 -1
  27. package/dist/devices/export.js +0 -5
  28. package/dist/devices/extractorHood.d.ts +0 -41
  29. package/dist/devices/extractorHood.js +0 -43
  30. package/dist/devices/heatPump.d.ts +0 -43
  31. package/dist/devices/heatPump.js +2 -50
  32. package/dist/devices/laundryDryer.d.ts +0 -58
  33. package/dist/devices/laundryDryer.js +3 -62
  34. package/dist/devices/laundryWasher.d.ts +0 -64
  35. package/dist/devices/laundryWasher.js +4 -70
  36. package/dist/devices/microwaveOven.d.ts +1 -77
  37. package/dist/devices/microwaveOven.js +5 -88
  38. package/dist/devices/oven.d.ts +0 -82
  39. package/dist/devices/oven.js +0 -85
  40. package/dist/devices/refrigerator.d.ts +0 -100
  41. package/dist/devices/refrigerator.js +0 -102
  42. package/dist/devices/roboticVacuumCleaner.d.ts +0 -83
  43. package/dist/devices/roboticVacuumCleaner.js +9 -100
  44. package/dist/devices/solarPower.d.ts +0 -36
  45. package/dist/devices/solarPower.js +0 -38
  46. package/dist/devices/speaker.d.ts +0 -79
  47. package/dist/devices/speaker.js +0 -84
  48. package/dist/devices/temperatureControl.d.ts +0 -21
  49. package/dist/devices/temperatureControl.js +3 -24
  50. package/dist/devices/waterHeater.d.ts +0 -74
  51. package/dist/devices/waterHeater.js +2 -82
  52. package/dist/dgram/coap.d.ts +0 -171
  53. package/dist/dgram/coap.js +13 -126
  54. package/dist/dgram/dgram.d.ts +0 -99
  55. package/dist/dgram/dgram.js +2 -114
  56. package/dist/dgram/mb_coap.d.ts +0 -23
  57. package/dist/dgram/mb_coap.js +3 -41
  58. package/dist/dgram/mb_mdns.d.ts +0 -23
  59. package/dist/dgram/mb_mdns.js +24 -80
  60. package/dist/dgram/mdns.d.ts +4 -187
  61. package/dist/dgram/mdns.js +139 -371
  62. package/dist/dgram/multicast.d.ts +0 -49
  63. package/dist/dgram/multicast.js +1 -62
  64. package/dist/dgram/unicast.d.ts +0 -53
  65. package/dist/dgram/unicast.js +0 -60
  66. package/dist/frontend.d.ts +0 -187
  67. package/dist/frontend.js +38 -485
  68. package/dist/frontendTypes.d.ts +0 -57
  69. package/dist/frontendTypes.js +0 -45
  70. package/dist/helpers.d.ts +0 -43
  71. package/dist/helpers.js +0 -53
  72. package/dist/index.d.ts +0 -23
  73. package/dist/index.js +0 -25
  74. package/dist/jestutils/export.d.ts +0 -1
  75. package/dist/jestutils/export.js +0 -1
  76. package/dist/jestutils/jestHelpers.d.ts +0 -255
  77. package/dist/jestutils/jestHelpers.js +14 -371
  78. package/dist/logger/export.d.ts +0 -1
  79. package/dist/logger/export.js +0 -1
  80. package/dist/matter/behaviors.d.ts +0 -1
  81. package/dist/matter/behaviors.js +0 -2
  82. package/dist/matter/clusters.d.ts +0 -1
  83. package/dist/matter/clusters.js +0 -2
  84. package/dist/matter/devices.d.ts +0 -1
  85. package/dist/matter/devices.js +0 -2
  86. package/dist/matter/endpoints.d.ts +0 -1
  87. package/dist/matter/endpoints.js +0 -2
  88. package/dist/matter/export.d.ts +0 -1
  89. package/dist/matter/export.js +0 -3
  90. package/dist/matter/types.d.ts +0 -1
  91. package/dist/matter/types.js +0 -3
  92. package/dist/matterNode.d.ts +0 -258
  93. package/dist/matterNode.js +8 -369
  94. package/dist/matterbridge.d.ts +0 -353
  95. package/dist/matterbridge.js +46 -824
  96. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -36
  97. package/dist/matterbridgeAccessoryPlatform.js +0 -38
  98. package/dist/matterbridgeBehaviors.d.ts +0 -24
  99. package/dist/matterbridgeBehaviors.js +5 -68
  100. package/dist/matterbridgeDeviceTypes.d.ts +0 -603
  101. package/dist/matterbridgeDeviceTypes.js +14 -635
  102. package/dist/matterbridgeDynamicPlatform.d.ts +0 -36
  103. package/dist/matterbridgeDynamicPlatform.js +0 -38
  104. package/dist/matterbridgeEndpoint.d.ts +0 -1332
  105. package/dist/matterbridgeEndpoint.js +53 -1457
  106. package/dist/matterbridgeEndpointHelpers.d.ts +0 -425
  107. package/dist/matterbridgeEndpointHelpers.js +20 -483
  108. package/dist/matterbridgeEndpointTypes.d.ts +0 -70
  109. package/dist/matterbridgeEndpointTypes.js +0 -25
  110. package/dist/matterbridgePlatform.d.ts +0 -425
  111. package/dist/matterbridgePlatform.js +1 -451
  112. package/dist/matterbridgeTypes.d.ts +0 -46
  113. package/dist/matterbridgeTypes.js +0 -26
  114. package/dist/pluginManager.d.ts +0 -305
  115. package/dist/pluginManager.js +5 -341
  116. package/dist/shelly.d.ts +0 -157
  117. package/dist/shelly.js +7 -178
  118. package/dist/storage/export.d.ts +0 -1
  119. package/dist/storage/export.js +0 -1
  120. package/dist/update.d.ts +0 -75
  121. package/dist/update.js +1 -93
  122. package/dist/utils/colorUtils.d.ts +0 -77
  123. package/dist/utils/colorUtils.js +2 -97
  124. package/dist/utils/commandLine.d.ts +0 -60
  125. package/dist/utils/commandLine.js +0 -60
  126. package/dist/utils/copyDirectory.d.ts +0 -33
  127. package/dist/utils/copyDirectory.js +0 -37
  128. package/dist/utils/createDirectory.d.ts +0 -32
  129. package/dist/utils/createDirectory.js +0 -33
  130. package/dist/utils/createZip.d.ts +0 -38
  131. package/dist/utils/createZip.js +2 -47
  132. package/dist/utils/deepCopy.d.ts +0 -31
  133. package/dist/utils/deepCopy.js +0 -39
  134. package/dist/utils/deepEqual.d.ts +0 -53
  135. package/dist/utils/deepEqual.js +1 -72
  136. package/dist/utils/error.d.ts +0 -42
  137. package/dist/utils/error.js +0 -42
  138. package/dist/utils/export.d.ts +0 -1
  139. package/dist/utils/export.js +0 -1
  140. package/dist/utils/format.d.ts +0 -49
  141. package/dist/utils/format.js +0 -49
  142. package/dist/utils/hex.d.ts +0 -85
  143. package/dist/utils/hex.js +0 -124
  144. package/dist/utils/inspector.d.ts +0 -63
  145. package/dist/utils/inspector.js +1 -69
  146. package/dist/utils/isValid.d.ts +0 -93
  147. package/dist/utils/isValid.js +0 -93
  148. package/dist/utils/network.d.ts +0 -116
  149. package/dist/utils/network.js +5 -126
  150. package/dist/utils/spawn.d.ts +0 -32
  151. package/dist/utils/spawn.js +1 -71
  152. package/dist/utils/tracker.d.ts +0 -56
  153. package/dist/utils/tracker.js +1 -64
  154. package/dist/utils/wait.d.ts +0 -51
  155. package/dist/utils/wait.js +8 -60
  156. package/dist/workerGlobalPrefix.d.ts +0 -24
  157. package/dist/workerGlobalPrefix.js +5 -37
  158. package/dist/workerTypes.d.ts +0 -25
  159. package/dist/workerTypes.js +0 -24
  160. package/dist/workers.d.ts +0 -61
  161. package/dist/workers.js +4 -68
  162. package/npm-shrinkwrap.json +1500 -11420
  163. package/package.json +10 -7
  164. package/dist/broadcastServer.d.ts.map +0 -1
  165. package/dist/broadcastServer.js.map +0 -1
  166. package/dist/broadcastServerTypes.d.ts.map +0 -1
  167. package/dist/broadcastServerTypes.js.map +0 -1
  168. package/dist/cli.d.ts.map +0 -1
  169. package/dist/cli.js.map +0 -1
  170. package/dist/cliEmitter.d.ts.map +0 -1
  171. package/dist/cliEmitter.js.map +0 -1
  172. package/dist/cliHistory.d.ts.map +0 -1
  173. package/dist/cliHistory.js.map +0 -1
  174. package/dist/clusters/export.d.ts.map +0 -1
  175. package/dist/clusters/export.js.map +0 -1
  176. package/dist/deviceManager.d.ts.map +0 -1
  177. package/dist/deviceManager.js.map +0 -1
  178. package/dist/devices/airConditioner.d.ts.map +0 -1
  179. package/dist/devices/airConditioner.js.map +0 -1
  180. package/dist/devices/batteryStorage.d.ts.map +0 -1
  181. package/dist/devices/batteryStorage.js.map +0 -1
  182. package/dist/devices/cooktop.d.ts.map +0 -1
  183. package/dist/devices/cooktop.js.map +0 -1
  184. package/dist/devices/dishwasher.d.ts.map +0 -1
  185. package/dist/devices/dishwasher.js.map +0 -1
  186. package/dist/devices/evse.d.ts.map +0 -1
  187. package/dist/devices/evse.js.map +0 -1
  188. package/dist/devices/export.d.ts.map +0 -1
  189. package/dist/devices/export.js.map +0 -1
  190. package/dist/devices/extractorHood.d.ts.map +0 -1
  191. package/dist/devices/extractorHood.js.map +0 -1
  192. package/dist/devices/heatPump.d.ts.map +0 -1
  193. package/dist/devices/heatPump.js.map +0 -1
  194. package/dist/devices/laundryDryer.d.ts.map +0 -1
  195. package/dist/devices/laundryDryer.js.map +0 -1
  196. package/dist/devices/laundryWasher.d.ts.map +0 -1
  197. package/dist/devices/laundryWasher.js.map +0 -1
  198. package/dist/devices/microwaveOven.d.ts.map +0 -1
  199. package/dist/devices/microwaveOven.js.map +0 -1
  200. package/dist/devices/oven.d.ts.map +0 -1
  201. package/dist/devices/oven.js.map +0 -1
  202. package/dist/devices/refrigerator.d.ts.map +0 -1
  203. package/dist/devices/refrigerator.js.map +0 -1
  204. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  205. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  206. package/dist/devices/solarPower.d.ts.map +0 -1
  207. package/dist/devices/solarPower.js.map +0 -1
  208. package/dist/devices/speaker.d.ts.map +0 -1
  209. package/dist/devices/speaker.js.map +0 -1
  210. package/dist/devices/temperatureControl.d.ts.map +0 -1
  211. package/dist/devices/temperatureControl.js.map +0 -1
  212. package/dist/devices/waterHeater.d.ts.map +0 -1
  213. package/dist/devices/waterHeater.js.map +0 -1
  214. package/dist/dgram/coap.d.ts.map +0 -1
  215. package/dist/dgram/coap.js.map +0 -1
  216. package/dist/dgram/dgram.d.ts.map +0 -1
  217. package/dist/dgram/dgram.js.map +0 -1
  218. package/dist/dgram/mb_coap.d.ts.map +0 -1
  219. package/dist/dgram/mb_coap.js.map +0 -1
  220. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  221. package/dist/dgram/mb_mdns.js.map +0 -1
  222. package/dist/dgram/mdns.d.ts.map +0 -1
  223. package/dist/dgram/mdns.js.map +0 -1
  224. package/dist/dgram/multicast.d.ts.map +0 -1
  225. package/dist/dgram/multicast.js.map +0 -1
  226. package/dist/dgram/unicast.d.ts.map +0 -1
  227. package/dist/dgram/unicast.js.map +0 -1
  228. package/dist/frontend.d.ts.map +0 -1
  229. package/dist/frontend.js.map +0 -1
  230. package/dist/frontendTypes.d.ts.map +0 -1
  231. package/dist/frontendTypes.js.map +0 -1
  232. package/dist/helpers.d.ts.map +0 -1
  233. package/dist/helpers.js.map +0 -1
  234. package/dist/index.d.ts.map +0 -1
  235. package/dist/index.js.map +0 -1
  236. package/dist/jestutils/export.d.ts.map +0 -1
  237. package/dist/jestutils/export.js.map +0 -1
  238. package/dist/jestutils/jestHelpers.d.ts.map +0 -1
  239. package/dist/jestutils/jestHelpers.js.map +0 -1
  240. package/dist/logger/export.d.ts.map +0 -1
  241. package/dist/logger/export.js.map +0 -1
  242. package/dist/matter/behaviors.d.ts.map +0 -1
  243. package/dist/matter/behaviors.js.map +0 -1
  244. package/dist/matter/clusters.d.ts.map +0 -1
  245. package/dist/matter/clusters.js.map +0 -1
  246. package/dist/matter/devices.d.ts.map +0 -1
  247. package/dist/matter/devices.js.map +0 -1
  248. package/dist/matter/endpoints.d.ts.map +0 -1
  249. package/dist/matter/endpoints.js.map +0 -1
  250. package/dist/matter/export.d.ts.map +0 -1
  251. package/dist/matter/export.js.map +0 -1
  252. package/dist/matter/types.d.ts.map +0 -1
  253. package/dist/matter/types.js.map +0 -1
  254. package/dist/matterNode.d.ts.map +0 -1
  255. package/dist/matterNode.js.map +0 -1
  256. package/dist/matterbridge.d.ts.map +0 -1
  257. package/dist/matterbridge.js.map +0 -1
  258. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  259. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  260. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  261. package/dist/matterbridgeBehaviors.js.map +0 -1
  262. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  263. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  264. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  265. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  266. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  267. package/dist/matterbridgeEndpoint.js.map +0 -1
  268. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  269. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  270. package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
  271. package/dist/matterbridgeEndpointTypes.js.map +0 -1
  272. package/dist/matterbridgePlatform.d.ts.map +0 -1
  273. package/dist/matterbridgePlatform.js.map +0 -1
  274. package/dist/matterbridgeTypes.d.ts.map +0 -1
  275. package/dist/matterbridgeTypes.js.map +0 -1
  276. package/dist/pluginManager.d.ts.map +0 -1
  277. package/dist/pluginManager.js.map +0 -1
  278. package/dist/shelly.d.ts.map +0 -1
  279. package/dist/shelly.js.map +0 -1
  280. package/dist/storage/export.d.ts.map +0 -1
  281. package/dist/storage/export.js.map +0 -1
  282. package/dist/update.d.ts.map +0 -1
  283. package/dist/update.js.map +0 -1
  284. package/dist/utils/colorUtils.d.ts.map +0 -1
  285. package/dist/utils/colorUtils.js.map +0 -1
  286. package/dist/utils/commandLine.d.ts.map +0 -1
  287. package/dist/utils/commandLine.js.map +0 -1
  288. package/dist/utils/copyDirectory.d.ts.map +0 -1
  289. package/dist/utils/copyDirectory.js.map +0 -1
  290. package/dist/utils/createDirectory.d.ts.map +0 -1
  291. package/dist/utils/createDirectory.js.map +0 -1
  292. package/dist/utils/createZip.d.ts.map +0 -1
  293. package/dist/utils/createZip.js.map +0 -1
  294. package/dist/utils/deepCopy.d.ts.map +0 -1
  295. package/dist/utils/deepCopy.js.map +0 -1
  296. package/dist/utils/deepEqual.d.ts.map +0 -1
  297. package/dist/utils/deepEqual.js.map +0 -1
  298. package/dist/utils/error.d.ts.map +0 -1
  299. package/dist/utils/error.js.map +0 -1
  300. package/dist/utils/export.d.ts.map +0 -1
  301. package/dist/utils/export.js.map +0 -1
  302. package/dist/utils/format.d.ts.map +0 -1
  303. package/dist/utils/format.js.map +0 -1
  304. package/dist/utils/hex.d.ts.map +0 -1
  305. package/dist/utils/hex.js.map +0 -1
  306. package/dist/utils/inspector.d.ts.map +0 -1
  307. package/dist/utils/inspector.js.map +0 -1
  308. package/dist/utils/isValid.d.ts.map +0 -1
  309. package/dist/utils/isValid.js.map +0 -1
  310. package/dist/utils/network.d.ts.map +0 -1
  311. package/dist/utils/network.js.map +0 -1
  312. package/dist/utils/spawn.d.ts.map +0 -1
  313. package/dist/utils/spawn.js.map +0 -1
  314. package/dist/utils/tracker.d.ts.map +0 -1
  315. package/dist/utils/tracker.js.map +0 -1
  316. package/dist/utils/wait.d.ts.map +0 -1
  317. package/dist/utils/wait.js.map +0 -1
  318. package/dist/workerGlobalPrefix.d.ts.map +0 -1
  319. package/dist/workerGlobalPrefix.js.map +0 -1
  320. package/dist/workerTypes.d.ts.map +0 -1
  321. package/dist/workerTypes.js.map +0 -1
  322. package/dist/workers.d.ts.map +0 -1
  323. package/dist/workers.js.map +0 -1
  324. package/frontend/index.html +0 -15
  325. package/frontend/package-lock.json +0 -7553
  326. package/packages/dgram/LICENSE +0 -202
  327. package/packages/dgram/dist/coap.d.ts +0 -205
  328. package/packages/dgram/dist/coap.d.ts.map +0 -1
  329. package/packages/dgram/dist/coap.js +0 -365
  330. package/packages/dgram/dist/coap.js.map +0 -1
  331. package/packages/dgram/dist/dgram.d.ts +0 -144
  332. package/packages/dgram/dist/dgram.d.ts.map +0 -1
  333. package/packages/dgram/dist/dgram.js +0 -367
  334. package/packages/dgram/dist/dgram.js.map +0 -1
  335. package/packages/dgram/dist/export.d.ts +0 -6
  336. package/packages/dgram/dist/export.d.ts.map +0 -1
  337. package/packages/dgram/dist/export.js +0 -6
  338. package/packages/dgram/dist/export.js.map +0 -1
  339. package/packages/dgram/dist/mdns.d.ts +0 -371
  340. package/packages/dgram/dist/mdns.d.ts.map +0 -1
  341. package/packages/dgram/dist/mdns.js +0 -934
  342. package/packages/dgram/dist/mdns.js.map +0 -1
  343. package/packages/dgram/dist/multicast.d.ts +0 -67
  344. package/packages/dgram/dist/multicast.d.ts.map +0 -1
  345. package/packages/dgram/dist/multicast.js +0 -180
  346. package/packages/dgram/dist/multicast.js.map +0 -1
  347. package/packages/dgram/dist/unicast.d.ts +0 -64
  348. package/packages/dgram/dist/unicast.d.ts.map +0 -1
  349. package/packages/dgram/dist/unicast.js +0 -100
  350. package/packages/dgram/dist/unicast.js.map +0 -1
  351. package/packages/dgram/package.json +0 -110
  352. package/packages/jest-utils/LICENSE +0 -202
  353. package/packages/jest-utils/dist/export.d.ts +0 -2
  354. package/packages/jest-utils/dist/export.d.ts.map +0 -1
  355. package/packages/jest-utils/dist/export.js +0 -2
  356. package/packages/jest-utils/dist/export.js.map +0 -1
  357. package/packages/jest-utils/dist/jestHelpers.d.ts +0 -77
  358. package/packages/jest-utils/dist/jestHelpers.d.ts.map +0 -1
  359. package/packages/jest-utils/dist/jestHelpers.js +0 -138
  360. package/packages/jest-utils/dist/jestHelpers.js.map +0 -1
  361. package/packages/jest-utils/package.json +0 -109
  362. package/packages/utils/LICENSE +0 -202
  363. package/packages/utils/dist/colorUtils.d.ts +0 -101
  364. package/packages/utils/dist/colorUtils.d.ts.map +0 -1
  365. package/packages/utils/dist/colorUtils.js +0 -282
  366. package/packages/utils/dist/colorUtils.js.map +0 -1
  367. package/packages/utils/dist/commandLine.d.ts +0 -66
  368. package/packages/utils/dist/commandLine.d.ts.map +0 -1
  369. package/packages/utils/dist/commandLine.js +0 -123
  370. package/packages/utils/dist/commandLine.js.map +0 -1
  371. package/packages/utils/dist/copyDirectory.d.ts +0 -35
  372. package/packages/utils/dist/copyDirectory.d.ts.map +0 -1
  373. package/packages/utils/dist/copyDirectory.js +0 -76
  374. package/packages/utils/dist/copyDirectory.js.map +0 -1
  375. package/packages/utils/dist/createDirectory.d.ts +0 -34
  376. package/packages/utils/dist/createDirectory.d.ts.map +0 -1
  377. package/packages/utils/dist/createDirectory.js +0 -54
  378. package/packages/utils/dist/createDirectory.js.map +0 -1
  379. package/packages/utils/dist/createZip.d.ts +0 -39
  380. package/packages/utils/dist/createZip.d.ts.map +0 -1
  381. package/packages/utils/dist/createZip.js +0 -114
  382. package/packages/utils/dist/createZip.js.map +0 -1
  383. package/packages/utils/dist/deepCopy.d.ts +0 -32
  384. package/packages/utils/dist/deepCopy.d.ts.map +0 -1
  385. package/packages/utils/dist/deepCopy.js +0 -79
  386. package/packages/utils/dist/deepCopy.js.map +0 -1
  387. package/packages/utils/dist/deepEqual.d.ts +0 -54
  388. package/packages/utils/dist/deepEqual.d.ts.map +0 -1
  389. package/packages/utils/dist/deepEqual.js +0 -130
  390. package/packages/utils/dist/deepEqual.js.map +0 -1
  391. package/packages/utils/dist/error.d.ts +0 -45
  392. package/packages/utils/dist/error.d.ts.map +0 -1
  393. package/packages/utils/dist/error.js +0 -54
  394. package/packages/utils/dist/error.js.map +0 -1
  395. package/packages/utils/dist/export.d.ts +0 -16
  396. package/packages/utils/dist/export.d.ts.map +0 -1
  397. package/packages/utils/dist/export.js +0 -16
  398. package/packages/utils/dist/export.js.map +0 -1
  399. package/packages/utils/dist/format.d.ts +0 -53
  400. package/packages/utils/dist/format.d.ts.map +0 -1
  401. package/packages/utils/dist/format.js +0 -78
  402. package/packages/utils/dist/format.js.map +0 -1
  403. package/packages/utils/dist/githubVersion.d.ts +0 -43
  404. package/packages/utils/dist/githubVersion.d.ts.map +0 -1
  405. package/packages/utils/dist/githubVersion.js +0 -70
  406. package/packages/utils/dist/githubVersion.js.map +0 -1
  407. package/packages/utils/dist/hex.d.ts +0 -89
  408. package/packages/utils/dist/hex.d.ts.map +0 -1
  409. package/packages/utils/dist/hex.js +0 -242
  410. package/packages/utils/dist/hex.js.map +0 -1
  411. package/packages/utils/dist/inspector.d.ts +0 -87
  412. package/packages/utils/dist/inspector.d.ts.map +0 -1
  413. package/packages/utils/dist/inspector.js +0 -268
  414. package/packages/utils/dist/inspector.js.map +0 -1
  415. package/packages/utils/dist/isValid.d.ts +0 -103
  416. package/packages/utils/dist/isValid.d.ts.map +0 -1
  417. package/packages/utils/dist/isValid.js +0 -162
  418. package/packages/utils/dist/isValid.js.map +0 -1
  419. package/packages/utils/dist/network.d.ts +0 -105
  420. package/packages/utils/dist/network.d.ts.map +0 -1
  421. package/packages/utils/dist/network.js +0 -201
  422. package/packages/utils/dist/network.js.map +0 -1
  423. package/packages/utils/dist/npmRoot.d.ts +0 -29
  424. package/packages/utils/dist/npmRoot.d.ts.map +0 -1
  425. package/packages/utils/dist/npmRoot.js +0 -41
  426. package/packages/utils/dist/npmRoot.js.map +0 -1
  427. package/packages/utils/dist/npmVersion.d.ts +0 -33
  428. package/packages/utils/dist/npmVersion.d.ts.map +0 -1
  429. package/packages/utils/dist/npmVersion.js +0 -76
  430. package/packages/utils/dist/npmVersion.js.map +0 -1
  431. package/packages/utils/dist/tracker.d.ts +0 -108
  432. package/packages/utils/dist/tracker.d.ts.map +0 -1
  433. package/packages/utils/dist/tracker.js +0 -264
  434. package/packages/utils/dist/tracker.js.map +0 -1
  435. package/packages/utils/dist/wait.d.ts +0 -54
  436. package/packages/utils/dist/wait.d.ts.map +0 -1
  437. package/packages/utils/dist/wait.js +0 -125
  438. package/packages/utils/dist/wait.js.map +0 -1
  439. package/packages/utils/package.json +0 -110
  440. package/packages/vitest-utils/LICENSE +0 -202
  441. package/packages/vitest-utils/dist/export.d.ts +0 -2
  442. package/packages/vitest-utils/dist/export.d.ts.map +0 -1
  443. package/packages/vitest-utils/dist/export.js +0 -2
  444. package/packages/vitest-utils/dist/export.js.map +0 -1
  445. package/packages/vitest-utils/dist/vitestHelpers.d.ts +0 -58
  446. package/packages/vitest-utils/dist/vitestHelpers.d.ts.map +0 -1
  447. package/packages/vitest-utils/dist/vitestHelpers.js +0 -119
  448. package/packages/vitest-utils/dist/vitestHelpers.js.map +0 -1
  449. package/packages/vitest-utils/package.json +0 -109
@@ -1,35 +1,8 @@
1
- /**
2
- * @description This file contains the class Dgram.
3
- * @file dgram.ts
4
- * @author Luca Liguori
5
- * @created 2025-03-22
6
- * @version 1.0.3
7
- * @license Apache-2.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
- // Node.js imports
24
1
  import dgram from 'node:dgram';
25
2
  import EventEmitter from 'node:events';
26
3
  import os from 'node:os';
27
- // AnsiLogger imports
28
4
  import { AnsiLogger, BLUE, db, idn, nf, rs } from 'node-ansi-logger';
29
5
  import { hasParameter } from '../utils/commandLine.js';
30
- /**
31
- * This class implements a dgram socket.
32
- */
33
6
  export class Dgram extends EventEmitter {
34
7
  verbose = hasParameter('v') || hasParameter('verbose');
35
8
  debug = hasParameter('d') || hasParameter('debug') || hasParameter('v') || hasParameter('verbose');
@@ -42,18 +15,9 @@ export class Dgram extends EventEmitter {
42
15
  interfaceAddress;
43
16
  interfaceNetmask;
44
17
  excludedInterfaceNamePattern = /(tailscale|wireguard|wintun|openvpn|\bwg\d*\b|\btun\d*\b|\btap\d*\b|\butun\d*\b|zerotier|hamachi|hyper-?v|v\s*ethernet|wsl|default switch|vmware|vmnet|vbox|virtualbox|virbr|docker|podman|\bveth\b|\bbr-\b|cni|kube|flannel|calico|teredo|isatap)/i;
45
- /**
46
- * Creates an instance of Dgram.
47
- *
48
- * @param {string} name - The name of the socket.
49
- * @param {'udp4' | 'udp6'} socketType - The type of the socket (IPv4 or IPv6).
50
- * @param {boolean | undefined} reuseAddr - Whether to allow address reuse. Defaults to true.
51
- * @param {string} [interfaceName] - The name of the network interface to bind to.
52
- * @param {string} [interfaceAddress] - The address of the network interface to bind to.
53
- */
54
18
  constructor(name, socketType, reuseAddr = true, interfaceName, interfaceAddress) {
55
19
  super();
56
- this.log = new AnsiLogger({ logName: name, logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: this.debug ? "debug" /* LogLevel.DEBUG */ : this.silent ? "notice" /* LogLevel.NOTICE */ : "info" /* LogLevel.INFO */ });
20
+ this.log = new AnsiLogger({ logName: name, logTimestampFormat: 4, logLevel: this.debug ? "debug" : this.silent ? "notice" : "info" });
57
21
  this.socket = dgram.createSocket({ type: socketType, reuseAddr });
58
22
  this.socketType = socketType;
59
23
  this.interfaceName = interfaceName;
@@ -88,13 +52,6 @@ export class Dgram extends EventEmitter {
88
52
  this.onListening(address);
89
53
  });
90
54
  }
91
- /**
92
- * Sends a message to the specified server.
93
- *
94
- * @param {Buffer} msg - The message buffer to send.
95
- * @param {string} serverAddress - The IPv4 address of the destination server.
96
- * @param {number} serverPort - The port of the destination server.
97
- */
98
55
  send(msg, serverAddress, serverPort) {
99
56
  this.socket.send(msg, 0, msg.length, serverPort, serverAddress, (error) => {
100
57
  if (error) {
@@ -132,32 +89,20 @@ export class Dgram extends EventEmitter {
132
89
  this.log.info(`Socket ready on ${BLUE}${address.family}${nf} ${BLUE}${address.address}${nf}:${BLUE}${address.port}${nf}`);
133
90
  this.emit('ready', address);
134
91
  }
135
- /**
136
- * Retrieves the IPv4 address of the specified network interface or the first external IPv4 interface if no interface is specified.
137
- * Throws an error if no suitable interface or address is found.
138
- *
139
- * @param {string} networkInterface - The name of the network interface to retrieve the IPv4 address from. If not specified, the first external IPv4 interface will be used.
140
- * @returns {string | undefined} The IPv4 address of the specified network interface or the first external IPv4 interface.
141
- * @throws {Error} if no suitable interface or address is found.
142
- */
143
92
  getIpv4InterfaceAddress(networkInterface) {
144
- // Normalize the interface name: treat an empty string as undefined.
145
93
  if (networkInterface === '')
146
94
  networkInterface = undefined;
147
95
  const interfaces = os.networkInterfaces();
148
- // If a specific interface is provided but not found, warn and fall back.
149
96
  if (networkInterface && !interfaces[networkInterface]) {
150
97
  this.log.warn(`Interface "${networkInterface}" not found. Using first external IPv4 interface.`);
151
98
  networkInterface = undefined;
152
99
  }
153
- // If no interface was specified or the provided one doesn't exist, find the first external IPv4 interface.
154
100
  if (!networkInterface) {
155
101
  for (const [interfaceName, interfaceDetails] of Object.entries(interfaces)) {
156
102
  if (!networkInterface && this.excludedInterfaceNamePattern.test(interfaceName))
157
103
  continue;
158
104
  if (!interfaceDetails)
159
105
  continue;
160
- // Check if at least one external IPv4 address exists on this interface.
161
106
  for (const detail of interfaceDetails) {
162
107
  if (detail.family === 'IPv4' && !detail.internal) {
163
108
  networkInterface = interfaceName;
@@ -171,7 +116,6 @@ export class Dgram extends EventEmitter {
171
116
  if (!networkInterface) {
172
117
  throw new Error(`Didn't find an external IPv4 network interface`);
173
118
  }
174
- // Select the first external IPv4 address from the interface.
175
119
  const addresses = interfaces[networkInterface];
176
120
  const ipv4Address = addresses?.find((addr) => addr.family === 'IPv4' && !addr.internal);
177
121
  if (!ipv4Address) {
@@ -179,25 +123,14 @@ export class Dgram extends EventEmitter {
179
123
  }
180
124
  return ipv4Address.address;
181
125
  }
182
- /**
183
- * Retrieves the IPv6 address of the specified network interface or the first external IPv6 interface if no interface is specified.
184
- * Throws an error if no suitable interface or address is found.
185
- *
186
- * @param {string} [networkInterface] - The name of the network interface to retrieve the IPv6 address from. If not specified, the first external IPv6 interface will be used.
187
- * @returns {string | undefined} The IPv6 address of the specified network interface or the first external IPv6 interface.
188
- * @throws {Error} If no suitable interface or address is found.
189
- */
190
126
  getIpv6InterfaceAddress(networkInterface) {
191
- // Normalize the interface name: treat an empty string as undefined.
192
127
  if (networkInterface === '')
193
128
  networkInterface = undefined;
194
129
  const interfaces = os.networkInterfaces();
195
- // If a specific interface is provided, verify it exists. Otherwise, warn and use the first external IPv6 interface.
196
130
  if (networkInterface && !interfaces[networkInterface]) {
197
131
  this.log.warn(`Interface "${networkInterface}" not found. Using first external IPv6 interface.`);
198
132
  networkInterface = undefined;
199
133
  }
200
- // If no network interface was specified, search for the first external IPv6 interface.
201
134
  if (!networkInterface) {
202
135
  for (const [interfaceName, interfaceDetails] of Object.entries(interfaces)) {
203
136
  if (!networkInterface && this.excludedInterfaceNamePattern.test(interfaceName))
@@ -218,21 +151,18 @@ export class Dgram extends EventEmitter {
218
151
  throw new Error(`Didn't find an external IPv6 network interface`);
219
152
  }
220
153
  const addresses = interfaces[networkInterface];
221
- // Try to find a link-local address and use scopeid
222
154
  const linkLocalAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fe80'));
223
155
  if (linkLocalAddress) {
224
156
  this.log.debug('Found IPv6 link-local address');
225
157
  return linkLocalAddress.scopeid ? `${linkLocalAddress.address}%${process.platform !== 'win32' ? networkInterface : linkLocalAddress.scopeid}` : linkLocalAddress.address;
226
158
  }
227
159
  this.log.debug('No IPv6 link-local address found');
228
- // Try to find a unique local address
229
160
  const ulaAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fd') && addr.netmask === 'ffff:ffff:ffff:ffff::');
230
161
  if (ulaAddress) {
231
162
  this.log.debug('Found IPv6 Unique Local Addresses (ULA) unicast address');
232
163
  return ulaAddress.address;
233
164
  }
234
165
  this.log.debug('No IPv6 Unique Local Addresses (ULA) unicast address found');
235
- // Try to find a unique local address
236
166
  const uniqueLocalAddress = addresses?.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.address.startsWith('fd'));
237
167
  if (uniqueLocalAddress) {
238
168
  this.log.debug('Found IPv6 Unique Local Addresses (ULA) address');
@@ -241,11 +171,6 @@ export class Dgram extends EventEmitter {
241
171
  this.log.debug('No IPv6 Unique Local Addresses (ULA) address found');
242
172
  throw new Error(`Interface ${networkInterface} does not have a suitable external IPv6 address`);
243
173
  }
244
- /**
245
- * Retrieves the names of all available network interfaces.
246
- *
247
- * @returns {string[]} An array of network interface names.
248
- */
249
174
  getInterfacesNames() {
250
175
  const interfaces = os.networkInterfaces();
251
176
  const interfaceNames = [];
@@ -256,12 +181,6 @@ export class Dgram extends EventEmitter {
256
181
  }
257
182
  return interfaceNames;
258
183
  }
259
- /**
260
- * Retrieves the scope ID of the first found IPv6 address on the specified network interface or on any interface if none is specified.
261
- *
262
- * @param {string} [interfaceName] - The name of the network interface. If not provided, the first found IPv6 address will be used.
263
- * @returns {string} The scope ID of the first found IPv6 address or an empty string.
264
- */
265
184
  getIpv6ScopeId(interfaceName) {
266
185
  const interfaces = os.networkInterfaces();
267
186
  for (const name in interfaces) {
@@ -273,24 +192,17 @@ export class Dgram extends EventEmitter {
273
192
  if (iface) {
274
193
  const ipv6Address = iface.find((addr) => addr.family === 'IPv6' && !addr.internal && addr.scopeid);
275
194
  if (ipv6Address) {
276
- return process.platform === 'win32' ? '%' + String(ipv6Address.scopeid) : '%' + name; // Use the scope ID for Windows, or the interface name for non-Windows platforms
195
+ return process.platform === 'win32' ? '%' + String(ipv6Address.scopeid) : '%' + name;
277
196
  }
278
197
  }
279
198
  }
280
199
  return '';
281
200
  }
282
- /**
283
- * Retrieves the interface name from the scope id of an IPv6 address.
284
- *
285
- * @param {number} scopeId - The scope id of the IPv6 address.
286
- * @returns {string | undefined} The interface name or undefined if not found.
287
- */
288
201
  getInterfaceNameFromScopeId(scopeId) {
289
202
  const nets = os.networkInterfaces();
290
203
  for (const ifaceName in nets) {
291
204
  const addresses = nets[ifaceName] || [];
292
205
  for (const addr of addresses) {
293
- // Check for IPv6 addresses with a matching scope id.
294
206
  if (addr.family === 'IPv6' && addr.scopeid === scopeId) {
295
207
  return ifaceName;
296
208
  }
@@ -298,16 +210,8 @@ export class Dgram extends EventEmitter {
298
210
  }
299
211
  return undefined;
300
212
  }
301
- /**
302
- * Retrieves the netmask of the specified interface address.
303
- *
304
- * @param {string} interfaceAddress - The interface address for which to retrieve the netmask.
305
- * @returns {string | undefined} The netmask of the specified interface address or undefined if not found.
306
- */
307
213
  getNetmask(interfaceAddress) {
308
- // Remove zone index if present (e.g. for IPv6 "fe80::1%eth0")
309
214
  const noZoneAddress = interfaceAddress.includes('%') ? interfaceAddress.split('%')[0] : interfaceAddress;
310
- // Iterate over all interfaces.
311
215
  const nets = os.networkInterfaces();
312
216
  for (const ifaceName in nets) {
313
217
  const ifaceAddresses = nets[ifaceName];
@@ -321,13 +225,6 @@ export class Dgram extends EventEmitter {
321
225
  }
322
226
  return undefined;
323
227
  }
324
- /**
325
- * Computes the broadcast address given an IPv4 address and netmask.
326
- *
327
- * @param {string | undefined} [ipAddress] - The IPv4 address e.g. "192.168.1.20"
328
- * @param {string | undefined} [netmask] - The IPv4 netmask e.g. "255.255.255.0"
329
- * @returns {string | undefined} The computed broadcast address, e.g. "192.168.1.255"
330
- */
331
228
  getIpv4BroadcastAddress(ipAddress, netmask) {
332
229
  if (!ipAddress || !netmask) {
333
230
  return undefined;
@@ -337,17 +234,9 @@ export class Dgram extends EventEmitter {
337
234
  const broadcastParts = ipParts.map((octet, i) => (octet & maskParts[i]) | (255 - maskParts[i]));
338
235
  return broadcastParts.join('.');
339
236
  }
340
- /**
341
- * Returns the broadcast IPv6 address.
342
- *
343
- * @returns {string} The broadcast IPv6 address, e.g. "ff02::1"
344
- */
345
237
  getIpv6BroadcastAddress() {
346
238
  return 'ff02::1';
347
239
  }
348
- /**
349
- * Logs all available network interfaces and their details.
350
- */
351
240
  listNetworkInterfaces() {
352
241
  const interfaces = os.networkInterfaces();
353
242
  for (const [name, addresses] of Object.entries(interfaces)) {
@@ -360,4 +249,3 @@ export class Dgram extends EventEmitter {
360
249
  }
361
250
  }
362
251
  }
363
- //# sourceMappingURL=dgram.js.map
@@ -1,24 +1 @@
1
- /**
2
- * @description This file contains the bin mb_coap for the class Coap.
3
- * @file src/dgram/mb_coap.ts
4
- * @author Luca Liguori
5
- * @created 2025-07-22
6
- * @version 1.0.0
7
- * @license Apache-2.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
1
  export {};
24
- //# sourceMappingURL=mb_coap.d.ts.map
@@ -1,64 +1,27 @@
1
- /**
2
- * @description This file contains the bin mb_coap for the class Coap.
3
- * @file src/dgram/mb_coap.ts
4
- * @author Luca Liguori
5
- * @created 2025-07-22
6
- * @version 1.0.0
7
- * @license Apache-2.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
- // Net imports
24
1
  import { COAP_MULTICAST_IPV4_ADDRESS, COAP_MULTICAST_IPV6_ADDRESS, COAP_MULTICAST_PORT, Coap, COAP_OPTION_URI_PATH } from '@matterbridge/dgram';
25
- // istanbul ignore next
26
2
  {
27
3
  const coapIpv4 = new Coap('CoAP Server udp4', COAP_MULTICAST_IPV4_ADDRESS, COAP_MULTICAST_PORT, 'udp4', true);
28
4
  const coapIpv6 = new Coap('CoAP Server udp6', COAP_MULTICAST_IPV6_ADDRESS, COAP_MULTICAST_PORT, 'udp6', true);
29
5
  coapIpv4.listNetworkInterfaces();
30
- /**
31
- * Cleanup and log device information before exiting.
32
- */
33
6
  function cleanupAndLogAndExit() {
34
7
  if (process.argv.includes('--coap-udp4'))
35
8
  coapIpv4.stop();
36
9
  if (process.argv.includes('--coap-udp6'))
37
10
  coapIpv6.stop();
38
- // eslint-disable-next-line n/no-process-exit
39
11
  process.exit(0);
40
12
  }
41
- /**
42
- * Queries mDNS services over UDP IPv4 and sends a response for a specific service instance.
43
- * This function sends a query for Shelly, HTTP, and services, and responds with the appropriate PTR records.
44
- */
45
13
  const requestUdp4 = () => {
46
14
  coapIpv4.sendRequest(32000, [
47
15
  { number: COAP_OPTION_URI_PATH, value: Buffer.from('cit') },
48
16
  { number: COAP_OPTION_URI_PATH, value: Buffer.from('d') },
49
17
  ], {}, undefined, COAP_MULTICAST_IPV4_ADDRESS, COAP_MULTICAST_PORT);
50
18
  };
51
- /**
52
- * Queries mDNS services over UDP IPv4 and sends a response for a specific service instance.
53
- * This function sends a query for Shelly, HTTP, and services, and responds with the appropriate PTR records.
54
- */
55
19
  const requestUdp6 = () => {
56
20
  coapIpv6.sendRequest(32000, [
57
21
  { number: COAP_OPTION_URI_PATH, value: Buffer.from('cit') },
58
22
  { number: COAP_OPTION_URI_PATH, value: Buffer.from('d') },
59
23
  ], {}, undefined, COAP_MULTICAST_IPV6_ADDRESS, COAP_MULTICAST_PORT);
60
24
  };
61
- // Handle Ctrl+C (SIGINT) to stop and log devices
62
25
  process.on('SIGINT', () => {
63
26
  cleanupAndLogAndExit();
64
27
  });
@@ -66,7 +29,7 @@ import { COAP_MULTICAST_IPV4_ADDRESS, COAP_MULTICAST_IPV6_ADDRESS, COAP_MULTICAS
66
29
  coapIpv4.on('ready', (address) => {
67
30
  coapIpv4.log.info(`coapIpv4 server ready on ${address.family} ${address.address}:${address.port}`);
68
31
  if (!process.argv.includes('--coap-request'))
69
- return; // Skip querying if --coap-request is not specified
32
+ return;
70
33
  requestUdp4();
71
34
  setInterval(() => {
72
35
  requestUdp4();
@@ -76,7 +39,7 @@ import { COAP_MULTICAST_IPV4_ADDRESS, COAP_MULTICAST_IPV6_ADDRESS, COAP_MULTICAS
76
39
  coapIpv6.on('ready', (address) => {
77
40
  coapIpv6.log.info(`coapIpv6 server ready on ${address.family} ${address.address}:${address.port}`);
78
41
  if (!process.argv.includes('--coap-request'))
79
- return; // Skip querying if --coap-request is not specified
42
+ return;
80
43
  requestUdp6();
81
44
  setInterval(() => {
82
45
  requestUdp6();
@@ -84,6 +47,5 @@ import { COAP_MULTICAST_IPV4_ADDRESS, COAP_MULTICAST_IPV6_ADDRESS, COAP_MULTICAS
84
47
  });
85
48
  setTimeout(() => {
86
49
  cleanupAndLogAndExit();
87
- }, 600000); // 10 minutes timeout to exit if no activity
50
+ }, 600000);
88
51
  }
89
- //# sourceMappingURL=mb_coap.js.map
@@ -1,24 +1 @@
1
- /**
2
- * @description This file contains the bin mb_mdns for the class Mdns.
3
- * @file src/dgram/mb_mdns.ts
4
- * @author Luca Liguori
5
- * @created 2025-07-22
6
- * @version 1.0.0
7
- * @license Apache-2.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
1
  export {};
24
- //# sourceMappingURL=mb_mdns.d.ts.map
@@ -1,36 +1,9 @@
1
- /**
2
- * @description This file contains the bin mb_mdns for the class Mdns.
3
- * @file src/dgram/mb_mdns.ts
4
- * @author Luca Liguori
5
- * @created 2025-07-22
6
- * @version 1.0.0
7
- * @license Apache-2.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License.
22
- */
23
1
  import os from 'node:os';
24
- // Net imports
25
2
  import { MDNS_MULTICAST_IPV4_ADDRESS, MDNS_MULTICAST_IPV6_ADDRESS, MDNS_MULTICAST_PORT, Mdns } from '@matterbridge/dgram';
26
- // Utils imports
27
3
  import { getIntParameter, getParameter, getStringArrayParameter, hasParameter } from '@matterbridge/utils';
28
- // istanbul ignore next
29
4
  {
30
5
  if (hasParameter('h') || hasParameter('help')) {
31
- // eslint-disable-next-line no-console
32
6
  console.log(`Copyright (c) Matterbridge. All rights reserved. Version 1.0.0.\n`);
33
- // eslint-disable-next-line no-console
34
7
  console.log(`Usage: mb_mdns [options...]
35
8
 
36
9
  If no command line is provided, mb_mdns shows all incoming mDNS records on all interfaces (0.0.0.0 and ::).
@@ -71,10 +44,8 @@ Examples:
71
44
  # Query each 5s and listen for _matterbridge._tcp.local service records
72
45
  mb_mdns --query 5000 --filter _matterbridge._tcp.local
73
46
  `);
74
- // eslint-disable-next-line n/no-process-exit
75
47
  process.exit(0);
76
48
  }
77
- // Dynamic JSON import (Node >= 20) with import attributes
78
49
  const { default: pkg } = await import('../../package.json', { with: { type: 'json' } });
79
50
  let mdnsIpv4QueryInterval;
80
51
  let mdnsIpv6QueryInterval;
@@ -82,9 +53,6 @@ Examples:
82
53
  let mdnsIpv6AdvertiseInterval;
83
54
  let mdnsIpv4 = undefined;
84
55
  let mdnsIpv6 = undefined;
85
- /**
86
- * Cleanup and log device information before exiting.
87
- */
88
56
  async function cleanupAndLogAndExit() {
89
57
  clearInterval(mdnsIpv4QueryInterval);
90
58
  clearInterval(mdnsIpv6QueryInterval);
@@ -92,42 +60,36 @@ Examples:
92
60
  clearInterval(mdnsIpv6AdvertiseInterval);
93
61
  if (hasParameter('advertise')) {
94
62
  if (mdnsIpv4)
95
- advertise(mdnsIpv4, 0); // Send goodbye with TTL 0
63
+ advertise(mdnsIpv4, 0);
96
64
  if (mdnsIpv6)
97
- advertise(mdnsIpv6, 0); // Send goodbye with TTL 0
65
+ advertise(mdnsIpv6, 0);
98
66
  }
99
- await new Promise((resolve) => setTimeout(resolve, 250)); // Wait for 250ms to allow goodbye messages to be sent
67
+ await new Promise((resolve) => setTimeout(resolve, 250));
100
68
  mdnsIpv4?.stop();
101
69
  mdnsIpv6?.stop();
102
70
  mdnsIpv4?.logDevices();
103
71
  mdnsIpv6?.logDevices();
104
- await new Promise((resolve) => setTimeout(resolve, 250)); // Wait for 250ms to allow sockets to close
72
+ await new Promise((resolve) => setTimeout(resolve, 250));
105
73
  }
106
74
  const query = (mdns) => {
107
75
  mdns.log.info('Sending mDNS query for common services...');
108
76
  try {
109
77
  mdns.sendQuery([
110
- { name: '_matterc._udp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
111
- { name: '_matter._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
112
- { name: '_matterbridge._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
113
- { name: '_home-assistant._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
114
- { name: '_shelly._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
115
- { name: '_mqtt._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
116
- { name: '_http._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
117
- { name: '_googlecast._tcp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
118
- { name: '_services._dns-sd._udp.local', type: 12 /* DnsRecordType.PTR */, class: 1 /* DnsClass.IN */, unicastResponse: true },
78
+ { name: '_matterc._udp.local', type: 12, class: 1, unicastResponse: true },
79
+ { name: '_matter._tcp.local', type: 12, class: 1, unicastResponse: true },
80
+ { name: '_matterbridge._tcp.local', type: 12, class: 1, unicastResponse: true },
81
+ { name: '_home-assistant._tcp.local', type: 12, class: 1, unicastResponse: true },
82
+ { name: '_shelly._tcp.local', type: 12, class: 1, unicastResponse: true },
83
+ { name: '_mqtt._tcp.local', type: 12, class: 1, unicastResponse: true },
84
+ { name: '_http._tcp.local', type: 12, class: 1, unicastResponse: true },
85
+ { name: '_googlecast._tcp.local', type: 12, class: 1, unicastResponse: true },
86
+ { name: '_services._dns-sd._udp.local', type: 12, class: 1, unicastResponse: true },
119
87
  ]);
120
88
  }
121
89
  catch (error) {
122
90
  mdns.log.error(`Error sending mDNS query: ${error.message}`);
123
91
  }
124
92
  };
125
- /**
126
- * Sends an mDNS advertisement for the HTTP service over UDP IPv4.
127
- *
128
- * @param {Mdns} mdns - The Mdns instance to use for sending the advertisement.
129
- * @param {number} [ttl] - The time-to-live for the advertisement records. Defaults to 120 seconds. Send 0 for goodbye.
130
- */
131
93
  const advertise = (mdns, ttl = 120) => {
132
94
  mdns.log.info(`Sending mDNS advertisement for matterbridge service with TTL ${ttl ? ttl.toString() : 'goodbye'}...`);
133
95
  const httpServiceType = '_http._tcp.local';
@@ -143,25 +105,17 @@ Examples:
143
105
  const srvRdata = mdns.encodeSrvRdata(0, 0, port, hostName);
144
106
  const txtRdata = mdns.encodeTxtRdata([`version=${pkg.version}`, 'path=/']);
145
107
  const answers = [
146
- // PTR records for service types and instances
147
- { name: '_services._dns-sd._udp.local', rtype: 12 /* DnsRecordType.PTR */, rclass: 1 /* DnsClass.IN */, ttl, rdata: ptrHttpServiceTypeRdata },
148
- { name: httpServiceType, rtype: 12 /* DnsRecordType.PTR */, rclass: 1 /* DnsClass.IN */, ttl, rdata: ptrHttpInstanceRdata },
149
- { name: '_services._dns-sd._udp.local', rtype: 12 /* DnsRecordType.PTR */, rclass: 1 /* DnsClass.IN */, ttl, rdata: ptrMatterbridgeServiceTypeRdata },
150
- { name: matterbridgeServiceType, rtype: 12 /* DnsRecordType.PTR */, rclass: 1 /* DnsClass.IN */, ttl, rdata: ptrMatterbridgeInstanceRdata },
151
- // SRV record for the HTTP instance
152
- { name: httpInstanceName, rtype: 33 /* DnsRecordType.SRV */, rclass: 1 /* DnsClass.IN */ | 32768 /* DnsClassFlag.FLUSH */, ttl, rdata: srvRdata },
153
- // SRV record for the matterbridge instance
154
- { name: matterbridgeInstanceName, rtype: 33 /* DnsRecordType.SRV */, rclass: 1 /* DnsClass.IN */ | 32768 /* DnsClassFlag.FLUSH */, ttl, rdata: srvRdata },
155
- // TXT record for the HTTP instance
156
- { name: httpInstanceName, rtype: 16 /* DnsRecordType.TXT */, rclass: 1 /* DnsClass.IN */ | 32768 /* DnsClassFlag.FLUSH */, ttl, rdata: txtRdata },
157
- // TXT record for the matterbridge instance
158
- { name: matterbridgeInstanceName, rtype: 16 /* DnsRecordType.TXT */, rclass: 1 /* DnsClass.IN */ | 32768 /* DnsClassFlag.FLUSH */, ttl, rdata: txtRdata },
108
+ { name: '_services._dns-sd._udp.local', rtype: 12, rclass: 1, ttl, rdata: ptrHttpServiceTypeRdata },
109
+ { name: httpServiceType, rtype: 12, rclass: 1, ttl, rdata: ptrHttpInstanceRdata },
110
+ { name: '_services._dns-sd._udp.local', rtype: 12, rclass: 1, ttl, rdata: ptrMatterbridgeServiceTypeRdata },
111
+ { name: matterbridgeServiceType, rtype: 12, rclass: 1, ttl, rdata: ptrMatterbridgeInstanceRdata },
112
+ { name: httpInstanceName, rtype: 33, rclass: 1 | 32768, ttl, rdata: srvRdata },
113
+ { name: matterbridgeInstanceName, rtype: 33, rclass: 1 | 32768, ttl, rdata: srvRdata },
114
+ { name: httpInstanceName, rtype: 16, rclass: 1 | 32768, ttl, rdata: txtRdata },
115
+ { name: matterbridgeInstanceName, rtype: 16, rclass: 1 | 32768, ttl, rdata: txtRdata },
159
116
  ];
160
- // Always attempt to add both A and all AAAA records (best effort), regardless of the socket family.
161
117
  const interfaces = os.networkInterfaces();
162
- // Use specified interface name if provided
163
118
  let interfaceInfos = mdns.interfaceName ? interfaces[mdns.interfaceName] : undefined;
164
- // Find the first non-internal IPv4 and IPv6 addresses if interface name is not provided or not found
165
119
  if (!interfaceInfos) {
166
120
  interfaceInfos = [];
167
121
  for (const name of Object.keys(interfaces)) {
@@ -172,15 +126,14 @@ Examples:
172
126
  }
173
127
  }
174
128
  }
175
- // Encode A and AAAA records for all non-internal addresses of the selected interface
176
129
  for (const info of interfaceInfos) {
177
130
  if (info.family === 'IPv4' && !info.internal) {
178
131
  const ipv4 = info.address;
179
- answers.push({ name: hostName, rtype: 1 /* DnsRecordType.A */, rclass: 1 /* DnsClass.IN */ | 32768 /* DnsClassFlag.FLUSH */, ttl, rdata: mdns.encodeA(ipv4) });
132
+ answers.push({ name: hostName, rtype: 1, rclass: 1 | 32768, ttl, rdata: mdns.encodeA(ipv4) });
180
133
  }
181
134
  else if (info.family === 'IPv6' && !info.internal) {
182
135
  const ipv6 = info.address;
183
- answers.push({ name: hostName, rtype: 28 /* DnsRecordType.AAAA */, rclass: 1 /* DnsClass.IN */ | 32768 /* DnsClassFlag.FLUSH */, ttl, rdata: mdns.encodeAAAA(ipv6) });
136
+ answers.push({ name: hostName, rtype: 28, rclass: 1 | 32768, ttl, rdata: mdns.encodeAAAA(ipv6) });
184
137
  }
185
138
  }
186
139
  try {
@@ -194,15 +147,12 @@ Examples:
194
147
  mdnsIpv4 = new Mdns('mDNS Server udp4', MDNS_MULTICAST_IPV4_ADDRESS, MDNS_MULTICAST_PORT, 'udp4', true, getParameter('interfaceName'), getParameter('ipv4InterfaceAddress') || '0.0.0.0', getParameter('outgoingIpv4InterfaceAddress'));
195
148
  if (hasParameter('v') || hasParameter('verbose'))
196
149
  mdnsIpv4.listNetworkInterfaces();
197
- // Apply filters if any
198
150
  const filters = getStringArrayParameter('filter');
199
151
  if (filters)
200
152
  mdnsIpv4.filters.push(...filters);
201
- // Handle errors
202
153
  mdnsIpv4.on('error', (err) => {
203
154
  mdnsIpv4?.log.error(`mDNS udp4 Server error: ${err.message}\n${err.stack}`);
204
155
  });
205
- // Start the IPv4 mDNS server
206
156
  mdnsIpv4.start();
207
157
  mdnsIpv4.on('ready', (address) => {
208
158
  mdnsIpv4?.socket.setMulticastLoopback(false);
@@ -221,15 +171,12 @@ Examples:
221
171
  mdnsIpv6 = new Mdns('mDNS Server udp6', MDNS_MULTICAST_IPV6_ADDRESS, MDNS_MULTICAST_PORT, 'udp6', true, getParameter('interfaceName'), getParameter('ipv6InterfaceAddress') || '::', getParameter('outgoingIpv6InterfaceAddress'));
222
172
  if (hasParameter('v') || hasParameter('verbose'))
223
173
  mdnsIpv6.listNetworkInterfaces();
224
- // Apply filters if any
225
174
  const filters = getStringArrayParameter('filter');
226
175
  if (filters)
227
176
  mdnsIpv6.filters.push(...filters);
228
- // Handle errors
229
177
  mdnsIpv6.on('error', (err) => {
230
178
  mdnsIpv6?.log.error(`mDNS udp6 Server error: ${err.message}\n${err.stack}`);
231
179
  });
232
- // Start the IPv6 mDNS server
233
180
  mdnsIpv6.start();
234
181
  mdnsIpv6.on('ready', (address) => {
235
182
  mdnsIpv6?.socket.setMulticastLoopback(false);
@@ -244,18 +191,15 @@ Examples:
244
191
  }
245
192
  });
246
193
  }
247
- // Handle Ctrl+C (SIGINT) and SIGTERM to stop and log devices
248
194
  process.on('SIGINT', async () => {
249
195
  await cleanupAndLogAndExit();
250
196
  });
251
197
  process.on('SIGTERM', async () => {
252
198
  await cleanupAndLogAndExit();
253
199
  });
254
- // Exit after a timeout to avoid running indefinitely in test environments
255
200
  if (!hasParameter('no-timeout')) {
256
201
  setTimeout(async () => {
257
202
  await cleanupAndLogAndExit();
258
- }, 600000).unref(); // 10 minutes timeout to exit if no activity
203
+ }, 600000).unref();
259
204
  }
260
205
  }
261
- //# sourceMappingURL=mb_mdns.js.map