@verdaccio/api 8.1.0-next-8.7 → 8.1.0-next-8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/LICENSE +1 -1
- package/README.md +0 -1
- package/build/user.js +3 -3
- package/build/user.js.map +1 -1
- package/package.json +11 -12
- package/src/user.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @verdaccio/api
|
|
2
2
|
|
|
3
|
+
## 8.1.0-next-8.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [96e0011]
|
|
8
|
+
- @verdaccio/middleware@8.0.0-next-8.9
|
|
9
|
+
- @verdaccio/auth@8.0.0-next-8.9
|
|
10
|
+
- @verdaccio/core@8.0.0-next-8.9
|
|
11
|
+
- @verdaccio/config@8.0.0-next-8.9
|
|
12
|
+
- @verdaccio/store@8.0.0-next-8.9
|
|
13
|
+
- @verdaccio/utils@8.1.0-next-8.9
|
|
14
|
+
- @verdaccio/logger@8.0.0-next-8.9
|
|
15
|
+
|
|
16
|
+
## 8.1.0-next-8.8
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [0588605]
|
|
21
|
+
- Updated dependencies [ca91b9a]
|
|
22
|
+
- @verdaccio/config@8.0.0-next-8.8
|
|
23
|
+
- @verdaccio/auth@8.0.0-next-8.8
|
|
24
|
+
- @verdaccio/middleware@8.0.0-next-8.8
|
|
25
|
+
- @verdaccio/store@8.0.0-next-8.8
|
|
26
|
+
- @verdaccio/core@8.0.0-next-8.8
|
|
27
|
+
- @verdaccio/logger@8.0.0-next-8.8
|
|
28
|
+
- @verdaccio/utils@8.1.0-next-8.8
|
|
29
|
+
|
|
3
30
|
## 8.1.0-next-8.7
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
[](https://crowdin.com/project/verdaccio)
|
|
7
7
|
[](https://www.tickgit.com/browse?repo=github.com/verdaccio/verdaccio)
|
|
8
8
|
|
|
9
|
-
[](https://twitter.com/verdaccio_npm)
|
|
10
9
|
[](https://github.com/verdaccio/verdaccio/stargazers)
|
|
11
10
|
|
|
12
11
|
## Donations
|
package/build/user.js
CHANGED
|
@@ -13,7 +13,7 @@ var _utils = require("@verdaccio/utils");
|
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
const debug = (0, _debug.default)('verdaccio:api:user');
|
|
15
15
|
function _default(route, auth, config, logger) {
|
|
16
|
-
route.get(
|
|
16
|
+
route.get(_middleware.USER_API_ENDPOINTS.get_user, (0, _middleware.rateLimit)(config?.userRateLimit), function (req, res, next) {
|
|
17
17
|
debug('verifying user');
|
|
18
18
|
if (!req.remote_user || typeof req.remote_user.name !== 'string' || req.remote_user.name === '') {
|
|
19
19
|
debug('user not logged in');
|
|
@@ -52,7 +52,7 @@ function _default(route, auth, config, logger) {
|
|
|
52
52
|
* @param {Auth} auth
|
|
53
53
|
* @param {Config} config
|
|
54
54
|
*/
|
|
55
|
-
route.put(
|
|
55
|
+
route.put(_middleware.USER_API_ENDPOINTS.add_user, (0, _middleware.rateLimit)(config?.userRateLimit), function (req, res, next) {
|
|
56
56
|
const {
|
|
57
57
|
name,
|
|
58
58
|
password
|
|
@@ -123,7 +123,7 @@ function _default(route, auth, config, logger) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
route.delete(
|
|
126
|
+
route.delete(_middleware.USER_API_ENDPOINTS.user_token, function (req, res, next) {
|
|
127
127
|
res.status(_core.HTTP_STATUS.OK);
|
|
128
128
|
next({
|
|
129
129
|
ok: _core.API_MESSAGE.LOGGED_OUT
|
package/build/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["_debug","_interopRequireDefault","require","_auth","_config","_core","_middleware","_utils","e","__esModule","default","debug","buildDebug","_default","route","auth","config","logger","get","rateLimit","userRateLimit","req","res","next","remote_user","name","status","HTTP_STATUS","OK","ok","username","params","org_couchdb_user","split","message","getAuthenticatedMessage","email","put","password","body","remoteName","validatioUtils","validateUserName","errorUtils","getBadRequest","API_ERROR","USERNAME_MISMATCH","authenticate","callbackAuthenticate","err","user","trace","getCode","UNAUTHORIZED","BAD_USERNAME_PASSWORD","restoredRemoteUser","createRemoteUser","groups","token","getApiToken","getUnauthorized","CREATED","set","HEADERS","CACHE_CONTROL","validatePassword","serverSettings","passwordValidationRegex","BAD_REQUEST","PASSWORD_SHORT","add_user","INTERNAL_ERROR","getConflict","undefined","mask","delete","API_MESSAGE","LOGGED_OUT"],"sources":["../src/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Response, Router } from 'express';\n\nimport { getApiToken } from '@verdaccio/auth';\nimport { Auth } from '@verdaccio/auth';\nimport { createRemoteUser } from '@verdaccio/config';\nimport {\n API_ERROR,\n API_MESSAGE,\n HEADERS,\n HTTP_STATUS,\n errorUtils,\n validatioUtils,\n} from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport { Logger } from '@verdaccio/types';\nimport { Config, RemoteUser } from '@verdaccio/types';\nimport { getAuthenticatedMessage, mask } from '@verdaccio/utils';\n\nimport { $NextFunctionVer, $RequestExtend } from '../types/custom';\n\nconst debug = buildDebug('verdaccio:api:user');\n\nexport default function (route: Router, auth: Auth, config: Config, logger: Logger): void {\n route.get(\n '/-/user/:org_couchdb_user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n debug('verifying user');\n\n if (\n !req.remote_user ||\n typeof req.remote_user.name !== 'string' ||\n req.remote_user.name === ''\n ) {\n debug('user not logged in');\n res.status(HTTP_STATUS.OK);\n return next({ ok: false });\n }\n\n const username = req.params.org_couchdb_user.split(':')[1];\n const message = getAuthenticatedMessage(req.remote_user.name);\n debug('user authenticated message %o', message);\n res.status(HTTP_STATUS.OK);\n next({\n // 'npm owner' requires user info\n // TODO: we don't have the email\n name: username,\n email: '',\n ok: message,\n });\n }\n );\n\n /**\n * \n * body example\n * req.body = {\n _id: \"org.couchdb.user:jjjj\",\n name: \"jjjj\",\n password: \"jjjj\",\n type: \"user\",\n roles: [],\n date: \"2022-07-08T15:51:04.002Z\",\n }\n * \n * @export\n * @param {Router} route\n * @param {Auth} auth\n * @param {Config} config\n */\n route.put(\n '/-/user/:org_couchdb_user/:_rev?/:revision?',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n const { name, password } = req.body;\n debug('login or adduser');\n const remoteName = req?.remote_user?.name;\n\n if (!validatioUtils.validateUserName(req.params.org_couchdb_user, name)) {\n return next(errorUtils.getBadRequest(API_ERROR.USERNAME_MISMATCH));\n }\n\n if (typeof remoteName !== 'undefined' && typeof name === 'string' && remoteName === name) {\n debug('login: no remote user detected');\n auth.authenticate(\n name,\n password,\n async function callbackAuthenticate(err, user): Promise<void> {\n if (err) {\n logger.trace(\n { name, err },\n 'authenticating for user @{username} failed. Error: @{err.message}'\n );\n return next(\n errorUtils.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD)\n );\n }\n\n const restoredRemoteUser: RemoteUser = createRemoteUser(name, user?.groups || []);\n const token = await getApiToken(auth, config, restoredRemoteUser, password);\n debug('login: new token');\n if (!token) {\n return next(errorUtils.getUnauthorized());\n }\n\n res.status(HTTP_STATUS.CREATED);\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n\n const message = getAuthenticatedMessage(req.remote_user.name);\n debug('login: created user message %o', message);\n\n return next({\n ok: message,\n token,\n });\n }\n );\n } else {\n debug('adduser: %o', name);\n if (\n validatioUtils.validatePassword(\n password,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n debug('adduser: invalid password');\n // eslint-disable-next-line new-cap\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, API_ERROR.PASSWORD_SHORT));\n }\n\n auth.add_user(name, password, async function (err, user): Promise<void> {\n if (err) {\n if (err.status >= HTTP_STATUS.BAD_REQUEST && err.status < HTTP_STATUS.INTERNAL_ERROR) {\n debug('adduser: error on create user');\n // With npm registering is the same as logging in,\n // and npm accepts only an 409 error.\n // So, changing status code here.\n return next(\n errorUtils.getCode(err.status, err.message) || errorUtils.getConflict(err.message)\n );\n }\n return next(err);\n }\n\n const token =\n name && password\n ? await getApiToken(auth, config, user as RemoteUser, password)\n : undefined;\n if (token) {\n debug('adduser: new token %o', mask(token as string, 4));\n }\n if (!token) {\n return next(errorUtils.getUnauthorized());\n }\n\n req.remote_user = user;\n res.status(HTTP_STATUS.CREATED);\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n debug('adduser: user has been created');\n return next({\n ok: `user '${req.body.name}' created`,\n token,\n });\n });\n }\n }\n );\n\n route.delete(\n '/-/user/token/*',\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n res.status(HTTP_STATUS.OK);\n next({\n ok: API_MESSAGE.LOGGED_OUT,\n });\n }\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAQA,IAAAI,WAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AAAiE,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIjE,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,oBAAoB,CAAC;AAE/B,SAAAC,SAAUC,KAAa,EAAEC,IAAU,EAAEC,MAAc,EAAEC,MAAc,EAAQ;EACxFH,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GAC7DmC,SAAS;QACf,IAAIf,KAAK,EAAE;UACT/C,KAAK,CAAC,uBAAuB,EAAE,IAAA+D,WAAI,EAAChB,KAAK,EAAY,CAAC,CAAC,CAAC;QAC1D;QACA,IAAI,CAACA,KAAK,EAAE;UACV,OAAOnC,IAAI,CAACoB,gBAAU,CAACiB,eAAe,CAAC,CAAC,CAAC;QAC3C;QAEAvC,GAAG,CAACG,WAAW,GAAG0B,IAAI;QACtB5B,GAAG,CAACI,MAAM,CAACC,iBAAW,CAACkC,OAAO,CAAC;QAC/BvC,GAAG,CAACwC,GAAG,CAACC,aAAO,CAACC,aAAa,EAAE,oBAAoB,CAAC;QACpDrD,KAAK,CAAC,gCAAgC,CAAC;QACvC,OAAOY,IAAI,CAAC;UACVM,EAAE,EAAE,SAASR,GAAG,CAACkB,IAAI,CAACd,IAAI,WAAW;UACrCiC;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ;EACF,CACF,CAAC;EAED5C,KAAK,CAAC6D,MAAM,CACV,iBAAiB,EACjB,UAAUtD,GAAmB,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IAC1ED,GAAG,CAACI,MAAM,CAACC,iBAAW,CAACC,EAAE,CAAC;IAC1BL,IAAI,CAAC;MACHM,EAAE,EAAE+C,iBAAW,CAACC;IAClB,CAAC,CAAC;EACJ,CACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"user.js","names":["_debug","_interopRequireDefault","require","_auth","_config","_core","_middleware","_utils","e","__esModule","default","debug","buildDebug","_default","route","auth","config","logger","get","USER_API_ENDPOINTS","get_user","rateLimit","userRateLimit","req","res","next","remote_user","name","status","HTTP_STATUS","OK","ok","username","params","org_couchdb_user","split","message","getAuthenticatedMessage","email","put","add_user","password","body","remoteName","validatioUtils","validateUserName","errorUtils","getBadRequest","API_ERROR","USERNAME_MISMATCH","authenticate","callbackAuthenticate","err","user","trace","getCode","UNAUTHORIZED","BAD_USERNAME_PASSWORD","restoredRemoteUser","createRemoteUser","groups","token","getApiToken","getUnauthorized","CREATED","set","HEADERS","CACHE_CONTROL","validatePassword","serverSettings","passwordValidationRegex","BAD_REQUEST","PASSWORD_SHORT","INTERNAL_ERROR","getConflict","undefined","mask","delete","user_token","API_MESSAGE","LOGGED_OUT"],"sources":["../src/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Response, Router } from 'express';\n\nimport { getApiToken } from '@verdaccio/auth';\nimport { Auth } from '@verdaccio/auth';\nimport { createRemoteUser } from '@verdaccio/config';\nimport {\n API_ERROR,\n API_MESSAGE,\n HEADERS,\n HTTP_STATUS,\n errorUtils,\n validatioUtils,\n} from '@verdaccio/core';\nimport { USER_API_ENDPOINTS, rateLimit } from '@verdaccio/middleware';\nimport { Logger } from '@verdaccio/types';\nimport { Config, RemoteUser } from '@verdaccio/types';\nimport { getAuthenticatedMessage, mask } from '@verdaccio/utils';\n\nimport { $NextFunctionVer, $RequestExtend } from '../types/custom';\n\nconst debug = buildDebug('verdaccio:api:user');\n\nexport default function (route: Router, auth: Auth, config: Config, logger: Logger): void {\n route.get(\n USER_API_ENDPOINTS.get_user,\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n debug('verifying user');\n\n if (\n !req.remote_user ||\n typeof req.remote_user.name !== 'string' ||\n req.remote_user.name === ''\n ) {\n debug('user not logged in');\n res.status(HTTP_STATUS.OK);\n return next({ ok: false });\n }\n\n const username = req.params.org_couchdb_user.split(':')[1];\n const message = getAuthenticatedMessage(req.remote_user.name);\n debug('user authenticated message %o', message);\n res.status(HTTP_STATUS.OK);\n next({\n // 'npm owner' requires user info\n // TODO: we don't have the email\n name: username,\n email: '',\n ok: message,\n });\n }\n );\n\n /**\n * \n * body example\n * req.body = {\n _id: \"org.couchdb.user:jjjj\",\n name: \"jjjj\",\n password: \"jjjj\",\n type: \"user\",\n roles: [],\n date: \"2022-07-08T15:51:04.002Z\",\n }\n * \n * @export\n * @param {Router} route\n * @param {Auth} auth\n * @param {Config} config\n */\n route.put(\n USER_API_ENDPOINTS.add_user,\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n const { name, password } = req.body;\n debug('login or adduser');\n const remoteName = req?.remote_user?.name;\n\n if (!validatioUtils.validateUserName(req.params.org_couchdb_user, name)) {\n return next(errorUtils.getBadRequest(API_ERROR.USERNAME_MISMATCH));\n }\n\n if (typeof remoteName !== 'undefined' && typeof name === 'string' && remoteName === name) {\n debug('login: no remote user detected');\n auth.authenticate(\n name,\n password,\n async function callbackAuthenticate(err, user): Promise<void> {\n if (err) {\n logger.trace(\n { name, err },\n 'authenticating for user @{username} failed. Error: @{err.message}'\n );\n return next(\n errorUtils.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD)\n );\n }\n\n const restoredRemoteUser: RemoteUser = createRemoteUser(name, user?.groups || []);\n const token = await getApiToken(auth, config, restoredRemoteUser, password);\n debug('login: new token');\n if (!token) {\n return next(errorUtils.getUnauthorized());\n }\n\n res.status(HTTP_STATUS.CREATED);\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n\n const message = getAuthenticatedMessage(req.remote_user.name);\n debug('login: created user message %o', message);\n\n return next({\n ok: message,\n token,\n });\n }\n );\n } else {\n debug('adduser: %o', name);\n if (\n validatioUtils.validatePassword(\n password,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n debug('adduser: invalid password');\n // eslint-disable-next-line new-cap\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, API_ERROR.PASSWORD_SHORT));\n }\n\n auth.add_user(name, password, async function (err, user): Promise<void> {\n if (err) {\n if (err.status >= HTTP_STATUS.BAD_REQUEST && err.status < HTTP_STATUS.INTERNAL_ERROR) {\n debug('adduser: error on create user');\n // With npm registering is the same as logging in,\n // and npm accepts only an 409 error.\n // So, changing status code here.\n return next(\n errorUtils.getCode(err.status, err.message) || errorUtils.getConflict(err.message)\n );\n }\n return next(err);\n }\n\n const token =\n name && password\n ? await getApiToken(auth, config, user as RemoteUser, password)\n : undefined;\n if (token) {\n debug('adduser: new token %o', mask(token as string, 4));\n }\n if (!token) {\n return next(errorUtils.getUnauthorized());\n }\n\n req.remote_user = user;\n res.status(HTTP_STATUS.CREATED);\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n debug('adduser: user has been created');\n return next({\n ok: `user '${req.body.name}' created`,\n token,\n });\n });\n }\n }\n );\n\n route.delete(\n USER_API_ENDPOINTS.user_token,\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n res.status(HTTP_STATUS.OK);\n next({\n ok: API_MESSAGE.LOGGED_OUT,\n });\n }\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAQA,IAAAI,WAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AAAiE,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIjE,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,oBAAoB,CAAC;AAE/B,SAAAC,SAAUC,KAAa,EAAEC,IAAU,EAAEC,MAAc,EAAEC,MAAc,EAAQ;EACxFH,KAAK,CAACI,GAAG,CACPC,8BAAkB,CAACC,QAAQ,EAC3B,IAAAC,qBAAS,EAACL,MAAM,EAAEM,aAAa,CAAC,EAChC,UAAUC,GAAmB,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IAC1Ed,KAAK,CAAC,gBAAgB,CAAC;IAEvB,IACE,CAACY,GAAG,CAACG,WAAW,IAChB,OAAOH,GAAG,CAACG,WAAW,CAACC,IAAI,KAAK,QAAQ,IACxCJ,GAAG,CAACG,WAAW,CAACC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AI;QACtB7B,GAAG,CAACI,MAAM,CAACC,iBAAW,CAACmC,OAAO,CAAC;QAC/BxC,GAAG,CAACyC,GAAG,CAACC,aAAO,CAACC,aAAa,EAAE,oBAAoB,CAAC;QACpDxD,KAAK,CAAC,gCAAgC,CAAC;QACvC,OAAOc,IAAI,CAAC;UACVM,EAAE,EAAE,SAASR,GAAG,CAACmB,IAAI,CAACf,IAAI,WAAW;UACrCkC;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ;EACF,CACF,CAAC;EAED/C,KAAK,CAAC+D,MAAM,CACV1D,8BAAkB,CAAC2D,UAAU,EAC7B,UAAUvD,GAAmB,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IAC1ED,GAAG,CAACI,MAAM,CAACC,iBAAW,CAACC,EAAE,CAAC;IAC1BL,IAAI,CAAC;MACHM,EAAE,EAAEgD,iBAAW,CAACC;IAClB,CAAC,CAAC;EACJ,CACF,CAAC;AACH","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/api",
|
|
3
|
-
"version": "8.1.0-next-8.
|
|
3
|
+
"version": "8.1.0-next-8.9",
|
|
4
4
|
"description": "loaders logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,27 +29,26 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/auth": "8.0.0-next-8.
|
|
33
|
-
"@verdaccio/config": "8.0.0-next-8.
|
|
34
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
35
|
-
"@verdaccio/logger": "8.0.0-next-8.
|
|
36
|
-
"@verdaccio/middleware": "8.0.0-next-8.
|
|
37
|
-
"@verdaccio/store": "8.0.0-next-8.
|
|
38
|
-
"@verdaccio/utils": "8.1.0-next-8.
|
|
39
|
-
"abortcontroller-polyfill": "1.7.
|
|
32
|
+
"@verdaccio/auth": "8.0.0-next-8.9",
|
|
33
|
+
"@verdaccio/config": "8.0.0-next-8.9",
|
|
34
|
+
"@verdaccio/core": "8.0.0-next-8.9",
|
|
35
|
+
"@verdaccio/logger": "8.0.0-next-8.9",
|
|
36
|
+
"@verdaccio/middleware": "8.0.0-next-8.9",
|
|
37
|
+
"@verdaccio/store": "8.0.0-next-8.9",
|
|
38
|
+
"@verdaccio/utils": "8.1.0-next-8.9",
|
|
39
|
+
"abortcontroller-polyfill": "1.7.8",
|
|
40
40
|
"body-parser": "1.20.3",
|
|
41
41
|
"cookies": "0.9.1",
|
|
42
42
|
"debug": "4.4.0",
|
|
43
43
|
"express": "4.21.2",
|
|
44
44
|
"lodash": "4.17.21",
|
|
45
45
|
"mime": "2.6.0",
|
|
46
|
-
"semver": "7.
|
|
46
|
+
"semver": "7.7.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@verdaccio/test-helper": "4.0.0-next-8.3",
|
|
50
|
-
"@verdaccio/types": "13.0.0-next-8.
|
|
50
|
+
"@verdaccio/types": "13.0.0-next-8.3",
|
|
51
51
|
"mockdate": "3.0.5",
|
|
52
|
-
"nock": "13.5.1",
|
|
53
52
|
"supertest": "7.0.0"
|
|
54
53
|
},
|
|
55
54
|
"funding": {
|
package/src/user.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
errorUtils,
|
|
13
13
|
validatioUtils,
|
|
14
14
|
} from '@verdaccio/core';
|
|
15
|
-
import { rateLimit } from '@verdaccio/middleware';
|
|
15
|
+
import { USER_API_ENDPOINTS, rateLimit } from '@verdaccio/middleware';
|
|
16
16
|
import { Logger } from '@verdaccio/types';
|
|
17
17
|
import { Config, RemoteUser } from '@verdaccio/types';
|
|
18
18
|
import { getAuthenticatedMessage, mask } from '@verdaccio/utils';
|
|
@@ -23,7 +23,7 @@ const debug = buildDebug('verdaccio:api:user');
|
|
|
23
23
|
|
|
24
24
|
export default function (route: Router, auth: Auth, config: Config, logger: Logger): void {
|
|
25
25
|
route.get(
|
|
26
|
-
|
|
26
|
+
USER_API_ENDPOINTS.get_user,
|
|
27
27
|
rateLimit(config?.userRateLimit),
|
|
28
28
|
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
|
|
29
29
|
debug('verifying user');
|
|
@@ -70,7 +70,7 @@ export default function (route: Router, auth: Auth, config: Config, logger: Logg
|
|
|
70
70
|
* @param {Config} config
|
|
71
71
|
*/
|
|
72
72
|
route.put(
|
|
73
|
-
|
|
73
|
+
USER_API_ENDPOINTS.add_user,
|
|
74
74
|
rateLimit(config?.userRateLimit),
|
|
75
75
|
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
|
|
76
76
|
const { name, password } = req.body;
|
|
@@ -168,7 +168,7 @@ export default function (route: Router, auth: Auth, config: Config, logger: Logg
|
|
|
168
168
|
);
|
|
169
169
|
|
|
170
170
|
route.delete(
|
|
171
|
-
|
|
171
|
+
USER_API_ENDPOINTS.user_token,
|
|
172
172
|
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
|
|
173
173
|
res.status(HTTP_STATUS.OK);
|
|
174
174
|
next({
|