@verdaccio/middleware 9.0.0-next-9.3 → 9.0.0-next-9.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.
Files changed (127) hide show
  1. package/build/_virtual/_rolldown/runtime.js +23 -0
  2. package/build/index.js +60 -221
  3. package/build/index.mjs +22 -0
  4. package/build/middlewares/allow.js +42 -50
  5. package/build/middlewares/allow.js.map +1 -1
  6. package/build/middlewares/allow.mjs +44 -0
  7. package/build/middlewares/allow.mjs.map +1 -0
  8. package/build/middlewares/antiLoop.d.ts +2 -2
  9. package/build/middlewares/antiLoop.js +22 -40
  10. package/build/middlewares/antiLoop.js.map +1 -1
  11. package/build/middlewares/antiLoop.mjs +25 -0
  12. package/build/middlewares/antiLoop.mjs.map +1 -0
  13. package/build/middlewares/api_urls.js +66 -59
  14. package/build/middlewares/api_urls.js.map +1 -1
  15. package/build/middlewares/api_urls.mjs +59 -0
  16. package/build/middlewares/api_urls.mjs.map +1 -0
  17. package/build/middlewares/dotfiles.d.ts +1 -1
  18. package/build/middlewares/dotfiles.js +25 -28
  19. package/build/middlewares/dotfiles.js.map +1 -1
  20. package/build/middlewares/dotfiles.mjs +27 -0
  21. package/build/middlewares/dotfiles.mjs.map +1 -0
  22. package/build/middlewares/encode-pkg.d.ts +1 -1
  23. package/build/middlewares/encode-pkg.js +20 -36
  24. package/build/middlewares/encode-pkg.js.map +1 -1
  25. package/build/middlewares/encode-pkg.mjs +22 -0
  26. package/build/middlewares/encode-pkg.mjs.map +1 -0
  27. package/build/middlewares/error.d.ts +3 -3
  28. package/build/middlewares/error.js +53 -71
  29. package/build/middlewares/error.js.map +1 -1
  30. package/build/middlewares/error.mjs +53 -0
  31. package/build/middlewares/error.mjs.map +1 -0
  32. package/build/middlewares/final.d.ts +2 -2
  33. package/build/middlewares/final.js +46 -57
  34. package/build/middlewares/final.js.map +1 -1
  35. package/build/middlewares/final.mjs +46 -0
  36. package/build/middlewares/final.mjs.map +1 -0
  37. package/build/middlewares/json.d.ts +1 -1
  38. package/build/middlewares/json.js +8 -11
  39. package/build/middlewares/json.js.map +1 -1
  40. package/build/middlewares/json.mjs +10 -0
  41. package/build/middlewares/json.mjs.map +1 -0
  42. package/build/middlewares/log.d.ts +1 -1
  43. package/build/middlewares/log.js +97 -125
  44. package/build/middlewares/log.js.map +1 -1
  45. package/build/middlewares/log.mjs +96 -0
  46. package/build/middlewares/log.mjs.map +1 -0
  47. package/build/middlewares/make-url-relative.d.ts +1 -1
  48. package/build/middlewares/make-url-relative.js +26 -41
  49. package/build/middlewares/make-url-relative.js.map +1 -1
  50. package/build/middlewares/make-url-relative.mjs +28 -0
  51. package/build/middlewares/make-url-relative.mjs.map +1 -0
  52. package/build/middlewares/match.js +8 -13
  53. package/build/middlewares/match.js.map +1 -1
  54. package/build/middlewares/match.mjs +11 -0
  55. package/build/middlewares/match.mjs.map +1 -0
  56. package/build/middlewares/media.js +15 -19
  57. package/build/middlewares/media.js.map +1 -1
  58. package/build/middlewares/media.mjs +17 -0
  59. package/build/middlewares/media.mjs.map +1 -0
  60. package/build/middlewares/rate-limit.d.ts +2 -2
  61. package/build/middlewares/rate-limit.js +8 -10
  62. package/build/middlewares/rate-limit.js.map +1 -1
  63. package/build/middlewares/rate-limit.mjs +9 -0
  64. package/build/middlewares/rate-limit.mjs.map +1 -0
  65. package/build/middlewares/request-options.d.ts +2 -2
  66. package/build/middlewares/request-options.js +18 -27
  67. package/build/middlewares/request-options.js.map +1 -1
  68. package/build/middlewares/request-options.mjs +19 -0
  69. package/build/middlewares/request-options.mjs.map +1 -0
  70. package/build/middlewares/user-agent.d.ts +1 -1
  71. package/build/middlewares/user-agent.js +11 -12
  72. package/build/middlewares/user-agent.js.map +1 -1
  73. package/build/middlewares/user-agent.mjs +13 -0
  74. package/build/middlewares/user-agent.mjs.map +1 -0
  75. package/build/middlewares/validation.d.ts +1 -1
  76. package/build/middlewares/validation.js +11 -18
  77. package/build/middlewares/validation.js.map +1 -1
  78. package/build/middlewares/validation.mjs +14 -0
  79. package/build/middlewares/validation.mjs.map +1 -0
  80. package/build/middlewares/web/index.js +4 -35
  81. package/build/middlewares/web/index.mjs +4 -0
  82. package/build/middlewares/web/render-web.d.ts +1 -1
  83. package/build/middlewares/web/render-web.js +80 -109
  84. package/build/middlewares/web/render-web.js.map +1 -1
  85. package/build/middlewares/web/render-web.mjs +79 -0
  86. package/build/middlewares/web/render-web.mjs.map +1 -0
  87. package/build/middlewares/web/security.js +29 -41
  88. package/build/middlewares/web/security.js.map +1 -1
  89. package/build/middlewares/web/security.mjs +30 -0
  90. package/build/middlewares/web/security.mjs.map +1 -0
  91. package/build/middlewares/web/utils/manifest.js +17 -18
  92. package/build/middlewares/web/utils/manifest.js.map +1 -1
  93. package/build/middlewares/web/utils/manifest.mjs +21 -0
  94. package/build/middlewares/web/utils/manifest.mjs.map +1 -0
  95. package/build/middlewares/web/utils/renderHTML.d.ts +5 -5
  96. package/build/middlewares/web/utils/renderHTML.js +109 -136
  97. package/build/middlewares/web/utils/renderHTML.js.map +1 -1
  98. package/build/middlewares/web/utils/renderHTML.mjs +113 -0
  99. package/build/middlewares/web/utils/renderHTML.mjs.map +1 -0
  100. package/build/middlewares/web/utils/template.d.ts +2 -2
  101. package/build/middlewares/web/utils/template.js +19 -20
  102. package/build/middlewares/web/utils/template.js.map +1 -1
  103. package/build/middlewares/web/utils/template.mjs +35 -0
  104. package/build/middlewares/web/utils/template.mjs.map +1 -0
  105. package/build/middlewares/web/utils/web-utils.js +17 -18
  106. package/build/middlewares/web/utils/web-utils.js.map +1 -1
  107. package/build/middlewares/web/utils/web-utils.mjs +18 -0
  108. package/build/middlewares/web/utils/web-utils.mjs.map +1 -0
  109. package/build/middlewares/web/web-api.d.ts +1 -2
  110. package/build/middlewares/web/web-api.js +18 -27
  111. package/build/middlewares/web/web-api.js.map +1 -1
  112. package/build/middlewares/web/web-api.mjs +19 -0
  113. package/build/middlewares/web/web-api.mjs.map +1 -0
  114. package/build/middlewares/web/web-middleware.js +16 -23
  115. package/build/middlewares/web/web-middleware.js.map +1 -1
  116. package/build/middlewares/web/web-middleware.mjs +16 -0
  117. package/build/middlewares/web/web-middleware.mjs.map +1 -0
  118. package/build/middlewares/web/web-urls.js +28 -29
  119. package/build/middlewares/web/web-urls.js.map +1 -1
  120. package/build/middlewares/web/web-urls.mjs +32 -0
  121. package/build/middlewares/web/web-urls.mjs.map +1 -0
  122. package/build/types.d.ts +2 -2
  123. package/package.json +22 -11
  124. package/build/index.js.map +0 -1
  125. package/build/middlewares/web/index.js.map +0 -1
  126. package/build/types.js +0 -6
  127. package/build/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","names":["_debug","_interopRequireDefault","require","_lodash","_core","e","__esModule","default","debug","buildDebug","isStaticRequest","url","startsWith","LOG_STATUS_MESSAGE","exports","LOG_VERDACCIO_ERROR","LOG_VERDACCIO_BYTES","log","logger","options","hideStaticLogs","req","res","next","child","sub","_auth","headers","authorization","_","isNil","_cookie","get","cookie","originalUrl","_skipLog","ip","info","bytesin","on","chunk","length","bytesout","_write","write","args","apply","forwardedFor","HEADERS","FORWARDED_FOR","remoteAddress","socket","remoteIP","message","locals","_verdaccio_error","request","method","user","remote_user","name","status","statusCode","error","bytes","in","out","http","_end","end"],"sources":["../../src/middlewares/log.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { HEADERS } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:log');\n\nfunction isStaticRequest(url: string): boolean {\n return url.startsWith('/-/static/');\n}\n\n// FIXME: deprecated, moved to @verdaccio/dev-commons\nexport const LOG_STATUS_MESSAGE =\n \"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'\";\nexport const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;\nexport const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;\n\nexport type LogOptions = {\n // When true, static file requests (/-/static/*) are hidden from pino logs\n // and only visible via DEBUG=verdaccio:middleware:log. Defaults to true.\n hideStaticLogs?: boolean;\n};\n\nexport const log = (logger, options: LogOptions = {}) => {\n const { hideStaticLogs = true } = options;\n\n return function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n // logger\n req.log = logger.child({ sub: 'in' });\n\n const _auth = req.headers.authorization;\n if (_.isNil(_auth) === false) {\n req.headers.authorization = '<Classified>';\n }\n\n const _cookie = req.get('cookie');\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = '<Classified>';\n }\n\n req.url = req.originalUrl;\n const _skipLog = hideStaticLogs && isStaticRequest(req.url);\n if (_skipLog) {\n debug(\"@{ip} requested '@{req.method} @{req.url}'\", { ip: req.ip, req });\n } else {\n req.log.info({ req: req, ip: req.ip }, \"@{ip} requested '@{req.method} @{req.url}'\");\n }\n req.originalUrl = req.url;\n\n if (_.isNil(_auth) === false) {\n req.headers.authorization = _auth;\n }\n\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = _cookie;\n }\n\n let bytesin = 0;\n req.on('data', function (chunk): void {\n bytesin += chunk.length;\n });\n\n let bytesout = 0;\n const _write = res.write;\n // @ts-ignore\n res.write = function (...args): boolean {\n bytesout += args[0]?.length || 0;\n // @ts-ignore\n return _write.apply(res, args);\n };\n\n const log = function (): void {\n const forwardedFor = req.get(HEADERS.FORWARDED_FOR);\n const remoteAddress = req.socket.remoteAddress;\n const remoteIP = forwardedFor ? `${forwardedFor} via ${remoteAddress}` : remoteAddress;\n let message;\n if (res.locals._verdaccio_error) {\n message = LOG_VERDACCIO_ERROR;\n } else {\n message = LOG_VERDACCIO_BYTES;\n }\n\n req.url = req.originalUrl;\n if (_skipLog) {\n debug(message, {\n request: { method: req.method, url: req.url },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: { in: bytesin, out: bytesout },\n });\n } else {\n req.log.http(\n {\n request: {\n method: req.method,\n url: req.url,\n },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: {\n in: bytesin,\n out: bytesout,\n },\n },\n message\n );\n }\n req.originalUrl = req.url;\n };\n\n req.on('close', function (): void {\n log();\n });\n\n const _end = res.end;\n // @ts-ignore\n res.end = function (...args): void {\n if (args[0]) {\n bytesout += args[0].length;\n }\n // @ts-ignore\n _end.apply(res, args);\n log();\n };\n next();\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA0C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI1C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AAEpD,SAASC,eAAeA,CAACC,GAAW,EAAW;EAC7C,OAAOA,GAAG,CAACC,UAAU,CAAC,YAAY,CAAC;AACrC;;AAEA;AACO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAC7B,gFAAgF;AAC3E,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,GAAGF,kBAAkB,oBAAoB;AACrE,MAAMG,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG,GAAGH,kBAAkB,mCAAmC;AAQpF,MAAMI,GAAG,GAAGA,CAACC,MAAM,EAAEC,OAAmB,GAAG,CAAC,CAAC,KAAK;EACvD,MAAM;IAAEC,cAAc,GAAG;EAAK,CAAC,GAAGD,OAAO;EAEzC,OAAO,SAASF,GAAGA,CAACI,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IAC3F;IACAF,GAAG,CAACJ,GAAG,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EAAE,EAAE3B,OAAO;YAAE4B,GAAG,EAAExB;UAAS;QACtC,CAAC,CAAC;MACJ,CAAC,MAAM;QACLrB,GAAG,CAACJ,GAAG,CAACkD,IAAI,CACV;UACEX,OAAO,EAAE;YACPC,MAAM,EAAEpC,GAAG,CAACoC,MAAM;YAClB9C,GAAG,EAAEU,GAAG,CAACV;UACX,CAAC;UACD+C,IAAI,EAAErC,GAAG,CAACsC,WAAW,EAAEC,IAAI,IAAI,IAAI;UACnCR,QAAQ;UACRS,MAAM,EAAEvC,GAAG,CAACwC,UAAU;UACtBC,KAAK,EAAEzC,GAAG,CAACgC,MAAM,CAACC,gBAAgB;UAClCS,KAAK,EAAE;YACLC,EAAE,EAAE3B,OAAO;YACX4B,GAAG,EAAExB;UACP;QACF,CAAC,EACDW,OACF,CAAC;MACH;MACAhC,GAAG,CAACa,WAAW,GAAGb,GAAG,CAACV,GAAG;IAC3B,CAAC;IAEDU,GAAG,CAACkB,EAAE,CAAC,OAAO,EAAE,YAAkB;MAChCtB,GAAG,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,MAAMmD,IAAI,GAAG9C,GAAG,CAAC+C,GAAG;IACpB;IACA/C,GAAG,CAAC+C,GAAG,GAAG,UAAU,GAAGxB,IAAI,EAAQ;MACjC,IAAIA,IAAI,CAAC,CAAC,CAAC,EAAE;QACXH,QAAQ,IAAIG,IAAI,CAAC,CAAC,CAAC,CAACJ,MAAM;MAC5B;MACA;MACA2B,IAAI,CAACtB,KAAK,CAACxB,GAAG,EAAEuB,IAAI,CAAC;MACrB5B,GAAG,CAAC,CAAC;IACP,CAAC;IACDM,IAAI,CAAC,CAAC;EACR,CAAC;AACH,CAAC;AAACT,OAAA,CAAAG,GAAA,GAAAA,GAAA","ignoreList":[]}
