homebridge-config-ui-x 6.0.2-alpha.0 → 6.0.2-alpha.2

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 (231) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/core/auth/auth.controller.js +3 -3
  3. package/dist/core/config/config.service.js +4 -0
  4. package/dist/core/config/config.startup.js +6 -0
  5. package/dist/core/spa/spa.filter.js +11 -2
  6. package/dist/core/web-root.js +63 -0
  7. package/dist/main.js +12 -5
  8. package/dist/modules/accessories/accessories.service.js +12 -2
  9. package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.js +8 -3
  10. package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.js +1 -1
  11. package/dist/modules/plugins/plugins.service.js +7 -1
  12. package/dist/modules/server/server.module.js +2 -0
  13. package/dist/modules/server/server.service.js +133 -18
  14. package/package.json +14 -14
  15. package/public/3rdpartylicenses.txt +175 -175
  16. package/public/assets/manifest.webmanifest +1 -1
  17. package/public/assets/monaco/min/vs/assets/editor.worker-Dpo8bqBT.js +45 -0
  18. package/public/assets/monaco/min/vs/assets/json.worker-BJDtq78O.js +77 -0
  19. package/public/assets/monaco/min/vs/basic-languages/monaco.contribution.js +1 -1
  20. package/public/assets/monaco/min/vs/css.worker-C7XcYe5x.js +1 -0
  21. package/public/assets/monaco/min/vs/editor/editor.main.css +1 -1
  22. package/public/assets/monaco/min/vs/editor/editor.main.js +1 -1
  23. package/public/assets/monaco/min/vs/editor-CG9c2pE-.js +1094 -0
  24. package/public/assets/monaco/min/vs/html.worker-VIR_LTyv.js +1 -0
  25. package/public/assets/monaco/min/vs/index-BVflv2uG.js +5 -0
  26. package/public/assets/monaco/min/vs/json.worker-DzWXGkG8.js +1 -0
  27. package/public/assets/monaco/min/vs/jsonMode-Dz4r0pwo.js +7 -0
  28. package/public/assets/monaco/min/vs/lspLanguageFeatures-IeRAvoKK.js +4 -0
  29. package/public/assets/monaco/min/vs/{monaco.contribution-C7tY_xnl.js → monaco.contribution-BRs4bdz5.js} +1 -1
  30. package/public/assets/monaco/min/vs/{monaco.contribution-BuX2NvO2.js → monaco.contribution-ChoOM5Gg.js} +1 -1
  31. package/public/assets/monaco/min/vs/{monaco.contribution-D1-wBxcq.js → monaco.contribution-DKFaWvum.js} +1 -1
  32. package/public/assets/monaco/min/vs/{monaco.contribution-CY2lwFI8.js → monaco.contribution-DbKqsbmO.js} +1 -1
  33. package/public/assets/monaco/min/vs/toggleHighContrast-CmI6H2gJ.js +65 -0
  34. package/public/assets/monaco/min/vs/ts.worker-Dp2_QI6H.js +1 -0
  35. package/public/assets/monaco/min/vs/{workers-BeMslOxK.js → workers-B_Zs9c54.js} +1 -1
  36. package/public/chunk-1lu9G6Yu.js +1 -0
  37. package/public/chunk-3m6zS8Mr.js +1 -0
  38. package/public/chunk-9uwo2qOO.js +1 -0
  39. package/public/chunk-B3Ri2XHC.js +1 -0
  40. package/public/chunk-B3ZX3QoH.js +1 -0
  41. package/public/{chunk-BFd_i428.js → chunk-B8d3htML.js} +1 -1
  42. package/public/chunk-B8oD3na1.js +1 -0
  43. package/public/{chunk-BUNcFZh1.js → chunk-B8oHFsqb.js} +1 -1
  44. package/public/chunk-BBdUQHh4.js +67 -0
  45. package/public/chunk-BBt6OZ-B.js +1 -0
  46. package/public/chunk-BEYdklL1.js +1 -0
  47. package/public/chunk-BEnB7BpR.js +1 -0
  48. package/public/chunk-BFMjt3Ba.js +1 -0
  49. package/public/chunk-BI8rLIOP.js +1 -0
  50. package/public/chunk-BILlmW9k.js +1 -0
  51. package/public/chunk-BInMMqcK.js +1 -0
  52. package/public/chunk-BJETCWnd.js +1 -0
  53. package/public/chunk-BJQZ6j97.js +1 -0
  54. package/public/{chunk-jv9zI3LS.js → chunk-BLJQEMUf.js} +1 -1
  55. package/public/{chunk-BveMKD0l.js → chunk-BQ8D5kFv.js} +1 -1
  56. package/public/{chunk-hHlVvZt_.js → chunk-BXehxSxl.js} +1 -1
  57. package/public/chunk-BYRwTpPf.js +1 -0
  58. package/public/{chunk-Dpp94EWX.js → chunk-Bj0U_sID.js} +2 -2
  59. package/public/{chunk-C8yrZ_eo.js → chunk-Bk_ArjL8.js} +1 -1
  60. package/public/chunk-Bo_O8iZP.js +1 -0
  61. package/public/chunk-BrFV8q14.js +77 -0
  62. package/public/chunk-BsNsTaWu.js +1 -0
  63. package/public/chunk-ByEml5nL.js +1 -0
  64. package/public/chunk-C1GCsifP.js +1 -0
  65. package/public/chunk-C2B_9ITv.js +1 -0
  66. package/public/chunk-C6JBSGvX.js +4 -0
  67. package/public/chunk-C8SH290k.js +1 -0
  68. package/public/chunk-C94ytHlF.js +1 -0
  69. package/public/chunk-CAg4iz2O.js +1 -0
  70. package/public/chunk-CHHH-td4.js +1 -0
  71. package/public/chunk-CHgXXDiY.js +1 -0
  72. package/public/{chunk-Qp75gW7I.js → chunk-CLQFLBmb.js} +1 -1
  73. package/public/chunk-CQ5ptinv.js +1 -0
  74. package/public/chunk-CRFzmmpm.js +1 -0
  75. package/public/chunk-CSYe8DIf.js +1 -0
  76. package/public/{chunk-BPVAlrHc.js → chunk-CTSZgML6.js} +1 -1
  77. package/public/chunk-CY6-Bpqk.js +1 -0
  78. package/public/chunk-C_fo00B4.js +1 -0
  79. package/public/{chunk-XcJN4P27.js → chunk-CdYS3o1A.js} +1 -1
  80. package/public/{chunk-B_-H5tD3.js → chunk-CgaoSL9H.js} +1 -1
  81. package/public/chunk-Ckk83aaw.js +1 -0
  82. package/public/chunk-CluzF5_A.js +1 -0
  83. package/public/chunk-Cm1bPHxo.js +1 -0
  84. package/public/chunk-Cnv5drQa.js +1 -0
  85. package/public/chunk-CoPZYJS4.js +1 -0
  86. package/public/{chunk-_DGivVxw.js → chunk-CqjABOYR.js} +1 -1
  87. package/public/{chunk-DhPScXQV.js → chunk-Crl1iRPV.js} +1 -1
  88. package/public/chunk-CsGuXURj.js +1 -0
  89. package/public/chunk-CwIavSVf.js +1 -0
  90. package/public/{chunk-CAK7-aGi.js → chunk-CwmHFXcS.js} +1 -1
  91. package/public/{chunk-C1JDi2C1.js → chunk-Cxjd4D1_.js} +3 -3
  92. package/public/chunk-Czl74XgX.js +1 -0
  93. package/public/chunk-CzltFWXY.js +1 -0
  94. package/public/{chunk-Bh2DW2Z7.js → chunk-D-8BaR3r.js} +1 -1
  95. package/public/chunk-D1Ma5hI9.js +1 -0
  96. package/public/{chunk-JcSMaleO.js → chunk-D1Vsa6Su.js} +3 -3
  97. package/public/chunk-D4gkyyi3.js +1 -0
  98. package/public/chunk-DAeEmuot.js +1 -0
  99. package/public/{chunk-S73g6Xv_.js → chunk-DB2gmL1d.js} +9 -9
  100. package/public/chunk-DBXkuMTo.js +1 -0
  101. package/public/chunk-DGvf-rc0.js +1 -0
  102. package/public/{chunk-DAZh5doz.js → chunk-DOnTXnzl.js} +1 -1
  103. package/public/chunk-DOx1FIJv.js +1 -0
  104. package/public/chunk-DOz6c5xr.js +1 -0
  105. package/public/{chunk-oafoTire.js → chunk-DPDD_n3a.js} +1 -1
  106. package/public/chunk-DReK6Ive.js +1 -0
  107. package/public/chunk-DRxp5xb4.js +1 -0
  108. package/public/{chunk-swVNWF3z.js → chunk-DVfSzUfa.js} +1 -1
  109. package/public/{chunk-B-vwazdF.js → chunk-DXrjtYSy.js} +1 -1
  110. package/public/{chunk-BwRqb4Xl.js → chunk-Da-Fx4NA.js} +1 -1
  111. package/public/chunk-DaGc5plA.js +1 -0
  112. package/public/chunk-DaXtGXR8.js +1 -0
  113. package/public/chunk-DapkaiSi.js +1 -0
  114. package/public/{chunk-Dhh_OKHH.js → chunk-Darearah.js} +1 -1
  115. package/public/{chunk-DOKbUbaG.js → chunk-Dck1QVAn.js} +2 -2
  116. package/public/chunk-Ddpcfkcn.js +1 -0
  117. package/public/chunk-DgkjbdVP.js +1 -0
  118. package/public/chunk-DhReRhI8.js +1 -0
  119. package/public/{chunk-B7WK0rWS.js → chunk-DiHcwt8a.js} +3 -3
  120. package/public/chunk-Dj8Yo0DW.js +1 -0
  121. package/public/chunk-DjJ9tJKX.js +1 -0
  122. package/public/chunk-DlMvu-9h.js +1 -0
  123. package/public/{chunk-C90YpOAm.js → chunk-DlUkBJNU.js} +1 -1
  124. package/public/chunk-Doics-T0.js +1 -0
  125. package/public/chunk-Dvl_mC30.js +1 -0
  126. package/public/chunk-DzJNqb7T.js +1 -0
  127. package/public/chunk-Fsiv7riA.js +1 -0
  128. package/public/chunk-JakTO4wZ.js +1 -0
  129. package/public/{chunk-DobfKJwY.js → chunk-LMn30YsD.js} +1 -1
  130. package/public/chunk-MZW_rzRd.js +1 -0
  131. package/public/{chunk-IMJ1Pklq.js → chunk-NzCxCir9.js} +3 -3
  132. package/public/chunk-TdhQab75.js +1 -0
  133. package/public/chunk-cEyWTJhy.js +1 -0
  134. package/public/chunk-cWHKVTH4.js +1 -0
  135. package/public/{chunk-DDhLcy_D.js → chunk-cZirCLw4.js} +1 -1
  136. package/public/chunk-gBZqvBaO.js +1 -0
  137. package/public/{chunk-CIb-rK1H.js → chunk-kPfKMbvf.js} +2 -2
  138. package/public/{chunk-BP5juMXa.js → chunk-ltCMKjJu.js} +2 -2
  139. package/public/{chunk-DNZ6y-E5.js → chunk-t4zF4uOE.js} +1 -1
  140. package/public/chunk-xJKUQLu7.js +1 -0
  141. package/public/index.html +6 -6
  142. package/public/main-GZBSSW6K.js +103 -0
  143. package/public/assets/monaco/min/vs/assets/editor.worker-_vAIFJDs.js +0 -30
  144. package/public/assets/monaco/min/vs/assets/json.worker-Csf_TLih.js +0 -62
  145. package/public/assets/monaco/min/vs/css.worker-BInK4lsP.js +0 -1
  146. package/public/assets/monaco/min/vs/editor/editor.worker.js +0 -1
  147. package/public/assets/monaco/min/vs/editor-BdtEMBbM.js +0 -892
  148. package/public/assets/monaco/min/vs/editorWorkerHost-B_VpI68A.js +0 -35
  149. package/public/assets/monaco/min/vs/html.worker-C1TNvQ72.js +0 -1
  150. package/public/assets/monaco/min/vs/index-049xrXrp.js +0 -1
  151. package/public/assets/monaco/min/vs/index-DZH_zysX.js +0 -5
  152. package/public/assets/monaco/min/vs/json.worker-Bp7U0-9w.js +0 -1
  153. package/public/assets/monaco/min/vs/jsonMode-w7Q_ZLTt.js +0 -1
  154. package/public/assets/monaco/min/vs/lspLanguageFeatures-Cog3rVVE.js +0 -2
  155. package/public/assets/monaco/min/vs/main-BEx-Fmlo.js +0 -15
  156. package/public/assets/monaco/min/vs/main-DsK8pnKg.js +0 -3
  157. package/public/assets/monaco/min/vs/toggleHighContrast-DuqAmExZ.js +0 -65
  158. package/public/assets/monaco/min/vs/ts.worker-BLYAhMkX.js +0 -1
  159. package/public/chunk-19RRhzSn.js +0 -1
  160. package/public/chunk-1ZZYSsZj.js +0 -1
  161. package/public/chunk-7qKC43aC.js +0 -1
  162. package/public/chunk-B7wk0Ryt.js +0 -1
  163. package/public/chunk-BE0TggZD.js +0 -1
  164. package/public/chunk-BIHDz9WT.js +0 -1
  165. package/public/chunk-BPGbGyH9.js +0 -1
  166. package/public/chunk-BRAtdQ6O.js +0 -1
  167. package/public/chunk-BRe-xqXh.js +0 -1
  168. package/public/chunk-BTPCFVoM.js +0 -1
  169. package/public/chunk-BUwwp9Lg.js +0 -1
  170. package/public/chunk-B_W-PbaT.js +0 -1
  171. package/public/chunk-BfMBukPc.js +0 -1
  172. package/public/chunk-Bj0y_T2Z.js +0 -4
  173. package/public/chunk-BjqPm-1A.js +0 -1
  174. package/public/chunk-BmyP6Esm.js +0 -1
  175. package/public/chunk-BoC9yLDy.js +0 -1
  176. package/public/chunk-BuI4wb3T.js +0 -1
  177. package/public/chunk-C5-srl7d.js +0 -1
  178. package/public/chunk-CIWsnVU5.js +0 -1
  179. package/public/chunk-CLflBUwq.js +0 -1
  180. package/public/chunk-CNRtiDBB.js +0 -1
  181. package/public/chunk-CRgwssHA.js +0 -1
  182. package/public/chunk-CULO6PUW.js +0 -1
  183. package/public/chunk-CZFE6dc4.js +0 -1
  184. package/public/chunk-Cd5v3OMi.js +0 -1
  185. package/public/chunk-CeZ-Qn-M.js +0 -1
  186. package/public/chunk-CfSQiSQT.js +0 -1
  187. package/public/chunk-Cg9fZ61J.js +0 -1
  188. package/public/chunk-CgTvy6_g.js +0 -1
  189. package/public/chunk-ChA2K8ty.js +0 -1
  190. package/public/chunk-CjiV0jfl.js +0 -1
  191. package/public/chunk-CoE1xdZy.js +0 -1
  192. package/public/chunk-CoeA5y6H.js +0 -1
  193. package/public/chunk-CuCEz0zz.js +0 -1
  194. package/public/chunk-CvxCalkY.js +0 -1
  195. package/public/chunk-D4NCpX10.js +0 -1
  196. package/public/chunk-D5LOTazk.js +0 -1
  197. package/public/chunk-D5daYzKr.js +0 -1
  198. package/public/chunk-DE5q6o6N.js +0 -1
  199. package/public/chunk-DEt61aJi.js +0 -1
  200. package/public/chunk-DI29fahl.js +0 -1
  201. package/public/chunk-DKT0VSMr.js +0 -1
  202. package/public/chunk-DLe28UIQ.js +0 -1
  203. package/public/chunk-DS6hj4Vx.js +0 -1
  204. package/public/chunk-DUFleTpE.js +0 -1
  205. package/public/chunk-DY5xWjnH.js +0 -1
  206. package/public/chunk-DcBCn-Kl.js +0 -1
  207. package/public/chunk-DfrqpENg.js +0 -1
  208. package/public/chunk-DkuVNYvO.js +0 -1
  209. package/public/chunk-Dnh0EI9F.js +0 -1
  210. package/public/chunk-DnpIQmjU.js +0 -1
  211. package/public/chunk-Drs_xPa5.js +0 -1
  212. package/public/chunk-DuzPkXgC.js +0 -76
  213. package/public/chunk-Dw-FHaqN.js +0 -1
  214. package/public/chunk-DxK_zlhD.js +0 -1
  215. package/public/chunk-DxkunErg.js +0 -1
  216. package/public/chunk-FNGgmFFQ.js +0 -1
  217. package/public/chunk-ILq0kRXD.js +0 -1
  218. package/public/chunk-JIUu5d6u.js +0 -1
  219. package/public/chunk-MoAW8ABl.js +0 -1
  220. package/public/chunk-Nn2eZN73.js +0 -1
  221. package/public/chunk-NurJqQMj.js +0 -1
  222. package/public/chunk-QTbOemWx.js +0 -67
  223. package/public/chunk-QVz_Nlcf.js +0 -1
  224. package/public/chunk-SVlSDgj0.js +0 -1
  225. package/public/chunk-WIz7sGpH.js +0 -1
  226. package/public/chunk-_h2sn7wK.js +0 -1
  227. package/public/chunk-c9qCGknq.js +0 -1
  228. package/public/chunk-et95Cghg.js +0 -1
  229. package/public/chunk-q4vdqpGO.js +0 -1
  230. package/public/chunk-wY4dK2UD.js +0 -1
  231. package/public/main-XEM2F5W3.js +0 -103
