@camera.ui/server 0.0.50-internal.0 → 0.0.50-internal.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/dist/interface/index.html +44 -44
- package/dist/interface/js/{@primevue.OhxoO3MD.0.0.50-internal.0.js → @primevue.BAIU_p3r.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{@tanstack.D1IL6eOv.0.0.50-internal.0.js → @tanstack.mdCorqzE.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{@vee-validate.BGPyWWTh.0.0.50-internal.0.js → @vee-validate.D0vsSsly.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{@vueuse.BsKtqdiG.0.0.50-internal.0.js → @vueuse.we5ZpWr2.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{Adminpanel.D93Kvbwp.0.0.50-internal.0.js → Adminpanel.9AEBJ3H1.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{Camera.DF2l3OMA.0.0.50-internal.0.js → Camera.CZcnEH0C.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{Cameras.YzvZccdv.0.0.50-internal.0.js → Cameras.DE0LkcGu.0.0.50-internal.2.js} +2 -2
- package/dist/interface/js/Cammesh.CVvmkelB.0.0.50-internal.2.js +1 -0
- package/dist/interface/js/{Camview.CB7_HnoQ.0.0.50-internal.0.js → Camview.CUr4pGoU.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{Config.BwflsWTm.0.0.50-internal.0.js → Config.CaJhu4fF.0.0.50-internal.2.js} +2 -2
- package/dist/interface/js/{Console.DZM8pN8Q.0.0.50-internal.0.js → Console.5VUmgryj.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{CuiConsole.BXXU7Gth.0.0.50-internal.0.js → CuiConsole.iYmUxAR5.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{CuiPluginCard.YFOrpbVD.0.0.50-internal.0.js → CuiPluginCard.DXPyE5mF.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{CuiTimeline.VV5KSJd5.0.0.50-internal.0.js → CuiTimeline.BqtlOFnV.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{FirstSteps.b-nvymgb.0.0.50-internal.0.js → FirstSteps.C_RI-SDQ.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{Plugin.BOMpVEwM.0.0.50-internal.0.js → Plugin.Ch_v02eN.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{Plugins.DdPwaUDA.0.0.50-internal.0.js → Plugins.BpXAYgSG.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/Recordings.CIKHJytH.0.0.50-internal.2.js +1 -0
- package/dist/interface/js/{Settings.D24ttaPu.0.0.50-internal.0.js → Settings.BcLoGNEy.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{SettingsAccount.ms3aqz4E.0.0.50-internal.0.js → SettingsAccount.DMROW8kx.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/SettingsAppearance.CUaHpihp.0.0.50-internal.2.js +1 -0
- package/dist/interface/js/{SettingsAppearance.vue_vue_type_script_setup_true_lang.CBQ6lL3T.0.0.50-internal.0.js → SettingsAppearance.vue_vue_type_script_setup_true_lang.BuKZ-Uco.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{SettingsBackup.BPEc4Rjg.0.0.50-internal.0.js → SettingsBackup.0QdwFSpv.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/SettingsRecordings.B-aj0U8_.0.0.50-internal.2.js +1 -0
- package/dist/interface/js/{SettingsRemote.BL5nXbUT.0.0.50-internal.0.js → SettingsRemote.Bi1YAJ76.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{SettingsSystem.D7T0AIpm.0.0.50-internal.0.js → SettingsSystem.CAx66Iir.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{SettingsUsers.1u0vCOVG.0.0.50-internal.0.js → SettingsUsers.CQcDtGy1.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{VersionsHandler.vue_vue_type_script_setup_true_lang.xDishkkS.0.0.50-internal.0.js → VersionsHandler.vue_vue_type_script_setup_true_lang.BhXMzIhV.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{ace-builds.D1nmvCwb.0.0.50-internal.0.js → ace-builds.C0sCXSu5.0.0.50-internal.2.js} +2 -2
- package/dist/interface/js/{ace.config.G96T2z54.0.0.50-internal.0.js → ace.config.DNqPWa0Q.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{backup.B_Gzxtp_.0.0.50-internal.0.js → backup.DAXgG3bP.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{chart.js.CP_nMnnf.0.0.50-internal.0.js → chart.js.Bq3YocRX.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{close-circle.DYLuVIOg.0.0.50-internal.0.js → close-circle.9rxyNw0z.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{dnd-core.T9OeW7mu.0.0.50-internal.0.js → dnd-core.BuEvHAsS.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{draggabilly.D3zGcBb3.0.0.50-internal.0.js → draggabilly.DUdE08x8.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{engine.io-client.kITRnq-g.0.0.50-internal.0.js → engine.io-client.DWU6YI8o.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{fast-deep-equal.Bpc9mIsj.0.0.50-internal.0.js → fast-deep-equal.BpPyC6E4.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{highlight.js.BlSXU-Wb.0.0.50-internal.0.js → highlight.js.BoR2Rhdd.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{linkify-it.C3N1lWsJ.0.0.50-internal.0.js → linkify-it.BXzPONHs.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{main.D0YR3Jat.0.0.50-internal.0.js → main.DwcBYfWc.0.0.50-internal.2.js} +3 -3
- package/dist/interface/js/{markdown-it.Dj0dt5s2.0.0.50-internal.0.js → markdown-it.BUDVOjPt.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{nprogress.BwQWDcGj.0.0.50-internal.0.js → nprogress.CsG-OBoI.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{pinia.DRh7plEC.0.0.50-internal.0.js → pinia.CqEQao5R.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{primevue.Cl58krXf.0.0.50-internal.0.js → primevue.D91sslRx.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{qrcode.C1sDj6P8.0.0.50-internal.0.js → qrcode.SdSTPzZO.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{react-dnd-touch-backend.BA4WhUJo.0.0.50-internal.0.js → react-dnd-touch-backend.BwroebQ4.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{refresh-rounded.D_SmhhUf.0.0.50-internal.0.js → refresh-rounded.DxM48YSv.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{rxjs.C-fTBwEO.0.0.50-internal.0.js → rxjs.Cmpbnzo4.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{socket.io-client.DKrRxgjP.0.0.50-internal.0.js → socket.io-client.DF2YgZo1.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{socket.io-parser.EXj3YDH2.0.0.50-internal.0.js → socket.io-parser.BUs2ineY.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{system.CY8rGd-Q.0.0.50-internal.0.js → system.DmkT2LKx.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{trash-fill.CMnCN3Oy.0.0.50-internal.0.js → trash-fill.dPzyZDVa.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{unidragger.D0w6Tqtt.0.0.50-internal.0.js → unidragger.y2ZlFveS.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vee-validate.BeiObIH8.0.0.50-internal.0.js → vee-validate.Y-alCADW.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vue-chartjs.DtdZdiYw.0.0.50-internal.0.js → vue-chartjs.sRVFTqDf.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vue-i18n.BW2bx_6z.0.0.50-internal.0.js → vue-i18n.D5WrXOZa.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vue-inline-svg.BJkQGmKz.0.0.50-internal.0.js → vue-inline-svg.R0uz_abA.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vue-router.B2mOXHaC.0.0.50-internal.0.js → vue-router.65mnGy-o.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vue-zoomable.BKDyCJE7.0.0.50-internal.0.js → vue-zoomable.B1Qop6Uu.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{vue3-dnd.DRK24CBp.0.0.50-internal.0.js → vue3-dnd.CwmyAcir.0.0.50-internal.2.js} +1 -1
- package/dist/interface/js/{zoom-out.DxvzgVEo.0.0.50-internal.0.js → zoom-out.CMPALvRh.0.0.50-internal.2.js} +1 -1
- package/dist/interface/sw.js +1 -1
- package/dist/server/package.json +1 -1
- package/dist/server/src/rpc/server.js +4 -1
- package/dist/server/src/rpc/server.js.map +1 -1
- package/package.json +1 -1
- package/.prettierignore +0 -12
- package/.prettierrc.json +0 -12
- package/artillery.yaml +0 -29
- package/bin/cameraui-server.ts +0 -11
- package/dist/interface/js/Cammesh.D-6dAROQ.0.0.50-internal.0.js +0 -1
- package/dist/interface/js/Recordings.DhxjIW7e.0.0.50-internal.0.js +0 -1
- package/dist/interface/js/SettingsAppearance.DsTjKXk1.0.0.50-internal.0.js +0 -1
- package/dist/interface/js/SettingsRecordings.DgW7M0jj.0.0.50-internal.0.js +0 -1
- package/eslint.config.js +0 -103
- package/localdeps.txt +0 -10
- package/mypy.ini +0 -30
- package/requirements.txt +0 -15
- package/ruff.toml +0 -90
- package/src/__init__.py +0 -0
- package/src/_camera_ui_tools/__init__.py +0 -0
- package/src/_camera_ui_tools/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/api/controllers/api.controller.ts +0 -19
- package/src/api/controllers/auth.controller.ts +0 -294
- package/src/api/controllers/backup.controller.ts +0 -72
- package/src/api/controllers/cameras.controller.ts +0 -1029
- package/src/api/controllers/config.controller.ts +0 -102
- package/src/api/controllers/files.controller.ts +0 -35
- package/src/api/controllers/frameWorkers.controller.ts +0 -109
- package/src/api/controllers/plugins.controller.ts +0 -1206
- package/src/api/controllers/system.controller.ts +0 -273
- package/src/api/controllers/users.controller.ts +0 -648
- package/src/api/database/checks.ts +0 -268
- package/src/api/database/constants.ts +0 -8
- package/src/api/database/index.ts +0 -262
- package/src/api/database/migration.ts +0 -62
- package/src/api/database/selfcheck.ts +0 -492
- package/src/api/database/types.ts +0 -104
- package/src/api/go2rtc/api/application.ts +0 -48
- package/src/api/go2rtc/api/config.ts +0 -61
- package/src/api/go2rtc/api/discover.ts +0 -197
- package/src/api/go2rtc/api/index.ts +0 -49
- package/src/api/go2rtc/api/snapshot.ts +0 -44
- package/src/api/go2rtc/api/streams.ts +0 -168
- package/src/api/go2rtc/index.ts +0 -43
- package/src/api/go2rtc/queue.ts +0 -50
- package/src/api/go2rtc/types.ts +0 -174
- package/src/api/index.ts +0 -286
- package/src/api/middlewares/authPermission.middleware.ts +0 -46
- package/src/api/middlewares/authValidation.middleware.ts +0 -160
- package/src/api/middlewares/pagination.middleware.ts +0 -67
- package/src/api/middlewares/socketAuth.middleware.ts +0 -136
- package/src/api/plugins/header.plugin.ts +0 -15
- package/src/api/plugins/logger.plugin.ts +0 -44
- package/src/api/plugins/proxy.plugin.ts +0 -255
- package/src/api/plugins/socket.plugin.ts +0 -28
- package/src/api/plugins/system.plugin.ts +0 -48
- package/src/api/plugins/useragent.plugin.ts +0 -19
- package/src/api/routes/api.routes.ts +0 -10
- package/src/api/routes/auth.routes.ts +0 -56
- package/src/api/routes/backup.routes.ts +0 -28
- package/src/api/routes/cameras.routes.ts +0 -281
- package/src/api/routes/config.routes.ts +0 -66
- package/src/api/routes/files.routes.ts +0 -15
- package/src/api/routes/frameWorkers.routes.ts +0 -39
- package/src/api/routes/index.ts +0 -37
- package/src/api/routes/plugins.routes.ts +0 -420
- package/src/api/routes/system.routes.ts +0 -101
- package/src/api/routes/users.routes.ts +0 -167
- package/src/api/schemas/backup.schema.ts +0 -112
- package/src/api/schemas/cameras.schema.ts +0 -479
- package/src/api/schemas/config.schema.ts +0 -38
- package/src/api/schemas/go2rtc.schema.ts +0 -189
- package/src/api/schemas/plugins.schema.ts +0 -126
- package/src/api/schemas/storage.schema.ts +0 -11
- package/src/api/schemas/system.schema.ts +0 -45
- package/src/api/schemas/users.schema.ts +0 -185
- package/src/api/services/auth.service.ts +0 -210
- package/src/api/services/backup.service.ts +0 -144
- package/src/api/services/cameras.service.ts +0 -671
- package/src/api/services/plugins.service.ts +0 -470
- package/src/api/services/system.service.ts +0 -85
- package/src/api/services/users.service.ts +0 -276
- package/src/api/types/index.ts +0 -675
- package/src/api/utils/cert.ts +0 -254
- package/src/api/utils/constants.ts +0 -17
- package/src/api/utils/fetch.ts +0 -21
- package/src/api/utils/moveFiles.ts +0 -45
- package/src/api/utils/parse.ts +0 -17
- package/src/api/websocket/index.ts +0 -110
- package/src/api/websocket/nsp/logs.ts +0 -240
- package/src/api/websocket/nsp/main.ts +0 -27
- package/src/api/websocket/nsp/metrics.ts +0 -301
- package/src/api/websocket/nsp/notifications.ts +0 -43
- package/src/api/websocket/nsp/plugins.ts +0 -37
- package/src/api/websocket/nsp/server.ts +0 -220
- package/src/api/websocket/nsp/status.ts +0 -77
- package/src/api/websocket/types.ts +0 -55
- package/src/api.ts +0 -163
- package/src/camera/classes.ts +0 -32
- package/src/camera/controller.ts +0 -579
- package/src/camera/device.ts +0 -422
- package/src/camera/frameWorker.ts +0 -403
- package/src/camera/index.ts +0 -679
- package/src/camera/interfaces.ts +0 -95
- package/src/camera/iou.ts +0 -153
- package/src/camera/polygon.ts +0 -226
- package/src/camera/python/__init__.py +0 -0
- package/src/camera/python/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/classes.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/delegate_controller.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/interfaces.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/iou.cpython-310.pyc +0 -0
- package/src/camera/python/__pycache__/iou.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/iou2.cpython-310.pyc +0 -0
- package/src/camera/python/__pycache__/polygon.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/typings.cpython-311.pyc +0 -0
- package/src/camera/python/__pycache__/video_frame.cpython-311.pyc +0 -0
- package/src/camera/python/classes.py +0 -41
- package/src/camera/python/interfaces.py +0 -130
- package/src/camera/python/iou.py +0 -158
- package/src/camera/python/polygon.py +0 -230
- package/src/camera/python/test/__pycache__/polygon.cpython-310.pyc +0 -0
- package/src/camera/python/test/iou_test.py +0 -799
- package/src/camera/python/test/polygon.py +0 -238
- package/src/camera/python/test/polygon_test.py +0 -256
- package/src/camera/python/test/polygon_test2.py +0 -484
- package/src/camera/python/typings.py +0 -50
- package/src/camera/python/video_frame.py +0 -143
- package/src/camera/session.ts +0 -192
- package/src/camera/streaming/fmp4-session.ts +0 -390
- package/src/camera/streaming/peer-connection.ts +0 -273
- package/src/camera/streaming/rtsp-session.ts +0 -331
- package/src/camera/streaming/webrtc-connection.ts +0 -260
- package/src/camera/streaming/werift-session.ts +0 -317
- package/src/camera/test/iou_test.ts +0 -761
- package/src/camera/test/polygon.test.ts +0 -611
- package/src/camera/test/polygon_test.ts +0 -210
- package/src/camera/types.ts +0 -48
- package/src/camera/utils.ts +0 -489
- package/src/camera/videoFrame.ts +0 -123
- package/src/cloud/index.ts +0 -61
- package/src/cloud/remote/cloudflare.ts +0 -18
- package/src/cloud/remote/upnp.ts +0 -18
- package/src/cloud/remote/utils.ts +0 -24
- package/src/cloud/types.ts +0 -16
- package/src/decoder/child.ts +0 -883
- package/src/decoder/imageUtils.ts +0 -275
- package/src/decoder/manager.ts +0 -251
- package/src/decoder/python/__init__.py +0 -0
- package/src/decoder/python/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/decoder/python/__pycache__/image_utils.cpython-311.pyc +0 -0
- package/src/decoder/python/__pycache__/typings.cpython-311.pyc +0 -0
- package/src/decoder/python/__pycache__/utils.cpython-311.pyc +0 -0
- package/src/decoder/python/child.py +0 -903
- package/src/decoder/python/image_utils.py +0 -196
- package/src/decoder/python/pool.py +0 -45
- package/src/decoder/python/test/group.py +0 -62
- package/src/decoder/python/test/motion.mp4 +0 -0
- package/src/decoder/python/test/motion2.mp4 +0 -0
- package/src/decoder/python/test/opencl.cl +0 -70
- package/src/decoder/python/test/opencl2.cl +0 -130
- package/src/decoder/python/test/test.py +0 -427
- package/src/decoder/python/test/test1.jpg +0 -0
- package/src/decoder/python/test/test1_resized.jpg +0 -0
- package/src/decoder/python/test/test2.jpg +0 -0
- package/src/decoder/python/test/test2.py +0 -451
- package/src/decoder/python/test/test2_resized.jpg +0 -0
- package/src/decoder/python/test/test3.jpg +0 -0
- package/src/decoder/python/test/utils.py +0 -50
- package/src/decoder/python/typings.py +0 -57
- package/src/decoder/python/utils.py +0 -70
- package/src/decoder/test/child.ts +0 -117
- package/src/decoder/test/ffmpeg.ts +0 -371
- package/src/decoder/test/test.ts +0 -182
- package/src/decoder/types.ts +0 -27
- package/src/decoder/utils.ts +0 -64
- package/src/decoder/wasm/asconfig.json +0 -28
- package/src/decoder/wasm/assembly/console.ts +0 -1
- package/src/decoder/wasm/assembly/index.ts +0 -890
- package/src/decoder/wasm/build/decoder.d.ts +0 -43
- package/src/decoder/wasm/build/decoder.js +0 -108
- package/src/decoder/wasm/build/decoder.wasm +0 -0
- package/src/decoder/wasm/tsconfig.json +0 -5
- package/src/decoder/worker.ts +0 -113
- package/src/go2rtc/index.ts +0 -324
- package/src/go2rtc/types.ts +0 -88
- package/src/main.ts +0 -267
- package/src/manager/coreManager.ts +0 -78
- package/src/manager/deviceManager.ts +0 -132
- package/src/manager/types.ts +0 -17
- package/src/plugins/index.ts +0 -443
- package/src/plugins/plugin.ts +0 -177
- package/src/plugins/runtime/base.ts +0 -282
- package/src/plugins/runtime/index.ts +0 -15
- package/src/plugins/runtime/node/child.ts +0 -193
- package/src/plugins/runtime/node/index.ts +0 -67
- package/src/plugins/runtime/node/plugin.ts +0 -122
- package/src/plugins/runtime/node/pluginApi.ts +0 -27
- package/src/plugins/runtime/node/proxy/cameraDevice.ts +0 -299
- package/src/plugins/runtime/node/proxy/coreManager.ts +0 -128
- package/src/plugins/runtime/node/proxy/deviceManager.ts +0 -187
- package/src/plugins/runtime/node/storage.ts +0 -312
- package/src/plugins/runtime/node/storageController.ts +0 -91
- package/src/plugins/runtime/python/__init__.py +0 -0
- package/src/plugins/runtime/python/__pycache__/__init__.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/camera_storage.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/config_service.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/constants.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/ipc.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/logger.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/message_queue.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/namespaces.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/plugin.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/plugin_api.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/plugin_logger.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/proxy_utils.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/schema.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/storage.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/storage_controller.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/__pycache__/typings.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/child.py +0 -248
- package/src/plugins/runtime/python/index.ts +0 -73
- package/src/plugins/runtime/python/namespaces.py +0 -101
- package/src/plugins/runtime/python/plugin.py +0 -155
- package/src/plugins/runtime/python/plugin_api.py +0 -29
- package/src/plugins/runtime/python/proxy/__pycache__/camera_device.cpython-310.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/camera_device.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/camera_device.cpython-38.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/camera_device.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/constants.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/constants.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/core_manager.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/device_manager.cpython-310.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/device_manager.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/device_manager.cpython-38.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/device_manager.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/generate_keys.cpython-310.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/generate_keys.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/generate_keys.cpython-38.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/generate_keys.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/message_queue.cpython-310.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/message_queue.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/message_queue.cpython-38.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/message_queue.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/plugins_manager.cpython-310.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/plugins_manager.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/plugins_manager.cpython-38.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/plugins_manager.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/system_manager.cpython-310.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/system_manager.cpython-311.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/system_manager.cpython-38.pyc +0 -0
- package/src/plugins/runtime/python/proxy/__pycache__/system_manager.cpython-39.pyc +0 -0
- package/src/plugins/runtime/python/proxy/camera_device.py +0 -1732
- package/src/plugins/runtime/python/proxy/core_manager.py +0 -126
- package/src/plugins/runtime/python/proxy/device_manager.py +0 -197
- package/src/plugins/runtime/python/schema.py +0 -99
- package/src/plugins/runtime/python/storage.py +0 -353
- package/src/plugins/runtime/python/storage_controller.py +0 -102
- package/src/plugins/runtime/python/typings.py +0 -195
- package/src/plugins/schema.ts +0 -472
- package/src/plugins/types.ts +0 -60
- package/src/plugins/worker.ts +0 -250
- package/src/rpc/index.ts +0 -149
- package/src/rpc/namespaces.ts +0 -79
- package/src/rpc/server.ts +0 -422
- package/src/rpc/types.ts +0 -119
- package/src/rpc/utils.ts +0 -16
- package/src/services/config/constants.ts +0 -47
- package/src/services/config/defaults.ts +0 -57
- package/src/services/config/index.ts +0 -744
- package/src/services/config/types.ts +0 -211
- package/src/services/logger/index.ts +0 -96
- package/src/types.ts +0 -47
- package/src/utils/path.ts +0 -16
- package/src/utils/pythonInstaller.ts +0 -597
- package/tsconfig.json +0 -37
- package/types/fastify.d.ts +0 -14
- package/updates.config.js +0 -3
- /package/dist/interface/assets/{@xterm.DYP7pi_n.0.0.50-internal.0.css → @xterm.DYP7pi_n.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{Adminpanel.BKek2EMH.0.0.50-internal.0.css → Adminpanel.BKek2EMH.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{Cameras.BDWZJqPN.0.0.50-internal.0.css → Cameras.BDWZJqPN.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{Camview.BFUFMoNX.0.0.50-internal.0.css → Camview.BFUFMoNX.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{CuiConsole.DCYyxdVg.0.0.50-internal.0.css → CuiConsole.DCYyxdVg.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{CuiPluginCard.yF8V0SZY.0.0.50-internal.0.css → CuiPluginCard.yF8V0SZY.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{CuiTimeline.BkIwlYtw.0.0.50-internal.0.css → CuiTimeline.BkIwlYtw.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{Plugin.DJElsAn5.0.0.50-internal.0.css → Plugin.DJElsAn5.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{Plugins.0h77qnmN.0.0.50-internal.0.css → Plugins.0h77qnmN.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{Settings.CkgfRkQr.0.0.50-internal.0.css → Settings.CkgfRkQr.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{SettingsAccount.DeFul3eQ.0.0.50-internal.0.css → SettingsAccount.DeFul3eQ.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{SettingsBackup.CX0rT0QJ.0.0.50-internal.0.css → SettingsBackup.CX0rT0QJ.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{highlight.Ch2EwETz.0.0.50-internal.0.css → highlight.Ch2EwETz.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{logo-256.BCQk9H1-.0.0.50-internal.0.png → logo-256.BCQk9H1-.0.0.50-internal.2.png} +0 -0
- /package/dist/interface/assets/{logo-512.DLKVOU2S.0.0.50-internal.0.png → logo-512.DLKVOU2S.0.0.50-internal.2.png} +0 -0
- /package/dist/interface/assets/{logo.DmEiRk0z.0.0.50-internal.0.png → logo.DmEiRk0z.0.0.50-internal.2.png} +0 -0
- /package/dist/interface/assets/{main.Cip9LkS3.0.0.50-internal.0.css → main.Cip9LkS3.0.0.50-internal.2.css} +0 -0
- /package/dist/interface/assets/{mode-json.Br7xisR1.0.0.50-internal.0.js → mode-json.Br7xisR1.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/assets/{mode-yaml.CIYL8U3d.0.0.50-internal.0.js → mode-yaml.CIYL8U3d.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/assets/{worker-base.jEXLGV2h.0.0.50-internal.0.js → worker-base.jEXLGV2h.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/assets/{worker-json.DgwNIOck.0.0.50-internal.0.js → worker-json.DgwNIOck.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/assets/{worker-yaml.B3uUYINB.0.0.50-internal.0.js → worker-yaml.B3uUYINB.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@babel.l0sNRNKZ.0.0.50-internal.0.js → @babel.l0sNRNKZ.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@intlify.BkGPX90O.0.0.50-internal.0.js → @intlify.BkGPX90O.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@kurkle.D8fDXNIl.0.0.50-internal.0.js → @kurkle.D8fDXNIl.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@primeuix.BFAY2Bk9.0.0.50-internal.0.js → @primeuix.BFAY2Bk9.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@react-dnd.CcwRs9xb.0.0.50-internal.0.js → @react-dnd.CcwRs9xb.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@socket.io.Dkula2eQ.0.0.50-internal.0.js → @socket.io.Dkula2eQ.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@vue.B5vqhCp2.0.0.50-internal.0.js → @vue.B5vqhCp2.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{@xterm.CAa7rpjv.0.0.50-internal.0.js → @xterm.C-5Lxnx_.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{axios.DHr9lByg.0.0.50-internal.0.js → axios.DHr9lByg.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{birpc.l0sNRNKZ.0.0.50-internal.0.js → birpc.l0sNRNKZ.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{compare-versions.DqEOhma6.0.0.50-internal.0.js → compare-versions.DqEOhma6.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{dijkstrajs.C00ieaqj.0.0.50-internal.0.js → dijkstrajs.C00ieaqj.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{engine.io-parser.BiEtp6m2.0.0.50-internal.0.js → engine.io-parser.BiEtp6m2.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{entities.C20TfXL6.0.0.50-internal.0.js → entities.C20TfXL6.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{ev-emitter.X5f1qa-c.0.0.50-internal.0.js → ev-emitter.X5f1qa-c.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{get-size.D1dS-IaP.0.0.50-internal.0.js → get-size.D1dS-IaP.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{hookable.l0sNRNKZ.0.0.50-internal.0.js → hookable.l0sNRNKZ.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{mdurl.k9Sl0PQj.0.0.50-internal.0.js → mdurl.k9Sl0PQj.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{perfect-debounce.l0sNRNKZ.0.0.50-internal.0.js → perfect-debounce.l0sNRNKZ.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{primelocale.Bga3dOQu.0.0.50-internal.0.js → primelocale.Bga3dOQu.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{punycode.js.Dj65hjkv.0.0.50-internal.0.js → punycode.js.Dj65hjkv.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{react-dnd-html5-backend.1HQjlkwI.0.0.50-internal.0.js → react-dnd-html5-backend.1HQjlkwI.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{redux.BFxtlG_c.0.0.50-internal.0.js → redux.BFxtlG_c.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{tslib.9k7AwCpt.0.0.50-internal.0.js → tslib.9k7AwCpt.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{uc.micro.kMc2yuuw.0.0.50-internal.0.js → uc.micro.kMc2yuuw.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{uuid.C6aID195.0.0.50-internal.0.js → uuid.C6aID195.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{vue.l0sNRNKZ.0.0.50-internal.0.js → vue.l0sNRNKZ.0.0.50-internal.2.js} +0 -0
- /package/dist/interface/js/{zod.SKKegNRO.0.0.50-internal.0.js → zod.SKKegNRO.0.0.50-internal.2.js} +0 -0
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
-
import type { AuthLoginRequest, Pagination, PaginationQuery, PaginationRequest, PaginationResponse } from '../types/index.js';
|
|
3
|
-
|
|
4
|
-
const PAGINATION_DEFAULTS = {
|
|
5
|
-
START: 0,
|
|
6
|
-
PAGE: 1,
|
|
7
|
-
PAGE_SIZE: -1,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const validateQuery = (query: Required<PaginationQuery>, totalItems: number) => {
|
|
11
|
-
return {
|
|
12
|
-
start: Math.max(0, Math.min(query.start, totalItems - 1)),
|
|
13
|
-
page: Math.max(1, query.page),
|
|
14
|
-
pageSize: query.pageSize === -1 ? -1 : Math.max(1, query.pageSize),
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const pages = async (req: FastifyRequest<AuthLoginRequest & PaginationRequest>, reply: FastifyReply, payload: any): Promise<PaginationResponse | void> => {
|
|
19
|
-
if (reply.statusCode >= 400) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const items = payload ?? [];
|
|
24
|
-
const rawQuery = {
|
|
25
|
-
start: req.query.start ?? PAGINATION_DEFAULTS.START,
|
|
26
|
-
page: req.query.page ?? PAGINATION_DEFAULTS.PAGE,
|
|
27
|
-
pageSize: req.query.pageSize ?? PAGINATION_DEFAULTS.PAGE_SIZE,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const query = validateQuery(rawQuery, items.length);
|
|
31
|
-
|
|
32
|
-
if (query.pageSize === -1) {
|
|
33
|
-
return {
|
|
34
|
-
pagination: {
|
|
35
|
-
currentPage: 1,
|
|
36
|
-
pageSize: -1,
|
|
37
|
-
totalPages: 1,
|
|
38
|
-
startIndex: query.start,
|
|
39
|
-
endIndex: items.length - 1,
|
|
40
|
-
totalItems: items.length,
|
|
41
|
-
},
|
|
42
|
-
result: items.slice(query.start),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const totalItems = items.length;
|
|
47
|
-
const totalPages = Math.ceil(totalItems / query.pageSize);
|
|
48
|
-
const currentPage = query.start !== PAGINATION_DEFAULTS.START ? Math.ceil((query.start + 1) / query.pageSize) : Math.min(query.page, totalPages);
|
|
49
|
-
const startIndex = query.start !== PAGINATION_DEFAULTS.START ? query.start : (currentPage - 1) * query.pageSize;
|
|
50
|
-
const endIndex = Math.min(startIndex + query.pageSize - 1, totalItems - 1);
|
|
51
|
-
|
|
52
|
-
const pagination: Pagination = {
|
|
53
|
-
currentPage,
|
|
54
|
-
pageSize: query.pageSize,
|
|
55
|
-
totalPages,
|
|
56
|
-
startIndex,
|
|
57
|
-
endIndex,
|
|
58
|
-
totalItems,
|
|
59
|
-
nextPageQuery: currentPage < totalPages ? `?page=${currentPage + 1}&start=${startIndex + query.pageSize}` : null,
|
|
60
|
-
prevPageQuery: currentPage > 1 ? `?page=${currentPage - 1}&start=${Math.max(0, startIndex - query.pageSize)}` : null,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
pagination,
|
|
65
|
-
result: items.slice(startIndex, endIndex + 1),
|
|
66
|
-
};
|
|
67
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// https://github.com/Thream/socketio-jwt
|
|
2
|
-
import type { Algorithm } from 'jsonwebtoken';
|
|
3
|
-
import jwt from 'jsonwebtoken';
|
|
4
|
-
|
|
5
|
-
import type { Socket } from 'socket.io';
|
|
6
|
-
|
|
7
|
-
export class UnauthorizedError extends Error {
|
|
8
|
-
inner: { message: string };
|
|
9
|
-
data: { message: string; code: string; type: 'UnauthorizedError' };
|
|
10
|
-
|
|
11
|
-
constructor(code: string, error: { message: string }) {
|
|
12
|
-
super(error.message);
|
|
13
|
-
|
|
14
|
-
this.name = 'UnauthorizedError';
|
|
15
|
-
this.inner = error;
|
|
16
|
-
this.data = {
|
|
17
|
-
message: this.message,
|
|
18
|
-
code,
|
|
19
|
-
type: 'UnauthorizedError',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const isUnauthorizedError = (error: unknown): error is UnauthorizedError => {
|
|
27
|
-
return (
|
|
28
|
-
typeof error === 'object' &&
|
|
29
|
-
error != null &&
|
|
30
|
-
'data' in error &&
|
|
31
|
-
typeof error.data === 'object' &&
|
|
32
|
-
error.data != null &&
|
|
33
|
-
'type' in error.data &&
|
|
34
|
-
error.data.type === 'UnauthorizedError'
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
declare module 'socket.io' {
|
|
39
|
-
interface Socket extends ExtendedSocket {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface ExtendedSocket {
|
|
43
|
-
encodedToken?: string;
|
|
44
|
-
decodedToken?: any;
|
|
45
|
-
user?: any;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type SocketIOMiddleware = (socket: Socket, next: (error?: UnauthorizedError) => void) => void;
|
|
49
|
-
|
|
50
|
-
interface CompleteDecodedToken {
|
|
51
|
-
header: {
|
|
52
|
-
alg: Algorithm;
|
|
53
|
-
[key: string]: any;
|
|
54
|
-
};
|
|
55
|
-
payload: any;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type SecretCallback = (decodedToken: CompleteDecodedToken) => Promise<string> | string;
|
|
59
|
-
|
|
60
|
-
export interface AuthorizeOptions {
|
|
61
|
-
secret: string | SecretCallback;
|
|
62
|
-
algorithms?: Algorithm[];
|
|
63
|
-
onAuthentication?: (decodedToken: any) => Promise<any>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const authorize = (options: AuthorizeOptions): SocketIOMiddleware => {
|
|
67
|
-
const { secret, algorithms = ['HS256'], onAuthentication } = options;
|
|
68
|
-
|
|
69
|
-
return async (socket, next) => {
|
|
70
|
-
let encodedToken: string | null = null;
|
|
71
|
-
let token: string | null = null;
|
|
72
|
-
|
|
73
|
-
if (socket.handshake.auth) {
|
|
74
|
-
token = socket.handshake.auth.token;
|
|
75
|
-
} else {
|
|
76
|
-
token = socket.handshake.headers.authorization ?? null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (token != null) {
|
|
80
|
-
const tokenSplitted = token.split(' ');
|
|
81
|
-
|
|
82
|
-
if (tokenSplitted.length !== 2 || tokenSplitted[0] !== 'Bearer') {
|
|
83
|
-
return next(
|
|
84
|
-
new UnauthorizedError('credentials_bad_format', {
|
|
85
|
-
message: 'Format is Authorization: Bearer [token]',
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
encodedToken = tokenSplitted[1];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (encodedToken == null) {
|
|
94
|
-
return next(
|
|
95
|
-
new UnauthorizedError('credentials_required', {
|
|
96
|
-
message: 'no token provided',
|
|
97
|
-
}),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
socket.encodedToken = encodedToken;
|
|
102
|
-
|
|
103
|
-
let keySecret: string | null = null;
|
|
104
|
-
let decodedToken: any = null;
|
|
105
|
-
|
|
106
|
-
if (typeof secret === 'string') {
|
|
107
|
-
keySecret = secret;
|
|
108
|
-
} else {
|
|
109
|
-
const completeDecodedToken = jwt.decode(encodedToken, { complete: true });
|
|
110
|
-
|
|
111
|
-
keySecret = await secret(completeDecodedToken as CompleteDecodedToken);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
decodedToken = jwt.verify(encodedToken, keySecret, { algorithms });
|
|
116
|
-
} catch {
|
|
117
|
-
return next(
|
|
118
|
-
new UnauthorizedError('invalid_token', {
|
|
119
|
-
message: 'Unauthorized: Token is missing or invalid Bearer',
|
|
120
|
-
}),
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
socket.decodedToken = decodedToken;
|
|
125
|
-
|
|
126
|
-
if (onAuthentication != null) {
|
|
127
|
-
try {
|
|
128
|
-
socket.user = await onAuthentication(decodedToken);
|
|
129
|
-
} catch (error: any) {
|
|
130
|
-
return next(error);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return next();
|
|
135
|
-
};
|
|
136
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fp from 'fastify-plugin';
|
|
2
|
-
|
|
3
|
-
import type { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify';
|
|
4
|
-
|
|
5
|
-
export const HeaderPlugin: FastifyPluginAsync = fp(async (app: FastifyInstance) => {
|
|
6
|
-
app.addHook('onRequest', (req: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => {
|
|
7
|
-
reply.headers({
|
|
8
|
-
'Cache-Control': 'no-store, max-age=0, must-revalidate',
|
|
9
|
-
Expires: '0',
|
|
10
|
-
Pragma: 'no-cache',
|
|
11
|
-
'Surrogate-Control': 'no-store',
|
|
12
|
-
});
|
|
13
|
-
done();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import ac from 'ansicolor';
|
|
2
|
-
import fp from 'fastify-plugin';
|
|
3
|
-
import { container } from 'tsyringe';
|
|
4
|
-
|
|
5
|
-
import type { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
|
6
|
-
import type { LoggerService } from '../../services/logger/index.js';
|
|
7
|
-
|
|
8
|
-
declare module 'fastify' {
|
|
9
|
-
interface FastifyReply {
|
|
10
|
-
startTime: number;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const LoggerPlugin: FastifyPluginAsync = fp(async (app: FastifyInstance) => {
|
|
15
|
-
const logger = container.resolve<LoggerService>('logger');
|
|
16
|
-
|
|
17
|
-
app.addHook('onRequest', (req, reply, done) => {
|
|
18
|
-
reply.startTime = Date.now();
|
|
19
|
-
done();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
app.addHook('onResponse', (req, reply, done) => {
|
|
23
|
-
const color =
|
|
24
|
-
reply.statusCode >= 500
|
|
25
|
-
? 'lightRed'
|
|
26
|
-
: reply.statusCode >= 400
|
|
27
|
-
? 'lightYellow'
|
|
28
|
-
: reply.statusCode >= 300
|
|
29
|
-
? 'lightCyan'
|
|
30
|
-
: reply.statusCode >= 200
|
|
31
|
-
? 'lightGreen'
|
|
32
|
-
: 'darkGray';
|
|
33
|
-
|
|
34
|
-
const method = ac.blue(req.method);
|
|
35
|
-
const url = ac.darkGray(req.url);
|
|
36
|
-
const status = ac[color](reply.statusCode);
|
|
37
|
-
const durationMs = ac.darkGray(`${Date.now() - reply.startTime}ms`);
|
|
38
|
-
const contentLength = ac.darkGray((reply.getHeader('content-length') ?? '').toString());
|
|
39
|
-
|
|
40
|
-
logger.trace(`${method} ${url} ${status} ${durationMs} - ${contentLength}`);
|
|
41
|
-
|
|
42
|
-
done();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import fp from 'fastify-plugin';
|
|
2
|
-
import { container } from 'tsyringe';
|
|
3
|
-
import { WebSocket, WebSocketServer } from 'ws';
|
|
4
|
-
|
|
5
|
-
import { AuthService } from '../services/auth.service.js';
|
|
6
|
-
|
|
7
|
-
import type { FastifyInstance, FastifyPluginAsync, HookHandlerDoneFunction } from 'fastify';
|
|
8
|
-
import type { IncomingMessage } from 'http';
|
|
9
|
-
import type { Duplex } from 'node:stream';
|
|
10
|
-
import type { ClientOptions, RawData } from 'ws';
|
|
11
|
-
import type { ProxyServer } from '../../rpc/index.js';
|
|
12
|
-
import type { ConfigService } from '../../services/config/index.js';
|
|
13
|
-
import type { Database } from '../database/index.js';
|
|
14
|
-
import type { JwtTokenEncoded } from '../types/index.js';
|
|
15
|
-
|
|
16
|
-
export interface ProxyTLSOptions {
|
|
17
|
-
cert: string | Buffer;
|
|
18
|
-
key: string | Buffer;
|
|
19
|
-
ca: string | Buffer;
|
|
20
|
-
rejectUnauthorized?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface ProxyOptions {
|
|
24
|
-
upstream: string;
|
|
25
|
-
prefix: string;
|
|
26
|
-
target: 'nats' | 'go2rtc';
|
|
27
|
-
tls?: ProxyTLSOptions;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function isValidCloseCode(code: number): boolean {
|
|
31
|
-
return (code >= 1000 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006) || (code >= 3000 && code <= 4999);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
class WebSocketProxy {
|
|
35
|
-
private wss: WebSocketServer;
|
|
36
|
-
private upstream: string;
|
|
37
|
-
private prefix: string;
|
|
38
|
-
private target: 'nats' | 'go2rtc';
|
|
39
|
-
private tlsConfig?: ProxyTLSOptions;
|
|
40
|
-
private dbs: Database;
|
|
41
|
-
private proxy: ProxyServer;
|
|
42
|
-
private configService: ConfigService;
|
|
43
|
-
|
|
44
|
-
constructor(fastify: FastifyInstance, options: ProxyOptions) {
|
|
45
|
-
this.dbs = container.resolve<Database>('dbs');
|
|
46
|
-
this.proxy = container.resolve<ProxyServer>('proxy');
|
|
47
|
-
this.configService = container.resolve<ConfigService>('configService');
|
|
48
|
-
|
|
49
|
-
this.upstream = options.upstream;
|
|
50
|
-
this.prefix = options.prefix;
|
|
51
|
-
this.target = options.target;
|
|
52
|
-
|
|
53
|
-
if (options.tls) {
|
|
54
|
-
this.tlsConfig = {
|
|
55
|
-
cert: options.tls.cert,
|
|
56
|
-
key: options.tls.key,
|
|
57
|
-
ca: options.tls.ca,
|
|
58
|
-
rejectUnauthorized: options.tls.rejectUnauthorized ?? true,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.wss = new WebSocketServer({
|
|
63
|
-
noServer: true,
|
|
64
|
-
perMessageDeflate: false,
|
|
65
|
-
maxPayload: 100 * 1024 * 1024, // 100MB
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
fastify.server.on('upgrade', (request, socket, head) => {
|
|
69
|
-
const pathname = new URL(request.url!, `http://${request.headers.host}`).pathname;
|
|
70
|
-
if (pathname.startsWith(this.prefix)) {
|
|
71
|
-
this.handleUpgrade(request, socket, head);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public close(): void {
|
|
77
|
-
this.wss.removeAllListeners();
|
|
78
|
-
this.wss.close();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
private async handleUpgrade(request: IncomingMessage, socket: Duplex, head: Buffer): Promise<void> {
|
|
82
|
-
try {
|
|
83
|
-
const authService = new AuthService();
|
|
84
|
-
const url = new URL(request.url!, `http://${request.headers.host}`);
|
|
85
|
-
const token = url.searchParams.get('token') ?? '';
|
|
86
|
-
const tokenValid = authService.checkToken(token);
|
|
87
|
-
|
|
88
|
-
if (!tokenValid) {
|
|
89
|
-
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
|
|
90
|
-
socket.destroy();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let targetUrl = this.upstream;
|
|
95
|
-
if (this.target === 'go2rtc') {
|
|
96
|
-
const source = url.searchParams.get('src') ?? '';
|
|
97
|
-
targetUrl += `?src=${source}`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const wsOptions: ClientOptions = {
|
|
101
|
-
perMessageDeflate: false,
|
|
102
|
-
maxPayload: 100 * 1024 * 1024,
|
|
103
|
-
headers: {
|
|
104
|
-
...Object.fromEntries(Object.entries(request.headers).filter(([, value]) => typeof value === 'string')),
|
|
105
|
-
host: new URL(this.upstream).host,
|
|
106
|
-
},
|
|
107
|
-
ca: this.tlsConfig?.ca,
|
|
108
|
-
cert: this.tlsConfig?.cert,
|
|
109
|
-
key: this.tlsConfig?.key,
|
|
110
|
-
rejectUnauthorized: this.tlsConfig?.rejectUnauthorized,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// Connect to the server
|
|
114
|
-
const serverWs = new WebSocket(targetUrl, wsOptions);
|
|
115
|
-
|
|
116
|
-
// Wait for the connection to be established
|
|
117
|
-
await new Promise<void>((resolve, reject) => {
|
|
118
|
-
serverWs.once('open', () => resolve());
|
|
119
|
-
serverWs.once('error', reject);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Upgrade the connection
|
|
123
|
-
this.wss.handleUpgrade(request, socket, head, (clientWs) => {
|
|
124
|
-
this.proxyWebSockets(clientWs, serverWs);
|
|
125
|
-
});
|
|
126
|
-
} catch (error) {
|
|
127
|
-
socket.write('HTTP/1.1 500 Internal Server Error\r\n\r\n');
|
|
128
|
-
socket.destroy(error);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private proxyWebSockets(client: WebSocket, server: WebSocket): void {
|
|
133
|
-
let connectHandled = false;
|
|
134
|
-
|
|
135
|
-
// Client -> Server
|
|
136
|
-
client.on('message', (data, isBinary) => {
|
|
137
|
-
if (server.readyState === WebSocket.OPEN) {
|
|
138
|
-
if (!connectHandled && this.target === 'nats') {
|
|
139
|
-
try {
|
|
140
|
-
const messageStr = this.extractMessage(data);
|
|
141
|
-
if (messageStr.startsWith('CONNECT ')) {
|
|
142
|
-
const jsonStr = messageStr.slice(8);
|
|
143
|
-
const connectData = JSON.parse(jsonStr);
|
|
144
|
-
|
|
145
|
-
connectData.user = this.proxy.auth.server.user;
|
|
146
|
-
connectData.pass = this.proxy.auth.server.password;
|
|
147
|
-
connectData.tls = {
|
|
148
|
-
cert: this.configService.ssl.cert,
|
|
149
|
-
key: this.configService.ssl.key,
|
|
150
|
-
ca: this.configService.ssl.ca,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
server.send(Buffer.from(`CONNECT${JSON.stringify(connectData)}\r\n`), { binary: isBinary });
|
|
154
|
-
connectHandled = true;
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
} catch (err) {
|
|
158
|
-
console.error('Error handling CONNECT message:', err);
|
|
159
|
-
}
|
|
160
|
-
connectHandled = true;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
server.send(data, { binary: isBinary });
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
client.on('ping', (data) => {
|
|
168
|
-
if (server.readyState === WebSocket.OPEN) {
|
|
169
|
-
server.ping(data);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
client.on('pong', (data) => {
|
|
174
|
-
if (server.readyState === WebSocket.OPEN) {
|
|
175
|
-
server.pong(data);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
client.on('close', (code, reason) => {
|
|
180
|
-
if (server.readyState === WebSocket.OPEN) {
|
|
181
|
-
const safeCode = isValidCloseCode(code) ? code : 1000;
|
|
182
|
-
server.close(safeCode, reason);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
client.on('error', (error) => {
|
|
187
|
-
if (server.readyState === WebSocket.OPEN) {
|
|
188
|
-
server.close(1011, `Client error: ${error.message}`);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// Server -> Client
|
|
193
|
-
server.on('message', (data, isBinary) => {
|
|
194
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
195
|
-
client.send(data, { binary: isBinary });
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
server.on('ping', (data) => {
|
|
200
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
201
|
-
client.ping(data);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
server.on('pong', (data) => {
|
|
206
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
207
|
-
client.pong(data);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
server.on('close', (code, reason) => {
|
|
212
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
213
|
-
const safeCode = isValidCloseCode(code) ? code : 1000;
|
|
214
|
-
client.close(safeCode, reason);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
server.on('error', (error) => {
|
|
219
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
220
|
-
client.close(1011, `Server error: ${error.message}`);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private extractMessage(data: RawData): string {
|
|
226
|
-
if (Buffer.isBuffer(data)) {
|
|
227
|
-
return data.toString('utf-8');
|
|
228
|
-
}
|
|
229
|
-
if (Array.isArray(data)) {
|
|
230
|
-
return Buffer.concat(data).toString('utf-8');
|
|
231
|
-
}
|
|
232
|
-
if (data instanceof ArrayBuffer) {
|
|
233
|
-
return Buffer.from(data).toString('utf-8');
|
|
234
|
-
}
|
|
235
|
-
throw new Error('Unsupported data type');
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private findByToken(access_token: string): JwtTokenEncoded | undefined {
|
|
239
|
-
const { tokens } = this.dbs.authDB.get('auth') ?? { tokens: [], clients: [] };
|
|
240
|
-
return tokens.find((jwtToken) => jwtToken.access_token === access_token);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export const ProxyPlugin: FastifyPluginAsync<ProxyOptions> = fp(async (app: FastifyInstance, options: ProxyOptions) => {
|
|
245
|
-
if (!options.upstream) {
|
|
246
|
-
throw new Error('upstream must be specified');
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const ws = new WebSocketProxy(app, options);
|
|
250
|
-
|
|
251
|
-
app.addHook('preClose', (done: HookHandlerDoneFunction) => {
|
|
252
|
-
ws.close();
|
|
253
|
-
done();
|
|
254
|
-
});
|
|
255
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import fp from 'fastify-plugin';
|
|
2
|
-
|
|
3
|
-
import { SocketService } from '../websocket/index.js';
|
|
4
|
-
|
|
5
|
-
import type { FastifyInstance, FastifyPluginAsync, HookHandlerDoneFunction } from 'fastify';
|
|
6
|
-
import type { Server, ServerOptions } from 'socket.io';
|
|
7
|
-
|
|
8
|
-
declare module 'fastify' {
|
|
9
|
-
interface FastifyInstance {
|
|
10
|
-
io: Server;
|
|
11
|
-
}
|
|
12
|
-
interface FastifyRequest {
|
|
13
|
-
io: Server;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const SocketIoPlugin: FastifyPluginAsync<Partial<ServerOptions>> = fp(async (app: FastifyInstance, opts: Partial<ServerOptions>) => {
|
|
18
|
-
const socketService = new SocketService(app, opts);
|
|
19
|
-
|
|
20
|
-
app.decorate('io', socketService.io);
|
|
21
|
-
app.decorateRequest('io', { getter: () => socketService.io });
|
|
22
|
-
|
|
23
|
-
app.addHook('preClose', (done: HookHandlerDoneFunction) => {
|
|
24
|
-
socketService.io.close();
|
|
25
|
-
|
|
26
|
-
done();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fp from 'fastify-plugin';
|
|
2
|
-
import { container } from 'tsyringe';
|
|
3
|
-
|
|
4
|
-
import type { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
|
5
|
-
import type { Go2Rtc } from '../../go2rtc/index.js';
|
|
6
|
-
import type { CameraUi } from '../../main.js';
|
|
7
|
-
|
|
8
|
-
declare module 'fastify' {
|
|
9
|
-
interface FastifyInstance {
|
|
10
|
-
system: System;
|
|
11
|
-
}
|
|
12
|
-
interface FastifyRequest {
|
|
13
|
-
system: System;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class System {
|
|
18
|
-
private app: FastifyInstance;
|
|
19
|
-
|
|
20
|
-
private cameraui: CameraUi;
|
|
21
|
-
private go2rtc: Go2Rtc;
|
|
22
|
-
|
|
23
|
-
constructor(app: FastifyInstance) {
|
|
24
|
-
this.app = app;
|
|
25
|
-
|
|
26
|
-
this.cameraui = container.resolve<CameraUi>('cameraui');
|
|
27
|
-
this.go2rtc = container.resolve<Go2Rtc>('go2rtc');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public close(): void {
|
|
31
|
-
process.kill(process.pid, 'SIGTERM');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public async restart(): Promise<void> {
|
|
35
|
-
await this.cameraui.restart();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public async restartGo2rtc(): Promise<void> {
|
|
39
|
-
await this.go2rtc.restart();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const SystemPlugin: FastifyPluginAsync = fp(async (app: FastifyInstance) => {
|
|
44
|
-
const systemController = new System(app);
|
|
45
|
-
|
|
46
|
-
app.decorate('system', systemController);
|
|
47
|
-
app.decorateRequest('system', { getter: () => systemController });
|
|
48
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import useragent from 'express-useragent';
|
|
2
|
-
import fp from 'fastify-plugin';
|
|
3
|
-
|
|
4
|
-
import type { Details } from 'express-useragent';
|
|
5
|
-
import type { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest, HookHandlerDoneFunction } from 'fastify';
|
|
6
|
-
|
|
7
|
-
declare module 'fastify' {
|
|
8
|
-
interface FastifyRequest {
|
|
9
|
-
useragent?: Details;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const UserAgentPlugin: FastifyPluginAsync = fp(async (app: FastifyInstance) => {
|
|
14
|
-
app.addHook('onRequest', (req: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => {
|
|
15
|
-
const source = req.headers['user-agent'];
|
|
16
|
-
req.useragent = source ? useragent.parse(source) : undefined;
|
|
17
|
-
done();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ApiController } from '../controllers/api.controller.js';
|
|
2
|
-
|
|
3
|
-
import type { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
|
4
|
-
|
|
5
|
-
export const ApiRoute: FastifyPluginAsync = async (app: FastifyInstance): Promise<void> => {
|
|
6
|
-
const apiController = new ApiController(app);
|
|
7
|
-
|
|
8
|
-
app.get('/', apiController.welcome.bind(apiController));
|
|
9
|
-
app.get('/health', apiController.health.bind(apiController));
|
|
10
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { AuthController } from '../controllers/auth.controller.js';
|
|
2
|
-
import { onlyAdminCanDoThisAction } from '../middlewares/authPermission.middleware.js';
|
|
3
|
-
import { isPasswordAndUserMatch, validJWTNeeded } from '../middlewares/authValidation.middleware.js';
|
|
4
|
-
import { pages } from '../middlewares/pagination.middleware.js';
|
|
5
|
-
import { loginUserSchema } from '../schemas/users.schema.js';
|
|
6
|
-
|
|
7
|
-
import type { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
|
8
|
-
import type { ZodTypeProvider } from 'fastify-type-provider-zod';
|
|
9
|
-
|
|
10
|
-
export const AuthRoute: FastifyPluginAsync = async (app: FastifyInstance): Promise<void> => {
|
|
11
|
-
const authController = new AuthController(app);
|
|
12
|
-
|
|
13
|
-
app.route({
|
|
14
|
-
url: '/check',
|
|
15
|
-
method: 'GET',
|
|
16
|
-
preValidation: [validJWTNeeded],
|
|
17
|
-
handler: authController.check.bind(authController),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
app.route({
|
|
21
|
-
url: '/tokens',
|
|
22
|
-
method: 'GET',
|
|
23
|
-
preValidation: [validJWTNeeded, onlyAdminCanDoThisAction],
|
|
24
|
-
preSerialization: [pages],
|
|
25
|
-
handler: authController.list.bind(authController),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
app.withTypeProvider<ZodTypeProvider>().route({
|
|
29
|
-
url: '/login',
|
|
30
|
-
method: 'POST',
|
|
31
|
-
preValidation: [isPasswordAndUserMatch],
|
|
32
|
-
handler: authController.login.bind(authController),
|
|
33
|
-
schema: {
|
|
34
|
-
body: loginUserSchema,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
app.route({
|
|
39
|
-
url: '/logout',
|
|
40
|
-
method: 'POST',
|
|
41
|
-
handler: authController.logout.bind(authController),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
app.route({
|
|
45
|
-
url: '/logout/:id',
|
|
46
|
-
method: 'POST',
|
|
47
|
-
preValidation: [validJWTNeeded, onlyAdminCanDoThisAction],
|
|
48
|
-
handler: authController.logoutByToken.bind(authController),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
app.route({
|
|
52
|
-
url: '/refresh',
|
|
53
|
-
method: 'POST',
|
|
54
|
-
handler: authController.refresh.bind(authController),
|
|
55
|
-
});
|
|
56
|
-
};
|