verdaccio-audit 10.2.2 → 10.2.4
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/lib/audit.js +1 -28
- package/lib/audit.js.map +1 -1
- package/lib/index.js +0 -4
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
package/lib/audit.js
CHANGED
|
@@ -4,42 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.REGISTRY_DOMAIN = void 0;
|
|
7
|
-
|
|
8
7
|
var _https = _interopRequireDefault(require("https"));
|
|
9
|
-
|
|
10
8
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
11
|
-
|
|
12
9
|
var _express = _interopRequireDefault(require("express"));
|
|
13
|
-
|
|
14
10
|
var _httpsProxyAgent = _interopRequireDefault(require("https-proxy-agent"));
|
|
15
|
-
|
|
16
11
|
var _bodyParser = require("body-parser");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
|
|
22
13
|
// FUTURE: we should be able to overwrite this
|
|
23
14
|
const REGISTRY_DOMAIN = 'https://registry.npmjs.org';
|
|
24
15
|
exports.REGISTRY_DOMAIN = REGISTRY_DOMAIN;
|
|
25
|
-
|
|
26
16
|
class ProxyAudit {
|
|
27
17
|
constructor(config, options) {
|
|
28
|
-
_defineProperty(this, "enabled", void 0);
|
|
29
|
-
|
|
30
|
-
_defineProperty(this, "logger", void 0);
|
|
31
|
-
|
|
32
|
-
_defineProperty(this, "strict_ssl", void 0);
|
|
33
|
-
|
|
34
18
|
this.enabled = config.enabled || false;
|
|
35
19
|
this.strict_ssl = config.strict_ssl !== undefined ? config.strict_ssl : true;
|
|
36
20
|
this.logger = options.logger;
|
|
37
21
|
}
|
|
38
|
-
|
|
39
22
|
register_middlewares(app, auth) {
|
|
40
23
|
const fetchAudit = (req, res) => {
|
|
41
24
|
var _auth$config;
|
|
42
|
-
|
|
43
25
|
const headers = req.headers;
|
|
44
26
|
headers['host'] = 'registry.npmjs.org';
|
|
45
27
|
headers['content-encoding'] = 'gzip,deflate,br';
|
|
@@ -51,10 +33,8 @@ class ProxyAudit {
|
|
|
51
33
|
headers,
|
|
52
34
|
method: req.method
|
|
53
35
|
};
|
|
54
|
-
|
|
55
36
|
if (auth !== null && auth !== void 0 && (_auth$config = auth.config) !== null && _auth$config !== void 0 && _auth$config.https_proxy) {
|
|
56
37
|
var _auth$config2;
|
|
57
|
-
|
|
58
38
|
// we should check whether this works fine after this migration
|
|
59
39
|
// please notify if anyone is having issues
|
|
60
40
|
const agent = (0, _httpsProxyAgent.default)(auth === null || auth === void 0 ? void 0 : (_auth$config2 = auth.config) === null || _auth$config2 === void 0 ? void 0 : _auth$config2.https_proxy);
|
|
@@ -62,13 +42,11 @@ class ProxyAudit {
|
|
|
62
42
|
agent
|
|
63
43
|
});
|
|
64
44
|
}
|
|
65
|
-
|
|
66
45
|
(async () => {
|
|
67
46
|
try {
|
|
68
47
|
const auditEndpoint = `${REGISTRY_DOMAIN}${req.baseUrl}${req.route.path}`;
|
|
69
48
|
this.logger.debug('fetching audit from ' + auditEndpoint);
|
|
70
49
|
const response = await (0, _nodeFetch.default)(auditEndpoint, requestOptions);
|
|
71
|
-
|
|
72
50
|
if (response.ok) {
|
|
73
51
|
res.status(response.status).send(await response.json());
|
|
74
52
|
} else {
|
|
@@ -81,7 +59,6 @@ class ProxyAudit {
|
|
|
81
59
|
}
|
|
82
60
|
})();
|
|
83
61
|
};
|
|
84
|
-
|
|
85
62
|
const handleAudit = (req, res) => {
|
|
86
63
|
if (this.enabled) {
|
|
87
64
|
fetchAudit(req, res);
|
|
@@ -89,13 +66,11 @@ class ProxyAudit {
|
|
|
89
66
|
res.status(500).end();
|
|
90
67
|
}
|
|
91
68
|
};
|
|
92
|
-
/* eslint new-cap:off */
|
|
93
|
-
|
|
94
69
|
|
|
70
|
+
/* eslint new-cap:off */
|
|
95
71
|
const router = _express.default.Router();
|
|
96
72
|
/* eslint new-cap:off */
|
|
97
73
|
|
|
98
|
-
|
|
99
74
|
router.post('/audits', (0, _bodyParser.json)({
|
|
100
75
|
limit: '10mb'
|
|
101
76
|
}), handleAudit);
|
|
@@ -107,8 +82,6 @@ class ProxyAudit {
|
|
|
107
82
|
}), handleAudit);
|
|
108
83
|
app.use('/-/npm/v1/security', router);
|
|
109
84
|
}
|
|
110
|
-
|
|
111
85
|
}
|
|
112
|
-
|
|
113
86
|
exports.default = ProxyAudit;
|
|
114
87
|
//# sourceMappingURL=audit.js.map
|
package/lib/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","names":["REGISTRY_DOMAIN","ProxyAudit","constructor","config","options","enabled","strict_ssl","undefined","logger","register_middlewares","app","auth","fetchAudit","req","res","headers","requestOptions","agent","https","Agent","rejectUnauthorized","body","JSON","stringify","method","https_proxy","createHttpsProxyAgent","Object","assign","auditEndpoint","baseUrl","route","path","debug","response","fetch","ok","status","send","json","warn","end","error","handleAudit","router","express","Router","post","jsonParser","limit","use"],"sources":["../src/audit.ts"],"sourcesContent":["import https from 'https';\nimport fetch from 'node-fetch';\nimport express, { Request, Response } from 'express';\nimport createHttpsProxyAgent from 'https-proxy-agent';\nimport { json as jsonParser } from 'body-parser';\nimport { Logger, IPluginMiddleware, IBasicAuth, PluginOptions } from '@verdaccio/types';\n\nimport { ConfigAudit } from './types';\n\n// FUTURE: we should be able to overwrite this\nexport const REGISTRY_DOMAIN = 'https://registry.npmjs.org';\n\nexport default class ProxyAudit implements IPluginMiddleware<ConfigAudit> {\n public enabled: boolean;\n public logger: Logger;\n public strict_ssl: boolean;\n\n public constructor(config: ConfigAudit, options: PluginOptions<ConfigAudit>) {\n this.enabled = config.enabled || false;\n this.strict_ssl = config.strict_ssl !== undefined ? config.strict_ssl : true;\n this.logger = options.logger;\n }\n\n public register_middlewares(app: any, auth: IBasicAuth<ConfigAudit>): void {\n const fetchAudit = (req: Request, res: Response & { report_error?: Function }): void => {\n const headers = req.headers;\n\n headers['host'] = 'registry.npmjs.org';\n headers['content-encoding'] = 'gzip,deflate,br';\n\n let requestOptions: any = {\n agent: new https.Agent({ rejectUnauthorized: this.strict_ssl }),\n body: JSON.stringify(req.body),\n headers,\n method: req.method,\n };\n\n if (auth?.config?.https_proxy) {\n // we should check whether this works fine after this migration\n // please notify if anyone is having issues\n const agent = createHttpsProxyAgent(auth?.config?.https_proxy);\n requestOptions = Object.assign({}, requestOptions, {\n agent,\n });\n }\n\n (async () => {\n try {\n const auditEndpoint = `${REGISTRY_DOMAIN}${req.baseUrl}${req.route.path}`;\n this.logger.debug('fetching audit from ' + auditEndpoint);\n\n const response = await fetch(auditEndpoint, requestOptions);\n\n if (response.ok) {\n res.status(response.status).send(await response.json());\n } else {\n this.logger.warn('could not fetch audit: ' + JSON.stringify(await response.json()));\n res.status(response.status).end();\n }\n } catch (error) {\n this.logger.warn('could not fetch audit: ' + error);\n res.status(500).end();\n }\n })();\n };\n\n const handleAudit = (req: Request, res: Response): void => {\n if (this.enabled) {\n fetchAudit(req, res);\n } else {\n res.status(500).end();\n }\n };\n\n /* eslint new-cap:off */\n const router = express.Router();\n /* eslint new-cap:off */\n\n router.post('/audits', jsonParser({ limit: '10mb' }), handleAudit);\n router.post('/audits/quick', jsonParser({ limit: '10mb' }), handleAudit);\n\n router.post('/advisories/bulk', jsonParser({ limit: '10mb' }), handleAudit);\n\n app.use('/-/npm/v1/security', router);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit.js","names":["REGISTRY_DOMAIN","ProxyAudit","constructor","config","options","enabled","strict_ssl","undefined","logger","register_middlewares","app","auth","fetchAudit","req","res","headers","requestOptions","agent","https","Agent","rejectUnauthorized","body","JSON","stringify","method","https_proxy","createHttpsProxyAgent","Object","assign","auditEndpoint","baseUrl","route","path","debug","response","fetch","ok","status","send","json","warn","end","error","handleAudit","router","express","Router","post","jsonParser","limit","use"],"sources":["../src/audit.ts"],"sourcesContent":["import https from 'https';\nimport fetch from 'node-fetch';\nimport express, { Request, Response } from 'express';\nimport createHttpsProxyAgent from 'https-proxy-agent';\nimport { json as jsonParser } from 'body-parser';\nimport { Logger, IPluginMiddleware, IBasicAuth, PluginOptions } from '@verdaccio/types';\n\nimport { ConfigAudit } from './types';\n\n// FUTURE: we should be able to overwrite this\nexport const REGISTRY_DOMAIN = 'https://registry.npmjs.org';\n\nexport default class ProxyAudit implements IPluginMiddleware<ConfigAudit> {\n public enabled: boolean;\n public logger: Logger;\n public strict_ssl: boolean;\n\n public constructor(config: ConfigAudit, options: PluginOptions<ConfigAudit>) {\n this.enabled = config.enabled || false;\n this.strict_ssl = config.strict_ssl !== undefined ? config.strict_ssl : true;\n this.logger = options.logger;\n }\n\n public register_middlewares(app: any, auth: IBasicAuth<ConfigAudit>): void {\n const fetchAudit = (req: Request, res: Response & { report_error?: Function }): void => {\n const headers = req.headers;\n\n headers['host'] = 'registry.npmjs.org';\n headers['content-encoding'] = 'gzip,deflate,br';\n\n let requestOptions: any = {\n agent: new https.Agent({ rejectUnauthorized: this.strict_ssl }),\n body: JSON.stringify(req.body),\n headers,\n method: req.method,\n };\n\n if (auth?.config?.https_proxy) {\n // we should check whether this works fine after this migration\n // please notify if anyone is having issues\n const agent = createHttpsProxyAgent(auth?.config?.https_proxy);\n requestOptions = Object.assign({}, requestOptions, {\n agent,\n });\n }\n\n (async () => {\n try {\n const auditEndpoint = `${REGISTRY_DOMAIN}${req.baseUrl}${req.route.path}`;\n this.logger.debug('fetching audit from ' + auditEndpoint);\n\n const response = await fetch(auditEndpoint, requestOptions);\n\n if (response.ok) {\n res.status(response.status).send(await response.json());\n } else {\n this.logger.warn('could not fetch audit: ' + JSON.stringify(await response.json()));\n res.status(response.status).end();\n }\n } catch (error) {\n this.logger.warn('could not fetch audit: ' + error);\n res.status(500).end();\n }\n })();\n };\n\n const handleAudit = (req: Request, res: Response): void => {\n if (this.enabled) {\n fetchAudit(req, res);\n } else {\n res.status(500).end();\n }\n };\n\n /* eslint new-cap:off */\n const router = express.Router();\n /* eslint new-cap:off */\n\n router.post('/audits', jsonParser({ limit: '10mb' }), handleAudit);\n router.post('/audits/quick', jsonParser({ limit: '10mb' }), handleAudit);\n\n router.post('/advisories/bulk', jsonParser({ limit: '10mb' }), handleAudit);\n\n app.use('/-/npm/v1/security', router);\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAAiD;AAKjD;AACO,MAAMA,eAAe,GAAG,4BAA4B;AAAC;AAE7C,MAAMC,UAAU,CAA2C;EAKjEC,WAAW,CAACC,MAAmB,EAAEC,OAAmC,EAAE;IAC3E,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO,IAAI,KAAK;IACtC,IAAI,CAACC,UAAU,GAAGH,MAAM,CAACG,UAAU,KAAKC,SAAS,GAAGJ,MAAM,CAACG,UAAU,GAAG,IAAI;IAC5E,IAAI,CAACE,MAAM,GAAGJ,OAAO,CAACI,MAAM;EAC9B;EAEOC,oBAAoB,CAACC,GAAQ,EAAEC,IAA6B,EAAQ;IACzE,MAAMC,UAAU,GAAG,CAACC,GAAY,EAAEC,GAA2C,KAAW;MAAA;MACtF,MAAMC,OAAO,GAAGF,GAAG,CAACE,OAAO;MAE3BA,OAAO,CAAC,MAAM,CAAC,GAAG,oBAAoB;MACtCA,OAAO,CAAC,kBAAkB,CAAC,GAAG,iBAAiB;MAE/C,IAAIC,cAAmB,GAAG;QACxBC,KAAK,EAAE,IAAIC,cAAK,CAACC,KAAK,CAAC;UAAEC,kBAAkB,EAAE,IAAI,CAACd;QAAW,CAAC,CAAC;QAC/De,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACV,GAAG,CAACQ,IAAI,CAAC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AAG,EAAE;QACvB;MACF,CAAC,GAAG;IACN,CAAC;IAED,MAAME,WAAW,GAAG,CAAC9B,GAAY,EAAEC,GAAa,KAAW;MACzD,IAAI,IAAI,CAACT,OAAO,EAAE;QAChBO,UAAU,CAACC,GAAG,EAAEC,GAAG,CAAC;MACtB,CAAC,MAAM;QACLA,GAAG,CAACuB,MAAM,CAAC,GAAG,CAAC,CAACI,GAAG,EAAE;MACvB;IACF,CAAC;;IAED;IACA,MAAMG,MAAM,GAAGC,gBAAO,CAACC,MAAM,EAAE;IAC/B;;IAEAF,MAAM,CAACG,IAAI,CAAC,SAAS,EAAE,IAAAC,gBAAU,EAAC;MAAEC,KAAK,EAAE;IAAO,CAAC,CAAC,EAAEN,WAAW,CAAC;IAClEC,MAAM,CAACG,IAAI,CAAC,eAAe,EAAE,IAAAC,gBAAU,EAAC;MAAEC,KAAK,EAAE;IAAO,CAAC,CAAC,EAAEN,WAAW,CAAC;IAExEC,MAAM,CAACG,IAAI,CAAC,kBAAkB,EAAE,IAAAC,gBAAU,EAAC;MAAEC,KAAK,EAAE;IAAO,CAAC,CAAC,EAAEN,WAAW,CAAC;IAE3EjC,GAAG,CAACwC,GAAG,CAAC,oBAAoB,EAAEN,MAAM,CAAC;EACvC;AACF;AAAC"}
|
package/lib/index.js
CHANGED
|
@@ -10,13 +10,9 @@ Object.defineProperty(exports, "ConfigAudit", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
exports.default = void 0;
|
|
13
|
-
|
|
14
13
|
var _audit = _interopRequireDefault(require("./audit"));
|
|
15
|
-
|
|
16
14
|
var _types = require("./types");
|
|
17
|
-
|
|
18
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
16
|
var _default = _audit.default;
|
|
21
17
|
exports.default = _default;
|
|
22
18
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["AuditPlugin"],"sources":["../src/index.ts"],"sourcesContent":["import AuditPlugin from './audit';\nimport { ConfigAudit } from './types';\n\nexport { ConfigAudit };\n\nexport default AuditPlugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["AuditPlugin"],"sources":["../src/index.ts"],"sourcesContent":["import AuditPlugin from './audit';\nimport { ConfigAudit } from './types';\n\nexport { ConfigAudit };\n\nexport default AuditPlugin;\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAAsC;AAAA,eAIvBA,cAAW;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "verdaccio-audit",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.4",
|
|
4
4
|
"description": "Verdaccio Middleware plugin to bypass npmjs audit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"verdaccio",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"node": ">=8"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"express": "4.18.
|
|
31
|
+
"express": "4.18.2",
|
|
32
32
|
"https-proxy-agent": "5.0.1",
|
|
33
|
-
"body-parser": "1.20.
|
|
34
|
-
"node-fetch": "2.6.
|
|
33
|
+
"body-parser": "1.20.1",
|
|
34
|
+
"node-fetch": "2.6.8"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@verdaccio/types": "10.
|
|
37
|
+
"@verdaccio/types": "10.7.0"
|
|
38
38
|
},
|
|
39
39
|
"funding": {
|
|
40
40
|
"type": "opencollective",
|