@verdaccio/web 6.0.0-6-next.34 → 6.0.0-6-next.35
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 +81 -0
- package/build/api/user.js +3 -3
- package/build/api/user.js.map +1 -1
- package/build/middleware/render-web.d.ts +2 -2
- package/build/middleware/render-web.js +20 -6
- package/build/middleware/render-web.js.map +1 -1
- package/build/web-middleware.d.ts +1 -1
- package/build/web-middleware.js +2 -2
- package/build/web-middleware.js.map +1 -1
- package/package.json +17 -17
- package/src/api/user.ts +7 -3
- package/src/middleware/render-web.ts +21 -14
- package/src/web-middleware.ts +2 -2
- package/test/helper.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @verdaccio/web
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.35
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 9fc2e796: feat(plugins): improve plugin loader
|
|
8
|
+
|
|
9
|
+
### Changes
|
|
10
|
+
|
|
11
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
12
|
+
- Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
|
|
13
|
+
- https://github.com/verdaccio/verdaccio/issues/1394
|
|
14
|
+
- `config.plugins` plugin path validations
|
|
15
|
+
- Updated algorithm for plugin loader.
|
|
16
|
+
- improved documentation (included dev)
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
21
|
+
- Custom prefix:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
// config.yaml
|
|
25
|
+
server:
|
|
26
|
+
pluginPrefix: mycompany
|
|
27
|
+
middleware:
|
|
28
|
+
audit:
|
|
29
|
+
foo: 1
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
|
|
33
|
+
|
|
34
|
+
## Breaking Changes
|
|
35
|
+
|
|
36
|
+
### sinopia plugins
|
|
37
|
+
|
|
38
|
+
- `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
|
|
39
|
+
|
|
40
|
+
### plugin filter
|
|
41
|
+
|
|
42
|
+
- method rename `filter_metadata`->`filterMetadata`
|
|
43
|
+
|
|
44
|
+
### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
|
|
45
|
+
|
|
46
|
+
The plugin receives as first argument `config`, which represents the config of the plugin. Example:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
// config.yaml
|
|
50
|
+
auth:
|
|
51
|
+
plugin:
|
|
52
|
+
foo: 1
|
|
53
|
+
bar: 2
|
|
54
|
+
|
|
55
|
+
export class Plugin<T> {
|
|
56
|
+
public constructor(config: T, options: PluginOptions) {
|
|
57
|
+
console.log(config);
|
|
58
|
+
// {foo:1, bar: 2}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- 62c24b63: feat: add passwordValidationRegex property
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [43f32687]
|
|
70
|
+
- Updated dependencies [9fc2e796]
|
|
71
|
+
- Updated dependencies [62c24b63]
|
|
72
|
+
- @verdaccio/core@6.0.0-6-next.48
|
|
73
|
+
- @verdaccio/store@6.0.0-6-next.28
|
|
74
|
+
- @verdaccio/auth@6.0.0-6-next.27
|
|
75
|
+
- @verdaccio/config@6.0.0-6-next.48
|
|
76
|
+
- @verdaccio/loaders@6.0.0-6-next.17
|
|
77
|
+
- @verdaccio/utils@6.0.0-6-next.16
|
|
78
|
+
- @verdaccio/tarball@11.0.0-6-next.17
|
|
79
|
+
- @verdaccio/url@11.0.0-6-next.14
|
|
80
|
+
- @verdaccio/logger@6.0.0-6-next.16
|
|
81
|
+
- @verdaccio/middleware@6.0.0-6-next.27
|
|
82
|
+
- @verdaccio/readme@11.0.0-6-next.6
|
|
83
|
+
|
|
3
84
|
## 6.0.0-6-next.34
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
package/build/api/user.js
CHANGED
|
@@ -13,8 +13,6 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
13
13
|
|
|
14
14
|
var _core = require("@verdaccio/core");
|
|
15
15
|
|
|
16
|
-
var _utils = require("@verdaccio/utils");
|
|
17
|
-
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
17
|
|
|
20
18
|
const debug = (0, _debug.default)('verdaccio:web:api:user');
|
|
@@ -49,6 +47,8 @@ function addUserAuthApi(auth, config) {
|
|
|
49
47
|
|
|
50
48
|
if ((config === null || config === void 0 ? void 0 : (_config$flags = config.flags) === null || _config$flags === void 0 ? void 0 : _config$flags.changePassword) === true) {
|
|
51
49
|
route.put('/reset_password', function (req, res, next) {
|
|
50
|
+
var _config$serverSetting;
|
|
51
|
+
|
|
52
52
|
if (_lodash.default.isNil(req.remote_user.name)) {
|
|
53
53
|
res.status(_core.HTTP_STATUS.UNAUTHORIZED);
|
|
54
54
|
return next({
|
|
@@ -64,7 +64,7 @@ function addUserAuthApi(auth, config) {
|
|
|
64
64
|
name
|
|
65
65
|
} = req.remote_user;
|
|
66
66
|
|
|
67
|
-
if (
|
|
67
|
+
if (_core.validatioUtils.validatePassword(password.new, config === null || config === void 0 ? void 0 : (_config$serverSetting = config.serverSettings) === null || _config$serverSetting === void 0 ? void 0 : _config$serverSetting.passwordValidationRegex) === false) {
|
|
68
68
|
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
|
69
69
|
if (_lodash.default.isNil(err) && isUpdated) {
|
|
70
70
|
next({
|
package/build/api/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["debug","buildDebug","addUserAuthApi","auth","config","route","Router","post","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","token","jwtEncrypt","name","flags","changePassword","put","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validatePassword","new","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION"],"sources":["../../src/api/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\
|
|
1
|
+
{"version":3,"file":"user.js","names":["debug","buildDebug","addUserAuthApi","auth","config","route","Router","post","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","token","jwtEncrypt","name","flags","changePassword","put","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validatioUtils","validatePassword","new","serverSettings","passwordValidationRegex","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION"],"sources":["../../src/api/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils, validatioUtils } from '@verdaccio/core';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\n\nimport { $NextFunctionVer } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:user');\n\nfunction addUserAuthApi(auth: IAuth, config: Config): Router {\n const route = Router(); /* eslint new-cap: 0 */\n route.post('/login', function (req: Request, res: Response, next: $NextFunctionVer): void {\n const { username, password } = req.body;\n debug('authenticate %o', username);\n auth.authenticate(username, password, async (err, user: RemoteUser): Promise<void> => {\n if (err) {\n const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;\n debug('error authenticate %o', errorCode);\n next(errorUtils.getCode(errorCode, err.message));\n } else {\n req.remote_user = user;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n\n next({\n token: await auth.jwtEncrypt(user, jWTSignOptions),\n username: req.remote_user.name,\n });\n }\n });\n });\n\n if (config?.flags?.changePassword === true) {\n route.put(\n '/reset_password',\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n // FUTURE: update to a more meaningful message\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password } = req.body;\n const { name } = req.remote_user;\n\n if (\n validatioUtils.validatePassword(\n password.new,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n auth.changePassword(\n name as string,\n password.old,\n password.new,\n (err, isUpdated): void => {\n if (_.isNil(err) && isUpdated) {\n next({\n ok: true,\n });\n } else {\n return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n }\n );\n } else {\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));\n }\n }\n );\n }\n\n return route;\n}\n\nexport default addUserAuthApi;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;;;AAKA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,wBAAX,CAAd;;AAEA,SAASC,cAAT,CAAwBC,IAAxB,EAAqCC,MAArC,EAA6D;EAAA;;EAC3D,MAAMC,KAAK,GAAG,IAAAC,eAAA,GAAd;EAAwB;;EACxBD,KAAK,CAACE,IAAN,CAAW,QAAX,EAAqB,UAAUC,GAAV,EAAwBC,GAAxB,EAAuCC,IAAvC,EAA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UACV;UACAQ,OAAO,EAAEoB,eAAA,CAAUC;QAFT,CAAD,CAAX;MAID;;MAED,MAAM;QAAE3B;MAAF,IAAeJ,GAAG,CAACK,IAAzB;MACA,MAAM;QAAEkB;MAAF,IAAWvB,GAAG,CAACgB,WAArB;;MAEA,IACEgB,oBAAA,CAAeC,gBAAf,CACE7B,QAAQ,CAAC8B,GADX,EAEEtC,MAFF,aAEEA,MAFF,gDAEEA,MAAM,CAAEuC,cAFV,0DAEE,sBAAwBC,uBAF1B,MAGM,KAJR,EAKE;QACAzC,IAAI,CAAC8B,cAAL,CACEF,IADF,EAEEnB,QAAQ,CAACiC,GAFX,EAGEjC,QAAQ,CAAC8B,GAHX,EAIE,CAAC3B,GAAD,EAAM+B,SAAN,KAA0B;UACxB,IAAIX,eAAA,CAAEC,KAAF,CAAQrB,GAAR,KAAgB+B,SAApB,EAA+B;YAC7BpC,IAAI,CAAC;cACHqC,EAAE,EAAE;YADD,CAAD,CAAJ;UAGD,CAJD,MAIO;YACL,OAAOrC,IAAI,CAACY,gBAAA,CAAW0B,gBAAX,CAA4BV,eAAA,CAAUW,qBAAtC,CAAD,CAAX;UACD;QACF,CAZH;MAcD,CApBD,MAoBO;QACL,OAAOvC,IAAI,CAACY,gBAAA,CAAWC,OAAX,CAAmBJ,iBAAA,CAAY+B,WAA/B,EAA4CC,eAAA,CAAUC,mBAAtD,CAAD,CAAX;MACD;IACF,CArCH;EAuCD;;EAED,OAAO/C,KAAP;AACD;;eAEcH,c"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function loadTheme(config: any):
|
|
2
|
-
export declare function renderWebMiddleware(config: any, auth: any): any
|
|
1
|
+
export declare function loadTheme(config: any): Promise<unknown>;
|
|
2
|
+
export declare function renderWebMiddleware(config: any, auth: any): Promise<any>;
|
|
@@ -18,6 +18,8 @@ var _core = require("@verdaccio/core");
|
|
|
18
18
|
|
|
19
19
|
var _loaders = require("@verdaccio/loaders");
|
|
20
20
|
|
|
21
|
+
var _logger = require("@verdaccio/logger");
|
|
22
|
+
|
|
21
23
|
var _url = require("@verdaccio/url");
|
|
22
24
|
|
|
23
25
|
var _renderHTML = _interopRequireDefault(require("../renderHTML"));
|
|
@@ -28,11 +30,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
28
30
|
|
|
29
31
|
const debug = (0, _debug.default)('verdaccio:web:render');
|
|
30
32
|
|
|
31
|
-
function loadTheme(config) {
|
|
33
|
+
async function loadTheme(config) {
|
|
32
34
|
if (_lodash.default.isNil(config.theme) === false) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
var _config$serverSetting;
|
|
36
|
+
|
|
37
|
+
const plugin = await (0, _loaders.asyncLoadPlugin)(config.theme, // @ts-ignore
|
|
38
|
+
{
|
|
39
|
+
config,
|
|
40
|
+
logger: _logger.logger
|
|
41
|
+
}, function (plugin) {
|
|
42
|
+
return typeof plugin === 'string';
|
|
43
|
+
}, (config === null || config === void 0 ? void 0 : (_config$serverSetting = config.serverSettings) === null || _config$serverSetting === void 0 ? void 0 : _config$serverSetting.pluginPrefix) ?? 'verdaccio-theme');
|
|
44
|
+
|
|
45
|
+
if (plugin.length > 1) {
|
|
46
|
+
_logger.logger.warn('multiple ui themes has been detected and is not supported, only the first one will be used');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return _lodash.default.head(plugin);
|
|
36
50
|
}
|
|
37
51
|
}
|
|
38
52
|
|
|
@@ -48,14 +62,14 @@ const sendFileCallback = next => err => {
|
|
|
48
62
|
}
|
|
49
63
|
};
|
|
50
64
|
|
|
51
|
-
function renderWebMiddleware(config, auth) {
|
|
65
|
+
async function renderWebMiddleware(config, auth) {
|
|
52
66
|
var _config$web;
|
|
53
67
|
|
|
54
68
|
const {
|
|
55
69
|
staticPath,
|
|
56
70
|
manifest,
|
|
57
71
|
manifestFiles
|
|
58
|
-
} = require('@verdaccio/ui-theme')();
|
|
72
|
+
} = (await loadTheme(config)) || require('@verdaccio/ui-theme')();
|
|
59
73
|
|
|
60
74
|
debug('static path %o', staticPath);
|
|
61
75
|
/* eslint new-cap:off */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-web.js","names":["debug","buildDebug","loadTheme","config","_","isNil","theme","
|
|
1
|
+
{"version":3,"file":"render-web.js","names":["debug","buildDebug","loadTheme","config","_","isNil","theme","plugin","asyncLoadPlugin","logger","serverSettings","pluginPrefix","length","warn","head","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","auth","staticPath","manifest","manifestFiles","require","router","express","Router","use","webUIJWTmiddleware","setSecurityWebHeaders","logoURI","web","logo","isURLhasValidProtocol","path","posix","join","basename","get","req","res","sendFile","resolve","filename","params","file","renderHTML"],"sources":["../../src/middleware/render-web.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport express from 'express';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport { logger } from '@verdaccio/logger';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\n\nimport renderHTML from '../renderHTML';\nimport { setSecurityWebHeaders } from './security';\n\nconst debug = buildDebug('verdaccio:web:render');\n\nexport async function loadTheme(config: any) {\n if (_.isNil(config.theme) === false) {\n const plugin = await asyncLoadPlugin(\n config.theme,\n // @ts-ignore\n { config, logger },\n function (plugin: string) {\n return typeof plugin === 'string';\n },\n config?.serverSettings?.pluginPrefix ?? 'verdaccio-theme'\n );\n if (plugin.length > 1) {\n logger.warn(\n 'multiple ui themes has been detected and is not supported, only the first one will be used'\n );\n }\n\n return _.head(plugin);\n }\n}\n\nconst sendFileCallback = (next) => (err) => {\n if (!err) {\n return;\n }\n if (err.status === HTTP_STATUS.NOT_FOUND) {\n next();\n } else {\n next(err);\n }\n};\n\nexport async function renderWebMiddleware(config, auth): Promise<any> {\n const { staticPath, manifest, manifestFiles } =\n (await loadTheme(config)) || require('@verdaccio/ui-theme')();\n debug('static path %o', staticPath);\n\n /* eslint new-cap:off */\n const router = express.Router();\n router.use(auth.webUIJWTmiddleware());\n router.use(setSecurityWebHeaders);\n\n // Logo\n let logoURI = config?.web?.logo ?? '';\n if (logoURI && !isURLhasValidProtocol(logoURI)) {\n // URI related to a local file\n\n // Note: `path.join` will break on Windows, because it transforms `/` to `\\`\n // Use POSIX version `path.posix.join` instead.\n logoURI = path.posix.join('/-/static/', path.basename(logoURI));\n router.get(logoURI, function (req, res, next) {\n res.sendFile(path.resolve(config.web.logo), sendFileCallback(next));\n debug('render static');\n });\n }\n\n // Static\n router.get('/-/static/*', function (req, res, next) {\n const filename = req.params[0];\n const file = `${staticPath}/${filename}`;\n debug('render static file %o', file);\n res.sendFile(file, sendFileCallback(next));\n });\n\n router.get('/-/web/:section/*', function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render html section');\n });\n\n router.get('/', function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render root');\n });\n\n return router;\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,sBAAX,CAAd;;AAEO,eAAeC,SAAf,CAAyBC,MAAzB,EAAsC;EAC3C,IAAIC,eAAA,CAAEC,KAAF,CAAQF,MAAM,CAACG,KAAf,MAA0B,KAA9B,EAAqC;IAAA;;IACnC,MAAMC,MAAM,GAAG,MAAM,IAAAC,wBAAA,EACnBL,MAAM,CAACG,KADY,EAEnB;IACA;MAAEH,MAAF;MAAUM,MAAM,EAANA;IAAV,CAHmB,EAInB,UAAUF,MAAV,EAA0B;MACxB,OAAO,OAAOA,MAAP,KAAkB,QAAzB;IACD,CANkB,EAOnB,CAAAJ,MAAM,SAAN,IAAAA,MAAM,WAAN,qCAAAA,MAAM,CAAEO,cAAR,gFAAwBC,YAAxB,KAAwC,iBAPrB,CAArB;;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GAAf,EAAoB3B,IAApB,EAA0B;MAC5C2B,GAAG,CAACC,QAAJ,CAAaP,aAAA,CAAKQ,OAAL,CAAa1C,MAAM,CAAC+B,GAAP,CAAWC,IAAxB,CAAb,EAA4CpB,gBAAgB,CAACC,IAAD,CAA5D;MACAhB,KAAK,CAAC,eAAD,CAAL;IACD,CAHD;EAID,CAtBmE,CAwBpE;;;EACA2B,MAAM,CAACc,GAAP,CAAW,aAAX,EAA0B,UAAUC,GAAV,EAAeC,GAAf,EAAoB3B,IAApB,EAA0B;IAClD,MAAM8B,QAAQ,GAAGJ,GAAG,CAACK,MAAJ,CAAW,CAAX,CAAjB;IACA,MAAMC,IAAI,GAAI,GAAEzB,UAAW,IAAGuB,QAAS,EAAvC;IACA9C,KAAK,CAAC,uBAAD,EAA0BgD,IAA1B,CAAL;IACAL,GAAG,CAACC,QAAJ,CAAaI,IAAb,EAAmBjC,gBAAgB,CAACC,IAAD,CAAnC;EACD,CALD;EAOAW,MAAM,CAACc,GAAP,CAAW,mBAAX,EAAgC,UAAUC,GAAV,EAAeC,GAAf,EAAoB;IAClD,IAAAM,mBAAA,EAAW9C,MAAX,EAAmBqB,QAAnB,EAA6BC,aAA7B,EAA4CiB,GAA5C,EAAiDC,GAAjD;IACA3C,KAAK,CAAC,qBAAD,CAAL;EACD,CAHD;EAKA2B,MAAM,CAACc,GAAP,CAAW,GAAX,EAAgB,UAAUC,GAAV,EAAeC,GAAf,EAAoB;IAClC,IAAAM,mBAAA,EAAW9C,MAAX,EAAmBqB,QAAnB,EAA6BC,aAA7B,EAA4CiB,GAA5C,EAAiDC,GAAjD;IACA3C,KAAK,CAAC,aAAD,CAAL;EACD,CAHD;EAKA,OAAO2B,MAAP;AACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (config: any, auth: any, storage: any) => import("express-serve-static-core").Router
|
|
1
|
+
declare const _default: (config: any, auth: any, storage: any) => Promise<import("express-serve-static-core").Router>;
|
|
2
2
|
export default _default;
|
package/build/web-middleware.js
CHANGED
|
@@ -13,12 +13,12 @@ var _webApi = require("./middleware/web-api");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
var _default = (config, auth, storage) => {
|
|
16
|
+
var _default = async (config, auth, storage) => {
|
|
17
17
|
// eslint-disable-next-line new-cap
|
|
18
18
|
const app = _express.default.Router(); // load application
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
app.use('/', (0, _renderWeb.renderWebMiddleware)(config, auth)); // web endpoints, search, packages, etc
|
|
21
|
+
app.use('/', await (0, _renderWeb.renderWebMiddleware)(config, auth)); // web endpoints, search, packages, etc
|
|
22
22
|
|
|
23
23
|
app.use('/-/verdaccio/', (0, _webApi.webAPI)(config, auth, storage));
|
|
24
24
|
return app;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-middleware.js","names":["config","auth","storage","app","express","Router","use","renderWebMiddleware","webAPI"],"sources":["../src/web-middleware.ts"],"sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './middleware/render-web';\nimport { webAPI } from './middleware/web-api';\n\nexport default (config, auth, storage) => {\n // eslint-disable-next-line new-cap\n const app = express.Router();\n // load application\n app.use('/', renderWebMiddleware(config, auth));\n // web endpoints, search, packages, etc\n app.use('/-/verdaccio/', webAPI(config, auth, storage));\n return app;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;eAEe,
|
|
1
|
+
{"version":3,"file":"web-middleware.js","names":["config","auth","storage","app","express","Router","use","renderWebMiddleware","webAPI"],"sources":["../src/web-middleware.ts"],"sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './middleware/render-web';\nimport { webAPI } from './middleware/web-api';\n\nexport default async (config, auth, storage) => {\n // eslint-disable-next-line new-cap\n const app = express.Router();\n // load application\n app.use('/', await renderWebMiddleware(config, auth));\n // web endpoints, search, packages, etc\n app.use('/-/verdaccio/', webAPI(config, auth, storage));\n return app;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;eAEe,OAAOA,MAAP,EAAeC,IAAf,EAAqBC,OAArB,KAAiC;EAC9C;EACA,MAAMC,GAAG,GAAGC,gBAAA,CAAQC,MAAR,EAAZ,CAF8C,CAG9C;;;EACAF,GAAG,CAACG,GAAJ,CAAQ,GAAR,EAAa,MAAM,IAAAC,8BAAA,EAAoBP,MAApB,EAA4BC,IAA5B,CAAnB,EAJ8C,CAK9C;;EACAE,GAAG,CAACG,GAAJ,CAAQ,eAAR,EAAyB,IAAAE,cAAA,EAAOR,MAAP,EAAeC,IAAf,EAAqBC,OAArB,CAAzB;EACA,OAAOC,GAAP;AACD,C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/web",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.35",
|
|
4
4
|
"description": "web ui middleware",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@verdaccio/auth": "6.0.0-6-next.
|
|
29
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
30
|
-
"@verdaccio/config": "6.0.0-6-next.
|
|
31
|
-
"@verdaccio/loaders": "6.0.0-6-next.
|
|
32
|
-
"@verdaccio/logger": "6.0.0-6-next.
|
|
33
|
-
"@verdaccio/middleware": "6.0.0-6-next.
|
|
28
|
+
"@verdaccio/auth": "6.0.0-6-next.27",
|
|
29
|
+
"@verdaccio/core": "6.0.0-6-next.48",
|
|
30
|
+
"@verdaccio/config": "6.0.0-6-next.48",
|
|
31
|
+
"@verdaccio/loaders": "6.0.0-6-next.17",
|
|
32
|
+
"@verdaccio/logger": "6.0.0-6-next.16",
|
|
33
|
+
"@verdaccio/middleware": "6.0.0-6-next.27",
|
|
34
34
|
"@verdaccio/readme": "11.0.0-6-next.6",
|
|
35
|
-
"@verdaccio/store": "6.0.0-6-next.
|
|
36
|
-
"@verdaccio/tarball": "11.0.0-6-next.
|
|
37
|
-
"@verdaccio/url": "11.0.0-6-next.
|
|
38
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
35
|
+
"@verdaccio/store": "6.0.0-6-next.28",
|
|
36
|
+
"@verdaccio/tarball": "11.0.0-6-next.17",
|
|
37
|
+
"@verdaccio/url": "11.0.0-6-next.14",
|
|
38
|
+
"@verdaccio/utils": "6.0.0-6-next.16",
|
|
39
39
|
"body-parser": "1.20.0",
|
|
40
40
|
"debug": "4.3.4",
|
|
41
41
|
"express": "4.18.1",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
"lru-cache": "6.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "16.11.
|
|
47
|
-
"@verdaccio/types": "11.0.0-6-next.
|
|
48
|
-
"@verdaccio/test-helper": "
|
|
49
|
-
"@verdaccio/api": "6.0.0-6-next.
|
|
46
|
+
"@types/node": "16.11.60",
|
|
47
|
+
"@verdaccio/types": "11.0.0-6-next.17",
|
|
48
|
+
"@verdaccio/test-helper": "2.0.0-6-next.5",
|
|
49
|
+
"@verdaccio/api": "6.0.0-6-next.31",
|
|
50
50
|
"node-html-parser": "4.1.5",
|
|
51
51
|
"supertest": "6.2.4",
|
|
52
52
|
"nock": "13.2.9",
|
|
53
53
|
"jsdom": "20.0.0",
|
|
54
54
|
"undici": "4.16.0",
|
|
55
|
-
"verdaccio-auth-memory": "11.0.0-6-next.
|
|
56
|
-
"verdaccio-memory": "11.0.0-6-next.
|
|
55
|
+
"verdaccio-auth-memory": "11.0.0-6-next.13",
|
|
56
|
+
"verdaccio-memory": "11.0.0-6-next.15"
|
|
57
57
|
},
|
|
58
58
|
"funding": {
|
|
59
59
|
"type": "opencollective",
|
package/src/api/user.ts
CHANGED
|
@@ -3,9 +3,8 @@ import { Request, Response, Router } from 'express';
|
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
|
|
5
5
|
import { IAuth } from '@verdaccio/auth';
|
|
6
|
-
import { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
|
|
6
|
+
import { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils, validatioUtils } from '@verdaccio/core';
|
|
7
7
|
import { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';
|
|
8
|
-
import { validatePassword } from '@verdaccio/utils';
|
|
9
8
|
|
|
10
9
|
import { $NextFunctionVer } from './package';
|
|
11
10
|
|
|
@@ -48,7 +47,12 @@ function addUserAuthApi(auth: IAuth, config: Config): Router {
|
|
|
48
47
|
const { password } = req.body;
|
|
49
48
|
const { name } = req.remote_user;
|
|
50
49
|
|
|
51
|
-
if (
|
|
50
|
+
if (
|
|
51
|
+
validatioUtils.validatePassword(
|
|
52
|
+
password.new,
|
|
53
|
+
config?.serverSettings?.passwordValidationRegex
|
|
54
|
+
) === false
|
|
55
|
+
) {
|
|
52
56
|
auth.changePassword(
|
|
53
57
|
name as string,
|
|
54
58
|
password.old,
|
|
@@ -4,7 +4,8 @@ import _ from 'lodash';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
|
|
6
6
|
import { HTTP_STATUS } from '@verdaccio/core';
|
|
7
|
-
import {
|
|
7
|
+
import { asyncLoadPlugin } from '@verdaccio/loaders';
|
|
8
|
+
import { logger } from '@verdaccio/logger';
|
|
8
9
|
import { isURLhasValidProtocol } from '@verdaccio/url';
|
|
9
10
|
|
|
10
11
|
import renderHTML from '../renderHTML';
|
|
@@ -12,19 +13,24 @@ import { setSecurityWebHeaders } from './security';
|
|
|
12
13
|
|
|
13
14
|
const debug = buildDebug('verdaccio:web:render');
|
|
14
15
|
|
|
15
|
-
export function loadTheme(config) {
|
|
16
|
+
export async function loadTheme(config: any) {
|
|
16
17
|
if (_.isNil(config.theme) === false) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'verdaccio-theme'
|
|
26
|
-
)
|
|
18
|
+
const plugin = await asyncLoadPlugin(
|
|
19
|
+
config.theme,
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
{ config, logger },
|
|
22
|
+
function (plugin: string) {
|
|
23
|
+
return typeof plugin === 'string';
|
|
24
|
+
},
|
|
25
|
+
config?.serverSettings?.pluginPrefix ?? 'verdaccio-theme'
|
|
27
26
|
);
|
|
27
|
+
if (plugin.length > 1) {
|
|
28
|
+
logger.warn(
|
|
29
|
+
'multiple ui themes has been detected and is not supported, only the first one will be used'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return _.head(plugin);
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -39,8 +45,9 @@ const sendFileCallback = (next) => (err) => {
|
|
|
39
45
|
}
|
|
40
46
|
};
|
|
41
47
|
|
|
42
|
-
export function renderWebMiddleware(config, auth): any {
|
|
43
|
-
const { staticPath, manifest, manifestFiles } =
|
|
48
|
+
export async function renderWebMiddleware(config, auth): Promise<any> {
|
|
49
|
+
const { staticPath, manifest, manifestFiles } =
|
|
50
|
+
(await loadTheme(config)) || require('@verdaccio/ui-theme')();
|
|
44
51
|
debug('static path %o', staticPath);
|
|
45
52
|
|
|
46
53
|
/* eslint new-cap:off */
|
package/src/web-middleware.ts
CHANGED
|
@@ -3,11 +3,11 @@ import express from 'express';
|
|
|
3
3
|
import { renderWebMiddleware } from './middleware/render-web';
|
|
4
4
|
import { webAPI } from './middleware/web-api';
|
|
5
5
|
|
|
6
|
-
export default (config, auth, storage) => {
|
|
6
|
+
export default async (config, auth, storage) => {
|
|
7
7
|
// eslint-disable-next-line new-cap
|
|
8
8
|
const app = express.Router();
|
|
9
9
|
// load application
|
|
10
|
-
app.use('/', renderWebMiddleware(config, auth));
|
|
10
|
+
app.use('/', await renderWebMiddleware(config, auth));
|
|
11
11
|
// web endpoints, search, packages, etc
|
|
12
12
|
app.use('/-/verdaccio/', webAPI(config, auth, storage));
|
|
13
13
|
return app;
|
package/test/helper.ts
CHANGED
|
@@ -18,5 +18,9 @@ export const getConf = (configName: string) => {
|
|
|
18
18
|
|
|
19
19
|
// @deprecated
|
|
20
20
|
export async function initializeServer(configName): Promise<Application> {
|
|
21
|
-
return initializeServerHelper(
|
|
21
|
+
return initializeServerHelper(
|
|
22
|
+
getConf(configName),
|
|
23
|
+
[apiMiddleware, { async: true, routes }],
|
|
24
|
+
Storage
|
|
25
|
+
);
|
|
22
26
|
}
|