@verdaccio/web 6.0.0-6-next.38 → 6.0.0-6-next.39
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 +15 -0
- package/build/api/index.js +1 -15
- package/build/api/index.js.map +1 -1
- package/build/api/package.js +10 -36
- package/build/api/package.js.map +1 -1
- package/build/api/readme.d.ts +1 -1
- package/build/api/readme.js +1 -14
- package/build/api/readme.js.map +1 -1
- package/build/api/search.js +5 -18
- package/build/api/search.js.map +1 -1
- package/build/api/sidebar.d.ts +2 -2
- package/build/api/sidebar.js +11 -25
- package/build/api/sidebar.js.map +1 -1
- package/build/api/user.js +1 -17
- package/build/api/user.js.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/middleware/render-web.js +8 -28
- package/build/middleware/render-web.js.map +1 -1
- package/build/middleware/security.js +6 -8
- package/build/middleware/security.js.map +1 -1
- package/build/middleware/web-api.js +2 -9
- package/build/middleware/web-api.js.map +1 -1
- package/build/renderHTML.js +2 -18
- package/build/renderHTML.js.map +1 -1
- package/build/template.d.ts +1 -1
- package/build/template.js +0 -6
- package/build/template.js.map +1 -1
- package/build/utils/manifest.d.ts +1 -1
- package/build/utils/manifest.js +0 -4
- package/build/utils/manifest.js.map +1 -1
- package/build/utils/web-utils.d.ts +1 -1
- package/build/utils/web-utils.js +0 -14
- package/build/utils/web-utils.js.map +1 -1
- package/build/web-middleware.js +4 -11
- package/build/web-middleware.js.map +1 -1
- package/package.json +18 -18
package/build/api/user.js
CHANGED
|
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
var _express = require("express");
|
|
11
|
-
|
|
12
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
10
|
var _core = require("@verdaccio/core");
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
const debug = (0, _debug.default)('verdaccio:web:api:user');
|
|
19
|
-
|
|
20
13
|
function addUserAuthApi(auth, config) {
|
|
21
14
|
var _config$flags;
|
|
22
|
-
|
|
23
|
-
const route = (0, _express.Router)();
|
|
24
|
-
/* eslint new-cap: 0 */
|
|
25
|
-
|
|
15
|
+
const route = (0, _express.Router)(); /* eslint new-cap: 0 */
|
|
26
16
|
route.post('/login', function (req, res, next) {
|
|
27
17
|
const {
|
|
28
18
|
username,
|
|
@@ -45,11 +35,9 @@ function addUserAuthApi(auth, config) {
|
|
|
45
35
|
}
|
|
46
36
|
});
|
|
47
37
|
});
|
|
48
|
-
|
|
49
38
|
if ((config === null || config === void 0 ? void 0 : (_config$flags = config.flags) === null || _config$flags === void 0 ? void 0 : _config$flags.changePassword) === true) {
|
|
50
39
|
route.put('/reset_password', function (req, res, next) {
|
|
51
40
|
var _config$serverSetting;
|
|
52
|
-
|
|
53
41
|
if (_lodash.default.isNil(req.remote_user.name)) {
|
|
54
42
|
res.status(_core.HTTP_STATUS.UNAUTHORIZED);
|
|
55
43
|
return next({
|
|
@@ -57,14 +45,12 @@ function addUserAuthApi(auth, config) {
|
|
|
57
45
|
message: _core.API_ERROR.MUST_BE_LOGGED
|
|
58
46
|
});
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
const {
|
|
62
49
|
password
|
|
63
50
|
} = req.body;
|
|
64
51
|
const {
|
|
65
52
|
name
|
|
66
53
|
} = req.remote_user;
|
|
67
|
-
|
|
68
54
|
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) {
|
|
69
55
|
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
|
70
56
|
if (_lodash.default.isNil(err) && isUpdated) {
|
|
@@ -80,10 +66,8 @@ function addUserAuthApi(auth, config) {
|
|
|
80
66
|
}
|
|
81
67
|
});
|
|
82
68
|
}
|
|
83
|
-
|
|
84
69
|
return route;
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
var _default = addUserAuthApi;
|
|
88
72
|
exports.default = _default;
|
|
89
73
|
//# sourceMappingURL=user.js.map
|
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","set","HEADERS","CACHE_CONTROL","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 { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HEADERS,\n HTTP_STATUS,\n VerdaccioError,\n errorUtils,\n validatioUtils,\n} 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: Auth, 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(\n username,\n password,\n async (err: VerdaccioError | null, 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 as RemoteUser;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n next({\n token: await auth.jwtEncrypt(user as RemoteUser, jWTSignOptions),\n username: req.remote_user.name,\n });\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":"
|
|
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","set","HEADERS","CACHE_CONTROL","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 { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HEADERS,\n HTTP_STATUS,\n VerdaccioError,\n errorUtils,\n validatioUtils,\n} 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: Auth, 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(\n username,\n password,\n async (err: VerdaccioError | null, 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 as RemoteUser;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n next({\n token: await auth.jwtEncrypt(user as RemoteUser, jWTSignOptions),\n username: req.remote_user.name,\n });\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;AAQyB;AAKzB,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,wBAAwB,CAAC;AAElD,SAASC,cAAc,CAACC,IAAU,EAAEC,MAAc,EAAU;EAAA;EAC1D,MAAMC,KAAK,GAAG,IAAAC,eAAM,GAAE,CAAC,CAAC;EACxBD,KAAK,CAACE,IAAI,CAAC,QAAQ,EAAE,UAAUC,GAAY,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IACxF,MAAM;MAAEC,QAAQ;MAAEC;IAAS,CAAC,GAAGJ,GAAG,CAACK,IAAI;IACvCb,KAAK,CAAC,iBAAiB,EAAEW,QAAQ,CAAC;IAClCR,IAAI,CAACW,YAAY,CACfH,QAAQ,EACRC,QAAQ,EACR,OAAOG,GAA0B,EAAEC,IAAiB,KAAoB;MACtE,IAAID,GAAG,EAAE;QACP,MAAME,SAAS,GAAGF,GAAG,CAACG,OAAO,GAAGC,iBAAW,CAACC,YAAY,GAAGD,iBAAW,CAACE,cAAc;QACrFrB,KAAK,CAAC,uBAAuB,EAAEiB,SAAS,CAAC;QACzCP,IAAI,CAACY,gBAAU,CAACC,OAAO,CAACN,SAAS,EAAEF,GAAG,CAACG,OAAO,CAAC,CAAC;MAClD,CAAC,MAAM;QACLV,GAAG,CAACgB,WAAW,GAAGR,IAAkB;QACpC,MAAMS,cAA8B,GAAGrB,MAAM,CAACsB,QAAQ,CAACC,GAAG,CAACC,IAAI;QAC/DnB,GAAG,CAACoB,GAAG,CAACC,aAAO,CAACC,aAAa,EAAE,oBAAoB,CAAC;QACpDrB,IAAI,CAAC;UACHsB,KAAK,EAAE,MAAM7B,IAA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ACW,qBAAqB,CAAC,CAAC;UAC3E;QACF,CAAC,CACF;MACH,CAAC,MAAM;QACL,OAAO1C,IAAI,CAACY,gBAAU,CAACC,OAAO,CAACJ,iBAAW,CAACkC,WAAW,EAAEC,eAAS,CAACC,mBAAmB,CAAC,CAAC;MACzF;IACF,CAAC,CACF;EACH;EAEA,OAAOlD,KAAK;AACd;AAAC,eAEcH,cAAc;AAAA"}
|
package/build/index.js
CHANGED
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
return _webMiddleware.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _webMiddleware = _interopRequireDefault(require("./web-middleware"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
14
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default } from './web-middleware';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default } from './web-middleware';\n"],"mappings":";;;;;;;;;;;AAAA;AAA2C"}
|
|
@@ -5,84 +5,64 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.loadTheme = loadTheme;
|
|
7
7
|
exports.renderWebMiddleware = renderWebMiddleware;
|
|
8
|
-
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
-
|
|
11
9
|
var _express = _interopRequireDefault(require("express"));
|
|
12
|
-
|
|
13
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
14
|
-
|
|
15
11
|
var _path = _interopRequireDefault(require("path"));
|
|
16
|
-
|
|
17
12
|
var _core = require("@verdaccio/core");
|
|
18
|
-
|
|
19
13
|
var _loaders = require("@verdaccio/loaders");
|
|
20
|
-
|
|
21
14
|
var _logger = require("@verdaccio/logger");
|
|
22
|
-
|
|
23
15
|
var _url = require("@verdaccio/url");
|
|
24
|
-
|
|
25
16
|
var _renderHTML = _interopRequireDefault(require("../renderHTML"));
|
|
26
|
-
|
|
27
17
|
var _security = require("./security");
|
|
28
|
-
|
|
29
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
|
|
31
19
|
const debug = (0, _debug.default)('verdaccio:web:render');
|
|
32
|
-
|
|
33
20
|
async function loadTheme(config) {
|
|
34
21
|
if (_lodash.default.isNil(config.theme) === false) {
|
|
35
22
|
var _config$serverSetting;
|
|
36
|
-
|
|
37
23
|
const plugin = await (0, _loaders.asyncLoadPlugin)(config.theme, {
|
|
38
24
|
config,
|
|
39
25
|
logger: _logger.logger
|
|
40
|
-
},
|
|
26
|
+
},
|
|
27
|
+
// TODO: add types { staticPath: string; manifest: unknown; manifestFiles: unknown }
|
|
41
28
|
function (plugin) {
|
|
42
29
|
return plugin.staticPath && plugin.manifest && plugin.manifestFiles;
|
|
43
30
|
}, (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
31
|
if (plugin.length > 1) {
|
|
46
32
|
_logger.logger.warn('multiple ui themes has been detected and is not supported, only the first one will be used');
|
|
47
33
|
}
|
|
48
|
-
|
|
49
34
|
return _lodash.default.head(plugin);
|
|
50
35
|
}
|
|
51
36
|
}
|
|
52
|
-
|
|
53
37
|
const sendFileCallback = next => err => {
|
|
54
38
|
if (!err) {
|
|
55
39
|
return;
|
|
56
40
|
}
|
|
57
|
-
|
|
58
41
|
if (err.status === _core.HTTP_STATUS.NOT_FOUND) {
|
|
59
42
|
next();
|
|
60
43
|
} else {
|
|
61
44
|
next(err);
|
|
62
45
|
}
|
|
63
46
|
};
|
|
64
|
-
|
|
65
47
|
async function renderWebMiddleware(config, auth) {
|
|
66
48
|
var _config$web;
|
|
67
|
-
|
|
68
49
|
const {
|
|
69
50
|
staticPath,
|
|
70
51
|
manifest,
|
|
71
52
|
manifestFiles
|
|
72
53
|
} = (await loadTheme(config)) || require('@verdaccio/ui-theme')();
|
|
73
|
-
|
|
74
54
|
debug('static path %o', staticPath);
|
|
75
|
-
/* eslint new-cap:off */
|
|
76
55
|
|
|
56
|
+
/* eslint new-cap:off */
|
|
77
57
|
const router = _express.default.Router();
|
|
78
|
-
|
|
79
58
|
router.use(auth.webUIJWTmiddleware());
|
|
80
|
-
router.use(_security.setSecurityWebHeaders);
|
|
59
|
+
router.use(_security.setSecurityWebHeaders);
|
|
81
60
|
|
|
61
|
+
// Logo
|
|
82
62
|
let logoURI = (config === null || config === void 0 ? void 0 : (_config$web = config.web) === null || _config$web === void 0 ? void 0 : _config$web.logo) ?? '';
|
|
83
|
-
|
|
84
63
|
if (logoURI && !(0, _url.isURLhasValidProtocol)(logoURI)) {
|
|
85
64
|
// URI related to a local file
|
|
65
|
+
|
|
86
66
|
// Note: `path.join` will break on Windows, because it transforms `/` to `\`
|
|
87
67
|
// Use POSIX version `path.posix.join` instead.
|
|
88
68
|
logoURI = _path.default.posix.join('/-/static/', _path.default.basename(logoURI));
|
|
@@ -90,9 +70,9 @@ async function renderWebMiddleware(config, auth) {
|
|
|
90
70
|
res.sendFile(_path.default.resolve(config.web.logo), sendFileCallback(next));
|
|
91
71
|
debug('render static');
|
|
92
72
|
});
|
|
93
|
-
}
|
|
94
|
-
|
|
73
|
+
}
|
|
95
74
|
|
|
75
|
+
// Static
|
|
96
76
|
router.get('/-/static/*', function (req, res, next) {
|
|
97
77
|
const filename = req.params[0];
|
|
98
78
|
const file = `${staticPath}/${filename}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-web.js","names":["debug","buildDebug","loadTheme","config","_","isNil","theme","plugin","asyncLoadPlugin","logger","staticPath","manifest","manifestFiles","serverSettings","pluginPrefix","length","warn","head","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","auth","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 { config, logger },\n // TODO: add types { staticPath: string; manifest: unknown; manifestFiles: unknown }\n function (plugin: any) {\n return plugin.staticPath && plugin.manifest && plugin.manifestFiles;\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":"
|
|
1
|
+
{"version":3,"file":"render-web.js","names":["debug","buildDebug","loadTheme","config","_","isNil","theme","plugin","asyncLoadPlugin","logger","staticPath","manifest","manifestFiles","serverSettings","pluginPrefix","length","warn","head","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","auth","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 { config, logger },\n // TODO: add types { staticPath: string; manifest: unknown; manifestFiles: unknown }\n function (plugin: any) {\n return plugin.staticPath && plugin.manifest && plugin.manifestFiles;\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;AAAmD;AAEnD,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEzC,eAAeC,SAAS,CAACC,MAAW,EAAE;EAC3C,IAAIC,eAAC,CAACC,KAAK,CAACF,MAAM,CAACG,KAAK,CAAC,KAAK,KAAK,EAAE;IAAA;IACnC,MAAMC,MAAM,GAAG,MAAM,IAAAC,wBAAe,EAClCL,MAAM,CA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C,aAAa,EAAE8B,GAAG,EAAEC,GAAG,CAAC;IACrD3C,KAAK,CAAC,aAAa,CAAC;EACtB,CAAC,CAAC;EAEF,OAAO2B,MAAM;AACf"}
|
|
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.setSecurityWebHeaders = setSecurityWebHeaders;
|
|
7
|
-
|
|
8
7
|
var _core = require("@verdaccio/core");
|
|
9
|
-
|
|
10
8
|
function setSecurityWebHeaders(req, res, next) {
|
|
11
9
|
// disable loading in frames (clickjacking, etc.)
|
|
12
|
-
res.header(_core.HEADERS.FRAMES_OPTIONS, 'deny');
|
|
13
|
-
|
|
14
|
-
res.header(_core.HEADERS.CSP, "connect-src 'self'");
|
|
15
|
-
|
|
16
|
-
res.header(_core.HEADERS.CTO, 'nosniff');
|
|
17
|
-
|
|
10
|
+
res.header(_core.HEADERS.FRAMES_OPTIONS, 'deny');
|
|
11
|
+
// avoid stablish connections outside of domain
|
|
12
|
+
res.header(_core.HEADERS.CSP, "connect-src 'self'");
|
|
13
|
+
// https://stackoverflow.com/questions/18337630/what-is-x-content-type-options-nosniff
|
|
14
|
+
res.header(_core.HEADERS.CTO, 'nosniff');
|
|
15
|
+
// https://stackoverflow.com/questions/9090577/what-is-the-http-header-x-xss-protection
|
|
18
16
|
res.header(_core.HEADERS.XSS, '1; mode=block');
|
|
19
17
|
next();
|
|
20
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","names":["setSecurityWebHeaders","req","res","next","header","HEADERS","FRAMES_OPTIONS","CSP","CTO","XSS"],"sources":["../../src/middleware/security.ts"],"sourcesContent":["import { HEADERS } from '@verdaccio/core';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\n\nexport function setSecurityWebHeaders(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n // disable loading in frames (clickjacking, etc.)\n res.header(HEADERS.FRAMES_OPTIONS, 'deny');\n // avoid stablish connections outside of domain\n res.header(HEADERS.CSP, \"connect-src 'self'\");\n // https://stackoverflow.com/questions/18337630/what-is-x-content-type-options-nosniff\n res.header(HEADERS.CTO, 'nosniff');\n // https://stackoverflow.com/questions/9090577/what-is-the-http-header-x-xss-protection\n res.header(HEADERS.XSS, '1; mode=block');\n next();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"security.js","names":["setSecurityWebHeaders","req","res","next","header","HEADERS","FRAMES_OPTIONS","CSP","CTO","XSS"],"sources":["../../src/middleware/security.ts"],"sourcesContent":["import { HEADERS } from '@verdaccio/core';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\n\nexport function setSecurityWebHeaders(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n // disable loading in frames (clickjacking, etc.)\n res.header(HEADERS.FRAMES_OPTIONS, 'deny');\n // avoid stablish connections outside of domain\n res.header(HEADERS.CSP, \"connect-src 'self'\");\n // https://stackoverflow.com/questions/18337630/what-is-x-content-type-options-nosniff\n res.header(HEADERS.CTO, 'nosniff');\n // https://stackoverflow.com/questions/9090577/what-is-the-http-header-x-xss-protection\n res.header(HEADERS.XSS, '1; mode=block');\n next();\n}\n"],"mappings":";;;;;;AAAA;AAGO,SAASA,qBAAqB,CACnCC,GAAmB,EACnBC,GAAoB,EACpBC,IAAsB,EAChB;EACN;EACAD,GAAG,CAACE,MAAM,CAACC,aAAO,CAACC,cAAc,EAAE,MAAM,CAAC;EAC1C;EACAJ,GAAG,CAACE,MAAM,CAACC,aAAO,CAACE,GAAG,EAAE,oBAAoB,CAAC;EAC7C;EACAL,GAAG,CAACE,MAAM,CAACC,aAAO,CAACG,GAAG,EAAE,SAAS,CAAC;EAClC;EACAN,GAAG,CAACE,MAAM,CAACC,aAAO,CAACI,GAAG,EAAE,eAAe,CAAC;EACxCN,IAAI,EAAE;AACR"}
|
|
@@ -4,24 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.webAPI = webAPI;
|
|
7
|
-
|
|
8
7
|
var _bodyParser = _interopRequireDefault(require("body-parser"));
|
|
9
|
-
|
|
10
8
|
var _express = require("express");
|
|
11
|
-
|
|
12
9
|
var _middleware = require("@verdaccio/middleware");
|
|
13
|
-
|
|
14
10
|
var _api = _interopRequireDefault(require("../api"));
|
|
15
|
-
|
|
16
11
|
var _security = require("./security");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function webAPI(config, auth, storage) {
|
|
21
14
|
// eslint-disable-next-line new-cap
|
|
22
|
-
const route = (0, _express.Router)();
|
|
15
|
+
const route = (0, _express.Router)();
|
|
16
|
+
// validate all of these params as a package name
|
|
23
17
|
// this might be too harsh, so ask if it causes trouble=
|
|
24
|
-
|
|
25
18
|
route.param('package', _middleware.validatePackage);
|
|
26
19
|
route.param('filename', _middleware.validateName);
|
|
27
20
|
route.param('version', _middleware.validateName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-api.js","names":["webAPI","config","auth","storage","route","Router","param","validatePackage","validateName","match","use","bodyParser","urlencoded","extended","webUIJWTmiddleware","setSecurityWebHeaders","webEndpointsApi"],"sources":["../../src/middleware/web-api.ts"],"sourcesContent":["import bodyParser from 'body-parser';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { match, validateName, validatePackage } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport webEndpointsApi from '../api';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPI(config: Config, auth: Auth, storage: Storage): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.param('anything', match(/.*/));\n route.use(bodyParser.urlencoded({ extended: false }));\n route.use(auth.webUIJWTmiddleware());\n route.use(setSecurityWebHeaders);\n route.use(webEndpointsApi(auth, storage, config));\n return route;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-api.js","names":["webAPI","config","auth","storage","route","Router","param","validatePackage","validateName","match","use","bodyParser","urlencoded","extended","webUIJWTmiddleware","setSecurityWebHeaders","webEndpointsApi"],"sources":["../../src/middleware/web-api.ts"],"sourcesContent":["import bodyParser from 'body-parser';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { match, validateName, validatePackage } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport webEndpointsApi from '../api';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPI(config: Config, auth: Auth, storage: Storage): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.param('anything', match(/.*/));\n route.use(bodyParser.urlencoded({ extended: false }));\n route.use(auth.webUIJWTmiddleware());\n route.use(setSecurityWebHeaders);\n route.use(webEndpointsApi(auth, storage, config));\n return route;\n}\n"],"mappings":";;;;;;AAAA;AACA;AAGA;AAIA;AACA;AAAmD;AAE5C,SAASA,MAAM,CAACC,MAAc,EAAEC,IAAU,EAAEC,OAAgB,EAAU;EAC3E;EACA,MAAMC,KAAK,GAAG,IAAAC,eAAM,GAAE;EACtB;EACA;EACAD,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEC,2BAAe,CAAC;EACvCH,KAAK,CAACE,KAAK,CAAC,UAAU,EAAEE,wBAAY,CAAC;EACrCJ,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEE,wBAAY,CAAC;EACpCJ,KAAK,CAACE,KAAK,CAAC,UAAU,EAAE,IAAAG,iBAAK,EAAC,IAAI,CAAC,CAAC;EACpCL,KAAK,CAACM,GAAG,CAACC,mBAAU,CAACC,UAAU,CAAC;IAAEC,QAAQ,EAAE;EAAM,CAAC,CAAC,CAAC;EACrDT,KAAK,CAACM,GAAG,CAACR,IAAI,CAACY,kBAAkB,EAAE,CAAC;EACpCV,KAAK,CAACM,GAAG,CAACK,+BAAqB,CAAC;EAChCX,KAAK,CAACM,GAAG,CAAC,IAAAM,YAAe,EAACd,IAAI,EAAEC,OAAO,EAAEF,MAAM,CAAC,CAAC;EACjD,OAAOG,KAAK;AACd"}
|
package/build/renderHTML.js
CHANGED
|
@@ -4,27 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = renderHTML;
|
|
7
|
-
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
var _lruCache = _interopRequireDefault(require("lru-cache"));
|
|
11
|
-
|
|
12
9
|
var _url = require("url");
|
|
13
|
-
|
|
14
10
|
var _config = require("@verdaccio/config");
|
|
15
|
-
|
|
16
11
|
var _core = require("@verdaccio/core");
|
|
17
|
-
|
|
18
12
|
var _url2 = require("@verdaccio/url");
|
|
19
|
-
|
|
20
13
|
var _template = _interopRequireDefault(require("./template"));
|
|
21
|
-
|
|
22
14
|
var _webUtils = require("./utils/web-utils");
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
const pkgJSON = require('../package.json');
|
|
27
|
-
|
|
28
17
|
const DEFAULT_LANGUAGE = 'es-US';
|
|
29
18
|
const cache = new _lruCache.default({
|
|
30
19
|
max: 500,
|
|
@@ -35,10 +24,8 @@ const defaultManifestFiles = {
|
|
|
35
24
|
js: ['runtime.js', 'vendors.js', 'main.js'],
|
|
36
25
|
ico: 'favicon.ico'
|
|
37
26
|
};
|
|
38
|
-
|
|
39
27
|
function renderHTML(config, manifest, manifestFiles, req, res) {
|
|
40
28
|
var _config$i18n, _config$web, _config$web2, _config$web3, _config$web4, _config$web5, _config$web6, _config$web7;
|
|
41
|
-
|
|
42
29
|
const {
|
|
43
30
|
url_prefix
|
|
44
31
|
} = config;
|
|
@@ -53,7 +40,8 @@ function renderHTML(config, manifest, manifestFiles, req, res) {
|
|
|
53
40
|
const logoURI = (config === null || config === void 0 ? void 0 : (_config$web5 = config.web) === null || _config$web5 === void 0 ? void 0 : _config$web5.logo) ?? '';
|
|
54
41
|
const pkgManagers = (config === null || config === void 0 ? void 0 : (_config$web6 = config.web) === null || _config$web6 === void 0 ? void 0 : _config$web6.pkgManagers) ?? ['yarn', 'pnpm', 'npm'];
|
|
55
42
|
const version = pkgJSON.version;
|
|
56
|
-
const flags = {
|
|
43
|
+
const flags = {
|
|
44
|
+
...config.flags
|
|
57
45
|
};
|
|
58
46
|
const primaryColor = (0, _webUtils.validatePrimaryColor)(config === null || config === void 0 ? void 0 : (_config$web7 = config.web) === null || _config$web7 === void 0 ? void 0 : _config$web7.primary_color) ?? '#4b5e40';
|
|
59
47
|
const {
|
|
@@ -93,10 +81,8 @@ function renderHTML(config, manifest, manifestFiles, req, res) {
|
|
|
93
81
|
language
|
|
94
82
|
};
|
|
95
83
|
let webPage;
|
|
96
|
-
|
|
97
84
|
try {
|
|
98
85
|
webPage = cache.get('template');
|
|
99
|
-
|
|
100
86
|
if (!webPage) {
|
|
101
87
|
webPage = (0, _template.default)({
|
|
102
88
|
manifest: manifestFiles ?? defaultManifestFiles,
|
|
@@ -105,7 +91,6 @@ function renderHTML(config, manifest, manifestFiles, req, res) {
|
|
|
105
91
|
metaScripts,
|
|
106
92
|
scriptsbodyBefore
|
|
107
93
|
}, manifest);
|
|
108
|
-
|
|
109
94
|
if (needHtmlCache) {
|
|
110
95
|
cache.set('template', webPage);
|
|
111
96
|
debug('set template cache');
|
|
@@ -116,7 +101,6 @@ function renderHTML(config, manifest, manifestFiles, req, res) {
|
|
|
116
101
|
} catch (error) {
|
|
117
102
|
throw new Error(`theme could not be load, stack ${error.stack}`);
|
|
118
103
|
}
|
|
119
|
-
|
|
120
104
|
res.setHeader('Content-Type', _core.HEADERS.TEXT_HTML);
|
|
121
105
|
res.send(webPage);
|
|
122
106
|
debug('web rendered');
|
package/build/renderHTML.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderHTML.js","names":["pkgJSON","require","DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","renderHTML","config","manifest","manifestFiles","req","res","url_prefix","base","getPublicUrl","basename","URL","pathname","language","i18n","web","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","logoURI","logo","pkgManagers","version","flags","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../src/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { TemplateUIOptions } from '@verdaccio/types';\nimport { getPublicUrl } from '@verdaccio/url';\n\nimport renderTemplate from './template';\nimport { hasLogin, validatePrimaryColor } from './utils/web-utils';\n\nconst pkgJSON = require('../package.json');\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n};\n\nexport default function renderHTML(config, manifest, manifestFiles, req, res) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, req);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config.web.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logoURI = config?.web?.logo ?? '';\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = pkgJSON.version;\n const flags = {\n ...config.flags,\n };\n const primaryColor = validatePrimaryColor(config?.web?.primary_color) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logoURI,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderHTML.js","names":["pkgJSON","require","DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","renderHTML","config","manifest","manifestFiles","req","res","url_prefix","base","getPublicUrl","basename","URL","pathname","language","i18n","web","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","logoURI","logo","pkgManagers","version","flags","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../src/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { TemplateUIOptions } from '@verdaccio/types';\nimport { getPublicUrl } from '@verdaccio/url';\n\nimport renderTemplate from './template';\nimport { hasLogin, validatePrimaryColor } from './utils/web-utils';\n\nconst pkgJSON = require('../package.json');\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n};\n\nexport default function renderHTML(config, manifest, manifestFiles, req, res) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, req);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config.web.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logoURI = config?.web?.logo ?? '';\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = pkgJSON.version;\n const flags = {\n ...config.flags,\n };\n const primaryColor = validatePrimaryColor(config?.web?.primary_color) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logoURI,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAAmE;AAEnE,MAAMA,OAAO,GAAGC,OAAO,CAAC,iBAAiB,CAAC;AAC1C,MAAMC,gBAAgB,GAAG,OAAO;AAChC,MAAMC,KAAK,GAAG,IAAIC,iBAAG,CAAC;EAAEC,GAAG,EAAE,GAAG;EAAEC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG;AAAG,CAAC,CAAC;AAExD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,oBAAoB,GAAG;EAC3BC,EAAE,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC;EAC3CC,GAAG,EAAE;AACP,CAAC;AAEc,SAASC,UAAU,CAACC,MAAM,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAE;EAAA;EAC5E,MAAM;IAAEC;E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AsB,CAAC;IAC/B;EACF,CAAC,CAAC,OAAOuD,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAE,kCAAiCD,KAAK,CAACE,KAAM,EAAC,CAAC;EAClE;EACA/C,GAAG,CAACgD,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChDlD,GAAG,CAACmD,IAAI,CAACV,OAAO,CAAC;EACjBnD,KAAK,CAAC,cAAc,CAAC;AACvB"}
|
package/build/template.d.ts
CHANGED
package/build/template.js
CHANGED
|
@@ -4,18 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = renderTemplate;
|
|
7
|
-
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
var _manifest = require("./utils/manifest");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
const debug = (0, _debug.default)('verdaccio:web:render:template');
|
|
15
|
-
|
|
16
11
|
function renderTemplate(template, manifest) {
|
|
17
12
|
var _template$options;
|
|
18
|
-
|
|
19
13
|
debug('template %o', template);
|
|
20
14
|
debug('manifest %o', manifest);
|
|
21
15
|
return `
|
package/build/template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","names":["debug","buildDebug","renderTemplate","template","manifest","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","getManifestValue","js","map","item","scriptsBodyAfter"],"sources":["../src/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './utils/manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\"> \n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title> \n <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /> \n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head> \n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join('')}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"template.js","names":["debug","buildDebug","renderTemplate","template","manifest","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","getManifestValue","js","map","item","scriptsBodyAfter"],"sources":["../src/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './utils/manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\"> \n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title> \n <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /> \n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head> \n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join('')}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;AAAA;AAIA;AAA8D;AAE9D,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AAe1C,SAASC,cAAc,CAACC,QAAkB,EAAEC,QAAyB,EAAE;EAAA;EACpFJ,KAAK,CAAC,aAAa,EAAEG,QAAQ,CAAC;EAC9BH,KAAK,CAAC,aAAa,EAAEI,QAAQ,CAAC;EAE9B,OAAQ;AACV;AACA;AACA;AACA;AACA,sBAAsBD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,OAAO,CAACC,IAAK;AAC7C,iBAAiB,CAAAH,QAAQ,aAARA,QAAQ,4CAARA,QAAQ,CAAEE,OAAO,sDAAjB,kBAAmBE,KAAK,KAAI,EAAG;AAChD,iCAAiCJ,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,OAAO,CAACC,IAAK;AACxD;AACA;AACA,qDAAqDE,IAAI,CAACC,SAAS,CAACN,QAAQ,CAACE,OAAO,CAAE;AACtF;AACA,UAAUF,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEO,WAAW,GAAGP,QAAQ,CAACO,WAAW,CAACC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAG;AACrE;AACA;AACA,QAAQR,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAES,iBAAiB,GAAGT,QAAQ,CAACS,iBAAiB,CAACD,IAAI,CAAC,EAAE,CAAC,GAAG,EAAG;AAC/E;AACA,UAAU,IAAAE,0BAAgB,EAACV,QAAQ,CAACC,QAAQ,CAACU,EAAE,EAAEV,QAAQ,EAAED,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,OAAO,CAACC,IAAI,CAAC,CACvES,GAAG,CAAEC,IAAI,IAAM,8BAA6BA,IAAK,aAAY,CAAC,CAC9DL,IAAI,CAAC,EAAE,CAAE;AACpB,UAAUR,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEc,gBAAgB,GAAGd,QAAQ,CAACc,gBAAgB,CAACN,IAAI,CAAC,EAAE,CAAC,GAAG,EAAG;AAC/E;AACA;AACA,GAAG;AACH"}
|
package/build/utils/manifest.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getManifestValue = getManifestValue;
|
|
7
|
-
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
const debug = (0, _debug.default)('verdaccio:web:render:manifest');
|
|
13
|
-
|
|
14
10
|
function getManifestValue(manifestItems, manifest, basePath = '') {
|
|
15
11
|
return manifestItems === null || manifestItems === void 0 ? void 0 : manifestItems.map(item => {
|
|
16
12
|
debug('resolve item %o', item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":["debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../src/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest.js","names":["debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../src/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;AAAA;AAA+B;AAS/B,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AAElD,SAASC,gBAAgB,CAC9BC,aAAuB,EACvBC,QAAQ,EACRC,QAAgB,GAAG,EAAE,EACX;EACV,OAAOF,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEG,GAAG,CAAEC,IAAI,IAAK;IAClCP,KAAK,CAAC,iBAAiB,EAAEO,IAAI,CAAC;IAC9B,MAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAI,CAAE,EAAC;IACnDP,KAAK,CAAC,kBAAkB,EAAEQ,YAAY,CAAC;IACvC,OAAOA,YAAY;EACrB,CAAC,CAAC;AACJ"}
|