homebridge-config-ui-x 5.9.1-beta.1 → 5.9.1-beta.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.
- package/CHANGELOG.md +7 -3
- package/dist/app.controller.d.ts +1 -1
- package/dist/app.controller.js +14 -12
- package/dist/app.controller.js.map +1 -1
- package/dist/app.gateway.js +7 -10
- package/dist/app.gateway.js.map +1 -1
- package/dist/app.module.js +40 -43
- package/dist/app.module.js.map +1 -1
- package/dist/app.service.js +4 -7
- package/dist/app.service.js.map +1 -1
- package/dist/bin/base-platform.d.ts +1 -1
- package/dist/bin/base-platform.js +11 -17
- package/dist/bin/base-platform.js.map +1 -1
- package/dist/bin/fork.js +7 -45
- package/dist/bin/fork.js.map +1 -1
- package/dist/bin/hb-service.js +224 -243
- package/dist/bin/hb-service.js.map +1 -1
- package/dist/bin/platforms/darwin.d.ts +1 -1
- package/dist/bin/platforms/darwin.js +61 -65
- package/dist/bin/platforms/darwin.js.map +1 -1
- package/dist/bin/platforms/freebsd.d.ts +1 -1
- package/dist/bin/platforms/freebsd.js +42 -47
- package/dist/bin/platforms/freebsd.js.map +1 -1
- package/dist/bin/platforms/linux.d.ts +1 -1
- package/dist/bin/platforms/linux.js +127 -132
- package/dist/bin/platforms/linux.js.map +1 -1
- package/dist/bin/platforms/win32.d.ts +1 -1
- package/dist/bin/platforms/win32.js +30 -36
- package/dist/bin/platforms/win32.js.map +1 -1
- package/dist/bin/standalone.js +15 -53
- package/dist/bin/standalone.js.map +1 -1
- package/dist/core/auth/auth.controller.d.ts +3 -3
- package/dist/core/auth/auth.controller.js +40 -39
- package/dist/core/auth/auth.controller.js.map +1 -1
- package/dist/core/auth/auth.dto.js +17 -18
- package/dist/core/auth/auth.dto.js.map +1 -1
- package/dist/core/auth/auth.module.js +28 -31
- package/dist/core/auth/auth.module.js.map +1 -1
- package/dist/core/auth/auth.service.d.ts +3 -3
- package/dist/core/auth/auth.service.js +65 -62
- package/dist/core/auth/auth.service.js.map +1 -1
- package/dist/core/auth/guards/admin.guard.js +4 -7
- package/dist/core/auth/guards/admin.guard.js.map +1 -1
- package/dist/core/auth/guards/custom.guard.js +6 -9
- package/dist/core/auth/guards/custom.guard.js.map +1 -1
- package/dist/core/auth/guards/ws-admin-guard.d.ts +1 -1
- package/dist/core/auth/guards/ws-admin-guard.js +13 -11
- package/dist/core/auth/guards/ws-admin-guard.js.map +1 -1
- package/dist/core/auth/guards/ws.guard.d.ts +1 -1
- package/dist/core/auth/guards/ws.guard.js +13 -11
- package/dist/core/auth/guards/ws.guard.js.map +1 -1
- package/dist/core/auth/jwt.strategy.d.ts +3 -2
- package/dist/core/auth/jwt.strategy.js +21 -16
- package/dist/core/auth/jwt.strategy.js.map +1 -1
- package/dist/core/config/config.interfaces.js +1 -2
- package/dist/core/config/config.module.js +8 -10
- package/dist/core/config/config.module.js.map +1 -1
- package/dist/core/config/config.service.d.ts +2 -2
- package/dist/core/config/config.service.js +88 -82
- package/dist/core/config/config.service.js.map +1 -1
- package/dist/core/config/config.startup.d.ts +1 -1
- package/dist/core/config/config.startup.js +23 -28
- package/dist/core/config/config.startup.js.map +1 -1
- package/dist/core/feature-flags/feature-flags.registry.js +1 -4
- package/dist/core/feature-flags/feature-flags.registry.js.map +1 -1
- package/dist/core/homebridge-ipc/homebridge-ipc.module.js +11 -14
- package/dist/core/homebridge-ipc/homebridge-ipc.module.js.map +1 -1
- package/dist/core/homebridge-ipc/homebridge-ipc.service.d.ts +2 -2
- package/dist/core/homebridge-ipc/homebridge-ipc.service.js +24 -19
- package/dist/core/homebridge-ipc/homebridge-ipc.service.js.map +1 -1
- package/dist/core/logger/logger.module.js +8 -10
- package/dist/core/logger/logger.module.js.map +1 -1
- package/dist/core/logger/logger.service.js +13 -23
- package/dist/core/logger/logger.service.js.map +1 -1
- package/dist/core/node-pty/node-pty.module.js +7 -10
- package/dist/core/node-pty/node-pty.module.js.map +1 -1
- package/dist/core/node-pty/node-pty.service.js +6 -11
- package/dist/core/node-pty/node-pty.service.js.map +1 -1
- package/dist/core/node-version.constants.js +4 -11
- package/dist/core/node-version.constants.js.map +1 -1
- package/dist/core/scheduler/scheduler.module.js +7 -10
- package/dist/core/scheduler/scheduler.module.js.map +1 -1
- package/dist/core/scheduler/scheduler.service.js +9 -14
- package/dist/core/scheduler/scheduler.service.js.map +1 -1
- package/dist/core/spa/spa-html.service.js +9 -15
- package/dist/core/spa/spa-html.service.js.map +1 -1
- package/dist/core/spa/spa.filter.d.ts +1 -1
- package/dist/core/spa/spa.filter.js +11 -16
- package/dist/core/spa/spa.filter.js.map +1 -1
- package/dist/core/ssl/ssl-cert-generator.service.js +34 -36
- package/dist/core/ssl/ssl-cert-generator.service.js.map +1 -1
- package/dist/env-setup.d.ts +1 -0
- package/dist/env-setup.js +7 -0
- package/dist/env-setup.js.map +1 -0
- package/dist/globalDefaults.d.ts +1 -0
- package/dist/globalDefaults.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -19
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +5 -3
- package/dist/main.js +44 -51
- package/dist/main.js.map +1 -1
- package/dist/modules/accessories/accessories.controller.d.ts +2 -2
- package/dist/modules/accessories/accessories.controller.js +27 -29
- package/dist/modules/accessories/accessories.controller.js.map +1 -1
- package/dist/modules/accessories/accessories.dto.js +11 -13
- package/dist/modules/accessories/accessories.dto.js.map +1 -1
- package/dist/modules/accessories/accessories.gateway.d.ts +1 -1
- package/dist/modules/accessories/accessories.gateway.js +18 -16
- package/dist/modules/accessories/accessories.gateway.js.map +1 -1
- package/dist/modules/accessories/accessories.module.js +17 -20
- package/dist/modules/accessories/accessories.module.js.map +1 -1
- package/dist/modules/accessories/accessories.service.d.ts +2 -2
- package/dist/modules/accessories/accessories.service.js +37 -35
- package/dist/modules/accessories/accessories.service.js.map +1 -1
- package/dist/modules/backup/backup.controller.d.ts +2 -2
- package/dist/modules/backup/backup.controller.js +68 -67
- package/dist/modules/backup/backup.controller.js.map +1 -1
- package/dist/modules/backup/backup.gateway.d.ts +2 -2
- package/dist/modules/backup/backup.gateway.js +25 -21
- package/dist/modules/backup/backup.gateway.js.map +1 -1
- package/dist/modules/backup/backup.module.js +22 -25
- package/dist/modules/backup/backup.module.js.map +1 -1
- package/dist/modules/backup/backup.service.d.ts +5 -5
- package/dist/modules/backup/backup.service.js +143 -133
- package/dist/modules/backup/backup.service.js.map +1 -1
- package/dist/modules/child-bridges/child-bridges.gateway.d.ts +2 -2
- package/dist/modules/child-bridges/child-bridges.gateway.js +23 -21
- package/dist/modules/child-bridges/child-bridges.gateway.js.map +1 -1
- package/dist/modules/child-bridges/child-bridges.interfaces.js +1 -2
- package/dist/modules/child-bridges/child-bridges.module.js +19 -22
- package/dist/modules/child-bridges/child-bridges.module.js.map +1 -1
- package/dist/modules/child-bridges/child-bridges.service.d.ts +3 -3
- package/dist/modules/child-bridges/child-bridges.service.js +15 -11
- package/dist/modules/child-bridges/child-bridges.service.js.map +1 -1
- package/dist/modules/config-editor/config-editor.controller.d.ts +6 -6
- package/dist/modules/config-editor/config-editor.controller.js +94 -95
- package/dist/modules/config-editor/config-editor.controller.js.map +1 -1
- package/dist/modules/config-editor/config-editor.module.js +21 -24
- package/dist/modules/config-editor/config-editor.module.js.map +1 -1
- package/dist/modules/config-editor/config-editor.service.d.ts +6 -6
- package/dist/modules/config-editor/config-editor.service.js +65 -57
- package/dist/modules/config-editor/config-editor.service.js.map +1 -1
- package/dist/modules/custom-plugins/custom-plugins.module.js +10 -13
- package/dist/modules/custom-plugins/custom-plugins.module.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.js +21 -19
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.controller.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.js +14 -17
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.module.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.js +18 -15
- package/dist/modules/custom-plugins/homebridge-deconz/homebridge-deconz.service.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.js +21 -19
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.controller.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.module.js +14 -17
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.module.js.map +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.service.d.ts +1 -1
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.service.js +18 -15
- package/dist/modules/custom-plugins/homebridge-hue/homebridge-hue.service.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.d.ts +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.js +18 -19
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.controller.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.d.ts +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.js +15 -13
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.gateway.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.js +18 -21
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.module.js.map +1 -1
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.d.ts +4 -4
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.js +47 -41
- package/dist/modules/custom-plugins/plugins-settings-ui/plugins-settings-ui.service.js.map +1 -1
- package/dist/modules/log/log.gateway.d.ts +2 -2
- package/dist/modules/log/log.gateway.js +15 -13
- package/dist/modules/log/log.gateway.js.map +1 -1
- package/dist/modules/log/log.interfaces.js +1 -2
- package/dist/modules/log/log.module.js +14 -17
- package/dist/modules/log/log.module.js.map +1 -1
- package/dist/modules/log/log.service.d.ts +3 -3
- package/dist/modules/log/log.service.js +47 -43
- package/dist/modules/log/log.service.js.map +1 -1
- package/dist/modules/platform-tools/docker/docker.controller.d.ts +1 -1
- package/dist/modules/platform-tools/docker/docker.controller.js +24 -25
- package/dist/modules/platform-tools/docker/docker.controller.js.map +1 -1
- package/dist/modules/platform-tools/docker/docker.module.js +14 -17
- package/dist/modules/platform-tools/docker/docker.module.js.map +1 -1
- package/dist/modules/platform-tools/docker/docker.service.d.ts +2 -2
- package/dist/modules/platform-tools/docker/docker.service.js +20 -16
- package/dist/modules/platform-tools/docker/docker.service.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.controller.d.ts +2 -2
- package/dist/modules/platform-tools/hb-service/hb-service.controller.js +35 -36
- package/dist/modules/platform-tools/hb-service/hb-service.controller.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.dto.js +20 -19
- package/dist/modules/platform-tools/hb-service/hb-service.dto.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.module.js +14 -17
- package/dist/modules/platform-tools/hb-service/hb-service.module.js.map +1 -1
- package/dist/modules/platform-tools/hb-service/hb-service.service.d.ts +3 -3
- package/dist/modules/platform-tools/hb-service/hb-service.service.js +37 -30
- package/dist/modules/platform-tools/hb-service/hb-service.service.js.map +1 -1
- package/dist/modules/platform-tools/linux/linux.controller.d.ts +1 -1
- package/dist/modules/platform-tools/linux/linux.controller.js +23 -21
- package/dist/modules/platform-tools/linux/linux.controller.js.map +1 -1
- package/dist/modules/platform-tools/linux/linux.module.js +14 -17
- package/dist/modules/platform-tools/linux/linux.module.js.map +1 -1
- package/dist/modules/platform-tools/linux/linux.service.d.ts +2 -2
- package/dist/modules/platform-tools/linux/linux.service.js +18 -14
- package/dist/modules/platform-tools/linux/linux.service.js.map +1 -1
- package/dist/modules/platform-tools/platform-tools.module.js +12 -15
- package/dist/modules/platform-tools/platform-tools.module.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.controller.d.ts +1 -1
- package/dist/modules/platform-tools/terminal/terminal.controller.js +15 -13
- package/dist/modules/platform-tools/terminal/terminal.controller.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.gateway.d.ts +2 -2
- package/dist/modules/platform-tools/terminal/terminal.gateway.js +17 -15
- package/dist/modules/platform-tools/terminal/terminal.gateway.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.interfaces.js +1 -2
- package/dist/modules/platform-tools/terminal/terminal.module.js +18 -21
- package/dist/modules/platform-tools/terminal/terminal.module.js.map +1 -1
- package/dist/modules/platform-tools/terminal/terminal.service.d.ts +4 -4
- package/dist/modules/platform-tools/terminal/terminal.service.js +33 -28
- package/dist/modules/platform-tools/terminal/terminal.service.js.map +1 -1
- package/dist/modules/plugins/plugins.controller.d.ts +6 -6
- package/dist/modules/plugins/plugins.controller.js +51 -52
- package/dist/modules/plugins/plugins.controller.js.map +1 -1
- package/dist/modules/plugins/plugins.dto.js +26 -24
- package/dist/modules/plugins/plugins.dto.js.map +1 -1
- package/dist/modules/plugins/plugins.gateway.d.ts +3 -3
- package/dist/modules/plugins/plugins.gateway.js +38 -34
- package/dist/modules/plugins/plugins.gateway.js.map +1 -1
- package/dist/modules/plugins/plugins.interfaces.js +1 -2
- package/dist/modules/plugins/plugins.module.js +23 -26
- package/dist/modules/plugins/plugins.module.js.map +1 -1
- package/dist/modules/plugins/plugins.service.d.ts +9 -7
- package/dist/modules/plugins/plugins.service.js +230 -202
- package/dist/modules/plugins/plugins.service.js.map +1 -1
- package/dist/modules/server/server.controller.d.ts +4 -4
- package/dist/modules/server/server.controller.js +208 -205
- package/dist/modules/server/server.controller.js.map +1 -1
- package/dist/modules/server/server.dto.js +13 -16
- package/dist/modules/server/server.dto.js.map +1 -1
- package/dist/modules/server/server.module.js +23 -26
- package/dist/modules/server/server.module.js.map +1 -1
- package/dist/modules/server/server.service.d.ts +6 -6
- package/dist/modules/server/server.service.js +202 -224
- package/dist/modules/server/server.service.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.controller.d.ts +2 -2
- package/dist/modules/setup-wizard/setup-wizard.controller.js +19 -20
- package/dist/modules/setup-wizard/setup-wizard.controller.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.gateway.d.ts +2 -2
- package/dist/modules/setup-wizard/setup-wizard.gateway.js +25 -21
- package/dist/modules/setup-wizard/setup-wizard.gateway.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.guard.d.ts +1 -1
- package/dist/modules/setup-wizard/setup-wizard.guard.js +11 -9
- package/dist/modules/setup-wizard/setup-wizard.guard.js.map +1 -1
- package/dist/modules/setup-wizard/setup-wizard.module.js +12 -15
- package/dist/modules/setup-wizard/setup-wizard.module.js.map +1 -1
- package/dist/modules/status/status.controller.d.ts +5 -5
- package/dist/modules/status/status.controller.js +40 -36
- package/dist/modules/status/status.controller.js.map +1 -1
- package/dist/modules/status/status.gateway.d.ts +9 -9
- package/dist/modules/status/status.gateway.js +51 -47
- package/dist/modules/status/status.gateway.js.map +1 -1
- package/dist/modules/status/status.interfaces.js +2 -5
- package/dist/modules/status/status.interfaces.js.map +1 -1
- package/dist/modules/status/status.module.js +26 -29
- package/dist/modules/status/status.module.js.map +1 -1
- package/dist/modules/status/status.service.d.ts +7 -7
- package/dist/modules/status/status.service.js +100 -88
- package/dist/modules/status/status.service.js.map +1 -1
- package/dist/modules/users/users.controller.d.ts +2 -2
- package/dist/modules/users/users.controller.js +59 -60
- package/dist/modules/users/users.controller.js.map +1 -1
- package/dist/modules/users/users.dto.js +51 -45
- package/dist/modules/users/users.dto.js.map +1 -1
- package/dist/modules/users/users.module.js +14 -17
- package/dist/modules/users/users.module.js.map +1 -1
- package/dist/self-check.js +25 -25
- package/dist/self-check.js.map +1 -1
- package/package.json +6 -7
- package/public/{chunk-732XLY23.js → chunk-2SCTALGY.js} +1 -1
- package/public/{chunk-TGZNYEGN.js → chunk-425ZEUU6.js} +1 -1
- package/public/{chunk-BTBGWLKK.js → chunk-4T6CM7M3.js} +1 -1
- package/public/{chunk-325LPX6W.js → chunk-7SKTJO5M.js} +1 -1
- package/public/{chunk-QK4V5DVW.js → chunk-ATMY4YI2.js} +1 -1
- package/public/{chunk-YH6MRXGX.js → chunk-AZIRJR4B.js} +1 -1
- package/public/{chunk-2CNQY2E7.js → chunk-B2XE365J.js} +1 -1
- package/public/{chunk-O4SS7KVP.js → chunk-BMKJTHFC.js} +1 -1
- package/public/{chunk-2KEG7SYT.js → chunk-CGYD722J.js} +1 -1
- package/public/{chunk-FM6ZYPKR.js → chunk-CQREAKPC.js} +4 -4
- package/public/{chunk-WLGXJQPD.js → chunk-FGNMMSZH.js} +1 -1
- package/public/{chunk-TOYVIOBH.js → chunk-FTKWC2Q2.js} +1 -1
- package/public/{chunk-2LXNPXT5.js → chunk-HFW5E2OW.js} +1 -1
- package/public/chunk-IIDLQ7XY.js +1 -0
- package/public/{chunk-UNGEHXRN.js → chunk-INX52LH2.js} +1 -1
- package/public/{chunk-73TX7DHV.js → chunk-JD5JQTN5.js} +1 -1
- package/public/{chunk-EVND2DL5.js → chunk-JFRCT5V7.js} +1 -1
- package/public/{chunk-X5AKILHJ.js → chunk-JPCV77W6.js} +1 -1
- package/public/{chunk-3XDYZNNE.js → chunk-K7D2P3SM.js} +1 -1
- package/public/chunk-L66ATRVT.js +1 -0
- package/public/{chunk-2UOYBCTN.js → chunk-LARQLRNL.js} +1 -1
- package/public/{chunk-L5I3DZ23.js → chunk-LHCMU3MO.js} +1 -1
- package/public/{chunk-ZJJ3EOBP.js → chunk-LZQVKA4S.js} +1 -1
- package/public/{chunk-BLT2YCDN.js → chunk-M7QUT5ZZ.js} +1 -1
- package/public/{chunk-57DUDNZJ.js → chunk-MDBZMB6Y.js} +1 -1
- package/public/{chunk-LZOHFRHN.js → chunk-MNVUSYOZ.js} +1 -1
- package/public/{chunk-7IYTG6GP.js → chunk-PXSEH255.js} +1 -1
- package/public/{chunk-6KT3BYU6.js → chunk-PZ2ZCCFR.js} +1 -1
- package/public/{chunk-L43N56JA.js → chunk-QCZ4VVDL.js} +1 -1
- package/public/{chunk-UF2IM5BE.js → chunk-QSVZNI3M.js} +1 -1
- package/public/{chunk-3E2NZ5JW.js → chunk-QUA46GZJ.js} +1 -1
- package/public/{chunk-Q2IS3QQY.js → chunk-QVLCTKQH.js} +1 -1
- package/public/{chunk-Y5FP6C55.js → chunk-RQ4B2IIV.js} +1 -1
- package/public/{chunk-OK5EJ7US.js → chunk-RQAFAZAK.js} +1 -1
- package/public/{chunk-LH2LMHIZ.js → chunk-S4OE2ITZ.js} +1 -1
- package/public/{chunk-RMZRXORR.js → chunk-SA5C7QVC.js} +1 -1
- package/public/{chunk-ADW6BF5G.js → chunk-SSZBNSOM.js} +1 -1
- package/public/{chunk-4QXLJX7D.js → chunk-TA6DOQC5.js} +1 -1
- package/public/{chunk-OAHDGV32.js → chunk-TC77PFBQ.js} +1 -1
- package/public/{chunk-W3SNJ7TC.js → chunk-TKGKVKOW.js} +1 -1
- package/public/{chunk-U5JF2ZOK.js → chunk-UEDMHOPK.js} +1 -1
- package/public/{chunk-AI6E5JVH.js → chunk-UOPWP4RR.js} +1 -1
- package/public/chunk-UTFHCUKB.js +1 -0
- package/public/{chunk-ONTEIYY3.js → chunk-UTN2R7WG.js} +1 -1
- package/public/{chunk-QQ5VZZQG.js → chunk-UV24H47X.js} +1 -1
- package/public/{chunk-5ETJWAIW.js → chunk-VSBBKD6B.js} +1 -1
- package/public/{chunk-ASKB5DLO.js → chunk-W7UNXMCL.js} +1 -1
- package/public/{chunk-SY4VNLXW.js → chunk-WVCOONJF.js} +1 -1
- package/public/{chunk-YYJG2ENF.js → chunk-X3IVSHIL.js} +1 -1
- package/public/{chunk-3IZSIVEA.js → chunk-XE5VJDQL.js} +1 -1
- package/public/chunk-XMNXI4QP.js +50 -0
- package/public/{chunk-5T4JHJYL.js → chunk-XX5GWADI.js} +1 -1
- package/public/{chunk-LWAL5JUG.js → chunk-Y5XBENWZ.js} +1 -1
- package/public/index.html +2 -2
- package/public/{main-27RPBS22.js → main-UGYHSCMY.js} +1 -1
- package/public/{styles-CSF457UW.css → styles-WNHDEKE4.css} +1 -1
- package/scripts/extract-plugin-alias.js +8 -4
- package/public/chunk-P7TZIGJS.js +0 -50
- package/public/chunk-RYTGW6B7.js +0 -1
- package/public/chunk-SOT54YHI.js +0 -1
- package/public/chunk-VEGMNMLG.js +0 -1
|
@@ -1,113 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
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;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
9
|
};
|
|
44
|
-
var
|
|
45
|
-
return (
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
12
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const pump =
|
|
13
|
+
import { Buffer } from 'node:buffer';
|
|
14
|
+
import { exec, spawn } from 'node:child_process';
|
|
15
|
+
import { createPrivateKey, createPublicKey, X509Certificate } from 'node:crypto';
|
|
16
|
+
import { createWriteStream } from 'node:fs';
|
|
17
|
+
import { readdir, unlink } from 'node:fs/promises';
|
|
18
|
+
import { extname, join, resolve } from 'node:path';
|
|
19
|
+
import process from 'node:process';
|
|
20
|
+
import { pipeline } from 'node:stream';
|
|
21
|
+
import { createSecureContext } from 'node:tls';
|
|
22
|
+
import { promisify } from 'node:util';
|
|
23
|
+
import { Categories } from '@homebridge/hap-client/dist/hap-types.js';
|
|
24
|
+
import { BadRequestException, Inject, Injectable, InternalServerErrorException, NotFoundException, ServiceUnavailableException, } from '@nestjs/common';
|
|
25
|
+
import { pathExists, readJson, remove, writeJson } from 'fs-extra/esm';
|
|
26
|
+
import NodeCache from 'node-cache';
|
|
27
|
+
import { networkInterfaces } from 'systeminformation';
|
|
28
|
+
import { check as tcpCheck } from 'tcp-port-used';
|
|
29
|
+
import { ConfigService } from '../../core/config/config.service.js';
|
|
30
|
+
import { HomebridgeIpcService } from '../../core/homebridge-ipc/homebridge-ipc.service.js';
|
|
31
|
+
import { Logger } from '../../core/logger/logger.service.js';
|
|
32
|
+
import { SslCertGeneratorService } from '../../core/ssl/ssl-cert-generator.service.js';
|
|
33
|
+
import { AccessoriesService } from '../accessories/accessories.service.js';
|
|
34
|
+
import { ConfigEditorService } from '../config-editor/config-editor.service.js';
|
|
35
|
+
const pump = promisify(pipeline);
|
|
70
36
|
let ServerService = class ServerService {
|
|
37
|
+
configService;
|
|
38
|
+
configEditorService;
|
|
39
|
+
accessoriesService;
|
|
40
|
+
homebridgeIpcService;
|
|
41
|
+
logger;
|
|
42
|
+
serverServiceCache = new NodeCache({ stdTTL: 300 });
|
|
43
|
+
accessoryId;
|
|
44
|
+
accessoryInfoPath;
|
|
45
|
+
setupCode = null;
|
|
46
|
+
paired = false;
|
|
71
47
|
constructor(configService, configEditorService, accessoriesService, homebridgeIpcService, logger) {
|
|
72
48
|
this.configService = configService;
|
|
73
49
|
this.configEditorService = configEditorService;
|
|
74
50
|
this.accessoriesService = accessoriesService;
|
|
75
51
|
this.homebridgeIpcService = homebridgeIpcService;
|
|
76
52
|
this.logger = logger;
|
|
77
|
-
this.serverServiceCache = new node_cache_1.default({ stdTTL: 300 });
|
|
78
|
-
this.setupCode = null;
|
|
79
|
-
this.paired = false;
|
|
80
53
|
this.accessoryId = this.configService.homebridgeConfig.bridge.username.split(':').join('');
|
|
81
|
-
this.accessoryInfoPath =
|
|
54
|
+
this.accessoryInfoPath = join(this.configService.storagePath, 'persist', `AccessoryInfo.${this.accessoryId}.json`);
|
|
82
55
|
}
|
|
83
56
|
async deleteSingleDeviceAccessories(id, cachedAccessoriesDir, protocol = 'both') {
|
|
84
57
|
if (protocol === 'hap' || protocol === 'both') {
|
|
85
|
-
const cachedAccessories =
|
|
86
|
-
const cachedAccessoriesBackup =
|
|
87
|
-
if (await
|
|
88
|
-
await
|
|
58
|
+
const cachedAccessories = join(cachedAccessoriesDir, `cachedAccessories.${id}`);
|
|
59
|
+
const cachedAccessoriesBackup = join(cachedAccessoriesDir, `.cachedAccessories.${id}.bak`);
|
|
60
|
+
if (await pathExists(cachedAccessories)) {
|
|
61
|
+
await unlink(cachedAccessories);
|
|
89
62
|
this.logger.warn(`Bridge ${id} HAP accessory removal: removed ${cachedAccessories}.`);
|
|
90
63
|
}
|
|
91
|
-
if (await
|
|
92
|
-
await
|
|
64
|
+
if (await pathExists(cachedAccessoriesBackup)) {
|
|
65
|
+
await unlink(cachedAccessoriesBackup);
|
|
93
66
|
this.logger.warn(`Bridge ${id} HAP accessory removal: removed ${cachedAccessoriesBackup}.`);
|
|
94
67
|
}
|
|
95
68
|
}
|
|
96
69
|
if (protocol === 'matter' || protocol === 'both') {
|
|
97
70
|
const deviceId = id.split(':').join('').toUpperCase();
|
|
98
|
-
const matterPath =
|
|
99
|
-
if (await
|
|
100
|
-
await
|
|
71
|
+
const matterPath = join(this.configService.storagePath, 'matter', deviceId);
|
|
72
|
+
if (await pathExists(matterPath)) {
|
|
73
|
+
await remove(matterPath);
|
|
101
74
|
this.logger.warn(`Bridge ${id} Matter accessory removal: removed Matter bridge storage at ${matterPath}.`);
|
|
102
75
|
}
|
|
103
76
|
}
|
|
104
77
|
}
|
|
105
78
|
async deleteSingleDevicePairing(id, resetPairingInfo) {
|
|
106
|
-
const persistPath =
|
|
107
|
-
const accessoryInfo =
|
|
108
|
-
const identifierCache =
|
|
79
|
+
const persistPath = join(this.configService.storagePath, 'persist');
|
|
80
|
+
const accessoryInfo = join(persistPath, `AccessoryInfo.${id}.json`);
|
|
81
|
+
const identifierCache = join(persistPath, `IdentifierCache.${id}.json`);
|
|
109
82
|
const deviceId = id.includes(':') ? id.split(':').join('').toUpperCase() : id.toUpperCase();
|
|
110
|
-
const matterPath =
|
|
83
|
+
const matterPath = join(this.configService.storagePath, 'matter', deviceId);
|
|
111
84
|
try {
|
|
112
85
|
const configFile = await this.configEditorService.getConfigFile();
|
|
113
86
|
const username = id.includes(':') ? id.toUpperCase() : id.match(/.{1,2}/g)?.join(':').toUpperCase() || id.toUpperCase();
|
|
@@ -152,16 +125,16 @@ let ServerService = class ServerService {
|
|
|
152
125
|
catch (e) {
|
|
153
126
|
this.logger.error(`Failed to reset username and pin for child bridge ${id} as ${e.message}.`);
|
|
154
127
|
}
|
|
155
|
-
if (await
|
|
156
|
-
await
|
|
128
|
+
if (await pathExists(accessoryInfo)) {
|
|
129
|
+
await unlink(accessoryInfo);
|
|
157
130
|
this.logger.warn(`Bridge ${id} reset: removed ${accessoryInfo}.`);
|
|
158
131
|
}
|
|
159
|
-
if (await
|
|
160
|
-
await
|
|
132
|
+
if (await pathExists(identifierCache)) {
|
|
133
|
+
await unlink(identifierCache);
|
|
161
134
|
this.logger.warn(`Bridge ${id} reset: removed ${identifierCache}.`);
|
|
162
135
|
}
|
|
163
|
-
if (await
|
|
164
|
-
await
|
|
136
|
+
if (await pathExists(matterPath)) {
|
|
137
|
+
await remove(matterPath);
|
|
165
138
|
this.logger.warn(`Bridge ${id} reset: removed Matter bridge storage at ${matterPath}.`);
|
|
166
139
|
}
|
|
167
140
|
await this.deleteDeviceAccessories(id);
|
|
@@ -177,7 +150,7 @@ let ServerService = class ServerService {
|
|
|
177
150
|
setTimeout(() => {
|
|
178
151
|
if (this.configService.ui.restart) {
|
|
179
152
|
this.logger.log(`Executing restart command ${this.configService.ui.restart}.`);
|
|
180
|
-
|
|
153
|
+
exec(this.configService.ui.restart, (err) => {
|
|
181
154
|
if (err) {
|
|
182
155
|
this.logger.log('Restart command exited with an error, failed to restart Homebridge.');
|
|
183
156
|
}
|
|
@@ -185,7 +158,7 @@ let ServerService = class ServerService {
|
|
|
185
158
|
}
|
|
186
159
|
else {
|
|
187
160
|
this.logger.log('Sending SIGTERM to process...');
|
|
188
|
-
|
|
161
|
+
process.kill(process.pid, 'SIGTERM');
|
|
189
162
|
}
|
|
190
163
|
}, 500);
|
|
191
164
|
return { ok: true, command: this.configService.ui.restart, restartingUI: true };
|
|
@@ -205,33 +178,33 @@ let ServerService = class ServerService {
|
|
|
205
178
|
}
|
|
206
179
|
this.logger.warn(`Homebridge bridge reset: new username ${configFile.bridge.username} and new pin ${configFile.bridge.pin}.`);
|
|
207
180
|
await this.configEditorService.updateConfigFile(configFile);
|
|
208
|
-
await
|
|
209
|
-
await
|
|
181
|
+
await remove(resolve(this.configService.storagePath, 'accessories'));
|
|
182
|
+
await remove(resolve(this.configService.storagePath, 'persist'));
|
|
210
183
|
const deviceId = oldUsername.split(':').join('').toUpperCase();
|
|
211
|
-
const matterPath =
|
|
212
|
-
if (await
|
|
213
|
-
await
|
|
184
|
+
const matterPath = join(this.configService.storagePath, 'matter', deviceId);
|
|
185
|
+
if (await pathExists(matterPath)) {
|
|
186
|
+
await remove(matterPath);
|
|
214
187
|
this.logger.warn(`Bridge ${oldUsername} reset: removed Matter bridge storage at ${matterPath}.`);
|
|
215
188
|
}
|
|
216
189
|
this.logger.log('Homebridge bridge reset: accessories and persist directories were removed.');
|
|
217
190
|
}
|
|
218
191
|
async getDevicePairings() {
|
|
219
|
-
const persistPath =
|
|
220
|
-
const devices = (await
|
|
192
|
+
const persistPath = join(this.configService.storagePath, 'persist');
|
|
193
|
+
const devices = (await readdir(persistPath))
|
|
221
194
|
.filter(x => x.match(/AccessoryInfo\.([A-Fa-f0-9]+)\.json$/));
|
|
222
195
|
const configFile = await this.configEditorService.getConfigFile();
|
|
223
196
|
const hapDevices = await Promise.all(devices.map(async (x) => {
|
|
224
197
|
return await this.getDevicePairingById(x.split('.')[1], configFile);
|
|
225
198
|
}));
|
|
226
|
-
const matterExternalDevices = await this.getMatterExternalAccessories(
|
|
199
|
+
const matterExternalDevices = await this.getMatterExternalAccessories(hapDevices);
|
|
227
200
|
return [...hapDevices, ...matterExternalDevices].sort((a, b) => a.name.localeCompare(b.name));
|
|
228
201
|
}
|
|
229
|
-
async getMatterExternalAccessories(
|
|
230
|
-
const matterPath =
|
|
231
|
-
if (!await
|
|
202
|
+
async getMatterExternalAccessories(hapDevices) {
|
|
203
|
+
const matterPath = join(this.configService.storagePath, 'matter');
|
|
204
|
+
if (!await pathExists(matterPath)) {
|
|
232
205
|
return [];
|
|
233
206
|
}
|
|
234
|
-
const matterDirs = (await
|
|
207
|
+
const matterDirs = (await readdir(matterPath))
|
|
235
208
|
.filter(x => x.match(/^[A-F0-9]{12}$/));
|
|
236
209
|
const matterExternalDevices = [];
|
|
237
210
|
for (const deviceId of matterDirs) {
|
|
@@ -244,19 +217,19 @@ let ServerService = class ServerService {
|
|
|
244
217
|
if (deviceId.toUpperCase() === mainBridgeId) {
|
|
245
218
|
continue;
|
|
246
219
|
}
|
|
247
|
-
const accessoriesPath =
|
|
248
|
-
if (!await
|
|
220
|
+
const accessoriesPath = join(matterPath, deviceId, 'accessories.json');
|
|
221
|
+
if (!await pathExists(accessoriesPath)) {
|
|
249
222
|
continue;
|
|
250
223
|
}
|
|
251
|
-
const accessories = await
|
|
224
|
+
const accessories = await readJson(accessoriesPath);
|
|
252
225
|
if (!Array.isArray(accessories) || accessories.length === 0) {
|
|
253
226
|
continue;
|
|
254
227
|
}
|
|
255
228
|
const accessory = accessories[0];
|
|
256
|
-
const commissioningPath =
|
|
229
|
+
const commissioningPath = join(matterPath, deviceId, 'commissioning.json');
|
|
257
230
|
let commissioned = false;
|
|
258
|
-
if (await
|
|
259
|
-
const commissioningInfo = await
|
|
231
|
+
if (await pathExists(commissioningPath)) {
|
|
232
|
+
const commissioningInfo = await readJson(commissioningPath);
|
|
260
233
|
commissioned = commissioningInfo.commissioned || false;
|
|
261
234
|
}
|
|
262
235
|
const device = {
|
|
@@ -284,13 +257,13 @@ let ServerService = class ServerService {
|
|
|
284
257
|
return matterExternalDevices;
|
|
285
258
|
}
|
|
286
259
|
async getDevicePairingById(deviceId, configFile = null) {
|
|
287
|
-
const persistPath =
|
|
260
|
+
const persistPath = join(this.configService.storagePath, 'persist');
|
|
288
261
|
let device;
|
|
289
262
|
try {
|
|
290
|
-
device = await
|
|
263
|
+
device = await readJson(join(persistPath, `AccessoryInfo.${deviceId}.json`));
|
|
291
264
|
}
|
|
292
265
|
catch (e) {
|
|
293
|
-
throw new
|
|
266
|
+
throw new NotFoundException();
|
|
294
267
|
}
|
|
295
268
|
if (!configFile) {
|
|
296
269
|
configFile = await this.configEditorService.getConfigFile();
|
|
@@ -302,7 +275,7 @@ let ServerService = class ServerService {
|
|
|
302
275
|
.concat([{ _bridge: configFile.bridge }])
|
|
303
276
|
.find((block) => block._bridge?.username?.toUpperCase() === username.toUpperCase());
|
|
304
277
|
try {
|
|
305
|
-
device._category = Object.entries(
|
|
278
|
+
device._category = Object.entries(Categories).find(([, value]) => value === device.category)[0].toLowerCase();
|
|
306
279
|
}
|
|
307
280
|
catch (e) {
|
|
308
281
|
device._category = 'Other';
|
|
@@ -343,7 +316,7 @@ let ServerService = class ServerService {
|
|
|
343
316
|
const pluginBlock = pluginBlocks.find((block) => block._bridge?.matter);
|
|
344
317
|
if (!pluginBlock) {
|
|
345
318
|
this.logger.error(`Failed to find Matter configuration for child bridge ${id}.`);
|
|
346
|
-
throw new
|
|
319
|
+
throw new NotFoundException(`Matter configuration not found for bridge ${id}`);
|
|
347
320
|
}
|
|
348
321
|
if ('accessory' in pluginBlock) {
|
|
349
322
|
this.logger.warn(`Removing Matter configuration from accessory-based plugin block for bridge ${id}. Matter is only supported for platform-based plugins.`);
|
|
@@ -353,18 +326,18 @@ let ServerService = class ServerService {
|
|
|
353
326
|
await this.configEditorService.updateConfigFile(configFile);
|
|
354
327
|
}
|
|
355
328
|
catch (e) {
|
|
356
|
-
if (e instanceof
|
|
329
|
+
if (e instanceof NotFoundException) {
|
|
357
330
|
throw e;
|
|
358
331
|
}
|
|
359
332
|
this.logger.error(`Failed to remove Matter configuration for child bridge ${id} as ${e.message}.`);
|
|
360
|
-
throw new
|
|
333
|
+
throw new InternalServerErrorException(`Failed to remove Matter configuration: ${e.message}`);
|
|
361
334
|
}
|
|
362
335
|
this.logger.warn(`Shutting down Homebridge before removing Matter storage for bridge ${id}...`);
|
|
363
336
|
await this.homebridgeIpcService.restartAndWaitForClose();
|
|
364
337
|
const deviceId = id.includes(':') ? id.split(':').join('').toUpperCase() : id.toUpperCase();
|
|
365
|
-
const matterPath =
|
|
366
|
-
if (await
|
|
367
|
-
await
|
|
338
|
+
const matterPath = join(this.configService.storagePath, 'matter', deviceId);
|
|
339
|
+
if (await pathExists(matterPath)) {
|
|
340
|
+
await remove(matterPath);
|
|
368
341
|
this.logger.warn(`Bridge ${id} Matter storage removed at ${matterPath}.`);
|
|
369
342
|
}
|
|
370
343
|
return { ok: true };
|
|
@@ -385,13 +358,13 @@ let ServerService = class ServerService {
|
|
|
385
358
|
async deleteDeviceAccessories(id) {
|
|
386
359
|
this.logger.warn(`Shutting down Homebridge before removing accessories for paired bridge ${id}...`);
|
|
387
360
|
await this.homebridgeIpcService.restartAndWaitForClose();
|
|
388
|
-
const cachedAccessoriesDir =
|
|
361
|
+
const cachedAccessoriesDir = join(this.configService.storagePath, 'accessories');
|
|
389
362
|
await this.deleteSingleDeviceAccessories(id, cachedAccessoriesDir);
|
|
390
363
|
}
|
|
391
364
|
async deleteDevicesAccessories(bridges) {
|
|
392
365
|
this.logger.warn(`Shutting down Homebridge before removing accessories for paired bridges ${bridges.map(x => x.id).join(', ')}...`);
|
|
393
366
|
await this.homebridgeIpcService.restartAndWaitForClose();
|
|
394
|
-
const cachedAccessoriesDir =
|
|
367
|
+
const cachedAccessoriesDir = join(this.configService.storagePath, 'accessories');
|
|
395
368
|
for (const { id, protocol } of bridges) {
|
|
396
369
|
try {
|
|
397
370
|
await this.deleteSingleDeviceAccessories(id, cachedAccessoriesDir, protocol || 'both');
|
|
@@ -402,12 +375,12 @@ let ServerService = class ServerService {
|
|
|
402
375
|
}
|
|
403
376
|
}
|
|
404
377
|
async getCachedAccessories() {
|
|
405
|
-
const cachedAccessoriesDir =
|
|
406
|
-
const cachedAccessoryFiles = (await
|
|
378
|
+
const cachedAccessoriesDir = join(this.configService.storagePath, 'accessories');
|
|
379
|
+
const cachedAccessoryFiles = (await readdir(cachedAccessoriesDir))
|
|
407
380
|
.filter(x => x.match(/^cachedAccessories\.([A-F,0-9]+)$/) || x === 'cachedAccessories');
|
|
408
381
|
const cachedAccessories = [];
|
|
409
382
|
await Promise.all(cachedAccessoryFiles.map(async (x) => {
|
|
410
|
-
const accessories = await
|
|
383
|
+
const accessories = await readJson(join(cachedAccessoriesDir, x));
|
|
411
384
|
for (const accessory of accessories) {
|
|
412
385
|
accessory.$cacheFile = x;
|
|
413
386
|
cachedAccessories.push(accessory);
|
|
@@ -417,19 +390,19 @@ let ServerService = class ServerService {
|
|
|
417
390
|
}
|
|
418
391
|
async deleteCachedAccessory(uuid, cacheFile) {
|
|
419
392
|
cacheFile = cacheFile || 'cachedAccessories';
|
|
420
|
-
const cachedAccessoriesPath =
|
|
393
|
+
const cachedAccessoriesPath = resolve(this.configService.storagePath, 'accessories', cacheFile);
|
|
421
394
|
this.logger.warn(`Shutting down Homebridge before removing cached accessory ${uuid}...`);
|
|
422
395
|
await this.homebridgeIpcService.restartAndWaitForClose();
|
|
423
|
-
const cachedAccessories = await
|
|
396
|
+
const cachedAccessories = await readJson(cachedAccessoriesPath);
|
|
424
397
|
const accessoryIndex = cachedAccessories.findIndex(x => x.UUID === uuid);
|
|
425
398
|
if (accessoryIndex > -1) {
|
|
426
399
|
cachedAccessories.splice(accessoryIndex, 1);
|
|
427
|
-
await
|
|
400
|
+
await writeJson(cachedAccessoriesPath, cachedAccessories);
|
|
428
401
|
this.logger.warn(`Removed cached accessory with UUID ${uuid} from file ${cacheFile}.`);
|
|
429
402
|
}
|
|
430
403
|
else {
|
|
431
404
|
this.logger.error(`Cannot find cached accessory with UUID ${uuid} from file ${cacheFile}.`);
|
|
432
|
-
throw new
|
|
405
|
+
throw new NotFoundException();
|
|
433
406
|
}
|
|
434
407
|
return { ok: true };
|
|
435
408
|
}
|
|
@@ -445,8 +418,8 @@ let ServerService = class ServerService {
|
|
|
445
418
|
accessoriesByCacheFile.get(accessoryCacheFile).push({ uuid });
|
|
446
419
|
}
|
|
447
420
|
for (const [cacheFile, accessories] of accessoriesByCacheFile.entries()) {
|
|
448
|
-
const cachedAccessoriesPath =
|
|
449
|
-
const cachedAccessories = await
|
|
421
|
+
const cachedAccessoriesPath = resolve(this.configService.storagePath, 'accessories', cacheFile);
|
|
422
|
+
const cachedAccessories = await readJson(cachedAccessoriesPath);
|
|
450
423
|
for (const { uuid } of accessories) {
|
|
451
424
|
try {
|
|
452
425
|
const accessoryIndex = cachedAccessories.findIndex(x => x.UUID === uuid);
|
|
@@ -462,53 +435,53 @@ let ServerService = class ServerService {
|
|
|
462
435
|
this.logger.error(`Failed to remove cached accessory with UUID ${uuid} from file ${cacheFile} as ${e.message}.`);
|
|
463
436
|
}
|
|
464
437
|
}
|
|
465
|
-
await
|
|
438
|
+
await writeJson(cachedAccessoriesPath, cachedAccessories);
|
|
466
439
|
}
|
|
467
440
|
return { ok: true };
|
|
468
441
|
}
|
|
469
442
|
async deleteAllCachedAccessories() {
|
|
470
|
-
const cachedAccessoriesDir =
|
|
471
|
-
const cachedAccessoryPaths = (await
|
|
443
|
+
const cachedAccessoriesDir = join(this.configService.storagePath, 'accessories');
|
|
444
|
+
const cachedAccessoryPaths = (await readdir(cachedAccessoriesDir))
|
|
472
445
|
.filter(x => x.match(/cachedAccessories\.([A-F,0-9]+)/) || x === 'cachedAccessories' || x === '.cachedAccessories.bak')
|
|
473
|
-
.map(x =>
|
|
474
|
-
const cachedAccessoriesPath =
|
|
446
|
+
.map(x => resolve(cachedAccessoriesDir, x));
|
|
447
|
+
const cachedAccessoriesPath = resolve(this.configService.storagePath, 'accessories', 'cachedAccessories');
|
|
475
448
|
await this.homebridgeIpcService.restartAndWaitForClose();
|
|
476
449
|
this.logger.warn('Shutting down Homebridge before removing cached accessories');
|
|
477
450
|
try {
|
|
478
451
|
this.logger.log('Clearing all HAP cached accessories...');
|
|
479
452
|
for (const thisCachedAccessoriesPath of cachedAccessoryPaths) {
|
|
480
|
-
if (await
|
|
481
|
-
await
|
|
453
|
+
if (await pathExists(thisCachedAccessoriesPath)) {
|
|
454
|
+
await unlink(thisCachedAccessoriesPath);
|
|
482
455
|
this.logger.warn(`Removed ${thisCachedAccessoriesPath}.`);
|
|
483
456
|
}
|
|
484
457
|
}
|
|
485
|
-
const matterDir =
|
|
486
|
-
if (await
|
|
458
|
+
const matterDir = join(this.configService.storagePath, 'matter');
|
|
459
|
+
if (await pathExists(matterDir)) {
|
|
487
460
|
this.logger.log('Clearing all Matter cached accessories...');
|
|
488
|
-
await
|
|
461
|
+
await remove(matterDir);
|
|
489
462
|
this.logger.warn(`Removed Matter storage directory at ${matterDir}.`);
|
|
490
463
|
}
|
|
491
464
|
}
|
|
492
465
|
catch (e) {
|
|
493
466
|
this.logger.error(`Failed to clear all cached accessories at ${cachedAccessoriesPath} as ${e.message}.`);
|
|
494
467
|
console.error(e);
|
|
495
|
-
throw new
|
|
468
|
+
throw new InternalServerErrorException('Failed to clear Homebridge accessory cache - see logs.');
|
|
496
469
|
}
|
|
497
470
|
return { ok: true };
|
|
498
471
|
}
|
|
499
472
|
async getMatterAccessories() {
|
|
500
|
-
const matterDir =
|
|
501
|
-
if (!await
|
|
473
|
+
const matterDir = join(this.configService.storagePath, 'matter');
|
|
474
|
+
if (!await pathExists(matterDir)) {
|
|
502
475
|
return [];
|
|
503
476
|
}
|
|
504
|
-
const matterBridges = (await
|
|
477
|
+
const matterBridges = (await readdir(matterDir))
|
|
505
478
|
.filter(x => x.match(/^[A-F0-9]+$/));
|
|
506
479
|
const matterAccessories = [];
|
|
507
480
|
await Promise.all(matterBridges.map(async (deviceId) => {
|
|
508
481
|
try {
|
|
509
|
-
const accessoriesPath =
|
|
510
|
-
if (await
|
|
511
|
-
const accessories = await
|
|
482
|
+
const accessoriesPath = join(matterDir, deviceId, 'accessories.json');
|
|
483
|
+
if (await pathExists(accessoriesPath)) {
|
|
484
|
+
const accessories = await readJson(accessoriesPath);
|
|
512
485
|
if (Array.isArray(accessories)) {
|
|
513
486
|
for (const accessory of accessories) {
|
|
514
487
|
accessory.$deviceId = deviceId;
|
|
@@ -525,23 +498,23 @@ let ServerService = class ServerService {
|
|
|
525
498
|
return matterAccessories;
|
|
526
499
|
}
|
|
527
500
|
async deleteMatterAccessory(deviceId, uuid) {
|
|
528
|
-
const matterAccessoriesPath =
|
|
529
|
-
if (!await
|
|
501
|
+
const matterAccessoriesPath = join(this.configService.storagePath, 'matter', deviceId, 'accessories.json');
|
|
502
|
+
if (!await pathExists(matterAccessoriesPath)) {
|
|
530
503
|
this.logger.error(`Matter accessories file not found for bridge ${deviceId}`);
|
|
531
|
-
throw new
|
|
504
|
+
throw new NotFoundException();
|
|
532
505
|
}
|
|
533
506
|
this.logger.warn(`Shutting down Homebridge before removing Matter accessory ${uuid} from bridge ${deviceId}...`);
|
|
534
507
|
await this.homebridgeIpcService.restartAndWaitForClose();
|
|
535
|
-
const matterAccessories = await
|
|
508
|
+
const matterAccessories = await readJson(matterAccessoriesPath);
|
|
536
509
|
const accessoryIndex = matterAccessories.findIndex(x => x.uuid === uuid);
|
|
537
510
|
if (accessoryIndex > -1) {
|
|
538
511
|
matterAccessories.splice(accessoryIndex, 1);
|
|
539
|
-
await
|
|
512
|
+
await writeJson(matterAccessoriesPath, matterAccessories, { spaces: 2 });
|
|
540
513
|
this.logger.warn(`Removed Matter accessory with UUID ${uuid} from bridge ${deviceId}.`);
|
|
541
514
|
}
|
|
542
515
|
else {
|
|
543
516
|
this.logger.error(`Cannot find Matter accessory with UUID ${uuid} in bridge ${deviceId}.`);
|
|
544
|
-
throw new
|
|
517
|
+
throw new NotFoundException();
|
|
545
518
|
}
|
|
546
519
|
return { ok: true };
|
|
547
520
|
}
|
|
@@ -556,13 +529,13 @@ let ServerService = class ServerService {
|
|
|
556
529
|
accessoriesByBridge.get(deviceId).push({ uuid });
|
|
557
530
|
}
|
|
558
531
|
for (const [deviceId, bridgeAccessories] of accessoriesByBridge.entries()) {
|
|
559
|
-
const matterAccessoriesPath =
|
|
532
|
+
const matterAccessoriesPath = join(this.configService.storagePath, 'matter', deviceId, 'accessories.json');
|
|
560
533
|
try {
|
|
561
|
-
if (!await
|
|
534
|
+
if (!await pathExists(matterAccessoriesPath)) {
|
|
562
535
|
this.logger.error(`Matter accessories file not found for bridge ${deviceId}`);
|
|
563
536
|
continue;
|
|
564
537
|
}
|
|
565
|
-
const matterAccessories = await
|
|
538
|
+
const matterAccessories = await readJson(matterAccessoriesPath);
|
|
566
539
|
for (const { uuid } of bridgeAccessories) {
|
|
567
540
|
try {
|
|
568
541
|
const accessoryIndex = matterAccessories.findIndex(x => x.uuid === uuid);
|
|
@@ -578,7 +551,7 @@ let ServerService = class ServerService {
|
|
|
578
551
|
this.logger.error(`Failed to remove Matter accessory with UUID ${uuid} from bridge ${deviceId} as ${e.message}.`);
|
|
579
552
|
}
|
|
580
553
|
}
|
|
581
|
-
await
|
|
554
|
+
await writeJson(matterAccessoriesPath, matterAccessories, { spaces: 2 });
|
|
582
555
|
}
|
|
583
556
|
catch (e) {
|
|
584
557
|
this.logger.error(`Failed to process Matter accessories for bridge ${deviceId} as ${e.message}.`);
|
|
@@ -591,16 +564,16 @@ let ServerService = class ServerService {
|
|
|
591
564
|
return this.setupCode;
|
|
592
565
|
}
|
|
593
566
|
else {
|
|
594
|
-
if (!await
|
|
567
|
+
if (!await pathExists(this.accessoryInfoPath)) {
|
|
595
568
|
return null;
|
|
596
569
|
}
|
|
597
|
-
const accessoryInfo = await
|
|
570
|
+
const accessoryInfo = await readJson(this.accessoryInfoPath);
|
|
598
571
|
this.setupCode = this.generateSetupCode(accessoryInfo);
|
|
599
572
|
return this.setupCode;
|
|
600
573
|
}
|
|
601
574
|
}
|
|
602
575
|
generateSetupCode(accessoryInfo) {
|
|
603
|
-
const buffer =
|
|
576
|
+
const buffer = Buffer.allocUnsafe(8);
|
|
604
577
|
let valueLow = Number.parseInt(accessoryInfo.pincode.replace(/-/g, ''), 10);
|
|
605
578
|
const valueHigh = accessoryInfo.category >> 1;
|
|
606
579
|
valueLow |= 1 << 28;
|
|
@@ -618,10 +591,10 @@ let ServerService = class ServerService {
|
|
|
618
591
|
return `X-HM://${encodedPayload}${accessoryInfo.setupID}`;
|
|
619
592
|
}
|
|
620
593
|
async getBridgePairingInformation() {
|
|
621
|
-
if (!await
|
|
622
|
-
return new
|
|
594
|
+
if (!await pathExists(this.accessoryInfoPath)) {
|
|
595
|
+
return new ServiceUnavailableException('Pairing Information Not Available Yet');
|
|
623
596
|
}
|
|
624
|
-
const accessoryInfo = await
|
|
597
|
+
const accessoryInfo = await readJson(this.accessoryInfoPath);
|
|
625
598
|
return {
|
|
626
599
|
displayName: accessoryInfo.displayName,
|
|
627
600
|
pincode: accessoryInfo.pincode,
|
|
@@ -631,7 +604,7 @@ let ServerService = class ServerService {
|
|
|
631
604
|
}
|
|
632
605
|
async getSystemNetworkInterfaces() {
|
|
633
606
|
const fromCache = this.serverServiceCache.get('network-interfaces');
|
|
634
|
-
const interfaces = fromCache || (await
|
|
607
|
+
const interfaces = fromCache || (await networkInterfaces()).filter((adapter) => {
|
|
635
608
|
return !adapter.internal
|
|
636
609
|
&& (adapter.ip4 || (adapter.ip6));
|
|
637
610
|
});
|
|
@@ -685,7 +658,7 @@ let ServerService = class ServerService {
|
|
|
685
658
|
const max = this.configService.homebridgeConfig.ports?.end ?? 60000;
|
|
686
659
|
const randomPort = () => Math.floor(Math.random() * (max - min + 1) + min);
|
|
687
660
|
let port = randomPort();
|
|
688
|
-
while (await (
|
|
661
|
+
while (await tcpCheck(port)) {
|
|
689
662
|
port = randomPort();
|
|
690
663
|
}
|
|
691
664
|
return { port };
|
|
@@ -708,11 +681,11 @@ let ServerService = class ServerService {
|
|
|
708
681
|
}
|
|
709
682
|
}
|
|
710
683
|
for (let port = min; port <= max; port += 1) {
|
|
711
|
-
if (!usedMatterPorts.has(port) && !await (
|
|
684
|
+
if (!usedMatterPorts.has(port) && !await tcpCheck(port)) {
|
|
712
685
|
return { port };
|
|
713
686
|
}
|
|
714
687
|
}
|
|
715
|
-
throw new
|
|
688
|
+
throw new InternalServerErrorException('No available ports in the Matter port range (5530-5541)');
|
|
716
689
|
}
|
|
717
690
|
async getHomebridgePort() {
|
|
718
691
|
const config = await this.configEditorService.getConfigFile();
|
|
@@ -734,7 +707,7 @@ let ServerService = class ServerService {
|
|
|
734
707
|
}
|
|
735
708
|
async setHomebridgeName(name) {
|
|
736
709
|
if (!name || !(/^[\p{L}\p{N}][\p{L}\p{N} ']*[\p{L}\p{N}]$/u).test(name)) {
|
|
737
|
-
throw new
|
|
710
|
+
throw new BadRequestException('Invalid name');
|
|
738
711
|
}
|
|
739
712
|
const config = await this.configEditorService.getConfigFile();
|
|
740
713
|
config.bridge.name = name;
|
|
@@ -742,7 +715,7 @@ let ServerService = class ServerService {
|
|
|
742
715
|
}
|
|
743
716
|
async setHomebridgePort(port) {
|
|
744
717
|
if (!port || typeof port !== 'number' || !Number.isInteger(port) || port < 1025 || port > 65533) {
|
|
745
|
-
throw new
|
|
718
|
+
throw new BadRequestException('Invalid port number');
|
|
746
719
|
}
|
|
747
720
|
const config = await this.configEditorService.getConfigFile();
|
|
748
721
|
config.bridge.port = port;
|
|
@@ -757,19 +730,19 @@ let ServerService = class ServerService {
|
|
|
757
730
|
delete value.end;
|
|
758
731
|
}
|
|
759
732
|
if ('start' in value && (typeof value.start !== 'number' || value.start < 1025 || value.start > 65533)) {
|
|
760
|
-
throw new
|
|
733
|
+
throw new BadRequestException('Port start must be a number between 1025 and 65533.');
|
|
761
734
|
}
|
|
762
735
|
if ('end' in value && (typeof value.end !== 'number' || value.end < 1025 || value.end > 65533)) {
|
|
763
|
-
throw new
|
|
736
|
+
throw new BadRequestException('Port end must be a number between 1025 and 65533.');
|
|
764
737
|
}
|
|
765
738
|
if ('start' in value && 'end' in value && value.start >= value.end) {
|
|
766
|
-
throw new
|
|
739
|
+
throw new BadRequestException('Ports start must be less than end.');
|
|
767
740
|
}
|
|
768
741
|
if ('start' in value && !('end' in value) && config.ports?.end && value.start >= config.ports.end) {
|
|
769
|
-
throw new
|
|
742
|
+
throw new BadRequestException('Ports start must be less than end.');
|
|
770
743
|
}
|
|
771
744
|
if ('end' in value && !('start' in value) && config.ports?.start && config.ports.start >= value.end) {
|
|
772
|
-
throw new
|
|
745
|
+
throw new BadRequestException('Ports start must be less than end.');
|
|
773
746
|
}
|
|
774
747
|
if (!value.start && !value.end) {
|
|
775
748
|
delete config.ports;
|
|
@@ -792,10 +765,10 @@ let ServerService = class ServerService {
|
|
|
792
765
|
const uiConfigBlock = configFile.platforms.find(x => x.platform === 'config');
|
|
793
766
|
if (uiConfigBlock) {
|
|
794
767
|
if (uiConfigBlock.wallpaper) {
|
|
795
|
-
const oldPath =
|
|
796
|
-
if (await
|
|
768
|
+
const oldPath = join(this.configService.storagePath, uiConfigBlock.wallpaper);
|
|
769
|
+
if (await pathExists(oldPath)) {
|
|
797
770
|
try {
|
|
798
|
-
await
|
|
771
|
+
await unlink(oldPath);
|
|
799
772
|
this.logger.log(`Old wallpaper file ${oldPath} deleted successfully.`);
|
|
800
773
|
}
|
|
801
774
|
catch (e) {
|
|
@@ -803,9 +776,9 @@ let ServerService = class ServerService {
|
|
|
803
776
|
}
|
|
804
777
|
}
|
|
805
778
|
}
|
|
806
|
-
const fileExtension =
|
|
807
|
-
const newPath =
|
|
808
|
-
await pump(data.file,
|
|
779
|
+
const fileExtension = extname(data.filename);
|
|
780
|
+
const newPath = join(this.configService.storagePath, `ui-wallpaper${fileExtension}`);
|
|
781
|
+
await pump(data.file, createWriteStream(newPath));
|
|
809
782
|
uiConfigBlock.wallpaper = `ui-wallpaper${fileExtension}`;
|
|
810
783
|
await this.configEditorService.updateConfigFile(configFile);
|
|
811
784
|
this.logger.log('Wallpaper uploaded and set in the config file.');
|
|
@@ -814,11 +787,11 @@ let ServerService = class ServerService {
|
|
|
814
787
|
async deleteWallpaper() {
|
|
815
788
|
const configFile = await this.configEditorService.getConfigFile();
|
|
816
789
|
const uiConfigBlock = configFile.platforms.find(x => x.platform === 'config');
|
|
817
|
-
const fullPath =
|
|
790
|
+
const fullPath = join(this.configService.storagePath, uiConfigBlock.wallpaper);
|
|
818
791
|
if (uiConfigBlock && uiConfigBlock.wallpaper) {
|
|
819
|
-
if (await
|
|
792
|
+
if (await pathExists(fullPath)) {
|
|
820
793
|
try {
|
|
821
|
-
await
|
|
794
|
+
await unlink(fullPath);
|
|
822
795
|
this.logger.log(`Wallpaper file ${uiConfigBlock.wallpaper} deleted successfully.`);
|
|
823
796
|
}
|
|
824
797
|
catch (e) {
|
|
@@ -834,9 +807,9 @@ let ServerService = class ServerService {
|
|
|
834
807
|
async nodeVersionChanged() {
|
|
835
808
|
return new Promise((res) => {
|
|
836
809
|
let result = false;
|
|
837
|
-
const child =
|
|
810
|
+
const child = spawn(process.execPath, ['-v']);
|
|
838
811
|
child.stdout.once('data', (data) => {
|
|
839
|
-
result = data.toString().trim() !==
|
|
812
|
+
result = data.toString().trim() !== process.version;
|
|
840
813
|
});
|
|
841
814
|
child.on('error', () => {
|
|
842
815
|
result = true;
|
|
@@ -863,22 +836,22 @@ let ServerService = class ServerService {
|
|
|
863
836
|
}
|
|
864
837
|
}
|
|
865
838
|
if (!files.length) {
|
|
866
|
-
throw new
|
|
839
|
+
throw new BadRequestException('No files uploaded. Please upload both the private key and certificate files.');
|
|
867
840
|
}
|
|
868
841
|
const readStreamToBuffer = async (stream) => {
|
|
869
842
|
const chunks = [];
|
|
870
843
|
await new Promise((resolvePromise, rejectPromise) => {
|
|
871
|
-
stream.on('data', (d) => chunks.push(
|
|
844
|
+
stream.on('data', (d) => chunks.push(Buffer.isBuffer(d) ? d : Buffer.from(d)));
|
|
872
845
|
stream.on('end', () => resolvePromise());
|
|
873
846
|
stream.on('error', rejectPromise);
|
|
874
847
|
});
|
|
875
|
-
return
|
|
848
|
+
return Buffer.concat(chunks);
|
|
876
849
|
};
|
|
877
850
|
let keyPem = null;
|
|
878
851
|
let certPem = null;
|
|
879
852
|
for (const f of files) {
|
|
880
853
|
if (f.file?.truncated) {
|
|
881
|
-
throw new
|
|
854
|
+
throw new InternalServerErrorException(`Upload exceeds maximum size ${globalThis.backup.maxBackupSizeText}.`);
|
|
882
855
|
}
|
|
883
856
|
const buf = await readStreamToBuffer(f.file);
|
|
884
857
|
const text = buf.toString('utf8');
|
|
@@ -896,35 +869,35 @@ let ServerService = class ServerService {
|
|
|
896
869
|
}
|
|
897
870
|
}
|
|
898
871
|
if (!keyPem || !certPem) {
|
|
899
|
-
throw new
|
|
872
|
+
throw new BadRequestException('Both a PEM private key and certificate must be provided.');
|
|
900
873
|
}
|
|
901
874
|
try {
|
|
902
|
-
const x509 = new
|
|
875
|
+
const x509 = new X509Certificate(certPem);
|
|
903
876
|
const certPub = x509.publicKey.export({ type: 'spki', format: 'der' });
|
|
904
|
-
const priv =
|
|
905
|
-
const pubFromPriv =
|
|
877
|
+
const priv = createPrivateKey({ key: keyPem });
|
|
878
|
+
const pubFromPriv = createPublicKey(priv).export({ type: 'spki', format: 'der' });
|
|
906
879
|
if (!certPub.equals(pubFromPriv)) {
|
|
907
|
-
throw new
|
|
880
|
+
throw new BadRequestException('The private key does not match the certificate public key.');
|
|
908
881
|
}
|
|
909
|
-
|
|
882
|
+
createSecureContext({ key: keyPem, cert: certPem });
|
|
910
883
|
}
|
|
911
884
|
catch (e) {
|
|
912
|
-
if (e instanceof
|
|
885
|
+
if (e instanceof BadRequestException) {
|
|
913
886
|
throw e;
|
|
914
887
|
}
|
|
915
|
-
throw new
|
|
888
|
+
throw new BadRequestException(`Invalid key/certificate: ${e?.message || e}`);
|
|
916
889
|
}
|
|
917
|
-
const sslDir =
|
|
918
|
-
const keyPath =
|
|
919
|
-
const certPath =
|
|
920
|
-
const { ensureDir, writeFile } = await
|
|
890
|
+
const sslDir = join(this.configService.storagePath, 'ssl-certs');
|
|
891
|
+
const keyPath = join(sslDir, 'ui-ssl.key');
|
|
892
|
+
const certPath = join(sslDir, 'ui-ssl.crt');
|
|
893
|
+
const { ensureDir, writeFile } = await import('fs-extra');
|
|
921
894
|
await ensureDir(sslDir);
|
|
922
895
|
await writeFile(keyPath, keyPem);
|
|
923
896
|
await writeFile(certPath, certPem);
|
|
924
897
|
const configFile = await this.configEditorService.getConfigFile();
|
|
925
898
|
const uiConfigBlock = configFile.platforms.find((x) => x.platform === 'config');
|
|
926
899
|
if (!uiConfigBlock) {
|
|
927
|
-
throw new
|
|
900
|
+
throw new InternalServerErrorException('Config platform block not found.');
|
|
928
901
|
}
|
|
929
902
|
if (!uiConfigBlock.ssl) {
|
|
930
903
|
uiConfigBlock.ssl = {};
|
|
@@ -963,36 +936,36 @@ let ServerService = class ServerService {
|
|
|
963
936
|
passphrase = req.body?.passphrase;
|
|
964
937
|
}
|
|
965
938
|
if (!filePart) {
|
|
966
|
-
throw new
|
|
939
|
+
throw new BadRequestException('No PFX file uploaded.');
|
|
967
940
|
}
|
|
968
941
|
if (filePart.file?.truncated) {
|
|
969
|
-
throw new
|
|
942
|
+
throw new InternalServerErrorException(`Upload exceeds maximum size ${globalThis.backup.maxBackupSizeText}.`);
|
|
970
943
|
}
|
|
971
944
|
const readStreamToBuffer = async (stream) => {
|
|
972
945
|
const chunks = [];
|
|
973
946
|
await new Promise((resolvePromise, rejectPromise) => {
|
|
974
|
-
stream.on('data', (d) => chunks.push(
|
|
947
|
+
stream.on('data', (d) => chunks.push(Buffer.isBuffer(d) ? d : Buffer.from(d)));
|
|
975
948
|
stream.on('end', () => resolvePromise());
|
|
976
949
|
stream.on('error', rejectPromise);
|
|
977
950
|
});
|
|
978
|
-
return
|
|
951
|
+
return Buffer.concat(chunks);
|
|
979
952
|
};
|
|
980
953
|
const pfxBuffer = await readStreamToBuffer(filePart.file);
|
|
981
954
|
try {
|
|
982
|
-
|
|
955
|
+
createSecureContext({ pfx: pfxBuffer, passphrase });
|
|
983
956
|
}
|
|
984
957
|
catch (e) {
|
|
985
|
-
throw new
|
|
958
|
+
throw new BadRequestException(`Invalid PFX or passphrase: ${e?.message || e}`);
|
|
986
959
|
}
|
|
987
|
-
const sslDir =
|
|
988
|
-
const pfxPath =
|
|
989
|
-
const { ensureDir, writeFile } = await
|
|
960
|
+
const sslDir = join(this.configService.storagePath, 'ssl-certs');
|
|
961
|
+
const pfxPath = join(sslDir, 'ui-ssl.pfx');
|
|
962
|
+
const { ensureDir, writeFile } = await import('fs-extra');
|
|
990
963
|
await ensureDir(sslDir);
|
|
991
964
|
await writeFile(pfxPath, pfxBuffer);
|
|
992
965
|
const configFile = await this.configEditorService.getConfigFile();
|
|
993
966
|
const uiConfigBlock = configFile.platforms.find((x) => x.platform === 'config');
|
|
994
967
|
if (!uiConfigBlock) {
|
|
995
|
-
throw new
|
|
968
|
+
throw new InternalServerErrorException('Config platform block not found.');
|
|
996
969
|
}
|
|
997
970
|
if (!uiConfigBlock.ssl) {
|
|
998
971
|
uiConfigBlock.ssl = {};
|
|
@@ -1022,23 +995,23 @@ let ServerService = class ServerService {
|
|
|
1022
995
|
}
|
|
1023
996
|
try {
|
|
1024
997
|
if (ssl.key && ssl.cert) {
|
|
1025
|
-
const { readFile } = await
|
|
998
|
+
const { readFile } = await import('fs-extra');
|
|
1026
999
|
const keyPem = await readFile(ssl.key);
|
|
1027
1000
|
const certPem = await readFile(ssl.cert);
|
|
1028
|
-
const x509 = new
|
|
1001
|
+
const x509 = new X509Certificate(certPem);
|
|
1029
1002
|
const certPub = x509.publicKey.export({ type: 'spki', format: 'der' });
|
|
1030
|
-
const priv =
|
|
1031
|
-
const pubFromPriv =
|
|
1003
|
+
const priv = createPrivateKey({ key: keyPem });
|
|
1004
|
+
const pubFromPriv = createPublicKey(priv).export({ type: 'spki', format: 'der' });
|
|
1032
1005
|
if (!certPub.equals(pubFromPriv)) {
|
|
1033
1006
|
return { ok: true, valid: false, type: 'keycert', details: 'Private key does not match certificate.' };
|
|
1034
1007
|
}
|
|
1035
|
-
|
|
1008
|
+
createSecureContext({ key: keyPem, cert: certPem });
|
|
1036
1009
|
return { ok: true, valid: true, type: 'keycert', details: 'Key and certificate are valid and match.' };
|
|
1037
1010
|
}
|
|
1038
1011
|
if (ssl.pfx) {
|
|
1039
|
-
const { readFile } = await
|
|
1012
|
+
const { readFile } = await import('fs-extra');
|
|
1040
1013
|
const pfx = await readFile(ssl.pfx);
|
|
1041
|
-
|
|
1014
|
+
createSecureContext({ pfx, passphrase: ssl.passphrase });
|
|
1042
1015
|
return { ok: true, valid: true, type: 'pfx', details: 'PFX file and passphrase are valid.' };
|
|
1043
1016
|
}
|
|
1044
1017
|
}
|
|
@@ -1052,11 +1025,11 @@ let ServerService = class ServerService {
|
|
|
1052
1025
|
? options.hostnames.map(h => String(h).trim()).filter(Boolean)
|
|
1053
1026
|
: ['localhost', '127.0.0.1'];
|
|
1054
1027
|
const mode = options.mode || 'keycert';
|
|
1055
|
-
const generator = new
|
|
1028
|
+
const generator = new SslCertGeneratorService();
|
|
1056
1029
|
await generator.generateCertificate(hostnames);
|
|
1057
|
-
const sslDir =
|
|
1058
|
-
const keyPath =
|
|
1059
|
-
const certPath =
|
|
1030
|
+
const sslDir = join(this.configService.storagePath, 'ssl-certs');
|
|
1031
|
+
const keyPath = join(sslDir, 'private-key.pem');
|
|
1032
|
+
const certPath = join(sslDir, 'certificate.pem');
|
|
1060
1033
|
const configFile = await this.configEditorService.getConfigFile();
|
|
1061
1034
|
const uiConfigBlock = configFile.platforms.find((x) => x.platform === 'config');
|
|
1062
1035
|
if (!uiConfigBlock.ssl) {
|
|
@@ -1089,13 +1062,18 @@ let ServerService = class ServerService {
|
|
|
1089
1062
|
};
|
|
1090
1063
|
}
|
|
1091
1064
|
};
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
(0,
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1065
|
+
ServerService = __decorate([
|
|
1066
|
+
Injectable(),
|
|
1067
|
+
__param(0, Inject(ConfigService)),
|
|
1068
|
+
__param(1, Inject(ConfigEditorService)),
|
|
1069
|
+
__param(2, Inject(AccessoriesService)),
|
|
1070
|
+
__param(3, Inject(HomebridgeIpcService)),
|
|
1071
|
+
__param(4, Inject(Logger)),
|
|
1072
|
+
__metadata("design:paramtypes", [ConfigService,
|
|
1073
|
+
ConfigEditorService,
|
|
1074
|
+
AccessoriesService,
|
|
1075
|
+
HomebridgeIpcService,
|
|
1076
|
+
Logger])
|
|
1100
1077
|
], ServerService);
|
|
1078
|
+
export { ServerService };
|
|
1101
1079
|
//# sourceMappingURL=server.service.js.map
|