@verdaccio/middleware 9.0.0-next-9.30 → 9.0.0-next-9.31
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 +1 -1
- package/build/index.js +1 -1
- package/build/index.mjs +1 -1
- package/build/middlewares/{api_urls.js → api-urls.js} +2 -2
- package/build/middlewares/{api_urls.js.map → api-urls.js.map} +1 -1
- package/build/middlewares/{api_urls.mjs → api-urls.mjs} +2 -2
- package/build/middlewares/{api_urls.mjs.map → api-urls.mjs.map} +1 -1
- package/build/middlewares/error.js +4 -1
- package/build/middlewares/error.js.map +1 -1
- package/build/middlewares/error.mjs +4 -1
- package/build/middlewares/error.mjs.map +1 -1
- package/package.json +7 -7
- /package/build/middlewares/{api_urls.d.ts → api-urls.d.ts} +0 -0
package/build/index.d.ts
CHANGED
|
@@ -20,5 +20,5 @@ export { getRequestOptions } from './middlewares/request-options';
|
|
|
20
20
|
export { log, LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, } from './middlewares/log';
|
|
21
21
|
export type { LogOptions } from './middlewares/log';
|
|
22
22
|
export * from './types';
|
|
23
|
-
export * from './middlewares/
|
|
23
|
+
export * from './middlewares/api-urls';
|
|
24
24
|
export * from './middlewares/web/web-urls';
|
package/build/index.js
CHANGED
|
@@ -24,7 +24,7 @@ require("./middlewares/web/index.js");
|
|
|
24
24
|
const require_error = require("./middlewares/error.js");
|
|
25
25
|
const require_request_options = require("./middlewares/request-options.js");
|
|
26
26
|
const require_log = require("./middlewares/log.js");
|
|
27
|
-
const require_api_urls = require("./middlewares/
|
|
27
|
+
const require_api_urls = require("./middlewares/api-urls.js");
|
|
28
28
|
exports.DIST_TAGS_API_ENDPOINTS = require_api_urls.DIST_TAGS_API_ENDPOINTS;
|
|
29
29
|
exports.LOGIN_API_ENDPOINTS = require_api_urls.LOGIN_API_ENDPOINTS;
|
|
30
30
|
exports.LOG_STATUS_MESSAGE = require_log.LOG_STATUS_MESSAGE;
|
package/build/index.mjs
CHANGED
|
@@ -20,5 +20,5 @@ import "./middlewares/web/index.mjs";
|
|
|
20
20
|
import { errorReportingMiddleware, handleError } from "./middlewares/error.mjs";
|
|
21
21
|
import { getRequestOptions } from "./middlewares/request-options.mjs";
|
|
22
22
|
import { LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, log } from "./middlewares/log.mjs";
|
|
23
|
-
import { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STAGE_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS } from "./middlewares/
|
|
23
|
+
import { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STAGE_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS } from "./middlewares/api-urls.mjs";
|
|
24
24
|
export { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STAGE_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS, WebUrls, WebUrlsNamespace, allow, antiLoop, dotfiles, encodeScopePackage, enforceGeneratedTokenMetadata, errorReportingMiddleware, expectJson, final, getRequestOptions, handleError, log, makeURLrelative, match, media, rateLimit, registerBodyParser, renderWebMiddleware, setSecurityWebHeaders, userAgent, validateName, validatePackage, web_middleware_default as webMiddleware };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/middlewares/
|
|
1
|
+
//#region src/middlewares/api-urls.ts
|
|
2
2
|
var USER_API_ENDPOINTS = /* @__PURE__ */ function(USER_API_ENDPOINTS) {
|
|
3
3
|
USER_API_ENDPOINTS["whoami"] = "/-/whoami";
|
|
4
4
|
USER_API_ENDPOINTS["get_user"] = "/-/user/:org_couchdb_user";
|
|
@@ -95,4 +95,4 @@ exports.STAGE_API_ENDPOINTS = STAGE_API_ENDPOINTS;
|
|
|
95
95
|
exports.TOKEN_API_ENDPOINTS = TOKEN_API_ENDPOINTS;
|
|
96
96
|
exports.USER_API_ENDPOINTS = USER_API_ENDPOINTS;
|
|
97
97
|
|
|
98
|
-
//# sourceMappingURL=
|
|
98
|
+
//# sourceMappingURL=api-urls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"api-urls.js","names":[],"sources":["../../src/middlewares/api-urls.ts"],"sourcesContent":["export enum USER_API_ENDPOINTS {\n whoami = '/-/whoami',\n get_user = '/-/user/:org_couchdb_user',\n add_user = '/-/user/:org_couchdb_user{/:_rev}{/:revision}',\n user_token = '/-/user/token/{*subject}',\n}\n\nexport enum SEARCH_API_ENDPOINTS {\n search = '/-/v1/search',\n deprecated_search = '/-/all{/:since}',\n}\n\nexport enum PUBLISH_API_ENDPOINTS {\n add_package = '/:package',\n publish_package = '/:package/-rev/:revision',\n remove_tarball = '/:package/-/:filename/-rev/:revision',\n}\n\n/**\n * Staged publish workflow (`npm stage`), matching the routes npmjs documents.\n *\n * | Method | Route | Command |\n * | -------- | ------------------------------ | -------------------- |\n * | `POST` | `/-/stage/package/:package` | `npm stage publish` |\n * | `GET` | `/-/stage` | `npm stage list` |\n * | `GET` | `/-/stage/:stageId` | `npm stage view` |\n * | `GET` | `/-/stage/:stageId/tarball` | `npm stage download` |\n * | `POST` | `/-/stage/:stageId/approve` | `npm stage approve` |\n * | `DELETE` | `/-/stage/:stageId` | `npm stage reject` |\n *\n * `list` accepts `package`, `page` and `perPage` as query parameters. All the\n * routes require authentication.\n *\n * The body of `stage_package` is the same packument a regular publish sends —\n * `libnpmpublish` builds the payload once and only swaps method and route — so\n * staging reuses every validation the publish path already performs.\n *\n * Two constraints on the shapes above:\n *\n * - `stage_package` must keep the literal `package` segment declared before the\n * `:stageId` routes, otherwise they swallow it.\n * - `:stageId` is constrained to a UUID, because the npm CLI validates the\n * format client side before it ever calls the registry.\n */\nexport enum STAGE_API_ENDPOINTS {\n list = '/-/stage',\n stage_package = '/-/stage/package/:package',\n item = '/-/stage/:stageId',\n approve = '/-/stage/:stageId/approve',\n tarball = '/-/stage/:stageId/tarball',\n}\n\nexport enum PING_API_ENDPOINTS {\n ping = '/-/ping',\n}\n\nexport enum PACKAGE_API_ENDPOINTS {\n get_package_by_version = '/:package{/:version}',\n get_package_tarball = '/:package/-/:filename',\n}\n\nexport enum DIST_TAGS_API_ENDPOINTS {\n tagging = '/:package/:tag',\n tagging_package = '/-/package/:package/dist-tags/:tag',\n get_dist_tags = '/-/package/:package/dist-tags',\n}\n\nexport enum PROFILE_API_ENDPOINTS {\n get_profile = '/-/npm/v1/user',\n}\n\nexport enum TOKEN_API_ENDPOINTS {\n get_tokens = '/-/npm/v1/tokens',\n delete_token = '/-/npm/v1/tokens/token/:tokenKey',\n}\n\nexport enum LOGIN_API_ENDPOINTS {\n login = '/-/v1/login',\n login_cli = '/-/v1/login_cli',\n login_cli_session = '/-/v1/login_cli/:sessionId',\n login_done = '/-/v1/done',\n login_done_session = '/-/v1/done/:sessionId',\n}\n"],"mappings":";AAAA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,YAAA;CACA,mBAAA,cAAA;CACA,mBAAA,cAAA;CACA,mBAAA,gBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,uBAAL,yBAAA,sBAAA;CACL,qBAAA,YAAA;CACA,qBAAA,uBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,iBAAA;CACA,sBAAA,qBAAA;CACA,sBAAA,oBAAA;;AACF,EAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAY,sBAAL,yBAAA,qBAAA;CACL,oBAAA,UAAA;CACA,oBAAA,mBAAA;CACA,oBAAA,UAAA;CACA,oBAAA,aAAA;CACA,oBAAA,aAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,4BAAA;CACA,sBAAA,yBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,0BAAL,yBAAA,yBAAA;CACL,wBAAA,aAAA;CACA,wBAAA,qBAAA;CACA,wBAAA,mBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,iBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,sBAAL,yBAAA,qBAAA;CACL,oBAAA,gBAAA;CACA,oBAAA,kBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,sBAAL,yBAAA,qBAAA;CACL,oBAAA,WAAA;CACA,oBAAA,eAAA;CACA,oBAAA,uBAAA;CACA,oBAAA,gBAAA;CACA,oBAAA,wBAAA;;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/middlewares/
|
|
1
|
+
//#region src/middlewares/api-urls.ts
|
|
2
2
|
var USER_API_ENDPOINTS = /* @__PURE__ */ function(USER_API_ENDPOINTS) {
|
|
3
3
|
USER_API_ENDPOINTS["whoami"] = "/-/whoami";
|
|
4
4
|
USER_API_ENDPOINTS["get_user"] = "/-/user/:org_couchdb_user";
|
|
@@ -86,4 +86,4 @@ var LOGIN_API_ENDPOINTS = /* @__PURE__ */ function(LOGIN_API_ENDPOINTS) {
|
|
|
86
86
|
//#endregion
|
|
87
87
|
export { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STAGE_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS };
|
|
88
88
|
|
|
89
|
-
//# sourceMappingURL=
|
|
89
|
+
//# sourceMappingURL=api-urls.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"api-urls.mjs","names":[],"sources":["../../src/middlewares/api-urls.ts"],"sourcesContent":["export enum USER_API_ENDPOINTS {\n whoami = '/-/whoami',\n get_user = '/-/user/:org_couchdb_user',\n add_user = '/-/user/:org_couchdb_user{/:_rev}{/:revision}',\n user_token = '/-/user/token/{*subject}',\n}\n\nexport enum SEARCH_API_ENDPOINTS {\n search = '/-/v1/search',\n deprecated_search = '/-/all{/:since}',\n}\n\nexport enum PUBLISH_API_ENDPOINTS {\n add_package = '/:package',\n publish_package = '/:package/-rev/:revision',\n remove_tarball = '/:package/-/:filename/-rev/:revision',\n}\n\n/**\n * Staged publish workflow (`npm stage`), matching the routes npmjs documents.\n *\n * | Method | Route | Command |\n * | -------- | ------------------------------ | -------------------- |\n * | `POST` | `/-/stage/package/:package` | `npm stage publish` |\n * | `GET` | `/-/stage` | `npm stage list` |\n * | `GET` | `/-/stage/:stageId` | `npm stage view` |\n * | `GET` | `/-/stage/:stageId/tarball` | `npm stage download` |\n * | `POST` | `/-/stage/:stageId/approve` | `npm stage approve` |\n * | `DELETE` | `/-/stage/:stageId` | `npm stage reject` |\n *\n * `list` accepts `package`, `page` and `perPage` as query parameters. All the\n * routes require authentication.\n *\n * The body of `stage_package` is the same packument a regular publish sends —\n * `libnpmpublish` builds the payload once and only swaps method and route — so\n * staging reuses every validation the publish path already performs.\n *\n * Two constraints on the shapes above:\n *\n * - `stage_package` must keep the literal `package` segment declared before the\n * `:stageId` routes, otherwise they swallow it.\n * - `:stageId` is constrained to a UUID, because the npm CLI validates the\n * format client side before it ever calls the registry.\n */\nexport enum STAGE_API_ENDPOINTS {\n list = '/-/stage',\n stage_package = '/-/stage/package/:package',\n item = '/-/stage/:stageId',\n approve = '/-/stage/:stageId/approve',\n tarball = '/-/stage/:stageId/tarball',\n}\n\nexport enum PING_API_ENDPOINTS {\n ping = '/-/ping',\n}\n\nexport enum PACKAGE_API_ENDPOINTS {\n get_package_by_version = '/:package{/:version}',\n get_package_tarball = '/:package/-/:filename',\n}\n\nexport enum DIST_TAGS_API_ENDPOINTS {\n tagging = '/:package/:tag',\n tagging_package = '/-/package/:package/dist-tags/:tag',\n get_dist_tags = '/-/package/:package/dist-tags',\n}\n\nexport enum PROFILE_API_ENDPOINTS {\n get_profile = '/-/npm/v1/user',\n}\n\nexport enum TOKEN_API_ENDPOINTS {\n get_tokens = '/-/npm/v1/tokens',\n delete_token = '/-/npm/v1/tokens/token/:tokenKey',\n}\n\nexport enum LOGIN_API_ENDPOINTS {\n login = '/-/v1/login',\n login_cli = '/-/v1/login_cli',\n login_cli_session = '/-/v1/login_cli/:sessionId',\n login_done = '/-/v1/done',\n login_done_session = '/-/v1/done/:sessionId',\n}\n"],"mappings":";AAAA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,YAAA;CACA,mBAAA,cAAA;CACA,mBAAA,cAAA;CACA,mBAAA,gBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,uBAAL,yBAAA,sBAAA;CACL,qBAAA,YAAA;CACA,qBAAA,uBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,iBAAA;CACA,sBAAA,qBAAA;CACA,sBAAA,oBAAA;;AACF,EAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAY,sBAAL,yBAAA,qBAAA;CACL,oBAAA,UAAA;CACA,oBAAA,mBAAA;CACA,oBAAA,UAAA;CACA,oBAAA,aAAA;CACA,oBAAA,aAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,4BAAA;CACA,sBAAA,yBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,0BAAL,yBAAA,yBAAA;CACL,wBAAA,aAAA;CACA,wBAAA,qBAAA;CACA,wBAAA,mBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,wBAAL,yBAAA,uBAAA;CACL,sBAAA,iBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,sBAAL,yBAAA,qBAAA;CACL,oBAAA,gBAAA;CACA,oBAAA,kBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,sBAAL,yBAAA,qBAAA;CACL,oBAAA,WAAA;CACA,oBAAA,eAAA;CACA,oBAAA,uBAAA;CACA,oBAAA,gBAAA;CACA,oBAAA,wBAAA;;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -43,7 +43,10 @@ var errorReportingMiddleware = (logger) => function errorReportingMiddleware(req
|
|
|
43
43
|
debug$1("send internal error %o", err);
|
|
44
44
|
res.status(_verdaccio_core.HTTP_STATUS.INTERNAL_ERROR);
|
|
45
45
|
next({ error: _verdaccio_core.API_ERROR.INTERNAL_SERVER_ERROR });
|
|
46
|
-
} else
|
|
46
|
+
} else {
|
|
47
|
+
debug$1("headers already sent, destroying response %o", err);
|
|
48
|
+
res.destroy(err);
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
51
|
};
|
|
49
52
|
debug$1("error report middleware end (skip next layer) next()");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../src/middlewares/error.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { HttpError } from 'http-errors';\nimport { isError, isNil, noop } from 'lodash-es';\n\nimport type { VerdaccioError } from '@verdaccio/core';\nimport { API_ERROR, HTTP_STATUS } from '@verdaccio/core';\nimport type { Logger } from '@verdaccio/types';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:error');\n\nexport const handleError = (logger: Logger) =>\n function handleError(\n err: HttpError,\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ) {\n debug('error handler init');\n if (isError(err)) {\n debug('is native error');\n if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n return next();\n }\n if (typeof res.locals.report_error !== 'function') {\n debug('is locals error report ref');\n // in case of very early error this middleware may not be loaded before error is generated\n // fixing that\n errorReportingMiddleware(logger)(req, res, noop);\n }\n debug('set locals error report ref');\n res.locals.report_error(err);\n } else {\n // Fall to Middleware.final\n debug('no error to report, jump next layer');\n return next(err);\n }\n };\n\n// Middleware\nexport const errorReportingMiddleware = (logger: Logger) =>\n function errorReportingMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n debug('error report middleware start');\n res.locals.report_error =\n res.locals.report_error ||\n function (err: VerdaccioError): void {\n if (err.status && err.status >= HTTP_STATUS.BAD_REQUEST && err.status < 600) {\n debug('is error > 409 %o', err?.status);\n if (isNil(res.headersSent) === false) {\n debug('send status %o', err?.status);\n res.status(err.status);\n debug('next layer %o', err?.message);\n next({ error: err.message || API_ERROR.UNKNOWN_ERROR });\n }\n } else {\n debug('is error < 409 %o', err?.status);\n logger.error({ err: err }, 'unexpected error: @{!err.message}\\n@{err.stack}');\n if (!res.status || !res.send) {\n // TODO: decide which debug keep\n logger.error('this is an error in express.js, please report this');\n debug('this is an error in express.js, please report this, destroy response %o', err);\n res.destroy();\n } else if (!res.headersSent) {\n debug('send internal error %o', err);\n res.status(HTTP_STATUS.INTERNAL_ERROR);\n next({ error: API_ERROR.INTERNAL_SERVER_ERROR });\n } else {\n //
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../src/middlewares/error.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { HttpError } from 'http-errors';\nimport { isError, isNil, noop } from 'lodash-es';\n\nimport type { VerdaccioError } from '@verdaccio/core';\nimport { API_ERROR, HTTP_STATUS } from '@verdaccio/core';\nimport type { Logger } from '@verdaccio/types';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:error');\n\nexport const handleError = (logger: Logger) =>\n function handleError(\n err: HttpError,\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ) {\n debug('error handler init');\n if (isError(err)) {\n debug('is native error');\n if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n return next();\n }\n if (typeof res.locals.report_error !== 'function') {\n debug('is locals error report ref');\n // in case of very early error this middleware may not be loaded before error is generated\n // fixing that\n errorReportingMiddleware(logger)(req, res, noop);\n }\n debug('set locals error report ref');\n res.locals.report_error(err);\n } else {\n // Fall to Middleware.final\n debug('no error to report, jump next layer');\n return next(err);\n }\n };\n\n// Middleware\nexport const errorReportingMiddleware = (logger: Logger) =>\n function errorReportingMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n debug('error report middleware start');\n res.locals.report_error =\n res.locals.report_error ||\n function (err: VerdaccioError): void {\n if (err.status && err.status >= HTTP_STATUS.BAD_REQUEST && err.status < 600) {\n debug('is error > 409 %o', err?.status);\n if (isNil(res.headersSent) === false) {\n debug('send status %o', err?.status);\n res.status(err.status);\n debug('next layer %o', err?.message);\n next({ error: err.message || API_ERROR.UNKNOWN_ERROR });\n }\n } else {\n debug('is error < 409 %o', err?.status);\n logger.error({ err: err }, 'unexpected error: @{!err.message}\\n@{err.stack}');\n if (!res.status || !res.send) {\n // TODO: decide which debug keep\n logger.error('this is an error in express.js, please report this');\n debug('this is an error in express.js, please report this, destroy response %o', err);\n res.destroy();\n } else if (!res.headersSent) {\n debug('send internal error %o', err);\n res.status(HTTP_STATUS.INTERNAL_ERROR);\n next({ error: API_ERROR.INTERNAL_SERVER_ERROR });\n } else {\n // Headers already sent: an error status can no longer be delivered,\n // so terminate the connection — leaving it open would make the\n // client wait forever on a response that will never complete.\n debug('headers already sent, destroying response %o', err);\n res.destroy(err);\n }\n }\n };\n\n debug('error report middleware end (skip next layer) next()');\n next();\n };\n"],"mappings":";;;;;;AAUA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,4BAA4B;AAErD,IAAa,eAAe,WAC1B,SAAS,YACP,KACA,KACA,KACA,MACA;CACA,QAAM,oBAAoB;CAC1B,KAAA,GAAI,UAAA,QAAA,CAAQ,GAAG,GAAG;EAChB,QAAM,iBAAiB;EACvB,IAAI,IAAI,SAAS,gBAAgB,IAAI,eAAe,gBAAA,YAAY,cAC9D,OAAO,KAAK;EAEd,IAAI,OAAO,IAAI,OAAO,iBAAiB,YAAY;GACjD,QAAM,4BAA4B;GAGlC,yBAAyB,MAAM,CAAC,CAAC,KAAK,KAAK,UAAA,IAAI;EACjD;EACA,QAAM,6BAA6B;EACnC,IAAI,OAAO,aAAa,GAAG;CAC7B,OAAO;EAEL,QAAM,qCAAqC;EAC3C,OAAO,KAAK,GAAG;CACjB;AACF;AAGF,IAAa,4BAA4B,WACvC,SAAS,yBACP,KACA,KACA,MACM;CACN,QAAM,+BAA+B;CACrC,IAAI,OAAO,eACT,IAAI,OAAO,gBACX,SAAU,KAA2B;EACnC,IAAI,IAAI,UAAU,IAAI,UAAU,gBAAA,YAAY,eAAe,IAAI,SAAS,KAAK;GAC3E,QAAM,qBAAqB,KAAK,MAAM;GACtC,KAAA,GAAI,UAAA,MAAA,CAAM,IAAI,WAAW,MAAM,OAAO;IACpC,QAAM,kBAAkB,KAAK,MAAM;IACnC,IAAI,OAAO,IAAI,MAAM;IACrB,QAAM,iBAAiB,KAAK,OAAO;IACnC,KAAK,EAAE,OAAO,IAAI,WAAW,gBAAA,UAAU,cAAc,CAAC;GACxD;EACF,OAAO;GACL,QAAM,qBAAqB,KAAK,MAAM;GACtC,OAAO,MAAM,EAAO,IAAI,GAAG,iDAAiD;GAC5E,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,MAAM;IAE5B,OAAO,MAAM,oDAAoD;IACjE,QAAM,2EAA2E,GAAG;IACpF,IAAI,QAAQ;GACd,OAAO,IAAI,CAAC,IAAI,aAAa;IAC3B,QAAM,0BAA0B,GAAG;IACnC,IAAI,OAAO,gBAAA,YAAY,cAAc;IACrC,KAAK,EAAE,OAAO,gBAAA,UAAU,sBAAsB,CAAC;GACjD,OAAO;IAIL,QAAM,gDAAgD,GAAG;IACzD,IAAI,QAAQ,GAAG;GACjB;EACF;CACF;CAEF,QAAM,sDAAsD;CAC5D,KAAK;AACP"}
|
|
@@ -41,7 +41,10 @@ var errorReportingMiddleware = (logger) => function errorReportingMiddleware(req
|
|
|
41
41
|
debug("send internal error %o", err);
|
|
42
42
|
res.status(HTTP_STATUS.INTERNAL_ERROR);
|
|
43
43
|
next({ error: API_ERROR.INTERNAL_SERVER_ERROR });
|
|
44
|
-
} else
|
|
44
|
+
} else {
|
|
45
|
+
debug("headers already sent, destroying response %o", err);
|
|
46
|
+
res.destroy(err);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
50
|
debug("error report middleware end (skip next layer) next()");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.mjs","names":[],"sources":["../../src/middlewares/error.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { HttpError } from 'http-errors';\nimport { isError, isNil, noop } from 'lodash-es';\n\nimport type { VerdaccioError } from '@verdaccio/core';\nimport { API_ERROR, HTTP_STATUS } from '@verdaccio/core';\nimport type { Logger } from '@verdaccio/types';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:error');\n\nexport const handleError = (logger: Logger) =>\n function handleError(\n err: HttpError,\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ) {\n debug('error handler init');\n if (isError(err)) {\n debug('is native error');\n if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n return next();\n }\n if (typeof res.locals.report_error !== 'function') {\n debug('is locals error report ref');\n // in case of very early error this middleware may not be loaded before error is generated\n // fixing that\n errorReportingMiddleware(logger)(req, res, noop);\n }\n debug('set locals error report ref');\n res.locals.report_error(err);\n } else {\n // Fall to Middleware.final\n debug('no error to report, jump next layer');\n return next(err);\n }\n };\n\n// Middleware\nexport const errorReportingMiddleware = (logger: Logger) =>\n function errorReportingMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n debug('error report middleware start');\n res.locals.report_error =\n res.locals.report_error ||\n function (err: VerdaccioError): void {\n if (err.status && err.status >= HTTP_STATUS.BAD_REQUEST && err.status < 600) {\n debug('is error > 409 %o', err?.status);\n if (isNil(res.headersSent) === false) {\n debug('send status %o', err?.status);\n res.status(err.status);\n debug('next layer %o', err?.message);\n next({ error: err.message || API_ERROR.UNKNOWN_ERROR });\n }\n } else {\n debug('is error < 409 %o', err?.status);\n logger.error({ err: err }, 'unexpected error: @{!err.message}\\n@{err.stack}');\n if (!res.status || !res.send) {\n // TODO: decide which debug keep\n logger.error('this is an error in express.js, please report this');\n debug('this is an error in express.js, please report this, destroy response %o', err);\n res.destroy();\n } else if (!res.headersSent) {\n debug('send internal error %o', err);\n res.status(HTTP_STATUS.INTERNAL_ERROR);\n next({ error: API_ERROR.INTERNAL_SERVER_ERROR });\n } else {\n //
|
|
1
|
+
{"version":3,"file":"error.mjs","names":[],"sources":["../../src/middlewares/error.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { HttpError } from 'http-errors';\nimport { isError, isNil, noop } from 'lodash-es';\n\nimport type { VerdaccioError } from '@verdaccio/core';\nimport { API_ERROR, HTTP_STATUS } from '@verdaccio/core';\nimport type { Logger } from '@verdaccio/types';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:error');\n\nexport const handleError = (logger: Logger) =>\n function handleError(\n err: HttpError,\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ) {\n debug('error handler init');\n if (isError(err)) {\n debug('is native error');\n if (err.code === 'ECONNABORT' && res.statusCode === HTTP_STATUS.NOT_MODIFIED) {\n return next();\n }\n if (typeof res.locals.report_error !== 'function') {\n debug('is locals error report ref');\n // in case of very early error this middleware may not be loaded before error is generated\n // fixing that\n errorReportingMiddleware(logger)(req, res, noop);\n }\n debug('set locals error report ref');\n res.locals.report_error(err);\n } else {\n // Fall to Middleware.final\n debug('no error to report, jump next layer');\n return next(err);\n }\n };\n\n// Middleware\nexport const errorReportingMiddleware = (logger: Logger) =>\n function errorReportingMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n debug('error report middleware start');\n res.locals.report_error =\n res.locals.report_error ||\n function (err: VerdaccioError): void {\n if (err.status && err.status >= HTTP_STATUS.BAD_REQUEST && err.status < 600) {\n debug('is error > 409 %o', err?.status);\n if (isNil(res.headersSent) === false) {\n debug('send status %o', err?.status);\n res.status(err.status);\n debug('next layer %o', err?.message);\n next({ error: err.message || API_ERROR.UNKNOWN_ERROR });\n }\n } else {\n debug('is error < 409 %o', err?.status);\n logger.error({ err: err }, 'unexpected error: @{!err.message}\\n@{err.stack}');\n if (!res.status || !res.send) {\n // TODO: decide which debug keep\n logger.error('this is an error in express.js, please report this');\n debug('this is an error in express.js, please report this, destroy response %o', err);\n res.destroy();\n } else if (!res.headersSent) {\n debug('send internal error %o', err);\n res.status(HTTP_STATUS.INTERNAL_ERROR);\n next({ error: API_ERROR.INTERNAL_SERVER_ERROR });\n } else {\n // Headers already sent: an error status can no longer be delivered,\n // so terminate the connection — leaving it open would make the\n // client wait forever on a response that will never complete.\n debug('headers already sent, destroying response %o', err);\n res.destroy(err);\n }\n }\n };\n\n debug('error report middleware end (skip next layer) next()');\n next();\n };\n"],"mappings":";;;;AAUA,IAAM,QAAQ,WAAW,4BAA4B;AAErD,IAAa,eAAe,WAC1B,SAAS,YACP,KACA,KACA,KACA,MACA;CACA,MAAM,oBAAoB;CAC1B,IAAI,QAAQ,GAAG,GAAG;EAChB,MAAM,iBAAiB;EACvB,IAAI,IAAI,SAAS,gBAAgB,IAAI,eAAe,YAAY,cAC9D,OAAO,KAAK;EAEd,IAAI,OAAO,IAAI,OAAO,iBAAiB,YAAY;GACjD,MAAM,4BAA4B;GAGlC,yBAAyB,MAAM,CAAC,CAAC,KAAK,KAAK,IAAI;EACjD;EACA,MAAM,6BAA6B;EACnC,IAAI,OAAO,aAAa,GAAG;CAC7B,OAAO;EAEL,MAAM,qCAAqC;EAC3C,OAAO,KAAK,GAAG;CACjB;AACF;AAGF,IAAa,4BAA4B,WACvC,SAAS,yBACP,KACA,KACA,MACM;CACN,MAAM,+BAA+B;CACrC,IAAI,OAAO,eACT,IAAI,OAAO,gBACX,SAAU,KAA2B;EACnC,IAAI,IAAI,UAAU,IAAI,UAAU,YAAY,eAAe,IAAI,SAAS,KAAK;GAC3E,MAAM,qBAAqB,KAAK,MAAM;GACtC,IAAI,MAAM,IAAI,WAAW,MAAM,OAAO;IACpC,MAAM,kBAAkB,KAAK,MAAM;IACnC,IAAI,OAAO,IAAI,MAAM;IACrB,MAAM,iBAAiB,KAAK,OAAO;IACnC,KAAK,EAAE,OAAO,IAAI,WAAW,UAAU,cAAc,CAAC;GACxD;EACF,OAAO;GACL,MAAM,qBAAqB,KAAK,MAAM;GACtC,OAAO,MAAM,EAAO,IAAI,GAAG,iDAAiD;GAC5E,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,MAAM;IAE5B,OAAO,MAAM,oDAAoD;IACjE,MAAM,2EAA2E,GAAG;IACpF,IAAI,QAAQ;GACd,OAAO,IAAI,CAAC,IAAI,aAAa;IAC3B,MAAM,0BAA0B,GAAG;IACnC,IAAI,OAAO,YAAY,cAAc;IACrC,KAAK,EAAE,OAAO,UAAU,sBAAsB,CAAC;GACjD,OAAO;IAIL,MAAM,gDAAgD,GAAG;IACzD,IAAI,QAAQ,GAAG;GACjB;EACF;CACF;CAEF,MAAM,sDAAsD;CAC5D,KAAK;AACP"}
|
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.31",
|
|
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.31",
|
|
37
|
+
"@verdaccio/core": "9.0.0-next-9.31",
|
|
38
|
+
"@verdaccio/url": "14.0.0-next-9.31",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
40
|
"express": "5.2.1",
|
|
41
41
|
"express-rate-limit": "8.6.0",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/lodash-es": "4.17.12",
|
|
51
|
-
"@verdaccio/logger": "9.0.0-next-9.
|
|
52
|
-
"@verdaccio/types": "14.0.0-next-9.
|
|
51
|
+
"@verdaccio/logger": "9.0.0-next-9.31",
|
|
52
|
+
"@verdaccio/types": "14.0.0-next-9.14",
|
|
53
53
|
"http-errors": "2.0.1",
|
|
54
54
|
"rimraf": "6.1.3",
|
|
55
55
|
"supertest": "7.1.4",
|
|
56
|
-
"vite": "8.2.
|
|
56
|
+
"vite": "8.2.2",
|
|
57
57
|
"vitest": "4.1.10"
|
|
58
58
|
},
|
|
59
59
|
"module": "./build/index.mjs",
|
|
File without changes
|