1
+ {"version":3,"file":"log.js","names":[],"sources":["../../src/middlewares/log.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { HEADERS } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:log');\n\nfunction isStaticRequest(url: string): boolean {\n return url.startsWith('/-/static/');\n}\n\n// FIXME: deprecated, moved to @verdaccio/dev-commons\nexport const LOG_STATUS_MESSAGE =\n \"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'\";\nexport const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;\nexport const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;\n\nexport type LogOptions = {\n // When true, static file requests (/-/static/*) are hidden from pino logs\n // and only visible via DEBUG=verdaccio:middleware:log. Defaults to true.\n hideStaticLogs?: boolean;\n};\n\nexport const log = (logger, options: LogOptions = {}) => {\n const { hideStaticLogs = true } = options;\n\n return function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n // logger\n req.log = logger.child({ sub: 'in' });\n\n const _auth = req.headers.authorization;\n if (_.isNil(_auth) === false) {\n req.headers.authorization = '<Classified>';\n }\n\n const _cookie = req.get('cookie');\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = '<Classified>';\n }\n\n req.url = req.originalUrl;\n const _skipLog = hideStaticLogs && isStaticRequest(req.url);\n if (_skipLog) {\n debug(\"@{ip} requested '@{req.method} @{req.url}'\", { ip: req.ip, req });\n } else {\n req.log.info({ req: req, ip: req.ip }, \"@{ip} requested '@{req.method} @{req.url}'\");\n }\n req.originalUrl = req.url;\n\n if (_.isNil(_auth) === false) {\n req.headers.authorization = _auth;\n }\n\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = _cookie;\n }\n\n let bytesin = 0;\n req.on('data', function (chunk): void {\n bytesin += chunk.length;\n });\n\n let bytesout = 0;\n const _write = res.write;\n // @ts-ignore\n res.write = function (...args): boolean {\n bytesout += args[0]?.length || 0;\n // @ts-ignore\n return _write.apply(res, args);\n };\n\n const log = function (): void {\n const forwardedFor = req.get(HEADERS.FORWARDED_FOR);\n const remoteAddress = req.socket.remoteAddress;\n const remoteIP = forwardedFor ? `${forwardedFor} via ${remoteAddress}` : remoteAddress;\n let message;\n if (res.locals._verdaccio_error) {\n message = LOG_VERDACCIO_ERROR;\n } else {\n message = LOG_VERDACCIO_BYTES;\n }\n\n req.url = req.originalUrl;\n if (_skipLog) {\n debug(message, {\n request: { method: req.method, url: req.url },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: { in: bytesin, out: bytesout },\n });\n } else {\n req.log.http(\n {\n request: {\n method: req.method,\n url: req.url,\n },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: {\n in: bytesin,\n out: bytesout,\n },\n },\n message\n );\n }\n req.originalUrl = req.url;\n };\n\n req.on('close', function (): void {\n log();\n });\n\n const _end = res.end;\n // @ts-ignore\n res.end = function (...args): void {\n if (args[0]) {\n bytesout += args[0].length;\n }\n // @ts-ignore\n _end.apply(res, args);\n log();\n };\n next();\n };\n};\n"],"mappings":";;;;;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,2BAA2B;AAEpD,SAAS,gBAAgB,KAAsB;AAC7C,QAAO,IAAI,WAAW,aAAa;;AAIrC,IAAa,qBACX;AACF,IAAa,sBAAsB,GAAG,mBAAmB;AACzD,IAAa,sBAAsB,GAAG,mBAAmB;AAQzD,IAAa,OAAO,QAAQ,UAAsB,EAAE,KAAK;CACvD,MAAM,EAAE,iBAAiB,SAAS;AAElC,QAAO,SAAS,IAAI,KAAqB,KAAsB,MAA8B;AAE3F,MAAI,MAAM,OAAO,MAAM,EAAE,KAAK,MAAM,CAAC;EAErC,MAAM,QAAQ,IAAI,QAAQ;AAC1B,MAAI,OAAA,QAAE,MAAM,MAAM,KAAK,MACrB,KAAI,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,IAAI,IAAI,SAAS;AACjC,MAAI,OAAA,QAAE,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Q,IAAI;IACZ,OAAO,IAAI,OAAO;IAClB,OAAO;KACL,IAAI;KACJ,KAAK;KACN;IACF,EACD,QACD;AAEH,OAAI,cAAc,IAAI;;AAGxB,MAAI,GAAG,SAAS,WAAkB;AAChC,QAAK;IACL;EAEF,MAAM,OAAO,IAAI;AAEjB,MAAI,MAAM,SAAU,GAAG,MAAY;AACjC,OAAI,KAAK,GACP,aAAY,KAAK,GAAG;AAGtB,QAAK,MAAM,KAAK,KAAK;AACrB,QAAK;;AAEP,QAAM"}
@@ -0,0 +1,96 @@
1
+ import { HEADERS } from "@verdaccio/core";
2
+ import buildDebug from "debug";
3
+ import _ from "lodash";
4
+ //#region src/middlewares/log.ts
5
+ var debug = buildDebug("verdaccio:middleware:log");
6
+ function isStaticRequest(url) {
7
+ return url.startsWith("/-/static/");
8
+ }
9
+ var LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
10
+ var LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
11
+ var LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
12
+ var log = (logger, options = {}) => {
13
+ const { hideStaticLogs = true } = options;
14
+ return function log(req, res, next) {
15
+ req.log = logger.child({ sub: "in" });
16
+ const _auth = req.headers.authorization;
17
+ if (_.isNil(_auth) === false) req.headers.authorization = "<Classified>";
18
+ const _cookie = req.get("cookie");
19
+ if (_.isNil(_cookie) === false) req.headers.cookie = "<Classified>";
20
+ req.url = req.originalUrl;
21
+ const _skipLog = hideStaticLogs && isStaticRequest(req.url);
22
+ if (_skipLog) debug("@{ip} requested '@{req.method} @{req.url}'", {
23
+ ip: req.ip,
24
+ req
25
+ });
26
+ else req.log.info({
27
+ req,
28
+ ip: req.ip
29
+ }, "@{ip} requested '@{req.method} @{req.url}'");
30
+ req.originalUrl = req.url;
31
+ if (_.isNil(_auth) === false) req.headers.authorization = _auth;
32
+ if (_.isNil(_cookie) === false) req.headers.cookie = _cookie;
33
+ let bytesin = 0;
34
+ req.on("data", function(chunk) {
35
+ bytesin += chunk.length;
36
+ });
37
+ let bytesout = 0;
38
+ const _write = res.write;
39
+ res.write = function(...args) {
40
+ bytesout += args[0]?.length || 0;
41
+ return _write.apply(res, args);
42
+ };
43
+ const log = function() {
44
+ const forwardedFor = req.get(HEADERS.FORWARDED_FOR);
45
+ const remoteAddress = req.socket.remoteAddress;
46
+ const remoteIP = forwardedFor ? `${forwardedFor} via ${remoteAddress}` : remoteAddress;
47
+ let message;
48
+ if (res.locals._verdaccio_error) message = LOG_VERDACCIO_ERROR;
49
+ else message = LOG_VERDACCIO_BYTES;
50
+ req.url = req.originalUrl;
51
+ if (_skipLog) debug(message, {
52
+ request: {
53
+ method: req.method,
54
+ url: req.url
55
+ },
56
+ user: req.remote_user?.name || null,
57
+ remoteIP,
58
+ status: res.statusCode,
59
+ error: res.locals._verdaccio_error,
60
+ bytes: {
61
+ in: bytesin,
62
+ out: bytesout
63
+ }
64
+ });
65
+ else req.log.http({
66
+ request: {
67
+ method: req.method,
68
+ url: req.url
69
+ },
70
+ user: req.remote_user?.name || null,
71
+ remoteIP,
72
+ status: res.statusCode,
73
+ error: res.locals._verdaccio_error,
74
+ bytes: {
75
+ in: bytesin,
76
+ out: bytesout
77
+ }
78
+ }, message);
79
+ req.originalUrl = req.url;
80
+ };
81
+ req.on("close", function() {
82
+ log();
83
+ });
84
+ const _end = res.end;
85
+ res.end = function(...args) {
86
+ if (args[0]) bytesout += args[0].length;
87
+ _end.apply(res, args);
88
+ log();
89
+ };
90
+ next();
91
+ };
92
+ };
93
+ //#endregion
94
+ export { LOG_STATUS_MESSAGE, LOG_VERDACCIO_BYTES, LOG_VERDACCIO_ERROR, log };
95
+
96
+ //# sourceMappingURL=log.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.mjs","names":[],"sources":["../../src/middlewares/log.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { HEADERS } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:log');\n\nfunction isStaticRequest(url: string): boolean {\n return url.startsWith('/-/static/');\n}\n\n// FIXME: deprecated, moved to @verdaccio/dev-commons\nexport const LOG_STATUS_MESSAGE =\n \"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'\";\nexport const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;\nexport const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;\n\nexport type LogOptions = {\n // When true, static file requests (/-/static/*) are hidden from pino logs\n // and only visible via DEBUG=verdaccio:middleware:log. Defaults to true.\n hideStaticLogs?: boolean;\n};\n\nexport const log = (logger, options: LogOptions = {}) => {\n const { hideStaticLogs = true } = options;\n\n return function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n // logger\n req.log = logger.child({ sub: 'in' });\n\n const _auth = req.headers.authorization;\n if (_.isNil(_auth) === false) {\n req.headers.authorization = '<Classified>';\n }\n\n const _cookie = req.get('cookie');\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = '<Classified>';\n }\n\n req.url = req.originalUrl;\n const _skipLog = hideStaticLogs && isStaticRequest(req.url);\n if (_skipLog) {\n debug(\"@{ip} requested '@{req.method} @{req.url}'\", { ip: req.ip, req });\n } else {\n req.log.info({ req: req, ip: req.ip }, \"@{ip} requested '@{req.method} @{req.url}'\");\n }\n req.originalUrl = req.url;\n\n if (_.isNil(_auth) === false) {\n req.headers.authorization = _auth;\n }\n\n if (_.isNil(_cookie) === false) {\n req.headers.cookie = _cookie;\n }\n\n let bytesin = 0;\n req.on('data', function (chunk): void {\n bytesin += chunk.length;\n });\n\n let bytesout = 0;\n const _write = res.write;\n // @ts-ignore\n res.write = function (...args): boolean {\n bytesout += args[0]?.length || 0;\n // @ts-ignore\n return _write.apply(res, args);\n };\n\n const log = function (): void {\n const forwardedFor = req.get(HEADERS.FORWARDED_FOR);\n const remoteAddress = req.socket.remoteAddress;\n const remoteIP = forwardedFor ? `${forwardedFor} via ${remoteAddress}` : remoteAddress;\n let message;\n if (res.locals._verdaccio_error) {\n message = LOG_VERDACCIO_ERROR;\n } else {\n message = LOG_VERDACCIO_BYTES;\n }\n\n req.url = req.originalUrl;\n if (_skipLog) {\n debug(message, {\n request: { method: req.method, url: req.url },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: { in: bytesin, out: bytesout },\n });\n } else {\n req.log.http(\n {\n request: {\n method: req.method,\n url: req.url,\n },\n user: req.remote_user?.name || null,\n remoteIP,\n status: res.statusCode,\n error: res.locals._verdaccio_error,\n bytes: {\n in: bytesin,\n out: bytesout,\n },\n },\n message\n );\n }\n req.originalUrl = req.url;\n };\n\n req.on('close', function (): void {\n log();\n });\n\n const _end = res.end;\n // @ts-ignore\n res.end = function (...args): void {\n if (args[0]) {\n bytesout += args[0].length;\n }\n // @ts-ignore\n _end.apply(res, args);\n log();\n };\n next();\n };\n};\n"],"mappings":";;;;AAOA,IAAM,QAAQ,WAAW,2BAA2B;AAEpD,SAAS,gBAAgB,KAAsB;AAC7C,QAAO,IAAI,WAAW,aAAa;;AAIrC,IAAa,qBACX;AACF,IAAa,sBAAsB,GAAG,mBAAmB;AACzD,IAAa,sBAAsB,GAAG,mBAAmB;AAQzD,IAAa,OAAO,QAAQ,UAAsB,EAAE,KAAK;CACvD,MAAM,EAAE,iBAAiB,SAAS;AAElC,QAAO,SAAS,IAAI,KAAqB,KAAsB,MAA8B;AAE3F,MAAI,MAAM,OAAO,MAAM,EAAE,KAAK,MAAM,CAAC;EAErC,MAAM,QAAQ,IAAI,QAAQ;AAC1B,MAAI,EAAE,MAAM,MAAM,KAAK,MACrB,KAAI,QAAQ,gBAAgB;EAG9B,MAAM,UAAU,IAA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C/B;IACA,QAAQ,IAAI;IACZ,OAAO,IAAI,OAAO;IAClB,OAAO;KACL,IAAI;KACJ,KAAK;KACN;IACF,EACD,QACD;AAEH,OAAI,cAAc,IAAI;;AAGxB,MAAI,GAAG,SAAS,WAAkB;AAChC,QAAK;IACL;EAEF,MAAM,OAAO,IAAI;AAEjB,MAAI,MAAM,SAAU,GAAG,MAAY;AACjC,OAAI,KAAK,GACP,aAAY,KAAK,GAAG;AAGtB,QAAK,MAAM,KAAK,KAAK;AACrB,QAAK;;AAEP,QAAM"}
@@ -1,4 +1,4 @@
1
- import type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
1
+ import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
2
2
  /**
3
3
  * Removes the host from the URL and turns it into a relative URL.
4
4
  * @param req
@@ -1,45 +1,30 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.makeURLrelative = makeURLrelative;
7
- var _debug = _interopRequireDefault(require("debug"));
8
- var _nodeUrl = require("node:url");
9
- var _core = require("@verdaccio/core");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const debug = (0, _debug.default)('verdaccio:middleware:make-url-relative');
12
-
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ let _verdaccio_core = require("@verdaccio/core");
3
+ let debug = require("debug");
4
+ debug = require_runtime.__toESM(debug);
5
+ let node_url = require("node:url");
6
+ //#region src/middlewares/make-url-relative.ts
7
+ var debug$1 = (0, debug.default)("verdaccio:middleware:make-url-relative");
13
8
  /**
14
- * Removes the host from the URL and turns it into a relative URL.
15
- * @param req
16
- * @param res
17
- * @param next
18
- */
9
+ * Removes the host from the URL and turns it into a relative URL.
10
+ * @param req
11
+ * @param res
12
+ * @param next
13
+ */
19
14
  function makeURLrelative(req, res, next) {
20
- const original = req.url;
21
-
22
- // npm requests can contain the full URL, including the hostname, for example:
23
- // tarball downloads. Removing the hostname makes the URL relative and allows
24
- // the application to handle requests in a more consistent way.
25
-
26
- let url;
27
- try {
28
- // In productive use, the URL is absolute (and base will be ignored)
29
- // In tests, the URL might brelative (and base will be used)
30
- // https://nodejs.org/docs/latest/api/url.html#new-urlinput-base
31
- url = new _nodeUrl.URL(req.url, `${req.protocol}://${req.headers.host}/`);
32
- } catch (error) {
33
- return next(_core.errorUtils.getBadRequest(`Invalid URL: ${req.url} (${error})`));
34
- }
35
-
36
- // Rebuild the URL without hostname
37
- req.url = url.pathname + url.search + url.hash;
38
- if (original !== req.url) {
39
- debug('makeURLrelative: %o -> %o', original, req.url);
40
- } else {
41
- debug('makeURLrelative: %o (unchanged)', original);
42
- }
43
- next();
15
+ const original = req.url;
16
+ let url;
17
+ try {
18
+ url = new node_url.URL(req.url, `${req.protocol}://${req.headers.host}/`);
19
+ } catch (error) {
20
+ return next(_verdaccio_core.errorUtils.getBadRequest(`Invalid URL: ${req.url} (${error})`));
21
+ }
22
+ req.url = url.pathname + url.search + url.hash;
23
+ if (original !== req.url) debug$1("makeURLrelative: %o -> %o", original, req.url);
24
+ else debug$1("makeURLrelative: %o (unchanged)", original);
25
+ next();
44
26
  }
