diff --git a/package-lock.json b/package-lock.json index 288d83dd..8c8fc5ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,18 @@ "version": "1.0.0", "hasInstallScript": true, "license": "GPL-3.0", + "dependencies": { + "bcryptjs": "^3.0.3", + "body-parser": "^2.2.2", + "cookie-parser": "^1.4.7", + "dotenv": "^17.4.1", + "ejs": "^5.0.2", + "express": "^5.2.1", + "express-validator": "^7.3.2", + "jsonwebtoken": "^9.0.3", + "nodemailer": "^8.0.5", + "uuid": "^13.0.0" + }, "devDependencies": { "@mate-academy/eslint-config": "latest", "@mate-academy/scripts": "^1.8.6", @@ -16,7 +28,8 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-node": "^11.1.0", "jest": "^29.7.0", - "prettier": "^3.3.2" + "prettier": "^3.3.2", + "supertest": "^7.2.2" } }, "node_modules/@ampproject/remapping": { @@ -1487,6 +1500,16 @@ "mate-scripts": "bin/mateScripts.js" } }, + "node_modules/@mate-academy/scripts/node_modules/dotenv": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", + "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=10" + } + }, "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", @@ -1496,6 +1519,19 @@ "eslint-scope": "5.1.1" } }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1531,71 +1567,6 @@ "node": ">= 8" } }, - "node_modules/@octokit/auth-token": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.1.1.tgz", - "integrity": "sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA==", - "dev": true, - "peer": true, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/core": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.2.tgz", - "integrity": "sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==", - "dev": true, - "peer": true, - "dependencies": { - "@octokit/auth-token": "^5.0.0", - "@octokit/graphql": "^8.0.0", - "@octokit/request": "^9.0.0", - "@octokit/request-error": "^6.0.1", - "@octokit/types": "^13.0.0", - "before-after-hook": "^3.0.2", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/endpoint": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.1.tgz", - "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==", - "dev": true, - "peer": true, - "dependencies": { - "@octokit/types": "^13.0.0", - "universal-user-agent": "^7.0.2" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/graphql": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.1.1.tgz", - "integrity": "sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==", - "dev": true, - "peer": true, - "dependencies": { - "@octokit/request": "^9.0.0", - "@octokit/types": "^13.0.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/openapi-types": { - "version": "22.2.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-22.2.0.tgz", - "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==", - "dev": true, - "peer": true - }, "node_modules/@octokit/plugin-paginate-rest": { "version": "2.21.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz", @@ -1651,35 +1622,6 @@ "@types/node": ">= 8" } }, - "node_modules/@octokit/request": { - "version": "9.1.3", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.1.3.tgz", - "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==", - "dev": true, - "peer": true, - "dependencies": { - "@octokit/endpoint": "^10.0.0", - "@octokit/request-error": "^6.0.1", - "@octokit/types": "^13.1.0", - "universal-user-agent": "^7.0.2" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@octokit/request-error": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.4.tgz", - "integrity": "sha512-VpAhIUxwhWZQImo/dWAN/NpPqqojR6PSLgLYAituLM6U+ddx9hCioFGwBr5Mi+oi5CLeJkcAs3gJ0PYYzU6wUg==", - "dev": true, - "peer": true, - "dependencies": { - "@octokit/types": "^13.0.0" - }, - "engines": { - "node": ">= 18" - } - }, "node_modules/@octokit/rest": { "version": "17.11.2", "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-17.11.2.tgz", @@ -1855,14 +1797,14 @@ "os-name": "^3.1.0" } }, - "node_modules/@octokit/types": { - "version": "13.5.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.5.0.tgz", - "integrity": "sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==", + "node_modules/@paralleldrive/cuid2": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.3.1.tgz", + "integrity": "sha512-XO7cAxhnTZl0Yggq6jOgjiOHhbgcO4NqFqwSmQpjK3b6TEE6Uj/jfSk6wzYyemh3+I0sHirKSetjQwn5cZktFw==", "dev": true, - "peer": true, + "license": "MIT", "dependencies": { - "@octokit/openapi-types": "^22.2.0" + "@noble/hashes": "^1.1.5" } }, "node_modules/@pkgr/core": { @@ -2198,6 +2140,19 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", @@ -2413,6 +2368,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, + "license": "MIT" + }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -2620,12 +2589,38 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, - "node_modules/before-after-hook": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz", - "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==", - "dev": true, - "peer": true + "node_modules/bcryptjs": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-3.0.3.tgz", + "integrity": "sha512-GlF5wPWnSa/X5LKM1o0wz0suXIINz1iHRLvTS+sLyi7XPbe5ycmYI3DlZqVGZZtDgl4DmasFg7gOB3JYbphV5g==", + "license": "BSD-3-Clause", + "bin": { + "bcrypt": "bin/bcrypt" + } + }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } }, "node_modules/brace-expansion": { "version": "1.1.11", @@ -2690,12 +2685,27 @@ "node-int64": "^0.4.0" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", @@ -2715,6 +2725,35 @@ "url": "https://github.com/sponsors/ljharb" } }, + "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", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2842,6 +2881,19 @@ "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", @@ -2851,18 +2903,85 @@ "node": ">= 6" } }, + "node_modules/component-emitter": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", + "integrity": "sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-parser": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", + "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "license": "MIT", + "dependencies": { + "cookie": "0.7.2", + "cookie-signature": "1.0.6" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, + "node_modules/cookiejar": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", + "dev": true, + "license": "MIT" + }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -3038,12 +3157,12 @@ } }, "node_modules/debug": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", - "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", - "dev": true, + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -3117,6 +3236,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -3132,6 +3270,17 @@ "node": ">=8" } }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dev": true, + "license": "ISC", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -3175,12 +3324,56 @@ } }, "node_modules/dotenv": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", - "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", - "dev": true, + "version": "17.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.1.tgz", + "integrity": "sha512-k8DaKGP6r1G30Lx8V4+pCsLzKr8vLmV2paqEj1Y55GdAgJuIqpRp5FfajGF8KtwMxCz9qJc6wUIJnm053d/WCw==", + "license": "BSD-2-Clause", "engines": { - "node": ">=10" + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/ejs": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-5.0.2.tgz", + "integrity": "sha512-IpbUaI/CAW86l3f+T8zN0iggSc0LmMZLcIW5eRVStLVNCoTXkE0YlncbbH50fp8Cl6zHIky0sW2uUbhBqGw0Jw==", + "license": "Apache-2.0", + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.12.18" } }, "node_modules/electron-to-chromium": { @@ -3207,6 +3400,15 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -3286,13 +3488,10 @@ } }, "node_modules/es-define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.2.4" - }, + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", "engines": { "node": ">= 0.4" } @@ -3301,16 +3500,15 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true, "engines": { "node": ">= 0.4" } }, "node_modules/es-object-atoms": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", - "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", - "dev": true, + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", "dependencies": { "es-errors": "^1.3.0" }, @@ -3319,14 +3517,16 @@ } }, "node_modules/es-set-tostringtag": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz", - "integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", "dev": true, + "license": "MIT", "dependencies": { - "get-intrinsic": "^1.2.4", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", - "hasown": "^2.0.1" + "hasown": "^2.0.2" }, "engines": { "node": ">= 0.4" @@ -3367,6 +3567,12 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -3974,6 +4180,15 @@ "node": ">=0.10.0" } }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -4022,6 +4237,71 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-validator": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/express-validator/-/express-validator-7.3.2.tgz", + "integrity": "sha512-ctLw1Vl6dXVH62dIQMDdTAQkrh480mkFuG6/SGXOaVlwPNukhRAe7EgJIMJ2TSAni8iwHBRp530zAZE5ZPF2IA==", + "license": "MIT", + "dependencies": { + "lodash": "^4.18.1", + "validator": "~13.15.23" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/express/node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4074,6 +4354,13 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true, + "license": "MIT" + }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", @@ -4116,6 +4403,27 @@ "node": ">=8" } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -4161,16 +4469,92 @@ "is-callable": "^1.1.3" } }, - "node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "dev": true, + "license": "MIT", "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/formidable": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.4.tgz", + "integrity": "sha512-YikH+7CUTOtP44ZTnUhR7Ic2UASBPOqmaRkRKxRbywPTe5VxF7RRCck4af9wutiZ/QKM5nME9Bie2fFaPz5Gug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "dezalgo": "^1.0.4", + "once": "^1.4.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" }, "engines": { "node": ">=10" @@ -4200,7 +4584,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -4251,16 +4634,21 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", - "dev": true, + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "hasown": "^2.0.0" + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" }, "engines": { "node": ">= 0.4" @@ -4290,6 +4678,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -4398,12 +4799,12 @@ } }, "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.1.3" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -4464,10 +4865,10 @@ } }, "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true, + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -4494,7 +4895,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "dependencies": { "function-bind": "^1.1.2" }, @@ -4508,6 +4908,26 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -4517,6 +4937,22 @@ "node": ">=10.17.0" } }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", @@ -4584,8 +5020,7 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/internal-slot": { "version": "1.0.7", @@ -4601,6 +5036,15 @@ "node": ">= 0.4" } }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-array-buffer": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", @@ -4816,6 +5260,12 @@ "node": ">=0.10.0" } }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/is-regex": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", @@ -6673,12 +7123,67 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/just-extend": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", "dev": true }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -6740,18 +7245,66 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "license": "MIT" + }, "node_modules/lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -6809,6 +7362,36 @@ "tmpl": "1.0.5" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -6824,6 +7407,16 @@ "node": ">= 8" } }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/micromatch": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", @@ -6837,6 +7430,44 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -6868,10 +7499,10 @@ } }, "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" }, "node_modules/natural-compare": { "version": "1.4.0", @@ -6879,6 +7510,15 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -6948,6 +7588,15 @@ "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "dev": true }, + "node_modules/nodemailer": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.5.tgz", + "integrity": "sha512-0PF8Yb1yZuQfQbq+5/pZJrtF6WQcjTd5/S4JOHs9PGFxuTqoB/icwuB44pOdURHJbRKX1PPoJZtY7R4VUoCC8w==", + "license": "MIT-0", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -6970,10 +7619,10 @@ } }, "node_modules/object-inspect": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", - "dev": true, + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7057,11 +7706,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, "dependencies": { "wrappy": "1" } @@ -7205,6 +7865,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7437,6 +8106,19 @@ "node": ">= 6" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -7472,6 +8154,21 @@ } ] }, + "node_modules/qs": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz", + "integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -7492,6 +8189,30 @@ } ] }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -7619,6 +8340,32 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/router/node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -7660,6 +8407,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/safe-regex-test": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", @@ -7677,6 +8444,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, "node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -7686,6 +8459,51 @@ "semver": "bin/semver.js" } }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -7718,6 +8536,12 @@ "node": ">= 0.4" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -7740,15 +8564,69 @@ } }, "node_modules/side-channel": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", - "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", - "dev": true, + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", "dependencies": { - "call-bind": "^1.0.7", "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.4", - "object-inspect": "^1.13.1" + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" }, "engines": { "node": ">= 0.4" @@ -7882,6 +8760,15 @@ "node": ">=8" } }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/string-length": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", @@ -8009,6 +8896,52 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/superagent": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.3.0.tgz", + "integrity": "sha512-B+4Ik7ROgVKrQsXTV0Jwp2u+PXYLSlqtDAhYnkkD+zn3yg8s/zjA2MeGayPoY/KICrbitwneDHrjSotxKL+0XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "component-emitter": "^1.3.1", + "cookiejar": "^2.1.4", + "debug": "^4.3.7", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.5", + "formidable": "^3.5.4", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.14.1" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/supertest": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.2.2.tgz", + "integrity": "sha512-oK8WG9diS3DlhdUkcFn4tkNIiIbBx9lI2ClF8K+b2/m8Eyv47LSawxUzZQSNKUrVb2KsqeTDCcjAAVPYaSLVTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cookie-signature": "^1.2.2", + "methods": "^1.1.2", + "superagent": "^10.3.0" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/supertest/node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -8096,6 +9029,15 @@ "node": ">=8.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -8195,6 +9137,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz", @@ -8268,20 +9224,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", - "dev": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -8303,13 +9245,6 @@ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, - "node_modules/universal-user-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz", - "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==", - "dev": true, - "peer": true - }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", @@ -8319,6 +9254,15 @@ "node": ">= 10.0.0" } }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/update-browserslist-db": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", @@ -8358,6 +9302,19 @@ "punycode": "^2.1.0" } }, + "node_modules/uuid": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", + "integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -8372,6 +9329,24 @@ "node": ">=10.12.0" } }, + "node_modules/validator": { + "version": "13.15.35", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.35.tgz", + "integrity": "sha512-TQ5pAGhd5whStmqWvYF4OjQROlmv9SMFVt37qoCBdqRffuuklWYQlCNnEs2ZaIBD1kZRNnikiZOS1eqgkar0iw==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -8642,8 +9617,7 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "node_modules/write-file-atomic": { "version": "4.0.2", diff --git a/package.json b/package.json index 5e195a15..bd67b34c 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,22 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-node": "^11.1.0", "jest": "^29.7.0", - "prettier": "^3.3.2" + "prettier": "^3.3.2", + "supertest": "^7.2.2" }, "mateAcademy": { "projectType": "javascript" + }, + "dependencies": { + "bcryptjs": "^3.0.3", + "body-parser": "^2.2.2", + "cookie-parser": "^1.4.7", + "dotenv": "^17.4.1", + "ejs": "^5.0.2", + "express": "^5.2.1", + "express-validator": "^7.3.2", + "jsonwebtoken": "^9.0.3", + "nodemailer": "^8.0.5", + "uuid": "^13.0.0" } } diff --git a/src/app.js b/src/app.js new file mode 100644 index 00000000..030435b9 --- /dev/null +++ b/src/app.js @@ -0,0 +1,33 @@ +'use strict'; + +const path = require('path'); +const express = require('express'); +const bodyParser = require('body-parser'); +const cookieParser = require('cookie-parser'); +const { router: authRouter } = require('./routes/auth'); +const { router: passwordRouter } = require('./routes/passwordReset'); +const { router: profileRouter } = require('./routes/profile'); + +const app = express(); + +app.use(bodyParser.urlencoded({ extended: true })); +app.use(bodyParser.json()); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, 'public'))); + +app.set('view engine', 'ejs'); +app.set('views', path.join(__dirname, 'views')); + +app.use('/auth', authRouter); +app.use('/password', passwordRouter); +app.use('/profile', profileRouter); + +app.get('/', (req, res) => { + res.redirect('/auth/login'); +}); + +app.use((req, res) => { + res.status(404).render('errors/404', { title: 'Not Found' }); +}); + +module.exports = app; diff --git a/src/config.js b/src/config.js new file mode 100644 index 00000000..ee14cfb6 --- /dev/null +++ b/src/config.js @@ -0,0 +1,18 @@ +'use strict'; + +require('dotenv').config(); + +module.exports = { + port: process.env.PORT || 3000, + jwtSecret: process.env.JWT_SECRET || 'dev_secret', + jwtExpiresIn: process.env.JWT_EXPIRES_IN || '24h', + baseUrl: process.env.BASE_URL || 'http://localhost:3000', + nodeEnv: process.env.NODE_ENV || 'development', + smtp: { + host: process.env.SMTP_HOST || 'smtp.ethereal.email', + port: parseInt(process.env.SMTP_PORT, 10) || 587, + secure: process.env.SMTP_SECURE === 'true', + user: process.env.SMTP_USER || '', + pass: process.env.SMTP_PASS || '', + }, +}; diff --git a/src/index.js b/src/index.js index ad9a93a7..19650d2d 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,14 @@ 'use strict'; + +require('dotenv').config(); + +const config = require('./config'); +const app = require('./app'); +const { User } = require('./models/User'); + +app.listen(config.port, () => { + // eslint-disable-next-line no-console + console.log(`Server running on port ${config.port}`); +}); + +module.exports = { app, User }; diff --git a/src/middleware/authenticate.js b/src/middleware/authenticate.js new file mode 100644 index 00000000..be0234ba --- /dev/null +++ b/src/middleware/authenticate.js @@ -0,0 +1,24 @@ +'use strict'; + +const { verifyToken } = require('../services/token'); + +function authenticate(req, res, next) { + const token = req.cookies.token; + + if (!token) { + return res.redirect('/auth/login'); + } + + const decoded = verifyToken(token); + + if (!decoded) { + res.clearCookie('token'); + + return res.redirect('/auth/login'); + } + + req.userId = decoded.userId; + next(); +} + +module.exports = { authenticate }; diff --git a/src/middleware/guest.js b/src/middleware/guest.js new file mode 100644 index 00000000..0b532ec8 --- /dev/null +++ b/src/middleware/guest.js @@ -0,0 +1,22 @@ +'use strict'; + +const { verifyToken } = require('../services/token'); + +function guest(req, res, next) { + const token = req.cookies.token; + + if (!token) { + return next(); + } + + const decoded = verifyToken(token); + + if (decoded) { + return res.redirect('/profile'); + } + + res.clearCookie('token'); + next(); +} + +module.exports = { guest }; diff --git a/src/models/User.js b/src/models/User.js new file mode 100644 index 00000000..b28e9cca --- /dev/null +++ b/src/models/User.js @@ -0,0 +1,172 @@ +'use strict'; + +const { randomUUID } = require('crypto'); +const bcrypt = require('bcryptjs'); + +const users = new Map(); +const resetTokens = new Map(); +const activationTokens = new Map(); + +function hashPassword(password) { + return bcrypt.hashSync(password, 10); +} + +function comparePassword(password, hash) { + return bcrypt.compareSync(password, hash); +} + +class User { + constructor({ id, name, email, password, isActive }) { + this.id = id; + this.name = name; + this.email = email; + this.password = password; + this.isActive = isActive; + } + + toJSON() { + return { + id: this.id, + name: this.name, + email: this.email, + isActive: this.isActive, + }; + } + + static create({ name, email, password }) { + const id = randomUUID(); + const hashedPassword = hashPassword(password); + const user = new User({ + id, + name, + email: email.toLowerCase(), + password: hashedPassword, + isActive: false, + }); + + users.set(id, user); + + const activationToken = randomUUID(); + + activationTokens.set(activationToken, id); + + return { user, activationToken }; + } + + static findById(id) { + return users.get(id) || null; + } + + static findByEmail(email) { + for (const user of users.values()) { + if (user.email === email.toLowerCase()) { + return user; + } + } + + return null; + } + + static verifyPassword(user, password) { + return comparePassword(password, user.password); + } + + static activate(activationToken) { + const userId = activationTokens.get(activationToken); + + if (!userId) { + return null; + } + + const user = users.get(userId); + + if (!user) { + return null; + } + + user.isActive = true; + activationTokens.delete(activationToken); + + return user; + } + + static updateName(id, name) { + const user = users.get(id); + + if (!user) { + return null; + } + + user.name = name; + + return user; + } + + static updatePassword(id, oldPassword, newPassword) { + const user = users.get(id); + + if (!user || !comparePassword(oldPassword, user.password)) { + return null; + } + + user.password = hashPassword(newPassword); + + return user; + } + + static updateEmail(id, password, newEmail) { + const user = users.get(id); + + if (!user || !comparePassword(password, user.password)) { + return null; + } + + const oldEmail = user.email; + + user.email = newEmail.toLowerCase(); + + return { user, oldEmail }; + } + + static createResetToken(email) { + const user = User.findByEmail(email); + + if (!user) { + return null; + } + + const token = randomUUID(); + + resetTokens.set(token, { userId: user.id, createdAt: Date.now() }); + + return token; + } + + static resetPassword(token, newPassword) { + const data = resetTokens.get(token); + + if (!data) { + return null; + } + + const user = users.get(data.userId); + + if (!user) { + return null; + } + + user.password = hashPassword(newPassword); + user.isActive = true; + resetTokens.delete(token); + + return user; + } + + static reset() { + users.clear(); + resetTokens.clear(); + activationTokens.clear(); + } +} + +module.exports = { User }; diff --git a/src/public/css/style.css b/src/public/css/style.css new file mode 100644 index 00000000..82de38c9 --- /dev/null +++ b/src/public/css/style.css @@ -0,0 +1,248 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + background-color: #f5f5f5; + color: #333; + line-height: 1.6; +} + +.container { + max-width: 600px; + margin: 0 auto; + padding: 0 20px; +} + +.navbar { + background-color: #2c3e50; + padding: 15px 0; + margin-bottom: 30px; +} + +.navbar .container { + display: flex; + justify-content: space-between; + align-items: center; +} + +.logo { + color: #fff; + text-decoration: none; + font-size: 1.5em; + font-weight: bold; +} + +.nav-links { + display: flex; + align-items: center; + gap: 15px; +} + +.nav-link { + color: #ecf0f1; + text-decoration: none; +} + +.nav-link:hover { + color: #3498db; +} + +.form-card { + background: #fff; + border-radius: 8px; + padding: 30px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); + margin-bottom: 30px; +} + +.form-card h1 { + margin-bottom: 20px; + color: #2c3e50; + text-align: center; +} + +.form-group { + margin-bottom: 15px; +} + +.form-group label { + display: block; + margin-bottom: 5px; + font-weight: 600; + color: #2c3e50; +} + +.form-group input { + width: 100%; + padding: 10px 12px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 14px; +} + +.form-group input:focus { + border-color: #3498db; + outline: none; + box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2); +} + +.btn { + display: inline-block; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 14px; + text-decoration: none; + text-align: center; +} + +.btn-primary { + background-color: #3498db; + color: #fff; +} + +.btn-primary:hover { + background-color: #2980b9; +} + +.btn-danger { + background-color: #e74c3c; + color: #fff; +} + +.btn-danger:hover { + background-color: #c0392b; +} + +.btn-link { + background: none; + border: none; + color: #ecf0f1; + cursor: pointer; + font-size: 14px; + padding: 0; +} + +.btn-link:hover { + color: #3498db; +} + +.alert { + padding: 12px 15px; + border-radius: 4px; + margin-bottom: 15px; +} + +.alert ul { + margin-left: 20px; +} + +.alert-error { + background-color: #fde8e8; + border: 1px solid #e74c3c; + color: #c0392b; +} + +.alert-success { + background-color: #e8f8e8; + border: 1px solid #27ae60; + color: #1e8449; +} + +.text-center { + text-align: center; + margin-top: 15px; +} + +.inline-form { + display: inline; +} + +.password-rules { + background: #f8f9fa; + border: 1px solid #ddd; + border-radius: 4px; + padding: 15px; + margin-bottom: 20px; +} + +.password-rules h3 { + margin-bottom: 8px; + font-size: 14px; + color: #2c3e50; +} + +.password-rules ul { + margin-left: 20px; + font-size: 13px; + color: #555; +} + +.profile-info { + background: #f8f9fa; + border-radius: 4px; + padding: 15px; + margin-bottom: 20px; +} + +.profile-info p { + margin-bottom: 5px; +} + +.profile-actions { + margin-top: 20px; + padding-top: 20px; + border-top: 1px solid #eee; +} + +.tabs { + display: flex; + gap: 0; + margin-bottom: 0; +} + +.tab-btn { + flex: 1; + padding: 10px; + background: #f8f9fa; + border: 1px solid #ddd; + border-bottom: none; + border-radius: 4px 4px 0 0; + cursor: pointer; + font-size: 13px; +} + +.tab-btn.active { + background: #fff; + border-bottom: 1px solid #fff; + margin-bottom: -1px; + font-weight: 600; +} + +.tab-content { + display: none; + padding: 20px 0; + border-top: 1px solid #ddd; +} + +.tab-content.active { + display: block; +} + +.form-hint { + margin-top: 5px; + font-size: 12px; + color: #888; +} + +footer { + text-align: center; + padding: 20px 0; + color: #888; + font-size: 13px; +} diff --git a/src/routes/auth.js b/src/routes/auth.js new file mode 100644 index 00000000..c0260dc4 --- /dev/null +++ b/src/routes/auth.js @@ -0,0 +1,210 @@ +'use strict'; + +const express = require('express'); +const { User } = require('../models/User'); +const { generateToken } = require('../services/token'); +const { sendActivationEmail } = require('../services/email'); +const { guest } = require('../middleware/guest'); +const { authenticate } = require('../middleware/authenticate'); + +const router = express.Router(); + +const PASSWORD_RULES = [ + 'At least 8 characters long', + 'Contains at least one uppercase letter', + 'Contains at least one lowercase letter', + 'Contains at least one number', + 'Contains at least one special character (!@#$%^&*)', +]; + +function validatePassword(password) { + if (!password) { + return ['Password is required']; + } + + const errors = []; + + if (password.length < 8) { + errors.push('Password must be at least 8 characters long'); + } + + if (!/[A-Z]/.test(password)) { + errors.push('Password must contain at least one uppercase letter'); + } + + if (!/[a-z]/.test(password)) { + errors.push('Password must contain at least one lowercase letter'); + } + + if (!/[0-9]/.test(password)) { + errors.push('Password must contain at least one number'); + } + + if (!/[!@#$%^&*]/.test(password)) { + errors.push( + 'Password must contain at least one special character (!@#$%^&*)', + ); + } + + return errors; +} + +function isValidEmail(email) { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); +} + +router.get('/register', guest, (req, res) => { + res.render('auth/register', { + title: 'Register', + errors: [], + old: {}, + passwordRules: PASSWORD_RULES, + }); +}); + +router.post('/register', guest, async (req, res) => { + const { name, email, password, confirmation } = req.body; + const errors = []; + + if (!name || !name.trim()) { + errors.push('Name is required'); + } + + if (!email || !isValidEmail(email)) { + errors.push('Valid email is required'); + } + + if (!password) { + errors.push('Password is required'); + } + + if (password && confirmation && password !== confirmation) { + errors.push('Passwords do not match'); + } + + if (password) { + errors.push(...validatePassword(password)); + } + + if (errors.length === 0) { + const existingUser = User.findByEmail(email); + + if (existingUser) { + errors.push('Email is already registered'); + } + } + + if (errors.length > 0) { + return res.render('auth/register', { + title: 'Register', + errors, + old: { name, email }, + passwordRules: PASSWORD_RULES, + }); + } + + const { user, activationToken } = User.create({ + name: name.trim(), + email, + password, + }); + + try { + await sendActivationEmail(user.email, activationToken); + } catch (err) { + // eslint-disable-next-line no-console + console.error('Failed to send activation email:', err.message); + } + + res.render('auth/register-success', { + title: 'Registration Successful', + email: user.email, + }); +}); + +router.get('/login', guest, (req, res) => { + res.render('auth/login', { + title: 'Login', + errors: [], + old: {}, + }); +}); + +router.post('/login', guest, (req, res) => { + const { email, password } = req.body; + const errors = []; + + if (!email || !isValidEmail(email)) { + errors.push('Valid email is required'); + } + + if (!password) { + errors.push('Password is required'); + } + + if (errors.length > 0) { + return res.render('auth/login', { + title: 'Login', + errors, + old: { email }, + }); + } + + const user = User.findByEmail(email); + + if (!user || !User.verifyPassword(user, password)) { + return res.render('auth/login', { + title: 'Login', + errors: ['Invalid email or password'], + old: { email }, + }); + } + + if (!user.isActive) { + return res.render('auth/login', { + title: 'Login', + errors: [ + 'Please activate your account. ' + + 'Check your email for the activation link.', + ], + old: { email }, + }); + } + + const token = generateToken(user.id); + + res.cookie('token', token, { + httpOnly: true, + maxAge: 24 * 60 * 60 * 1000, + }); + + res.redirect('/profile'); +}); + +router.post('/logout', authenticate, (req, res) => { + res.clearCookie('token'); + res.redirect('/auth/login'); +}); + +router.get('/activate/:token', guest, (req, res) => { + const { token } = req.params; + const user = User.activate(token); + + if (!user) { + return res.render('auth/activate', { + title: 'Activation Failed', + success: false, + }); + } + + const jwtToken = generateToken(user.id); + + res.cookie('token', jwtToken, { + httpOnly: true, + maxAge: 24 * 60 * 60 * 1000, + }); + + res.redirect('/profile'); +}); + +module.exports = { router, validatePassword, PASSWORD_RULES }; diff --git a/src/routes/passwordReset.js b/src/routes/passwordReset.js new file mode 100644 index 00000000..417a5952 --- /dev/null +++ b/src/routes/passwordReset.js @@ -0,0 +1,106 @@ +'use strict'; + +const express = require('express'); +const { User } = require('../models/User'); +const { sendPasswordResetEmail } = require('../services/email'); +const { guest } = require('../middleware/guest'); +const { validatePassword } = require('./auth'); + +const router = express.Router(); + +function isValidEmail(email) { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); +} + +router.get('/reset', guest, (req, res) => { + res.render('password/reset-request', { + title: 'Reset Password', + errors: [], + old: {}, + }); +}); + +router.post('/reset', guest, async (req, res) => { + const { email } = req.body; + const errors = []; + + if (!email || !isValidEmail(email)) { + errors.push('Valid email is required'); + } + + if (errors.length > 0) { + return res.render('password/reset-request', { + title: 'Reset Password', + errors, + old: { email }, + }); + } + + const token = User.createResetToken(email); + + if (token) { + try { + await sendPasswordResetEmail(email, token); + } catch (err) { + // eslint-disable-next-line no-console + console.error('Failed to send reset email:', err.message); + } + } + + res.render('password/reset-sent', { + title: 'Email Sent', + email, + }); +}); + +router.get('/reset/:token', guest, (req, res) => { + const { token } = req.params; + + res.render('password/reset-confirm', { + title: 'Reset Password', + token, + errors: [], + }); +}); + +router.post('/reset/:token', guest, (req, res) => { + const { password, confirmation } = req.body; + const { token } = req.params; + const errors = []; + + if (!password) { + errors.push('Password is required'); + } + + if (password && confirmation && password !== confirmation) { + errors.push('Passwords do not match'); + } + + if (password) { + errors.push(...validatePassword(password)); + } + + if (errors.length > 0) { + return res.render('password/reset-confirm', { + title: 'Reset Password', + token, + errors, + }); + } + + const user = User.resetPassword(token, password); + + if (!user) { + return res.render('password/reset-confirm', { + title: 'Reset Password', + token, + errors: ['Invalid or expired reset token'], + }); + } + + res.render('password/reset-success', { + title: 'Password Reset Successful', + }); +}); + +module.exports = { router }; diff --git a/src/routes/profile.js b/src/routes/profile.js new file mode 100644 index 00000000..289ebf73 --- /dev/null +++ b/src/routes/profile.js @@ -0,0 +1,192 @@ +'use strict'; + +const express = require('express'); +const { User } = require('../models/User'); +const { authenticate } = require('../middleware/authenticate'); +const { + sendEmailChangeNotification, + sendNewEmailConfirmation, +} = require('../services/email'); +const { validatePassword } = require('./auth'); + +const router = express.Router(); + +function isValidEmail(email) { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); +} + +router.get('/', authenticate, (req, res) => { + const user = User.findById(req.userId); + + if (!user) { + res.clearCookie('token'); + + return res.redirect('/auth/login'); + } + + res.render('profile/index', { + title: 'Profile', + user: user.toJSON(), + errors: [], + success: null, + activeTab: 'profile', + }); +}); + +router.post('/name', authenticate, (req, res) => { + const { name } = req.body; + const user = User.findById(req.userId); + const errors = []; + + if (!user) { + res.clearCookie('token'); + + return res.redirect('/auth/login'); + } + + if (!name || !name.trim()) { + errors.push('Name is required'); + } + + if (errors.length > 0) { + return res.render('profile/index', { + title: 'Profile', + user: user.toJSON(), + errors, + success: null, + activeTab: 'name', + }); + } + + User.updateName(req.userId, name.trim()); + + const updatedUser = User.findById(req.userId); + + res.render('profile/index', { + title: 'Profile', + user: updatedUser.toJSON(), + errors: [], + success: 'Name updated successfully', + activeTab: 'name', + }); +}); + +router.post('/password', authenticate, (req, res) => { + const { oldPassword, newPassword, confirmation } = req.body; + const user = User.findById(req.userId); + const errors = []; + + if (!user) { + res.clearCookie('token'); + + return res.redirect('/auth/login'); + } + + if (!oldPassword) { + errors.push('Current password is required'); + } + + if (!newPassword) { + errors.push('New password is required'); + } + + if (newPassword && confirmation && newPassword !== confirmation) { + errors.push('Passwords do not match'); + } + + if (newPassword) { + errors.push(...validatePassword(newPassword)); + } + + if (errors.length > 0) { + return res.render('profile/index', { + title: 'Profile', + user: user.toJSON(), + errors, + success: null, + activeTab: 'password', + }); + } + + const updated = User.updatePassword(req.userId, oldPassword, newPassword); + + if (!updated) { + return res.render('profile/index', { + title: 'Profile', + user: user.toJSON(), + errors: ['Current password is incorrect'], + success: null, + activeTab: 'password', + }); + } + + const updatedUser = User.findById(req.userId); + + res.render('profile/index', { + title: 'Profile', + user: updatedUser.toJSON(), + errors: [], + success: 'Password updated successfully', + activeTab: 'password', + }); +}); + +router.post('/email', authenticate, async (req, res) => { + const { password, newEmail } = req.body; + const user = User.findById(req.userId); + const errors = []; + + if (!user) { + res.clearCookie('token'); + + return res.redirect('/auth/login'); + } + + if (!password) { + errors.push('Password is required'); + } + + if (!newEmail || !isValidEmail(newEmail)) { + errors.push('Valid email is required'); + } + + if (errors.length > 0) { + return res.render('profile/index', { + title: 'Profile', + user: user.toJSON(), + errors, + success: null, + activeTab: 'email', + }); + } + + const result = User.updateEmail(req.userId, password, newEmail); + + if (!result) { + return res.render('profile/index', { + title: 'Profile', + user: user.toJSON(), + errors: ['Password is incorrect'], + success: null, + activeTab: 'email', + }); + } + + try { + await sendEmailChangeNotification(result.oldEmail, result.user.email); + await sendNewEmailConfirmation(result.user.email); + } catch (err) { + // eslint-disable-next-line no-console + console.error('Failed to send email notifications:', err.message); + } + + res.render('profile/index', { + title: 'Profile', + user: result.user.toJSON(), + errors: [], + success: 'Email updated successfully', + activeTab: 'email', + }); +}); + +module.exports = { router }; diff --git a/src/services/email.js b/src/services/email.js new file mode 100644 index 00000000..388d1bab --- /dev/null +++ b/src/services/email.js @@ -0,0 +1,162 @@ +'use strict'; + +const nodemailer = require('nodemailer'); +const config = require('../config'); + +let transporter = null; + +async function getTransporter() { + if (transporter) { + return transporter; + } + + if (config.nodeEnv === 'test') { + transporter = nodemailer.createTransport({ + streamTransport: true, + newline: 'unix', + buffer: true, + }); + + return transporter; + } + + if (config.smtp.user && config.smtp.pass) { + try { + const testTransport = nodemailer.createTransport({ + host: config.smtp.host, + port: config.smtp.port, + secure: config.smtp.secure, + auth: { + user: config.smtp.user, + pass: config.smtp.pass, + }, + }); + + await testTransport.verify(); + transporter = testTransport; + + return transporter; + } catch { + // eslint-disable-next-line no-console + console.log( + 'SMTP credentials invalid, ' + + 'falling back to Ethereal test account...', + ); + } + } + + const testAccount = await nodemailer.createTestAccount(); + + transporter = nodemailer.createTransport({ + host: 'smtp.ethereal.email', + port: 587, + secure: false, + auth: { + user: testAccount.user, + pass: testAccount.pass, + }, + }); + + // eslint-disable-next-line no-console + console.log(`Ethereal test account created: ${testAccount.user}`); + // eslint-disable-next-line no-console + console.log('View emails at https://ethereal.email/login'); + + return transporter; +} + +async function sendActivationEmail(email, activationToken) { + const transport = await getTransporter(); + const activationUrl = `${config.baseUrl}/auth/activate/${activationToken}`; + + const info = await transport.sendMail({ + from: '"Auth App" ', + to: email, + subject: 'Activate your account', + html: ` +

Welcome!

+

Please activate your account by clicking the link below:

+ Activate Account +

Or copy this link: ${activationUrl}

+ `, + }); + + logPreviewUrl(info); + + return info; +} + +async function sendPasswordResetEmail(email, resetToken) { + const transport = await getTransporter(); + const resetUrl = `${config.baseUrl}/password/reset/${resetToken}`; + + const info = await transport.sendMail({ + from: '"Auth App" ', + to: email, + subject: 'Password Reset', + html: ` +

Password Reset

+

You requested a password reset. Click the link below:

+ Reset Password +

Or copy this link: ${resetUrl}

+

If you did not request this, ignore this email.

+ `, + }); + + logPreviewUrl(info); + + return info; +} + +async function sendEmailChangeNotification(oldEmail, newEmail) { + const transport = await getTransporter(); + + const info = await transport.sendMail({ + from: '"Auth App" ', + to: oldEmail, + subject: 'Your email has been changed', + html: ` +

Email Changed

+

Your email address has been changed from ${oldEmail} + to ${newEmail}.

+

If you did not make this change, contact support.

+ `, + }); + + logPreviewUrl(info); + + return info; +} + +async function sendNewEmailConfirmation(newEmail) { + const transport = await getTransporter(); + + const info = await transport.sendMail({ + from: '"Auth App" ', + to: newEmail, + subject: 'Email change confirmation', + html: ` +

Email Change Confirmed

+

Your email has been successfully updated to ${newEmail}.

+ `, + }); + + logPreviewUrl(info); + + return info; +} + +function logPreviewUrl(info) { + if (nodemailer.getTestMessageUrl(info)) { + // eslint-disable-next-line no-console + console.log(`Preview email: ${nodemailer.getTestMessageUrl(info)}`); + } +} + +module.exports = { + sendActivationEmail, + sendPasswordResetEmail, + sendEmailChangeNotification, + sendNewEmailConfirmation, + getTransporter, +}; diff --git a/src/services/token.js b/src/services/token.js new file mode 100644 index 00000000..7a6f307e --- /dev/null +++ b/src/services/token.js @@ -0,0 +1,20 @@ +'use strict'; + +const jwt = require('jsonwebtoken'); +const config = require('../config'); + +function generateToken(userId) { + return jwt.sign({ userId }, config.jwtSecret, { + expiresIn: config.jwtExpiresIn, + }); +} + +function verifyToken(token) { + try { + return jwt.verify(token, config.jwtSecret); + } catch { + return null; + } +} + +module.exports = { generateToken, verifyToken }; diff --git a/src/tests/app.test.js b/src/tests/app.test.js new file mode 100644 index 00000000..7920a6e6 --- /dev/null +++ b/src/tests/app.test.js @@ -0,0 +1,465 @@ +'use strict'; + +const request = require('supertest'); +const app = require('../app'); +const { User } = require('../models/User'); + +beforeEach(() => { + User.reset(); +}); + +afterAll(() => { + User.reset(); +}); + +describe('Auth Routes', () => { + describe('GET /auth/register', () => { + it('should render register page', async () => { + const res = await request(app).get('/auth/register'); + + expect(res.status).toBe(200); + expect(res.text).toContain('Register'); + }); + }); + + describe('POST /auth/register', () => { + it('should register a new user', async () => { + const res = await request(app).post('/auth/register').send({ + name: 'Test User', + email: 'test@example.com', + password: 'Password1!', + confirmation: 'Password1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Registration Successful'); + }); + + it('should reject duplicate email', async () => { + await request(app).post('/auth/register').send({ + name: 'Test User', + email: 'test@example.com', + password: 'Password1!', + confirmation: 'Password1!', + }); + + const res = await request(app).post('/auth/register').send({ + name: 'Another User', + email: 'test@example.com', + password: 'Password2@', + confirmation: 'Password2@', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('already registered'); + }); + + it('should reject mismatched passwords', async () => { + const res = await request(app).post('/auth/register').send({ + name: 'Test User', + email: 'test@example.com', + password: 'Password1!', + confirmation: 'Different1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('do not match'); + }); + + it('should reject weak password', async () => { + const res = await request(app).post('/auth/register').send({ + name: 'Test User', + email: 'test@example.com', + password: 'weak', + confirmation: 'weak', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('at least 8 characters'); + }); + + it('should reject empty name', async () => { + const res = await request(app).post('/auth/register').send({ + name: '', + email: 'test@example.com', + password: 'Password1!', + confirmation: 'Password1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Name is required'); + }); + + it('should reject invalid email', async () => { + const res = await request(app).post('/auth/register').send({ + name: 'Test User', + email: 'invalid-email', + password: 'Password1!', + confirmation: 'Password1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Valid email'); + }); + }); + + describe('GET /auth/login', () => { + it('should render login page', async () => { + const res = await request(app).get('/auth/login'); + + expect(res.status).toBe(200); + expect(res.text).toContain('Login'); + }); + }); + + describe('POST /auth/login', () => { + it('should login with valid credentials', async () => { + const { activationToken } = User.create({ + name: 'Test', + email: 'test@example.com', + password: 'Password1!', + }); + + User.activate(activationToken); + + const res = await request(app).post('/auth/login').send({ + email: 'test@example.com', + password: 'Password1!', + }); + + expect(res.status).toBe(302); + expect(res.header.location).toBe('/profile'); + }); + + it('should reject invalid credentials', async () => { + const res = await request(app).post('/auth/login').send({ + email: 'test@example.com', + password: 'wrongpassword', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Invalid email or password'); + }); + + it('should reject inactive user', async () => { + User.create({ + name: 'Test', + email: 'test@example.com', + password: 'Password1!', + }); + + const res = await request(app).post('/auth/login').send({ + email: 'test@example.com', + password: 'Password1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('activate your account'); + }); + }); + + describe('GET /auth/activate/:token', () => { + it('should activate user with valid token', async () => { + const { activationToken } = User.create({ + name: 'Test', + email: 'test@example.com', + password: 'Password1!', + }); + + const res = await request(app).get(`/auth/activate/${activationToken}`); + + expect(res.status).toBe(302); + expect(res.header.location).toBe('/profile'); + }); + + it('should reject invalid activation token', async () => { + const res = await request(app).get('/auth/activate/invalid-token'); + + expect(res.status).toBe(200); + expect(res.text).toContain('Activation Failed'); + }); + }); + + describe('POST /auth/logout', () => { + it('should redirect to login when not authenticated', async () => { + const res = await request(app).post('/auth/logout'); + + expect(res.status).toBe(302); + expect(res.header.location).toBe('/auth/login'); + }); + + it('should logout authenticated user', async () => { + const { activationToken } = User.create({ + name: 'Test', + email: 'test@example.com', + password: 'Password1!', + }); + + User.activate(activationToken); + + const loginRes = await request(app).post('/auth/login').send({ + email: 'test@example.com', + password: 'Password1!', + }); + + const cookies = loginRes.headers['set-cookie']; + + const res = await request(app) + .post('/auth/logout') + .set('Cookie', cookies); + + expect(res.status).toBe(302); + expect(res.header.location).toBe('/auth/login'); + }); + }); +}); + +describe('Password Reset Routes', () => { + describe('GET /password/reset', () => { + it('should render reset request page', async () => { + const res = await request(app).get('/password/reset'); + + expect(res.status).toBe(200); + expect(res.text).toContain('Reset Password'); + }); + }); + + describe('POST /password/reset', () => { + it('should show sent page for any email', async () => { + const res = await request(app).post('/password/reset').send({ + email: 'test@example.com', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Email Sent'); + }); + + it('should reject invalid email', async () => { + const res = await request(app).post('/password/reset').send({ + email: 'invalid', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Valid email'); + }); + }); + + describe('GET /password/reset/:token', () => { + it('should render reset confirm page', async () => { + const res = await request(app).get('/password/reset/some-token'); + + expect(res.status).toBe(200); + expect(res.text).toContain('Set New Password'); + }); + }); + + describe('POST /password/reset/:token', () => { + it('should reset password with valid token', async () => { + User.create({ + name: 'Test', + email: 'test@example.com', + password: 'Password1!', + }); + + const token = User.createResetToken('test@example.com'); + + const res = await request(app).post(`/password/reset/${token}`).send({ + password: 'NewPassword1!', + confirmation: 'NewPassword1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Password Reset Successful'); + }); + + it('should reject mismatched passwords', async () => { + const res = await request(app).post('/password/reset/some-token').send({ + password: 'NewPassword1!', + confirmation: 'Different1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('do not match'); + }); + + it('should reject invalid token', async () => { + const res = await request(app) + .post('/password/reset/invalid-token') + .send({ + password: 'NewPassword1!', + confirmation: 'NewPassword1!', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Invalid or expired'); + }); + }); +}); + +describe('Profile Routes', () => { + let cookies; + + function setupAuthenticatedUser() { + const { activationToken } = User.create({ + name: 'Test User', + email: 'test@example.com', + password: 'Password1!', + }); + + User.activate(activationToken); + } + + async function loginUser() { + const loginRes = await request(app).post('/auth/login').send({ + email: 'test@example.com', + password: 'Password1!', + }); + + cookies = loginRes.headers['set-cookie']; + + return cookies; + } + + beforeEach(() => { + User.reset(); + setupAuthenticatedUser(); + }); + + beforeEach(async () => { + await loginUser(); + }); + + describe('GET /profile', () => { + it('should render profile page for authenticated user', async () => { + const res = await request(app).get('/profile').set('Cookie', cookies); + + expect(res.status).toBe(200); + expect(res.text).toContain('Profile'); + expect(res.text).toContain('Test User'); + }); + + it('should redirect to login when not authenticated', async () => { + const res = await request(app).get('/profile'); + + expect(res.status).toBe(302); + expect(res.header.location).toBe('/auth/login'); + }); + }); + + describe('POST /profile/name', () => { + it('should update name', async () => { + const res = await request(app) + .post('/profile/name') + .set('Cookie', cookies) + .send({ name: 'Updated Name' }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Updated Name'); + expect(res.text).toContain('Name updated successfully'); + }); + + it('should reject empty name', async () => { + const res = await request(app) + .post('/profile/name') + .set('Cookie', cookies) + .send({ name: '' }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Name is required'); + }); + }); + + describe('POST /profile/password', () => { + it('should update password with correct old password', async () => { + const res = await request(app) + .post('/profile/password') + .set('Cookie', cookies) + .send({ + oldPassword: 'Password1!', + newPassword: 'NewPassword2@', + confirmation: 'NewPassword2@', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Password updated successfully'); + }); + + it('should reject wrong old password', async () => { + const res = await request(app) + .post('/profile/password') + .set('Cookie', cookies) + .send({ + oldPassword: 'WrongPassword1!', + newPassword: 'NewPassword2@', + confirmation: 'NewPassword2@', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Current password is incorrect'); + }); + + it('should reject mismatched new passwords', async () => { + const res = await request(app) + .post('/profile/password') + .set('Cookie', cookies) + .send({ + oldPassword: 'Password1!', + newPassword: 'NewPassword2@', + confirmation: 'Different2@', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('do not match'); + }); + }); + + describe('POST /profile/email', () => { + it('should update email with correct password', async () => { + const res = await request(app) + .post('/profile/email') + .set('Cookie', cookies) + .send({ + password: 'Password1!', + newEmail: 'newemail@example.com', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Email updated successfully'); + }); + + it('should reject wrong password', async () => { + const res = await request(app) + .post('/profile/email') + .set('Cookie', cookies) + .send({ + password: 'WrongPassword1!', + newEmail: 'newemail@example.com', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Password is incorrect'); + }); + + it('should reject invalid email', async () => { + const res = await request(app) + .post('/profile/email') + .set('Cookie', cookies) + .send({ + password: 'Password1!', + newEmail: 'invalid-email', + }); + + expect(res.status).toBe(200); + expect(res.text).toContain('Valid email'); + }); + }); +}); + +describe('404 Page', () => { + it('should return 404 for unknown routes', async () => { + const res = await request(app).get('/nonexistent-page'); + + expect(res.status).toBe(404); + expect(res.text).toContain('Not Found'); + }); +}); diff --git a/src/views/auth/activate.ejs b/src/views/auth/activate.ejs new file mode 100644 index 00000000..55771703 --- /dev/null +++ b/src/views/auth/activate.ejs @@ -0,0 +1,29 @@ +<%- include('../partials/header') %> + +
+

Account Activation

+ + <% if (success) { %> +
+

Your account has been activated successfully!

+

Redirecting to your profile...

+
+ +

+ Go to Profile +

+ <% } else { %> +
+

Activation failed. The link may be invalid or expired.

+
+

+ Go to Login +

+ <% } %> +
+ +<%- include('../partials/footer') %> diff --git a/src/views/auth/login.ejs b/src/views/auth/login.ejs new file mode 100644 index 00000000..ecc13284 --- /dev/null +++ b/src/views/auth/login.ejs @@ -0,0 +1,28 @@ +<%- include('../partials/header') %> + +
+

Login

+ + <%- include('../partials/messages', { errors: errors }) %> + +
+
+ + +
+
+ + +
+ +
+ +

+ Don't have an account? Register +

+

+ Forgot your password? +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/auth/register-success.ejs b/src/views/auth/register-success.ejs new file mode 100644 index 00000000..ff6e9d75 --- /dev/null +++ b/src/views/auth/register-success.ejs @@ -0,0 +1,15 @@ +<%- include('../partials/header') %> + +
+

Registration Successful

+
+

Your account has been created!

+

We sent an activation email to <%= email %>.

+

Please check your inbox and click the activation link.

+
+

+ Go to Login +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/auth/register.ejs b/src/views/auth/register.ejs new file mode 100644 index 00000000..5992257d --- /dev/null +++ b/src/views/auth/register.ejs @@ -0,0 +1,42 @@ +<%- include('../partials/header') %> + +
+

Register

+ +
+

Password requirements:

+
    + <% passwordRules.forEach(function(rule) { %> +
  • <%= rule %>
  • + <% }); %> +
+
+ + <%- include('../partials/messages', { errors: errors }) %> + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +

+ Already have an account? Login +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/errors/404.ejs b/src/views/errors/404.ejs new file mode 100644 index 00000000..5cef5930 --- /dev/null +++ b/src/views/errors/404.ejs @@ -0,0 +1,11 @@ +<%- include('../partials/header') %> + +
+

404 - Page Not Found

+

The page you are looking for does not exist.

+

+ Go to Login +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/partials/footer.ejs b/src/views/partials/footer.ejs new file mode 100644 index 00000000..d652837e --- /dev/null +++ b/src/views/partials/footer.ejs @@ -0,0 +1,6 @@ + +
+

© 2026 Auth App

+
+ + diff --git a/src/views/partials/header.ejs b/src/views/partials/header.ejs new file mode 100644 index 00000000..7485d476 --- /dev/null +++ b/src/views/partials/header.ejs @@ -0,0 +1,25 @@ + + + + + + <%= title %> - Auth App + + + + +
diff --git a/src/views/partials/messages.ejs b/src/views/partials/messages.ejs new file mode 100644 index 00000000..bf1e9a51 --- /dev/null +++ b/src/views/partials/messages.ejs @@ -0,0 +1,15 @@ +<% if (errors && errors.length > 0) { %> +
+
    + <% errors.forEach(function(error) { %> +
  • <%= error %>
  • + <% }); %> +
+
+<% } %> + +<% if (typeof success !== 'undefined' && success) { %> +
+

<%= success %>

+
+<% } %> diff --git a/src/views/password/reset-confirm.ejs b/src/views/password/reset-confirm.ejs new file mode 100644 index 00000000..f425884c --- /dev/null +++ b/src/views/password/reset-confirm.ejs @@ -0,0 +1,21 @@ +<%- include('../partials/header') %> + +
+

Set New Password

+ + <%- include('../partials/messages', { errors: errors }) %> + +
+
+ + +
+
+ + +
+ +
+
+ +<%- include('../partials/footer') %> diff --git a/src/views/password/reset-request.ejs b/src/views/password/reset-request.ejs new file mode 100644 index 00000000..bb43ef38 --- /dev/null +++ b/src/views/password/reset-request.ejs @@ -0,0 +1,21 @@ +<%- include('../partials/header') %> + +
+

Reset Password

+ + <%- include('../partials/messages', { errors: errors }) %> + +
+
+ + +
+ +
+ +

+ Back to Login +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/password/reset-sent.ejs b/src/views/password/reset-sent.ejs new file mode 100644 index 00000000..e77c88a6 --- /dev/null +++ b/src/views/password/reset-sent.ejs @@ -0,0 +1,14 @@ +<%- include('../partials/header') %> + +
+

Email Sent

+
+

If an account with <%= email %> exists, a password reset link has been sent.

+

Please check your inbox.

+
+

+ Back to Login +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/password/reset-success.ejs b/src/views/password/reset-success.ejs new file mode 100644 index 00000000..7d47cdf7 --- /dev/null +++ b/src/views/password/reset-success.ejs @@ -0,0 +1,14 @@ +<%- include('../partials/header') %> + +
+

Password Reset Successful

+
+

Your password has been reset successfully!

+

You can now log in with your new password.

+
+

+ Go to Login +

+
+ +<%- include('../partials/footer') %> diff --git a/src/views/profile/index.ejs b/src/views/profile/index.ejs new file mode 100644 index 00000000..9799c5be --- /dev/null +++ b/src/views/profile/index.ejs @@ -0,0 +1,85 @@ +<%- include('../partials/header') %> + +
+

Profile

+ + <%- include('../partials/messages', { errors: errors, success: success }) %> + +
+

Name: <%= user.name %>

+

Email: <%= user.email %>

+

Status: <%= user.isActive ? 'Active' : 'Inactive' %>

+
+ +
+ + + +
+ +
+
+
+ + +
+ +
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ +
+
+
+ + +
+
+ + +
+ +

Your old email will be notified about this change.

+
+
+ +
+
+ +
+
+
+ + + +<%- include('../partials/footer') %>