verdaccio 6.8.0 → 6.9.0
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/README.md +2 -2
- package/bin/verdaccio +5 -1
- package/build/_virtual/_rolldown/runtime.js +23 -0
- package/build/api/debug/index.js +23 -26
- package/build/api/debug/index.js.map +1 -0
- package/build/api/debug/index.mjs +19 -0
- package/build/api/debug/index.mjs.map +1 -0
- package/build/api/endpoint/api/dist-tags.js +62 -75
- package/build/api/endpoint/api/dist-tags.js.map +1 -0
- package/build/api/endpoint/api/dist-tags.mjs +56 -0
- package/build/api/endpoint/api/dist-tags.mjs.map +1 -0
- package/build/api/endpoint/api/package.js +91 -99
- package/build/api/endpoint/api/package.js.map +1 -0
- package/build/api/endpoint/api/package.mjs +89 -0
- package/build/api/endpoint/api/package.mjs.map +1 -0
- package/build/api/endpoint/api/ping.js +13 -11
- package/build/api/endpoint/api/ping.js.map +1 -0
- package/build/api/endpoint/api/ping.mjs +11 -0
- package/build/api/endpoint/api/ping.mjs.map +1 -0
- package/build/api/endpoint/api/publish.js +276 -367
- package/build/api/endpoint/api/publish.js.map +1 -0
- package/build/api/endpoint/api/publish.mjs +280 -0
- package/build/api/endpoint/api/publish.mjs.map +1 -0
- package/build/api/endpoint/api/search.js +57 -105
- package/build/api/endpoint/api/search.js.map +1 -0
- package/build/api/endpoint/api/search.mjs +54 -0
- package/build/api/endpoint/api/search.mjs.map +1 -0
- package/build/api/endpoint/api/star.js +60 -71
- package/build/api/endpoint/api/star.js.map +1 -0
- package/build/api/endpoint/api/star.mjs +54 -0
- package/build/api/endpoint/api/star.mjs.map +1 -0
- package/build/api/endpoint/api/stars.js +40 -40
- package/build/api/endpoint/api/stars.js.map +1 -0
- package/build/api/endpoint/api/stars.mjs +35 -0
- package/build/api/endpoint/api/stars.mjs.map +1 -0
- package/build/api/endpoint/api/user.js +69 -81
- package/build/api/endpoint/api/user.js.map +1 -0
- package/build/api/endpoint/api/user.mjs +64 -0
- package/build/api/endpoint/api/user.mjs.map +1 -0
- package/build/api/endpoint/api/v1/profile.js +50 -67
- package/build/api/endpoint/api/v1/profile.js.map +1 -0
- package/build/api/endpoint/api/v1/profile.mjs +46 -0
- package/build/api/endpoint/api/v1/profile.mjs.map +1 -0
- package/build/api/endpoint/api/v1/search.js +147 -203
- package/build/api/endpoint/api/v1/search.js.map +1 -0
- package/build/api/endpoint/api/v1/search.mjs +154 -0
- package/build/api/endpoint/api/v1/search.mjs.map +1 -0
- package/build/api/endpoint/api/v1/token.js +122 -155
- package/build/api/endpoint/api/v1/token.js.map +1 -0
- package/build/api/endpoint/api/v1/token.mjs +119 -0
- package/build/api/endpoint/api/v1/token.mjs.map +1 -0
- package/build/api/endpoint/api/whoami.js +13 -13
- package/build/api/endpoint/api/whoami.js.map +1 -0
- package/build/api/endpoint/api/whoami.mjs +11 -0
- package/build/api/endpoint/api/whoami.mjs.map +1 -0
- package/build/api/endpoint/index.js +58 -67
- package/build/api/endpoint/index.js.map +1 -0
- package/build/api/endpoint/index.mjs +54 -0
- package/build/api/endpoint/index.mjs.map +1 -0
- package/build/api/index.js +85 -106
- package/build/api/index.js.map +1 -0
- package/build/api/index.mjs +78 -0
- package/build/api/index.mjs.map +1 -0
- package/build/api/middleware.js +60 -54
- package/build/api/middleware.js.map +1 -0
- package/build/api/middleware.mjs +55 -0
- package/build/api/middleware.mjs.map +1 -0
- package/build/api/web/api/index.js +25 -29
- package/build/api/web/api/index.js.map +1 -0
- package/build/api/web/api/index.mjs +23 -0
- package/build/api/web/api/index.mjs.map +1 -0
- package/build/api/web/api/package.js +142 -160
- package/build/api/web/api/package.js.map +1 -0
- package/build/api/web/api/package.mjs +139 -0
- package/build/api/web/api/package.mjs.map +1 -0
- package/build/api/web/api/search.js +37 -49
- package/build/api/web/api/search.js.map +1 -0
- package/build/api/web/api/search.mjs +36 -0
- package/build/api/web/api/search.mjs.map +1 -0
- package/build/api/web/api/user.js +52 -72
- package/build/api/web/api/user.js.map +1 -0
- package/build/api/web/api/user.mjs +49 -0
- package/build/api/web/api/user.mjs.map +1 -0
- package/build/api/web/api/utils.js +9 -10
- package/build/api/web/api/utils.js.map +1 -0
- package/build/api/web/api/utils.mjs +11 -0
- package/build/api/web/api/utils.mjs.map +1 -0
- package/build/api/web/index.js +76 -88
- package/build/api/web/index.js.map +1 -0
- package/build/api/web/index.mjs +70 -0
- package/build/api/web/index.mjs.map +1 -0
- package/build/index.js +43 -60
- package/build/index.mjs +5 -0
- package/build/lib/auth-utils.js +12 -14
- package/build/lib/auth-utils.js.map +1 -0
- package/build/lib/auth-utils.mjs +11 -0
- package/build/lib/auth-utils.mjs.map +1 -0
- package/build/lib/bootstrap.js +125 -157
- package/build/lib/bootstrap.js.map +1 -0
- package/build/lib/bootstrap.mjs +125 -0
- package/build/lib/bootstrap.mjs.map +1 -0
- package/build/lib/cli/cli.js +22 -24
- package/build/lib/cli/cli.js.map +1 -0
- package/build/lib/cli/cli.mjs +23 -0
- package/build/lib/cli/cli.mjs.map +1 -0
- package/build/lib/cli/commands/info.js +34 -25
- package/build/lib/cli/commands/info.js.map +1 -0
- package/build/lib/cli/commands/info.mjs +32 -0
- package/build/lib/cli/commands/info.mjs.map +1 -0
- package/build/lib/cli/commands/init.js +61 -79
- package/build/lib/cli/commands/init.js.map +1 -0
- package/build/lib/cli/commands/init.mjs +70 -0
- package/build/lib/cli/commands/init.mjs.map +1 -0
- package/build/lib/cli/commands/version.js +14 -16
- package/build/lib/cli/commands/version.js.map +1 -0
- package/build/lib/cli/commands/version.mjs +14 -0
- package/build/lib/cli/commands/version.mjs.map +1 -0
- package/build/lib/cli/utils.d.ts +2 -2
- package/build/lib/cli/utils.js +16 -15
- package/build/lib/cli/utils.js.map +1 -0
- package/build/lib/cli/utils.mjs +14 -0
- package/build/lib/cli/utils.mjs.map +1 -0
- package/build/lib/cli.js +11 -14
- package/build/lib/cli.js.map +1 -0
- package/build/lib/cli.mjs +12 -0
- package/build/lib/cli.mjs.map +1 -0
- package/build/lib/config.js +19 -21
- package/build/lib/config.js.map +1 -0
- package/build/lib/config.mjs +16 -0
- package/build/lib/config.mjs.map +1 -0
- package/build/lib/constants.js +100 -93
- package/build/lib/constants.js.map +1 -0
- package/build/lib/constants.mjs +28 -0
- package/build/lib/constants.mjs.map +1 -0
- package/build/lib/experiments.js +19 -24
- package/build/lib/experiments.js.map +1 -0
- package/build/lib/experiments.mjs +20 -0
- package/build/lib/experiments.mjs.map +1 -0
- package/build/lib/local-storage.js +606 -764
- package/build/lib/local-storage.js.map +1 -0
- package/build/lib/local-storage.mjs +600 -0
- package/build/lib/local-storage.mjs.map +1 -0
- package/build/lib/logger/index.js +24 -19
- package/build/lib/logger/index.js.map +1 -0
- package/build/lib/logger/index.mjs +17 -0
- package/build/lib/logger/index.mjs.map +1 -0
- package/build/lib/metadata-utils.js +24 -36
- package/build/lib/metadata-utils.js.map +1 -0
- package/build/lib/metadata-utils.mjs +23 -0
- package/build/lib/metadata-utils.mjs.map +1 -0
- package/build/lib/run-server.js +83 -114
- package/build/lib/run-server.js.map +1 -0
- package/build/lib/run-server.mjs +82 -0
- package/build/lib/run-server.mjs.map +1 -0
- package/build/lib/storage-utils.js +369 -437
- package/build/lib/storage-utils.js.map +1 -0
- package/build/lib/storage-utils.mjs +400 -0
- package/build/lib/storage-utils.mjs.map +1 -0
- package/build/lib/storage.js +675 -836
- package/build/lib/storage.js.map +1 -0
- package/build/lib/storage.mjs +665 -0
- package/build/lib/storage.mjs.map +1 -0
- package/build/lib/up-storage.js +490 -616
- package/build/lib/up-storage.js.map +1 -0
- package/build/lib/up-storage.mjs +484 -0
- package/build/lib/up-storage.mjs.map +1 -0
- package/build/lib/uplink-util.js +21 -31
- package/build/lib/uplink-util.js.map +1 -0
- package/build/lib/uplink-util.mjs +24 -0
- package/build/lib/uplink-util.mjs.map +1 -0
- package/build/lib/utils.js +172 -231
- package/build/lib/utils.js.map +1 -0
- package/build/lib/utils.mjs +188 -0
- package/build/lib/utils.mjs.map +1 -0
- package/package.json +51 -43
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { API_ERROR, API_MESSAGE, HEADERS, HTTP_STATUS } from "../../../lib/constants.mjs";
|
|
2
|
+
import { logger } from "../../../lib/logger/index.mjs";
|
|
3
|
+
import { ErrorCode } from "../../../lib/utils.mjs";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
import { rateLimit } from "@verdaccio/middleware";
|
|
6
|
+
import { validationUtils } from "@verdaccio/core";
|
|
7
|
+
import { getAuthenticatedMessage } from "@verdaccio/utils";
|
|
8
|
+
import { createRemoteUser } from "@verdaccio/config";
|
|
9
|
+
import express from "express";
|
|
10
|
+
import { getApiToken } from "@verdaccio/auth";
|
|
11
|
+
//#region src/api/endpoint/api/user.ts
|
|
12
|
+
function user_default(route, auth, config) {
|
|
13
|
+
const userRouter = express.Router();
|
|
14
|
+
userRouter.get("/-/user/:org_couchdb_user", rateLimit(config?.userRateLimit), function(req, res, next) {
|
|
15
|
+
res.status(HTTP_STATUS.OK);
|
|
16
|
+
next({ ok: getAuthenticatedMessage(req.remote_user.name) });
|
|
17
|
+
});
|
|
18
|
+
userRouter.put("/-/user/:org_couchdb_user/:_rev?/:revision?", rateLimit(config?.userRateLimit), function(req, res, next) {
|
|
19
|
+
const { name, password } = req.body;
|
|
20
|
+
const remoteName = req.remote_user.name;
|
|
21
|
+
if (_.isNil(remoteName) === false && _.isNil(name) === false && remoteName === name) auth.authenticate(name, password, async function callbackAuthenticate(err, user) {
|
|
22
|
+
if (err) {
|
|
23
|
+
logger.error({
|
|
24
|
+
name,
|
|
25
|
+
err
|
|
26
|
+
}, "authenticating for user @{username} failed. Error: @{err.message}");
|
|
27
|
+
return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD));
|
|
28
|
+
}
|
|
29
|
+
const token = await getApiToken(auth, config, createRemoteUser(name, user?.groups ?? []), password);
|
|
30
|
+
res.status(HTTP_STATUS.CREATED);
|
|
31
|
+
res.set(HEADERS.CACHE_CONTROL, "no-cache, no-store");
|
|
32
|
+
return next({
|
|
33
|
+
ok: getAuthenticatedMessage(req.remote_user.name),
|
|
34
|
+
token
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
else {
|
|
38
|
+
if (validationUtils.validatePassword(password) === false) return next(ErrorCode.getCode(HTTP_STATUS.BAD_REQUEST, API_ERROR.PASSWORD_SHORT));
|
|
39
|
+
auth.add_user(name, password, async function(err, user) {
|
|
40
|
+
if (err) {
|
|
41
|
+
if (err.status >= HTTP_STATUS.BAD_REQUEST && err.status < HTTP_STATUS.INTERNAL_ERROR) return next(ErrorCode.getCode(err.status, err.message) || ErrorCode.getConflict(err.message));
|
|
42
|
+
return next(err);
|
|
43
|
+
}
|
|
44
|
+
const token = name && password ? await getApiToken(auth, config, user, password) : void 0;
|
|
45
|
+
req.remote_user = user;
|
|
46
|
+
res.status(HTTP_STATUS.CREATED);
|
|
47
|
+
res.set(HEADERS.CACHE_CONTROL, "no-cache, no-store");
|
|
48
|
+
return next({
|
|
49
|
+
ok: `user '${req.body.name}' created`,
|
|
50
|
+
token
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
userRouter.delete("/-/user/token/*", rateLimit(config?.userRateLimit), function(req, res, next) {
|
|
56
|
+
res.status(HTTP_STATUS.OK);
|
|
57
|
+
next({ ok: API_MESSAGE.LOGGED_OUT });
|
|
58
|
+
});
|
|
59
|
+
route.use(userRouter);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { user_default as default };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=user.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.mjs","names":[],"sources":["../../../../src/api/endpoint/api/user.ts"],"sourcesContent":["import type { Response, Router } from 'express';\nimport express from 'express';\nimport _ from 'lodash';\n\nimport { getApiToken } from '@verdaccio/auth';\nimport type { Auth } from '@verdaccio/auth';\nimport { createRemoteUser } from '@verdaccio/config';\nimport { validationUtils } from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport type { Config, RemoteUser } from '@verdaccio/types';\nimport { getAuthenticatedMessage } from '@verdaccio/utils';\n\nimport { API_ERROR, API_MESSAGE, HEADERS, HTTP_STATUS } from '../../../lib/constants';\nimport { logger } from '../../../lib/logger';\nimport { ErrorCode } from '../../../lib/utils';\nimport type { $NextFunctionVer, $RequestExtend } from '../../../types';\n\nexport default function (route: Router, auth: Auth, config: Config): void {\n const userRouter = express.Router();\n\n userRouter.get(\n '/-/user/:org_couchdb_user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n res.status(HTTP_STATUS.OK);\n next({\n ok: getAuthenticatedMessage(req.remote_user.name),\n });\n }\n );\n\n userRouter.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 const remoteName = req.remote_user.name;\n\n if (_.isNil(remoteName) === false && _.isNil(name) === false && remoteName === name) {\n auth.authenticate(\n name,\n password,\n async function callbackAuthenticate(err, user): Promise<void> {\n if (err) {\n logger.error(\n { name, err },\n 'authenticating for user @{username} failed. Error: @{err.message}'\n );\n return next(\n ErrorCode.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\n res.status(HTTP_STATUS.CREATED);\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n return next({\n ok: getAuthenticatedMessage(req.remote_user.name),\n token,\n });\n }\n );\n } else {\n if (validationUtils.validatePassword(password) === false) {\n return next(ErrorCode.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 // 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 ErrorCode.getCode(err.status, err.message) || ErrorCode.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\n req.remote_user = user;\n res.status(HTTP_STATUS.CREATED);\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n return next({\n ok: `user '${req.body.name}' created`,\n token,\n });\n });\n }\n }\n );\n\n userRouter.delete(\n '/-/user/token/*',\n rateLimit(config?.userRateLimit),\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 route.use(userRouter);\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAA,aAAyB,OAAe,MAAY,QAAsB;CACxE,MAAM,aAAa,QAAQ,OAAO;CAElC,WAAW,IACT,6BACA,UAAU,QAAQ,aAAa,GAC/B,SAAU,KAAqB,KAAe,MAA8B;EAC1E,IAAI,OAAO,YAAY,EAAE;EACzB,KAAK,EACH,IAAI,wBAAwB,IAAI,YAAY,IAAI,EAClD,CAAC;CACH,CACF;CAEA,WAAW,IACT,+CACA,UAAU,QAAQ,aAAa,GAC/B,SAAU,KAAqB,KAAe,MAA8B;EAC1E,MAAM,EAAE,MAAM,aAAa,IAAI;EAC/B,MAAM,aAAa,IAAI,YAAY;EAEnC,IAAI,EAAE,MAAM,UAAU,MAAM,SAAS,EAAE,MAAM,IAAI,MAAM,SAAS,eAAe,MAC7E,KAAK,aACH,MACA,UACA,eAAe,qBAAqB,KAAK,MAAqB;GAC5D,IAAI,KAAK;IACP,OAAO,MACL;KAAE;KAAM;IAAI,GACZ,mEACF;IACA,OAAO,KACL,UAA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esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (_lodash.default.isNil(password) === false) {
|
|
50
|
-
if (_core.validationUtils.validatePassword(password.new) === false) {
|
|
51
|
-
return next(_utils.ErrorCode.getCode(_constants.HTTP_STATUS.UNAUTHORIZED, _constants.API_ERROR.PASSWORD_SHORT));
|
|
52
|
-
}
|
|
53
|
-
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
|
54
|
-
if (_lodash.default.isNull(err) === false) {
|
|
55
|
-
return next(_utils.ErrorCode.getCode(err.status, err.message) || _utils.ErrorCode.getConflict(err.message));
|
|
56
|
-
}
|
|
57
|
-
if (isUpdated) {
|
|
58
|
-
return next(buildProfile(req.remote_user.name));
|
|
59
|
-
}
|
|
60
|
-
return next(_utils.ErrorCode.getInternalError(_constants.API_ERROR.INTERNAL_SERVER_ERROR));
|
|
61
|
-
});
|
|
62
|
-
} else if (_lodash.default.isNil(tfa) === false) {
|
|
63
|
-
return next(_utils.ErrorCode.getCode(_constants.HTTP_STATUS.SERVICE_UNAVAILABLE, _constants.SUPPORT_ERRORS.TFA_DISABLED));
|
|
64
|
-
} else {
|
|
65
|
-
return next(_utils.ErrorCode.getCode(_constants.HTTP_STATUS.INTERNAL_ERROR, _constants.APP_ERROR.PROFILE_ERROR));
|
|
66
|
-
}
|
|
67
|
-
});
|
|
5
|
+
const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
|
|
6
|
+
require("../../../../lib/constants.js");
|
|
7
|
+
const require_lib_utils = require("../../../../lib/utils.js");
|
|
8
|
+
let lodash = require("lodash");
|
|
9
|
+
lodash = require_runtime.__toESM(lodash);
|
|
10
|
+
let _verdaccio_middleware = require("@verdaccio/middleware");
|
|
11
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
12
|
+
//#region src/api/endpoint/api/v1/profile.ts
|
|
13
|
+
function profile_default(router, auth, config) {
|
|
14
|
+
function buildProfile(name) {
|
|
15
|
+
return {
|
|
16
|
+
tfa: false,
|
|
17
|
+
name,
|
|
18
|
+
email: "",
|
|
19
|
+
email_verified: false,
|
|
20
|
+
created: "",
|
|
21
|
+
updated: "",
|
|
22
|
+
cidr_whitelist: null,
|
|
23
|
+
fullname: ""
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
router.get("/-/npm/v1/user", (0, _verdaccio_middleware.rateLimit)(config?.userRateLimit), function(req, res, next) {
|
|
27
|
+
if (lodash.default.isNil(req.remote_user.name) === false) return next(buildProfile(req.remote_user.name));
|
|
28
|
+
res.status(_verdaccio_core.HTTP_STATUS.UNAUTHORIZED);
|
|
29
|
+
return next({ message: _verdaccio_core.API_ERROR.MUST_BE_LOGGED });
|
|
30
|
+
});
|
|
31
|
+
router.post("/-/npm/v1/user", (0, _verdaccio_middleware.rateLimit)(config?.userRateLimit), function(req, res, next) {
|
|
32
|
+
if (lodash.default.isNil(req.remote_user.name)) {
|
|
33
|
+
res.status(_verdaccio_core.HTTP_STATUS.UNAUTHORIZED);
|
|
34
|
+
return next({ message: _verdaccio_core.API_ERROR.MUST_BE_LOGGED });
|
|
35
|
+
}
|
|
36
|
+
const { password, tfa } = req.body;
|
|
37
|
+
const { name } = req.remote_user;
|
|
38
|
+
if (lodash.default.isNil(password) === false) {
|
|
39
|
+
if (_verdaccio_core.validationUtils.validatePassword(password.new) === false) return next(require_lib_utils.ErrorCode.getCode(_verdaccio_core.HTTP_STATUS.UNAUTHORIZED, _verdaccio_core.API_ERROR.PASSWORD_SHORT));
|
|
40
|
+
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
|
41
|
+
if (lodash.default.isNull(err) === false) return next(require_lib_utils.ErrorCode.getCode(err.status, err.message) || require_lib_utils.ErrorCode.getConflict(err.message));
|
|
42
|
+
if (isUpdated) return next(buildProfile(req.remote_user.name));
|
|
43
|
+
return next(require_lib_utils.ErrorCode.getInternalError(_verdaccio_core.API_ERROR.INTERNAL_SERVER_ERROR));
|
|
44
|
+
});
|
|
45
|
+
} else if (lodash.default.isNil(tfa) === false) return next(require_lib_utils.ErrorCode.getCode(_verdaccio_core.HTTP_STATUS.SERVICE_UNAVAILABLE, _verdaccio_core.SUPPORT_ERRORS.TFA_DISABLED));
|
|
46
|
+
else return next(require_lib_utils.ErrorCode.getCode(_verdaccio_core.HTTP_STATUS.INTERNAL_ERROR, _verdaccio_core.APP_ERROR.PROFILE_ERROR));
|
|
47
|
+
});
|
|
68
48
|
}
|
|
69
|
-
//#
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.default = profile_default;
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","names":[],"sources":["../../../../../src/api/endpoint/api/v1/profile.ts"],"sourcesContent":["import type { Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport type { Auth } from '@verdaccio/auth';\nimport { validationUtils } from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport type { ConfigYaml } from '@verdaccio/types';\n\nimport { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants';\nimport { ErrorCode } from '../../../../lib/utils';\nimport type { $NextFunctionVer, $RequestExtend } from '../../../../types';\n\nexport interface Profile {\n tfa: boolean;\n name: string;\n email: string;\n email_verified: boolean;\n created: string;\n updated: string;\n cidr_whitelist: string[] | null;\n fullname: string;\n}\n\nexport default function (router: Router, auth: Auth, config: ConfigYaml) {\n function buildProfile(name: string): Profile {\n return {\n tfa: false,\n name,\n email: '',\n email_verified: false,\n created: '',\n updated: '',\n cidr_whitelist: null,\n fullname: '',\n };\n }\n\n router.get(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name) === false) {\n return next(buildProfile(req.remote_user.name));\n }\n\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n );\n\n router.post(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password, tfa } = req.body;\n const { name } = req.remote_user;\n\n if (_.isNil(password) === false) {\n if (validationUtils.validatePassword(password.new) === false) {\n return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.PASSWORD_SHORT));\n }\n\n auth.changePassword(\n name,\n password.old,\n password.new,\n (err, isUpdated): $NextFunctionVer => {\n if (_.isNull(err) === false) {\n return next(\n ErrorCode.getCode(err.status, err.message) || ErrorCode.getConflict(err.message)\n );\n }\n\n if (isUpdated) {\n return next(buildProfile(req.remote_user.name));\n }\n return next(ErrorCode.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n );\n } else if (_.isNil(tfa) === false) {\n return next(\n ErrorCode.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPORT_ERRORS.TFA_DISABLED)\n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Q,IAAI,QAAQ,IAAI,OAAO,KAAK,kBAAA,UAAU,YAAY,IAAI,OAAO,CACjF;IAGF,IAAI,WACF,OAAO,KAAK,aAAa,IAAI,YAAY,IAAI,CAAC;IAEhD,OAAO,KAAK,kBAAA,UAAU,iBAAiB,gBAAA,UAAU,qBAAqB,CAAC;GACzE,CACF;EACF,OAAO,IAAI,OAAA,QAAE,MAAM,GAAG,MAAM,OAC1B,OAAO,KACL,kBAAA,UAAU,QAAQ,gBAAA,YAAY,qBAAqB,gBAAA,eAAe,YAAY,CAChF;OAEA,OAAO,KAAK,kBAAA,UAAU,QAAQ,gBAAA,YAAY,gBAAgB,gBAAA,UAAU,aAAa,CAAC;CAEtF,CACF;AACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from "../../../../lib/constants.mjs";
|
|
2
|
+
import { ErrorCode } from "../../../../lib/utils.mjs";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
import { rateLimit } from "@verdaccio/middleware";
|
|
5
|
+
import { validationUtils } from "@verdaccio/core";
|
|
6
|
+
//#region src/api/endpoint/api/v1/profile.ts
|
|
7
|
+
function profile_default(router, auth, config) {
|
|
8
|
+
function buildProfile(name) {
|
|
9
|
+
return {
|
|
10
|
+
tfa: false,
|
|
11
|
+
name,
|
|
12
|
+
email: "",
|
|
13
|
+
email_verified: false,
|
|
14
|
+
created: "",
|
|
15
|
+
updated: "",
|
|
16
|
+
cidr_whitelist: null,
|
|
17
|
+
fullname: ""
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
router.get("/-/npm/v1/user", rateLimit(config?.userRateLimit), function(req, res, next) {
|
|
21
|
+
if (_.isNil(req.remote_user.name) === false) return next(buildProfile(req.remote_user.name));
|
|
22
|
+
res.status(HTTP_STATUS.UNAUTHORIZED);
|
|
23
|
+
return next({ message: API_ERROR.MUST_BE_LOGGED });
|
|
24
|
+
});
|
|
25
|
+
router.post("/-/npm/v1/user", rateLimit(config?.userRateLimit), function(req, res, next) {
|
|
26
|
+
if (_.isNil(req.remote_user.name)) {
|
|
27
|
+
res.status(HTTP_STATUS.UNAUTHORIZED);
|
|
28
|
+
return next({ message: API_ERROR.MUST_BE_LOGGED });
|
|
29
|
+
}
|
|
30
|
+
const { password, tfa } = req.body;
|
|
31
|
+
const { name } = req.remote_user;
|
|
32
|
+
if (_.isNil(password) === false) {
|
|
33
|
+
if (validationUtils.validatePassword(password.new) === false) return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.PASSWORD_SHORT));
|
|
34
|
+
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
|
35
|
+
if (_.isNull(err) === false) return next(ErrorCode.getCode(err.status, err.message) || ErrorCode.getConflict(err.message));
|
|
36
|
+
if (isUpdated) return next(buildProfile(req.remote_user.name));
|
|
37
|
+
return next(ErrorCode.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));
|
|
38
|
+
});
|
|
39
|
+
} else if (_.isNil(tfa) === false) return next(ErrorCode.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPORT_ERRORS.TFA_DISABLED));
|
|
40
|
+
else return next(ErrorCode.getCode(HTTP_STATUS.INTERNAL_ERROR, APP_ERROR.PROFILE_ERROR));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { profile_default as default };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=profile.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.mjs","names":[],"sources":["../../../../../src/api/endpoint/api/v1/profile.ts"],"sourcesContent":["import type { Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport type { Auth } from '@verdaccio/auth';\nimport { validationUtils } from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport type { ConfigYaml } from '@verdaccio/types';\n\nimport { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants';\nimport { ErrorCode } from '../../../../lib/utils';\nimport type { $NextFunctionVer, $RequestExtend } from '../../../../types';\n\nexport interface Profile {\n tfa: boolean;\n name: string;\n email: string;\n email_verified: boolean;\n created: string;\n updated: string;\n cidr_whitelist: string[] | null;\n fullname: string;\n}\n\nexport default function (router: Router, auth: Auth, config: ConfigYaml) {\n function buildProfile(name: string): Profile {\n return {\n tfa: false,\n name,\n email: '',\n email_verified: false,\n created: '',\n updated: '',\n cidr_whitelist: null,\n fullname: '',\n };\n }\n\n router.get(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name) === false) {\n return next(buildProfile(req.remote_user.name));\n }\n\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n );\n\n router.post(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password, tfa } = req.body;\n const { name } = req.remote_user;\n\n if (_.isNil(password) === false) {\n if (validationUtils.validatePassword(password.new) === false) {\n return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.PASSWORD_SHORT));\n }\n\n auth.changePassword(\n name,\n password.old,\n password.new,\n (err, isUpdated): $NextFunctionVer => {\n if (_.isNull(err) === false) {\n return next(\n ErrorCode.getCode(err.status, err.message) || ErrorCode.getConflict(err.message)\n );\n }\n\n if (isUpdated) {\n return next(buildProfile(req.remote_user.name));\n }\n return next(ErrorCode.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n );\n } else if (_.isNil(tfa) === false) {\n return next(\n ErrorCode.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPOR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