27
+ //#endregion
28
+ exports.makeURLrelative = makeURLrelative;
29
+
45
30
  //# sourceMappingURL=make-url-relative.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-url-relative.js","names":["_debug","_interopRequireDefault","require","_nodeUrl","_core","e","__esModule","default","debug","buildDebug","makeURLrelative","req","res","next","original","url","URL","protocol","headers","host","error","errorUtils","getBadRequest","pathname","search","hash"],"sources":["../../src/middlewares/make-url-relative.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'node:url';\n\nimport { errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:make-url-relative');\n\n/**\n * Removes the host from the URL and turns it into a relative URL.\n * @param req\n * @param res\n * @param next\n */\nexport function makeURLrelative(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n const original = req.url;\n\n // npm requests can contain the full URL, including the hostname, for example:\n // tarball downloads. Removing the hostname makes the URL relative and allows\n // the application to handle requests in a more consistent way.\n\n let url;\n try {\n // In productive use, the URL is absolute (and base will be ignored)\n // In tests, the URL might brelative (and base will be used)\n // https://nodejs.org/docs/latest/api/url.html#new-urlinput-base\n url = new URL(req.url, `${req.protocol}://${req.headers.host}/`);\n } catch (error) {\n return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (${error})`));\n }\n\n // Rebuild the URL without hostname\n req.url = url.pathname + url.search + url.hash;\n\n if (original !== req.url) {\n debug('makeURLrelative: %o -> %o', original, req.url);\n } else {\n debug('makeURLrelative: %o (unchanged)', original);\n }\n next();\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA6C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI7C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,wCAAwC,CAAC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BC,GAAmB,EACnBC,GAAoB,EACpBC,IAAsB,EAChB;EACN,MAAMC,QAAQ,GAAGH,GAAG,CAACI,GAAG;;EAExB;EACA;EACA;;EAEA,IAAIA,GAAG;EACP,IAAI;IACF;IACA;IACA;IACAA,GAAG,GAAG,IAAIC,YAAG,CAACL,GAAG,CAACI,GAAG,EAAE,GAAGJ,GAAG,CAACM,QAAQ,MAAMN,GAAG,CAACO,OAAO,CAACC,IAAI,GAAG,CAAC;EAClE,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAOP,IAAI,CAACQ,gBAAU,CAACC,aAAa,CAAC,gBAAgBX,GAAG,CAACI,GAAG,KAAKK,KAAK,GAAG,CAAC,CAAC;EAC7E;;EAEA;EACAT,GAAG,CAACI,GAAG,GAAGA,GAAG,CAACQ,QAAQ,GAAGR,GAAG,CAACS,MAAM,GAAGT,GAAG,CAACU,IAAI;EAE9C,IAAIX,QAAQ,KAAKH,GAAG,CAACI,GAAG,EAAE;IACxBP,KAAK,CAAC,2BAA2B,EAAEM,QAAQ,EAAEH,GAAG,CAACI,GAAG,CAAC;EACvD,CAAC,MAAM;IACLP,KAAK,CAAC,iCAAiC,EAAEM,QAAQ,CAAC;EACpD;EACAD,IAAI,CAAC,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"file":"make-url-relative.js","names":[],"sources":["../../src/middlewares/make-url-relative.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'node:url';\n\nimport { errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:make-url-relative');\n\n/**\n * Removes the host from the URL and turns it into a relative URL.\n * @param req\n * @param res\n * @param next\n */\nexport function makeURLrelative(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n const original = req.url;\n\n // npm requests can contain the full URL, including the hostname, for example:\n // tarball downloads. Removing the hostname makes the URL relative and allows\n // the application to handle requests in a more consistent way.\n\n let url;\n try {\n // In productive use, the URL is absolute (and base will be ignored)\n // In tests, the URL might brelative (and base will be used)\n // https://nodejs.org/docs/latest/api/url.html#new-urlinput-base\n url = new URL(req.url, `${req.protocol}://${req.headers.host}/`);\n } catch (error) {\n return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (${error})`));\n }\n\n // Rebuild the URL without hostname\n req.url = url.pathname + url.search + url.hash;\n\n if (original !== req.url) {\n debug('makeURLrelative: %o -> %o', original, req.url);\n } else {\n debug('makeURLrelative: %o (unchanged)', original);\n }\n next();\n}\n"],"mappings":";;;;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,yCAAyC;;;;;;;AAQlE,SAAgB,gBACd,KACA,KACA,MACM;CACN,MAAM,WAAW,IAAI;CAMrB,IAAI;AACJ,KAAI;AAIF,QAAM,IAAI,SAAA,IAAI,IAAI,KAAK,GAAG,IAAI,SAAS,KAAK,IAAI,QAAQ,KAAK,GAAG;UACzD,OAAO;AACd,SAAO,KAAK,gBAAA,WAAW,cAAc,gBAAgB,IAAI,IAAI,IAAI,MAAM,GAAG,CAAC;;AAI7E,KAAI,MAAM,IAAI,WAAW,IAAI,SAAS,IAAI;AAE1C,KAAI,aAAa,IAAI,IACnB,SAAM,6BAA6B,UAAU,IAAI,IAAI;KAErD,SAAM,mCAAmC,SAAS;AAEpD,OAAM"}
