@verdaccio/middleware 6.0.0-6-next.54 → 7.0.0-next-7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,286 @@
1
1
  # @verdaccio/middleware
2
2
 
3
+ ## 7.0.0-next-7.7
4
+
5
+ ### Patch Changes
6
+
7
+ - @verdaccio/core@7.0.0-next-7.7
8
+ - @verdaccio/config@7.0.0-next-7.7
9
+ - @verdaccio/url@12.0.0-next-7.7
10
+ - @verdaccio/utils@7.0.0-next-7.7
11
+
12
+ ## 7.0.0-next.6
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [4d96324]
17
+ - @verdaccio/config@7.0.0-next.6
18
+ - @verdaccio/core@7.0.0-next.6
19
+ - @verdaccio/url@12.0.0-next.6
20
+ - @verdaccio/utils@7.0.0-next.6
21
+
22
+ ## 7.0.0-next.5
23
+
24
+ ### Minor Changes
25
+
26
+ - f047cc8: refactor: auth with legacy sign support
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [f047cc8]
31
+ - @verdaccio/core@7.0.0-next.5
32
+ - @verdaccio/url@12.0.0-next.5
33
+ - @verdaccio/config@7.0.0-next.5
34
+ - @verdaccio/utils@7.0.0-next.5
35
+
36
+ ## 7.0.0-next.4
37
+
38
+ ### Patch Changes
39
+
40
+ - @verdaccio/core@7.0.0-next.4
41
+ - @verdaccio/config@7.0.0-next.4
42
+ - @verdaccio/url@12.0.0-next.4
43
+ - @verdaccio/utils@7.0.0-next.4
44
+
45
+ ## 7.0.0-next.3
46
+
47
+ ### Major Changes
48
+
49
+ - e7ebccb61: update major dependencies, remove old nodejs support
50
+
51
+ ### Minor Changes
52
+
53
+ - daceb6d87: restore legacy support
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [daceb6d87]
58
+ - Updated dependencies [e7ebccb61]
59
+ - @verdaccio/config@7.0.0-next.3
60
+ - @verdaccio/core@7.0.0-next.3
61
+ - @verdaccio/url@12.0.0-next.3
62
+ - @verdaccio/utils@7.0.0-next.3
63
+
64
+ ## 7.0.0-next.2
65
+
66
+ ### Patch Changes
67
+
68
+ - @verdaccio/core@7.0.0-next.2
69
+ - @verdaccio/config@7.0.0-next.2
70
+ - @verdaccio/url@12.0.0-next.2
71
+ - @verdaccio/utils@7.0.0-next.2
72
+
73
+ ## 7.0.0-next.1
74
+
75
+ ### Patch Changes
76
+
77
+ - @verdaccio/core@7.0.0-next.1
78
+ - @verdaccio/config@7.0.0-next.1
79
+ - @verdaccio/url@12.0.0-next.1
80
+ - @verdaccio/utils@7.0.0-next.1
81
+
82
+ ## 7.0.0-next.0
83
+
84
+ ### Major Changes
85
+
86
+ - feat!: bump to v7
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies
91
+ - @verdaccio/config@7.0.0-next.0
92
+ - @verdaccio/core@7.0.0-next.0
93
+ - @verdaccio/url@12.0.0-next.0
94
+ - @verdaccio/utils@7.0.0-next.0
95
+
96
+ ## 6.0.0
97
+
98
+ ### Major Changes
99
+
100
+ - 292c0a37f: feat!: replace deprecated request dependency by got
101
+
102
+ This is a big refactoring of the core, fetching dependencies, improve code, more tests and better stability. This is essential for the next release, will take some time but would allow modularize more the core.
103
+
104
+ ## Notes
105
+
106
+ - Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
107
+ - Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
108
+ - Refactor with promises instead callback wherever is possible
109
+ - ~Document the API~
110
+ - Improve testing, integration tests
111
+ - Bugfix
112
+ - Clean up old validations
113
+ - Improve performance
114
+
115
+ ## 💥 Breaking changes
116
+
117
+ - Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
118
+ - Write Tarball, Read Tarball methods parameters change, a new set of options like `AbortController` signals are being provided to the `addAbortSignal` can be internally used with Streams when a request is aborted. eg: `addAbortSignal(signal, fs.createReadStream(pathName));`
119
+ - `@verdaccio/streams` stream abort support is legacy is being deprecated removed
120
+ - Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
121
+
122
+ - 794af76c5: Remove Node 12 support
123
+
124
+ - We need move to the new `undici` and does not support Node.js 12
125
+
126
+ - 10aeb4f13: feat!: experiments config renamed to flags
127
+
128
+ - The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
129
+
130
+ ```js
131
+ flags: token: false;
132
+ search: false;
133
+ ```
134
+
135
+ - The `self_path` property from the config file is being removed in favor of `config_file` full path.
136
+ - Refactor `config` module, better types and utilities
137
+
138
+ - e367c3f1e: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
139
+
140
+ - Introduce environment variables for legacy tokens
141
+
142
+ ### Code Improvements
143
+
144
+ - Add debug library for improve developer experience
145
+
146
+ ### Breaking change
147
+
148
+ - The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
149
+ - The secret key must have 32 characters long.
150
+
151
+ ### New environment variables
152
+
153
+ - `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
154
+ - `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
155
+
156
+ ### Minor Changes
157
+
158
+ - a1986e098: feat: expose middleware utils
159
+ - ae93e039d: fix: expose middleware methods
160
+ - 24b9be020: refactor: improve docker image build with strict dependencies and prod build
161
+ - 631abe1ac: feat: refactor logger
162
+ - b61f762d6: feat: add server rate limit protection to all request
163
+
164
+ To modify custom values, use the server settings property.
165
+
166
+ ```markdown
167
+ server:
168
+
169
+ ## https://www.npmjs.com/package/express-rate-limit#configuration-options
170
+
171
+ rateLimit:
172
+ windowMs: 1000
173
+ max: 10000
174
+ ```
175
+
176
+ The values are intended to be high, if you want to improve security of your server consider
177
+ using different values.
178
+
179
+ - 154b2ecd3: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
180
+ - aa763baec: feat: add typescript project references settings
181
+
182
+ Reading https://ebaytech.berlin/optimizing-multi-package-apps-with-typescript-project-references-d5c57a3b4440 I realized I can use project references to solve the issue to pre-compile modules on develop mode.
183
+
184
+ It allows to navigate (IDE) trough the packages without need compile the packages.
185
+
186
+ Add two `tsconfig`, one using the previous existing configuration that is able to produce declaration files (`tsconfig.build`) and a new one `tsconfig` which is enables [_projects references_](https://www.typescriptlang.org/docs/handbook/project-references.html).
187
+
188
+ - 4b29d715b: chore: move improvements from v5 to v6
189
+
190
+ Migrate improvements form v5 to v6:
191
+
192
+ - https://github.com/verdaccio/verdaccio/pull/3158
193
+ - https://github.com/verdaccio/verdaccio/pull/3151
194
+ - https://github.com/verdaccio/verdaccio/pull/2271
195
+ - https://github.com/verdaccio/verdaccio/pull/2787
196
+ - https://github.com/verdaccio/verdaccio/pull/2791
197
+ - https://github.com/verdaccio/verdaccio/pull/2205
198
+
199
+ - 45c03819e: refactor: render html middleware
200
+
201
+ ### Patch Changes
202
+
203
+ - 9943e2b18: fix: extract logger from middleware
204
+ - 1d1112805: Remove @ts-ignore and any in packages/web/src/endpoint/package.ts
205
+ - 7ef599cc4: fix: missing version on footer
206
+ - a610ef26b: chore: add release step to private regisry on merge changeset pr
207
+ - 4fc21146a: fix: missing logo on header
208
+ - 34f0f1101: Enable prerelease mode with **changesets**
209
+ - f859d2b1a: fix: official package "-" cannot be synced
210
+ - 65f88b826: bump logger packages
211
+ - 68ea21214: ESLint Warnings Fixed
212
+
213
+ Related to issue #1461
214
+
215
+ - max-len: most of the sensible max-len errors are fixed
216
+ - no-unused-vars: most of these types of errors are fixed by deleting not needed declarations
217
+ - @typescript-eslint/no-unused-vars: same as above
218
+
219
+ - fa274ee44: chore: bumb up package
220
+ - Updated dependencies [292c0a37f]
221
+ - Updated dependencies [dc05edfe6]
222
+ - Updated dependencies [a1986e098]
223
+ - Updated dependencies [974cd8c19]
224
+ - Updated dependencies [a828271d6]
225
+ - Updated dependencies [ef88da3b4]
226
+ - Updated dependencies [43f32687c]
227
+ - Updated dependencies [679c19c1b]
228
+ - Updated dependencies [a3a209b5e]
229
+ - Updated dependencies [459b6fa72]
230
+ - Updated dependencies [9fc2e7961]
231
+ - Updated dependencies [24b9be020]
232
+ - Updated dependencies [794af76c5]
233
+ - Updated dependencies [351aeeaa8]
234
+ - Updated dependencies [10aeb4f13]
235
+ - Updated dependencies [9718e0330]
236
+ - Updated dependencies [1b217fd34]
237
+ - Updated dependencies [e367c3f1e]
238
+ - Updated dependencies [a1da11308]
239
+ - Updated dependencies [d167f92e1]
240
+ - Updated dependencies [d2c65da9c]
241
+ - Updated dependencies [00d1d2a17]
242
+ - Updated dependencies [1810ed0d8]
243
+ - Updated dependencies [a610ef26b]
244
+ - Updated dependencies [ddb6a2239]
245
+ - Updated dependencies [648575aa4]
246
+ - Updated dependencies [b61f762d6]
247
+ - Updated dependencies [d43894e8f]
248
+ - Updated dependencies [154b2ecd3]
249
+ - Updated dependencies [aa763baec]
250
+ - Updated dependencies [378e907d5]
251
+ - Updated dependencies [16e38df8a]
252
+ - Updated dependencies [34f0f1101]
253
+ - Updated dependencies [82cb0f2bf]
254
+ - Updated dependencies [dc571aabd]
255
+ - Updated dependencies [ce013d2fc]
256
+ - Updated dependencies [f859d2b1a]
257
+ - Updated dependencies [6c1eb021b]
258
+ - Updated dependencies [62c24b632]
259
+ - Updated dependencies [0a6412ca9]
260
+ - Updated dependencies [d08fe29d9]
261
+ - Updated dependencies [5167bb528]
262
+ - Updated dependencies [f86c31ed0]
263
+ - Updated dependencies [c9d1af0e5]
264
+ - Updated dependencies [4b29d715b]
265
+ - Updated dependencies [b13a3fefd]
266
+ - Updated dependencies [68ea21214]
267
+ - Updated dependencies [8f43bf17d]
268
+ - Updated dependencies [45c03819e]
269
+ - Updated dependencies [b849128de]
270
+ - @verdaccio/config@6.0.0
271
+ - @verdaccio/core@6.0.0
272
+ - @verdaccio/url@11.0.0
273
+ - @verdaccio/utils@6.0.0
274
+
275
+ ## 6.0.0-6-next.55
276
+
277
+ ### Patch Changes
278
+
279
+ - @verdaccio/core@6.0.0-6-next.76
280
+ - @verdaccio/config@6.0.0-6-next.76
281
+ - @verdaccio/url@11.0.0-6-next.42
282
+ - @verdaccio/utils@6.0.0-6-next.44
283
+
3
284
  ## 6.0.0-6-next.54
4
285
 
5
286
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Verdaccio contributors
3
+ Copyright (c) 2024 Verdaccio contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,8 @@
1
1
  import { Config } from '@verdaccio/types';
2
+ import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
2
3
  /**
3
4
  * A middleware that avoid a registry points itself as proxy and avoid create infinite loops.
4
5
  * @param config
5
6
  * @returns
6
7
  */
7
- export declare function antiLoop(config: Config): Function;
8
+ export declare function antiLoop(config: Config): (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"antiLoop.js","names":["_core","require","antiLoop","config","req","res","next","_req$headers","headers","via","_req$get","arr","get","split","Array","isArray","i","length","m","trim","match","server_id","errorUtils","getCode","HTTP_STATUS","LOOP_DETECTED"],"sources":["../../src/middlewares/antiLoop.ts"],"sourcesContent":["import { HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { Config } from '@verdaccio/types';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\n/**\n * A middleware that avoid a registry points itself as proxy and avoid create infinite loops.\n * @param config\n * @returns\n */\nexport function antiLoop(config: Config): Function {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n if (req?.headers?.via != null) {\n const arr = req.get('via')?.split(',');\n if (Array.isArray(arr)) {\n for (let i = 0; i < arr.length; i++) {\n // the \"via\" header must contains an specific headers, this has to be on sync\n // with the proxy request\n // match eg: Server 1 or Server 2\n // TODO: improve this RegEX\n const m = arr[i].trim().match(/\\s*(\\S+)\\s+(\\S+)/);\n if (m && m[2] === config.server_id) {\n return next(errorUtils.getCode(HTTP_STATUS.LOOP_DETECTED, 'loop detected'));\n }\n }\n }\n }\n next();\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAACC,MAAc,EAAY;EACjD,OAAO,UAAUC,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IAAA,IAAAC,YAAA;IACxF,IAAI,CAAAH,GAAG,aAAHA,GAAG,wBAAAG,YAAA,GAAHH,GAAG,CAAEI,OAAO,cAAAD,YAAA,uBAAZA,YAAA,CAAcE,GAAG,KAAI,IAAI,EAAE;MAAA,IAAAC,QAAA;MAC7B,MAAMC,GAAG,IAAAD,QAAA,GAAGN,GAAG,CAACQ,GAAG,CAAC,KAAK,CAAC,cAAAF,QAAA,uBAAdA,QAAA,CAAgBG,KAAK,CAAC,GAAG,CAAC;MACtC,IAAIC,KAAK,CAACC,OAAO,CAACJ,GAAG,CAAC,EAAE;QACtB,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,GAAG,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;UACnC;UACA;UACA;UACA;UACA,MAAME,CAAC,GAAGP,GAAG,CAACK,CAAC,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,kBAAkB,CAAC;UACjD,IAAIF,CAAC,IAAIA,CAAC,CAAC,CAAC,CAAC,KAAKf,MAAM,CAACkB,SAAS,EAAE;YAClC,OAAOf,IAAI,CAACgB,gBAAU,CAACC,OAAO,CAACC,iBAAW,CAACC,aAAa,EAAE,eAAe,CAAC,CAAC;UAC7E;QACF;MACF;IACF;IACAnB,IAAI,CAAC,CAAC;EACR,CAAC;AACH"}
1
+ {"version":3,"file":"antiLoop.js","names":["_core","require","antiLoop","config","req","res","next","_req$headers","headers","via","_req$get","arr","get","split","Array","isArray","i","length","m","trim","match","server_id","errorUtils","getCode","HTTP_STATUS","LOOP_DETECTED"],"sources":["../../src/middlewares/antiLoop.ts"],"sourcesContent":["import { HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { Config } from '@verdaccio/types';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\n/**\n * A middleware that avoid a registry points itself as proxy and avoid create infinite loops.\n * @param config\n * @returns\n */\nexport function antiLoop(config: Config) {\n return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {\n if (req?.headers?.via != null) {\n const arr = req.get('via')?.split(',');\n if (Array.isArray(arr)) {\n for (let i = 0; i < arr.length; i++) {\n // the \"via\" header must contains an specific headers, this has to be on sync\n // with the proxy request\n // match eg: Server 1 or Server 2\n // TODO: improve this RegEX\n const m = arr[i].trim().match(/\\s*(\\S+)\\s+(\\S+)/);\n if (m && m[2] === config.server_id) {\n return next(errorUtils.getCode(HTTP_STATUS.LOOP_DETECTED, 'loop detected'));\n }\n }\n }\n }\n next();\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAACC,MAAc,EAAE;EACvC,OAAO,UAAUC,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IAAA,IAAAC,YAAA;IACxF,IAAI,CAAAH,GAAG,aAAHA,GAAG,wBAAAG,YAAA,GAAHH,GAAG,CAAEI,OAAO,cAAAD,YAAA,uBAAZA,YAAA,CAAcE,GAAG,KAAI,IAAI,EAAE;MAAA,IAAAC,QAAA;MAC7B,MAAMC,GAAG,IAAAD,QAAA,GAAGN,GAAG,CAACQ,GAAG,CAAC,KAAK,CAAC,cAAAF,QAAA,uBAAdA,QAAA,CAAgBG,KAAK,CAAC,GAAG,CAAC;MACtC,IAAIC,KAAK,CAACC,OAAO,CAACJ,GAAG,CAAC,EAAE;QACtB,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,GAAG,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;UACnC;UACA;UACA;UACA;UACA,MAAME,CAAC,GAAGP,GAAG,CAACK,CAAC,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,kBAAkB,CAAC;UACjD,IAAIF,CAAC,IAAIA,CAAC,CAAC,CAAC,CAAC,KAAKf,MAAM,CAACkB,SAAS,EAAE;YAClC,OAAOf,IAAI,CAACgB,gBAAU,CAACC,OAAO,CAACC,iBAAW,CAACC,aAAa,EAAE,eAAe,CAAC,CAAC;UAC7E;QACF;MACF;IACF;IACAnB,IAAI,CAAC,CAAC;EACR,CAAC;AACH"}
@@ -34,7 +34,7 @@ const handleError = logger => function handleError(err, req, res, next) {
34
34
  // Middleware
35
35
  exports.handleError = handleError;
36
36
  const errorReportingMiddleware = logger => function errorReportingMiddleware(req, res, next) {
37
- debug('error report middleware');
37
+ debug('error report middleware start');
38
38
  res.locals.report_error = res.locals.report_error || function (err) {
39
39
  if (err.status && err.status >= _core.HTTP_STATUS.BAD_REQUEST && err.status < 600) {
40
40
  debug('is error > 409 %o', err === null || err === void 0 ? void 0 : err.status);
@@ -57,7 +57,7 @@ const errorReportingMiddleware = logger => function errorReportingMiddleware(req
57
57
  debug('this is an error in express.js, please report this, destroy response %o', err);
58
58
  res.destroy();
59
59
  } else if (!res.headersSent) {
60
- debug('report internal error %o', err);
60
+ debug('send internal error %o', err);
61
61
  res.status(_core.HTTP_STATUS.INTERNAL_ERROR);
62
62
  next({
63
63
  error: _core.API_ERROR.INTERNAL_SERVER_ERROR
@@ -68,7 +68,7 @@ const errorReportingMiddleware = logger => function errorReportingMiddleware(req
68
68
  }
69
69
  }
70
70
  };
71
- debug('error report middleware next()');
71
+ debug('error report middleware end (skip next layer) next()');
72
72
  next();
73
73
  };
74
74
  exports.errorReportingMiddleware = errorReportingMiddleware;
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":["_debug","_interopRequireDefault","require","_lodash","_core","obj","__esModule","default","debug","buildDebug","handleError","logger","err","req","res","next","_","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","errorReportingMiddleware","noop","exports","status","BAD_REQUEST","isNil","headersSent","message","error","API_ERROR","UNKNOWN_ERROR","send","destroy","INTERNAL_ERROR","INTERNAL_SERVER_ERROR"],"sources":["../../src/middlewares/error.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { HttpError } from 'http-errors';\nimport _ from 'lodash';\n\nimport { API_ERROR, HTTP_STATUS, VerdaccioError } from '@verdaccio/core';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:error');\n\nexport const handleError = (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 (_.isFunction(res.locals.report_error) === false) {\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) =>\n function errorReportingMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n debug('error report middleware');\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('report internal error %o', err);\n res.status(HTTP_STATUS.INTERNAL_ERROR);\n next({ error: API_ERROR.INTERNAL_SERVER_ERROR });\n } else {\n // socket should be already closed\n debug('this should not happen, otherwise report %o', err);\n }\n }\n };\n\n debug('error report middleware next()');\n next();\n };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAAyE,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAIzE,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,4BAA4B,CAAC;AAE/C,MAAMC,WAAW,GAAIC,MAAM,IAChC,SAASD,WAAWA,CAClBE,GAAc,EACdC,GAAmB,EACnBC,GAAoB,EACpBC,IAAsB,EACtB;EACAP,KAAK,CAAC,oBAAoB,CAAC;EAC3B,IAAIQ,eAAC,CAACC,OAAO,CAACL,GAAG,CAAC,EAAE;IAClBJ,KAAK,CAAC,iBAAiB,CAAC;IACxB,IAAII,GAAG,CAACM,IAAI,KAAK,YAAY,IAAIJ,GAAG,CAACK,UAAU,KAAKC,iBAAW,CAACC,YAAY,EAAE;MAC5E,OAAON,IAAI,CAAC,CAAC;IACf;IACA,IAAIC,eAAC,CAACM,UAAU,CAACR,GAAG,CAACS,MAAM,CAACC,YAAY,CAAC,KAAK,KAAK,EAAE;MACnDhB,KAAK,CAAC,4BAA4B,CAAC;MACnC;MACA;MACAiB,wBAAwB,CAACd,MAA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L3B,KAAK,CAAC,mBAAmB,EAAEI,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEgB,MAAM,CAAC;MACvCjB,MAAM,CAACsB,KAAK,CAAC;QAAErB,GAAG,EAAEA;MAAI,CAAC,EAAE,iDAAiD,CAAC;MAC7E,IAAI,CAACE,GAAG,CAACc,MAAM,IAAI,CAACd,GAAG,CAACsB,IAAI,EAAE;QAC5B;QACAzB,MAAM,CAACsB,KAAK,CAAC,oDAAoD,CAAC;QAClEzB,KAAK,CAAC,yEAAyE,EAAEI,GAAG,CAAC;QACrFE,GAAG,CAACuB,OAAO,CAAC,CAAC;MACf,CAAC,MAAM,IAAI,CAACvB,GAAG,CAACiB,WAAW,EAAE;QAC3BvB,KAAK,CAAC,0BAA0B,EAAEI,GAAG,CAAC;QACtCE,GAAG,CAACc,MAAM,CAACR,iBAAW,CAACkB,cAAc,CAAC;QACtCvB,IAAI,CAAC;UAAEkB,KAAK,EAAEC,eAAS,CAACK;QAAsB,CAAC,CAAC;MAClD,CAAC,MAAM;QACL;QACA/B,KAAK,CAAC,6CAA6C,EAAEI,GAAG,CAAC;MAC3D;IACF;EACF,CAAC;EAEHJ,KAAK,CAAC,gCAAgC,CAAC;EACvCO,IAAI,CAAC,CAAC;AACR,CAAC;AAACY,OAAA,CAAAF,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"file":"error.js","names":["_debug","_interopRequireDefault","require","_lodash","_core","obj","__esModule","default","debug","buildDebug","handleError","logger","err","req","res","next","_","isError","code","statusCode","HTTP_STATUS","NOT_MODIFIED","isFunction","locals","report_error","errorReportingMiddleware","noop","exports","status","BAD_REQUEST","isNil","headersSent","message","error","API_ERROR","UNKNOWN_ERROR","send","destroy","INTERNAL_ERROR","INTERNAL_SERVER_ERROR"],"sources":["../../src/middlewares/error.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { HttpError } from 'http-errors';\nimport _ from 'lodash';\n\nimport { API_ERROR, HTTP_STATUS, VerdaccioError } from '@verdaccio/core';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:error');\n\nexport const handleError = (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 (_.isFunction(res.locals.report_error) === false) {\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) =>\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 // socket should be already closed\n debug('this should not happen, otherwise report %o', err);\n }\n }\n };\n\n debug('error report middleware end (skip next layer) next()');\n next();\n };\n"],"mappings":";;;;;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,MAAM,IAAI,CAACvB,GAAG,CAACiB,WAAW,EAAE;QAC3BvB,KAAK,CAAC,wBAAwB,EAAEI,GAAG,CAAC;QACpCE,GAAG,CAACc,MAAM,CAACR,iBAAW,CAACkB,cAAc,CAAC;QACtCvB,IAAI,CAAC;UAAEkB,KAAK,EAAEC,eAAS,CAACK;QAAsB,CAAC,CAAC;MAClD,CAAC,MAAM;QACL;QACA/B,KAAK,CAAC,6CAA6C,EAAEI,GAAG,CAAC;MAC3D;IACF;EACF,CAAC;EAEHJ,KAAK,CAAC,sDAAsD,CAAC;EAC7DO,IAAI,CAAC,CAAC;AACR,CAAC;AAACY,OAAA,CAAAF,wBAAA,GAAAA,wBAAA"}
@@ -4,24 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.final = final;
7
+ var _debug = _interopRequireDefault(require("debug"));
7
8
  var _lodash = _interopRequireDefault(require("lodash"));
8
9
  var _core = require("@verdaccio/core");
9
10
  var _utils = require("@verdaccio/utils");
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const debug = (0, _debug.default)('verdaccio:middleware:final');
11
13
  function final(body, req, res,
12
14
  // if we remove `next` breaks test
13
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
16
  next) {
15
17
  if (res.statusCode === _core.HTTP_STATUS.UNAUTHORIZED && !res.getHeader(_core.HEADERS.WWW_AUTH)) {
18
+ debug('set auth header support');
16
19
  res.header(_core.HEADERS.WWW_AUTH, `${_core.TOKEN_BASIC}, ${_core.TOKEN_BEARER}`);
17
20
  }
18
21
  try {
19
22
  if (_lodash.default.isString(body) || _lodash.default.isObject(body)) {
20
23
  if (!res.get(_core.HEADERS.CONTENT_TYPE)) {
24
+ debug('set json type header support');
21
25
  res.header(_core.HEADERS.CONTENT_TYPE, _core.HEADERS.JSON);
22
26
  }
23
27
  if (typeof body === 'object' && _lodash.default.isNil(body) === false) {
24
28
  if (typeof body.error === 'string') {
29
+ debug('set verdaccio_error method');
25
30
  res.locals._verdaccio_error = body.error;
26
31
  }
27
32
  body = JSON.stringify(body, undefined, ' ') + '\n';
@@ -29,9 +34,12 @@ next) {
29
34
 
30
35
  // don't send etags with errors
31
36
  if (!res.statusCode || res.statusCode >= _core.HTTP_STATUS.OK && res.statusCode < _core.HTTP_STATUS.MULTIPLE_CHOICES) {
32
- res.header(_core.HEADERS.ETAG, '"' + (0, _utils.stringToMD5)(body) + '"');
37
+ const etag = (0, _utils.stringToMD5)(body);
38
+ debug('set etag header %s', etag);
39
+ res.header(_core.HEADERS.ETAG, '"' + etag + '"');
33
40
  }
34
41
  } else {
42
+ debug('this line should never be visible, if does report');
35
43
  // send(null), send(204), etc.
36
44
  }
37
45
  } catch (err) {
@@ -39,8 +47,10 @@ next) {
39
47
  // as an error handler, we can't report error properly,
40
48
  // and should just close socket
41
49
  if (err.message.match(/set headers after they are sent/)) {
50
+ debug('set headers after they are sent');
42
51
  if (_lodash.default.isNil(res.socket) === false) {
43
52
  var _res$socket;
53
+ debug('force destroy socket');
44
54
  (_res$socket = res.socket) === null || _res$socket === void 0 ? void 0 : _res$socket.destroy();
45
55
  }
46
56
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"final.js","names":["_lodash","_interopRequireDefault","require","_core","_utils","obj","__esModule","default","final","body","req","res","next","statusCode","HTTP_STATUS","UNAUTHORIZED","getHeader","HEADERS","WWW_AUTH","header","TOKEN_BASIC","TOKEN_BEARER","_","isString","isObject","get","CONTENT_TYPE","JSON","isNil","error","locals","_verdaccio_error","stringify","undefined","OK","MULTIPLE_CHOICES","ETAG","stringToMD5","err","message","match","socket","_res$socket","destroy","send"],"sources":["../../src/middlewares/final.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport { HEADERS, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '@verdaccio/core';\nimport { Manifest } from '@verdaccio/types';\nimport { stringToMD5 } from '@verdaccio/utils';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, MiddlewareError } from '../types';\n\nexport type FinalBody = Manifest | MiddlewareError | string;\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 res.header(HEADERS.WWW_AUTH, `${TOKEN_BASIC}, ${TOKEN_BEARER}`);\n }\n\n try {\n if (_.isString(body) || _.isObject(body)) {\n if (!res.get(HEADERS.CONTENT_TYPE)) {\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 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 res.header(HEADERS.ETAG, '\"' + stringToMD5(body as string) + '\"');\n }\n } else {\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 if (_.isNil(res.socket) === false) {\n res.socket?.destroy();\n }\n return;\n }\n throw err;\n }\n\n res.send(body);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAA+C,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAMxC,SAASG,KAAKA,CACnBC,IAAe,EACfC,GAAmB,EACnBC,GAAoB;AACpB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IACA;IACA,IAAIA,GAAG,CAACC,OAAO,CAACC,KAAK,CAAC,iCAAiC,CAAC,EAAE;MACxD,IAAIlB,eAAC,CAACM,KAAK,CAACjB,GAAG,CAAC8B,MAAM,CAAC,KAAK,KAAK,EAAE;QAAA,IAAAC,WAAA;QACjC,CAAAA,WAAA,GAAA/B,GAAG,CAAC8B,MAAM,cAAAC,WAAA,uBAAVA,WAAA,CAAYC,OAAO,CAAC,CAAC;MACvB;MACA;IACF;IACA,MAAML,GAAG;EACX;EAEA3B,GAAG,CAACiC,IAAI,CAACnC,IAAI,CAAC;AAChB"}
1
+ {"version":3,"file":"final.js","names":["_debug","_interopRequireDefault","require","_lodash","_core","_utils","obj","__esModule","default","debug","buildDebug","final","body","req","res","next","statusCode","HTTP_STATUS","UNAUTHORIZED","getHeader","HEADERS","WWW_AUTH","header","TOKEN_BASIC","TOKEN_BEARER","_","isString","isObject","get","CONTENT_TYPE","JSON","isNil","error","locals","_verdaccio_error","stringify","undefined","OK","MULTIPLE_CHOICES","etag","stringToMD5","ETAG","err","message","match","socket","_res$socket","destroy","send"],"sources":["../../src/middlewares/final.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { HEADERS, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '@verdaccio/core';\nimport { Manifest } from '@verdaccio/types';\nimport { stringToMD5 } from '@verdaccio/utils';\n\nimport { $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_BASIC}, ${TOKEN_BEARER}`);\n }\n\n try {\n if (_.isString(body) || _.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 = 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":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAA+C,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAM/C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,4BAA4B,CAAC;AAE/C,SAASC,KAAKA,CACnBC,IAAe,EACfC,GAAmB,EACnBC,GAAoB;AACpB;AACA;AACAC,IAAsB,EAChB;EACN,IAAID,GAAG,CAACE,UAAU,KAAKC,iBAAW,CAACC,YAA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I,GAAG,GAAG,CAAC;MAC5C;IACF,CAAC,MAAM;MACL9B,KAAK,CAAC,mDAAmD,CAAC;MAC1D;IACF;EACF,CAAC,CAAC,OAAOiC,GAAQ,EAAE;IACjB;IACA;IACA;IACA,IAAIA,GAAG,CAACC,OAAO,CAACC,KAAK,CAAC,iCAAiC,CAAC,EAAE;MACxDnC,KAAK,CAAC,iCAAiC,CAAC;MACxC,IAAIgB,eAAC,CAACM,KAAK,CAACjB,GAAG,CAAC+B,MAAM,CAAC,KAAK,KAAK,EAAE;QAAA,IAAAC,WAAA;QACjCrC,KAAK,CAAC,sBAAsB,CAAC;QAC7B,CAAAqC,WAAA,GAAAhC,GAAG,CAAC+B,MAAM,cAAAC,WAAA,uBAAVA,WAAA,CAAYC,OAAO,CAAC,CAAC;MACvB;MACA;IACF;IACA,MAAML,GAAG;EACX;EAEA5B,GAAG,CAACkC,IAAI,CAACpC,IAAI,CAAC;AAChB"}
@@ -1,5 +1,5 @@
1
1
  import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
2
2
  export declare const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
3
- export declare const LOG_VERDACCIO_ERROR: string;
4
- export declare const LOG_VERDACCIO_BYTES: string;
3
+ export declare const LOG_VERDACCIO_ERROR = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}', error: @{!error}";
4
+ export declare const LOG_VERDACCIO_BYTES = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}', bytes: @{bytes.in}/@{bytes.out}";
5
5
  export declare const log: (logger: any) => (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => void;
@@ -7,12 +7,9 @@ exports.log = exports.LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_BYTES = export
7
7
  var _lodash = _interopRequireDefault(require("lodash"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  // FIXME: deprecated, moved to @verdaccio/dev-commons
10
- const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
11
- exports.LOG_STATUS_MESSAGE = LOG_STATUS_MESSAGE;
12
- const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
13
- exports.LOG_VERDACCIO_ERROR = LOG_VERDACCIO_ERROR;
14
- const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
15
- exports.LOG_VERDACCIO_BYTES = LOG_VERDACCIO_BYTES;
10
+ const LOG_STATUS_MESSAGE = exports.LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
11
+ const LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
12
+ const LOG_VERDACCIO_BYTES = exports.LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
16
13
  const log = logger => {
17
14
  return function log(req, res, next) {
18
15
  // logger
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","names":["_lodash","_interopRequireDefault","require","obj","__esModule","default","LOG_STATUS_MESSAGE","exports","LOG_VERDACCIO_ERROR","LOG_VERDACCIO_BYTES","log","logger","req","res","next","child","sub","_auth","headers","authorization","_","isNil","_cookie","get","cookie","url","originalUrl","info","ip","bytesin","on","chunk","length","bytesout","_write","write","buf","apply","arguments","_req$remote_user","forwardedFor","remoteAddress","connection","remoteIP","message","locals","_verdaccio_error","http","request","method","user","remote_user","name","status","statusCode","error","bytes","in","out","_end","end"],"sources":["../../src/middlewares/log.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\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 const log = (logger) => {\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 req.log.info({ req: req, ip: req.ip }, \"@{ip} requested '@{req.method} @{req.url}'\");\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 // FIXME: res.write should return boolean\n // @ts-ignore\n res.write = function (buf): boolean {\n bytesout += buf.length;\n /* eslint prefer-rest-params: \"off\" */\n // @ts-ignore\n _write.apply(res, arguments);\n };\n\n const log = function (): void {\n const forwardedFor = req.get('x-forwarded-for');\n const remoteAddress = req.connection.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 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 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 (buf): void {\n if (buf) {\n bytesout += buf.length;\n }\n /* eslint prefer-rest-params: \"off\" */\n // @ts-ignore\n _end.apply(res, arguments);\n log();\n };\n next();\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAIvB;AACO,MAAMG,kBAAkB,GAC7B,gFAAgF;AAACC,OAAA,CAAAD,kBAAA,GAAAA,kBAAA;AAC5E,MAAME,mBAAmB,GAAI,GAAEF,kBAAmB,oBAAmB;AAACC,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AACtE,MAAMC,mBAAmB,GAAI,GAAEH,kBAAmB,mCAAkC;AAACC,OAAA,CAAAE,mBAAA,GAAAA,mBAAA;AAErF,MAAMC,GAAG,GAAIC,MAAM,IAAK;EAC7B,OAAO,SAASD,GAAGA,CAACE,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IAC3F;IACAF,GAAG,CAACF,GAAG,GAAGC,MAAM,CAACI,KAAK,CAAC;MAAEC,GAAG,EAAE;IAAK,CAAC,CAAC;IAErC,MAAMC,KAAK,GAAGL,GAAG,CAACM,OAAO,CAACC,aAAa;IACvC,IAAIC,eAAC,CAACC,KAAK,CAACJ,KAAK,CAAC,KAAK,KAAK,EAAE;MAC5BL,GAAG,CAACM,OAAO,CAACC,aAAa,GAAG,cAAc;IAC5C;IAEA,MAAMG,OAAO,GAAGV,GAAG,CAACW,GAAG,CAAC,QAAQ,CAAC;IACjC,IAAIH,eAAC,CAACC,KAAK,CAACC,OAAO,CAAC,KAAK,KAAK,EAAE;MAC9BV,GAAG,CAACM,OAAO,CAACM,MAAM,GAAG,cAAc;IACrC;IAEAZ,GAAG,CAACa,GAAG,GAAGb,GAAG,CAACc,WAAW;IACzBd,GAAG,CAACF,GAAG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AAC,MAAM;QACLoC,OAAO,GAAGnC,mBAAmB;MAC/B;MAEAG,GAAG,CAACa,GAAG,GAAGb,GAAG,CAACc,WAAW;MACzBd,GAAG,CAACF,GAAG,CAACqC,IAAI,CACV;QACEC,OAAO,EAAE;UACPC,MAAM,EAAErC,GAAG,CAACqC,MAAM;UAClBxB,GAAG,EAAEb,GAAG,CAACa;QACX,CAAC;QACDyB,IAAI,EAAE,EAAAX,gBAAA,GAAA3B,GAAG,CAACuC,WAAW,cAAAZ,gBAAA,uBAAfA,gBAAA,CAAiBa,IAAI,KAAI,IAAI;QACnCT,QAAQ;QACRU,MAAM,EAAExC,GAAG,CAACyC,UAAU;QACtBC,KAAK,EAAE1C,GAAG,CAACgC,MAAM,CAACC,gBAAgB;QAClCU,KAAK,EAAE;UACLC,EAAE,EAAE5B,OAAO;UACX6B,GAAG,EAAEzB;QACP;MACF,CAAC,EACDW,OACF,CAAC;MACDhC,GAAG,CAACc,WAAW,GAAGd,GAAG,CAACa,GAAG;IAC3B,CAAC;IAEDb,GAAG,CAACkB,EAAE,CAAC,OAAO,EAAE,YAAkB;MAChCpB,GAAG,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,MAAMiD,IAAI,GAAG9C,GAAG,CAAC+C,GAAG;IACpB;IACA/C,GAAG,CAAC+C,GAAG,GAAG,UAAUxB,GAAG,EAAQ;MAC7B,IAAIA,GAAG,EAAE;QACPH,QAAQ,IAAIG,GAAG,CAACJ,MAAM;MACxB;MACA;MACA;MACA2B,IAAI,CAACtB,KAAK,CAACxB,GAAG,EAAEyB,SAAS,CAAC;MAC1B5B,GAAG,CAAC,CAAC;IACP,CAAC;IACDI,IAAI,CAAC,CAAC;EACR,CAAC;AACH,CAAC;AAACP,OAAA,CAAAG,GAAA,GAAAA,GAAA"}
1
+ {"version":3,"file":"log.js","names":["_lodash","_interopRequireDefault","require","obj","__esModule","default","LOG_STATUS_MESSAGE","exports","LOG_VERDACCIO_ERROR","LOG_VERDACCIO_BYTES","log","logger","req","res","next","child","sub","_auth","headers","authorization","_","isNil","_cookie","get","cookie","url","originalUrl","info","ip","bytesin","on","chunk","length","bytesout","_write","write","buf","apply","arguments","_req$remote_user","forwardedFor","remoteAddress","connection","remoteIP","message","locals","_verdaccio_error","http","request","method","user","remote_user","name","status","statusCode","error","bytes","in","out","_end","end"],"sources":["../../src/middlewares/log.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\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 const log = (logger) => {\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 req.log.info({ req: req, ip: req.ip }, \"@{ip} requested '@{req.method} @{req.url}'\");\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 // FIXME: res.write should return boolean\n // @ts-ignore\n res.write = function (buf): boolean {\n bytesout += buf.length;\n /* eslint prefer-rest-params: \"off\" */\n // @ts-ignore\n _write.apply(res, arguments);\n };\n\n const log = function (): void {\n const forwardedFor = req.get('x-forwarded-for');\n const remoteAddress = req.connection.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 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 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 (buf): void {\n if (buf) {\n bytesout += buf.length;\n }\n /* eslint prefer-rest-params: \"off\" */\n // @ts-ignore\n _end.apply(res, arguments);\n log();\n };\n next();\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAIvB;AACO,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAC7B,gFAAgF;AAC3E,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAI,GAAEF,kBAAmB,oBAAmB;AACrE,MAAMG,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAI,GAAEH,kBAAmB,mCAAkC;AAEpF,MAAMI,GAAG,GAAIC,MAAM,IAAK;EAC7B,OAAO,SAASD,GAAGA,CAACE,GAAmB,EAAEC,GAAoB,EAAEC,IAAsB,EAAQ;IAC3F;IACAF,GAAG,CAACF,GAAG,GAAGC,MAAM,CAACI,KAAK,CAAC;MAAEC,GAAG,EAAE;IAAK,CAAC,CAAC;IAErC,MAAMC,KAAK,GAAGL,GAAG,CAACM,OAAO,CAACC,aAAa;IACvC,IAAIC,eAAC,CAACC,KAAK,CAACJ,KAA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G,GAAG,CAACJ,MAAM;MACxB;MACA;MACA;MACA2B,IAAI,CAACtB,KAAK,CAACxB,GAAG,EAAEyB,SAAS,CAAC;MAC1B5B,GAAG,CAAC,CAAC;IACP,CAAC;IACDI,IAAI,CAAC,CAAC;EACR,CAAC;AACH,CAAC;AAACP,OAAA,CAAAG,GAAA,GAAAA,GAAA"}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getManifestValue = getManifestValue;
7
7
  var _debug = _interopRequireDefault(require("debug"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const debug = (0, _debug.default)('verdaccio:web:render:manifest');
9
+ const debug = (0, _debug.default)('verdaccio:middleware:web:render:manifest');
10
10
  function getManifestValue(manifestItems, manifest, basePath = '') {
11
11
  return manifestItems === null || manifestItems === void 0 ? void 0 : manifestItems.map(item => {
12
12
  debug('resolve item %o', item);
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","names":["_debug","_interopRequireDefault","require","obj","__esModule","default","debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../../../src/middlewares/web/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAS/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AAElD,SAASC,gBAAgBA,CAC9BC,aAAuB,EACvBC,QAAQ,EACRC,QAAgB,GAAG,EAAE,EACX;EACV,OAAOF,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEG,GAAG,CAAEC,IAAI,IAAK;IAClCP,KAAK,CAAC,iBAAiB,EAAEO,IAAI,CAAC;IAC9B,MAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAI,CAAE,EAAC;IACnDP,KAAK,CAAC,kBAAkB,EAAEQ,YAAY,CAAC;IACvC,OAAOA,YAAY;EACrB,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"manifest.js","names":["_debug","_interopRequireDefault","require","obj","__esModule","default","debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../../../src/middlewares/web/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:middleware:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAS/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0CAA0C,CAAC;AAE7D,SAASC,gBAAgBA,CAC9BC,aAAuB,EACvBC,QAAQ,EACRC,QAAgB,GAAG,EAAE,EACX;EACV,OAAOF,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEG,GAAG,CAAEC,IAAI,IAAK;IAClCP,KAAK,CAAC,iBAAiB,EAAEO,IAAI,CAAC;IAC9B,MAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAI,CAAE,EAAC;IACnDP,KAAK,CAAC,kBAAkB,EAAEQ,YAAY,CAAC;IACvC,OAAOA,YAAY;EACrB,CAAC,CAAC;AACJ"}
@@ -42,28 +42,29 @@ function resolveLogo(config, req) {
42
42
  }
43
43
  }
44
44
  function renderHTML(config, manifest, manifestFiles, req, res) {
45
- var _config$i18n$web, _config$i18n, _config$web7, _config$web8, _config$web$darkMode, _config$web9, _config$web$title, _config$web10, _config$web$scope, _config$web11, _config$web$pkgManage, _config$web12, _res$locals$app_versi, _validatePrimaryColor, _config$web$primary_c, _config$web13, _config$web14;
45
+ var _config$i18n$web, _config$i18n, _config$web$hideDepre, _config$web7, _config$web8, _config$web9, _config$web$darkMode, _config$web10, _config$web$title, _config$web11, _config$web$scope, _config$web12, _config$web$pkgManage, _config$web13, _res$locals$app_versi, _validatePrimaryColor, _config$web$primary_c, _config$web14, _config$web15;
46
46
  const {
47
47
  url_prefix
48
48
  } = config;
49
49
  const base = (0, _url2.getPublicUrl)(config === null || config === void 0 ? void 0 : config.url_prefix, req);
50
50
  const basename = new _url.URL(base).pathname;
51
51
  const language = (_config$i18n$web = config === null || config === void 0 ? void 0 : (_config$i18n = config.i18n) === null || _config$i18n === void 0 ? void 0 : _config$i18n.web) !== null && _config$i18n$web !== void 0 ? _config$i18n$web : DEFAULT_LANGUAGE;
52
+ const hideDeprecatedVersions = (_config$web$hideDepre = config === null || config === void 0 ? void 0 : (_config$web7 = config.web) === null || _config$web7 === void 0 ? void 0 : _config$web7.hideDeprecatedVersions) !== null && _config$web$hideDepre !== void 0 ? _config$web$hideDepre : false;
52
53
  // @ts-ignore
53
- const needHtmlCache = [undefined, null].includes(config === null || config === void 0 ? void 0 : (_config$web7 = config.web) === null || _config$web7 === void 0 ? void 0 : _config$web7.html_cache) ? true : config === null || config === void 0 ? void 0 : (_config$web8 = config.web) === null || _config$web8 === void 0 ? void 0 : _config$web8.html_cache;
54
- const darkMode = (_config$web$darkMode = config === null || config === void 0 ? void 0 : (_config$web9 = config.web) === null || _config$web9 === void 0 ? void 0 : _config$web9.darkMode) !== null && _config$web$darkMode !== void 0 ? _config$web$darkMode : false;
55
- const title = (_config$web$title = config === null || config === void 0 ? void 0 : (_config$web10 = config.web) === null || _config$web10 === void 0 ? void 0 : _config$web10.title) !== null && _config$web$title !== void 0 ? _config$web$title : _config.WEB_TITLE;
54
+ const needHtmlCache = [undefined, null].includes(config === null || config === void 0 ? void 0 : (_config$web8 = config.web) === null || _config$web8 === void 0 ? void 0 : _config$web8.html_cache) ? true : config === null || config === void 0 ? void 0 : (_config$web9 = config.web) === null || _config$web9 === void 0 ? void 0 : _config$web9.html_cache;
55
+ const darkMode = (_config$web$darkMode = config === null || config === void 0 ? void 0 : (_config$web10 = config.web) === null || _config$web10 === void 0 ? void 0 : _config$web10.darkMode) !== null && _config$web$darkMode !== void 0 ? _config$web$darkMode : false;
56
+ const title = (_config$web$title = config === null || config === void 0 ? void 0 : (_config$web11 = config.web) === null || _config$web11 === void 0 ? void 0 : _config$web11.title) !== null && _config$web$title !== void 0 ? _config$web$title : _config.WEB_TITLE;
56
57
  const login = (0, _webUtils.hasLogin)(config);
57
- const scope = (_config$web$scope = config === null || config === void 0 ? void 0 : (_config$web11 = config.web) === null || _config$web11 === void 0 ? void 0 : _config$web11.scope) !== null && _config$web$scope !== void 0 ? _config$web$scope : '';
58
+ const scope = (_config$web$scope = config === null || config === void 0 ? void 0 : (_config$web12 = config.web) === null || _config$web12 === void 0 ? void 0 : _config$web12.scope) !== null && _config$web$scope !== void 0 ? _config$web$scope : '';
58
59
  const logo = resolveLogo(config, req);
59
- const pkgManagers = (_config$web$pkgManage = config === null || config === void 0 ? void 0 : (_config$web12 = config.web) === null || _config$web12 === void 0 ? void 0 : _config$web12.pkgManagers) !== null && _config$web$pkgManage !== void 0 ? _config$web$pkgManage : ['yarn', 'pnpm', 'npm'];
60
+ const pkgManagers = (_config$web$pkgManage = config === null || config === void 0 ? void 0 : (_config$web13 = config.web) === null || _config$web13 === void 0 ? void 0 : _config$web13.pkgManagers) !== null && _config$web$pkgManage !== void 0 ? _config$web$pkgManage : ['yarn', 'pnpm', 'npm'];
60
61
  const version = (_res$locals$app_versi = res.locals.app_version) !== null && _res$locals$app_versi !== void 0 ? _res$locals$app_versi : '';
61
62
  const flags = {
62
63
  ...config.flags,
63
64
  // legacy from 5.x
64
65
  ...config.experiments
65
66
  };
66
- const primaryColor = (_validatePrimaryColor = (0, _webUtils.validatePrimaryColor)((_config$web$primary_c = config === null || config === void 0 ? void 0 : (_config$web13 = config.web) === null || _config$web13 === void 0 ? void 0 : _config$web13.primary_color) !== null && _config$web$primary_c !== void 0 ? _config$web$primary_c : config === null || config === void 0 ? void 0 : (_config$web14 = config.web) === null || _config$web14 === void 0 ? void 0 : _config$web14.primaryColor)) !== null && _validatePrimaryColor !== void 0 ? _validatePrimaryColor : '#4b5e40';
67
+ const primaryColor = (_validatePrimaryColor = (0, _webUtils.validatePrimaryColor)((_config$web$primary_c = config === null || config === void 0 ? void 0 : (_config$web14 = config.web) === null || _config$web14 === void 0 ? void 0 : _config$web14.primary_color) !== null && _config$web$primary_c !== void 0 ? _config$web$primary_c : config === null || config === void 0 ? void 0 : (_config$web15 = config.web) === null || _config$web15 === void 0 ? void 0 : _config$web15.primaryColor)) !== null && _validatePrimaryColor !== void 0 ? _validatePrimaryColor : '#4b5e40';
67
68
  const {
68
69
  scriptsBodyAfter,
69
70
  metaScripts,
@@ -98,7 +99,8 @@ function renderHTML(config, manifest, manifestFiles, req, res) {
98
99
  pkgManagers,
99
100
  title,
100
101
  scope,
101
- language
102
+ language,
103
+ hideDeprecatedVersions
102
104
  };
103
105
  let webPage;
104
106
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"renderHTML.js","names":["_debug","_interopRequireDefault","require","_lruCache","_path","_url","_config","_core","_url2","_template","_webUtils","obj","__esModule","default","DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","resolveLogo","config","req","_config$web","_config$web2","_config$web3","_config$web5","web","logo","isLocalFile","isURLhasValidProtocol","_config$web4","getPublicUrl","url_prefix","path","basename","_config$web6","renderHTML","manifest","manifestFiles","res","_config$i18n$web","_config$i18n","_config$web7","_config$web8","_config$web$darkMode","_config$web9","_config$web$title","_config$web10","_config$web$scope","_config$web11","_config$web$pkgManage","_config$web12","_res$locals$app_versi","_validatePrimaryColor","_config$web$primary_c","_config$web13","_config$web14","base","URL","pathname","language","i18n","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","pkgManagers","version","locals","app_version","flags","experiments","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport path from 'path';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\nimport { getPublicUrl } from '@verdaccio/url';\n\nimport renderTemplate from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n};\n\nexport function resolveLogo(config: ConfigYaml, req) {\n if (typeof config?.web?.logo !== 'string') {\n return '';\n }\n const isLocalFile = config?.web?.logo && !isURLhasValidProtocol(config?.web?.logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(config?.url_prefix, req)}-/static/${path.basename(config?.web?.logo)}`;\n } else if (isURLhasValidProtocol(config?.web?.logo)) {\n return config?.web?.logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(config: ConfigYaml, manifest, manifestFiles, req, res) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, req);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n // @ts-ignore\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config?.web?.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logo = resolveLogo(config, req);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAN,OAAA;AAGA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAA6D,SAAAD,uBAAAU,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE7D,MAAMG,gBAAgB,GAAG,OAAO;AAChC,MAAMC,KAAK,GAAG,IAAIC,iBAAG,CAAC;EAAEC,GAAG,EAAE,GAAG;EAAEC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG;AAAG,CAAC,CAAC;AAExD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,oBAAoB,GAAG;EAC3BC,EAAE,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC;EAC3CC,GAAG,EAAE;AACP,CAAC;AAEM,SAASC,WAAWA,CAACC,MAAkB,EAAEC,GAAG,EAAE;EAAA,IAAAC,WAAA,EAAAC,YAAA,EAAAC,YAAA,EAAAC,YAAA;EACnD,IAAI,QAAOL,MAAM,aAANA,MAAM,wBAAAE,WAAA,GAANF,MAAM,CAAEM,GAAG,cAAAJ,WAAA,uBAAXA,WAAA,CAAaK,IAAI,MAAK,QA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Default","require","_lruCache","_path","_url","_config","_core","_url2","_template","_webUtils","obj","__esModule","default","DEFAULT_LANGUAGE","cache","LRU","max","ttl","debug","buildDebug","defaultManifestFiles","js","ico","resolveLogo","config","req","_config$web","_config$web2","_config$web3","_config$web5","web","logo","isLocalFile","isURLhasValidProtocol","_config$web4","getPublicUrl","url_prefix","path","basename","_config$web6","renderHTML","manifest","manifestFiles","res","_config$i18n$web","_config$i18n","_config$web$hideDepre","_config$web7","_config$web8","_config$web9","_config$web$darkMode","_config$web10","_config$web$title","_config$web11","_config$web$scope","_config$web12","_config$web$pkgManage","_config$web13","_res$locals$app_versi","_validatePrimaryColor","_config$web$primary_c","_config$web14","_config$web15","base","URL","pathname","language","i18n","hideDeprecatedVersions","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","pkgManagers","version","locals","app_version","flags","experiments","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../../../../src/middlewares/web/utils/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport path from 'path';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { ConfigYaml, TemplateUIOptions } from '@verdaccio/types';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\nimport { getPublicUrl } from '@verdaccio/url';\n\nimport renderTemplate from './template';\nimport { hasLogin, validatePrimaryColor } from './web-utils';\n\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n};\n\nexport function resolveLogo(config: ConfigYaml, req) {\n if (typeof config?.web?.logo !== 'string') {\n return '';\n }\n const isLocalFile = config?.web?.logo && !isURLhasValidProtocol(config?.web?.logo);\n\n if (isLocalFile) {\n return `${getPublicUrl(config?.url_prefix, req)}-/static/${path.basename(config?.web?.logo)}`;\n } else if (isURLhasValidProtocol(config?.web?.logo)) {\n return config?.web?.logo;\n } else {\n return '';\n }\n}\n\nexport default function renderHTML(config: ConfigYaml, manifest, manifestFiles, req, res) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, req);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;\n // @ts-ignore\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config?.web?.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logo = resolveLogo(config, req);\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = res.locals.app_version ?? '';\n const flags = {\n ...config.flags,\n // legacy from 5.x\n ...config.experiments,\n };\n const primaryColor =\n validatePrimaryColor(config?.web?.primary_color ?? config?.web?.primaryColor) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logo,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n hideDeprecatedVersions,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAN,OAAA;AAGA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAA6D,SAAAD,uBAAAU,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE7D,MAAMG,gBAAgB,GAAG,OAAO;AAChC,MAAMC,KAAK,GAAG,IAAIC,iBAAG,CAAC;EAAEC,GAAG,EAAE,GAAG;EAAEC,GAAG,EAAE,IAAI,GAAG,EAAE,GAAG;AAAG,CAAC,CAAC;AAExD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,sBAAsB,CAAC;AAEhD,MAAMC,oBAAoB,GAAG;EAC3BC,EAAE,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC;EAC3CC,GAAG,EAAE;AACP,CAAC;AAEM,SAASC,WAAWA,CAACC,MAAkB,EAAEC,GAAG,EAAE;EAAA,IAAAC,WAAA,EAAAC,YAAA,EAAAC,YAAA,EAA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CAAC;MAC7B;IACF,CAAC,MAAM;MACLA,KAAK,CAAC,sBAAsB,CAAC;IAC/B;EACF,CAAC,CAAC,OAAOuF,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAE,kCAAiCD,KAAK,CAACE,KAAM,EAAC,CAAC;EAClE;EACAhE,GAAG,CAACiE,SAAS,CAAC,cAAc,EAAEC,aAAO,CAACC,SAAS,CAAC;EAChDnE,GAAG,CAACoE,IAAI,CAACV,OAAO,CAAC;EACjBnF,KAAK,CAAC,cAAc,CAAC;AACvB"}
@@ -7,8 +7,8 @@ exports.webAPIMiddleware = webAPIMiddleware;
7
7
  var _express = _interopRequireWildcard(require("express"));
8
8
  var _validation = require("../validation");
9
9
  var _security = require("./security");
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
12
  function webAPIMiddleware(tokenMiddleware, webEndpointsApi) {
13
13
  // eslint-disable-next-line new-cap
14
14
  const route = (0, _express.Router)();
@@ -1 +1 @@
1
- {"version":3,"file":"web-api.js","names":["_express","_interopRequireWildcard","require","_validation","_security","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","webAPIMiddleware","tokenMiddleware","webEndpointsApi","route","Router","param","validatePackage","validateName","use","express","urlencoded","extended","setSecurityWebHeaders"],"sources":["../../../src/middlewares/web/web-api.ts"],"sourcesContent":["import express from 'express';\nimport { RequestHandler, Router } from 'express';\n\nimport { validateName, validatePackage } from '../validation';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPIMiddleware(\n tokenMiddleware: RequestHandler,\n webEndpointsApi: RequestHandler\n): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.use(express.urlencoded({ extended: false }));\n route.use(setSecurityWebHeaders);\n\n if (typeof tokenMiddleware === 'function') {\n route.use(tokenMiddleware);\n }\n\n if (typeof webEndpointsApi === 'function') {\n route.use(webEndpointsApi);\n }\n\n return route;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD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,EAAC,CAAC;EACtB;EACA;EACAD,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEC,2BAAe,CAAC;EACvCH,KAAK,CAACE,KAAK,CAAC,UAAU,EAAEE,wBAAY,CAAC;EACrCJ,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEE,wBAAY,CAAC;EACpCJ,KAAK,CAACK,GAAG,CAACC,gBAAO,CAACC,UAAU,CAAC;IAAEC,QAAQ,EAAE;EAAM,CAAC,CAAC,CAAC;EAClDR,KAAK,CAACK,GAAG,CAACI,+BAAqB,CAAC;EAEhC,IAAI,OAAOX,eAAe,KAAK,UAAU,EAAE;IACzCE,KAAK,CAACK,GAAG,CAACP,eAAe,CAAC;EAC5B;EAEA,IAAI,OAAOC,eAAe,KAAK,UAAU,EAAE;IACzCC,KAAK,CAACK,GAAG,CAACN,eAAe,CAAC;EAC5B;EAEA,OAAOC,KAAK;AACd"}
1
+ {"version":3,"file":"web-api.js","names":["_express","_interopRequireWildcard","require","_validation","_security","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","webAPIMiddleware","tokenMiddleware","webEndpointsApi","route","Router","param","validatePackage","validateName","use","express","urlencoded","extended","setSecurityWebHeaders"],"sources":["../../../src/middlewares/web/web-api.ts"],"sourcesContent":["import express from 'express';\nimport { RequestHandler, Router } from 'express';\n\nimport { validateName, validatePackage } from '../validation';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPIMiddleware(\n tokenMiddleware: RequestHandler,\n webEndpointsApi: RequestHandler\n): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.use(express.urlencoded({ extended: false }));\n route.use(setSecurityWebHeaders);\n\n if (typeof tokenMiddleware === 'function') {\n route.use(tokenMiddleware);\n }\n\n if (typeof webE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GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAE5C,SAASY,gBAAgBA,CAC9BC,eAA+B,EAC/BC,eAA+B,EACvB;EACR;EACA,MAAMC,KAAK,GAAG,IAAAC,eAAM,EAAC,CAAC;EACtB;EACA;EACAD,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEC,2BAAe,CAAC;EACvCH,KAAK,CAACE,KAAK,CAAC,UAAU,EAAEE,wBAAY,CAAC;EACrCJ,KAAK,CAACE,KAAK,CAAC,SAAS,EAAEE,wBAAY,CAAC;EACpCJ,KAAK,CAACK,GAAG,CAACC,gBAAO,CAACC,UAAU,CAAC;IAAEC,QAAQ,EAAE;EAAM,CAAC,CAAC,CAAC;EAClDR,KAAK,CAACK,GAAG,CAACI,+BAAqB,CAAC;EAEhC,IAAI,OAAOX,eAAe,KAAK,UAAU,EAAE;IACzCE,KAAK,CAACK,GAAG,CAACP,eAAe,CAAC;EAC5B;EAEA,IAAI,OAAOC,eAAe,KAAK,UAAU,EAAE;IACzCC,KAAK,CAACK,GAAG,CAACN,eAAe,CAAC;EAC5B;EAEA,OAAOC,KAAK;AACd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/middleware",
3
- "version": "6.0.0-6-next.54",
3
+ "version": "7.0.0-next-7.7",
4
4
  "description": "express middleware utils",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -29,10 +29,10 @@
29
29
  "node": ">=12"
30
30
  },
31
31
  "dependencies": {
32
- "@verdaccio/core": "6.0.0-6-next.75",
33
- "@verdaccio/utils": "6.0.0-6-next.43",
34
- "@verdaccio/config": "6.0.0-6-next.75",
35
- "@verdaccio/url": "11.0.0-6-next.41",
32
+ "@verdaccio/core": "7.0.0-next-7.7",
33
+ "@verdaccio/utils": "7.0.0-next-7.7",
34
+ "@verdaccio/config": "7.0.0-next-7.7",
35
+ "@verdaccio/url": "12.0.0-next-7.7",
36
36
  "debug": "4.3.4",
37
37
  "lru-cache": "7.18.3",
38
38
  "express": "4.18.2",
@@ -45,7 +45,7 @@
45
45
  "url": "https://opencollective.com/verdaccio"
46
46
  },
47
47
  "devDependencies": {
48
- "@verdaccio/logger": "6.0.0-6-next.43",
48
+ "@verdaccio/logger": "7.0.0-next-7.7",
49
49
  "body-parser": "1.20.2",
50
50
  "supertest": "6.3.3"
51
51
  },
@@ -8,7 +8,7 @@ import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
8
8
  * @param config
9
9
  * @returns
10
10
  */
11
- export function antiLoop(config: Config): Function {
11
+ export function antiLoop(config: Config) {
12
12
  return function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
13
13
  if (req?.headers?.via != null) {
14
14
  const arr = req.get('via')?.split(',');
@@ -43,7 +43,7 @@ export const errorReportingMiddleware = (logger) =>
43
43
  res: $ResponseExtend,
44
44
  next: $NextFunctionVer
45
45
  ): void {
46
- debug('error report middleware');
46
+ debug('error report middleware start');
47
47
  res.locals.report_error =
48
48
  res.locals.report_error ||
49
49
  function (err: VerdaccioError): void {
@@ -64,7 +64,7 @@ export const errorReportingMiddleware = (logger) =>
64
64
  debug('this is an error in express.js, please report this, destroy response %o', err);
65
65
  res.destroy();
66
66
  } else if (!res.headersSent) {
67
- debug('report internal error %o', err);
67
+ debug('send internal error %o', err);
68
68
  res.status(HTTP_STATUS.INTERNAL_ERROR);
69
69
  next({ error: API_ERROR.INTERNAL_SERVER_ERROR });
70
70
  } else {
@@ -74,6 +74,6 @@ export const errorReportingMiddleware = (logger) =>
74
74
  }
75
75
  };
76
76
 
77
- debug('error report middleware next()');
77
+ debug('error report middleware end (skip next layer) next()');
78
78
  next();
79
79
  };
@@ -1,3 +1,4 @@
1
+ import buildDebug from 'debug';
1
2
  import _ from 'lodash';
2
3
 
3
4
  import { HEADERS, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '@verdaccio/core';
@@ -8,6 +9,8 @@ import { $NextFunctionVer, $RequestExtend, $ResponseExtend, MiddlewareError } fr
8
9
 
9
10
  export type FinalBody = Manifest | MiddlewareError | string;
10
11
 
12
+ const debug = buildDebug('verdaccio:middleware:final');
13
+
11
14
  export function final(
12
15
  body: FinalBody,
13
16
  req: $RequestExtend,
@@ -17,17 +20,20 @@ export function final(
17
20
  next: $NextFunctionVer
18
21
  ): void {
19
22
  if (res.statusCode === HTTP_STATUS.UNAUTHORIZED && !res.getHeader(HEADERS.WWW_AUTH)) {
23
+ debug('set auth header support');
20
24
  res.header(HEADERS.WWW_AUTH, `${TOKEN_BASIC}, ${TOKEN_BEARER}`);
21
25
  }
22
26
 
23
27
  try {
24
28
  if (_.isString(body) || _.isObject(body)) {
25
29
  if (!res.get(HEADERS.CONTENT_TYPE)) {
30
+ debug('set json type header support');
26
31
  res.header(HEADERS.CONTENT_TYPE, HEADERS.JSON);
27
32
  }
28
33
 
29
34
  if (typeof body === 'object' && _.isNil(body) === false) {
30
35
  if (typeof (body as MiddlewareError).error === 'string') {
36
+ debug('set verdaccio_error method');
31
37
  res.locals._verdaccio_error = (body as MiddlewareError).error;
32
38
  }
33
39
  body = JSON.stringify(body, undefined, ' ') + '\n';
@@ -38,9 +44,12 @@ export function final(
38
44
  !res.statusCode ||
39
45
  (res.statusCode >= HTTP_STATUS.OK && res.statusCode < HTTP_STATUS.MULTIPLE_CHOICES)
40
46
  ) {
41
- res.header(HEADERS.ETAG, '"' + stringToMD5(body as string) + '"');
47
+ const etag = stringToMD5(body as string);
48
+ debug('set etag header %s', etag);
49
+ res.header(HEADERS.ETAG, '"' + etag + '"');
42
50
  }
43
51
  } else {
52
+ debug('this line should never be visible, if does report');
44
53
  // send(null), send(204), etc.
45
54
  }
46
55
  } catch (err: any) {
@@ -48,7 +57,9 @@ export function final(
48
57
  // as an error handler, we can't report error properly,
49
58
  // and should just close socket
50
59
  if (err.message.match(/set headers after they are sent/)) {
60
+ debug('set headers after they are sent');
51
61
  if (_.isNil(res.socket) === false) {
62
+ debug('force destroy socket');
52
63
  res.socket?.destroy();
53
64
  }
54
65
  return;
@@ -7,7 +7,7 @@ export type Manifest = {
7
7
  js: string[];
8
8
  };
9
9
 
10
- const debug = buildDebug('verdaccio:web:render:manifest');
10
+ const debug = buildDebug('verdaccio:middleware:web:render:manifest');
11
11
 
12
12
  export function getManifestValue(
13
13
  manifestItems: string[],
@@ -42,6 +42,7 @@ export default function renderHTML(config: ConfigYaml, manifest, manifestFiles,
42
42
  const base = getPublicUrl(config?.url_prefix, req);
43
43
  const basename = new URL(base).pathname;
44
44
  const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
45
+ const hideDeprecatedVersions = config?.web?.hideDeprecatedVersions ?? false;
45
46
  // @ts-ignore
46
47
  const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)
47
48
  ? true
@@ -99,6 +100,7 @@ export default function renderHTML(config: ConfigYaml, manifest, manifestFiles,
99
100
  title,
100
101
  scope,
101
102
  language,
103
+ hideDeprecatedVersions,
102
104
  };
103
105
 
104
106
  let webPage;