package/CHANGELOG.md CHANGED
@@ -132,6 +132,11 @@ All notable changes to `homebridge-config-ui-x` will be documented in this file.
132
132
  - fix(accessories): keep the filters dropdown hidden until it is opened, sized like the group and sort menu
133
133
  - feat(accessories): style the group and sort menu like the filters menu, and drop the show accessories button
134
134
  - feat(accessories): reset the grouping and sort from the group and sort menu
135
+ - feat(accessories): move the toolbar buttons to the header, add a reset, count filter options against the other filters, and show tick marks
136
+ - fix(accessories): put the search beside the header buttons, and plain menu rows with muted counts
137
+ - fix(accessories): import the dropdown item directive, so the filter and sort menu rows render as menu items in light and dark mode
138
+ - fix(accessories): name bridges by their advertised mdns name from hap-client 5.4.1-beta.4, without the username suffix
139
+ - feat(accessories): filter low batteries under state instead of a battery section, drop the battery sort, and keep the full advertised bridge name
135
140
 
136
141
  ### Other Changes
137
142
 
@@ -174,6 +179,14 @@ All notable changes to `homebridge-config-ui-x` will be documented in this file.
174
179
  - fix(auth): close a user's open sockets when the user is deleted or the session is revoked
175
180
  - fix(terminal): leave a swipe past the first or last line to the phone, to scroll the page
