@verdaccio/middleware 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 +14 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +24 -0
- package/build/index.js.map +1 -1
- package/build/middlewares/rate-limit.d.ts +2 -0
- package/build/middlewares/rate-limit.js +13 -0
- package/build/middlewares/rate-limit.js.map +1 -0
- package/build/middlewares/user-agent.d.ts +2 -0
- package/build/middlewares/user-agent.js +14 -0
- package/build/middlewares/user-agent.js.map +1 -0
- package/build/middlewares/validation.d.ts +2 -3
- package/build/middlewares/validation.js +2 -2
- package/build/middlewares/validation.js.map +1 -1
- package/build/middlewares/web/index.d.ts +1 -0
- package/build/middlewares/web/index.js +14 -0
- package/build/middlewares/web/index.js.map +1 -0
- package/build/middlewares/web/render-web.d.ts +1 -0
- package/build/middlewares/web/render-web.js +103 -0
- package/build/middlewares/web/render-web.js.map +1 -0
- package/build/middlewares/web/security.d.ts +1 -0
- package/build/middlewares/web/security.js +19 -0
- package/build/middlewares/web/security.js.map +1 -0
- package/build/middlewares/web/utils/manifest.d.ts +6 -0
- package/build/middlewares/web/utils/manifest.js +18 -0
- package/build/middlewares/web/utils/manifest.js.map +1 -0
- package/build/middlewares/web/utils/renderHTML.d.ts +7 -0
- package/build/middlewares/web/utils/renderHTML.js +133 -0
- package/build/middlewares/web/utils/renderHTML.js.map +1 -0
- package/build/middlewares/web/utils/template.d.ts +13 -0
- package/build/middlewares/web/utils/template.js +38 -0
- package/build/middlewares/web/utils/template.js.map +1 -0
- package/build/middlewares/web/utils/web-utils.d.ts +2 -0
- package/build/middlewares/web/utils/web-utils.js +24 -0
- package/build/middlewares/web/utils/web-utils.js.map +1 -0
- package/build/middlewares/web/web-api.d.ts +1 -0
- package/build/middlewares/web/web-api.js +32 -0
- package/build/middlewares/web/web-api.js.map +1 -0
- package/build/middlewares/web/web-middleware.d.ts +2 -0
- package/build/middlewares/web/web-middleware.js +25 -0
- package/build/middlewares/web/web-middleware.js.map +1 -0
- package/package.json +10 -5
- package/src/index.ts +3 -0
- package/src/middlewares/rate-limit.ts +8 -0
- package/src/middlewares/user-agent.ts +10 -0
- package/src/middlewares/validation.ts +2 -16
- package/src/middlewares/web/index.ts +1 -0
- package/src/middlewares/web/render-web.ts +99 -0
- package/src/middlewares/web/security.ts +13 -0
- package/src/middlewares/web/utils/manifest.ts +23 -0
- package/src/middlewares/web/utils/renderHTML.ts +134 -0
- package/src/middlewares/web/utils/template.ts +50 -0
- package/src/middlewares/web/utils/web-utils.ts +18 -0
- package/src/middlewares/web/web-api.ts +27 -0
- package/src/middlewares/web/web-middleware.ts +15 -0
- package/test/__snapshots__/template.test.ts.snap +151 -0
- package/test/_helper.ts +8 -0
- package/test/config/default-test.yaml +28 -0
- package/test/config/login-disabled.yaml +29 -0
- package/test/config/web.yaml +23 -0
- package/test/manifest.test.ts +11 -0
- package/test/partials/htmlParser.ts +1 -0
- package/test/partials/manifest/manifest.json +64 -0
- package/test/render.spec.ts +106 -0
- package/test/static/main.js +3 -0
- package/test/static/vendor.js +3 -0
- package/test/template.test.ts +74 -0
- package/test/utils.spec.ts +13 -0
- package/tsconfig.json +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @verdaccio/middleware
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.39
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 45c03819: refactor: render html middleware
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [45c03819]
|
|
12
|
+
- @verdaccio/config@6.0.0-6-next.60
|
|
13
|
+
- @verdaccio/core@6.0.0-6-next.60
|
|
14
|
+
- @verdaccio/url@11.0.0-6-next.26
|
|
15
|
+
- @verdaccio/utils@6.0.0-6-next.28
|
|
16
|
+
|
|
3
17
|
## 6.0.0-6-next.38
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/build/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export { expectJson } from './middlewares/json';
|
|
|
7
7
|
export { antiLoop } from './middlewares/antiLoop';
|
|
8
8
|
export { final } from './middlewares/final';
|
|
9
9
|
export { allow } from './middlewares/allow';
|
|
10
|
+
export { rateLimit } from './middlewares/rate-limit';
|
|
11
|
+
export { userAgent } from './middlewares/user-agent';
|
|
12
|
+
export { webMiddleware } from './middlewares/web';
|
|
10
13
|
export { errorReportingMiddleware, handleError } from './middlewares/error';
|
|
11
14
|
export { log, LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, } from './middlewares/log';
|
|
12
15
|
export * from './types';
|
package/build/index.js
CHANGED
|
@@ -14,6 +14,9 @@ var _exportNames = {
|
|
|
14
14
|
antiLoop: true,
|
|
15
15
|
final: true,
|
|
16
16
|
allow: true,
|
|
17
|
+
rateLimit: true,
|
|
18
|
+
userAgent: true,
|
|
19
|
+
webMiddleware: true,
|
|
17
20
|
errorReportingMiddleware: true,
|
|
18
21
|
handleError: true,
|
|
19
22
|
log: true,
|
|
@@ -99,12 +102,24 @@ Object.defineProperty(exports, "media", {
|
|
|
99
102
|
return _media.media;
|
|
100
103
|
}
|
|
101
104
|
});
|
|
105
|
+
Object.defineProperty(exports, "rateLimit", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () {
|
|
108
|
+
return _rateLimit.rateLimit;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
102
111
|
Object.defineProperty(exports, "setSecurityWebHeaders", {
|
|
103
112
|
enumerable: true,
|
|
104
113
|
get: function () {
|
|
105
114
|
return _securityHeaders.setSecurityWebHeaders;
|
|
106
115
|
}
|
|
107
116
|
});
|
|
117
|
+
Object.defineProperty(exports, "userAgent", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () {
|
|
120
|
+
return _userAgent.userAgent;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
108
123
|
Object.defineProperty(exports, "validateName", {
|
|
109
124
|
enumerable: true,
|
|
110
125
|
get: function () {
|
|
@@ -117,6 +132,12 @@ Object.defineProperty(exports, "validatePackage", {
|
|
|
117
132
|
return _validation.validatePackage;
|
|
118
133
|
}
|
|
119
134
|
});
|
|
135
|
+
Object.defineProperty(exports, "webMiddleware", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () {
|
|
138
|
+
return _web.webMiddleware;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
120
141
|
var _match = require("./middlewares/match");
|
|
121
142
|
var _securityHeaders = require("./middlewares/security-headers");
|
|
122
143
|
var _validation = require("./middlewares/validation");
|
|
@@ -126,6 +147,9 @@ var _json = require("./middlewares/json");
|
|
|
126
147
|
var _antiLoop = require("./middlewares/antiLoop");
|
|
127
148
|
var _final = require("./middlewares/final");
|
|
128
149
|
var _allow = require("./middlewares/allow");
|
|
150
|
+
var _rateLimit = require("./middlewares/rate-limit");
|
|
151
|
+
var _userAgent = require("./middlewares/user-agent");
|
|
152
|
+
var _web = require("./middlewares/web");
|
|
129
153
|
var _error = require("./middlewares/error");
|
|
130
154
|
var _log = require("./middlewares/log");
|
|
131
155
|
var _types = require("./types");
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { match } from './middlewares/match';\nexport { setSecurityWebHeaders } from './middlewares/security-headers';\nexport { validateName, validatePackage } from './middlewares/validation';\nexport { media } from './middlewares/media';\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 { errorReportingMiddleware, handleError } from './middlewares/error';\nexport {\n log,\n LOG_STATUS_MESSAGE,\n LOG_VERDACCIO_BYTES,\n LOG_VERDACCIO_ERROR,\n} from './middlewares/log';\nexport * from './types';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { match } from './middlewares/match';\nexport { setSecurityWebHeaders } from './middlewares/security-headers';\nexport { validateName, validatePackage } from './middlewares/validation';\nexport { media } from './middlewares/media';\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 } from './middlewares/web';\nexport { errorReportingMiddleware, handleError } from './middlewares/error';\nexport {\n log,\n LOG_STATUS_MESSAGE,\n LOG_VERDACCIO_BYTES,\n LOG_VERDACCIO_ERROR,\n} from './middlewares/log';\nexport * from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rateLimit = rateLimit;
|
|
7
|
+
var _expressRateLimit = _interopRequireDefault(require("express-rate-limit"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
function rateLimit(rateLimitOptions) {
|
|
10
|
+
const limiter = new _expressRateLimit.default(rateLimitOptions);
|
|
11
|
+
return limiter;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=rate-limit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.js","names":["rateLimit","rateLimitOptions","limiter","RateLimit"],"sources":["../../src/middlewares/rate-limit.ts"],"sourcesContent":["import RateLimit from 'express-rate-limit';\n\nimport { RateLimit as RateLimitType } from '@verdaccio/types';\n\nexport function rateLimit(rateLimitOptions?: RateLimitType) {\n const limiter = new RateLimit(rateLimitOptions);\n return limiter;\n}\n"],"mappings":";;;;;;AAAA;AAA2C;AAIpC,SAASA,SAAS,CAACC,gBAAgC,EAAE;EAC1D,MAAMC,OAAO,GAAG,IAAIC,yBAAS,CAACF,gBAAgB,CAAC;EAC/C,OAAOC,OAAO;AAChB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.userAgent = userAgent;
|
|
7
|
+
var _config = require("@verdaccio/config");
|
|
8
|
+
function userAgent(config) {
|
|
9
|
+
return function (_req, res, next) {
|
|
10
|
+
res.setHeader('x-powered-by', (0, _config.getUserAgent)(config === null || config === void 0 ? void 0 : config.user_agent));
|
|
11
|
+
next();
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=user-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-agent.js","names":["userAgent","config","_req","res","next","setHeader","getUserAgent","user_agent"],"sources":["../../src/middlewares/user-agent.ts"],"sourcesContent":["import { getUserAgent } from '@verdaccio/config';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function userAgent(config) {\n return function (_req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n res.setHeader('x-powered-by', getUserAgent(config?.user_agent));\n next();\n };\n}\n"],"mappings":";;;;;;AAAA;AAIO,SAASA,SAAS,CAACC,MAAM,EAAE;EAChC,OAAO,UAAUC,IAAoB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IACzFD,GAAG,CAACE,SAAS,CAAC,cAAc,EAAE,IAAAC,oBAAY,EAACL,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEM,UAAU,CAAC,CAAC;IAC/DH,IAAI,EAAE;EACR,CAAC;AACH"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function validatePackage(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer, value: string, name: string): void;
|
|
1
|
+
export declare function validateName(_req: any, _res: any, next: any, value: string, name: string): void;
|
|
2
|
+
export declare function validatePackage(_req: any, _res: any, next: any, value: string, name: string): void;
|
|
@@ -7,7 +7,7 @@ exports.validateName = validateName;
|
|
|
7
7
|
exports.validatePackage = validatePackage;
|
|
8
8
|
var _core = require("@verdaccio/core");
|
|
9
9
|
var _utils = require("@verdaccio/utils");
|
|
10
|
-
function validateName(
|
|
10
|
+
function validateName(_req, _res, next, value, name) {
|
|
11
11
|
if (value === '-') {
|
|
12
12
|
// special case in couchdb usually
|
|
13
13
|
next('route');
|
|
@@ -17,7 +17,7 @@ function validateName(req, res, next, value, name) {
|
|
|
17
17
|
next(_core.errorUtils.getForbidden('invalid ' + name));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function validatePackage(
|
|
20
|
+
function validatePackage(_req, _res, next, value, name) {
|
|
21
21
|
if (value === '-') {
|
|
22
22
|
// special case in couchdb usually
|
|
23
23
|
next('route');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","names":["validateName","
|
|
1
|
+
{"version":3,"file":"validation.js","names":["validateName","_req","_res","next","value","name","utilValidateName","errorUtils","getForbidden","validatePackage","utilValidatePackage"],"sources":["../../src/middlewares/validation.ts"],"sourcesContent":["import { errorUtils } from '@verdaccio/core';\nimport {\n validateName as utilValidateName,\n validatePackage as utilValidatePackage,\n} from '@verdaccio/utils';\n\nexport function validateName(_req, _res, next, value: string, name: string) {\n if (value === '-') {\n // special case in couchdb usually\n next('route');\n } else if (utilValidateName(value)) {\n next();\n } else {\n next(errorUtils.getForbidden('invalid ' + name));\n }\n}\n\nexport function validatePackage(_req, _res, next, value: string, name: string) {\n if (value === '-') {\n // special case in couchdb usually\n next('route');\n } else if (utilValidatePackage(value)) {\n next();\n } else {\n next(errorUtils.getForbidden('invalid ' + name));\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AAKO,SAASA,YAAY,CAACC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAa,EAAEC,IAAY,EAAE;EAC1E,IAAID,KAAK,KAAK,GAAG,EAAE;IACjB;IACAD,IAAI,CAAC,OAAO,CAAC;EACf,CAAC,MAAM,IAAI,IAAAG,mBAAgB,EAACF,KAAK,CAAC,EAAE;IAClCD,IAAI,EAAE;EACR,CAAC,MAAM;IACLA,IAAI,CAACI,gBAAU,CAACC,YAAY,CAAC,UAAU,GAAGH,IAAI,CAAC,CAAC;EAClD;AACF;AAEO,SAASI,eAAe,CAACR,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAa,EAAEC,IAAY,EAAE;EAC7E,IAAID,KAAK,KAAK,GAAG,EAAE;IACjB;IACAD,IAAI,CAAC,OAAO,CAAC;EACf,CAAC,MAAM,IAAI,IAAAO,sBAAmB,EAACN,KAAK,CAAC,EAAE;IACrCD,IAAI,EAAE;EACR,CAAC,MAAM;IACLA,IAAI,CAACI,gBAAU,CAACC,YAAY,CAAC,UAAU,GAAGH,IAAI,CAAC,CAAC;EAClD;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as webMiddleware } from './web-middleware';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "webMiddleware", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _webMiddleware.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _webMiddleware = _interopRequireDefault(require("./web-middleware"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/middlewares/web/index.ts"],"sourcesContent":["export { default as webMiddleware } from './web-middleware';\n"],"mappings":";;;;;;;;;;;AAAA;AAA4D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderWebMiddleware(config: any, tokenMiddleware: any, pluginOptions: any): import("express-serve-static-core").Router;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderWebMiddleware = renderWebMiddleware;
|
|
7
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
+
var _express = _interopRequireDefault(require("express"));
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _core = require("@verdaccio/core");
|
|
12
|
+
var _url = require("@verdaccio/url");
|
|
13
|
+
var _security = require("./security");
|
|
14
|
+
var _renderHTML = _interopRequireWildcard(require("./utils/renderHTML"));
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
const debug = (0, _debug.default)('verdaccio:web:render');
|
|
19
|
+
const sendFileCallback = next => err => {
|
|
20
|
+
if (!err) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (err.status === _core.HTTP_STATUS.NOT_FOUND) {
|
|
24
|
+
next();
|
|
25
|
+
} else {
|
|
26
|
+
next(err);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function renderWebMiddleware(config, tokenMiddleware, pluginOptions) {
|
|
30
|
+
var _config$web$logo, _config$web, _config$web2, _config$web3;
|
|
31
|
+
const {
|
|
32
|
+
staticPath,
|
|
33
|
+
manifest,
|
|
34
|
+
manifestFiles
|
|
35
|
+
} = pluginOptions;
|
|
36
|
+
debug('static path %o', staticPath);
|
|
37
|
+
|
|
38
|
+
/* eslint new-cap:off */
|
|
39
|
+
const router = _express.default.Router();
|
|
40
|
+
if (typeof tokenMiddleware === 'function') {
|
|
41
|
+
router.use(tokenMiddleware);
|
|
42
|
+
}
|
|
43
|
+
router.use(_security.setSecurityWebHeaders);
|
|
44
|
+
|
|
45
|
+
// Logo
|
|
46
|
+
let logoURI = (_config$web$logo = config === null || config === void 0 ? void 0 : (_config$web = config.web) === null || _config$web === void 0 ? void 0 : _config$web.logo) !== null && _config$web$logo !== void 0 ? _config$web$logo : '';
|
|
47
|
+
if (logoURI && !(0, _url.isURLhasValidProtocol)(logoURI)) {
|
|
48
|
+
// URI related to a local file
|
|
49
|
+
|
|
50
|
+
// Note: `path.join` will break on Windows, because it transforms `/` to `\`
|
|
51
|
+
// Use POSIX version `path.posix.join` instead.
|
|
52
|
+
logoURI = _path.default.posix.join('/-/static/', _path.default.basename(logoURI));
|
|
53
|
+
router.get(logoURI, function (req, res, next) {
|
|
54
|
+
res.sendFile(_path.default.resolve(config.web.logo), sendFileCallback(next));
|
|
55
|
+
debug('render static');
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Static
|
|
60
|
+
router.get('/-/static/*', function (req, res, next) {
|
|
61
|
+
const filename = req.params[0];
|
|
62
|
+
const file = `${staticPath}/${filename}`;
|
|
63
|
+
debug('render static file %o', file);
|
|
64
|
+
res.sendFile(file, sendFileCallback(next));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// logo
|
|
68
|
+
if (config !== null && config !== void 0 && (_config$web2 = config.web) !== null && _config$web2 !== void 0 && _config$web2.logo && !(0, _renderHTML.isHTTPProtocol)(config === null || config === void 0 ? void 0 : (_config$web3 = config.web) === null || _config$web3 === void 0 ? void 0 : _config$web3.logo)) {
|
|
69
|
+
// URI related to a local file
|
|
70
|
+
const absoluteLocalFile = _path.default.posix.resolve(config.web.logo);
|
|
71
|
+
debug('serve local logo %s', absoluteLocalFile);
|
|
72
|
+
try {
|
|
73
|
+
// TODO: remove existsSync by async alternative
|
|
74
|
+
if (_fs.default.existsSync(absoluteLocalFile) && typeof _fs.default.accessSync(absoluteLocalFile, _fs.default.constants.R_OK) === 'undefined') {
|
|
75
|
+
// Note: `path.join` will break on Windows, because it transforms `/` to `\`
|
|
76
|
+
// Use POSIX version `path.posix.join` instead.
|
|
77
|
+
config.web.logo = _path.default.posix.join('/-/static/', _path.default.basename(config.web.logo));
|
|
78
|
+
router.get(config.web.logo, function (_req, res, next) {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
debug('serve custom logo web:%s - local:%s', config.web.logo, absoluteLocalFile);
|
|
81
|
+
res.sendFile(absoluteLocalFile, sendFileCallback(next));
|
|
82
|
+
});
|
|
83
|
+
debug('enabled custom logo %s', config.web.logo);
|
|
84
|
+
} else {
|
|
85
|
+
config.web.logo = undefined;
|
|
86
|
+
debug(`web logo is wrong, path ${absoluteLocalFile} does not exist or is not readable`);
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
config.web.logo = undefined;
|
|
90
|
+
debug(`web logo is wrong, path ${absoluteLocalFile} does not exist or is not readable`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
router.get('/-/web/:section/*', function (req, res) {
|
|
94
|
+
(0, _renderHTML.default)(config, manifest, manifestFiles, req, res);
|
|
95
|
+
debug('render html section');
|
|
96
|
+
});
|
|
97
|
+
router.get('/', function (req, res) {
|
|
98
|
+
(0, _renderHTML.default)(config, manifest, manifestFiles, req, res);
|
|
99
|
+
debug('render root');
|
|
100
|
+
});
|
|
101
|
+
return router;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=render-web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-web.js","names":["debug","buildDebug","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","config","tokenMiddleware","pluginOptions","staticPath","manifest","manifestFiles","router","express","Router","use","setSecurityWebHeaders","logoURI","web","logo","isURLhasValidProtocol","path","posix","join","basename","get","req","res","sendFile","resolve","filename","params","file","isHTTPProtocol","absoluteLocalFile","fs","existsSync","accessSync","constants","R_OK","_req","undefined","renderHTML"],"sources":["../../../src/middlewares/web/render-web.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport express from 'express';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\n\nimport { setSecurityWebHeaders } from './security';\nimport renderHTML, { isHTTPProtocol } from './utils/renderHTML';\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 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 // logo\n if (config?.web?.logo && !isHTTPProtocol(config?.web?.logo)) {\n // URI related to a local file\n const absoluteLocalFile = path.posix.resolve(config.web.logo);\n debug('serve local logo %s', absoluteLocalFile);\n try {\n // TODO: remove 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 config.web.logo = path.posix.join('/-/static/', path.basename(config.web.logo));\n router.get(config.web.logo, function (_req, res, next) {\n // @ts-ignore\n debug('serve custom logo web:%s - local:%s', config.web.logo, absoluteLocalFile);\n res.sendFile(absoluteLocalFile, sendFileCallback(next));\n });\n debug('enabled custom logo %s', config.web.logo);\n } else {\n config.web.logo = undefined;\n debug(`web logo is wrong, path ${absoluteLocalFile} does not exist or is not readable`);\n }\n } catch {\n config.web.logo = undefined;\n debug(`web logo is wrong, path ${absoluteLocalFile} does not exist or is not readable`);\n }\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;AAEA;AACA;AAAgE;AAAA;AAAA;AAEhE,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,gBAAgB,GAAIC,IAAI,IAAMC,GAAG,IAAK;EAC1C,IAAI,CAACA,GAAG,EAAE;IACR;EACF;EACA,IAAIA,GAAG,CAACC,MAAM,KAAKC,iBAAW,CAACC,SAAS,EAAE;IACxCJ,IAAI,EAAE;EACR,CAAC,MAAM;IACLA,IAAI,CAACC,GAAG,CAAC;EACX;AACF,CAAC;AAEM,SAASI,mBAAmB,CAACC,MAAM,EAAEC,eAAe,EAAEC,aAAa,EAAE;EAAA;EAC1E,MAAM;IAAEC,UAAU;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAGH,aAAa;EAC7DX,KAAK,CAAC,gBAAgB,EAAEY,UAAU,CAAC;;EAEnC;EACA,MAAMG,MAAM,GAAGC,gBAAO,CAACC,MAAM,EAAE;EAC/B,IAAI,OAAOP,eAAe,KAAK,UAAU,EAAE;IACzCK,MAAM,CAACG,GAAG,CAACR,eAAe,CAAC;EAC7B;EACAK,MAAM,CAACG,GAAG,CAACC,+BAAqB,CAAC;;EAEjC;EACA,IAAIC,OAAO,uBAAGX,MAAM,aAANA,MAAM,sCAANA,MAAM,CAAEY,GAAG,gDAAX,YAAaC,IAAI,+DAAI,EAAE;EACrC,IAAIF,OAAO,IAAI,CAAC,IAAAG,0BAAqB,EAACH,OAAO,CAAC,EAAE;IAC9C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,MAAM,EAAEI,QAAQ,EAAEC,aAAa,EAAEe,GAAG,EAAEC,GAAG,CAAC;IACrD9B,KAAK,CAAC,aAAa,CAAC;EACtB,CAAC,CAAC;EAEF,OAAOe,MAAM;AACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSecurityWebHeaders(_req: any, res: any, next: any): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setSecurityWebHeaders = setSecurityWebHeaders;
|
|
7
|
+
var _core = require("@verdaccio/core");
|
|
8
|
+
function setSecurityWebHeaders(_req, res, next) {
|
|
9
|
+
// disable loading in frames (clickjacking, etc.)
|
|
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
|
|
16
|
+
res.header(_core.HEADERS.XSS, '1; mode=block');
|
|
17
|
+
next();
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","names":["setSecurityWebHeaders","_req","res","next","header","HEADERS","FRAMES_OPTIONS","CSP","CTO","XSS"],"sources":["../../../src/middlewares/web/security.ts"],"sourcesContent":["import { HEADERS } from '@verdaccio/core';\n\nexport function setSecurityWebHeaders(_req, res, next): 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;AAEO,SAASA,qBAAqB,CAACC,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAQ;EAC3D;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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getManifestValue = getManifestValue;
|
|
7
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const debug = (0, _debug.default)('verdaccio:web:render:manifest');
|
|
10
|
+
function getManifestValue(manifestItems, manifest, basePath = '') {
|
|
11
|
+
return manifestItems === null || manifestItems === void 0 ? void 0 : manifestItems.map(item => {
|
|
12
|
+
debug('resolve item %o', item);
|
|
13
|
+
const resolvedItem = `${basePath}${manifest[item]}`;
|
|
14
|
+
debug('resolved item %o', resolvedItem);
|
|
15
|
+
return resolvedItem;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","names":["debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../../../src/middlewares/web/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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if URI is starting with "http://", "https://" or "//"
|
|
3
|
+
* @param {string} uri
|
|
4
|
+
*/
|
|
5
|
+
export declare function isHTTPProtocol(uri: string): boolean;
|
|
6
|
+
export declare function resolveLogo(config: any, req: any): any;
|
|
7
|
+
export default function renderHTML(config: any, manifest: any, manifestFiles: any, req: any, res: any): void;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = renderHTML;
|
|
7
|
+
exports.isHTTPProtocol = isHTTPProtocol;
|
|
8
|
+
exports.resolveLogo = resolveLogo;
|
|
9
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
+
var _lruCache = _interopRequireDefault(require("lru-cache"));
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var _url = require("url");
|
|
13
|
+
var _config = require("@verdaccio/config");
|
|
14
|
+
var _core = require("@verdaccio/core");
|
|
15
|
+
var _url2 = require("@verdaccio/url");
|
|
16
|
+
var _template = _interopRequireDefault(require("./template"));
|
|
17
|
+
var _webUtils = require("./web-utils");
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
const DEFAULT_LANGUAGE = 'es-US';
|
|
20
|
+
const cache = new _lruCache.default({
|
|
21
|
+
max: 500,
|
|
22
|
+
ttl: 1000 * 60 * 60
|
|
23
|
+
});
|
|
24
|
+
const debug = (0, _debug.default)('verdaccio:web:render');
|
|
25
|
+
const defaultManifestFiles = {
|
|
26
|
+
js: ['runtime.js', 'vendors.js', 'main.js'],
|
|
27
|
+
ico: 'favicon.ico'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Check if URI is starting with "http://", "https://" or "//"
|
|
32
|
+
* @param {string} uri
|
|
33
|
+
*/
|
|
34
|
+
function isHTTPProtocol(uri) {
|
|
35
|
+
return /^(https?:)?\/\//.test(uri);
|
|
36
|
+
}
|
|
37
|
+
function resolveLogo(config, req) {
|
|
38
|
+
var _config$web, _config$web2, _config$web4;
|
|
39
|
+
const isLocalFile = (config === null || config === void 0 ? void 0 : (_config$web = config.web) === null || _config$web === void 0 ? void 0 : _config$web.logo) && !isHTTPProtocol(config === null || config === void 0 ? void 0 : (_config$web2 = config.web) === null || _config$web2 === void 0 ? void 0 : _config$web2.logo);
|
|
40
|
+
if (isLocalFile) {
|
|
41
|
+
var _config$web3;
|
|
42
|
+
return `${(0, _url2.getPublicUrl)(config === null || config === void 0 ? void 0 : config.url_prefix, req)}-/static/${_path.default.basename(config === null || config === void 0 ? void 0 : (_config$web3 = config.web) === null || _config$web3 === void 0 ? void 0 : _config$web3.logo)}`;
|
|
43
|
+
} else if (isHTTPProtocol(config === null || config === void 0 ? void 0 : (_config$web4 = config.web) === null || _config$web4 === void 0 ? void 0 : _config$web4.logo)) {
|
|
44
|
+
var _config$web5;
|
|
45
|
+
return config === null || config === void 0 ? void 0 : (_config$web5 = config.web) === null || _config$web5 === void 0 ? void 0 : _config$web5.logo;
|
|
46
|
+
} else {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function renderHTML(config, manifest, manifestFiles, req, res) {
|
|
51
|
+
var _config$i18n$web, _config$i18n, _config$web6, _config$web$darkMode, _config$web7, _config$web$title, _config$web8, _config$web$scope, _config$web9, _config$web$pkgManage, _config$web10, _config$web11, _validatePrimaryColor, _config$web12;
|
|
52
|
+
const {
|
|
53
|
+
url_prefix
|
|
54
|
+
} = config;
|
|
55
|
+
const base = (0, _url2.getPublicUrl)(config === null || config === void 0 ? void 0 : config.url_prefix, req);
|
|
56
|
+
const basename = new _url.URL(base).pathname;
|
|
57
|
+
const language = (_config$i18n$web = config === null || config === void 0 ? void 0 : (_config$i18n = config.i18n) === null || _config$i18n === void 0 ? void 0 : _config$i18n.web) !== null && _config$i18n$web !== void 0 ? _config$i18n$web : DEFAULT_LANGUAGE;
|
|
58
|
+
const needHtmlCache = [undefined, null].includes(config === null || config === void 0 ? void 0 : (_config$web6 = config.web) === null || _config$web6 === void 0 ? void 0 : _config$web6.html_cache) ? true : config.web.html_cache;
|
|
59
|
+
const darkMode = (_config$web$darkMode = config === null || config === void 0 ? void 0 : (_config$web7 = config.web) === null || _config$web7 === void 0 ? void 0 : _config$web7.darkMode) !== null && _config$web$darkMode !== void 0 ? _config$web$darkMode : false;
|
|
60
|
+
const title = (_config$web$title = config === null || config === void 0 ? void 0 : (_config$web8 = config.web) === null || _config$web8 === void 0 ? void 0 : _config$web8.title) !== null && _config$web$title !== void 0 ? _config$web$title : _config.WEB_TITLE;
|
|
61
|
+
const login = (0, _webUtils.hasLogin)(config);
|
|
62
|
+
const scope = (_config$web$scope = config === null || config === void 0 ? void 0 : (_config$web9 = config.web) === null || _config$web9 === void 0 ? void 0 : _config$web9.scope) !== null && _config$web$scope !== void 0 ? _config$web$scope : '';
|
|
63
|
+
const logoURI = resolveLogo(config, req);
|
|
64
|
+
const pkgManagers = (_config$web$pkgManage = config === null || config === void 0 ? void 0 : (_config$web10 = config.web) === null || _config$web10 === void 0 ? void 0 : _config$web10.pkgManagers) !== null && _config$web$pkgManage !== void 0 ? _config$web$pkgManage : ['yarn', 'pnpm', 'npm'];
|
|
65
|
+
const version = config === null || config === void 0 ? void 0 : (_config$web11 = config.web) === null || _config$web11 === void 0 ? void 0 : _config$web11.version;
|
|
66
|
+
const flags = {
|
|
67
|
+
...config.flags,
|
|
68
|
+
// legacy from 5.x
|
|
69
|
+
...config.experiments
|
|
70
|
+
};
|
|
71
|
+
const primaryColor = (_validatePrimaryColor = (0, _webUtils.validatePrimaryColor)(config === null || config === void 0 ? void 0 : (_config$web12 = config.web) === null || _config$web12 === void 0 ? void 0 : _config$web12.primary_color)) !== null && _validatePrimaryColor !== void 0 ? _validatePrimaryColor : '#4b5e40';
|
|
72
|
+
const {
|
|
73
|
+
scriptsBodyAfter,
|
|
74
|
+
metaScripts,
|
|
75
|
+
scriptsbodyBefore,
|
|
76
|
+
showInfo,
|
|
77
|
+
showSettings,
|
|
78
|
+
showThemeSwitch,
|
|
79
|
+
showFooter,
|
|
80
|
+
showSearch,
|
|
81
|
+
showDownloadTarball
|
|
82
|
+
} = Object.assign({}, {
|
|
83
|
+
scriptsBodyAfter: [],
|
|
84
|
+
bodyBefore: [],
|
|
85
|
+
metaScripts: []
|
|
86
|
+
}, config === null || config === void 0 ? void 0 : config.web);
|
|
87
|
+
const options = {
|
|
88
|
+
showInfo,
|
|
89
|
+
showSettings,
|
|
90
|
+
showThemeSwitch,
|
|
91
|
+
showFooter,
|
|
92
|
+
showSearch,
|
|
93
|
+
showDownloadTarball,
|
|
94
|
+
darkMode,
|
|
95
|
+
url_prefix,
|
|
96
|
+
basename,
|
|
97
|
+
base,
|
|
98
|
+
primaryColor,
|
|
99
|
+
version,
|
|
100
|
+
logoURI,
|
|
101
|
+
flags,
|
|
102
|
+
login,
|
|
103
|
+
pkgManagers,
|
|
104
|
+
title,
|
|
105
|
+
scope,
|
|
106
|
+
language
|
|
107
|
+
};
|
|
108
|
+
let webPage;
|
|
109
|
+
try {
|
|
110
|
+
webPage = cache.get('template');
|
|
111
|
+
if (!webPage) {
|
|
112
|
+
webPage = (0, _template.default)({
|
|
113
|
+
manifest: manifestFiles !== null && manifestFiles !== void 0 ? manifestFiles : defaultManifestFiles,
|
|
114
|
+
options,
|
|
115
|
+
scriptsBodyAfter,
|
|
116
|
+
metaScripts,
|
|
117
|
+
scriptsbodyBefore
|
|
118
|
+
}, manifest);
|
|
119
|
+
if (needHtmlCache) {
|
|
120
|
+
cache.set('template', webPage);
|
|
121
|
+
debug('set template cache');
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
debug('reuse template cache');
|
|
125
|
+
}
|
|
126
|
+
} catch (error) {
|
|
127
|
+
throw new Error(`theme could not be load, stack ${error.stack}`);
|
|
128
|
+
}
|
|
129
|
+
res.setHeader('Content-Type', _core.HEADERS.TEXT_HTML);
|
|
130
|
+
res.send(webPage);
|
|
131
|
+
debug('web rendered');
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=renderHTML.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderHTML.js","names":["DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","isHTTPProtocol","uri","test","resolveLogo","config","req","isLocalFile","web","logo","getPublicUrl","url_prefix","path","basename","renderHTML","manifest","manifestFiles","res","base","URL","pathname","language","i18n","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","logoURI","pkgManagers","version","flags","experiments","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/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport path from 'path';\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 './web-utils';\n\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\n/**\n * Check if URI is starting with \"http://\", \"https://\" or \"//\"\n * @param {string} uri\n */\nexport function isHTTPProtocol(uri: string): boolean {\n return /^(https?:)?\\/\\//.test(uri);\n}\n\nexport function resolveLogo(config, req) {\n const isLocalFile = config?.web?.logo && !isHTTPProtocol(config?.web?.logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(config?.url_prefix, req)}-/static/${path.basename(config?.web?.logo)}`;\n } else if (isHTTPProtocol(config?.web?.logo)) {\n return config?.web?.logo;\n } else {\n return '';\n }\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 = resolveLogo(config, req);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = config?.web?.version;\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\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;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAA6D;AAE7D,MAAMA,gBAAgB,GAAG,OAAO;AAChC,MAAMC,KAAK,GAAG,IAAIC,iBAAG,CAAC;EAAEC,GAAG,EAAE,GAAG;EAAEC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG;AAAG,CAAC,CAAC;AAEx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C,CAAC,OAAO8D,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAE,kCAAiCD,KAAK,CAACE,KAAM,EAAC,CAAC;EAClE;EACA3C,GAAG,CAAC4C,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChD9C,GAAG,CAAC+C,IAAI,CAACV,OAAO,CAAC;EACjB1D,KAAK,CAAC,cAAc,CAAC;AACvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TemplateUIOptions } from '@verdaccio/types';
|
|
2
|
+
import { Manifest } from './manifest';
|
|
3
|
+
export type Template = {
|
|
4
|
+
manifest: Manifest;
|
|
5
|
+
options: TemplateUIOptions;
|
|
6
|
+
metaScripts?: string[];
|
|
7
|
+
scriptsBodyAfter?: string[];
|
|
8
|
+
scriptsbodyBefore?: string[];
|
|
9
|
+
};
|
|
10
|
+
export interface WebpackManifest {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
}
|
|
13
|
+
export default function renderTemplate(template: Template, manifest: WebpackManifest): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = renderTemplate;
|
|
7
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
+
var _manifest = require("./manifest");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const debug = (0, _debug.default)('verdaccio:web:render:template');
|
|
11
|
+
function renderTemplate(template, manifest) {
|
|
12
|
+
var _template$options$tit, _template$options;
|
|
13
|
+
debug('template %o', template);
|
|
14
|
+
debug('manifest %o', manifest);
|
|
15
|
+
return `
|
|
16
|
+
<!DOCTYPE html>
|
|
17
|
+
<html lang="en-us">
|
|
18
|
+
<head>
|
|
19
|
+
<meta charset="utf-8">
|
|
20
|
+
<base href="${template === null || template === void 0 ? void 0 : template.options.base}">
|
|
21
|
+
<title>${(_template$options$tit = template === null || template === void 0 ? void 0 : (_template$options = template.options) === null || _template$options === void 0 ? void 0 : _template$options.title) !== null && _template$options$tit !== void 0 ? _template$options$tit : ''}</title>
|
|
22
|
+
<link rel="icon" href="${template === null || template === void 0 ? void 0 : template.options.base}-/static/favicon.ico"/>
|
|
23
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
24
|
+
<script>
|
|
25
|
+
window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}
|
|
26
|
+
</script>
|
|
27
|
+
${template !== null && template !== void 0 && template.metaScripts ? template.metaScripts.join('') : ''}
|
|
28
|
+
</head>
|
|
29
|
+
<body class="body">
|
|
30
|
+
${template !== null && template !== void 0 && template.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
${(0, _manifest.getManifestValue)(template.manifest.js, manifest, template === null || template === void 0 ? void 0 : template.options.base).map(item => `<script defer="defer" src="${item}"></script>`).join('')}
|
|
33
|
+
${template !== null && template !== void 0 && template.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +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/middlewares/web/utils/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './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;AAAwD;AAExD,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,iBAAe,yBAAEH,QAAQ,aAARA,QAAQ,4CAARA,QAAQ,CAAEE,OAAO,sDAAjB,kBAAmBE,KAAK,yEAAI,EAAG;AAChD,iCAAiCJ,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,OAAO,CAACC,IAAK;AACxD;AACA;AACA,qDAA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