@verdaccio/middleware 9.0.0-next-9.26 → 9.0.0-next-9.28
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.
|
@@ -8,7 +8,7 @@ var debug$1 = (0, debug.default)("verdaccio:middleware:final");
|
|
|
8
8
|
function final(body, req, res, next) {
|
|
9
9
|
if (res.statusCode === _verdaccio_core.HTTP_STATUS.UNAUTHORIZED && !res.getHeader(_verdaccio_core.HEADERS.WWW_AUTH)) {
|
|
10
10
|
debug$1("set auth header support");
|
|
11
|
-
res.header(_verdaccio_core.HEADERS.WWW_AUTH,
|
|
11
|
+
res.header(_verdaccio_core.HEADERS.WWW_AUTH, _verdaccio_core.TOKEN_BEARER);
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
if (typeof body === "string" || (0, lodash_es.isObject)(body)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"final.js","names":[],"sources":["../../src/middlewares/final.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { isNil, isObject } from 'lodash-es';\n\nimport { HEADERS, HTTP_STATUS,
|
|
1
|
+
{"version":3,"file":"final.js","names":[],"sources":["../../src/middlewares/final.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { isNil, isObject } from 'lodash-es';\n\nimport { HEADERS, HTTP_STATUS, TOKEN_BEARER, cryptoUtils } from '@verdaccio/core';\nimport type { Manifest } from '@verdaccio/types';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend, MiddlewareError } from '../types';\n\nexport type FinalBody = Manifest | MiddlewareError | string;\n\nconst debug = buildDebug('verdaccio:middleware:final');\n\nexport function final(\n body: FinalBody,\n req: $RequestExtend,\n res: $ResponseExtend,\n // if we remove `next` breaks test\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n next: $NextFunctionVer\n): void {\n if (res.statusCode === HTTP_STATUS.UNAUTHORIZED && !res.getHeader(HEADERS.WWW_AUTH)) {\n debug('set auth header support');\n res.header(HEADERS.WWW_AUTH, TOKEN_BEARER);\n }\n\n try {\n if (typeof body === 'string' || isObject(body)) {\n if (!res.get(HEADERS.CONTENT_TYPE)) {\n debug('set json type header support');\n res.header(HEADERS.CONTENT_TYPE, HEADERS.JSON);\n }\n\n if (typeof body === 'object' && isNil(body) === false) {\n if (typeof (body as MiddlewareError).error === 'string') {\n debug('set verdaccio_error method');\n res.locals._verdaccio_error = (body as MiddlewareError).error;\n }\n body = JSON.stringify(body, undefined, ' ') + '\\n';\n }\n\n // don't send etags with errors\n if (\n !res.statusCode ||\n (res.statusCode >= HTTP_STATUS.OK && res.statusCode < HTTP_STATUS.MULTIPLE_CHOICES)\n ) {\n const etag = cryptoUtils.stringToMD5(body as string);\n debug('set etag header %s', etag);\n res.header(HEADERS.ETAG, '\"' + etag + '\"');\n }\n } else {\n debug('this line should never be visible, if does report');\n // send(null), send(204), etc.\n }\n } catch (err: any) {\n // if verdaccio sends headers first, and then calls res.send()\n // as an error handler, we can't report error properly,\n // and should just close socket\n if (err.message.match(/set headers after they are sent/)) {\n debug('set headers after they are sent');\n if (isNil(res.socket) === false) {\n debug('force destroy socket');\n res.socket?.destroy();\n }\n return;\n }\n throw err;\n }\n\n res.send(body);\n}\n"],"mappings":";;;;;;AAUA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,4BAA4B;AAErD,SAAgB,MACd,MACA,KACA,KAGA,MACM;CACN,IAAI,IAAI,eAAe,gBAAA,YAAY,gBAAgB,CAAC,IAAI,UAAU,gBAAA,QAAQ,QAAQ,GAAG;EACnF,QAAM,yBAAyB;EAC/B,IAAI,OAAO,gBAAA,QAAQ,UAAU,gBAAA,YAAY;CAC3C;CAEA,IAAI;EACF,IAAI,OAAO,SAAS,aAAA,GAAY,UAAA,SAAA,CAAS,IAAI,GAAG;GAC9C,IAAI,CAAC,IAAI,IAAI,gBAAA,QAAQ,YAAY,GAAG;IAClC,QAAM,8BAA8B;IACpC,IAAI,OAAO,gBAAA,QAAQ,cAAc,gBAAA,QAAQ,IAAI;GAC/C;GAEA,IAAI,OAAO,SAAS,aAAA,GAAY,UAAA,MAAA,CAAM,IAAI,MAAM,OAAO;IACrD,IAAI,OAAQ,KAAyB,UAAU,UAAU;KACvD,QAAM,4BAA4B;KAClC,IAAI,OAAO,mBAAoB,KAAyB;IAC1D;IACA,OAAO,KAAK,UAAU,MAAM,KAAA,GAAW,IAAI,IAAI;GACjD;GAGA,IACE,CAAC,IAAI,cACJ,IAAI,cAAc,gBAAA,YAAY,MAAM,IAAI,aAAa,gBAAA,YAAY,kBAClE;IACA,MAAM,OAAO,gBAAA,YAAY,YAAY,IAAc;IACnD,QAAM,sBAAsB,IAAI;IAChC,IAAI,OAAO,gBAAA,QAAQ,MAAM,OAAM,OAAO,IAAG;GAC3C;EACF,OACE,QAAM,mDAAmD;CAG7D,SAAS,KAAU;EAIjB,IAAI,IAAI,QAAQ,MAAM,iCAAiC,GAAG;GACxD,QAAM,iCAAiC;GACvC,KAAA,GAAI,UAAA,MAAA,CAAM,IAAI,MAAM,MAAM,OAAO;IAC/B,QAAM,sBAAsB;IAC5B,IAAI,QAAQ,QAAQ;GACtB;GACA;EACF;EACA,MAAM;CACR;CAEA,IAAI,KAAK,IAAI;AACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HEADERS, HTTP_STATUS,
|
|
1
|
+
import { HEADERS, HTTP_STATUS, TOKEN_BEARER, cryptoUtils } from "@verdaccio/core";
|
|
2
2
|
import buildDebug from "debug";
|
|
3
3
|
import { isNil, isObject } from "lodash-es";
|
|
4
4
|
//#region src/middlewares/final.ts
|
|
@@ -6,7 +6,7 @@ var debug = buildDebug("verdaccio:middleware:final");
|
|
|
6
6
|
function final(body, req, res, next) {
|
|
7
7
|
if (res.statusCode === HTTP_STATUS.UNAUTHORIZED && !res.getHeader(HEADERS.WWW_AUTH)) {
|
|
8
8
|
debug("set auth header support");
|
|
9
|
-
res.header(HEADERS.WWW_AUTH,
|
|
9
|
+
res.header(HEADERS.WWW_AUTH, TOKEN_BEARER);
|
|
10
10
|
}
|
|
11
11
|
try {
|
|
12
12
|
if (typeof body === "string" || isObject(body)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"final.mjs","names":[],"sources":["../../src/middlewares/final.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { isNil, isObject } from 'lodash-es';\n\nimport { HEADERS, HTTP_STATUS,
|
|
1
|
+
{"version":3,"file":"final.mjs","names":[],"sources":["../../src/middlewares/final.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { isNil, isObject } from 'lodash-es';\n\nimport { HEADERS, HTTP_STATUS, TOKEN_BEARER, cryptoUtils } from '@verdaccio/core';\nimport type { Manifest } from '@verdaccio/types';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend, MiddlewareError } from '../types';\n\nexport type FinalBody = Manifest | MiddlewareError | string;\n\nconst debug = buildDebug('verdaccio:middleware:final');\n\nexport function final(\n body: FinalBody,\n req: $RequestExtend,\n res: $ResponseExtend,\n // if we remove `next` breaks test\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n next: $NextFunctionVer\n): void {\n if (res.statusCode === HTTP_STATUS.UNAUTHORIZED && !res.getHeader(HEADERS.WWW_AUTH)) {\n debug('set auth header support');\n res.header(HEADERS.WWW_AUTH, TOKEN_BEARER);\n }\n\n try {\n if (typeof body === 'string' || isObject(body)) {\n if (!res.get(HEADERS.CONTENT_TYPE)) {\n debug('set json type header support');\n res.header(HEADERS.CONTENT_TYPE, HEADERS.JSON);\n }\n\n if (typeof body === 'object' && isNil(body) === false) {\n if (typeof (body as MiddlewareError).error === 'string') {\n debug('set verdaccio_error method');\n res.locals._verdaccio_error = (body as MiddlewareError).error;\n }\n body = JSON.stringify(body, undefined, ' ') + '\\n';\n }\n\n // don't send etags with errors\n if (\n !res.statusCode ||\n (res.statusCode >= HTTP_STATUS.OK && res.statusCode < HTTP_STATUS.MULTIPLE_CHOICES)\n ) {\n const etag = cryptoUtils.stringToMD5(body as string);\n debug('set etag header %s', etag);\n res.header(HEADERS.ETAG, '\"' + etag + '\"');\n }\n } else {\n debug('this line should never be visible, if does report');\n // send(null), send(204), etc.\n }\n } catch (err: any) {\n // if verdaccio sends headers first, and then calls res.send()\n // as an error handler, we can't report error properly,\n // and should just close socket\n if (err.message.match(/set headers after they are sent/)) {\n debug('set headers after they are sent');\n if (isNil(res.socket) === false) {\n debug('force destroy socket');\n res.socket?.destroy();\n }\n return;\n }\n throw err;\n }\n\n res.send(body);\n}\n"],"mappings":";;;;AAUA,IAAM,QAAQ,WAAW,4BAA4B;AAErD,SAAgB,MACd,MACA,KACA,KAGA,MACM;CACN,IAAI,IAAI,eAAe,YAAY,gBAAgB,CAAC,IAAI,UAAU,QAAQ,QAAQ,GAAG;EACnF,MAAM,yBAAyB;EAC/B,IAAI,OAAO,QAAQ,UAAU,YAAY;CAC3C;CAEA,IAAI;EACF,IAAI,OAAO,SAAS,YAAY,SAAS,IAAI,GAAG;GAC9C,IAAI,CAAC,IAAI,IAAI,QAAQ,YAAY,GAAG;IAClC,MAAM,8BAA8B;IACpC,IAAI,OAAO,QAAQ,cAAc,QAAQ,IAAI;GAC/C;GAEA,IAAI,OAAO,SAAS,YAAY,MAAM,IAAI,MAAM,OAAO;IACrD,IAAI,OAAQ,KAAyB,UAAU,UAAU;KACvD,MAAM,4BAA4B;KAClC,IAAI,OAAO,mBAAoB,KAAyB;IAC1D;IACA,OAAO,KAAK,UAAU,MAAM,KAAA,GAAW,IAAI,IAAI;GACjD;GAGA,IACE,CAAC,IAAI,cACJ,IAAI,cAAc,YAAY,MAAM,IAAI,aAAa,YAAY,kBAClE;IACA,MAAM,OAAO,YAAY,YAAY,IAAc;IACnD,MAAM,sBAAsB,IAAI;IAChC,IAAI,OAAO,QAAQ,MAAM,OAAM,OAAO,IAAG;GAC3C;EACF,OACE,MAAM,mDAAmD;CAG7D,SAAS,KAAU;EAIjB,IAAI,IAAI,QAAQ,MAAM,iCAAiC,GAAG;GACxD,MAAM,iCAAiC;GACvC,IAAI,MAAM,IAAI,MAAM,MAAM,OAAO;IAC/B,MAAM,sBAAsB;IAC5B,IAAI,QAAQ,QAAQ;GACtB;GACA;EACF;EACA,MAAM;CACR;CAEA,IAAI,KAAK,IAAI;AACf"}
|
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.28",
|
|
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.28",
|
|
37
|
+
"@verdaccio/core": "9.0.0-next-9.28",
|
|
38
|
+
"@verdaccio/url": "14.0.0-next-9.28",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
40
|
"express": "5.2.1",
|
|
41
41
|
"express-rate-limit": "8.6.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/lodash-es": "4.17.12",
|
|
51
|
-
"@verdaccio/logger": "9.0.0-next-9.
|
|
51
|
+
"@verdaccio/logger": "9.0.0-next-9.28",
|
|
52
52
|
"@verdaccio/types": "14.0.0-next-9.12",
|
|
53
53
|
"http-errors": "2.0.1",
|
|
54
54
|
"rimraf": "6.1.3",
|