176
181
  - fix(plugins): match the start of words in the plugin search (#3138) (@emreocell)
182
+ - fix(plugins): show a plugin's first maintainer in the search, not github actions (#3146)
183
+ - test(ui): stop loading the app polyfills in the ui tests, which left them unchecked
184
+ - fix(accessories): hide a camera's recording, operating mode and data stream services
185
+ - feat(accessories): show a camera as one tile, with its sound, motion sensor and doorbell
186
+ - fix(accessories): accept an id saved before hap-client 5.4.1 in the accessory api (#3125)
187
+ - feat(server): add a web root setting, to serve the ui under a path behind a reverse proxy (#746)
188
+ - feat(matter): show left-over matter storage as stale bridges, and remove it with its plugin
189
+ - fix(server): return an empty list, not a 500, when the accessories or persist folder is missing
177
190
  - chore(deps): dependency updates
178
191
  - fix(build): subset the font awesome fonts from a full copy each time, so an icon added after the first local build is included
179
192
  - test(accessories): time the 500-service grouping check after a warm-up, with a budget a busy ci runner can meet
@@ -167,13 +167,13 @@ let AuthController = class AuthController {
167
167
  buildRefreshCookie(token, secure) {
168
168
  const maxAge = this.configService.ui.sessionTimeout || 28800;
169
169
  const secureFlag = secure ? '; Secure' : '';
170
- return `hb-refresh=${token}; HttpOnly; SameSite=Strict; Path=${API_PREFIX}/auth/session; Max-Age=${maxAge}${secureFlag}`;
170
+ return `hb-refresh=${token}; HttpOnly; SameSite=Strict; Path=${this.configService.webRoot}${API_PREFIX}/auth/session; Max-Age=${maxAge}${secureFlag}`;
171
171
  }
172
172
  buildClearedCookies(secure, pluginNames = []) {
173
173
  const secureFlag = secure ? '; Secure' : '';
174
174
  return [
175
- `hb-refresh=; HttpOnly; SameSite=Strict; Path=${API_PREFIX}/auth/session; Max-Age=0${secureFlag}`,
176
- ...pluginNames.map(pluginName => `hb-plugin-ui=; HttpOnly; SameSite=Strict; Path=${API_PREFIX}/plugins/settings-ui/${encodeURIComponent(pluginName)}/; Max-Age=0${secureFlag}`),
175
+ `hb-refresh=; HttpOnly; SameSite=Strict; Path=${this.configService.webRoot}${API_PREFIX}/auth/session; Max-Age=0${secureFlag}`,
176
+ ...pluginNames.map(pluginName => `hb-plugin-ui=; HttpOnly; SameSite=Strict; Path=${this.configService.webRoot}${API_PREFIX}/plugins/settings-ui/${encodeURIComponent(pluginName)}/; Max-Age=0${secureFlag}`),
177
177
  ];
178
178
  }
179
179
  };
@@ -18,6 +18,7 @@ import { Injectable } from '@nestjs/common';
18
18
  import { pathExists, pathExistsSync, readJson, readJSONSync, readJsonSync } from 'fs-extra/esm';
19
19
  import { satisfies } from 'semver';
20
20
  import { FEATURE_FLAGS } from '../feature-flags/feature-flags.registry.js';
21
+ import { activeWebRoot } from '../web-root.js';
21
22
  const WALLPAPER_EXTENSIONS = new Set([
22
23
  '.avif',
23
24
  '.bmp',
@@ -83,9 +84,11 @@ let ConfigService = class ConfigService {
83
84
  secrets;
84
85
  instanceId;
85
86
  savedUiRestart;
87
+ webRoot;
86
88
  constructor() {
87
89
  const homebridgeConfig = readJSONSync(this.configPath);
88
90
  this.parseConfig(homebridgeConfig);
91
+ this.webRoot = activeWebRoot(this.ui.webRoot);
89
92
  this.checkIfRunningOnRaspberryPi();
90
93
  this.checkIfRunningOnRaspbianImage();
91
94
  }
@@ -230,6 +233,7 @@ let ConfigService = class ConfigService {
230
233
  wallpaper: this.ui.wallpaper,
231
234
  host: this.ui.host || '',
232
235
  proxyHost: this.ui.proxyHost || '',
236
+ webRoot: this.ui.webRoot || '',
233
237
  keepOrphans: this.hbStartupSettings?.keepOrphans || false,
234
238
  };
235
239
  }
@@ -5,6 +5,7 @@ import process from 'node:process';
5
5
  import { readJson } from 'fs-extra/esm';
6
6
  import { Logger } from '../logger/logger.service.js';
7
7
  import { SslCertGeneratorService } from '../ssl/ssl-cert-generator.service.js';
8
+ import { activeWebRoot } from '../web-root.js';
8
9
  export async function getStartupConfig() {
9
10
  const logger = new Logger();
10
11
  const configPath = process.env.UIX_CONFIG_PATH || resolve(homedir(), '.homebridge/config.json');
@@ -17,6 +18,7 @@ export async function getStartupConfig() {
17
18
  return addresses.find(x => x.family === 'IPv6');
18
19
  }).length;
19
20
  config.host = ipv6 ? '::' : '0.0.0.0';
21
+ config.webRoot = '';
20
22
  if (!ui) {
21
23
  return config;
22
24
  }
@@ -72,6 +74,10 @@ export async function getStartupConfig() {
72
74
  if (ui.proxyHost && process.env.UIX_DEVELOPMENT !== '1') {
73
75
  config.cspWsOverride = `wss://${ui.proxyHost} ws://${ui.proxyHost}`;
74
76
  }
77
+ config.webRoot = activeWebRoot(ui.webRoot);
78
+ if (ui.webRoot && !config.webRoot && process.env.UIX_DEVELOPMENT !== '1') {
79
+ logger.error(`Web root config error: ui.webRoot: ${JSON.stringify(ui.webRoot)} is not a valid path, so the UI is at the root.`);
80
+ }
75
81
  if (ui.allowFrameAncestors) {
76
82
  const raw = Array.isArray(ui.allowFrameAncestors)
77
83
  ? ui.allowFrameAncestors
@@ -4,11 +4,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
7
10
  import { readFileSync } from 'node:fs';
8
11
  import { resolve } from 'node:path';
9
12
  import process from 'node:process';
10
13
  import { Catch, NotFoundException } from '@nestjs/common';
14
+ import { setBaseHref } from '../web-root.js';
11
15
  let SpaFilter = class SpaFilter {
16
+ webRoot;
17
+ constructor(webRoot = '') {
18
+ this.webRoot = webRoot;
19
+ }
12
20
  catch(exception, host) {
13
21
  const ctx = host.switchToHttp();
14
22
  const req = ctx.getRequest();
@@ -24,10 +32,11 @@ let SpaFilter = class SpaFilter {
24
32
  res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
25
33
  res.header('Pragma', 'no-cache');
26
34
  res.header('Expires', '0');
27
- res.send(indexHtml);
35
+ res.send(setBaseHref(indexHtml, this.webRoot));
28
36
  }
29
37
  };
30
38
  SpaFilter = __decorate([
31
- Catch(NotFoundException)
39
+ Catch(NotFoundException),
40
+ __metadata("design:paramtypes", [Object])
32
41
  ], SpaFilter);
33
42
  export { SpaFilter };
@@ -0,0 +1,63 @@
1
+ import process from 'node:process';
2
+ const RESERVED = new Set([
3
+ 'api',
4
+ 'assets',
5
+ 'media',
6
+ 'socket.io',
7
+ 'swagger',
8
+ ]);
9
+ const RE_PART = /^[\w.~-]+$/;
10
+ const RE_ONLY_DOTS = /^\.+$/;
11
+ const RE_OUTER_SLASHES = /^\/|\/$/g;
12
+ const RE_BASE_TAG = /<base href="\/"/;
13
+ const MAX_LENGTH = 100;
14
+ export function normalizeWebRoot(value) {
15
+ if (typeof value !== 'string') {
16
+ return '';
17
+ }
18
+ const path = value.trim().replace(RE_OUTER_SLASHES, '');
19
+ if (!path || path.length >= MAX_LENGTH) {
20
+ return '';
21
+ }
22
+ const parts = path.split('/');
23
+ if (parts.some(part => !RE_PART.test(part) || RE_ONLY_DOTS.test(part)) || RESERVED.has(parts[0].toLowerCase())) {
24
+ return '';
25
+ }
26
+ return `/${path}`;
27
+ }
28
+ export function activeWebRoot(value) {
29
+ return process.env.UIX_DEVELOPMENT === '1'
30
+ ? ''
31
+ : normalizeWebRoot(value);
32
+ }
33
+ export function stripWebRoot(url, webRoot) {
34
+ if (!webRoot || !url.startsWith(webRoot)) {
35
+ return url;
36
+ }
37
+ const rest = url.slice(webRoot.length);
38
+ if (rest === '') {
39
+ return '/';
40
+ }
41
+ if (rest.startsWith('/')) {
42
+ return rest;
43
+ }
44
+ if (rest.startsWith('?')) {
45
+ return `/${rest}`;
46
+ }
47
+ return url;
48
+ }
49
+ export function setBaseHref(indexHtml, webRoot) {
50
+ return webRoot
51
+ ? indexHtml.replace(RE_BASE_TAG, `<base href="${webRoot}/"`)
52
+ : indexHtml;
53
+ }
54
+ export function serveUnderWebRoot(server, webRoot) {
55
+ if (!webRoot) {
56
+ return;
57
+ }
58
+ const strip = (req) => {
59
+ req.url = stripWebRoot(req.url ?? '/', webRoot);
60
+ };
61
+ server.prependListener('request', strip);
62
+ server.prependListener('upgrade', strip);
63
+ }
package/dist/main.js CHANGED
@@ -16,6 +16,7 @@ import { devServerCorsConfig } from './core/cors.config.js';
16
16
  import { Logger } from './core/logger/logger.service.js';
17
17
  import { SpaFilter } from './core/spa/spa.filter.js';
18
18
  import { setStaticAssetCacheHeaders } from './core/static-assets.js';
19
+ import { serveUnderWebRoot, setBaseHref } from './core/web-root.js';
19
20
  import './env-setup.js';
20
21
  import 'reflect-metadata';
21
22
  import './self-check.js';
@@ -92,7 +93,7 @@ async function bootstrap() {
92
93
  res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
93
94
  res.header('Pragma', 'no-cache');
94
95
  res.header('Expires', '0');
95
- res.send(await readFile(resolve(process.env.UIX_BASE_PATH, 'public/index.html')));
96
+ res.send(setBaseHref(await readFile(resolve(process.env.UIX_BASE_PATH, 'public/index.html'), 'utf-8'), startupConfig.webRoot));
96
97
  });
97
98
  app.useStaticAssets({
98
99
  root: resolve(process.env.UIX_BASE_PATH, 'public'),
@@ -122,16 +123,22 @@ async function bootstrap() {
122
123
  type: 'oauth2',
123
124
  flows: {
124
125
  password: {
125
- tokenUrl: '/api/auth/login',
126
+ tokenUrl: `${startupConfig.webRoot}${API_PREFIX}/auth/login`,
126
127
  scopes: null,
127
128
  },
128
129
  },
129
130
  })
131
+ .addServer(startupConfig.webRoot || '/')
130
132
  .build();
131
133
  const document = SwaggerModule.createDocument(app, options);
132
134
  SwaggerModule.setup('swagger', app, document);
133
- app.useGlobalFilters(new SpaFilter());
134
- logger.success(`Homebridge UI v${configService.package.version} is listening on ${startupConfig.host} port ${configService.ui.port}.`);
135
+ app.useGlobalFilters(new SpaFilter(startupConfig.webRoot));
136
+ await app.init();
137
+ serveUnderWebRoot(app.getHttpServer(), startupConfig.webRoot);
138
+ const underWebRoot = startupConfig.webRoot
139
+ ? `, under ${startupConfig.webRoot}`
140
+ : '';
141
+ logger.success(`Homebridge UI v${configService.package.version} is listening on ${startupConfig.host} port ${configService.ui.port}${underWebRoot}.`);
135
142
  await app.listen(configService.ui.port, startupConfig.host);
136
143
  let bonjour = null;
137
144
  if (configService.ui.enableMdnsAdvertise) {
@@ -148,7 +155,7 @@ async function bootstrap() {
148
155
  ? undefined
149
156
  : startupConfig.host,
150
157
  txt: {
151
- path: '/',
158
+ path: `${startupConfig.webRoot}/`,
152
159
  version: configService.package.version,
153
160
  https: startupConfig.httpsOptions ? 'true' : 'false',
154
161
  },
@@ -288,12 +288,22 @@ let AccessoriesService = class AccessoriesService {
288
288
  return [];
289
289
  }
290
290
  }
291
+ findService(services, uniqueId) {
292
+ const service = services.find(x => x.uniqueId === uniqueId);
293
+ if (service) {
294
+ return service;
295
+ }
296
+ const legacy = services.filter(x => x.legacyUniqueId === uniqueId);
297
+ return legacy.length === 1
298
+ ? legacy[0]
299
+ : undefined;
300
+ }
291
301
  async getAccessory(uniqueId) {
292
302
  if (uniqueId.startsWith('matter:')) {
293
303
  return this.getMatterAccessory(uniqueId);
294
304
  }
295
305
  const services = await this.loadAccessories();
296
- const service = services.find(x => x.uniqueId === uniqueId);
306
+ const service = this.findService(services, uniqueId);
297
307
  if (!service) {
298
308
  throw new BadRequestException(`Service with uniqueId of '${uniqueId}' not found.`);
299
309
  }
@@ -333,7 +343,7 @@ let AccessoriesService = class AccessoriesService {
333
343
  }
334
344
  async setAccessoryCharacteristic(uniqueId, characteristicType, value) {
335
345
  const services = await this.loadAccessories();
336
- const service = services.find(x => x.uniqueId === uniqueId);
346
+ const service = this.findService(services, uniqueId);
337
347
  if (!service) {
338
348
  throw new BadRequestException(`Service with uniqueId of '${uniqueId}' not found.`);
339
349
  }
@@ -16,14 +16,17 @@ import { ApiBearerAuth, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'
16
16
  import { API_PREFIX } from '../../../core/api.constants.js';
17
17
  import { AdminGuard } from '../../../core/auth/guards/admin.guard.js';
18
18
  import { JwtAuthGuard } from '../../../core/auth/guards/jwt-auth.guard.js';
19
+ import { ConfigService } from '../../../core/config/config.service.js';
19
20
  import { PluginsSettingsUiTicketService } from './plugins-settings-ui-ticket.service.js';
20
21
  import { PluginsSettingsUiService } from './plugins-settings-ui.service.js';
21
22
  let PluginsSettingsUiController = class PluginsSettingsUiController {
22
23
  pluginSettingsUiService;
23
24
  ticketService;
24
- constructor(pluginSettingsUiService, ticketService) {
25
+ configService;
26
+ constructor(pluginSettingsUiService, ticketService, configService) {
25
27
  this.pluginSettingsUiService = pluginSettingsUiService;
26
28
  this.ticketService = ticketService;
29
+ this.configService = configService;
27
30
  }
28
31
  async issueTicket(request, pluginName) {
29
32
  await this.pluginSettingsUiService.getPluginUiMetadata(pluginName);
@@ -68,7 +71,7 @@ let PluginsSettingsUiController = class PluginsSettingsUiController {
68
71
  return await this.pluginSettingsUiService.serveCustomUiAsset(reply, pluginName, file, '', v);
69
72
  }
70
73
  setAssetSessionCookie(request, reply, token, maxAge = PluginsSettingsUiTicketService.assetSessionTtl) {
71
- const cookiePath = `${API_PREFIX}/plugins/settings-ui/${encodeURIComponent(request.params.pluginName)}/`;
74
+ const cookiePath = `${this.configService.webRoot}${API_PREFIX}/plugins/settings-ui/${encodeURIComponent(request.params.pluginName)}/`;
72
75
  const secure = request.protocol === 'https'
73
76
  ? '; Secure'
74
77
  : '';
@@ -128,7 +131,9 @@ PluginsSettingsUiController = __decorate([
128
131
  Controller('plugins/settings-ui'),
129
132
  __param(0, Inject(PluginsSettingsUiService)),
130
133
  __param(1, Inject(PluginsSettingsUiTicketService)),
134
+ __param(2, Inject(ConfigService)),
131
135
  __metadata("design:paramtypes", [PluginsSettingsUiService,
132
- PluginsSettingsUiTicketService])
136
+ PluginsSettingsUiTicketService,
137
+ ConfigService])
133
138
  ], PluginsSettingsUiController);
134
139
  export { PluginsSettingsUiController };
@@ -154,7 +154,7 @@ let PluginsSettingsUiService = class PluginsSettingsUiService {
154
154
  serverEnv: ${JSON.stringify(this.configService.uiSettings(true)).replace(/</g, '\\u003c')},
155
155
  };
156
156
  </script>
157
- <script src="${safeOrigin}/assets/plugin-ui-utils/ui.js?v=${this.configService.package.version}"></script>
157
+ <script src="${safeOrigin}${this.configService.webRoot}/assets/plugin-ui-utils/ui.js?v=${this.configService.package.version}"></script>
158
158
  <script>
159
159
  window.addEventListener('load', () => {
160
160
  window.parent.postMessage({action: 'loaded'}, '*');
@@ -378,7 +378,10 @@ let PluginsService = class PluginsService {
378
378
  description: (pkg.package.description || pkg.package.name).replace(RE_URL_WITH_OPTIONAL_PAREN, '').trim(),
379
379
  keywords: pkg.package.keywords || [],
380
380
  links: pkg.package.links,
381
- author: this.pluginAuthors[pkg.package.name] || (pkg.package.publisher ? pkg.package.publisher.username : null),
381
+ author: this.pluginAuthors[pkg.package.name]
382
+ || pkg.package.maintainers?.[0]?.username
383
+ || pkg.package.publisher?.username
384
+ || null,
382
385
  verifiedPlugin: this.verifiedPlugins.includes(pkg.package.name),
383
386
  verifiedPlusPlugin: this.verifiedPlusPlugins.includes(pkg.package.name),
384
387
  supportsMatter: this.supportsMatter(pkg.package.keywords),
@@ -1636,6 +1639,9 @@ let PluginsService = class PluginsService {
1636
1639
  return [];
1637
1640
  }
1638
1641
  }
1642
+ async getInstalledModuleNames() {
1643
+ return new Set((await this.getInstalledModules()).map(module => module.name));
1644
+ }
1639
1645
  async getInstalledModules() {
1640
1646
  const allModules = [];
1641
1647
  for (const requiredPath of this.paths) {
@@ -13,6 +13,7 @@ import { LoggerModule } from '../../core/logger/logger.module.js';
13
13
  import { AccessoriesModule } from '../accessories/accessories.module.js';
14
14
  import { ChildBridgesModule } from '../child-bridges/child-bridges.module.js';
15
15
  import { ConfigEditorModule } from '../config-editor/config-editor.module.js';
16
+ import { PluginsModule } from '../plugins/plugins.module.js';
16
17
  import { ServerController } from './server.controller.js';
17
18
  import { ServerService } from './server.service.js';
18
19
  let ServerModule = class ServerModule {
@@ -28,6 +29,7 @@ ServerModule = __decorate([
28
29
  ChildBridgesModule,
29
30
  HomebridgeIpcModule,
30
31
  FsModule,
32
+ PluginsModule,
31
33
  ],
32
34
  providers: [
33
35
  ServerService,
@@ -33,10 +33,11 @@ import { JsonFileStoreService } from '../../core/fs/json-file-store.service.js';
33
33
  import { writePrivateFile } from '../../core/fs/private-file.js';
34
34
  import { HomebridgeIpcService } from '../../core/homebridge-ipc/homebridge-ipc.service.js';
35
35
  import { Logger } from '../../core/logger/logger.service.js';
36
- import { RE_ACCESSORY_INFO_FILE, RE_CACHED_ACCESSORIES, RE_CACHED_ACCESSORIES_EXACT, RE_CERTIFICATE, RE_CHAR_PAIRS, RE_COLON, RE_DEVICE_ID, RE_EXTERNAL_ACCESSORIES_EXACT, RE_HEX_12, RE_HEX_ANY, RE_HYPHEN_GLOBAL, RE_PRIVATE_KEY, RE_SAFE_RESTART_CMD, RE_VALID_NAME, } from '../../core/regex.constants.js';
36
+ import { RE_ACCESSORY_INFO_FILE, RE_CACHED_ACCESSORIES, RE_CACHED_ACCESSORIES_EXACT, RE_CERTIFICATE, RE_CHAR_PAIRS, RE_COLON, RE_DEVICE_ID, RE_EXTERNAL_ACCESSORIES_EXACT, RE_HEX_12, RE_HEX_ANY, RE_HYPHEN_GLOBAL, RE_PRIVATE_KEY, RE_SAFE_RESTART_CMD, RE_VALID_NAME, RE_WHITESPACE, } from '../../core/regex.constants.js';
37
37
  import { SslCertGeneratorService } from '../../core/ssl/ssl-cert-generator.service.js';
38
38
  import { AccessoriesService } from '../accessories/accessories.service.js';
39
39
  import { ConfigEditorService } from '../config-editor/config-editor.service.js';
40
+ import { PluginsService } from '../plugins/plugins.service.js';
40
41
  const pump = promisify(pipeline);
41
42
  function toPortNumber(value) {
42
43
  const port = typeof value === 'string' && value.trim() !== ''
@@ -55,18 +56,20 @@ let ServerService = ServerService_1 = class ServerService {
55
56
  homebridgeIpcService;
56
57
  jsonStore;
57
58
  logger;
59
+ pluginsService;
58
60
  serverServiceCache = new NodeCache({ stdTTL: 300 });
59
61
  accessoryId;
60
62
  accessoryInfoPath;
61
63
  setupCode = null;
62
64
  paired = false;
63
- constructor(configService, configEditorService, accessoriesService, homebridgeIpcService, jsonStore, logger) {
65
+ constructor(configService, configEditorService, accessoriesService, homebridgeIpcService, jsonStore, logger, pluginsService) {
64
66
  this.configService = configService;
65
67
  this.configEditorService = configEditorService;
66
68
  this.accessoriesService = accessoriesService;
67
69
  this.homebridgeIpcService = homebridgeIpcService;
68
70
  this.jsonStore = jsonStore;
69
71
  this.logger = logger;
72
+ this.pluginsService = pluginsService;
70
73
  this.accessoryId = ServerService_1.macToHex(this.configService.homebridgeConfig.bridge.username);
71
74
  this.accessoryInfoPath = join(this.configService.storagePath, 'persist', `AccessoryInfo.${this.accessoryId}.json`);
72
75
  }
@@ -248,14 +251,20 @@ let ServerService = ServerService_1 = class ServerService {
248
251
  }
249
252
  async getDevicePairings() {
250
253
  const persistPath = join(this.configService.storagePath, 'persist');
251
- const devices = (await readdir(persistPath))
254
+ const persistFiles = await pathExists(persistPath)
255
+ ? await readdir(persistPath)
256
+ : [];
257
+ const devices = persistFiles
252
258
  .filter(x => x.match(RE_ACCESSORY_INFO_FILE) && RE_HEX_12.test(x.split('.')[1]));
253
259
  const configFile = await this.configEditorService.getConfigFile();
254
260
  const externalAttribution = await this.getExternalAccessoryAttribution();
255
261
  const hapDevices = await Promise.all(devices.map(async (x) => {
256
262
  return await this.getDevicePairingById(x.split('.')[1], configFile, externalAttribution);
257
263
  }));
258
- const matterExternalDevices = await this.getMatterExternalAccessories(hapDevices);
264
+ await Promise.all(hapDevices.filter(device => device._couldBeStale).map(async (device) => {
265
+ device._matter = await pathExists(join(this.configService.storagePath, 'matter', device._id));
266
+ }));
267
+ const matterExternalDevices = await this.getMatterExternalAccessories(hapDevices, configFile);
259
268
  return [
260
269
  ...hapDevices,
261
270
  ...matterExternalDevices,
@@ -292,13 +301,80 @@ let ServerService = ServerService_1 = class ServerService {
292
301
  }
293
302
  return attribution;
294
303
  }
295
- async getMatterExternalAccessories(hapDevices) {
304
+ async getMatterUsageContext(configFile) {
305
+ const blocks = [
306
+ ...(configFile.accessories || []),
307
+ ...(configFile.platforms || []),
308
+ ];
309
+ let installedPlugins = null;
310
+ if (!this.pluginsService.isPluginManagementInProgress) {
311
+ try {
312
+ installedPlugins = await this.pluginsService.getInstalledModuleNames();
313
+ }
314
+ catch (e) {
315
+ this.logger.warn(`Could not read the installed plugins to check for left-over Matter storage: ${e.message}`);
316
+ }
317
+ }
318
+ return {
319
+ installedPlugins,
320
+ platformAliases: new Set(blocks.map(block => block?.platform).filter(alias => typeof alias === 'string')),
321
+ bridgeUsernames: new Set([
322
+ this.configService.homebridgeConfig.bridge.username,
323
+ ...blocks.map(block => block?._bridge?.username),
324
+ ].filter(username => typeof username === 'string').map(username => username.toUpperCase())),
325
+ };
326
+ }
327
+ async isMatterStorageLocked(folder) {
328
+ let nodeFolders;
329
+ try {
330
+ nodeFolders = (await readdir(folder, { withFileTypes: true }))
331
+ .filter(entry => entry.isDirectory())
332
+ .map(entry => join(folder, entry.name));
333
+ }
334
+ catch {
335
+ return false;
336
+ }
337
+ for (const nodeFolder of nodeFolders) {
338
+ try {
339
+ const pid = Number.parseInt((await readFile(join(nodeFolder, 'matter.pid'), 'utf-8')).trim().split(RE_WHITESPACE)[0], 10);
340
+ if (!Number.isInteger(pid) || pid <= 0 || !await pathExists(join(nodeFolder, 'matter.lock'))) {
341
+ continue;
342
+ }
343
+ process.kill(pid, 0);
344
+ return true;
345
+ }
346
+ catch (e) {
347
+ if (e?.code === 'EPERM') {
348
+ return true;
349
+ }
350
+ }
351
+ }
352
+ return false;
353
+ }
354
+ static matterStoragePointsAtNothing(accessory, owner, context) {
355
+ const plugin = [accessory?.plugin, owner?.plugin].find(name => typeof name === 'string' && name);
356
+ if (plugin && context.installedPlugins && !context.installedPlugins.has(plugin)) {
357
+ return true;
358
+ }
359
+ const platform = [accessory?.platform, owner?.platform]
360
+ .find(alias => typeof alias === 'string' && alias && alias !== 'ExternalMatter');
361
+ if (platform && !context.platformAliases.has(platform)) {
362
+ return true;
363
+ }
364
+ return typeof owner?.bridge === 'string' && !context.bridgeUsernames.has(owner.bridge.toUpperCase());
365
+ }
366
+ async getMatterExternalAccessories(hapDevices, configFile) {
296
367
  const matterPath = join(this.configService.storagePath, 'matter');
297
368
  if (!await pathExists(matterPath)) {
298
369
  return [];
299
370
  }
300
371
  const matterDirs = (await readdir(matterPath))
301
372
  .filter(x => x.match(RE_HEX_12));
373
+ if (!matterDirs.length) {
374
+ return [];
375
+ }
376
+ const context = await this.getMatterUsageContext(configFile);
377
+ const mainBridgeId = ServerService_1.macToHex(this.configService.homebridgeConfig.bridge.username);
302
378
  const matterExternalDevices = [];
303
379
  for (const deviceId of matterDirs) {
304
380
  try {
@@ -306,20 +382,18 @@ let ServerService = ServerService_1 = class ServerService {
306
382
  if (hasHapAccessoryInfo) {
307
383
  continue;
308
384
  }
309
- const mainBridgeId = ServerService_1.macToHex(this.configService.homebridgeConfig.bridge.username);
310
385
  if (deviceId.toUpperCase() === mainBridgeId) {
311
386
  continue;
312
387
  }
313
- const accessoriesPath = join(matterPath, deviceId, 'accessories.json');
314
- if (!await pathExists(accessoriesPath)) {
315
- continue;
316
- }
317
- const accessories = await readJson(accessoriesPath);
318
- if (!Array.isArray(accessories) || accessories.length === 0) {
319
- continue;
320
- }
321
- const accessory = accessories[0];
322
- const commissioningPath = join(matterPath, deviceId, 'commissioning.json');
388
+ const folder = join(matterPath, deviceId);
389
+ const username = ServerService_1.hexToMac(deviceId);
390
+ const inUse = context.bridgeUsernames.has(username) || await this.isMatterStorageLocked(folder);
391
+ const accessories = await this.readJsonOr(join(folder, 'accessories.json'), []);
392
+ const owner = await this.readJsonOr(join(folder, 'homebridge-owner.json'), null);
393
+ const accessory = Array.isArray(accessories)
394
+ ? accessories[0]
395
+ : undefined;
396
+ const commissioningPath = join(folder, 'commissioning.json');
323
397
  let commissioned = false;
324
398
  let qrCode;
325
399
  let manualPairingCode;
@@ -344,15 +418,43 @@ let ServerService = ServerService_1 = class ServerService {
344
418
  }
345
419
  }
346
420
  }
421
+ if (!accessory) {
422
+ const comesBack = owner !== null && typeof owner === 'object' && !ServerService_1.matterStoragePointsAtNothing(undefined, owner, context);
423
+ if (inUse || comesBack) {
424
+ continue;
425
+ }
426
+ matterExternalDevices.push({
427
+ _id: deviceId,
428
+ _username: username,
429
+ _main: false,
430
+ _category: 'other',
431
+ _matter: true,
432
+ _matterOnly: true,
433
+ _isExternal: false,
434
+ _isPaired: commissioned,
435
+ _couldBeStale: true,
436
+ _plugin: typeof owner?.plugin === 'string'
437
+ ? owner.plugin
438
+ : undefined,
439
+ name: 'Unknown Matter Bridge',
440
+ displayName: 'Unknown Matter Bridge',
441
+ manufacturer: 'Unknown',
442
+ model: 'Unknown',
443
+ serialNumber: deviceId,
444
+ category: 1,
445
+ });
446
+ continue;
447
+ }
347
448
  const device = {
348
449
  _id: deviceId,
349
- _username: ServerService_1.hexToMac(deviceId),
450
+ _username: username,
350
451
  _main: false,
351
452
  _category: 'other',
352
453
  _matter: true,
353
454
  _matterOnly: true,
354
455
  _isExternal: true,
355
456
  _isPaired: commissioned,
457
+ _couldBeStale: !inUse && ServerService_1.matterStoragePointsAtNothing(accessory, owner, context),
356
458
  _plugin: accessory.plugin,
357
459
  _setupCode: qrCode,
358
460
  pincode: manualPairingCode,
@@ -371,6 +473,14 @@ let ServerService = ServerService_1 = class ServerService {
371
473
  }
372
474
  return matterExternalDevices;
373
475
  }
476
+ async readJsonOr(file, fallback) {
477
+ try {
478
+ return await readJson(file);
479
+ }
480
+ catch {
481
+ return fallback;
482
+ }
483
+ }
374
484
  async getDevicePairingById(deviceId, configFile = null, externalAttribution = null) {
375
485
  if (typeof deviceId !== 'string' || !RE_HEX_12.test(deviceId)) {
376
486
  throw new BadRequestException('Invalid device id.');
@@ -533,6 +643,9 @@ let ServerService = ServerService_1 = class ServerService {
533
643
  }
534
644
  async getCachedAccessories() {
535
645
  const cachedAccessoriesDir = join(this.configService.storagePath, 'accessories');
646
+ if (!await pathExists(cachedAccessoriesDir)) {
647
+ return [];
648
+ }
536
649
  const cachedAccessoryFiles = (await readdir(cachedAccessoriesDir))
537
650
  .filter(x => x.match(RE_CACHED_ACCESSORIES_EXACT) || x === 'cachedAccessories');
538
651
  const cachedAccessories = [];
@@ -1497,11 +1610,13 @@ ServerService = ServerService_1 = __decorate([
1497
1610
  __param(3, Inject(HomebridgeIpcService)),
1498
1611
  __param(4, Inject(JsonFileStoreService)),
1499
1612
  __param(5, Inject(Logger)),
1613
+ __param(6, Inject(PluginsService)),
1500
1614
  __metadata("design:paramtypes", [ConfigService,
1501
1615
  ConfigEditorService,
1502
1616
  AccessoriesService,
1503
1617
  HomebridgeIpcService,
1504
1618
  JsonFileStoreService,
1505
- Logger])
1619
+ Logger,
1620
+ PluginsService])
1506
1621
  ], ServerService);
1507
1622
  export { ServerService };