diff --git a/APP_UI/package-lock.json b/APP_UI/package-lock.json index b65b590..7bcd138 100644 --- a/APP_UI/package-lock.json +++ b/APP_UI/package-lock.json @@ -20,7 +20,8 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^6.0.1", - "vite": "^7.2.4" + "vite": "^7.2.4", + "vitest": "^3.2.4" } }, "node_modules/@babel/helper-string-parser": { @@ -1196,6 +1197,24 @@ "win32" ] }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -1220,6 +1239,131 @@ "vue": "^3.2.25" } }, + "node_modules/@vitest/expect": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.7.tgz", + "integrity": "sha512-E8eBXaKibuvH2pSZErOjdVb5vF4PbKYcrnluBTYxEk1l/VhhwZg1kZQsdtjq+CsF5CFydf2Rdkz7jDHKSisi3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.7", + "@vitest/utils": "3.2.7", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.7.tgz", + "integrity": "sha512-Trr0hYO9CM3Wj6ksWHRhK9IZpIY6wTMO5u/MqXurMxT57sWBaOPEtP3Oq60ihZuh5JsiagKfz95OcxdEP6dBrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.2.7", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/mocker/node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/@vitest/pretty-format": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.7.tgz", + "integrity": "sha512-KUHlwqVu0sRlhCdyPdQ/wBoTfRahjUky1MubOmYw9fWfIZy1gNoHpuaaQBPAaMaVYdQYHJLurzj8ECCj5OwTqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.7.tgz", + "integrity": "sha512-sB9y4ovltoQP+WaUPwmSxO9WIg9Ig694Di5PalVPsYHklAdE027mehpWF2SQSVq+k6sFgaivbTjTJwZLSHbedA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.2.7", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.7.tgz", + "integrity": "sha512-7C+MwShwtBSI5Buwoyg3s/iY1eHL9PKAf+O1wVh/TdnjXUtkoL/9YQtre90i4MtNXM6edP1wJ2zOBpfCyhIS7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.7", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.7.tgz", + "integrity": "sha512-Q2eQGI6d2L/hBtZ0qNuKcAGid68XK6cv1xsoaIma6PaJhHPoqcEJhYpXZ/5myCMqkNgtP6UKuBhbc0nHKnrkuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^4.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.7.tgz", + "integrity": "sha512-x6BDOd7dyo3PFLY3I9/HJ25X/6OurhGXk2/B9gOZNPF7XDVjeBK4k01lQE5uvDpbuheErh91qYuE1E2OEjK3Rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.7", + "loupe": "^3.1.4", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/@vue/compiler-core": { "version": "3.5.26", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.26.tgz", @@ -1326,6 +1470,16 @@ "integrity": "sha512-7Z6/y3uFI5PRoKeorTOSXKcDj0MSasfNNltcslbFrPpcw6aXRUALq4IfJlaTRspiWIUOEZbrpM+iQGmCOiWe4A==", "license": "MIT" }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -1375,6 +1529,16 @@ "node": ">=8" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind-apply-helpers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", @@ -1388,6 +1552,23 @@ "node": ">= 0.4" } }, + "node_modules/chai": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", + "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/chart.js": { "version": "4.5.1", "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.5.1.tgz", @@ -1400,6 +1581,16 @@ "pnpm": ">=8" } }, + "node_modules/check-error": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz", + "integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, "node_modules/chokidar": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", @@ -1433,6 +1624,34 @@ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "license": "MIT" }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -1499,6 +1718,13 @@ "node": ">= 0.4" } }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, "node_modules/es-object-atoms": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", @@ -1574,6 +1800,16 @@ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "license": "MIT" }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -1792,6 +2028,20 @@ "node": ">=0.12.0" } }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/loupe": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", + "dev": true, + "license": "MIT" + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -1858,6 +2108,13 @@ "node": ">= 0.6" } }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/nanoid": { "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", @@ -1883,6 +2140,23 @@ "license": "MIT", "optional": true }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -1895,7 +2169,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -2009,7 +2282,6 @@ "resolved": "https://registry.npmjs.org/sass/-/sass-1.97.2.tgz", "integrity": "sha512-y5LWb0IlbO4e97Zr7c3mlpabcbBtS+ieiZ9iwDooShpFKWXf62zz5pEPdwrLYm+Bxn1fnbwFGzHuCLSA9tBmrw==", "license": "MIT", - "peer": true, "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", @@ -2025,6 +2297,13 @@ "@parcel/watcher": "^2.4.1" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -2034,6 +2313,33 @@ "node": ">=0.10.0" } }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-literal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", + "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/sweetalert2": { "version": "11.26.17", "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.26.17.tgz", @@ -2044,6 +2350,20 @@ "url": "https://github.com/sponsors/limonte" } }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", @@ -2061,6 +2381,36 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tinypool": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.6.tgz", + "integrity": "sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2080,7 +2430,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -2150,12 +2499,107 @@ } } }, + "node_modules/vite-node": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.7.tgz", + "integrity": "sha512-KrxIJ62Fd89gfysR4WotlgZABiz2dqFPgqGzX7s+CwsqLFomRH7777ZcrOD6+WVAh7khPQP41A+BKbpcJFrdEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.7", + "@vitest/mocker": "3.2.7", + "@vitest/pretty-format": "^3.2.7", + "@vitest/runner": "3.2.7", + "@vitest/snapshot": "3.2.7", + "@vitest/spy": "3.2.7", + "@vitest/utils": "3.2.7", + "chai": "^5.2.0", + "debug": "^4.4.1", + "expect-type": "^1.2.1", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "picomatch": "^4.0.2", + "std-env": "^3.9.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.2.7", + "@vitest/ui": "3.2.7", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, "node_modules/vue": { "version": "3.5.26", "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz", "integrity": "sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA==", "license": "MIT", - "peer": true, "dependencies": { "@vue/compiler-dom": "3.5.26", "@vue/compiler-sfc": "3.5.26", @@ -2186,6 +2630,23 @@ "peerDependencies": { "vue": "^3.5.0" } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } } } } diff --git a/APP_UI/package.json b/APP_UI/package.json index 6d5e61c..5b95f2c 100644 --- a/APP_UI/package.json +++ b/APP_UI/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "vite", "build": "vite build", - "preview": "vite preview" + "preview": "vite preview", + "test": "vitest run" }, "dependencies": { "@fortawesome/fontawesome-free": "^7.1.0", @@ -21,6 +22,7 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^6.0.1", - "vite": "^7.2.4" + "vite": "^7.2.4", + "vitest": "^3.2.4" } } diff --git a/APP_UI/src/composables/useApi.js b/APP_UI/src/composables/useApi.js index ad7dcc6..9bc90d2 100644 --- a/APP_UI/src/composables/useApi.js +++ b/APP_UI/src/composables/useApi.js @@ -9,6 +9,23 @@ const profilesApiClient = axios.create(); const getBaseUrl = (config) => config?.api_base_url || 'http://localhost:5001/api/v1'; const getProfilesBaseUrl = (config) => config?.profiles_api_base_url || 'http://localhost:8000'; +// Auth endpoints answer 401 for a wrong current password or 2FA code (change-password, change-username): +// that is a form error, not an expired session, so it must not log the user out. +export const isAuthRequest = (url) => /(^|\/)auth\//.test(url || ''); + +// 401 on a regular API request: the session is gone, clear it and go to the login page +export const handleUnauthorized = (error) => { + if (error.response && error.response.status === 401 && !isAuthRequest(error.config?.url)) { + localStorage.removeItem('ovpmon_token'); + localStorage.removeItem('ovpmon_user'); + // Redirecting using window.location for absolute refresh + if (window.location.pathname !== '/login') { + window.location.href = '/login'; + } + } + return Promise.reject(error); +}; + // Add interceptors to handle Auth and Dynamic Base URLs const setupInterceptors = (instance, getBase) => { instance.interceptors.request.use((reqConfig) => { @@ -22,20 +39,7 @@ const setupInterceptors = (instance, getBase) => { return reqConfig; }); - instance.interceptors.response.use( - response => response, - error => { - if (error.response && error.response.status === 401) { - localStorage.removeItem('ovpmon_token'); - localStorage.removeItem('ovpmon_user'); - // Redirecting using window.location for absolute refresh - if (window.location.pathname !== '/login') { - window.location.href = '/login'; - } - } - return Promise.reject(error); - } - ); + instance.interceptors.response.use(response => response, handleUnauthorized); }; setupInterceptors(apiClient, getBaseUrl); @@ -59,10 +63,10 @@ export function useApi() { const fetchCertificates = async () => { const res = await profilesApiClient.get('/profiles'); - return res.data; + // GET /profiles returns a plain array (not the {success, data} envelope of the monitoring API) + return Array.isArray(res.data) ? res.data : []; }; - return { apiClient, profilesApiClient, diff --git a/APP_UI/src/composables/useApi.test.js b/APP_UI/src/composables/useApi.test.js new file mode 100644 index 0000000..8d7c211 --- /dev/null +++ b/APP_UI/src/composables/useApi.test.js @@ -0,0 +1,48 @@ +import { describe, it, expect, beforeEach, vi } from 'vitest'; +import { AxiosError } from 'axios'; + +const store = {}; +let location; + +beforeEach(() => { + for (const k of Object.keys(store)) delete store[k]; + store.ovpmon_token = 'tok'; + store.ovpmon_user = 'admin'; + location = { pathname: '/account', href: '/account' }; + vi.stubGlobal('localStorage', { + getItem: (k) => (k in store ? store[k] : null), + setItem: (k, v) => { store[k] = String(v); }, + removeItem: (k) => { delete store[k]; } + }); + vi.stubGlobal('window', { location }); +}); + +// Make the client answer with the given status without any network +const failWith = async (client, status, url) => { + client.defaults.adapter = (config) => Promise.reject( + new AxiosError('failed', 'ERR_BAD_REQUEST', config, null, { status, data: {}, config }) + ); + await client.post(url).catch(() => {}); +}; + +describe('401 handling', () => { + it('keeps the session on 401 from /auth/* (wrong password or 2FA code)', async () => { + const { useApi } = await import('./useApi'); + await failWith(useApi().apiClient, 401, '../auth/change-password'); + expect(store.ovpmon_token).toBe('tok'); + expect(location.href).toBe('/account'); + }); + + it('ends the session on 401 from other requests', async () => { + const { useApi } = await import('./useApi'); + await failWith(useApi().apiClient, 401, '/stats'); + expect(store.ovpmon_token).toBeUndefined(); + expect(location.href).toBe('/login'); + }); + + it('ignores other error codes', async () => { + const { useApi } = await import('./useApi'); + await failWith(useApi().profilesApiClient, 500, '/profiles'); + expect(store.ovpmon_token).toBe('tok'); + }); +}); diff --git a/APP_UI/src/composables/useFormatters.js b/APP_UI/src/composables/useFormatters.js index 8533bf7..70e2783 100644 --- a/APP_UI/src/composables/useFormatters.js +++ b/APP_UI/src/composables/useFormatters.js @@ -1,15 +1,17 @@ export function useFormatters() { function formatBytes(bytes, decimals = 2) { - if (bytes === 0) return '0 B'; + const value = Number(bytes); + // null, undefined, NaN and negative values are shown as zero + if (!Number.isFinite(value) || value <= 0) return '0 B'; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; - const i = Math.floor(Math.log(bytes) / Math.log(k)); - return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; + const i = Math.min(Math.max(Math.floor(Math.log(value) / Math.log(k)), 0), sizes.length - 1); + return parseFloat((value / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; } function formatRate(rate) { - return parseFloat(rate).toFixed(3) + ' Mbps'; + return (parseFloat(rate) || 0).toFixed(3) + ' Mbps'; } function parseServerDate(dateStr) { diff --git a/APP_UI/src/composables/useFormatters.test.js b/APP_UI/src/composables/useFormatters.test.js new file mode 100644 index 0000000..2e355b0 --- /dev/null +++ b/APP_UI/src/composables/useFormatters.test.js @@ -0,0 +1,29 @@ +import { describe, it, expect } from 'vitest'; +import { useFormatters } from './useFormatters'; + +const { formatBytes, formatRate } = useFormatters(); + +describe('formatBytes', () => { + it('formats regular values', () => { + expect(formatBytes(1536)).toBe('1.5 KB'); + expect(formatBytes(5 * 1024 * 1024)).toBe('5 MB'); + }); + + it('shows zero for empty, non-numeric and negative values', () => { + for (const v of [0, null, undefined, NaN, 'abc', -5, Infinity]) { + expect(formatBytes(v)).toBe('0 B'); + } + }); + + it('stays inside the unit table', () => { + expect(formatBytes(0.5)).toBe('0.5 B'); + expect(formatBytes(Math.pow(1024, 6))).toMatch(/ TB$/); + }); +}); + +describe('formatRate', () => { + it('does not produce NaN', () => { + expect(formatRate(1.23456)).toBe('1.235 Mbps'); + expect(formatRate(null)).toBe('0.000 Mbps'); + }); +}); diff --git a/APP_UI/src/utils/cidr.js b/APP_UI/src/utils/cidr.js new file mode 100644 index 0000000..9b98199 --- /dev/null +++ b/APP_UI/src/utils/cidr.js @@ -0,0 +1,34 @@ +// IPv4 helpers for the VPN subnet field: "a.b.c.d/nn" <-> network address + dotted netmask. + +const IPV4 = /^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/; + +// 24 -> '255.255.255.0'; null for a value outside 0..32 +export function cidrToMask(bits) { + const n = Number(bits); + if (bits === '' || bits === null || !Number.isInteger(n) || n < 0 || n > 32) return null; + const mask = n === 0 ? 0 : (0xFFFFFFFF << (32 - n)) >>> 0; + return [24, 16, 8, 0].map(shift => (mask >>> shift) & 255).join('.'); +} + +// '255.255.255.0' -> 24; null for a malformed or non-contiguous mask +export function maskToCidr(mask) { + if (typeof mask !== 'string' || !IPV4.test(mask)) return null; + const value = mask.split('.').reduce((acc, p) => ((acc << 8) | Number(p)) >>> 0, 0); + let bits = 0; + while (bits < 32 && (value & (0x80000000 >>> bits))) bits++; + // The rest must be zeros, otherwise the mask is not contiguous + const expected = bits === 0 ? 0 : (0xFFFFFFFF << (32 - bits)) >>> 0; + return value === expected ? bits : null; +} + +// '172.20.1.0/24' -> { network: '172.20.1.0', netmask: '255.255.255.0' } +// '172.20.1.0' -> { network: '172.20.1.0', netmask: null } (no suffix: the caller keeps the current mask) +// anything else -> null +export function parseCidr(value) { + const text = String(value ?? '').trim(); + const [network, suffix, ...rest] = text.split('/'); + if (rest.length || !IPV4.test(network)) return null; + if (suffix === undefined) return { network, netmask: null }; + const netmask = cidrToMask(suffix); + return netmask ? { network, netmask } : null; +} diff --git a/APP_UI/src/utils/cidr.test.js b/APP_UI/src/utils/cidr.test.js new file mode 100644 index 0000000..addb561 --- /dev/null +++ b/APP_UI/src/utils/cidr.test.js @@ -0,0 +1,36 @@ +import { describe, it, expect } from 'vitest'; +import { cidrToMask, maskToCidr, parseCidr } from './cidr'; + +describe('cidrToMask / maskToCidr', () => { + it('converts a suffix to a netmask and back', () => { + for (const [bits, mask] of [[8, '255.0.0.0'], [22, '255.255.252.0'], [24, '255.255.255.0'], [30, '255.255.255.252']]) { + expect(cidrToMask(bits)).toBe(mask); + expect(maskToCidr(mask)).toBe(bits); + } + expect(cidrToMask(0)).toBe('0.0.0.0'); + expect(cidrToMask(32)).toBe('255.255.255.255'); + }); + + it('rejects out-of-range suffixes and non-contiguous masks', () => { + for (const v of [-1, 33, 'x', '', null]) expect(cidrToMask(v)).toBeNull(); + expect(maskToCidr('255.0.255.0')).toBeNull(); + expect(maskToCidr('255.255.255')).toBeNull(); + }); +}); + +describe('parseCidr', () => { + it('splits the address and the mask', () => { + expect(parseCidr('172.20.1.0/24')).toEqual({ network: '172.20.1.0', netmask: '255.255.255.0' }); + expect(parseCidr(' 10.8.0.0/22 ')).toEqual({ network: '10.8.0.0', netmask: '255.255.252.0' }); + }); + + it('keeps the mask empty when there is no suffix', () => { + expect(parseCidr('10.8.0.0')).toEqual({ network: '10.8.0.0', netmask: null }); + }); + + it('rejects malformed input', () => { + for (const v of ['', 'abc', '10.8.0.0/', '10.8.0.0/33', '10.8.0/24', '300.1.1.1/24', '10.8.0.0/24/1']) { + expect(parseCidr(v)).toBeNull(); + } + }); +}); diff --git a/APP_UI/src/views/Analytics.vue b/APP_UI/src/views/Analytics.vue index 23e9b22..d270fb8 100644 --- a/APP_UI/src/views/Analytics.vue +++ b/APP_UI/src/views/Analytics.vue @@ -201,17 +201,16 @@ const loadAnalytics = async () => { const loadCerts = async () => { loading.certs = true; try { - const res = await fetchCertificates(); - if(res.success && Array.isArray(res.data)) { - const list = res.data.filter(cert => { - // Only active, non-revoked, and expiring soon (within 45 days) - return !cert.is_revoked && !cert.is_expired && - cert.days_remaining !== null && cert.days_remaining <= 45; - }); - - kpi.expiringCerts = list.length; - expiringCertsList.value = list.sort((a,b) => (a.days_remaining || 0) - (b.days_remaining || 0)); - } + // fetchCertificates returns the plain array of profiles + const profiles = await fetchCertificates(); + const list = profiles.filter(cert => { + // Only active, non-revoked, and expiring soon (within 45 days) + return !cert.is_revoked && !cert.is_expired && + cert.days_remaining != null && cert.days_remaining <= 45; + }); + + kpi.expiringCerts = list.length; + expiringCertsList.value = list.sort((a, b) => a.days_remaining - b.days_remaining); } catch (e) { console.error(e); } finally { diff --git a/APP_UI/src/views/Certificates.vue b/APP_UI/src/views/Certificates.vue index d44ba20..89c3d8e 100644 --- a/APP_UI/src/views/Certificates.vue +++ b/APP_UI/src/views/Certificates.vue @@ -234,8 +234,8 @@ const categorized = computed(() => { }); // Sort logic - active.sort((a,b) => (a.days_remaining || 9999) - (b.days_remaining || 9999)); - expired.sort((a,b) => (b.days_remaining || -9999) - (a.days_remaining || -9999)); + active.sort((a,b) => (a.days_remaining ?? 9999) - (b.days_remaining ?? 9999)); + expired.sort((a,b) => (b.days_remaining ?? -9999) - (a.days_remaining ?? -9999)); return { active, expired }; }); diff --git a/APP_UI/src/views/VPNConfig.vue b/APP_UI/src/views/VPNConfig.vue index ef3c3f3..377e344 100644 --- a/APP_UI/src/views/VPNConfig.vue +++ b/APP_UI/src/views/VPNConfig.vue @@ -264,6 +264,7 @@ import { ref, onMounted, reactive, watch } from 'vue'; import { useApi } from '../composables/useApi'; import { useToast } from '../composables/useToast'; import { usePkiStatus } from '../composables/usePkiStatus'; +import { maskToCidr, parseCidr } from '../utils/cidr'; const { profilesApiClient } = useApi(); const toast = useToast(); @@ -302,15 +303,8 @@ watch(isSplitTunnel, (val) => { form.tunnel_type = val ? 'SPLIT' : 'FULL'; }); -// Helpers -function maskToCidr(mask) { - if (!mask) return ''; - const parts = mask.split('.'); - let bits = 0; - const map = {255:8, 254:7, 252:6, 248:5, 240:4, 224:3, 192:2, 128:1, 0:0}; - for(let p of parts) bits += map[parseInt(p)] || 0; - return bits; -} +// Netmask received from the server: used when the subnet is typed without a /nn suffix +let currentNetmask = ''; // Methods const showMessage = (text, type = 'success') => toast.show(text, type); @@ -337,9 +331,10 @@ const loadConfig = async () => { } }); + currentNetmask = data.vpn_netmask || ''; if (data.vpn_network && data.vpn_netmask) { const cidrSuffix = maskToCidr(data.vpn_netmask); - if (cidrSuffix) { + if (cidrSuffix !== null) { form.vpn_network = `${data.vpn_network}/${cidrSuffix}`; } } @@ -351,20 +346,25 @@ const loadConfig = async () => { }; const handleSave = async () => { + // The API takes the address and the netmask separately: without vpn_netmask it resets the mask to 255.255.255.0 + const subnet = parseCidr(form.vpn_network); + if (!subnet) { + showMessage('VPN subnet must be an IPv4 network in CIDR format, e.g. 172.20.1.0/24', 'error'); + return; + } + isLoading.value = true; action.value = 'save'; - + const payload = { ...form }; payload.split_routes = payload.split_routes.filter(r => r && r.trim() !== ''); payload.dns_servers = payload.dns_servers.filter(d => d && d.trim() !== ''); - - if (payload.vpn_network.includes('/')) { - const [ip, suffix] = payload.vpn_network.split('/'); - payload.vpn_network = ip; - } - + payload.vpn_network = subnet.network; + payload.vpn_netmask = subnet.netmask || currentNetmask || '255.255.255.0'; + try { await profilesApiClient.put('/config/server', payload); + currentNetmask = payload.vpn_netmask; showMessage('Server configuration saved!', 'success'); } catch (err) { showMessage(`Error saving: ${err.response?.data?.detail || err.message}`, 'error');