Initial commit — specs pré-projet SatPRO + site de présentation (viewer, annotations, gestion des accès)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
|
||||
# curl pour le healthcheck du compose
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
# Dépendances (couche cache)
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Code source
|
||||
COPY src ./src
|
||||
|
||||
ENV PORT=8080
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["node", "src/server.js"]
|
||||
Generated
+988
@@ -0,0 +1,988 @@
|
||||
{
|
||||
"name": "satpro-specs-backend",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "satpro-specs-backend",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.21.2",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bcryptjs": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
|
||||
"integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.8",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.8.tgz",
|
||||
"integrity": "sha512-JNcyFQ64OiijEkPzUBTCe+hyPXUD/3LEldGQ6iF5LR1w00mx9o7xtDWHXBY2iItjdCFGoilOLNQbH943ut7pHA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "~1.2.0",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"on-finished": "~2.4.1",
|
||||
"qs": "~6.16.0",
|
||||
"raw-body": "~2.5.3",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"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/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-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/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"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/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-signature": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
|
||||
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cors": {
|
||||
"version": "2.8.6",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
|
||||
"integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"object-assign": "^4",
|
||||
"vary": "^1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.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/destroy": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
|
||||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"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/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/es-define-property": {
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
|
||||
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"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/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/express": {
|
||||
"version": "4.22.3",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.3.tgz",
|
||||
"integrity": "sha512-Bdcs4+3qlpVlx2NRn6fgX2Ue2/gGRaPeawebgclM0ERSCqDpA+owF1fdPwjJUTAJWMTuAaxjDf+hzb0/4eKvvw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "~1.20.5",
|
||||
"content-disposition": "~0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "~0.7.1",
|
||||
"cookie-signature": "~1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.3.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.0",
|
||||
"merge-descriptors": "1.0.3",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "~0.1.13",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "~6.16.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "~0.19.0",
|
||||
"serve-static": "~1.16.2",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "~2.0.1",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
|
||||
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"statuses": "~2.0.2",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"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": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"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",
|
||||
"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"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"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/gopd": {
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"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"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
|
||||
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"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/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"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/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/ms": {
|
||||
"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/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/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.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/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": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
||||
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/methods": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"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"
|
||||
},
|
||||
"funding": {
|
||||
"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/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-to-regexp": {
|
||||
"version": "0.1.13",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
|
||||
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"forwarded": "0.2.0",
|
||||
"ipaddr.js": "1.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.16.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
|
||||
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"es-define-property": "^1.0.1",
|
||||
"side-channel": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"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": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
|
||||
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"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/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": "7.8.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
|
||||
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"mime": "1.6.0",
|
||||
"ms": "2.1.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"range-parser": "~1.2.1",
|
||||
"statuses": "~2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "1.16.3",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
|
||||
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "~0.19.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"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/side-channel": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
|
||||
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.4",
|
||||
"side-channel-list": "^1.0.1",
|
||||
"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"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"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/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/type-is": {
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"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/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "satpro-specs-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "API Node servant les specs markdown SatPRO (lecture en direct) avec authentification multi-comptes.",
|
||||
"type": "module",
|
||||
"main": "src/server.js",
|
||||
"scripts": {
|
||||
"start": "node src/server.js",
|
||||
"dev": "node --watch src/server.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.21.2",
|
||||
"jsonwebtoken": "^9.0.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
// Stockage des annotations : un fichier JSON par document, dans ANNOTATIONS_DIR.
|
||||
// Format d'un fichier (ex. annotations/06-prestations.json) :
|
||||
// { "cle": "06-prestations", "annotations": [ { ...annotation... }, ... ] }
|
||||
//
|
||||
// Une annotation :
|
||||
// {
|
||||
// id: "a1b2c3", // identifiant court unique
|
||||
// docCle: "06-prestations", // document concerné
|
||||
// ancre: "4-1-decoupage", // id de section (slug du titre) ou "" (doc entier)
|
||||
// titreSection: "4.1 Découpage", // libellé de section au moment de l'annotation
|
||||
// type: "correction", // ajout | correction | question | remarque
|
||||
// texte: "…", // contenu libre
|
||||
// auteur: "invite1", // login de l'auteur
|
||||
// statut: "ouverte", // ouverte | traitee
|
||||
// creeLe: "2026-10-04T…Z",
|
||||
// modifieLe: "2026-10-04T…Z"
|
||||
// }
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
import { ANNOTATIONS_DIR } from './config.js';
|
||||
|
||||
const CLE_VALIDE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
|
||||
const TYPES = new Set(['ajout', 'correction', 'question', 'remarque']);
|
||||
const STATUTS = new Set(['ouverte', 'traitee']);
|
||||
|
||||
/** Garantit l'existence du dossier d'annotations. */
|
||||
async function assurerDossier() {
|
||||
await fs.mkdir(ANNOTATIONS_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
/** Chemin sûr du fichier JSON d'un document. */
|
||||
function cheminFichier(docCle) {
|
||||
if (!CLE_VALIDE.test(docCle)) {
|
||||
return null;
|
||||
}
|
||||
const chemin = path.resolve(ANNOTATIONS_DIR, `${docCle}.json`);
|
||||
const racine = path.resolve(ANNOTATIONS_DIR) + path.sep;
|
||||
if (!chemin.startsWith(racine)) {
|
||||
return null;
|
||||
}
|
||||
return chemin;
|
||||
}
|
||||
|
||||
/** Lit les annotations d'un document (tableau, éventuellement vide). */
|
||||
export async function lireAnnotations(docCle) {
|
||||
const chemin = cheminFichier(docCle);
|
||||
if (!chemin) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const brut = await fs.readFile(chemin, 'utf8');
|
||||
const data = JSON.parse(brut);
|
||||
return Array.isArray(data.annotations) ? data.annotations : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** Écrit (atomiquement) les annotations d'un document. */
|
||||
async function ecrireAnnotations(docCle, annotations) {
|
||||
const chemin = cheminFichier(docCle);
|
||||
if (!chemin) {
|
||||
throw new Error('Clé de document invalide.');
|
||||
}
|
||||
await assurerDossier();
|
||||
const contenu = JSON.stringify({ cle: docCle, annotations }, null, 2);
|
||||
const tmp = `${chemin}.tmp-${process.pid}`;
|
||||
await fs.writeFile(tmp, contenu, 'utf8');
|
||||
await fs.rename(tmp, chemin); // rename atomique
|
||||
}
|
||||
|
||||
/** Normalise/valide les champs d'entrée. Retourne { ok, valeur|erreur }. */
|
||||
function validerEntree({ type, texte, ancre, titreSection, statut }) {
|
||||
const texteNet = typeof texte === 'string' ? texte.trim() : '';
|
||||
if (!texteNet) {
|
||||
return { ok: false, erreur: 'Le texte de l’annotation est requis.' };
|
||||
}
|
||||
if (texteNet.length > 5000) {
|
||||
return { ok: false, erreur: 'Texte trop long (5000 caractères max).' };
|
||||
}
|
||||
const typeNet = TYPES.has(type) ? type : 'remarque';
|
||||
const statutNet = STATUTS.has(statut) ? statut : 'ouverte';
|
||||
return {
|
||||
ok: true,
|
||||
valeur: {
|
||||
type: typeNet,
|
||||
texte: texteNet,
|
||||
ancre: typeof ancre === 'string' ? ancre.slice(0, 200) : '',
|
||||
titreSection: typeof titreSection === 'string' ? titreSection.slice(0, 300) : '',
|
||||
statut: statutNet
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Crée une annotation sur un document. */
|
||||
export async function creerAnnotation(docCle, auteur, entree) {
|
||||
if (!CLE_VALIDE.test(docCle)) {
|
||||
throw new Error('Clé de document invalide.');
|
||||
}
|
||||
const v = validerEntree(entree);
|
||||
if (!v.ok) {
|
||||
return { erreur: v.erreur };
|
||||
}
|
||||
const maintenant = new Date().toISOString();
|
||||
const annotation = {
|
||||
id: crypto.randomBytes(5).toString('hex'),
|
||||
docCle,
|
||||
ancre: v.valeur.ancre,
|
||||
titreSection: v.valeur.titreSection,
|
||||
type: v.valeur.type,
|
||||
texte: v.valeur.texte,
|
||||
auteur,
|
||||
statut: 'ouverte',
|
||||
creeLe: maintenant,
|
||||
modifieLe: maintenant
|
||||
};
|
||||
const liste = await lireAnnotations(docCle);
|
||||
liste.push(annotation);
|
||||
await ecrireAnnotations(docCle, liste);
|
||||
return { annotation };
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour une annotation (texte/type/statut).
|
||||
* Autorisé si l'appelant est l'auteur OU administrateur.
|
||||
*/
|
||||
export async function majAnnotation(docCle, id, appelant, estAdminAppelant, maj) {
|
||||
const liste = await lireAnnotations(docCle);
|
||||
const idx = liste.findIndex((a) => a.id === id);
|
||||
if (idx === -1) {
|
||||
return { erreur: 'introuvable' };
|
||||
}
|
||||
const annotation = liste[idx];
|
||||
if (annotation.auteur !== appelant && !estAdminAppelant) {
|
||||
return { erreur: 'interdit' };
|
||||
}
|
||||
if (typeof maj.texte === 'string') {
|
||||
const t = maj.texte.trim();
|
||||
if (!t) return { erreur: 'Le texte ne peut pas être vide.' };
|
||||
if (t.length > 5000) return { erreur: 'Texte trop long (5000 caractères max).' };
|
||||
annotation.texte = t;
|
||||
}
|
||||
if (TYPES.has(maj.type)) {
|
||||
annotation.type = maj.type;
|
||||
}
|
||||
if (STATUTS.has(maj.statut)) {
|
||||
annotation.statut = maj.statut;
|
||||
}
|
||||
annotation.modifieLe = new Date().toISOString();
|
||||
liste[idx] = annotation;
|
||||
await ecrireAnnotations(docCle, liste);
|
||||
return { annotation };
|
||||
}
|
||||
|
||||
/** Supprime une annotation (auteur ou admin). */
|
||||
export async function supprimerAnnotation(docCle, id, appelant, estAdminAppelant) {
|
||||
const liste = await lireAnnotations(docCle);
|
||||
const idx = liste.findIndex((a) => a.id === id);
|
||||
if (idx === -1) {
|
||||
return { erreur: 'introuvable' };
|
||||
}
|
||||
if (liste[idx].auteur !== appelant && !estAdminAppelant) {
|
||||
return { erreur: 'interdit' };
|
||||
}
|
||||
liste.splice(idx, 1);
|
||||
await ecrireAnnotations(docCle, liste);
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/** Liste TOUTES les annotations (tous documents), triées par document puis date. */
|
||||
export async function listerToutes() {
|
||||
await assurerDossier();
|
||||
let fichiers = [];
|
||||
try {
|
||||
fichiers = await fs.readdir(ANNOTATIONS_DIR);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
const toutes = [];
|
||||
for (const nom of fichiers.filter((f) => /\.json$/i.test(f))) {
|
||||
const docCle = nom.replace(/\.json$/i, '');
|
||||
const liste = await lireAnnotations(docCle);
|
||||
toutes.push(...liste);
|
||||
}
|
||||
toutes.sort((a, b) => {
|
||||
if (a.docCle !== b.docCle) return a.docCle.localeCompare(b.docCle, 'fr', { numeric: true });
|
||||
return a.creeLe.localeCompare(b.creeLe);
|
||||
});
|
||||
return toutes;
|
||||
}
|
||||
|
||||
/** Construit un markdown de synthèse regroupé par document puis par section. */
|
||||
export function construireExportMarkdown(toutes) {
|
||||
const lignes = [];
|
||||
lignes.push('# Annotations des specs SatPRO — synthèse');
|
||||
lignes.push('');
|
||||
lignes.push(`> Export généré le ${new Date().toISOString()}.`);
|
||||
lignes.push(`> ${toutes.length} annotation(s). À transmettre à Kiro pour mise à jour des .md.`);
|
||||
lignes.push('');
|
||||
|
||||
const parDoc = new Map();
|
||||
for (const a of toutes) {
|
||||
if (!parDoc.has(a.docCle)) parDoc.set(a.docCle, []);
|
||||
parDoc.get(a.docCle).push(a);
|
||||
}
|
||||
|
||||
const emoji = { ajout: '➕', correction: '✏️', question: '❓', remarque: '💬' };
|
||||
|
||||
for (const [docCle, liste] of parDoc) {
|
||||
lignes.push(`## ${docCle}`);
|
||||
lignes.push('');
|
||||
// Regroupe par section (titreSection), les annotations "document entier" en tête.
|
||||
const parSection = new Map();
|
||||
for (const a of liste) {
|
||||
const cle = a.titreSection || '(document entier)';
|
||||
if (!parSection.has(cle)) parSection.set(cle, []);
|
||||
parSection.get(cle).push(a);
|
||||
}
|
||||
for (const [section, annos] of parSection) {
|
||||
lignes.push(`### ${section}`);
|
||||
lignes.push('');
|
||||
for (const a of annos) {
|
||||
const type = emoji[a.type] || '💬';
|
||||
const etat = a.statut === 'traitee' ? ' _(traitée)_' : '';
|
||||
lignes.push(`- ${type} **${a.type}** — _${a.auteur}_, ${a.creeLe}${etat}`);
|
||||
for (const l of a.texte.split(/\r?\n/)) {
|
||||
lignes.push(` > ${l}`);
|
||||
}
|
||||
lignes.push('');
|
||||
}
|
||||
}
|
||||
}
|
||||
return lignes.join('\n');
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// Authentification : vérification des identifiants et émission/validation des JWT.
|
||||
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import {
|
||||
JWT_SECRET,
|
||||
JWT_EXPIRATION_MINUTES,
|
||||
ADMIN_USER,
|
||||
ADMIN_PASSWORD,
|
||||
estAdmin
|
||||
} from './config.js';
|
||||
import { verifierConnexion, trouverUtilisateur } from './users.js';
|
||||
|
||||
/**
|
||||
* Vérifie les identifiants.
|
||||
* Ordre : d'abord l'ADMIN du .env, puis les comptes gérés (store users.json).
|
||||
*
|
||||
* Retourne un objet décrivant le résultat :
|
||||
* - { ok:true, login, role, admin, doitChangerMdp }
|
||||
* - { ok:false, raison } avec raison ∈ 'identifiants' | 'desactive'
|
||||
*/
|
||||
export async function verifierIdentifiants(login, motDePasse) {
|
||||
if (typeof login !== 'string' || typeof motDePasse !== 'string') {
|
||||
return { ok: false, raison: 'identifiants' };
|
||||
}
|
||||
|
||||
// 1) Compte administrateur (défini dans le .env, hors store).
|
||||
if (ADMIN_USER && login === ADMIN_USER) {
|
||||
if (motDePasse === ADMIN_PASSWORD) {
|
||||
return { ok: true, login, role: 'admin', admin: true, doitChangerMdp: false };
|
||||
}
|
||||
return { ok: false, raison: 'identifiants' };
|
||||
}
|
||||
|
||||
// 2) Comptes gérés via le site.
|
||||
const res = await verifierConnexion(login, motDePasse);
|
||||
if (res.ok) {
|
||||
return {
|
||||
ok: true,
|
||||
login: res.utilisateur.login,
|
||||
role: res.utilisateur.role,
|
||||
admin: false,
|
||||
doitChangerMdp: res.utilisateur.doitChangerMdp
|
||||
};
|
||||
}
|
||||
if (res.raison === 'desactive') {
|
||||
return { ok: false, raison: 'desactive' };
|
||||
}
|
||||
return { ok: false, raison: 'identifiants' };
|
||||
}
|
||||
|
||||
/**
|
||||
* Émet un JWT signé. Le token ne porte que le login (`sub`) : le rôle est relu à
|
||||
* chaque requête depuis le store, pour que tout changement de rôle ou désactivation
|
||||
* décidé par l'admin prenne effet immédiatement, sans attendre une reconnexion.
|
||||
*/
|
||||
export function emettreJeton(login) {
|
||||
return jwt.sign({ sub: login }, JWT_SECRET, {
|
||||
expiresIn: `${JWT_EXPIRATION_MINUTES}m`
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware Express : exige un JWT valide (Authorization: Bearer <token>).
|
||||
* Renseigne req.utilisateur = { login, role, admin }. Le rôle est relu en direct :
|
||||
* - admin du .env -> role 'admin' ;
|
||||
* - sinon rôle courant du store ; un compte supprimé ou désactivé est refusé (401/403).
|
||||
*/
|
||||
export async function exigerAuth(req, res, next) {
|
||||
const entete = req.headers.authorization || '';
|
||||
const [schema, jeton] = entete.split(' ');
|
||||
if (schema !== 'Bearer' || !jeton) {
|
||||
return res.status(401).json({ erreur: 'Authentification requise.' });
|
||||
}
|
||||
let charge;
|
||||
try {
|
||||
charge = jwt.verify(jeton, JWT_SECRET);
|
||||
} catch {
|
||||
return res.status(401).json({ erreur: 'Session invalide ou expirée.' });
|
||||
}
|
||||
|
||||
const login = charge.sub;
|
||||
if (estAdmin(login)) {
|
||||
req.utilisateur = { login, role: 'admin', admin: true };
|
||||
return next();
|
||||
}
|
||||
|
||||
// Rôle relu depuis le store à chaque requête.
|
||||
const u = await trouverUtilisateur(login);
|
||||
if (!u) {
|
||||
return res.status(401).json({ erreur: 'Compte introuvable.' });
|
||||
}
|
||||
if (u.role === 'desactive') {
|
||||
return res.status(403).json({ erreur: 'Ce compte est désactivé.' });
|
||||
}
|
||||
req.utilisateur = { login, role: u.role, admin: false };
|
||||
return next();
|
||||
}
|
||||
|
||||
/** Middleware : réservé à l'administrateur. */
|
||||
export function exigerAdmin(req, res, next) {
|
||||
if (!req.utilisateur?.admin) {
|
||||
return res.status(403).json({ erreur: 'Réservé à l’administrateur.' });
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware : exige un rôle autorisé à contribuer (annoter).
|
||||
* Admin et contributeur passent ; consultation est refusé (403).
|
||||
*/
|
||||
export function exigerContributeur(req, res, next) {
|
||||
const role = req.utilisateur?.role;
|
||||
if (role === 'admin' || role === 'contributeur') {
|
||||
return next();
|
||||
}
|
||||
return res.status(403).json({ erreur: 'Votre accès est en lecture seule.' });
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Configuration du backend, lue depuis les variables d'environnement.
|
||||
// Aucune valeur sensible n'est codée en dur : tout vient de l'environnement (.env via docker-compose).
|
||||
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* Répertoire contenant les fichiers .md à présenter.
|
||||
* Par défaut, en conteneur, les specs sont montées en lecture seule sur /specs.
|
||||
* En dev local, on retombe sur le dossier docs/specs-pre-projet du dépôt.
|
||||
*/
|
||||
export const SPECS_DIR =
|
||||
process.env.SPECS_DIR ||
|
||||
path.resolve(__dirname, '../../../docs/specs-pre-projet');
|
||||
|
||||
/**
|
||||
* Répertoire d'écriture des annotations (un fichier JSON par document).
|
||||
* En conteneur, monté en lecture-écriture sur /annotations (volume dédié).
|
||||
* En dev local, retombe sur site/annotations.
|
||||
*/
|
||||
export const ANNOTATIONS_DIR =
|
||||
process.env.ANNOTATIONS_DIR ||
|
||||
path.resolve(__dirname, '../../annotations');
|
||||
|
||||
/**
|
||||
* Répertoire d'écriture des comptes utilisateurs gérés via le site (users.json).
|
||||
* En conteneur, monté en lecture-écriture sur /users (volume dédié).
|
||||
* En dev local, retombe sur site/users.
|
||||
*/
|
||||
export const USERS_DIR =
|
||||
process.env.USERS_DIR ||
|
||||
path.resolve(__dirname, '../../users');
|
||||
|
||||
/** Port d'écoute HTTP du backend. */
|
||||
export const PORT = Number(process.env.PORT || 8080);
|
||||
|
||||
/** Secret de signature des JWT. OBLIGATOIRE : le serveur refuse de démarrer sans. */
|
||||
export const JWT_SECRET = process.env.JWT_SECRET || '';
|
||||
|
||||
/** Durée de validité d'un jeton de session, en minutes. */
|
||||
export const JWT_EXPIRATION_MINUTES = Number(process.env.JWT_EXPIRATION_MINUTES || 720);
|
||||
|
||||
/**
|
||||
* Compte ADMINISTRATEUR unique, défini dans le .env (hors du store géré par le site).
|
||||
* C'est le seul compte qui ne vit pas dans users.json. Il gère les accès et les exports.
|
||||
* ADMIN_USER=madjax
|
||||
* ADMIN_PASSWORD=Change-moi
|
||||
*/
|
||||
export const ADMIN_USER = (process.env.ADMIN_USER || '').trim();
|
||||
export const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || '';
|
||||
|
||||
/** Vrai si le login correspond à l'administrateur du .env. */
|
||||
export function estAdmin(login) {
|
||||
return !!ADMIN_USER && login === ADMIN_USER;
|
||||
}
|
||||
|
||||
/** Validation de la configuration au démarrage : échec rapide si incohérent. */
|
||||
export function validerConfig() {
|
||||
const erreurs = [];
|
||||
if (!JWT_SECRET || JWT_SECRET.length < 32) {
|
||||
erreurs.push('JWT_SECRET est requis et doit faire au moins 32 caractères.');
|
||||
}
|
||||
if (!ADMIN_USER || !ADMIN_PASSWORD) {
|
||||
erreurs.push('ADMIN_USER et ADMIN_PASSWORD sont requis (compte administrateur).');
|
||||
}
|
||||
return erreurs;
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
// Point d'entrée du backend : API Express.
|
||||
// GET /health -> sonde de santé (publique)
|
||||
// POST /api/auth/login -> { login, motDePasse } -> { token, login, role, admin, doitChangerMdp }
|
||||
// POST /api/auth/change-password -> { ancien, nouveau } (protégé)
|
||||
// GET /api/specs[/:cle] -> documents markdown (protégé)
|
||||
// GET/POST/PUT/DELETE /api/annotations -> annotations (contrib. pour l'écriture)
|
||||
// GET/POST/PUT/DELETE /api/users -> gestion des comptes (admin)
|
||||
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
|
||||
import { PORT, SPECS_DIR, validerConfig } from './config.js';
|
||||
import {
|
||||
verifierIdentifiants,
|
||||
emettreJeton,
|
||||
exigerAuth,
|
||||
exigerAdmin,
|
||||
exigerContributeur
|
||||
} from './auth.js';
|
||||
import { listerDocuments, obtenirDocument } from './specs.js';
|
||||
import {
|
||||
lireAnnotations,
|
||||
creerAnnotation,
|
||||
majAnnotation,
|
||||
supprimerAnnotation,
|
||||
listerToutes,
|
||||
construireExportMarkdown
|
||||
} from './annotations.js';
|
||||
import {
|
||||
listerUtilisateurs,
|
||||
creerUtilisateur,
|
||||
definirRole,
|
||||
reinitialiserMotDePasse,
|
||||
changerMotDePasse,
|
||||
supprimerUtilisateur,
|
||||
amorcerSiVide
|
||||
} from './users.js';
|
||||
|
||||
// --- Validation de configuration : échec rapide au démarrage ---
|
||||
const erreursConfig = validerConfig();
|
||||
if (erreursConfig.length > 0) {
|
||||
for (const e of erreursConfig) {
|
||||
console.error(`[config] ${e}`);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// --- Amorçage des comptes initiaux (une seule fois, si le store est vide) ---
|
||||
// Les 3 comptes repris de l'ancien .env, en contributeur, avec changement de mot de
|
||||
// passe imposé à la première connexion. Le seed est modifiable via SEED_USERS
|
||||
// ("login:mdp:role,...") mais possède une valeur par défaut.
|
||||
function parserSeed() {
|
||||
const brut = (process.env.SEED_USERS || '').trim();
|
||||
if (!brut) {
|
||||
return [
|
||||
{ login: 'nikolaz.stephan', motDePasse: 'A251365', role: 'contributeur' },
|
||||
{ login: 'philippe.courivaud', motDePasse: 'A252750', role: 'contributeur' },
|
||||
{ login: 'bruno.peyraud', motDePasse: 'A251992', role: 'contributeur' }
|
||||
];
|
||||
}
|
||||
return brut.split(',').map((t) => {
|
||||
const [login, motDePasse, role] = t.split(':');
|
||||
return { login: (login || '').trim(), motDePasse, role: (role || 'contributeur').trim() };
|
||||
});
|
||||
}
|
||||
|
||||
await amorcerSiVide(parserSeed()).then((r) => {
|
||||
if (r.amorce) {
|
||||
console.log(`[satpro-specs] ${r.nombre} compte(s) initial(aux) amorcé(s).`);
|
||||
}
|
||||
});
|
||||
|
||||
const app = express();
|
||||
app.use(express.json({ limit: '256kb' }));
|
||||
app.use(cors());
|
||||
|
||||
// Empêche l'indexation côté API également.
|
||||
app.use((req, res, next) => {
|
||||
res.setHeader('X-Robots-Tag', 'noindex, nofollow');
|
||||
next();
|
||||
});
|
||||
|
||||
// --- Santé (publique) ---
|
||||
app.get('/health', (req, res) => {
|
||||
res.json({ statut: 'ok' });
|
||||
});
|
||||
|
||||
// --- Authentification ---
|
||||
app.post('/api/auth/login', async (req, res) => {
|
||||
const { login, motDePasse } = req.body || {};
|
||||
const r = await verifierIdentifiants(login, motDePasse);
|
||||
if (!r.ok) {
|
||||
if (r.raison === 'desactive') {
|
||||
return res.status(403).json({ erreur: 'Ce compte est désactivé.' });
|
||||
}
|
||||
return res.status(401).json({ erreur: 'Identifiants invalides.' });
|
||||
}
|
||||
const token = emettreJeton(r.login);
|
||||
return res.json({
|
||||
token,
|
||||
login: r.login,
|
||||
role: r.role,
|
||||
admin: r.admin,
|
||||
doitChangerMdp: r.doitChangerMdp
|
||||
});
|
||||
});
|
||||
|
||||
// Changement de mot de passe par l'utilisateur lui-même (comptes gérés).
|
||||
app.post('/api/auth/change-password', exigerAuth, async (req, res) => {
|
||||
if (req.utilisateur.admin) {
|
||||
return res.status(400).json({ erreur: "Le compte administrateur se gère via le fichier .env." });
|
||||
}
|
||||
const { ancien, nouveau } = req.body || {};
|
||||
const r = await changerMotDePasse(req.utilisateur.login, ancien, nouveau);
|
||||
if (r.erreur === 'introuvable') {
|
||||
return res.status(404).json({ erreur: 'Compte introuvable.' });
|
||||
}
|
||||
if (r.erreur === 'mauvais_ancien') {
|
||||
return res.status(400).json({ erreur: 'Ancien mot de passe incorrect.' });
|
||||
}
|
||||
if (r.erreur) {
|
||||
return res.status(400).json({ erreur: r.erreur });
|
||||
}
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// --- Specs (protégées) ---
|
||||
app.get('/api/specs', exigerAuth, async (req, res) => {
|
||||
const docs = await listerDocuments();
|
||||
res.json(docs.map(({ cle, titre }) => ({ cle, titre, disponible: true })));
|
||||
});
|
||||
|
||||
app.get('/api/specs/:cle', exigerAuth, async (req, res) => {
|
||||
const doc = await obtenirDocument(req.params.cle);
|
||||
if (!doc) {
|
||||
return res.status(404).json({ erreur: 'Document introuvable.' });
|
||||
}
|
||||
res.json(doc);
|
||||
});
|
||||
|
||||
// --- Gestion des comptes (admin uniquement) ---
|
||||
app.get('/api/users', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
res.json(await listerUtilisateurs());
|
||||
});
|
||||
|
||||
app.post('/api/users', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
const { login, motDePasse, role } = req.body || {};
|
||||
const r = await creerUtilisateur({ login, motDePasse, role });
|
||||
if (r.erreur) {
|
||||
return res.status(400).json({ erreur: r.erreur });
|
||||
}
|
||||
res.status(201).json(r.utilisateur);
|
||||
});
|
||||
|
||||
app.put('/api/users/:login/role', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
const r = await definirRole(req.params.login, (req.body || {}).role);
|
||||
if (r.erreur === 'introuvable') {
|
||||
return res.status(404).json({ erreur: 'Compte introuvable.' });
|
||||
}
|
||||
if (r.erreur) {
|
||||
return res.status(400).json({ erreur: r.erreur });
|
||||
}
|
||||
res.json(r.utilisateur);
|
||||
});
|
||||
|
||||
app.post('/api/users/:login/reset-password', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
const r = await reinitialiserMotDePasse(req.params.login, (req.body || {}).motDePasse);
|
||||
if (r.erreur === 'introuvable') {
|
||||
return res.status(404).json({ erreur: 'Compte introuvable.' });
|
||||
}
|
||||
if (r.erreur) {
|
||||
return res.status(400).json({ erreur: r.erreur });
|
||||
}
|
||||
res.json(r.utilisateur);
|
||||
});
|
||||
|
||||
app.delete('/api/users/:login', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
const r = await supprimerUtilisateur(req.params.login);
|
||||
if (r.erreur === 'introuvable') {
|
||||
return res.status(404).json({ erreur: 'Compte introuvable.' });
|
||||
}
|
||||
res.status(204).end();
|
||||
});
|
||||
|
||||
// --- Annotations ---
|
||||
|
||||
// Export global (admin). Placé AVANT /api/annotations/:cle.
|
||||
app.get('/api/annotations/export.md', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
const toutes = await listerToutes();
|
||||
const md = construireExportMarkdown(toutes);
|
||||
res.setHeader('Content-Type', 'text/markdown; charset=utf-8');
|
||||
res.setHeader('Content-Disposition', 'attachment; filename="annotations-satpro.md"');
|
||||
res.send(md);
|
||||
});
|
||||
|
||||
app.get('/api/annotations/export.json', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
const toutes = await listerToutes();
|
||||
res.setHeader('Content-Disposition', 'attachment; filename="annotations-satpro.json"');
|
||||
res.json(toutes);
|
||||
});
|
||||
|
||||
// Liste de toutes les annotations (admin).
|
||||
app.get('/api/annotations', exigerAuth, exigerAdmin, async (req, res) => {
|
||||
res.json(await listerToutes());
|
||||
});
|
||||
|
||||
// Annotations d'un document (tout utilisateur authentifié, y compris consultation en lecture).
|
||||
app.get('/api/annotations/:cle', exigerAuth, async (req, res) => {
|
||||
const liste = await lireAnnotations(req.params.cle);
|
||||
res.json(liste);
|
||||
});
|
||||
|
||||
// Création — réservé aux contributeurs (et admin).
|
||||
app.post('/api/annotations/:cle', exigerAuth, exigerContributeur, async (req, res) => {
|
||||
const resultat = await creerAnnotation(req.params.cle, req.utilisateur.login, req.body || {});
|
||||
if (resultat.erreur) {
|
||||
return res.status(400).json({ erreur: resultat.erreur });
|
||||
}
|
||||
res.status(201).json(resultat.annotation);
|
||||
});
|
||||
|
||||
// Mise à jour — contributeur/admin, et seulement auteur ou admin.
|
||||
app.put('/api/annotations/:cle/:id', exigerAuth, exigerContributeur, async (req, res) => {
|
||||
const resultat = await majAnnotation(
|
||||
req.params.cle,
|
||||
req.params.id,
|
||||
req.utilisateur.login,
|
||||
req.utilisateur.admin,
|
||||
req.body || {}
|
||||
);
|
||||
if (resultat.erreur === 'introuvable') {
|
||||
return res.status(404).json({ erreur: 'Annotation introuvable.' });
|
||||
}
|
||||
if (resultat.erreur === 'interdit') {
|
||||
return res.status(403).json({ erreur: 'Vous ne pouvez modifier que vos annotations.' });
|
||||
}
|
||||
if (resultat.erreur) {
|
||||
return res.status(400).json({ erreur: resultat.erreur });
|
||||
}
|
||||
res.json(resultat.annotation);
|
||||
});
|
||||
|
||||
// Suppression — contributeur/admin, et seulement auteur ou admin.
|
||||
app.delete('/api/annotations/:cle/:id', exigerAuth, exigerContributeur, async (req, res) => {
|
||||
const resultat = await supprimerAnnotation(
|
||||
req.params.cle,
|
||||
req.params.id,
|
||||
req.utilisateur.login,
|
||||
req.utilisateur.admin
|
||||
);
|
||||
if (resultat.erreur === 'introuvable') {
|
||||
return res.status(404).json({ erreur: 'Annotation introuvable.' });
|
||||
}
|
||||
if (resultat.erreur === 'interdit') {
|
||||
return res.status(403).json({ erreur: 'Vous ne pouvez supprimer que vos annotations.' });
|
||||
}
|
||||
res.status(204).end();
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`[satpro-specs] backend à l'écoute sur :${PORT}`);
|
||||
console.log(`[satpro-specs] specs lues depuis : ${SPECS_DIR}`);
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
// Lecture des fichiers de specs Markdown depuis le disque, EN DIRECT.
|
||||
// Aucune mise en cache du contenu : chaque requête relit le fichier, de sorte que
|
||||
// les éditions faites dans l'IDE sont immédiatement visibles après rafraîchissement.
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import { SPECS_DIR } from './config.js';
|
||||
|
||||
/**
|
||||
* Clé d'un document = nom de fichier sans extension (ex. "05-initialisation-contrat").
|
||||
* On n'autorise que ce format pour empêcher toute traversée de répertoire.
|
||||
*/
|
||||
const CLE_VALIDE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
|
||||
|
||||
/** Convertit un nom de fichier en clé (retire l'extension .md). */
|
||||
function fichierVersCle(nomFichier) {
|
||||
return nomFichier.replace(/\.md$/i, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dérive un titre lisible :
|
||||
* - priorité au premier titre de niveau 1 (# ...) du contenu ;
|
||||
* - sinon, à partir du nom de fichier (préfixe numérique retiré, tirets -> espaces).
|
||||
*/
|
||||
function deriverTitre(cle, contenu) {
|
||||
const ligneTitre = contenu
|
||||
.split(/\r?\n/)
|
||||
.find((l) => /^#\s+/.test(l.trim()));
|
||||
if (ligneTitre) {
|
||||
return ligneTitre.trim().replace(/^#\s+/, '').trim();
|
||||
}
|
||||
// Repli : "05-initialisation-contrat" -> "Initialisation contrat"
|
||||
const sansPrefixe = cle.replace(/^\d+[-_]?/, '');
|
||||
const mots = sansPrefixe.replace(/[-_]+/g, ' ').trim();
|
||||
return mots.charAt(0).toUpperCase() + mots.slice(1);
|
||||
}
|
||||
|
||||
/** Résout de façon sûre le chemin d'un fichier .md à partir d'une clé. */
|
||||
function cheminSur(cle) {
|
||||
if (!CLE_VALIDE.test(cle)) {
|
||||
return null;
|
||||
}
|
||||
const chemin = path.resolve(SPECS_DIR, `${cle}.md`);
|
||||
// Garde-fou anti-traversée : le chemin résolu doit rester sous SPECS_DIR.
|
||||
const racine = path.resolve(SPECS_DIR) + path.sep;
|
||||
if (!chemin.startsWith(racine)) {
|
||||
return null;
|
||||
}
|
||||
return chemin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste les documents disponibles, triés par nom de fichier (préfixes 00, 01, …).
|
||||
* Retourne [{ cle, titre, ordre }].
|
||||
*/
|
||||
export async function listerDocuments() {
|
||||
let entrees;
|
||||
try {
|
||||
entrees = await fs.readdir(SPECS_DIR, { withFileTypes: true });
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
|
||||
const fichiersMd = entrees
|
||||
.filter((e) => e.isFile() && /\.md$/i.test(e.name))
|
||||
.map((e) => e.name)
|
||||
.sort((a, b) => a.localeCompare(b, 'fr', { numeric: true }));
|
||||
|
||||
const docs = [];
|
||||
for (const nom of fichiersMd) {
|
||||
const cle = fichierVersCle(nom);
|
||||
if (!CLE_VALIDE.test(cle)) continue;
|
||||
let contenu = '';
|
||||
try {
|
||||
contenu = await fs.readFile(path.join(SPECS_DIR, nom), 'utf8');
|
||||
} catch {
|
||||
// ignore le fichier illisible
|
||||
continue;
|
||||
}
|
||||
docs.push({ cle, titre: deriverTitre(cle, contenu), fichier: nom });
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le contenu Markdown d'un document par sa clé, ou null si introuvable.
|
||||
* { cle, titre, markdown }
|
||||
*/
|
||||
export async function obtenirDocument(cle) {
|
||||
const chemin = cheminSur(cle);
|
||||
if (!chemin) {
|
||||
return null;
|
||||
}
|
||||
let markdown;
|
||||
try {
|
||||
markdown = await fs.readFile(chemin, 'utf8');
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return { cle, titre: deriverTitre(cle, markdown), markdown };
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
// Gestion des comptes utilisateurs gérés via le site (hors admin, défini dans .env).
|
||||
// Stockage : un unique fichier JSON { "users": [ ... ] } dans USERS_DIR/users.json.
|
||||
//
|
||||
// Un utilisateur :
|
||||
// {
|
||||
// login: "nikolaz.stephan",
|
||||
// motDePasseHash: "$2a$10$...", // bcrypt, jamais en clair
|
||||
// role: "contributeur", // consultation | contributeur | desactive
|
||||
// doitChangerMdp: true, // force le changement à la prochaine connexion
|
||||
// creeLe, modifieLe
|
||||
// }
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
import { USERS_DIR } from './config.js';
|
||||
|
||||
export const ROLES = ['consultation', 'contributeur', 'desactive'];
|
||||
const LOGIN_VALIDE = /^[a-zA-Z0-9._-]{2,64}$/;
|
||||
const FICHIER = () => path.join(USERS_DIR, 'users.json');
|
||||
|
||||
async function assurerDossier() {
|
||||
await fs.mkdir(USERS_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
/** Lit la liste brute des utilisateurs (avec hash). Usage interne. */
|
||||
async function lireTous() {
|
||||
try {
|
||||
const brut = await fs.readFile(FICHIER(), 'utf8');
|
||||
const data = JSON.parse(brut);
|
||||
return Array.isArray(data.users) ? data.users : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** Écrit (atomiquement) la liste des utilisateurs. */
|
||||
async function ecrireTous(users) {
|
||||
await assurerDossier();
|
||||
const contenu = JSON.stringify({ users }, null, 2);
|
||||
const tmp = `${FICHIER()}.tmp-${process.pid}`;
|
||||
await fs.writeFile(tmp, contenu, 'utf8');
|
||||
await fs.rename(tmp, FICHIER());
|
||||
}
|
||||
|
||||
/** Projection publique (sans le hash de mot de passe). */
|
||||
function versPublic(u) {
|
||||
return {
|
||||
login: u.login,
|
||||
role: u.role,
|
||||
doitChangerMdp: !!u.doitChangerMdp,
|
||||
creeLe: u.creeLe,
|
||||
modifieLe: u.modifieLe
|
||||
};
|
||||
}
|
||||
|
||||
/** Liste publique de tous les comptes (sans hash). */
|
||||
export async function listerUtilisateurs() {
|
||||
const users = await lireTous();
|
||||
return users
|
||||
.sort((a, b) => a.login.localeCompare(b.login, 'fr'))
|
||||
.map(versPublic);
|
||||
}
|
||||
|
||||
/** Récupère un utilisateur par login (objet brut avec hash) ou null. */
|
||||
export async function trouverUtilisateur(login) {
|
||||
const users = await lireTous();
|
||||
return users.find((u) => u.login === login) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie les identifiants d'un compte géré.
|
||||
* Retourne { ok, raison, utilisateur } :
|
||||
* - raison = 'inconnu' | 'desactive' | 'mauvais_mdp'
|
||||
* - utilisateur = projection publique si ok.
|
||||
*/
|
||||
export async function verifierConnexion(login, motDePasse) {
|
||||
const u = await trouverUtilisateur(login);
|
||||
if (!u) {
|
||||
return { ok: false, raison: 'inconnu' };
|
||||
}
|
||||
if (u.role === 'desactive') {
|
||||
return { ok: false, raison: 'desactive' };
|
||||
}
|
||||
const correspond = bcrypt.compareSync(motDePasse, u.motDePasseHash);
|
||||
if (!correspond) {
|
||||
return { ok: false, raison: 'mauvais_mdp' };
|
||||
}
|
||||
return { ok: true, utilisateur: versPublic(u) };
|
||||
}
|
||||
|
||||
/** Crée un compte. role par défaut 'contributeur', doitChangerMdp=true. */
|
||||
export async function creerUtilisateur({ login, motDePasse, role }) {
|
||||
const loginNet = (login || '').trim();
|
||||
if (!LOGIN_VALIDE.test(loginNet)) {
|
||||
return { erreur: 'Login invalide (2 à 64 caractères : lettres, chiffres, . _ -).' };
|
||||
}
|
||||
if (!motDePasse || String(motDePasse).length < 4) {
|
||||
return { erreur: 'Mot de passe par défaut requis (4 caractères minimum).' };
|
||||
}
|
||||
const roleNet = ROLES.includes(role) ? role : 'contributeur';
|
||||
const users = await lireTous();
|
||||
if (users.some((u) => u.login === loginNet)) {
|
||||
return { erreur: 'Ce login existe déjà.' };
|
||||
}
|
||||
const maintenant = new Date().toISOString();
|
||||
const u = {
|
||||
login: loginNet,
|
||||
motDePasseHash: bcrypt.hashSync(String(motDePasse), 10),
|
||||
role: roleNet,
|
||||
doitChangerMdp: true,
|
||||
creeLe: maintenant,
|
||||
modifieLe: maintenant
|
||||
};
|
||||
users.push(u);
|
||||
await ecrireTous(users);
|
||||
return { utilisateur: versPublic(u) };
|
||||
}
|
||||
|
||||
/** Met à jour le rôle d'un compte. */
|
||||
export async function definirRole(login, role) {
|
||||
if (!ROLES.includes(role)) {
|
||||
return { erreur: 'Rôle invalide.' };
|
||||
}
|
||||
const users = await lireTous();
|
||||
const u = users.find((x) => x.login === login);
|
||||
if (!u) return { erreur: 'introuvable' };
|
||||
u.role = role;
|
||||
u.modifieLe = new Date().toISOString();
|
||||
await ecrireTous(users);
|
||||
return { utilisateur: versPublic(u) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Réinitialise le mot de passe d'un compte (admin). Impose le changement à la
|
||||
* prochaine connexion.
|
||||
*/
|
||||
export async function reinitialiserMotDePasse(login, motDePasseParDefaut) {
|
||||
if (!motDePasseParDefaut || String(motDePasseParDefaut).length < 4) {
|
||||
return { erreur: 'Mot de passe par défaut requis (4 caractères minimum).' };
|
||||
}
|
||||
const users = await lireTous();
|
||||
const u = users.find((x) => x.login === login);
|
||||
if (!u) return { erreur: 'introuvable' };
|
||||
u.motDePasseHash = bcrypt.hashSync(String(motDePasseParDefaut), 10);
|
||||
u.doitChangerMdp = true;
|
||||
u.modifieLe = new Date().toISOString();
|
||||
await ecrireTous(users);
|
||||
return { utilisateur: versPublic(u) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le mot de passe par l'utilisateur lui-même (après vérification de l'ancien).
|
||||
* Retire le flag doitChangerMdp.
|
||||
*/
|
||||
export async function changerMotDePasse(login, ancien, nouveau) {
|
||||
if (!nouveau || String(nouveau).length < 4) {
|
||||
return { erreur: 'Le nouveau mot de passe doit faire au moins 4 caractères.' };
|
||||
}
|
||||
const users = await lireTous();
|
||||
const u = users.find((x) => x.login === login);
|
||||
if (!u) return { erreur: 'introuvable' };
|
||||
if (!bcrypt.compareSync(String(ancien), u.motDePasseHash)) {
|
||||
return { erreur: 'mauvais_ancien' };
|
||||
}
|
||||
if (String(nouveau) === String(ancien)) {
|
||||
return { erreur: 'Le nouveau mot de passe doit être différent de l’ancien.' };
|
||||
}
|
||||
u.motDePasseHash = bcrypt.hashSync(String(nouveau), 10);
|
||||
u.doitChangerMdp = false;
|
||||
u.modifieLe = new Date().toISOString();
|
||||
await ecrireTous(users);
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/** Supprime un compte. */
|
||||
export async function supprimerUtilisateur(login) {
|
||||
const users = await lireTous();
|
||||
const idx = users.findIndex((u) => u.login === login);
|
||||
if (idx === -1) return { erreur: 'introuvable' };
|
||||
users.splice(idx, 1);
|
||||
await ecrireTous(users);
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* Amorce les comptes initiaux au premier démarrage si le store est vide.
|
||||
* `seed` = [{ login, motDePasse, role }]. Ne fait rien si des comptes existent déjà.
|
||||
*/
|
||||
export async function amorcerSiVide(seed) {
|
||||
const users = await lireTous();
|
||||
if (users.length > 0 || !Array.isArray(seed) || seed.length === 0) {
|
||||
return { amorce: false };
|
||||
}
|
||||
const maintenant = new Date().toISOString();
|
||||
const nouveaux = seed
|
||||
.filter((s) => LOGIN_VALIDE.test((s.login || '').trim()) && s.motDePasse)
|
||||
.map((s) => ({
|
||||
login: s.login.trim(),
|
||||
motDePasseHash: bcrypt.hashSync(String(s.motDePasse), 10),
|
||||
role: ROLES.includes(s.role) ? s.role : 'contributeur',
|
||||
doitChangerMdp: true,
|
||||
creeLe: maintenant,
|
||||
modifieLe: maintenant
|
||||
}));
|
||||
if (nouveaux.length > 0) {
|
||||
await ecrireTous(nouveaux);
|
||||
}
|
||||
return { amorce: nouveaux.length > 0, nombre: nouveaux.length };
|
||||
}
|
||||
Reference in New Issue
Block a user