diff --git a/package-lock.json b/package-lock.json index c673008..ce38b34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,15 +32,78 @@ "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.5.0", "globals": "^16.5.0", + "jsdom": "^28.1.0", "typescript": "~5.9.3", "typescript-eslint": "^8.55.0", "vite": "^7.3.1", "vitest": "^4.0.18" }, "engines": { - "node": ">=18" + "node": ">=20.19" } }, + "node_modules/@acemir/cssom": { + "version": "0.9.31", + "resolved": "https://registry.npmjs.org/@acemir/cssom/-/cssom-0.9.31.tgz", + "integrity": "sha512-ZnR3GSaH+/vJ0YlHau21FjfLYjMpYVIzTD8M8vIEQvIGxeOXyXdzCI140rrCY862p/C/BbzWsjc1dgnM9mkoTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@asamuzakjp/css-color": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-4.1.2.tgz", + "integrity": "sha512-NfBUvBaYgKIuq6E/RBLY1m0IohzNHAYyaJGuTK79Z23uNwmz2jl1mPsC5ZxCCxylinKhT1Amn5oNTlx1wN8cQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^3.0.0", + "@csstools/css-color-parser": "^4.0.1", + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0", + "lru-cache": "^11.2.5" + } + }, + "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": { + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@asamuzakjp/dom-selector": { + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-6.8.1.tgz", + "integrity": "sha512-MvRz1nCqW0fsy8Qz4dnLIvhOlMzqDVBabZx6lH+YywFDdjXhMY37SmpV1XFX3JzG5GWHn63j6HX6QPr3lZXHvQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/nwsapi": "^2.3.9", + "bidi-js": "^1.0.3", + "css-tree": "^3.1.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.2.6" + } + }, + "node_modules/@asamuzakjp/dom-selector/node_modules/lru-cache": { + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@asamuzakjp/nwsapi": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/@asamuzakjp/nwsapi/-/nwsapi-2.3.9.tgz", + "integrity": "sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@babel/code-frame": { "version": "7.29.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", @@ -333,6 +396,151 @@ "node": ">=18" } }, + "node_modules/@bramus/specificity": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz", + "integrity": "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-tree": "^3.0.0" + }, + "bin": { + "specificity": "bin/cli.js" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.0.1.tgz", + "integrity": "sha512-NmXRccUJMk2AWA5A7e5a//3bCIMyOu2hAtdRYrhPPHjDxINuCwX1w6rnIZ4xjLcp0ayv6h8Pc3X0eJUGiAAXHQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@csstools/css-calc": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.1.1.tgz", + "integrity": "sha512-HJ26Z/vmsZQqs/o3a6bgKslXGFAungXGbinULZO3eMsOyNJHeBBZfup5FiZInOghgoM4Hwnmw+OgbJCNg1wwUQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.0.1.tgz", + "integrity": "sha512-vYwO15eRBEkeF6xjAno/KQ61HacNhfQuuU/eGwH67DplL0zD5ZixUa563phQvUelA07yDczIXdtmYojCphKJcw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^6.0.1", + "@csstools/css-calc": "^3.0.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.0.tgz", + "integrity": "sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-syntax-patches-for-csstree": { + "version": "1.0.27", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.0.27.tgz", + "integrity": "sha512-sxP33Jwg1bviSUXAV43cVYdmjt2TLnLXNqCWl9xmxHawWVjGz/kEbdkr7F9pxJNBN2Mh+dq0crgItbW6tQvyow==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0" + }, + "node_modules/@csstools/css-tokenizer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.0.tgz", + "integrity": "sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.3", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", @@ -906,6 +1114,24 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@exodus/bytes": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.14.1.tgz", + "integrity": "sha512-OhkBFWI6GcRMUroChZiopRiSp2iAMvEBK47NhJooDqz1RERO4QuZIZnjP63TXX8GAiLABkYmX+fuQsdJ1dd2QQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -2213,6 +2439,16 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -2309,6 +2545,16 @@ "baseline-browser-mapping": "dist/cli.js" } }, + "node_modules/bidi-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz", + "integrity": "sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", @@ -2530,12 +2776,66 @@ "node": ">= 8" } }, + "node_modules/css-tree": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.1.0.tgz", + "integrity": "sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.12.2", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/cssstyle": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-6.0.1.tgz", + "integrity": "sha512-IoJs7La+oFp/AB033wBStxNOJt4+9hHMxsXUPANcoXL2b3W4DZKghlJ2cI/eyeRZIQ9ysvYEorVhjrcYctWbog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^4.1.2", + "@csstools/css-syntax-patches-for-csstree": "^1.0.26", + "css-tree": "^3.1.0", + "lru-cache": "^11.2.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/cssstyle/node_modules/lru-cache": { + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "license": "MIT" }, + "node_modules/data-urls": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-7.0.0.tgz", + "integrity": "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -2553,6 +2853,13 @@ } } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, "node_modules/decode-named-character-reference": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz", @@ -2624,6 +2931,19 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -3165,6 +3485,19 @@ "node": ">=12.0.0" } }, + "node_modules/html-encoding-sniffer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz", + "integrity": "sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.6.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -3182,6 +3515,34 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -3304,6 +3665,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -3379,6 +3747,47 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsdom": { + "version": "28.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-28.1.0.tgz", + "integrity": "sha512-0+MoQNYyr2rBHqO1xilltfDjV9G7ymYGlAUazgcDLQaUf8JDHbuGwsxN6U9qWaElZ4w1B2r7yEGIL3GdeW3Rug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@acemir/cssom": "^0.9.31", + "@asamuzakjp/dom-selector": "^6.8.1", + "@bramus/specificity": "^2.4.2", + "@exodus/bytes": "^1.11.0", + "cssstyle": "^6.0.1", + "data-urls": "^7.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^6.0.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.6", + "is-potential-custom-element-name": "^1.0.1", + "parse5": "^8.0.0", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^6.0.0", + "undici": "^7.21.0", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "canvas": "^3.0.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, "node_modules/jsesc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", @@ -4122,6 +4531,13 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdn-data": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.12.2.tgz", + "integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/micromark": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", @@ -4835,6 +5251,19 @@ "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", "license": "MIT" }, + "node_modules/parse5": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.0.tgz", + "integrity": "sha512-9m4m5GSgXjL4AjumKzq1Fgfp3Z8rsvjRNbnkVwfu2ImRqE5D0LnY2QfDen18FSY9C573YU5XxSapdHZTZ2WolA==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -5094,6 +5523,16 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -5148,6 +5587,19 @@ "fsevents": "~2.3.2" } }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", @@ -5285,6 +5737,13 @@ "node": ">=8" } }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, "node_modules/tailwind-merge": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.4.0.tgz", @@ -5357,6 +5816,52 @@ "node": ">=14.0.0" } }, + "node_modules/tldts": { + "version": "7.0.23", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.23.tgz", + "integrity": "sha512-ASdhgQIBSay0R/eXggAkQ53G4nTJqTXqC2kbaBbdDwM7SkjyZyO0OaaN1/FH7U/yCeqOHDwFO5j8+Os/IS1dXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.0.23" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.0.23", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.23.tgz", + "integrity": "sha512-0g9vrtDQLrNIiCj22HSe9d4mLVG3g5ph5DZ8zCKBr4OtrspmNB6ss7hVyzArAeE88ceZocIEGkyW1Ime7fxPtQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.0.tgz", + "integrity": "sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz", + "integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/trim-lines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", @@ -5441,6 +5946,16 @@ "typescript": ">=4.8.4 <6.0.0" } }, + "node_modules/undici": { + "version": "7.22.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.22.0.tgz", + "integrity": "sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/undici-types": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", @@ -5770,6 +6285,54 @@ } } }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-16.0.0.tgz", + "integrity": "sha512-9CcxtEKsf53UFwkSUZjG+9vydAsFO4lFHBpJUtjBcoJOCJpKnSJNwCw813zrYJHpCJ7sgfbtOe0V5Ku7Pa1XMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.11.0", + "tr46": "^6.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5813,6 +6376,23 @@ "node": ">=0.10.0" } }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/package.json b/package.json index a2d730a..522502d 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.5.0", "globals": "^16.5.0", + "jsdom": "^28.1.0", "typescript": "~5.9.3", "typescript-eslint": "^8.55.0", "vite": "^7.3.1", diff --git a/src/components/LoginScreen.tsx b/src/components/LoginScreen.tsx index 24eca4e..b4d012b 100644 --- a/src/components/LoginScreen.tsx +++ b/src/components/LoginScreen.tsx @@ -1,10 +1,10 @@ import { useState } from 'react'; -import { Sparkles, Eye, EyeOff, Loader2 } from 'lucide-react'; +import { Sparkles, Eye, EyeOff, Loader2, Key, Lock } from 'lucide-react'; import { useT } from '../hooks/useLocale'; -import { getStoredCredentials } from '../lib/credentials'; +import { getStoredCredentials, type AuthMode } from '../lib/credentials'; interface Props { - onConnect: (url: string, token: string) => void; + onConnect: (url: string, secret: string, authMode: AuthMode) => void; error?: string | null; isConnecting?: boolean; } @@ -31,11 +31,17 @@ function getInitialToken(): string { return stored?.token ?? ''; } +function getInitialAuthMode(): AuthMode { + const stored = getStoredCredentials(); + return stored?.authMode ?? 'token'; +} + export function LoginScreen({ onConnect, error, isConnecting }: Props) { const t = useT(); const [url, setUrl] = useState(getInitialUrl); const [token, setToken] = useState(getInitialToken); const [showToken, setShowToken] = useState(false); + const [authMode, setAuthMode] = useState(getInitialAuthMode); const urlTrimmed = url.trim(); const isValidWsUrl = /^wss?:\/\/.+/.test(urlTrimmed); @@ -44,7 +50,7 @@ export function LoginScreen({ onConnect, error, isConnecting }: Props) { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!urlTrimmed || !token.trim() || !isValidWsUrl) return; - onConnect(urlTrimmed, token.trim()); + onConnect(urlTrimmed, token.trim(), authMode); }; return ( @@ -83,9 +89,39 @@ export function LoginScreen({ onConnect, error, isConnecting }: Props) { )} + {/* Auth mode toggle */} +
+ + +
+
setToken(e.target.value)} - placeholder={t('login.tokenPlaceholder')} + placeholder={authMode === 'password' ? t('login.passwordPlaceholder') : t('login.tokenPlaceholder')} className="w-full rounded-xl border border-pc-border bg-pc-elevated/50 px-4 py-3 pr-12 text-sm text-pc-text placeholder:text-pc-text-faint outline-none focus:border-[var(--pc-accent-dim)] focus:ring-1 focus:ring-[var(--pc-accent-glow)] transition-all" autoComplete="current-password" disabled={isConnecting} diff --git a/src/hooks/useGateway.ts b/src/hooks/useGateway.ts index 69cf6ce..c049369 100644 --- a/src/hooks/useGateway.ts +++ b/src/hooks/useGateway.ts @@ -1,7 +1,7 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { GatewayClient, type JsonPayload } from '../lib/gateway'; import { genIdempotencyKey } from '../lib/utils'; -import { getStoredCredentials, storeCredentials, clearCredentials } from '../lib/credentials'; +import { getStoredCredentials, storeCredentials, clearCredentials, type AuthMode } from '../lib/credentials'; import { getOrCreateDeviceIdentity } from '../lib/deviceIdentity'; import { isSystemEvent } from '../lib/systemEvent'; import { getCachedMessages, setCachedMessages, mergeWithCache } from '../lib/messageCache'; @@ -272,13 +272,13 @@ export function useGateway() { } }, []); - const setupClient = useCallback(async (wsUrl: string, token: string) => { + const setupClient = useCallback(async (wsUrl: string, token: string, authMode: AuthMode = 'token') => { // Tear down existing client if (clientRef.current) { clientRef.current.disconnect(); } - const client = new GatewayClient(wsUrl, token); + const client = new GatewayClient(wsUrl, token, authMode); clientRef.current = client; // Load device identity for signed connect handshake @@ -296,7 +296,7 @@ export function useGateway() { setConnectError(null); setIsConnecting(false); isConnectingRef.current = false; - storeCredentials(wsUrl, token); + storeCredentials(wsUrl, token, authMode); loadSessions(); loadAgentIdentity(); loadHistory(activeSessionRef.current); @@ -445,7 +445,7 @@ export function useGateway() { const stored = getStoredCredentials(); if (stored) { // Init on mount — setupClient sets state as part of establishing the connection - setupClient(stored.url, stored.token); + setupClient(stored.url, stored.token, stored.authMode || 'token'); } else { setAuthenticated(false); } @@ -503,8 +503,8 @@ export function useGateway() { loadHistory(key); }, [loadHistory]); - const login = useCallback((url: string, token: string) => { - setupClient(url, token); + const login = useCallback((url: string, token: string, authMode: AuthMode = 'token') => { + setupClient(url, token, authMode); }, [setupClient]); const deleteSession = useCallback(async (key: string) => { diff --git a/src/lib/__tests__/clipboard.test.ts b/src/lib/__tests__/clipboard.test.ts new file mode 100644 index 0000000..6b6f666 --- /dev/null +++ b/src/lib/__tests__/clipboard.test.ts @@ -0,0 +1,62 @@ +/** + * @vitest-environment jsdom + */ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { copyToClipboard } from '../clipboard'; + +describe('copyToClipboard', () => { + beforeEach(() => { + // jsdom doesn't define execCommand — add it so we can spy on it + if (!document.execCommand) { + (document as unknown as Record).execCommand = () => false; + } + }); + + afterEach(() => { + vi.restoreAllMocks(); + }); + + it('uses navigator.clipboard.writeText when available', async () => { + const writeText = vi.fn().mockResolvedValue(undefined); + Object.assign(navigator, { clipboard: { writeText } }); + + const result = await copyToClipboard('hello'); + expect(writeText).toHaveBeenCalledWith('hello'); + expect(result).toBe(true); + }); + + it('falls back to execCommand when clipboard API throws', async () => { + const writeText = vi.fn().mockRejectedValue(new Error('denied')); + Object.assign(navigator, { clipboard: { writeText } }); + vi.spyOn(document, 'execCommand').mockReturnValue(true); + + const result = await copyToClipboard('fallback text'); + expect(document.execCommand).toHaveBeenCalledWith('copy'); + expect(result).toBe(true); + }); + + it('falls back to execCommand when clipboard API is undefined', async () => { + Object.assign(navigator, { clipboard: undefined }); + vi.spyOn(document, 'execCommand').mockReturnValue(true); + + const result = await copyToClipboard('no clipboard'); + expect(document.execCommand).toHaveBeenCalledWith('copy'); + expect(result).toBe(true); + }); + + it('returns false when execCommand returns false', async () => { + Object.assign(navigator, { clipboard: undefined }); + vi.spyOn(document, 'execCommand').mockReturnValue(false); + + const result = await copyToClipboard('fail'); + expect(result).toBe(false); + }); + + it('returns false when both methods throw', async () => { + Object.assign(navigator, { clipboard: { writeText: vi.fn().mockRejectedValue(new Error()) } }); + vi.spyOn(document, 'execCommand').mockImplementation(() => { throw new Error('not supported'); }); + + const result = await copyToClipboard('total fail'); + expect(result).toBe(false); + }); +}); diff --git a/src/lib/__tests__/credentials.test.ts b/src/lib/__tests__/credentials.test.ts index c61cf28..ba920fb 100644 --- a/src/lib/__tests__/credentials.test.ts +++ b/src/lib/__tests__/credentials.test.ts @@ -47,7 +47,7 @@ describe('storeCredentials', () => { storeCredentials('wss://gw', 'tok'); expect(localStorageMock.setItem).toHaveBeenCalledWith( 'pinchchat_credentials', - JSON.stringify({ url: 'wss://gw', token: 'tok' }), + JSON.stringify({ url: 'wss://gw', token: 'tok', authMode: 'token' }), ); }); }); diff --git a/src/lib/credentials.ts b/src/lib/credentials.ts index aa81548..33c9b35 100644 --- a/src/lib/credentials.ts +++ b/src/lib/credentials.ts @@ -1,6 +1,15 @@ const STORAGE_KEY = 'pinchchat_credentials'; -export function getStoredCredentials(): { url: string; token: string } | null { +export type AuthMode = 'token' | 'password'; + +export interface StoredCredentials { + url: string; + token: string; + /** Auth mode — defaults to 'token' for backward compatibility */ + authMode?: AuthMode; +} + +export function getStoredCredentials(): StoredCredentials | null { try { const raw = localStorage.getItem(STORAGE_KEY); if (!raw) return null; @@ -12,8 +21,8 @@ export function getStoredCredentials(): { url: string; token: string } | null { return null; } -export function storeCredentials(url: string, token: string) { - localStorage.setItem(STORAGE_KEY, JSON.stringify({ url, token })); +export function storeCredentials(url: string, token: string, authMode: AuthMode = 'token') { + localStorage.setItem(STORAGE_KEY, JSON.stringify({ url, token, authMode })); } export function clearCredentials() { diff --git a/src/lib/gateway.ts b/src/lib/gateway.ts index 823fe13..77febf3 100644 --- a/src/lib/gateway.ts +++ b/src/lib/gateway.ts @@ -1,6 +1,7 @@ import { genId } from './utils'; import type { DeviceIdentity } from './deviceIdentity'; import { buildDeviceAuthPayload, signPayload } from './deviceIdentity'; +import type { AuthMode } from './credentials'; /** Debug logger — enable with localStorage.setItem('pinchchat:debug', '1') */ const isDebug = () => { @@ -41,17 +42,20 @@ export class GatewayClient { private wsUrl: string; private authToken: string; + private authMode: AuthMode = 'token'; private deviceIdentity: DeviceIdentity | null = null; - constructor(wsUrl?: string, authToken?: string) { + constructor(wsUrl?: string, authToken?: string, authMode?: AuthMode) { this.wsUrl = wsUrl || `ws://${window.location.hostname}:18789`; this.authToken = authToken || ''; + this.authMode = authMode || 'token'; } /** Update credentials (e.g. after login). Does not reconnect automatically. */ - setCredentials(wsUrl: string, authToken: string) { + setCredentials(wsUrl: string, authToken: string, authMode?: AuthMode) { this.wsUrl = wsUrl; this.authToken = authToken; + if (authMode) this.authMode = authMode; } /** Set the device identity for signed connect handshakes. */ @@ -154,7 +158,7 @@ export class GatewayClient { caps: [], commands: [], permissions: {}, - auth: { token: this.authToken }, + auth: this.authMode === 'password' ? { password: this.authToken } : { token: this.authToken }, device, locale: (typeof navigator !== 'undefined' ? navigator.language : undefined) || 'en', userAgent: `pinchchat/${__APP_VERSION__}`, diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index 9b98605..c53fbf3 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -14,6 +14,10 @@ const en = { 'login.gatewayUrl': 'Gateway URL', 'login.token': 'Token', 'login.tokenPlaceholder': 'Enter your gateway token', + 'login.authToken': 'Token', + 'login.authPassword': 'Password', + 'login.password': 'Password', + 'login.passwordPlaceholder': 'Enter your gateway password', 'login.connect': 'Connect', 'login.connecting': 'Connecting…', 'login.showToken': 'Show token', @@ -191,6 +195,10 @@ const fr: Record = { 'login.gatewayUrl': 'URL de la gateway', 'login.token': 'Token', 'login.tokenPlaceholder': 'Entrez votre token gateway', + 'login.authToken': 'Token', + 'login.authPassword': 'Mot de passe', + 'login.password': 'Mot de passe', + 'login.passwordPlaceholder': 'Entrez votre mot de passe gateway', 'login.connect': 'Connexion', 'login.connecting': 'Connexion…', 'login.showToken': 'Afficher le token', @@ -353,6 +361,10 @@ const es: Record = { 'login.gatewayUrl': 'URL del gateway', 'login.token': 'Token', 'login.tokenPlaceholder': 'Introduce tu token de gateway', + 'login.authToken': 'Token', + 'login.authPassword': 'Contraseña', + 'login.password': 'Contraseña', + 'login.passwordPlaceholder': 'Introduce tu contraseña de gateway', 'login.connect': 'Conectar', 'login.connecting': 'Conectando…', 'login.showToken': 'Mostrar token', @@ -517,6 +529,10 @@ const de: Record = { 'login.gatewayUrl': 'Gateway-URL', 'login.token': 'Token', 'login.tokenPlaceholder': 'Gateway-Token eingeben', + 'login.authToken': 'Token', + 'login.authPassword': 'Passwort', + 'login.password': 'Passwort', + 'login.passwordPlaceholder': 'Gateway-Passwort eingeben', 'login.connect': 'Verbinden', 'login.connecting': 'Verbinde…', 'login.showToken': 'Token anzeigen', @@ -679,6 +695,10 @@ const ja: Record = { 'login.gatewayUrl': 'ゲートウェイURL', 'login.token': 'トークン', 'login.tokenPlaceholder': 'ゲートウェイトークンを入力', + 'login.authToken': 'トークン', + 'login.authPassword': 'パスワード', + 'login.password': 'パスワード', + 'login.passwordPlaceholder': 'ゲートウェイパスワードを入力', 'login.connect': '接続', 'login.connecting': '接続中…', 'login.showToken': 'トークンを表示', @@ -841,6 +861,10 @@ const pt: Record = { 'login.gatewayUrl': 'URL do Gateway', 'login.token': 'Token', 'login.tokenPlaceholder': 'Insira o token do gateway', + 'login.authToken': 'Token', + 'login.authPassword': 'Senha', + 'login.password': 'Senha', + 'login.passwordPlaceholder': 'Insira a senha do gateway', 'login.connect': 'Conectar', 'login.connecting': 'Conectando…', 'login.showToken': 'Mostrar token', @@ -1003,6 +1027,10 @@ const zh: Record = { 'login.gatewayUrl': '网关地址', 'login.token': '令牌', 'login.tokenPlaceholder': '输入网关令牌', + 'login.authToken': '令牌', + 'login.authPassword': '密码', + 'login.password': '密码', + 'login.passwordPlaceholder': '输入网关密码', 'login.connect': '连接', 'login.connecting': '连接中…', 'login.showToken': '显示令牌', @@ -1165,6 +1193,10 @@ const it: Record = { 'login.gatewayUrl': 'URL del Gateway', 'login.token': 'Token', 'login.tokenPlaceholder': 'Inserisci il token del gateway', + 'login.authToken': 'Token', + 'login.authPassword': 'Password', + 'login.password': 'Password', + 'login.passwordPlaceholder': 'Inserisci la password del gateway', 'login.connect': 'Connetti', 'login.connecting': 'Connessione…', 'login.showToken': 'Mostra token',