@verdaccio/middleware 9.0.0-next-9.2 → 9.0.0-next-9.3
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/build/index.d.ts +3 -0
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/middlewares/dotfiles.d.ts +12 -0
- package/build/middlewares/dotfiles.js +31 -0
- package/build/middlewares/dotfiles.js.map +1 -0
- package/build/middlewares/log.d.ts +4 -1
- package/build/middlewares/log.js +53 -19
- package/build/middlewares/log.js.map +1 -1
- package/build/middlewares/web/render-web.js +12 -6
- package/build/middlewares/web/render-web.js.map +1 -1
- package/build/middlewares/web/utils/renderHTML.js +1 -1
- package/build/middlewares/web/utils/renderHTML.js.map +1 -1
- package/package.json +6 -6
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { dotfiles } from './middlewares/dotfiles';
|
|
2
|
+
export type { DotfilesPolicy } from './middlewares/dotfiles';
|
|
1
3
|
export { match } from './middlewares/match';
|
|
2
4
|
export { validateName, validatePackage } from './middlewares/validation';
|
|
3
5
|
export { media } from './middlewares/media';
|
|
@@ -13,6 +15,7 @@ export { webMiddleware, renderWebMiddleware, setSecurityWebHeaders } from './mid
|
|
|
13
15
|
export { errorReportingMiddleware, handleError } from './middlewares/error';
|
|
14
16
|
export { getRequestOptions } from './middlewares/request-options';
|
|
15
17
|
export { log, LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, } from './middlewares/log';
|
|
18
|
+
export type { LogOptions } from './middlewares/log';
|
|
16
19
|
export * from './types';
|
|
17
20
|
export * from './middlewares/api_urls';
|
|
18
21
|
export * from './middlewares/web/web-urls';
|
package/build/index.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
+
dotfiles: true,
|
|
7
8
|
match: true,
|
|
8
9
|
validateName: true,
|
|
9
10
|
validatePackage: true,
|
|
@@ -57,6 +58,12 @@ Object.defineProperty(exports, "antiLoop", {
|
|
|
57
58
|
return _antiLoop.antiLoop;
|
|
58
59
|
}
|
|
59
60
|
});
|
|
61
|
+
Object.defineProperty(exports, "dotfiles", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return _dotfiles.dotfiles;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
60
67
|
Object.defineProperty(exports, "encodeScopePackage", {
|
|
61
68
|
enumerable: true,
|
|
62
69
|
get: function () {
|
|
@@ -159,6 +166,7 @@ Object.defineProperty(exports, "webMiddleware", {
|
|
|
159
166
|
return _web.webMiddleware;
|
|
160
167
|
}
|
|
161
168
|
});
|
|
169
|
+
var _dotfiles = require("./middlewares/dotfiles");
|
|
162
170
|
var _match = require("./middlewares/match");
|
|
163
171
|
var _validation = require("./middlewares/validation");
|
|
164
172
|
var _media = require("./middlewares/media");
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_dotfiles","require","_match","_validation","_media","_makeUrlRelative","_encodePkg","_json","_antiLoop","_final","_allow","_rateLimit","_userAgent","_web","_error","_requestOptions","_log","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_api_urls","_webUrls"],"sources":["../src/index.ts"],"sourcesContent":["export { dotfiles } from './middlewares/dotfiles';\nexport type { DotfilesPolicy } from './middlewares/dotfiles';\nexport { match } from './middlewares/match';\nexport { validateName, validatePackage } from './middlewares/validation';\nexport { media } from './middlewares/media';\nexport { makeURLrelative } from './middlewares/make-url-relative';\nexport { encodeScopePackage } from './middlewares/encode-pkg';\nexport { expectJson } from './middlewares/json';\nexport { antiLoop } from './middlewares/antiLoop';\nexport { final } from './middlewares/final';\nexport { allow } from './middlewares/allow';\nexport { rateLimit } from './middlewares/rate-limit';\nexport { userAgent } from './middlewares/user-agent';\nexport { webMiddleware, renderWebMiddleware, setSecurityWebHeaders } from './middlewares/web';\nexport { errorReportingMiddleware, handleError } from './middlewares/error';\nexport { getRequestOptions } from './middlewares/request-options';\nexport {\n log,\n LOG_STATUS_MESSAGE,\n LOG_VERDACCIO_BYTES,\n LOG_VERDACCIO_ERROR,\n} from './middlewares/log';\nexport type { LogOptions } from './middlewares/log';\nexport * from './types';\nexport * from './middlewares/api_urls';\nexport * from './middlewares/web/web-urls';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,IAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,eAAA,GAAAd,OAAA;AACA,IAAAe,IAAA,GAAAf,OAAA;AAOA,IAAAgB,MAAA,GAAAhB,OAAA;AAAAiB,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,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Ver, $RequestExtend, $ResponseExtend } from '../types';
|
|
2
|
+
export type DotfilesPolicy = 'allow' | 'deny' | 'ignore';
|
|
3
|
+
/**
|
|
4
|
+
* Middleware that controls how requests with dotfile path segments
|
|
5
|
+
* (e.g. /.env, /.well-known/, /.git/) are handled.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the semantics of serve-static's `dotfiles` option:
|
|
8
|
+
* - 'deny': respond with 403
|
|
9
|
+
* - 'ignore': respond with 404 (default)
|
|
10
|
+
* - 'allow': pass through to next middleware
|
|
11
|
+
*/
|
|
12
|
+
export declare function dotfiles(policy?: DotfilesPolicy): (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotfiles = dotfiles;
|
|
7
|
+
var _core = require("@verdaccio/core");
|
|
8
|
+
/**
|
|
9
|
+
* Middleware that controls how requests with dotfile path segments
|
|
10
|
+
* (e.g. /.env, /.well-known/, /.git/) are handled.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors the semantics of serve-static's `dotfiles` option:
|
|
13
|
+
* - 'deny': respond with 403
|
|
14
|
+
* - 'ignore': respond with 404 (default)
|
|
15
|
+
* - 'allow': pass through to next middleware
|
|
16
|
+
*/
|
|
17
|
+
function dotfiles(policy = 'ignore') {
|
|
18
|
+
return function dotfilesMiddleware(req, res, next) {
|
|
19
|
+
if (policy !== 'allow' && req.path.split('/').some(segment => segment.startsWith('.') && segment.length > 1)) {
|
|
20
|
+
if (policy === 'deny') {
|
|
21
|
+
res.statusCode = _core.HTTP_STATUS.FORBIDDEN;
|
|
22
|
+
res.end();
|
|
23
|
+
} else {
|
|
24
|
+
next(_core.errorUtils.getNotFound('resource not found'));
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
next();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=dotfiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dotfiles.js","names":["_core","require","dotfiles","policy","dotfilesMiddleware","req","res","next","path","split","some","segment","startsWith","length","statusCode","HTTP_STATUS","FORBIDDEN","end","errorUtils","getNotFound"],"sources":["../../src/middlewares/dotfiles.ts"],"sourcesContent":["import { HTTP_STATUS, errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport type DotfilesPolicy = 'allow' | 'deny' | 'ignore';\n\n/**\n * Middleware that controls how requests with dotfile path segments\n * (e.g. /.env, /.well-known/, /.git/) are handled.\n *\n * Mirrors the semantics of serve-static's `dotfiles` option:\n * - 'deny': respond with 403\n * - 'ignore': respond with 404 (default)\n * - 'allow': pass through to next middleware\n */\nexport function dotfiles(policy: DotfilesPolicy = 'ignore') {\n return function dotfilesMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n if (\n policy !== 'allow' &&\n req.path.split('/').some((segment) => segment.startsWith('.') && segment.length > 1)\n ) {\n if (policy === 'deny') {\n res.statusCode = HTTP_STATUS.FORBIDDEN;\n res.end();\n } else {\n next(errorUtils.getNotFound('resource not found'));\n }\n return;\n }\n next();\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAACC,MAAsB,GAAG,QAAQ,EAAE;EAC1D,OAAO,SAASC,kBAAkBA,CAChCC,GAAmB,EACnBC,GAAoB,EACpBC,IAAsB,EAChB;IACN,IACEJ,MAAM,KAAK,OAAO,IAClBE,GAAG,CAACG,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACC,UAAU,CAAC,GAAG,CAAC,IAAID,OAAO,CAACE,MAAM,GAAG,CAAC,CAAC,EACpF;MACA,IAAIV,MAAM,KAAK,MAAM,EAAE;QACrBG,GAAG,CAACQ,UAAU,GAAGC,iBAAW,CAACC,SAAS;QACtCV,GAAG,CAACW,GAAG,CAAC,CAAC;MACX,CAAC,MAAM;QACLV,IAAI,CAACW,gBAAU,CAACC,WAAW,CAAC,oBAAoB,CAAC,CAAC;MACpD;MACA;IACF;IACAZ,IAAI,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -2,4 +2,7 @@ import type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types
|
|
|
2
2
|
export declare const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
|
|
3
3
|
export declare const LOG_VERDACCIO_ERROR = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}', error: @{!error}";
|
|
4
4
|
export declare const LOG_VERDACCIO_BYTES = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}', bytes: @{bytes.in}/@{bytes.out}";
|
|
5
|
-
export
|
|
5
|
+
export type LogOptions = {
|
|
6
|
+
hideStaticLogs?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const log: (logger: any, options?: LogOptions) => (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => void;
|
package/build/middlewares/log.js
CHANGED
|
@@ -4,14 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.log = exports.LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_BYTES = exports.LOG_STATUS_MESSAGE = void 0;
|
|
7
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
7
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
9
|
var _core = require("@verdaccio/core");
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const debug = (0, _debug.default)('verdaccio:middleware:log');
|
|
12
|
+
function isStaticRequest(url) {
|
|
13
|
+
return url.startsWith('/-/static/');
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
// FIXME: deprecated, moved to @verdaccio/dev-commons
|
|
11
17
|
const LOG_STATUS_MESSAGE = exports.LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
|
|
12
18
|
const LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
|
|
13
19
|
const LOG_VERDACCIO_BYTES = exports.LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
|
|
14
|
-
const log = logger => {
|
|
20
|
+
const log = (logger, options = {}) => {
|
|
21
|
+
const {
|
|
22
|
+
hideStaticLogs = true
|
|
23
|
+
} = options;
|
|
15
24
|
return function log(req, res, next) {
|
|
16
25
|
// logger
|
|
17
26
|
req.log = logger.child({
|
|
@@ -26,10 +35,18 @@ const log = logger => {
|
|
|
26
35
|
req.headers.cookie = '<Classified>';
|
|
27
36
|
}
|
|
28
37
|
req.url = req.originalUrl;
|
|
29
|
-
req.
|
|
30
|
-
|
|
31
|
-
ip
|
|
32
|
-
|
|
38
|
+
const _skipLog = hideStaticLogs && isStaticRequest(req.url);
|
|
39
|
+
if (_skipLog) {
|
|
40
|
+
debug("@{ip} requested '@{req.method} @{req.url}'", {
|
|
41
|
+
ip: req.ip,
|
|
42
|
+
req
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
req.log.info({
|
|
46
|
+
req: req,
|
|
47
|
+
ip: req.ip
|
|
48
|
+
}, "@{ip} requested '@{req.method} @{req.url}'");
|
|
49
|
+
}
|
|
33
50
|
req.originalUrl = req.url;
|
|
34
51
|
if (_lodash.default.isNil(_auth) === false) {
|
|
35
52
|
req.headers.authorization = _auth;
|
|
@@ -60,20 +77,37 @@ const log = logger => {
|
|
|
60
77
|
message = LOG_VERDACCIO_BYTES;
|
|
61
78
|
}
|
|
62
79
|
req.url = req.originalUrl;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
if (_skipLog) {
|
|
81
|
+
debug(message, {
|
|
82
|
+
request: {
|
|
83
|
+
method: req.method,
|
|
84
|
+
url: req.url
|
|
85
|
+
},
|
|
86
|
+
user: req.remote_user?.name || null,
|
|
87
|
+
remoteIP,
|
|
88
|
+
status: res.statusCode,
|
|
89
|
+
error: res.locals._verdaccio_error,
|
|
90
|
+
bytes: {
|
|
91
|
+
in: bytesin,
|
|
92
|
+
out: bytesout
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
req.log.http({
|
|
97
|
+
request: {
|
|
98
|
+
method: req.method,
|
|
99
|
+
url: req.url
|
|
100
|
+
},
|
|
101
|
+
user: req.remote_user?.name || null,
|
|
102
|
+
remoteIP,
|
|
103
|
+
status: res.statusCode,
|
|
104
|
+
error: res.locals._verdaccio_error,
|
|
105
|
+
bytes: {
|
|
106
|
+
in: bytesin,
|
|
107
|
+
out: bytesout
|
|
108
|
+
}
|
|
109
|
+
}, message);
|
|
110
|
+
}
|
|
77
111
|
req.originalUrl = req.url;
|
|
78
112
|
};
|
|
79
113
|
req.on('close', function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","names":["
|
|
1
|
+
{"version":3,"file":"log.js","names":["_debug","_interopRequireDefault","require","_lodash","_core","e","__esModule","default","debug","buildDebug","isStaticRequest","url","startsWith","LOG_STATUS_MESSAGE","exports","LOG_VERDACCIO_ERROR","LOG_VERDACCIO_BYTES","log","logger","options","hideStaticLogs","req","res","next","child","sub","_auth","headers","authorization","_","isNil","_cookie","get","cookie","originalUrl","_skipLog","ip","info","bytesin","on","chunk","length","bytesout","_write","write","args","apply","forwardedFor","HEADERS","FORWARDED_FOR","remoteAddress","socket","remoteIP","message","locals","_verdaccio_error","request","method","user","remote_user","name","status","statusCode","error","bytes","in","out","http","_end","end"],"sources":["../../src/middlewares/log.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { HEADERS } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:log');\n\nfunction isStaticRequest(url: string): boolean {\n return url.startsWith('/-/static/');\n}\n\n// FIXME: deprecated, moved to @verdaccio/dev-commons\nexport const LOG_STATUS_MESSAGE =\n \"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'\";\nexport const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;\nexport const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;\n\nexport type LogOptions = {\n // When true, static file requests (/-/static/*) are hidden from pino logs\n // and only visible via DEBUG=verdaccio:middleware:log. Defaults to true.\n hideStaticLogs?: boolean;\n};\n\nexport const log = (logger, options: LogOptions = {}) => {\n const { hideStaticLogs = true } = options;\n\n return function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n // logger\n req.log = logger.child({ sub: 'in' });\n\n const _auth = req.headers.authorization;\n if (_.isNil(_auth) === false) {\n req.headers.authorization = '<Classified>';\n }\n\n const _cookie = req.get('cookie');\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = '<Classified>';\n }\n\n req.url = req.originalUrl;\n const _skipLog = hideStaticLogs && isStaticRequest(req.url);\n if (_skipLog) {\n debug(\"@{ip} requested '@{req.method} @{req.url}'\", { ip: req.ip, req });\n } else {\n req.log.info({ req: req, ip: req.ip }, \"@{ip} requested '@{req.method} @{req.url}'\");\n }\n req.originalUrl = req.url;\n\n if (_.isNil(_auth) === false) {\n req.headers.authorization = _auth;\n }\n\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = _cookie;\n }\n\n let bytesin = 0;\n req.on('data', function (chunk): void {\n bytesin += chunk.length;\n });\n\n let bytesout = 0;\n const _write = res.write;\n // @ts-ignore\n res.write = function (...args): boolean {\n bytesout += args[0]?.length || 0;\n // @ts-ignore\n return _write.apply(res, args);\n };\n\n const log = function (): void {\n const forwardedFor = req.get(HEADERS.FORWARDED_FOR);\n const remoteAddress = req.socket.remoteAddress;\n const remoteIP = forwardedFor ? `${forwardedFor} via ${remoteAddress}` : remoteAddress;\n let message;\n if (res.locals._verdaccio_error) {\n message = LOG_VERDACCIO_ERROR;\n } else {\n message = LOG_VERDACCIO_BYTES;\n }\n\n req.url = req.originalUrl;\n if (_skipLog) {\n debug(message, {\n request: { method: req.method, url: req.url },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: { in: bytesin, out: bytesout },\n });\n } else {\n req.log.http(\n {\n request: {\n method: req.method,\n url: req.url,\n },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: {\n in: bytesin,\n out: bytesout,\n },\n },\n message\n );\n }\n req.originalUrl = req.url;\n };\n\n req.on('close', function (): void {\n log();\n });\n\n const _end = res.end;\n // @ts-ignore\n res.end = function (...args): void {\n if (args[0]) {\n bytesout += args[0].length;\n }\n // @ts-ignore\n _end.apply(res, args);\n log();\n };\n next();\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA0C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI1C,MAAMG,KAAK,GAAG,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B,GAAG,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,MAAMmD,IAAI,GAAG9C,GAAG,CAAC+C,GAAG;IACpB;IACA/C,GAAG,CAAC+C,GAAG,GAAG,UAAU,GAAGxB,IAAI,EAAQ;MACjC,IAAIA,IAAI,CAAC,CAAC,CAAC,EAAE;QACXH,QAAQ,IAAIG,IAAI,CAAC,CAAC,CAAC,CAACJ,MAAM;MAC5B;MACA;MACA2B,IAAI,CAACtB,KAAK,CAACxB,GAAG,EAAEuB,IAAI,CAAC;MACrB5B,GAAG,CAAC,CAAC;IACP,CAAC;IACDM,IAAI,CAAC,CAAC;EACR,CAAC;AACH,CAAC;AAACT,OAAA,CAAAG,GAAA,GAAAA,GAAA","ignoreList":[]}
|
|
@@ -42,18 +42,22 @@ function renderWebMiddleware(config, tokenMiddleware, pluginOptions) {
|
|
|
42
42
|
|
|
43
43
|
// any match within the static is routed to the file system
|
|
44
44
|
router.get(_webUrls.WebUrlsNamespace.static, function (req, res, next) {
|
|
45
|
-
const filename = req.params.all;
|
|
46
|
-
let file = `${staticPath}/${filename}`;
|
|
45
|
+
const filename = Array.isArray(req.params.all) ? req.params.all.join('/') : req.params.all;
|
|
47
46
|
if (filename === 'favicon.ico' && config?.web?.favicon) {
|
|
48
|
-
file = config?.web?.favicon;
|
|
47
|
+
const file = config?.web?.favicon;
|
|
49
48
|
if ((0, _url.isURLhasValidProtocol)(file)) {
|
|
50
49
|
debug('redirect to favicon %s', file);
|
|
51
50
|
req.url = file;
|
|
52
51
|
return next();
|
|
53
52
|
}
|
|
53
|
+
debug('render custom favicon %o', file);
|
|
54
|
+
res.sendFile(file, sendFileCallback(next));
|
|
55
|
+
return;
|
|
54
56
|
}
|
|
55
|
-
debug('render static file %o',
|
|
56
|
-
res.sendFile(
|
|
57
|
+
debug('render static file %o', filename);
|
|
58
|
+
res.sendFile(filename, {
|
|
59
|
+
root: staticPath
|
|
60
|
+
}, sendFileCallback(next));
|
|
57
61
|
});
|
|
58
62
|
function renderLogo(logo) {
|
|
59
63
|
// check the origin of the logo
|
|
@@ -70,7 +74,9 @@ function renderWebMiddleware(config, tokenMiddleware, pluginOptions) {
|
|
|
70
74
|
router.get(logo, function (_req, res, next) {
|
|
71
75
|
// @ts-ignore
|
|
72
76
|
debug('serve custom logo web:%s - local:%s', logo, absoluteLocalFile);
|
|
73
|
-
res.sendFile(absoluteLocalFile,
|
|
77
|
+
res.sendFile(_nodePath.default.basename(absoluteLocalFile), {
|
|
78
|
+
root: _nodePath.default.dirname(absoluteLocalFile)
|
|
79
|
+
}, sendFileCallback(next));
|
|
74
80
|
});
|
|
75
81
|
debug('enabled custom logo %s', logo);
|
|
76
82
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-web.js","names":["_debug","_interopRequireDefault","require","_express","_nodeFs","_nodePath","_core","_url","_security","_renderHTML","_webUrls","e","__esModule","default","debug","buildDebug","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","config","tokenMiddleware","pluginOptions","staticPath","manifest","manifestFiles","router","express","Router","use","setSecurityWebHeaders","get","WebUrlsNamespace","static","req","res","filename","params","all","
|
|
1
|
+
{"version":3,"file":"render-web.js","names":["_debug","_interopRequireDefault","require","_express","_nodeFs","_nodePath","_core","_url","_security","_renderHTML","_webUrls","e","__esModule","default","debug","buildDebug","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","config","tokenMiddleware","pluginOptions","staticPath","manifest","manifestFiles","router","express","Router","use","setSecurityWebHeaders","get","WebUrlsNamespace","static","req","res","filename","Array","isArray","params","all","join","web","favicon","file","isURLhasValidProtocol","url","sendFile","root","renderLogo","logo","absoluteLocalFile","path","posix","resolve","fs","existsSync","accessSync","constants","R_OK","basename","_req","dirname","undefined","logoDark","renderHTML"],"sources":["../../../src/middlewares/web/render-web.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport express from 'express';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\n\nimport { setSecurityWebHeaders } from './security';\nimport renderHTML from './utils/renderHTML';\nimport { WebUrlsNamespace } from './web-urls';\n\nconst debug = buildDebug('verdaccio:web:render');\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 function renderWebMiddleware(config, tokenMiddleware, pluginOptions) {\n const { staticPath, manifest, manifestFiles } = pluginOptions;\n debug('static path %o', staticPath);\n\n /* eslint new-cap:off */\n const router = express.Router();\n if (typeof tokenMiddleware === 'function') {\n router.use(tokenMiddleware);\n }\n\n router.use(setSecurityWebHeaders);\n\n // any match within the static is routed to the file system\n router.get(\n WebUrlsNamespace.static,\n function (req: express.Request<{ all: string | string[] }>, res, next) {\n const filename = Array.isArray(req.params.all) ? req.params.all.join('/') : req.params.all;\n if (filename === 'favicon.ico' && config?.web?.favicon) {\n const file = config?.web?.favicon;\n if (isURLhasValidProtocol(file)) {\n debug('redirect to favicon %s', file);\n req.url = file;\n return next();\n }\n debug('render custom favicon %o', file);\n res.sendFile(file, sendFileCallback(next));\n return;\n }\n debug('render static file %o', filename);\n res.sendFile(filename, { root: staticPath }, sendFileCallback(next));\n }\n );\n\n function renderLogo(logo: string | undefined): string | undefined {\n // check the origin of the logo\n if (logo && !isURLhasValidProtocol(logo)) {\n // URI related to a local file\n const absoluteLocalFile = path.posix.resolve(logo);\n debug('serve local logo %s', absoluteLocalFile);\n try {\n // TODO: replace existsSync by async alternative\n if (\n fs.existsSync(absoluteLocalFile) &&\n typeof fs.accessSync(absoluteLocalFile, fs.constants.R_OK) === 'undefined'\n ) {\n // Note: `path.join` will break on Windows, because it transforms `/` to `\\`\n // Use POSIX version `path.posix.join` instead.\n logo = `/-/static/${path.basename(logo)}`;\n router.get(logo, function (_req, res, next) {\n // @ts-ignore\n debug('serve custom logo web:%s - local:%s', logo, absoluteLocalFile);\n res.sendFile(\n path.basename(absoluteLocalFile),\n { root: path.dirname(absoluteLocalFile) },\n sendFileCallback(next)\n );\n });\n debug('enabled custom logo %s', logo);\n } else {\n logo = undefined;\n debug(`web logo is wrong, path ${absoluteLocalFile} does not exist or is not readable`);\n }\n } catch {\n logo = undefined;\n debug(`web logo is wrong, path ${absoluteLocalFile} does not exist or is not readable`);\n }\n }\n return logo;\n }\n\n const logo = renderLogo(config?.web?.logo);\n if (config?.web?.logo) {\n config.web.logo = logo;\n }\n const logoDark = renderLogo(config?.web?.logoDark);\n if (config?.web?.logoDark) {\n config.web.logoDark = logoDark;\n }\n\n // Handle all web routes including security routes\n router.get(WebUrlsNamespace.web, function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render html section');\n });\n\n router.get(WebUrlsNamespace.root, function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render root');\n });\n\n return router;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAEA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAA8C,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,gBAAgB,GAAIC,IAAI,IAAMC,GAAG,IAAK;EAC1C,IAAI,CAACA,GAAG,EAAE;IACR;EACF;EACA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pD,KAAK,CAAC,2BAA2BwC,iBAAiB,oCAAoC,CAAC;QACzF;MACF,CAAC,CAAC,MAAM;QACND,IAAI,GAAGa,SAAS;QAChBpD,KAAK,CAAC,2BAA2BwC,iBAAiB,oCAAoC,CAAC;MACzF;IACF;IACA,OAAOD,IAAI;EACb;EAEA,MAAMA,IAAI,GAAGD,UAAU,CAAC7B,MAAM,EAAEsB,GAAG,EAAEQ,IAAI,CAAC;EAC1C,IAAI9B,MAAM,EAAEsB,GAAG,EAAEQ,IAAI,EAAE;IACrB9B,MAAM,CAACsB,GAAG,CAACQ,IAAI,GAAGA,IAAI;EACxB;EACA,MAAMc,QAAQ,GAAGf,UAAU,CAAC7B,MAAM,EAAEsB,GAAG,EAAEsB,QAAQ,CAAC;EAClD,IAAI5C,MAAM,EAAEsB,GAAG,EAAEsB,QAAQ,EAAE;IACzB5C,MAAM,CAACsB,GAAG,CAACsB,QAAQ,GAAGA,QAAQ;EAChC;;EAEA;EACAtC,MAAM,CAACK,GAAG,CAACC,yBAAgB,CAACU,GAAG,EAAE,UAAUR,GAAG,EAAEC,GAAG,EAAE;IACnD,IAAA8B,mBAAU,EAAC7C,MAAM,EAAEI,QAAQ,EAAEC,aAAa,EAAES,GAAG,EAAEC,GAAG,CAAC;IACrDxB,KAAK,CAAC,qBAAqB,CAAC;EAC9B,CAAC,CAAC;EAEFe,MAAM,CAACK,GAAG,CAACC,yBAAgB,CAACgB,IAAI,EAAE,UAAUd,GAAG,EAAEC,GAAG,EAAE;IACpD,IAAA8B,mBAAU,EAAC7C,MAAM,EAAEI,QAAQ,EAAEC,aAAa,EAAES,GAAG,EAAEC,GAAG,CAAC;IACrDxB,KAAK,CAAC,aAAa,CAAC;EACtB,CAAC,CAAC;EAEF,OAAOe,MAAM;AACf","ignoreList":[]}
|
|
@@ -45,7 +45,7 @@ function renderHTML(config, manifest, manifestFiles, requestOptions, res) {
|
|
|
45
45
|
url_prefix
|
|
46
46
|
} = config;
|
|
47
47
|
const base = (0, _url.getPublicUrl)(config?.url_prefix, requestOptions);
|
|
48
|
-
const basename = new _nodeUrl.URL(base).pathname;
|
|
48
|
+
const basename = _nodeUrl.URL.canParse(base) ? new _nodeUrl.URL(base).pathname : base;
|
|
49
49
|
const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
|
|
50
50
|
const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;
|
|
51
51
|
// @ts-ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderHTML.js","names":["_debug","_interopRequireDefault","require","_lruCache","_nodePath","_nodeUrl","_config","_core","_url","_template","_webUtils","e","__esModule","default","DEFAULT_LANGUAGE","cache","LRUCache","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","css","resolveLogo","logo","url_prefix","requestOptions","isLocalFile","isURLhasValidProtocol","getPublicUrl","path","basename","renderHTML","config","manifest","manifestFiles","res","base","URL","pathname","language","i18n","web","hideDeprecatedVersions","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","favicon","logoDark","pkgManagers","version","locals","app_version","flags","experiments","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","showRaw","showUplinks","Object","assign","bodyBefore","scriptsBodyBefore","options","webPage","cacheKey","JSON","stringify","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Response } from 'express';\nimport { LRUCache } from 'lru-cache';\nimport path from 'node:path';\nimport { URL } from 'node:url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport type { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport type { RequestOptions } from '@verdaccio/url';\nimport { getPublicUrl, isURLhasValidProtocol } from '@verdaccio/url';\n\nimport type { Manifest } from './manifest';\nimport renderTemplate from './template';\nimport type { AssetManifest } from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\n// Cache for rendered HTML templates: max 500 entries, 1 hour TTL\nconst cache = new LRUCache({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles: Manifest = {\n js: ['vendors.js', 'main.js'],\n ico: 'favicon.ico',\n css: [],\n};\n\nexport function resolveLogo(\n logo: string | undefined,\n url_prefix: string | undefined,\n requestOptions: RequestOptions\n) {\n if (typeof logo !== 'string') {\n return '';\n }\n const isLocalFile = logo && !isURLhasValidProtocol(logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;\n } else if (isURLhasValidProtocol(logo)) {\n return logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(\n config: ConfigYaml,\n manifest: AssetManifest,\n manifestFiles: Manifest | null | undefined,\n requestOptions: RequestOptions,\n res: Response\n) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, requestOptions);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\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 favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);\n const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);\n const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore, // deprecated\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n // Fallback\n let scriptsBodyBefore = config?.web?.scriptsBodyBefore;\n if (scriptsbodyBefore && !scriptsBodyBefore) {\n scriptsBodyBefore = scriptsbodyBefore;\n }\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n logoDark,\n favicon,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n const cacheKey = `template:${JSON.stringify(options)}`;\n\n try {\n webPage = cache.get(cacheKey);\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsBodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set(cacheKey, 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL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ACFC,OAAO,GAAGpE,KAAK,CAACwE,GAAG,CAACH,QAAQ,CAAC;IAC7B,IAAI,CAACD,OAAO,EAAE;MACZA,OAAO,GAAG,IAAAK,iBAAc,EACtB;QACEpD,QAAQ,EAAEC,aAAa,IAAIhB,oBAAoB;QAC/C6D,OAAO;QACPf,gBAAgB;QAChBC,WAAW;QACXa;MACF,CAAC,EACD7C,QACF,CAAC;MAED,IAAIU,aAAa,EAAE;QACjB/B,KAAK,CAAC0E,GAAG,CAACL,QAAQ,EAAED,OAAO,CAAC;QAC5BhE,KAAK,CAAC,oBAAoB,CAAC;MAC7B;IACF,CAAC,MAAM;MACLA,KAAK,CAAC,sBAAsB,CAAC;IAC/B;EACF,CAAC,CAAC,OAAOuE,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAC,kCAAkCD,KAAK,CAACE,KAAK,EAAE,CAAC;EAClE;EACAtD,GAAG,CAACuD,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChDzD,GAAG,CAAC0D,IAAI,CAACb,OAAO,CAAC;EACjBhE,KAAK,CAAC,cAAc,CAAC;AACvB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderHTML.js","names":["_debug","_interopRequireDefault","require","_lruCache","_nodePath","_nodeUrl","_config","_core","_url","_template","_webUtils","e","__esModule","default","DEFAULT_LANGUAGE","cache","LRUCache","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","css","resolveLogo","logo","url_prefix","requestOptions","isLocalFile","isURLhasValidProtocol","getPublicUrl","path","basename","renderHTML","config","manifest","manifestFiles","res","base","URL","canParse","pathname","language","i18n","web","hideDeprecatedVersions","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","favicon","logoDark","pkgManagers","version","locals","app_version","flags","experiments","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","showRaw","showUplinks","Object","assign","bodyBefore","scriptsBodyBefore","options","webPage","cacheKey","JSON","stringify","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Response } from 'express';\nimport { LRUCache } from 'lru-cache';\nimport path from 'node:path';\nimport { URL } from 'node:url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport type { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport type { RequestOptions } from '@verdaccio/url';\nimport { getPublicUrl, isURLhasValidProtocol } from '@verdaccio/url';\n\nimport type { Manifest } from './manifest';\nimport renderTemplate from './template';\nimport type { AssetManifest } from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\n// Cache for rendered HTML templates: max 500 entries, 1 hour TTL\nconst cache = new LRUCache({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles: Manifest = {\n js: ['vendors.js', 'main.js'],\n ico: 'favicon.ico',\n css: [],\n};\n\nexport function resolveLogo(\n logo: string | undefined,\n url_prefix: string | undefined,\n requestOptions: RequestOptions\n) {\n if (typeof logo !== 'string') {\n return '';\n }\n const isLocalFile = logo && !isURLhasValidProtocol(logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(url_prefix, requestOptions)}-/static/${path.basename(logo)}`;\n } else if (isURLhasValidProtocol(logo)) {\n return logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(\n config: ConfigYaml,\n manifest: AssetManifest,\n manifestFiles: Manifest | null | undefined,\n requestOptions: RequestOptions,\n res: Response\n) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, requestOptions);\n const basename = URL.canParse(base) ? new URL(base).pathname : base;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\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 favicon = resolveLogo(config?.web?.favicon, config?.url_prefix, requestOptions);\n const logo = resolveLogo(config?.web?.logo, config?.url_prefix, requestOptions);\n const logoDark = resolveLogo(config?.web?.logoDark, config?.url_prefix, requestOptions);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore, // deprecated\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n // Fallback\n let scriptsBodyBefore = config?.web?.scriptsBodyBefore;\n if (scriptsbodyBefore && !scriptsBodyBefore) {\n scriptsBodyBefore = scriptsbodyBefore;\n }\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n showRaw,\n showUplinks,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n logoDark,\n favicon,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n const cacheKey = `template:${JSON.stringify(options)}`;\n\n try {\n webPage = cache.get(cacheKey);\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsBodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set(cacheKey, 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAGA,IAAAM,IAAA,GAAAN,OAAA;AAGA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,IAAAQ,SAAA,GAAAR,OAAA;AAA6D,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7D,MAAMG,gBAAgB,GAAG,OAAO;AAChC;AACA,MAAMC,KAAK,GAAG,IAAIC,kBAAQ,CAAC;EAAEC,GAAG,EAAE,GAAG;EAAEC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG;AAAG,CAAC,CAAC;AAE7D,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,oBAA8B,GAAG;EACrCC,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC;EAC7BC,GAAG,EAAE,aAAa;EAClBC,GAAG,EAAE;AACP,CAAC;AAEM,SAASC,WAAWA,CACzBC,IAAwB,EACxBC,UAA8B,EAC9BC,cAA8B,EAC9B;EACA,IAAI,OAAOF,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,EAAE;EACX;EACA,MAAMG,WAAW,GAAGH,IAAI,IAAI,CAAC,IA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oreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/middleware",
|
|
3
|
-
"version": "9.0.0-next-9.
|
|
3
|
+
"version": "9.0.0-next-9.3",
|
|
4
4
|
"description": "Verdaccio Express Middleware",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"node": ">=24"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@verdaccio/config": "9.0.0-next-9.
|
|
37
|
-
"@verdaccio/core": "9.0.0-next-9.
|
|
38
|
-
"@verdaccio/url": "14.0.0-next-9.
|
|
36
|
+
"@verdaccio/config": "9.0.0-next-9.3",
|
|
37
|
+
"@verdaccio/core": "9.0.0-next-9.3",
|
|
38
|
+
"@verdaccio/url": "14.0.0-next-9.3",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
40
|
"express": "5.2.1",
|
|
41
41
|
"express-rate-limit": "8.2.1",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"url": "https://opencollective.com/verdaccio"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@verdaccio/logger": "9.0.0-next-9.
|
|
51
|
-
"@verdaccio/types": "14.0.0-next-9.
|
|
50
|
+
"@verdaccio/logger": "9.0.0-next-9.3",
|
|
51
|
+
"@verdaccio/types": "14.0.0-next-9.1",
|
|
52
52
|
"http-errors": "2.0.1",
|
|
53
53
|
"supertest": "7.1.4",
|
|
54
54
|
"jsdom": "26.1.0",
|