@@ -0,0 +1,28 @@
1
+ import { errorUtils } from "@verdaccio/core";
2
+ import buildDebug from "debug";
3
+ import { URL } from "node:url";
4
+ //#region src/middlewares/make-url-relative.ts
5
+ var debug = buildDebug("verdaccio:middleware:make-url-relative");
6
+ /**
7
+ * Removes the host from the URL and turns it into a relative URL.
8
+ * @param req
9
+ * @param res
10
+ * @param next
11
+ */
12
+ function makeURLrelative(req, res, next) {
13
+ const original = req.url;
14
+ let url;
15
+ try {
16
+ url = new URL(req.url, `${req.protocol}://${req.headers.host}/`);
17
+ } catch (error) {
18
+ return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (${error})`));
19
+ }
20
+ req.url = url.pathname + url.search + url.hash;
21
+ if (original !== req.url) debug("makeURLrelative: %o -> %o", original, req.url);
22
+ else debug("makeURLrelative: %o (unchanged)", original);
23
+ next();
24
+ }
25
+ //#endregion
26
+ export { makeURLrelative };
27
+
28
+ //# sourceMappingURL=make-url-relative.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-url-relative.mjs","names":[],"sources":["../../src/middlewares/make-url-relative.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { URL } from 'node:url';\n\nimport { errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:make-url-relative');\n\n/**\n * Removes the host from the URL and turns it into a relative URL.\n * @param req\n * @param res\n * @param next\n */\nexport function makeURLrelative(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n const original = req.url;\n\n // npm requests can contain the full URL, including the hostname, for example:\n // tarball downloads. Removing the hostname makes the URL relative and allows\n // the application to handle requests in a more consistent way.\n\n let url;\n try {\n // In productive use, the URL is absolute (and base will be ignored)\n // In tests, the URL might brelative (and base will be used)\n // https://nodejs.org/docs/latest/api/url.html#new-urlinput-base\n url = new URL(req.url, `${req.protocol}://${req.headers.host}/`);\n } catch (error) {\n return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (${error})`));\n }\n\n // Rebuild the URL without hostname\n req.url = url.pathname + url.search + url.hash;\n\n if (original !== req.url) {\n debug('makeURLrelative: %o -> %o', original, req.url);\n } else {\n debug('makeURLrelative: %o (unchanged)', original);\n }\n next();\n}\n"],"mappings":";;;;AAOA,IAAM,QAAQ,WAAW,yCAAyC;;;;;;;AAQlE,SAAgB,gBACd,KACA,KACA,MACM;CACN,MAAM,WAAW,IAAI;CAMrB,IAAI;AACJ,KAAI;AAIF,QAAM,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,SAAS,KAAK,IAAI,QAAQ,KAAK,GAAG;UACzD,OAAO;AACd,SAAO,KAAK,WAAW,cAAc,gBAAgB,IAAI,IAAI,IAAI,MAAM,GAAG,CAAC;;AAI7E,KAAI,MAAM,IAAI,WAAW,IAAI,SAAS,IAAI;AAE1C,KAAI,aAAa,IAAI,IACnB,OAAM,6BAA6B,UAAU,IAAI,IAAI;KAErD,OAAM,mCAAmC,SAAS;AAEpD,OAAM"}
@@ -1,16 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.match = match;
1
+ //#region src/middlewares/match.ts
7
2
  function match(regexp) {
8
- return function (req, res, next, value) {
9
- if (regexp.exec(value)) {
10
- next();
11
- } else {
12
- next('route');
13
- }
14
- };
3
+ return function(req, res, next, value) {
4
+ if (regexp.exec(value)) next();
5
+ else next("route");
6
+ };
15
7
  }
8
+ //#endregion
9
+ exports.match = match;
10
+
16
11
  //# sourceMappingURL=match.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.js","names":["match","regexp","req","res","next","value","exec"],"sources":["../../src/middlewares/match.ts"],"sourcesContent":["import type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function match(regexp: RegExp): any {\n return function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer,\n value: string\n ): void {\n if (regexp.exec(value)) {\n next();\n } else {\n next('route');\n }\n };\n}\n"],"mappings":";;;;;;AAEO,SAASA,KAAKA,CAACC,MAAc,EAAO;EACzC,OAAO,UACLC,GAAmB,EACnBC,GAAoB,EACpBC,IAAsB,EACtBC,KAAa,EACP;IACN,IAAIJ,MAAM,CAACK,IAAI,CAACD,KAAK,CAAC,EAAE;MACtBD,IAAI,CAAC,CAAC;IACR,CAAC,MAAM;MACLA,IAAI,CAAC,OAAO,CAAC;IACf;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"match.js","names":[],"sources":["../../src/middlewares/match.ts"],"sourcesContent":["import type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function match(regexp: RegExp): any {\n return function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer,\n value: string\n ): void {\n if (regexp.exec(value)) {\n next();\n } else {\n next('route');\n }\n };\n}\n"],"mappings":";AAEA,SAAgB,MAAM,QAAqB;AACzC,QAAO,SACL,KACA,KACA,MACA,OACM;AACN,MAAI,OAAO,KAAK,MAAM,CACpB,OAAM;MAEN,MAAK,QAAQ"}
@@ -0,0 +1,11 @@
1
+ //#region src/middlewares/match.ts
2
+ function match(regexp) {
3
+ return function(req, res, next, value) {
4
+ if (regexp.exec(value)) next();
5
+ else next("route");
6
+ };
7
+ }
8
+ //#endregion
9
+ export { match };
10
+
11
+ //# sourceMappingURL=match.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.mjs","names":[],"sources":["../../src/middlewares/match.ts"],"sourcesContent":["import type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function match(regexp: RegExp): any {\n return function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer,\n value: string\n ): void {\n if (regexp.exec(value)) {\n next();\n } else {\n next('route');\n }\n };\n}\n"],"mappings":";AAEA,SAAgB,MAAM,QAAqB;AACzC,QAAO,SACL,KACA,KACA,MACA,OACM;AACN,MAAI,OAAO,KAAK,MAAM,CACpB,OAAM;MAEN,MAAK,QAAQ"}
@@ -1,22 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.media = media;
7
- var _core = require("@verdaccio/core");
1
+ require("../_virtual/_rolldown/runtime.js");
2
+ let _verdaccio_core = require("@verdaccio/core");
3
+ //#region src/middlewares/media.ts
8
4
  function media(expect) {
9
- return function (req, res, next) {
10
- const header = req.headers[_core.HEADER_TYPE.CONTENT_TYPE];
11
- if (!header) {
12
- next(_core.errorUtils.getCode(_core.HTTP_STATUS.UNSUPPORTED_MEDIA, 'content-type is missing, expect: ' + expect));
13
- return;
14
- }
15
- if (typeof header !== 'string' || header.split(';')[0].trim() !== expect) {
16
- next(_core.errorUtils.getCode(_core.HTTP_STATUS.UNSUPPORTED_MEDIA, 'wrong content-type, expect: ' + expect + ', got: ' + req.get(_core.HEADER_TYPE.CONTENT_TYPE)));
17
- } else {
18
- next();
19
- }
20
- };
5
+ return function(req, res, next) {
6
+ const header = req.headers[_verdaccio_core.HEADER_TYPE.CONTENT_TYPE];
7
+ if (!header) {
8
+ next(_verdaccio_core.errorUtils.getCode(_verdaccio_core.HTTP_STATUS.UNSUPPORTED_MEDIA, "content-type is missing, expect: " + expect));
9
+ return;
10
+ }
11
+ if (typeof header !== "string" || header.split(";")[0].trim() !== expect) next(_verdaccio_core.errorUtils.getCode(_verdaccio_core.HTTP_STATUS.UNSUPPORTED_MEDIA, "wrong content-type, expect: " + expect + ", got: " + req.get(_verdaccio_core.HEADER_TYPE.CONTENT_TYPE)));
12
+ else next();
13
+ };
21
14
  }
15
+ //#endregion
16
+ exports.media = media;
17
+
22
18
  //# sourceMappingURL=media.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"media.js","names":["_core","require","media","expect","req","res","next","header","headers","HEADER_TYPE","CONTENT_TYPE","errorUtils","getCode","HTTP_STATUS","UNSUPPORTED_MEDIA","split","trim","get"],"sources":["../../src/middlewares/media.ts"],"sourcesContent":["import { HEADER_TYPE, HTTP_STATUS, errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function media(expect: string | null): any {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n const header = req.headers[HEADER_TYPE.CONTENT_TYPE];\n if (!header) {\n next(\n errorUtils.getCode(\n HTTP_STATUS.UNSUPPORTED_MEDIA,\n 'content-type is missing, expect: ' + expect\n )\n );\n return;\n }\n\n if (typeof header !== 'string' || header.split(';')[0].trim() !== expect) {\n next(\n errorUtils.getCode(\n HTTP_STATUS.UNSUPPORTED_MEDIA,\n 'wrong content-type, expect: ' + expect + ', got: ' + req.get(HEADER_TYPE.CONTENT_TYPE)\n )\n );\n } else {\n next();\n }\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIO,SAASC,KAAKA,CAACC,MAAqB,EAAO;EAChD,OAAO,UAAUC,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IACxF,MAAMC,MAAM,GAAGH,GAAG,CAACI,OAAO,CAACC,iBAAW,CAACC,YAAY,CAAC;IACpD,IAAI,CAACH,MAAM,EAAE;MACXD,IAAI,CACFK,gBAAU,CAACC,OAAO,CAChBC,iBAAW,CAACC,iBAAiB,EAC7B,mCAAmC,GAAGX,MACxC,CACF,CAAC;MACD;IACF;IAEA,IAAI,OAAOI,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACQ,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,KAAKb,MAAM,EAAE;MACxEG,IAAI,CACFK,gBAAU,CAACC,OAAO,CAChBC,iBAAW,CAACC,iBAAiB,EAC7B,8BAA8B,GAAGX,MAAM,GAAG,SAAS,GAAGC,GAAG,CAACa,GAAG,CAACR,iBAAW,CAACC,YAAY,CACxF,CACF,CAAC;IACH,CAAC,MAAM;MACLJ,IAAI,CAAC,CAAC;IACR;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"media.js","names":[],"sources":["../../src/middlewares/media.ts"],"sourcesContent":["import { HEADER_TYPE, HTTP_STATUS, errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function media(expect: string | null): any {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n const header = req.headers[HEADER_TYPE.CONTENT_TYPE];\n if (!header) {\n next(\n errorUtils.getCode(\n HTTP_STATUS.UNSUPPORTED_MEDIA,\n 'content-type is missing, expect: ' + expect\n )\n );\n return;\n }\n\n if (typeof header !== 'string' || header.split(';')[0].trim() !== expect) {\n next(\n errorUtils.getCode(\n HTTP_STATUS.UNSUPPORTED_MEDIA,\n 'wrong content-type, expect: ' + expect + ', got: ' + req.get(HEADER_TYPE.CONTENT_TYPE)\n )\n );\n } else {\n next();\n }\n };\n}\n"],"mappings":";;;AAIA,SAAgB,MAAM,QAA4B;AAChD,QAAO,SAAU,KAAqB,KAAsB,MAA8B;EACxF,MAAM,SAAS,IAAI,QAAQ,gBAAA,YAAY;AACvC,MAAI,CAAC,QAAQ;AACX,QACE,gBAAA,WAAW,QACT,gBAAA,YAAY,mBACZ,sCAAsC,OACvC,CACF;AACD;;AAGF,MAAI,OAAO,WAAW,YAAY,OAAO,MAAM,IAAI,CAAC,GAAG,MAAM,KAAK,OAChE,MACE,gBAAA,WAAW,QACT,gBAAA,YAAY,mBACZ,iCAAiC,SAAS,YAAY,IAAI,IAAI,gBAAA,YAAY,aAAa,CACxF,CACF;MAED,OAAM"}
@@ -0,0 +1,17 @@
1
+ import { HEADER_TYPE, HTTP_STATUS, errorUtils } from "@verdaccio/core";
2
+ //#region src/middlewares/media.ts
3
+ function media(expect) {
4
+ return function(req, res, next) {
5
+ const header = req.headers[HEADER_TYPE.CONTENT_TYPE];
6
+ if (!header) {
7
+ next(errorUtils.getCode(HTTP_STATUS.UNSUPPORTED_MEDIA, "content-type is missing, expect: " + expect));
8
+ return;
9
+ }
10
+ if (typeof header !== "string" || header.split(";")[0].trim() !== expect) next(errorUtils.getCode(HTTP_STATUS.UNSUPPORTED_MEDIA, "wrong content-type, expect: " + expect + ", got: " + req.get(HEADER_TYPE.CONTENT_TYPE)));
11
+ else next();
12
+ };
13
+ }
14
+ //#endregion
15
+ export { media };
16
+
17
+ //# sourceMappingURL=media.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.mjs","names":[],"sources":["../../src/middlewares/media.ts"],"sourcesContent":["import { HEADER_TYPE, HTTP_STATUS, errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport function media(expect: string | null): any {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n const header = req.headers[HEADER_TYPE.CONTENT_TYPE];\n if (!header) {\n next(\n errorUtils.getCode(\n HTTP_STATUS.UNSUPPORTED_MEDIA,\n 'content-type is missing, expect: ' + expect\n )\n );\n return;\n }\n\n if (typeof header !== 'string' || header.split(';')[0].trim() !== expect) {\n next(\n errorUtils.getCode(\n HTTP_STATUS.UNSUPPORTED_MEDIA,\n 'wrong content-type, expect: ' + expect + ', got: ' + req.get(HEADER_TYPE.CONTENT_TYPE)\n )\n );\n } else {\n next();\n }\n };\n}\n"],"mappings":";;AAIA,SAAgB,MAAM,QAA4B;AAChD,QAAO,SAAU,KAAqB,KAAsB,MAA8B;EACxF,MAAM,SAAS,IAAI,QAAQ,YAAY;AACvC,MAAI,CAAC,QAAQ;AACX,QACE,WAAW,QACT,YAAY,mBACZ,sCAAsC,OACvC,CACF;AACD;;AAGF,MAAI,OAAO,WAAW,YAAY,OAAO,MAAM,IAAI,CAAC,GAAG,MAAM,KAAK,OAChE,MACE,WAAW,QACT,YAAY,mBACZ,iCAAiC,SAAS,YAAY,IAAI,IAAI,YAAY,aAAa,CACxF,CACF;MAED,OAAM"}
@@ -1,2 +1,2 @@
1
- import type { RateLimit as RateLimitType } from '@verdaccio/types';
2
- export declare function rateLimit(rateLimitOptions?: RateLimitType): import("express-rate-limit").RateLimitRequestHandler;
1
+ import { RateLimit as RateLimitType } from '@verdaccio/types';
2
+ export declare function rateLimit(rateLimitOptions?: RateLimitType): import('express-rate-limit').RateLimitRequestHandler;
@@ -1,13 +1,11 @@
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(e) { return e && e.__esModule ? e : { default: e }; }
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ let express_rate_limit = require("express-rate-limit");
3
+ express_rate_limit = require_runtime.__toESM(express_rate_limit);
4
+ //#region src/middlewares/rate-limit.ts
9
5
  function rateLimit(rateLimitOptions) {
10
- const limiter = (0, _expressRateLimit.default)(rateLimitOptions);
11
- return limiter;
6
+ return (0, express_rate_limit.default)(rateLimitOptions);
12
7
  }
8
+ //#endregion
9
+ exports.rateLimit = rateLimit;
10
+
13
11
  //# sourceMappingURL=rate-limit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rate-limit.js","names":["_expressRateLimit","_interopRequireDefault","require","e","__esModule","default","rateLimit","rateLimitOptions","limiter","RateLimit"],"sources":["../../src/middlewares/rate-limit.ts"],"sourcesContent":["import RateLimit from 'express-rate-limit';\n\nimport type { RateLimit as RateLimitType } from '@verdaccio/types';\n\nexport function rateLimit(rateLimitOptions?: RateLimitType) {\n const limiter = RateLimit(rateLimitOptions);\n return limiter;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC,SAASG,SAASA,CAACC,gBAAgC,EAAE;EAC1D,MAAMC,OAAO,GAAG,IAAAC,yBAAS,EAACF,gBAAgB,CAAC;EAC3C,OAAOC,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"rate-limit.js","names":[],"sources":["../../src/middlewares/rate-limit.ts"],"sourcesContent":["import RateLimit from 'express-rate-limit';\n\nimport type { RateLimit as RateLimitType } from '@verdaccio/types';\n\nexport function rateLimit(rateLimitOptions?: RateLimitType) {\n const limiter = RateLimit(rateLimitOptions);\n return limiter;\n}\n"],"mappings":";;;;AAIA,SAAgB,UAAU,kBAAkC;AAE1D,SAAA,GAAA,mBAAA,SAD0B,iBAAiB"}
@@ -0,0 +1,9 @@
1
+ import RateLimit from "express-rate-limit";
2
+ //#region src/middlewares/rate-limit.ts
3
+ function rateLimit(rateLimitOptions) {
4
+ return RateLimit(rateLimitOptions);
5
+ }
6
+ //#endregion
7
+ export { rateLimit };
8
+
9
+ //# sourceMappingURL=rate-limit.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit.mjs","names":[],"sources":["../../src/middlewares/rate-limit.ts"],"sourcesContent":["import RateLimit from 'express-rate-limit';\n\nimport type { RateLimit as RateLimitType } from '@verdaccio/types';\n\nexport function rateLimit(rateLimitOptions?: RateLimitType) {\n const limiter = RateLimit(rateLimitOptions);\n return limiter;\n}\n"],"mappings":";;AAIA,SAAgB,UAAU,kBAAkC;AAE1D,QADgB,UAAU,iBAAiB"}
@@ -1,3 +1,3 @@
1
- import type { RequestOptions } from '@verdaccio/url';
2
- import type { $RequestExtend } from '../types';
1
+ import { RequestOptions } from '@verdaccio/url';
2
+ import { $RequestExtend } from '../types';
3
3
  export declare function getRequestOptions(req: $RequestExtend): RequestOptions;
@@ -1,30 +1,21 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRequestOptions = getRequestOptions;
7
- var _debug = _interopRequireDefault(require("debug"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const debug = (0, _debug.default)('verdaccio:middleware:request-options');
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ let debug = require("debug");
3
+ debug = require_runtime.__toESM(debug);
4
+ //#region src/middlewares/request-options.ts
5
+ var debug$1 = (0, debug.default)("verdaccio:middleware:request-options");
10
6
  function getRequestOptions(req) {
11
- const requestOptions = {
12
- // FIXME: decide if host should contain port or not
13
- //
14
- // Express 4:
15
- // - req.host is marked as deprecated since it does not include the port
16
- // - use req.headers['host'] instead, which includes the port
17
- // Express 5:
18
- // - req.host is fully supported and includes the port
19
- // - https://expressjs.com/en/api.html#req.host
20
- host: req.host,
21
- protocol: req.protocol,
22
- headers: req.headers,
23
- remoteAddress: req.socket.remoteAddress,
24
- byPassCache: req.query.write === 'true',
25
- username: req.remote_user?.name ?? undefined
26
- };
27
- debug('request options: %o', requestOptions);
28
- return requestOptions;
7
+ const requestOptions = {
8
+ host: req.host,
9
+ protocol: req.protocol,
10
+ headers: req.headers,
11
+ remoteAddress: req.socket.remoteAddress,
12
+ byPassCache: req.query.write === "true",
13
+ username: req.remote_user?.name ?? void 0
14
+ };
15
+ debug$1("request options: %o", requestOptions);
16
+ return requestOptions;
29
17
  }
18
+ //#endregion
19
+ exports.getRequestOptions = getRequestOptions;
20
+
30
21
  //# sourceMappingURL=request-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-options.js","names":["_debug","_interopRequireDefault","require","e","__esModule","default","debug","buildDebug","getRequestOptions","req","requestOptions","host","protocol","headers","remoteAddress","socket","byPassCache","query","write","username","remote_user","name","undefined"],"sources":["../../src/middlewares/request-options.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { IncomingHttpHeaders } from 'node:http';\n\nimport type { RequestOptions } from '@verdaccio/url';\n\nimport type { $RequestExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:request-options');\n\nexport function getRequestOptions(req: $RequestExtend): RequestOptions {\n const requestOptions = {\n // FIXME: decide if host should contain port or not\n //\n // Express 4:\n // - req.host is marked as deprecated since it does not include the port\n // - use req.headers['host'] instead, which includes the port\n // Express 5:\n // - req.host is fully supported and includes the port\n // - https://expressjs.com/en/api.html#req.host\n host: req.host,\n protocol: req.protocol,\n headers: req.headers as IncomingHttpHeaders,\n remoteAddress: req.socket.remoteAddress,\n byPassCache: req.query.write === 'true',\n username: req.remote_user?.name ?? undefined,\n };\n\n debug('request options: %o', requestOptions);\n\n return requestOptions;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAO/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,sCAAsC,CAAC;AAEzD,SAASC,iBAAiBA,CAACC,GAAmB,EAAkB;EACrE,MAAMC,cAAc,GAAG;IACrB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAC,IAAI,EAAEF,GAAG,CAACE,IAAI;IACdC,QAAQ,EAAEH,GAAG,CAACG,QAAQ;IACtBC,OAAO,EAAEJ,GAAG,CAACI,OAA8B;IAC3CC,aAAa,EAAEL,GAAG,CAACM,MAAM,CAACD,aAAa;IACvCE,WAAW,EAAEP,GAAG,CAACQ,KAAK,CAACC,KAAK,KAAK,MAAM;IACvCC,QAAQ,EAAEV,GAAG,CAACW,WAAW,EAAEC,IAAI,IAAIC;EACrC,CAAC;EAEDhB,KAAK,CAAC,qBAAqB,EAAEI,cAAc,CAAC;EAE5C,OAAOA,cAAc;AACvB","ignoreList":[]}
1
+ {"version":3,"file":"request-options.js","names":[],"sources":["../../src/middlewares/request-options.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { IncomingHttpHeaders } from 'node:http';\n\nimport type { RequestOptions } from '@verdaccio/url';\n\nimport type { $RequestExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:request-options');\n\nexport function getRequestOptions(req: $RequestExtend): RequestOptions {\n const requestOptions = {\n // FIXME: decide if host should contain port or not\n //\n // Express 4:\n // - req.host is marked as deprecated since it does not include the port\n // - use req.headers['host'] instead, which includes the port\n // Express 5:\n // - req.host is fully supported and includes the port\n // - https://expressjs.com/en/api.html#req.host\n host: req.host,\n protocol: req.protocol,\n headers: req.headers as IncomingHttpHeaders,\n remoteAddress: req.socket.remoteAddress,\n byPassCache: req.query.write === 'true',\n username: req.remote_user?.name ?? undefined,\n };\n\n debug('request options: %o', requestOptions);\n\n return requestOptions;\n}\n"],"mappings":";;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,uCAAuC;AAEhE,SAAgB,kBAAkB,KAAqC;CACrE,MAAM,iBAAiB;EASrB,MAAM,IAAI;EACV,UAAU,IAAI;EACd,SAAS,IAAI;EACb,eAAe,IAAI,OAAO;EAC1B,aAAa,IAAI,MAAM,UAAU;EACjC,UAAU,IAAI,aAAa,QAAQ,KAAA;EACpC;AAED,SAAM,uBAAuB,eAAe;AAE5C,QAAO"}
@@ -0,0 +1,19 @@
1
+ import buildDebug from "debug";
2
+ //#region src/middlewares/request-options.ts
3
+ var debug = buildDebug("verdaccio:middleware:request-options");
4
+ function getRequestOptions(req) {
5
+ const requestOptions = {
6
+ host: req.host,
7
+ protocol: req.protocol,
8
+ headers: req.headers,
9
+ remoteAddress: req.socket.remoteAddress,
10
+ byPassCache: req.query.write === "true",
11
+ username: req.remote_user?.name ?? void 0
12
+ };
13
+ debug("request options: %o", requestOptions);
14
+ return requestOptions;
15
+ }
16
+ //#endregion
17
+ export { getRequestOptions };
18
+
19
+ //# sourceMappingURL=request-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-options.mjs","names":[],"sources":["../../src/middlewares/request-options.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { IncomingHttpHeaders } from 'node:http';\n\nimport type { RequestOptions } from '@verdaccio/url';\n\nimport type { $RequestExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:request-options');\n\nexport function getRequestOptions(req: $RequestExtend): RequestOptions {\n const requestOptions = {\n // FIXME: decide if host should contain port or not\n //\n // Express 4:\n // - req.host is marked as deprecated since it does not include the port\n // - use req.headers['host'] instead, which includes the port\n // Express 5:\n // - req.host is fully supported and includes the port\n // - https://expressjs.com/en/api.html#req.host\n host: req.host,\n protocol: req.protocol,\n headers: req.headers as IncomingHttpHeaders,\n remoteAddress: req.socket.remoteAddress,\n byPassCache: req.query.write === 'true',\n username: req.remote_user?.name ?? undefined,\n };\n\n debug('request options: %o', requestOptions);\n\n return requestOptions;\n}\n"],"mappings":";;AAOA,IAAM,QAAQ,WAAW,uCAAuC;AAEhE,SAAgB,kBAAkB,KAAqC;CACrE,MAAM,iBAAiB;EASrB,MAAM,IAAI;EACV,UAAU,IAAI;EACd,SAAS,IAAI;EACb,eAAe,IAAI,OAAO;EAC1B,aAAa,IAAI,MAAM,UAAU;EACjC,UAAU,IAAI,aAAa,QAAQ,KAAA;EACpC;AAED,OAAM,uBAAuB,eAAe;AAE5C,QAAO"}
@@ -1,2 +1,2 @@
1
- import type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
1
+ import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
2
2
  export declare function userAgent(config: any): (_req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => void;
@@ -1,15 +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
- var _core = require("@verdaccio/core");
1
+ require("../_virtual/_rolldown/runtime.js");
2
+ let _verdaccio_core = require("@verdaccio/core");
3
+ let _verdaccio_config = require("@verdaccio/config");
4
+ //#region src/middlewares/user-agent.ts
9
5
  function userAgent(config) {
10
- return function (_req, res, next) {
11
- res.setHeader(_core.HEADERS.POWERED_BY, (0, _config.getUserAgent)(config?.user_agent));
12
- next();
13
- };
6
+ return function(_req, res, next) {
7
+ res.setHeader(_verdaccio_core.HEADERS.POWERED_BY, (0, _verdaccio_config.getUserAgent)(config?.user_agent));
8
+ next();
9
+ };
14
10
  }
11
+ //#endregion
12
+ exports.userAgent = userAgent;
13
+
15
14
  //# sourceMappingURL=user-agent.js.map