@verdaccio/web 6.0.0-6-next.63 → 7.0.0-next-7.8

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,618 @@
1
1
  # @verdaccio/web
2
2
 
3
+ ## 7.0.0-next-7.8
4
+
5
+ ### Patch Changes
6
+
7
+ - @verdaccio/core@7.0.0-next-7.8
8
+ - @verdaccio/config@7.0.0-next-7.8
9
+ - @verdaccio/auth@7.0.0-next-7.8
10
+ - @verdaccio/tarball@12.0.0-next-7.8
11
+ - @verdaccio/url@12.0.0-next-7.8
12
+ - @verdaccio/loaders@7.0.0-next-7.8
13
+ - @verdaccio/middleware@7.0.0-next-7.8
14
+ - @verdaccio/store@7.0.0-next-7.8
15
+ - @verdaccio/utils@7.0.0-next-7.8
16
+ - @verdaccio/logger@7.0.0-next-7.8
17
+
18
+ ## 7.0.0-next-7.7
19
+
20
+ ### Patch Changes
21
+
22
+ - @verdaccio/core@7.0.0-next-7.7
23
+ - @verdaccio/config@7.0.0-next-7.7
24
+ - @verdaccio/auth@7.0.0-next-7.7
25
+ - @verdaccio/tarball@12.0.0-next-7.7
26
+ - @verdaccio/url@12.0.0-next-7.7
27
+ - @verdaccio/loaders@7.0.0-next-7.7
28
+ - @verdaccio/middleware@7.0.0-next-7.7
29
+ - @verdaccio/store@7.0.0-next-7.7
30
+ - @verdaccio/utils@7.0.0-next-7.7
31
+ - @verdaccio/logger@7.0.0-next-7.7
32
+
33
+ ## 7.0.0-next.6
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [e14b064]
38
+ - Updated dependencies [4d96324]
39
+ - @verdaccio/store@7.0.0-next.6
40
+ - @verdaccio/tarball@12.0.0-next.6
41
+ - @verdaccio/config@7.0.0-next.6
42
+ - @verdaccio/auth@7.0.0-next.6
43
+ - @verdaccio/loaders@7.0.0-next.6
44
+ - @verdaccio/middleware@7.0.0-next.6
45
+ - @verdaccio/core@7.0.0-next.6
46
+ - @verdaccio/url@12.0.0-next.6
47
+ - @verdaccio/utils@7.0.0-next.6
48
+ - @verdaccio/logger@7.0.0-next.6
49
+
50
+ ## 7.0.0-next.5
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [f047cc8]
55
+ - @verdaccio/middleware@7.0.0-next.5
56
+ - @verdaccio/core@7.0.0-next.5
57
+ - @verdaccio/url@12.0.0-next.5
58
+ - @verdaccio/config@7.0.0-next.5
59
+ - @verdaccio/auth@7.0.0-next.5
60
+ - @verdaccio/store@7.0.0-next.5
61
+ - @verdaccio/tarball@12.0.0-next.5
62
+ - @verdaccio/loaders@7.0.0-next.5
63
+ - @verdaccio/logger@7.0.0-next.5
64
+ - @verdaccio/utils@7.0.0-next.5
65
+
66
+ ## 7.0.0-next.4
67
+
68
+ ### Patch Changes
69
+
70
+ - @verdaccio/auth@7.0.0-next.4
71
+ - @verdaccio/core@7.0.0-next.4
72
+ - @verdaccio/config@7.0.0-next.4
73
+ - @verdaccio/tarball@12.0.0-next.4
74
+ - @verdaccio/url@12.0.0-next.4
75
+ - @verdaccio/loaders@7.0.0-next.4
76
+ - @verdaccio/middleware@7.0.0-next.4
77
+ - @verdaccio/store@7.0.0-next.4
78
+ - @verdaccio/utils@7.0.0-next.4
79
+ - @verdaccio/logger@7.0.0-next.4
80
+
81
+ ## 7.0.0-next.3
82
+
83
+ ### Major Changes
84
+
85
+ - e7ebccb61: update major dependencies, remove old nodejs support
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [daceb6d87]
90
+ - Updated dependencies [e7ebccb61]
91
+ - @verdaccio/config@7.0.0-next.3
92
+ - @verdaccio/core@7.0.0-next.3
93
+ - @verdaccio/tarball@12.0.0-next.3
94
+ - @verdaccio/url@12.0.0-next.3
95
+ - @verdaccio/middleware@7.0.0-next.3
96
+ - @verdaccio/utils@7.0.0-next.3
97
+ - @verdaccio/auth@7.0.0-next.3
98
+ - @verdaccio/loaders@7.0.0-next.3
99
+ - @verdaccio/logger@7.0.0-next.3
100
+ - @verdaccio/store@7.0.0-next.3
101
+
102
+ ## 7.0.0-next.2
103
+
104
+ ### Patch Changes
105
+
106
+ - @verdaccio/core@7.0.0-next.2
107
+ - @verdaccio/config@7.0.0-next.2
108
+ - @verdaccio/auth@7.0.0-next.2
109
+ - @verdaccio/tarball@12.0.0-next.2
110
+ - @verdaccio/url@12.0.0-next.2
111
+ - @verdaccio/loaders@7.0.0-next.2
112
+ - @verdaccio/middleware@7.0.0-next.2
113
+ - @verdaccio/store@7.0.0-next.2
114
+ - @verdaccio/utils@7.0.0-next.2
115
+ - @verdaccio/logger@7.0.0-next.2
116
+
117
+ ## 7.0.0-next.1
118
+
119
+ ### Patch Changes
120
+
121
+ - @verdaccio/core@7.0.0-next.1
122
+ - @verdaccio/config@7.0.0-next.1
123
+ - @verdaccio/auth@7.0.0-next.1
124
+ - @verdaccio/tarball@12.0.0-next.1
125
+ - @verdaccio/url@12.0.0-next.1
126
+ - @verdaccio/loaders@7.0.0-next.1
127
+ - @verdaccio/middleware@7.0.0-next.1
128
+ - @verdaccio/store@7.0.0-next.1
129
+ - @verdaccio/utils@7.0.0-next.1
130
+ - @verdaccio/logger@7.0.0-next.1
131
+
132
+ ## 7.0.0-next.0
133
+
134
+ ### Major Changes
135
+
136
+ - feat!: bump to v7
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies
141
+ - @verdaccio/auth@7.0.0-next.0
142
+ - @verdaccio/config@7.0.0-next.0
143
+ - @verdaccio/core@7.0.0-next.0
144
+ - @verdaccio/tarball@12.0.0-next.0
145
+ - @verdaccio/url@12.0.0-next.0
146
+ - @verdaccio/loaders@7.0.0-next.0
147
+ - @verdaccio/logger@7.0.0-next.0
148
+ - @verdaccio/middleware@7.0.0-next.0
149
+ - @verdaccio/store@7.0.0-next.0
150
+ - @verdaccio/utils@7.0.0-next.0
151
+
152
+ ## 6.0.0
153
+
154
+ ### Major Changes
155
+
156
+ - 292c0a37f: feat!: replace deprecated request dependency by got
157
+
158
+ 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.
159
+
160
+ ## Notes
161
+
162
+ - Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
163
+ - Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
164
+ - Refactor with promises instead callback wherever is possible
165
+ - ~Document the API~
166
+ - Improve testing, integration tests
167
+ - Bugfix
168
+ - Clean up old validations
169
+ - Improve performance
170
+
171
+ ## 💥 Breaking changes
172
+
173
+ - Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
174
+ - 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));`
175
+ - `@verdaccio/streams` stream abort support is legacy is being deprecated removed
176
+ - Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
177
+
178
+ - 459b6fa72: refactor: search v1 endpoint and local-database
179
+
180
+ - refactor search `api v1` endpoint, improve performance
181
+ - remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
182
+ - refactor method storage class
183
+ - create new module `core` to reduce the ammount of modules with utilities
184
+ - use `undici` instead `node-fetch`
185
+ - use `fastify` instead `express` for functional test
186
+
187
+ ### Breaking changes
188
+
189
+ - plugin storage API changes
190
+ - remove old search endpoint (return 404)
191
+ - filter local private packages at plugin level
192
+
193
+ The storage api changes for methods `get`, `add`, `remove` as promise base. The `search` methods also changes and recieves a `query` object that contains all query params from the client.
194
+
195
+ ```ts
196
+ export interface IPluginStorage<T> extends IPlugin {
197
+ add(name: string): Promise<void>;
198
+ remove(name: string): Promise<void>;
199
+ get(): Promise<any>;
200
+ init(): Promise<void>;
201
+ getSecret(): Promise<string>;
202
+ setSecret(secret: string): Promise<any>;
203
+ getPackageStorage(packageInfo: string): IPackageStorage;
204
+ search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
205
+ saveToken(token: Token): Promise<any>;
206
+ deleteToken(user: string, tokenKey: string): Promise<any>;
207
+ readTokens(filter: TokenFilter): Promise<Token[]>;
208
+ }
209
+ ```
210
+
211
+ - 9fc2e7961: feat(plugins): improve plugin loader
212
+
213
+ ### Changes
214
+
215
+ - Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
216
+ - Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
217
+ - https://github.com/verdaccio/verdaccio/issues/1394
218
+ - `config.plugins` plugin path validations
219
+ - Updated algorithm for plugin loader.
220
+ - improved documentation (included dev)
221
+
222
+ ## Features
223
+
224
+ - Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
225
+ - Custom prefix:
226
+
227
+ ```
228
+ // config.yaml
229
+ server:
230
+ pluginPrefix: mycompany
231
+ middleware:
232
+ audit:
233
+ foo: 1
234
+ ```
235
+
236
+ This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
237
+
238
+ ## Breaking Changes
239
+
240
+ ### sinopia plugins
241
+
242
+ - `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
243
+
244
+ ### plugin filter
245
+
246
+ - method rename `filter_metadata`->`filterMetadata`
247
+
248
+ ### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
249
+
250
+ The plugin receives as first argument `config`, which represents the config of the plugin. Example:
251
+
252
+ ```
253
+ // config.yaml
254
+ auth:
255
+ plugin:
256
+ foo: 1
257
+ bar: 2
258
+
259
+ export class Plugin<T> {
260
+ public constructor(config: T, options: PluginOptions) {
261
+ console.log(config);
262
+ // {foo:1, bar: 2}
263
+ }
264
+ }
265
+ ```
266
+
267
+ - 794af76c5: Remove Node 12 support
268
+
269
+ - We need move to the new `undici` and does not support Node.js 12
270
+
271
+ - 10aeb4f13: feat!: experiments config renamed to flags
272
+
273
+ - The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
274
+
275
+ ```js
276
+ flags: token: false;
277
+ search: false;
278
+ ```
279
+
280
+ - The `self_path` property from the config file is being removed in favor of `config_file` full path.
281
+ - Refactor `config` module, better types and utilities
282
+
283
+ - e367c3f1e: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
284
+
285
+ - Introduce environment variables for legacy tokens
286
+
287
+ ### Code Improvements
288
+
289
+ - Add debug library for improve developer experience
290
+
291
+ ### Breaking change
292
+
293
+ - The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
294
+ - The secret key must have 32 characters long.
295
+
296
+ ### New environment variables
297
+
298
+ - `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
299
+ - `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
300
+
301
+ - 82cb0f2bf: feat!: config.logs throw an error, logging config not longer accept array or logs property
302
+
303
+ ### 💥 Breaking change
304
+
305
+ This is valid
306
+
307
+ ```yaml
308
+ log: { type: stdout, format: pretty, level: http }
309
+ ```
310
+
311
+ This is invalid
312
+
313
+ ```yaml
314
+ logs: { type: stdout, format: pretty, level: http }
315
+ ```
316
+
317
+ or
318
+
319
+ ```yaml
320
+ logs:
321
+ - [{ type: stdout, format: pretty, level: http }]
322
+ ```
323
+
324
+ - 000d43746: feat: upgrade to material ui 5
325
+ - 558d78f32: feat: flexible user interface generator
326
+
327
+ **breaking change**
328
+
329
+ The UI does not provide a pre-generated `index.html`, instead the server generates
330
+ the body of the web application based in few parameters:
331
+
332
+ - Webpack manifest
333
+ - User configuration details
334
+
335
+ It allows inject html tags, javascript and new CSS to make the page even more flexible.
336
+
337
+ ### Web new properties for dynamic template
338
+
339
+ The new set of properties are made in order allow inject _html_ and _JavaScript_ scripts within the template. This
340
+ might be useful for scenarios like Google Analytics scripts or custom html in any part of the body.
341
+
342
+ - metaScripts: html injected before close the `head` element.
343
+ - scriptsBodyAfter: html injected before close the `body` element.
344
+ - bodyAfter: html injected after _verdaccio_ JS scripts.
345
+
346
+ ```yaml
347
+ web:
348
+ scriptsBodyAfter:
349
+ - '<script type="text/javascript" src="https://my.company.com/customJS.min.js"></script>'
350
+ metaScripts:
351
+ - '<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>'
352
+ - '<script type="text/javascript" src="https://browser.sentry-cdn.com/5.15.5/bundle.min.js"></script>'
353
+ - '<meta name="robots" content="noindex" />'
354
+ bodyBefore:
355
+ - '<div id="myId">html before webpack scripts</div>'
356
+ bodyAfter:
357
+ - '<div id="myId">html after webpack scripts</div>'
358
+ ```
359
+
360
+ ### UI plugin changes
361
+
362
+ - `index.html` is not longer used, template is generated based on `manifest.json` generated by webpack.
363
+ - Plugin must export:
364
+ - the manifest file.
365
+ - the manifest files: matcher (array of id that generates required scripts to run the ui)
366
+ - static path: The absolute path where the files are located in `node_modules`
367
+
368
+ ```
369
+ exports.staticPath = path.join(__dirname, 'static');
370
+ exports.manifest = require('./static/manifest.json');
371
+ exports.manifestFiles = {
372
+ js: ['runtime.js', 'vendors.js', 'main.js'],
373
+ css: [],
374
+ ico: 'favicon.ico',
375
+ };
376
+ ```
377
+
378
+ - Remove font files
379
+ - CSS is inline on JS (this will help with #2046)
380
+
381
+ ### Docker v5 Examples
382
+
383
+ - Move all current examples to v4 folder
384
+ - Remove any v3 example
385
+ - Create v5 folder with Nginx Example
386
+
387
+ #### Related tickets
388
+
389
+ https://github.com/verdaccio/verdaccio/issues/1523
390
+ https://github.com/verdaccio/verdaccio/issues/1297
391
+ https://github.com/verdaccio/verdaccio/issues/1593
392
+ https://github.com/verdaccio/verdaccio/discussions/1539
393
+ https://github.com/verdaccio/website/issues/264
394
+ https://github.com/verdaccio/verdaccio/issues/1565
395
+ https://github.com/verdaccio/verdaccio/issues/1251
396
+ https://github.com/verdaccio/verdaccio/issues/2029
397
+ https://github.com/verdaccio/docker-examples/issues/29
398
+
399
+ - 781ac9ac2: fix package configuration issues
400
+
401
+ ### Minor Changes
402
+
403
+ - 0da7031e7: allow disable login on ui and endpoints
404
+
405
+ To be able disable the login, set `login: false`, anything else would enable login. This flag will disable access via UI and web endpoints.
406
+
407
+ ```yml
408
+ web:
409
+ title: verdaccio
410
+ login: false
411
+ ```
412
+
413
+ - a1986e098: feat: expose middleware utils
414
+ - 24b9be020: refactor: improve docker image build with strict dependencies and prod build
415
+ - 631abe1ac: feat: refactor logger
416
+ - a23628be9: feat: parse and sanitize on ui
417
+ - 048ac95e8: feat: align with v5 ui endpoints and ui small bugfix
418
+ - b61f762d6: feat: add server rate limit protection to all request
419
+
420
+ To modify custom values, use the server settings property.
421
+
422
+ ```markdown
423
+ server:
424
+
425
+ ## https://www.npmjs.com/package/express-rate-limit#configuration-options
426
+
427
+ rateLimit:
428
+ windowMs: 1000
429
+ max: 10000
430
+ ```
431
+
432
+ The values are intended to be high, if you want to improve security of your server consider
433
+ using different values.
434
+
435
+ - 154b2ecd3: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
436
+ - aa763baec: feat: add typescript project references settings
437
+
438
+ 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.
439
+
440
+ It allows to navigate (IDE) trough the packages without need compile the packages.
441
+
442
+ 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).
443
+
444
+ - 62c24b632: feat: add passwordValidationRegex property
445
+ - d08fe29d9: feat(web): add a config item to web,let the developer can select whet……her enable the html cache
446
+ - 5167bb528: feat: ui search support for remote, local and private packages
447
+
448
+ The command `npm search` search globally and return all matches, with this improvement the user interface
449
+ is powered with the same capabilities.
450
+
451
+ The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
452
+
453
+ - f86c31ed0: feat: migrate web sidebar endpoint to fastify
454
+
455
+ reuse utils methods between packages
456
+
457
+ - 20c9e43ed: dist tags Implementation on Fastify
458
+ - 4b29d715b: chore: move improvements from v5 to v6
459
+
460
+ Migrate improvements form v5 to v6:
461
+
462
+ - https://github.com/verdaccio/verdaccio/pull/3158
463
+ - https://github.com/verdaccio/verdaccio/pull/3151
464
+ - https://github.com/verdaccio/verdaccio/pull/2271
465
+ - https://github.com/verdaccio/verdaccio/pull/2787
466
+ - https://github.com/verdaccio/verdaccio/pull/2791
467
+ - https://github.com/verdaccio/verdaccio/pull/2205
468
+
469
+ - 37274e4c8: feat: implement abbreviated manifest
470
+
471
+ Enable abbreviated manifest data by adding the header:
472
+
473
+ ```
474
+ curl -H "Accept: application/vnd.npm.install-v1+json" https://registry.npmjs.org/verdaccio
475
+ ```
476
+
477
+ It returns a filtered manifest, additionally includes the [time](https://github.com/pnpm/rfcs/pull/2) field by request.
478
+
479
+ Current support for packages managers:
480
+
481
+ - npm: yes
482
+ - pnpm: yes
483
+ - yarn classic: yes
484
+ - yarn modern (+2.x): [no](https://github.com/yarnpkg/berry/pull/3981#issuecomment-1076566096)
485
+
486
+ https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format
487
+
488
+ - 45c03819e: refactor: render html middleware
489
+ - aecbd226d: web: allow ui hide package managers on sidebar
490
+
491
+ If there is a package manager of preference over others, you can define the package managers to be displayed on the detail page and sidebar, just define in the `config.yaml` and web section the list of package managers to be displayed.
492
+
493
+ ```
494
+ web:
495
+ title: Verdaccio
496
+ sort_packages: asc
497
+ primary_color: #cccccc
498
+ pkgManagers:
499
+ - pnpm
500
+ - yarn
501
+ # - npm
502
+ ```
503
+
504
+ To disable all package managers, just define empty:
505
+
506
+ ```
507
+ web:
508
+ title: Verdaccio
509
+ sort_packages: asc
510
+ primary_color: #cccccc
511
+ pkgManagers:
512
+ ```
513
+
514
+ and the section would be hidden.
515
+
516
+ ### Patch Changes
517
+
518
+ - 702d5c497: Fix the password validation logic for the `/reset_password` route to ensure that the password is only reset if it is valid.
519
+ - 351aeeaa8: fix(deps): @verdaccio/utils should be a prod dep of local-storage
520
+ - 1d1112805: Remove @ts-ignore and any in packages/web/src/endpoint/package.ts
521
+ - a828a5f6c: fix: #3174 set correctly ui values to html render
522
+ - a610ef26b: chore: add release step to private regisry on merge changeset pr
523
+ - 4fc21146a: fix: missing logo on header
524
+ - 34f0f1101: Enable prerelease mode with **changesets**
525
+ - 5ddfa5264: Fix the search by exact name of the package
526
+
527
+ Full package name queries was not finding anithing. It was happening
528
+ becouse of stemmer of [lunr.js](https://lunrjs.com/).
529
+
530
+ To fix this, the stemmer of [lunr.js](https://lunrjs.com/) was removed from search pipeline.
531
+
532
+ - 0a6412ca9: refactor: got instead undici
533
+ - b4cc80017: fix: improve abort request search
534
+ - Updated dependencies [292c0a37f]
535
+ - Updated dependencies [dc05edfe6]
536
+ - Updated dependencies [a1986e098]
537
+ - Updated dependencies [974cd8c19]
538
+ - Updated dependencies [a828271d6]
539
+ - Updated dependencies [ef88da3b4]
540
+ - Updated dependencies [43f32687c]
541
+ - Updated dependencies [679c19c1b]
542
+ - Updated dependencies [a3a209b5e]
543
+ - Updated dependencies [459b6fa72]
544
+ - Updated dependencies [9fc2e7961]
545
+ - Updated dependencies [9943e2b18]
546
+ - Updated dependencies [ae93e039d]
547
+ - Updated dependencies [24b9be020]
548
+ - Updated dependencies [794af76c5]
549
+ - Updated dependencies [e75c0a3b9]
550
+ - Updated dependencies [351aeeaa8]
551
+ - Updated dependencies [10aeb4f13]
552
+ - Updated dependencies [1d1112805]
553
+ - Updated dependencies [631abe1ac]
554
+ - Updated dependencies [9718e0330]
555
+ - Updated dependencies [7ef599cc4]
556
+ - Updated dependencies [b702ea363]
557
+ - Updated dependencies [1b217fd34]
558
+ - Updated dependencies [e367c3f1e]
559
+ - Updated dependencies [a1da11308]
560
+ - Updated dependencies [d167f92e1]
561
+ - Updated dependencies [d2c65da9c]
562
+ - Updated dependencies [00d1d2a17]
563
+ - Updated dependencies [1810ed0d8]
564
+ - Updated dependencies [a610ef26b]
565
+ - Updated dependencies [ddb6a2239]
566
+ - Updated dependencies [31d661c7b]
567
+ - Updated dependencies [648575aa4]
568
+ - Updated dependencies [b61f762d6]
569
+ - Updated dependencies [4fc21146a]
570
+ - Updated dependencies [d43894e8f]
571
+ - Updated dependencies [154b2ecd3]
572
+ - Updated dependencies [061bfcc8d]
573
+ - Updated dependencies [aa763baec]
574
+ - Updated dependencies [378e907d5]
575
+ - Updated dependencies [16e38df8a]
576
+ - Updated dependencies [34f0f1101]
577
+ - Updated dependencies [82cb0f2bf]
578
+ - Updated dependencies [dc571aabd]
579
+ - Updated dependencies [5ddfa5264]
580
+ - Updated dependencies [b78f35257]
581
+ - Updated dependencies [ce013d2fc]
582
+ - Updated dependencies [f859d2b1a]
583
+ - Updated dependencies [2c594910d]
584
+ - Updated dependencies [6c1eb021b]
585
+ - Updated dependencies [62c24b632]
586
+ - Updated dependencies [0a6412ca9]
587
+ - Updated dependencies [0a6412ca9]
588
+ - Updated dependencies [d08fe29d9]
589
+ - Updated dependencies [5167bb528]
590
+ - Updated dependencies [f86c31ed0]
591
+ - Updated dependencies [65f88b826]
592
+ - Updated dependencies [aeff267d9]
593
+ - Updated dependencies [20c9e43ed]
594
+ - Updated dependencies [b3e8438f6]
595
+ - Updated dependencies [c9d1af0e5]
596
+ - Updated dependencies [730b5d8cc]
597
+ - Updated dependencies [4b29d715b]
598
+ - Updated dependencies [b13a3fefd]
599
+ - Updated dependencies [68ea21214]
600
+ - Updated dependencies [37274e4c8]
601
+ - Updated dependencies [fa274ee44]
602
+ - Updated dependencies [8f43bf17d]
603
+ - Updated dependencies [45c03819e]
604
+ - Updated dependencies [b849128de]
605
+ - @verdaccio/auth@6.0.0
606
+ - @verdaccio/config@6.0.0
607
+ - @verdaccio/core@6.0.0
608
+ - @verdaccio/tarball@11.0.0
609
+ - @verdaccio/url@11.0.0
610
+ - @verdaccio/loaders@6.0.0
611
+ - @verdaccio/logger@6.0.0
612
+ - @verdaccio/middleware@6.0.0
613
+ - @verdaccio/store@6.0.0
614
+ - @verdaccio/utils@6.0.0
615
+
3
616
  ## 6.0.0-6-next.63
4
617
 
5
618
  ### 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
@@ -119,6 +119,5 @@ function addPackageWebApi(storage, auth, config) {
119
119
  });
120
120
  return pkgRouter;
121
121
  }
122
- var _default = addPackageWebApi;
123
- exports.default = _default;
122
+ var _default = exports.default = addPackageWebApi;
124
123
  //# sourceMappingURL=package.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_logger","_middleware","_tarball","_utils","_webUtils","obj","__esModule","default","getOrder","order","debug","buildDebug","addPackageWebApi","storage","auth","config","_ref","_config$web","isLoginEnabled","web","login","pkgRouter","Router","anonymousRemoteUser","name","undefined","real_groups","groups","checkAllow","remoteUser","Promise","resolve","reject","allow_access","packageName","err","allowed","processPackages","packages","req","permissions","packagesToProcess","slice","pkg","pkgCopy","author","formatAuthor","remote_user","avatar","generateGravatarUrl","email","gravatar","_","isNil","dist","isNull","tarball","getLocalRegistryTarballUri","protocol","headers","host","hostname","url_prefix","push","logger","error","get","res","next","_config$web2","localPackages","getLocalDatabase","sort_packages","pkgs","sortByName","_default","exports"],"sources":["../../src/api/package.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { getLocalRegistryTarballUri } from '@verdaccio/tarball';\nimport { Config, RemoteUser, Version } from '@verdaccio/types';\nimport { formatAuthor, generateGravatarUrl } from '@verdaccio/utils';\n\nimport { sortByName } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nconst getOrder = (order = 'asc') => {\n return order === 'asc';\n};\n\nconst debug = buildDebug('verdaccio:web:api:package');\n\nfunction addPackageWebApi(storage: Storage, auth: Auth, config: Config): Router {\n const isLoginEnabled = config?.web?.login === true ?? true;\n const pkgRouter = Router(); /* eslint new-cap: 0 */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const anonymousRemoteUser: RemoteUser = {\n name: undefined,\n real_groups: [],\n groups: [],\n };\n\n debug('initialized package web api');\n const checkAllow = (name: string, remoteUser: RemoteUser): Promise<boolean> =>\n new Promise((resolve, reject): void => {\n debug('is login disabled %o', isLoginEnabled);\n // FIXME: this logic does not work, review\n // const remoteUserAccess = !isLoginEnabled ? anonymousRemoteUser : remoteUser;\n try {\n auth.allow_access({ packageName: name }, remoteUser, (err, allowed): void => {\n if (err) {\n resolve(false);\n }\n return resolve(allowed as boolean);\n });\n } catch (err: any) {\n reject(err);\n }\n });\n\n async function processPackages(packages: Version[] = [], req): Promise<Version[]> {\n const permissions: Version[] = [];\n const packagesToProcess = packages.slice();\n debug('process packages %o', packagesToProcess);\n for (const pkg of packagesToProcess) {\n const pkgCopy = { ...pkg };\n pkgCopy.author = formatAuthor(pkg.author);\n try {\n if (await checkAllow(pkg.name, req.remote_user)) {\n if (config.web) {\n // @ts-ignore\n pkgCopy.author.avatar = generateGravatarUrl(pkgCopy.author.email, config.web.gravatar);\n }\n // convert any remote dist to a local reference\n // eg: if the dist points to npmjs, switch to localhost:4873/prefix/etc.tar.gz\n if (!_.isNil(pkgCopy.dist) && !_.isNull(pkgCopy.dist.tarball)) {\n pkgCopy.dist.tarball = getLocalRegistryTarballUri(\n pkgCopy.dist.tarball,\n pkg.name,\n { protocol: req.protocol, headers: req.headers as any, host: req.hostname },\n config?.url_prefix\n );\n }\n permissions.push(pkgCopy);\n }\n } catch (err: any) {\n debug('process packages error %o', err);\n logger.error(\n { name: pkg.name, error: err },\n 'permission process for @{name} has failed: @{error}'\n );\n throw err;\n }\n }\n\n return permissions;\n }\n\n // Get list of all visible package\n pkgRouter.get(\n '/packages',\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('hit package web api %o');\n\n try {\n const localPackages: Version[] = await storage.getLocalDatabase();\n\n const order = getOrder(config?.web?.sort_packages);\n debug('order %o', order);\n const pkgs = await processPackages(localPackages, req);\n next(sortByName(pkgs, order));\n } catch (error: any) {\n next(error);\n }\n }\n );\n\n return pkgRouter;\n}\n\nexport default addPackageWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAEA,IAAAO,SAAA,GAAAP,OAAA;AAA0C,SAAAD,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEoB;;AAE9D,MAAMG,QAAQ,GAAGA,CAACC,KAAK,GAAG,KAAK,KAAK;EAClC,OAAOA,KAAK,KAAK,KAAK;AACxB,CAAC;AAED,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,2BAA2B,CAAC;AAErD,SAASC,gBAAgBA,CAACC,OAAgB,EAAEC,IAAU,EAAEC,MAAc,EAAU;EAAA,IAAAC,IAAA,EAAAC,WAAA;EAC9E,MAAMC,cAAc,IAAAF,IAAA,GAAG,CAAAD,MAAM,aAANA,MAAM,wBAAAE,WAAA,GAANF,MAAM,CAAEI,GAAG,cAAAF,WAAA,uBA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B,GAAG,MAAMzD,OAAO,CAAC0D,gBAAgB,CAAC,CAAC;MAEjE,MAAM9D,KAAK,GAAGD,QAAQ,CAACO,MAAM,aAANA,MAAM,wBAAAsD,YAAA,GAANtD,MAAM,CAAEI,GAAG,cAAAkD,YAAA,uBAAXA,YAAA,CAAaG,aAAa,CAAC;MAClD9D,KAAK,CAAC,UAAU,EAAED,KAAK,CAAC;MACxB,MAAMgE,IAAI,GAAG,MAAMpC,eAAe,CAACiC,aAAa,EAAE/B,GAAG,CAAC;MACtD6B,IAAI,CAAC,IAAAM,oBAAU,EAACD,IAAI,EAAEhE,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,OAAOwD,KAAU,EAAE;MACnBG,IAAI,CAACH,KAAK,CAAC;IACb;EACF,CACF,CAAC;EAED,OAAO5C,SAAS;AAClB;AAAC,IAAAsD,QAAA,GAEc/D,gBAAgB;AAAAgE,OAAA,CAAArE,OAAA,GAAAoE,QAAA"}
1
+ {"version":3,"file":"package.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_logger","_middleware","_tarball","_utils","_webUtils","obj","__esModule","default","getOrder","order","debug","buildDebug","addPackageWebApi","storage","auth","config","_ref","_config$web","isLoginEnabled","web","login","pkgRouter","Router","anonymousRemoteUser","name","undefined","real_groups","groups","checkAllow","remoteUser","Promise","resolve","reject","allow_access","packageName","err","allowed","processPackages","packages","req","permissions","packagesToProcess","slice","pkg","pkgCopy","author","formatAuthor","remote_user","avatar","generateGravatarUrl","email","gravatar","_","isNil","dist","isNull","tarball","getLocalRegistryTarballUri","protocol","headers","host","hostname","url_prefix","push","logger","error","get","res","next","_config$web2","localPackages","getLocalDatabase","sort_packages","pkgs","sortByName","_default","exports"],"sources":["../../src/api/package.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { getLocalRegistryTarballUri } from '@verdaccio/tarball';\nimport { Config, RemoteUser, Version } from '@verdaccio/types';\nimport { formatAuthor, generateGravatarUrl } from '@verdaccio/utils';\n\nimport { sortByName } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nconst getOrder = (order = 'asc') => {\n return order === 'asc';\n};\n\nconst debug = buildDebug('verdaccio:web:api:package');\n\nfunction addPackageWebApi(storage: Storage, auth: Auth, config: Config): Router {\n const isLoginEnabled = config?.web?.login === true ?? true;\n const pkgRouter = Router(); /* eslint new-cap: 0 */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const anonymousRemoteUser: RemoteUser = {\n name: undefined,\n real_groups: [],\n groups: [],\n };\n\n debug('initialized package web api');\n const checkAllow = (name: string, remoteUser: RemoteUser): Promise<boolean> =>\n new Promise((resolve, reject): void => {\n debug('is login disabled %o', isLoginEnabled);\n // FIXME: this logic does not work, review\n // const remoteUserAccess = !isLoginEnabled ? anonymousRemoteUser : remoteUser;\n try {\n auth.allow_access({ packageName: name }, remoteUser, (err, allowed): void => {\n if (err) {\n resolve(false);\n }\n return resolve(allowed as boolean);\n });\n } catch (err: any) {\n reject(err);\n }\n });\n\n async function processPackages(packages: Version[] = [], req): Promise<Version[]> {\n const permissions: Version[] = [];\n const packagesToProcess = packages.slice();\n debug('process packages %o', packagesToProcess);\n for (const pkg of packagesToProcess) {\n const pkgCopy = { ...pkg };\n pkgCopy.author = formatAuthor(pkg.author);\n try {\n if (await checkAllow(pkg.name, req.remote_user)) {\n if (config.web) {\n // @ts-ignore\n pkgCopy.author.avatar = generateGravatarUrl(pkgCopy.author.email, config.web.gravatar);\n }\n // convert any remote dist to a local reference\n // eg: if the dist points to npmjs, switch to localhost:4873/prefix/etc.tar.gz\n if (!_.isNil(pkgCopy.dist) && !_.isNull(pkgCopy.dist.tarball)) {\n pkgCopy.dist.tarball = getLocalRegistryTarballUri(\n pkgCopy.dist.tarball,\n pkg.name,\n { protocol: req.protocol, headers: req.headers as any, host: req.hostname },\n config?.url_prefix\n );\n }\n permissions.push(pkgCopy);\n }\n } catch (err: any) {\n debug('process packages error %o', err);\n logger.error(\n { name: pkg.name, error: err },\n 'permission process for @{name} has failed: @{error}'\n );\n throw err;\n }\n }\n\n return permissions;\n }\n\n // Get list of all visible package\n pkgRouter.get(\n '/packages',\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('hit package web api %o');\n\n try {\n const localPackages: Version[] = await storage.getLocalDatabase();\n\n const order = getOrder(config?.web?.sort_packages);\n debug('order %o', order);\n const pkgs = await processPackages(localPackages, req);\n next(sortByName(pkgs, order));\n } catch (error: any) {\n next(error);\n }\n }\n );\n\n return pkgRouter;\n}\n\nexport default addPackageWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAEA,IAAAO,SAAA,GAAAP,OAAA;AAA0C,SAAAD,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEoB;;AAE9D,MAAMG,QAAQ,GAAGA,CAACC,KAAK,GAAG,KAAK,KAAK;EAClC,OAAOA,KAAK,KAAK,KAAK;AACxB,CAAC;AAED,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,2BAA2B,CAAC;AAErD,SAASC,gBAAgBA,CAACC,OAAgB,EAAEC,IAAU,EAAEC,MAAc,EAAU;EAAA,IAAAC,IAAA,EAAAC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B,GAAmB,EACnB4B,GAAoB,EACpBC,IAAsB,EACP;IACf1D,KAAK,CAAC,wBAAwB,CAAC;IAE/B,IAAI;MAAA,IAAA2D,YAAA;MACF,MAAMC,aAAwB,GAAG,MAAMzD,OAAO,CAAC0D,gBAAgB,CAAC,CAAC;MAEjE,MAAM9D,KAAK,GAAGD,QAAQ,CAACO,MAAM,aAANA,MAAM,wBAAAsD,YAAA,GAANtD,MAAM,CAAEI,GAAG,cAAAkD,YAAA,uBAAXA,YAAA,CAAaG,aAAa,CAAC;MAClD9D,KAAK,CAAC,UAAU,EAAED,KAAK,CAAC;MACxB,MAAMgE,IAAI,GAAG,MAAMpC,eAAe,CAACiC,aAAa,EAAE/B,GAAG,CAAC;MACtD6B,IAAI,CAAC,IAAAM,oBAAU,EAACD,IAAI,EAAEhE,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,OAAOwD,KAAU,EAAE;MACnBG,IAAI,CAACH,KAAK,CAAC;IACb;EACF,CACF,CAAC;EAED,OAAO5C,SAAS;AAClB;AAAC,IAAAsD,QAAA,GAAAC,OAAA,CAAArE,OAAA,GAEcK,gBAAgB"}
@@ -33,8 +33,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
33
33
 
34
34
  // TODO: review this type, should be on @verdacid/types
35
35
 
36
- const NOT_README_FOUND = 'ERROR: No README data found!';
37
- exports.NOT_README_FOUND = NOT_README_FOUND;
36
+ const NOT_README_FOUND = exports.NOT_README_FOUND = 'ERROR: No README data found!';
38
37
  const debug = (0, _debug.default)('verdaccio:web:api:readme');
39
38
  const getReadme = readme => {
40
39
  if (typeof readme === 'string' && readme.length === 0) {
@@ -81,6 +80,5 @@ function addReadmeWebApi(storage, auth) {
81
80
  });
82
81
  return pkgRouter;
83
82
  }
84
- var _default = addReadmeWebApi;
85
- exports.default = _default;
83
+ var _default = exports.default = addReadmeWebApi;
86
84
  //# sourceMappingURL=readme.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readme.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_webUtils","obj","__esModule","default","NOT_README_FOUND","exports","debug","buildDebug","getReadme","readme","length","addReadmeWebApi","storage","auth","can","allow","beforeAll","a","b","logger","trace","afterAll","pkgRouter","Router","get","req","res","next","name","params","scope","addScope","package","requestOptions","protocol","headers","host","remoteAddress","socket","manifest","getPackageByOptions","uplinksLook","abbreviated","set","HEADER_TYPE","CONTENT_TYPE","HEADERS","TEXT_PLAIN_UTF8","err","_default"],"sources":["../../src/api/readme.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { HEADERS, HEADER_TYPE } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Manifest } from '@verdaccio/types';\n\nimport { AuthorAvatar, addScope } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\n// TODO: review this type, should be on @verdacid/types\nexport type PackageExt = Manifest & { author: AuthorAvatar; dist?: { tarball: string } };\nexport const NOT_README_FOUND = 'ERROR: No README data found!';\nconst debug = buildDebug('verdaccio:web:api:readme');\nconst getReadme = (readme) => {\n if (typeof readme === 'string' && readme.length === 0) {\n return NOT_README_FOUND;\n }\n if (typeof readme !== 'string') {\n return NOT_README_FOUND;\n } else {\n return readme;\n }\n};\n\nfunction addReadmeWebApi(storage: Storage, auth: Auth): Router {\n debug('initialized readme web api');\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n const pkgRouter = Router(); /* eslint new-cap: 0 */\n\n pkgRouter.get(\n '/package/readme/(@:scope/)?:package/:version?',\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('readme hit');\n const name = req.params.scope\n ? addScope(req.params.scope, req.params.package)\n : req.params.package;\n debug('readme name %o', name);\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const manifest = (await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n abbreviated: false,\n requestOptions,\n })) as Manifest;\n debug('readme pkg %o', manifest?.name);\n res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);\n next(getReadme(manifest.readme));\n } catch (err) {\n next(err);\n }\n }\n );\n return pkgRouter;\n}\n\nexport default addReadmeWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAIA,IAAAK,SAAA,GAAAL,OAAA;AAAsD,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEQ;;AAE9D;;AAEO,MAAMG,gBAAgB,GAAG,8BAA8B;AAACC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA;AAC/D,MAAME,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AACpD,MAAMC,SAAS,GAAIC,MAAM,IAAK;EAC5B,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IACrD,OAAON,gBAAgB;EACzB;EACA,IAAI,OAAOK,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOL,gBAAgB;EACzB,CAAC,MAAM;IACL,OAAOK,MAAM;EACf;AACF,CAAC;AAED,SAASE,eAAeA,CAACC,OAAgB,EAAEC,IAAU,EAAU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AC;MACtCF,GAAG,CAACiB,GAAG,CAACC,iBAAW,CAACC,YAAY,EAAEC,aAAO,CAACC,eAAe,CAAC;MAC1DpB,IAAI,CAACnB,SAAS,CAAC+B,QAAQ,CAAC9B,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,OAAOuC,GAAG,EAAE;MACZrB,IAAI,CAACqB,GAAG,CAAC;IACX;EACF,CACF,CAAC;EACD,OAAO1B,SAAS;AAClB;AAAC,IAAA2B,QAAA,GAEctC,eAAe;AAAAN,OAAA,CAAAF,OAAA,GAAA8C,QAAA"}
1
+ {"version":3,"file":"readme.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_webUtils","obj","__esModule","default","NOT_README_FOUND","exports","debug","buildDebug","getReadme","readme","length","addReadmeWebApi","storage","auth","can","allow","beforeAll","a","b","logger","trace","afterAll","pkgRouter","Router","get","req","res","next","name","params","scope","addScope","package","requestOptions","protocol","headers","host","remoteAddress","socket","manifest","getPackageByOptions","uplinksLook","abbreviated","set","HEADER_TYPE","CONTENT_TYPE","HEADERS","TEXT_PLAIN_UTF8","err","_default"],"sources":["../../src/api/readme.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { HEADERS, HEADER_TYPE } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Manifest } from '@verdaccio/types';\n\nimport { AuthorAvatar, addScope } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\n// TODO: review this type, should be on @verdacid/types\nexport type PackageExt = Manifest & { author: AuthorAvatar; dist?: { tarball: string } };\nexport const NOT_README_FOUND = 'ERROR: No README data found!';\nconst debug = buildDebug('verdaccio:web:api:readme');\nconst getReadme = (readme) => {\n if (typeof readme === 'string' && readme.length === 0) {\n return NOT_README_FOUND;\n }\n if (typeof readme !== 'string') {\n return NOT_README_FOUND;\n } else {\n return readme;\n }\n};\n\nfunction addReadmeWebApi(storage: Storage, auth: Auth): Router {\n debug('initialized readme web api');\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n const pkgRouter = Router(); /* eslint new-cap: 0 */\n\n pkgRouter.get(\n '/package/readme/(@:scope/)?:package/:version?',\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('readme hit');\n const name = req.params.scope\n ? addScope(req.params.scope, req.params.package)\n : req.params.package;\n debug('readme name %o', name);\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const manifest = (await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n abbreviated: false,\n requestOptions,\n })) as Manifest;\n debug('readme pkg %o', manifest?.name);\n res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);\n next(getReadme(manifest.readme));\n } catch (err) {\n next(err);\n }\n }\n );\n return pkgRouter;\n}\n\nexport default addReadmeWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAIA,IAAAK,SAAA,GAAAL,OAAA;AAAsD,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEQ;;AAE9D;;AAEO,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,8BAA8B;AAC9D,MAA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AAG,CAACU,OAAc;MAC3B;MACAC,IAAI,EAAEX,GAAG,CAACW,IAAI;MACdC,aAAa,EAAEZ,GAAG,CAACa,MAAM,CAACD;IAC5B,CAAC;IACD,IAAI;MACF,MAAME,QAAQ,GAAI,MAAM3B,OAAO,CAAC4B,mBAAmB,CAAC;QAClDZ,IAAI;QACJa,WAAW,EAAE,IAAI;QACjBC,WAAW,EAAE,KAAK;QAClBT;MACF,CAAC,CAAc;MACf3B,KAAK,CAAC,eAAe,EAAEiC,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEX,IAAI,CAAC;MACtCF,GAAG,CAACiB,GAAG,CAACC,iBAAW,CAACC,YAAY,EAAEC,aAAO,CAACC,eAAe,CAAC;MAC1DpB,IAAI,CAACnB,SAAS,CAAC+B,QAAQ,CAAC9B,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,OAAOuC,GAAG,EAAE;MACZrB,IAAI,CAACqB,GAAG,CAAC;IACX;EACF,CACF,CAAC;EACD,OAAO1B,SAAS;AAClB;AAAC,IAAA2B,QAAA,GAAA5C,OAAA,CAAAF,OAAA,GAEcQ,eAAe"}
@@ -75,6 +75,5 @@ function addSearchWebApi(storage, auth) {
75
75
  });
76
76
  return router;
77
77
  }
78
- var _default = addSearchWebApi;
79
- exports.default = _default;
78
+ var _default = exports.default = addSearchWebApi;
80
79
  //# sourceMappingURL=search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_url","_core","obj","__esModule","default","debug","buildDebug","checkAccess","pkg","auth","remoteUser","Promise","resolve","reject","_pkg$package","allow_access","packageName","package","name","err","allowed","status","String","match","addSearchWebApi","storage","router","Router","get","req","res","next","_ref","data","abort","AbortController","socket","on","text","params","anything","size","from","query","maintenance","popularity","quality","urlParams","URLSearchParams","search","url","toString","checkAccessPromises","all","map","pkgItem","remote_user","final","filter","i","_","isNull","slice","errorUtils","getInternalError","message","_default","exports"],"sources":["../../src/api/search.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport _ from 'lodash';\nimport { URLSearchParams } from 'url';\n\nimport { Auth } from '@verdaccio/auth';\nimport { errorUtils, searchUtils } from '@verdaccio/core';\nimport { SearchQuery } from '@verdaccio/core/src/search-utils';\nimport { Storage } from '@verdaccio/store';\nimport { Manifest } from '@verdaccio/types';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:search');\n\nfunction checkAccess(pkg: any, auth: any, remoteUser): Promise<Manifest | null> {\n return new Promise((resolve, reject) => {\n auth.allow_access({ packageName: pkg?.package?.name }, remoteUser, function (err, allowed) {\n if (err) {\n if (err.status && String(err.status).match(/^4\\d\\d$/)) {\n // auth plugin returns 4xx user error,\n // that's equivalent of !allowed basically\n allowed = false;\n return resolve(null);\n } else {\n reject(err);\n }\n } else {\n return resolve(allowed ? pkg : null);\n }\n });\n });\n}\n\nfunction addSearchWebApi(storage: Storage, auth: Auth): Router {\n const router = Router(); /* eslint new-cap: 0 */\n router.get(\n '/search/:anything',\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n try {\n let data;\n const abort = new AbortController();\n req.socket.on('close', function () {\n debug('search web aborted');\n abort.abort();\n });\n const text: string = (req.params.anything as string) ?? '';\n // These values are declared as optimal by npm cli\n // FUTURE: could be overwritten by ui settings.\n const size = 20;\n const from = 0;\n const query: SearchQuery = {\n from: 0,\n maintenance: 0.5,\n popularity: 0.98,\n quality: 0.65,\n size: 20,\n text,\n };\n // @ts-ignore\n const urlParams = new URLSearchParams(query);\n debug('search web init');\n data = await storage?.search({\n query,\n url: `/-/v1/search?${urlParams.toString()}`,\n abort,\n });\n const checkAccessPromises: searchUtils.SearchItemPkg[] = await Promise.all(\n data.map((pkgItem) => {\n return checkAccess(pkgItem, auth, req.remote_user);\n })\n );\n\n const final: searchUtils.SearchItemPkg[] = checkAccessPromises\n .filter((i) => !_.isNull(i))\n .slice(from, size);\n\n next(final);\n } catch (err: any) {\n next(errorUtils.getInternalError(err.message));\n }\n }\n );\n return router;\n}\n\nexport default addSearchWebApi;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAGA,IAAAI,KAAA,GAAAJ,OAAA;AAA0D,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAO1D,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AAEpD,SAASC,WAAWA,CAACC,GAAQ,EAAEC,IAAS,EAAEC,UAAU,EAA4B;EAC9E,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IAAA,IAAAC,YAAA;IACtCL,IAAI,CAACM,YAAY,CAAC;MAAEC,WAAW,EAAER,GAAG,aAAHA,GAAG,wBAAAM,YAAA,GAAHN,GAAG,CAAES,OAAO,cAAAH,YAAA,uBAAZA,YAAA,CAAcI;IAAK,CAAC,EAAER,UAAU,EAAE,UAAUS,GAAG,EAAEC,OAAO,EAAE;MACzF,IAAID,GAAG,EAAE;QACP,IAAIA,GAAG,CAACE,MAAM,IAAIC,MAAM,CAACH,GAAG,CAACE,MAAM,CAAC,CAACE,KAAK,CAAC,SAAS,CAAC,EAAE;UACrD;UACA;UACAH,OAAO,GAAG,KAAK;UACf,OAAOR,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC,MAAM;UACLC,MAAM,CAACM,GAAG,CAAC;QACb;MACF,CAAC,MAAM;QACL,OAAOP,OAAO,CAACQ,OAAO,GAAGZ,GAAG,GAAG,IAAI,CAAC;MACtC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ;AAEA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IAAI,EAAEoB,GAAG,CAAC2B,WAAW,CAAC;MACpD,CAAC,CACH,CAAC;MAED,MAAMC,KAAkC,GAAGL,mBAAmB,CAC3DM,MAAM,CAAEC,CAAC,IAAK,CAACC,eAAC,CAACC,MAAM,CAACF,CAAC,CAAC,CAAC,CAC3BG,KAAK,CAACpB,IAAI,EAAED,IAAI,CAAC;MAEpBV,IAAI,CAAC0B,KAAK,CAAC;IACb,CAAC,CAAC,OAAOtC,GAAQ,EAAE;MACjBY,IAAI,CAACgC,gBAAU,CAACC,gBAAgB,CAAC7C,GAAG,CAAC8C,OAAO,CAAC,CAAC;IAChD;EACF,CACF,CAAC;EACD,OAAOvC,MAAM;AACf;AAAC,IAAAwC,QAAA,GAEc1C,eAAe;AAAA2C,OAAA,CAAA/D,OAAA,GAAA8D,QAAA"}
1
+ {"version":3,"file":"search.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_url","_core","obj","__esModule","default","debug","buildDebug","checkAccess","pkg","auth","remoteUser","Promise","resolve","reject","_pkg$package","allow_access","packageName","package","name","err","allowed","status","String","match","addSearchWebApi","storage","router","Router","get","req","res","next","_ref","data","abort","AbortController","socket","on","text","params","anything","size","from","query","maintenance","popularity","quality","urlParams","URLSearchParams","search","url","toString","checkAccessPromises","all","map","pkgItem","remote_user","final","filter","i","_","isNull","slice","errorUtils","getInternalError","message","_default","exports"],"sources":["../../src/api/search.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport _ from 'lodash';\nimport { URLSearchParams } from 'url';\n\nimport { Auth } from '@verdaccio/auth';\nimport { errorUtils, searchUtils } from '@verdaccio/core';\nimport { SearchQuery } from '@verdaccio/core/src/search-utils';\nimport { Storage } from '@verdaccio/store';\nimport { Manifest } from '@verdaccio/types';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:search');\n\nfunction checkAccess(pkg: any, auth: any, remoteUser): Promise<Manifest | null> {\n return new Promise((resolve, reject) => {\n auth.allow_access({ packageName: pkg?.package?.name }, remoteUser, function (err, allowed) {\n if (err) {\n if (err.status && String(err.status).match(/^4\\d\\d$/)) {\n // auth plugin returns 4xx user error,\n // that's equivalent of !allowed basically\n allowed = false;\n return resolve(null);\n } else {\n reject(err);\n }\n } else {\n return resolve(allowed ? pkg : null);\n }\n });\n });\n}\n\nfunction addSearchWebApi(storage: Storage, auth: Auth): Router {\n const router = Router(); /* eslint new-cap: 0 */\n router.get(\n '/search/:anything',\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n try {\n let data;\n const abort = new AbortController();\n req.socket.on('close', function () {\n debug('search web aborted');\n abort.abort();\n });\n const text: string = (req.params.anything as string) ?? '';\n // These values are declared as optimal by npm cli\n // FUTURE: could be overwritten by ui settings.\n const size = 20;\n const from = 0;\n const query: SearchQuery = {\n from: 0,\n maintenance: 0.5,\n popularity: 0.98,\n quality: 0.65,\n size: 20,\n text,\n };\n // @ts-ignore\n const urlParams = new URLSearchParams(query);\n debug('search web init');\n data = await storage?.search({\n query,\n url: `/-/v1/search?${urlParams.toString()}`,\n abort,\n });\n const checkAccessPromises: searchUtils.SearchItemPkg[] = await Promise.all(\n data.map((pkgItem) => {\n return checkAccess(pkgItem, auth, req.remote_user);\n })\n );\n\n const final: searchUtils.SearchItemPkg[] = checkAccessPromises\n .filter((i) => !_.isNull(i))\n .slice(from, size);\n\n next(final);\n } catch (err: any) {\n next(errorUtils.getInternalError(err.message));\n }\n }\n );\n return router;\n}\n\nexport default addSearchWebApi;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAGA,IAAAI,KAAA,GAAAJ,OAAA;AAA0D,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA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OAAO,CAAC,CAAC;IAChD;EACF,CACF,CAAC;EACD,OAAOvC,MAAM;AACf;AAAC,IAAAwC,QAAA,GAAAC,OAAA,CAAA/D,OAAA,GAEcoB,eAAe"}
@@ -91,6 +91,5 @@ function addSidebarWebApi(config, storage, auth) {
91
91
  });
92
92
  return router;
93
93
  }
94
- var _default = addSidebarWebApi;
95
- exports.default = _default;
94
+ var _default = exports.default = addSidebarWebApi;
96
95
  //# sourceMappingURL=sidebar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_tarball","_utils","_webUtils","obj","__esModule","default","debug","buildDebug","addSidebarWebApi","config","storage","auth","router","Router","can","allow","beforeAll","a","b","logger","trace","afterAll","get","req","res","next","name","params","scope","addScope","package","requestOptions","protocol","headers","host","remoteAddress","socket","info","getPackageByOptions","uplinksLook","keepUpLinkData","v","query","sideBarInfo","versions","convertDistRemoteToLocalTarballUrls","hostname","url_prefix","isVersionValid","latest","author","formatAuthor","DIST_TAGS","deleteProperties","authorAvatar","web","addGravatarSupport","gravatar","err","status","HTTP_STATUS","NOT_FOUND","end","_default","exports"],"sources":["../../src/api/sidebar.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { DIST_TAGS, HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { convertDistRemoteToLocalTarballUrls } from '@verdaccio/tarball';\nimport { Config, Manifest, Version } from '@verdaccio/types';\nimport { addGravatarSupport, formatAuthor, isVersionValid } from '@verdaccio/utils';\n\nimport { AuthorAvatar, addScope, deleteProperties } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nexport type PackageExt = Manifest & { author: AuthorAvatar; dist?: { tarball: string } };\n\nexport type $SidebarPackage = Manifest & { latest: Version };\nconst debug = buildDebug('verdaccio:web:api:sidebar');\n\nfunction addSidebarWebApi(config: Config, storage: Storage, auth: Auth): Router {\n debug('initialized sidebar web api');\n const router = Router(); /* eslint new-cap: 0 */\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n // Get package readme\n router.get(\n '/sidebar/(@:scope/)?:package',\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const name: string = req.params.scope\n ? addScope(req.params.scope, req.params.package)\n : req.params.package;\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const info = (await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n keepUpLinkData: true,\n requestOptions,\n })) as Manifest;\n const { v } = req.query;\n let sideBarInfo = { ...info };\n sideBarInfo.versions = convertDistRemoteToLocalTarballUrls(\n info,\n { protocol: req.protocol, headers: req.headers as any, host: req.hostname },\n config.url_prefix\n ).versions;\n // TODO: review this implementation\n if (typeof v === 'string' && isVersionValid(info, v)) {\n // @ts-ignore\n sideBarInfo.latest = sideBarInfo.versions[v];\n // @ts-ignore\n sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);\n } else {\n // @ts-ignore\n sideBarInfo.latest = sideBarInfo.versions[info[DIST_TAGS].latest];\n // @ts-ignore\n sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);\n }\n sideBarInfo = deleteProperties(['readme', '_attachments', '_rev', 'name'], sideBarInfo);\n const authorAvatar = config.web\n ? addGravatarSupport(sideBarInfo, config.web.gravatar)\n : addGravatarSupport(sideBarInfo);\n next(authorAvatar);\n } catch (err) {\n res.status(HTTP_STATUS.NOT_FOUND);\n res.end();\n }\n }\n );\n\n return router;\n}\n\nexport default addSidebarWebApi;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M,CAAC;MACrE;MACAP,WAAW,GAAG,IAAAU,0BAAgB,EAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAEV,WAAW,CAAC;MACvF,MAAMW,YAAY,GAAG7C,MAAM,CAAC8C,GAAG,GAC3B,IAAAC,yBAAkB,EAACb,WAAW,EAAElC,MAAM,CAAC8C,GAAG,CAACE,QAAQ,CAAC,GACpD,IAAAD,yBAAkB,EAACb,WAAW,CAAC;MACnClB,IAAI,CAAC6B,YAAY,CAAC;IACpB,CAAC,CAAC,OAAOI,GAAG,EAAE;MACZlC,GAAG,CAACmC,MAAM,CAACC,iBAAW,CAACC,SAAS,CAAC;MACjCrC,GAAG,CAACsC,GAAG,CAAC,CAAC;IACX;EACF,CACF,CAAC;EAED,OAAOlD,MAAM;AACf;AAAC,IAAAmD,QAAA,GAEcvD,gBAAgB;AAAAwD,OAAA,CAAA3D,OAAA,GAAA0D,QAAA"}
1
+ {"version":3,"file":"sidebar.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_tarball","_utils","_webUtils","obj","__esModule","default","debug","buildDebug","addSidebarWebApi","config","storage","auth","router","Router","can","allow","beforeAll","a","b","logger","trace","afterAll","get","req","res","next","name","params","scope","addScope","package","requestOptions","protocol","headers","host","remoteAddress","socket","info","getPackageByOptions","uplinksLook","keepUpLinkData","v","query","sideBarInfo","versions","convertDistRemoteToLocalTarballUrls","hostname","url_prefix","isVersionValid","latest","author","formatAuthor","DIST_TAGS","deleteProperties","authorAvatar","web","addGravatarSupport","gravatar","err","status","HTTP_STATUS","NOT_FOUND","end","_default","exports"],"sources":["../../src/api/sidebar.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { DIST_TAGS, HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { convertDistRemoteToLocalTarballUrls } from '@verdaccio/tarball';\nimport { Config, Manifest, Version } from '@verdaccio/types';\nimport { addGravatarSupport, formatAuthor, isVersionValid } from '@verdaccio/utils';\n\nimport { AuthorAvatar, addScope, deleteProperties } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nexport type PackageExt = Manifest & { author: AuthorAvatar; dist?: { tarball: string } };\n\nexport type $SidebarPackage = Manifest & { latest: Version };\nconst debug = buildDebug('verdaccio:web:api:sidebar');\n\nfunction addSidebarWebApi(config: Config, storage: Storage, auth: Auth): Router {\n debug('initialized sidebar web api');\n const router = Router(); /* eslint new-cap: 0 */\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n // Get package readme\n router.get(\n '/sidebar/(@:scope/)?:package',\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const name: string = req.params.scope\n ? addScope(req.params.scope, req.params.package)\n : req.params.package;\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const info = (await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n keepUpLinkData: true,\n requestOptions,\n })) as Manifest;\n const { v } = req.query;\n let sideBarInfo = { ...info };\n sideBarInfo.versions = convertDistRemoteToLocalTarballUrls(\n info,\n { protocol: req.protocol, headers: req.headers as any, host: req.hostname },\n config.url_prefix\n ).versions;\n // TODO: review this implementation\n if (typeof v === 'string' && isVersionValid(info, v)) {\n // @ts-ignore\n sideBarInfo.latest = sideBarInfo.versions[v];\n // @ts-ignore\n sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);\n } else {\n // @ts-ignore\n sideBarInfo.latest = sideBarInfo.versions[info[DIST_TAGS].latest];\n // @ts-ignore\n sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);\n }\n sideBarInfo = deleteProperties(['readme', '_attachments', '_rev', 'name'], sideBarInfo);\n const authorAvatar = config.web\n ? addGravatarSupport(sideBarInfo, config.web.gravatar)\n : addGravatarSupport(sideBarInfo);\n next(authorAvatar);\n } catch (err) {\n res.status(HTTP_STATUS.NOT_FOUND);\n res.end();\n }\n }\n );\n\n return router;\n}\n\nexport default addSidebarWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAEA,IAAAO,SAAA,GAAAP,OAAA;AAAwE,SAAAD,uBAAAS,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEV;;AAK9D,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,2BAA2B,CAAC;AAErD,SAASC,gBAAgBA,CAACC,MAAc,EAAEC,OAAgB,EAAEC,IAAU,EAAU;EAC9EL,KAAK,CAAC,6BAA6B,CAAC;EACpC,MAAMM,MAAM,GAAG,IAAAC,eAAM,EAAC,CAAC,CAAC,CAAC;EACzB,MAAMC,GAAG,GAAG,IAAAC,iBAAK,EAACJ,IAAI,EAAE;IACtBK,SAAS,EAAEA,CAACC,CAAC,EAAEC,CAAC,KAAKC,cAAM,CAACC,KAAK,CAACH,CAAC,EAAEC,CAAC,CAAC;IACvCG,QAAQ,EAAEA,CAACJ,CAAC,EAAEC,CAAC,KAAKC,cAAM,CAACC,KAAK,CAACH,CAAC,EAAEC,CAAC;EACvC,CAAC,CAAC;EACF;EACAN,MAAM,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AAM,GAAG,IAAAC,mBAAY,EAACR,WAAW,CAACM,MAAM,CAACC,MAAM,CAAC;MACrE,CAAC,MAAM;QACL;QACAP,WAAW,CAACM,MAAM,GAAGN,WAAW,CAACC,QAAQ,CAACP,IAAI,CAACe,eAAS,CAAC,CAACH,MAAM,CAAC;QACjE;QACAN,WAAW,CAACM,MAAM,CAACC,MAAM,GAAG,IAAAC,mBAAY,EAACR,WAAW,CAACM,MAAM,CAACC,MAAM,CAAC;MACrE;MACAP,WAAW,GAAG,IAAAU,0BAAgB,EAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAEV,WAAW,CAAC;MACvF,MAAMW,YAAY,GAAG7C,MAAM,CAAC8C,GAAG,GAC3B,IAAAC,yBAAkB,EAACb,WAAW,EAAElC,MAAM,CAAC8C,GAAG,CAACE,QAAQ,CAAC,GACpD,IAAAD,yBAAkB,EAACb,WAAW,CAAC;MACnClB,IAAI,CAAC6B,YAAY,CAAC;IACpB,CAAC,CAAC,OAAOI,GAAG,EAAE;MACZlC,GAAG,CAACmC,MAAM,CAACC,iBAAW,CAACC,SAAS,CAAC;MACjCrC,GAAG,CAACsC,GAAG,CAAC,CAAC;IACX;EACF,CACF,CAAC;EAED,OAAOlD,MAAM;AACf;AAAC,IAAAmD,QAAA,GAAAC,OAAA,CAAA3D,OAAA,GAEcG,gBAAgB"}
package/build/api/user.js CHANGED
@@ -68,6 +68,5 @@ function addUserAuthApi(auth, config) {
68
68
  }
69
69
  return route;
70
70
  }
71
- var _default = addUserAuthApi;
72
- exports.default = _default;
71
+ var _default = exports.default = addUserAuthApi;
73
72
  //# sourceMappingURL=user.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_core","_middleware","obj","__esModule","default","debug","buildDebug","addUserAuthApi","auth","config","_config$flags","route","Router","post","rateLimit","userRateLimit","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","set","HEADERS","CACHE_CONTROL","token","jwtEncrypt","name","flags","changePassword","put","_config$serverSetting","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validatioUtils","validatePassword","new","serverSettings","passwordValidationRegex","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","_default","exports"],"sources":["../../src/api/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HEADERS,\n HTTP_STATUS,\n VerdaccioError,\n errorUtils,\n validatioUtils,\n} from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\n\nimport { $NextFunctionVer } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:user');\n\nfunction addUserAuthApi(auth: Auth, config: Config): Router {\n const route = Router(); /* eslint new-cap: 0 */\n route.post(\n '/login',\n rateLimit(config?.userRateLimit),\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n const { username, password } = req.body;\n debug('authenticate %o', username);\n auth.authenticate(\n username,\n password,\n async (err: VerdaccioError | null, user?: RemoteUser): Promise<void> => {\n if (err) {\n const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;\n debug('error authenticate %o', errorCode);\n next(errorUtils.getCode(errorCode, err.message));\n } else {\n req.remote_user = user as RemoteUser;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n next({\n token: await auth.jwtEncrypt(user as RemoteUser, jWTSignOptions),\n username: req.remote_user.name,\n });\n }\n }\n );\n }\n );\n\n if (config?.flags?.changePassword === true) {\n route.put(\n '/reset_password',\n rateLimit(config?.userRateLimit),\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n // FUTURE: update to a more meaningful message\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password } = req.body;\n const { name } = req.remote_user;\n\n if (\n validatioUtils.validatePassword(\n password.new,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));\n }\n\n auth.changePassword(name as string, password.old, password.new, (err, isUpdated): void => {\n if (_.isNil(err) && isUpdated) {\n next({\n ok: true,\n });\n } else {\n return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n });\n }\n );\n }\n\n return route;\n}\n\nexport default addUserAuthApi;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGA,IAAAG,KAAA,GAAAH,OAAA;AASA,IAAAI,WAAA,GAAAJ,OAAA;AAAkD,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAKlD,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,wBAAwB,CAAC;AAElD,SAASC,cAAcA,CAACC,IAAU,EAAEC,MAAc,EAAU;EAAA,IAAAC,aAAA;EAC1D,MAAMC,KAAK,GAAG,IAAAC,eAAM,EAAC,CAAC,CAAC,CAAC;EACxBD,KAAK,CAACE,IAAI,CACR,QAAQ,EACR,IAAAC,qBAAS,EAACL,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEM,aAAa,CAAC,EAChC,UAAUC,GAAY,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IACnE,MAAM;MAAEC,QAAQ;MAAEC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WAAW,CAACU,IAAI,CAAC,EAAE;QACjCzB,GAAG,CAACgC,MAAM,CAACtB,iBAAW,CAACC,YAAY,CAAC;QACpC,OAAOV,IAAI,CAAC;UACV;UACAQ,OAAO,EAAEwB,eAAS,CAACC;QACrB,CAAC,CAAC;MACJ;MAEA,MAAM;QAAE/B;MAAS,CAAC,GAAGJ,GAAG,CAACK,IAAI;MAC7B,MAAM;QAAEqB;MAAK,CAAC,GAAG1B,GAAG,CAACgB,WAAW;MAEhC,IACEoB,oBAAc,CAACC,gBAAgB,CAC7BjC,QAAQ,CAACkC,GAAG,EACZ7C,MAAM,aAANA,MAAM,wBAAAqC,qBAAA,GAANrC,MAAM,CAAE8C,cAAc,cAAAT,qBAAA,uBAAtBA,qBAAA,CAAwBU,uBAC1B,CAAC,KAAK,KAAK,EACX;QACA,OAAOtC,IAAI,CAACY,gBAAU,CAACC,OAAO,CAACJ,iBAAW,CAAC8B,WAAW,EAAEC,eAAS,CAACC,mBAAmB,CAAC,CAAC;MACzF;MAEAnD,IAAI,CAACoC,cAAc,CAACF,IAAI,EAAYtB,QAAQ,CAACwC,GAAG,EAAExC,QAAQ,CAACkC,GAAG,EAAE,CAAC/B,GAAG,EAAEsC,SAAS,KAAW;QACxF,IAAId,eAAC,CAACC,KAAK,CAACzB,GAAG,CAAC,IAAIsC,SAAS,EAAE;UAC7B3C,IAAI,CAAC;YACH4C,EAAE,EAAE;UACN,CAAC,CAAC;QACJ,CAAC,MAAM;UACL,OAAO5C,IAAI,CAACY,gBAAU,CAACiC,gBAAgB,CAACb,eAAS,CAACc,qBAAqB,CAAC,CAAC;QAC3E;MACF,CAAC,CAAC;IACJ,CACF,CAAC;EACH;EAEA,OAAOrD,KAAK;AACd;AAAC,IAAAsD,QAAA,GAEc1D,cAAc;AAAA2D,OAAA,CAAA9D,OAAA,GAAA6D,QAAA"}
1
+ {"version":3,"file":"user.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_core","_middleware","obj","__esModule","default","debug","buildDebug","addUserAuthApi","auth","config","_config$flags","route","Router","post","rateLimit","userRateLimit","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","set","HEADERS","CACHE_CONTROL","token","jwtEncrypt","name","flags","changePassword","put","_config$serverSetting","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validatioUtils","validatePassword","new","serverSettings","passwordValidationRegex","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","_default","exports"],"sources":["../../src/api/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HEADERS,\n HTTP_STATUS,\n VerdaccioError,\n errorUtils,\n validatioUtils,\n} from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\n\nimport { $NextFunctionVer } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:user');\n\nfunction addUserAuthApi(auth: Auth, config: Config): Router {\n const route = Router(); /* eslint new-cap: 0 */\n route.post(\n '/login',\n rateLimit(config?.userRateLimit),\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n const { username, password } = req.body;\n debug('authenticate %o', username);\n auth.authenticate(\n username,\n password,\n async (err: VerdaccioError | null, user?: RemoteUser): Promise<void> => {\n if (err) {\n const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;\n debug('error authenticate %o', errorCode);\n next(errorUtils.getCode(errorCode, err.message));\n } else {\n req.remote_user = user as RemoteUser;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n next({\n token: await auth.jwtEncrypt(user as RemoteUser, jWTSignOptions),\n username: req.remote_user.name,\n });\n }\n }\n );\n }\n );\n\n if (config?.flags?.changePassword === true) {\n route.put(\n '/reset_password',\n rateLimit(config?.userRateLimit),\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n // FUTURE: update to a more meaningful message\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password } = req.body;\n const { name } = req.remote_user;\n\n if (\n validatioUtils.validatePassword(\n password.new,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));\n }\n\n auth.changePassword(name as string, password.old, password.new, (err, isUpdated): void => {\n if (_.isNil(err) && isUpdated) {\n next({\n ok: true,\n });\n } else {\n return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n });\n }\n );\n }\n\n return route;\n}\n\nexport default addUserAuthApi;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGA,IAAAG,KAAA,GAAAH,OAAA;AASA,IAAAI,WAAA,GAAAJ,OAAA;AAAkD,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAKlD,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,wBAAwB,CAAC;AAElD,SAASC,cAAcA,CAACC,IAAU,EAAEC,MAAc,EAAU;EAAA,IAAAC,aAAA;EAC1D,MAAMC,KAAK,GAAG,IAAAC,eAAM,EAAC,CAAC,CAAC,CAAC;EACxBD,KAAK,CAACE,IAAI,CACR,QAAQ,EACR,IAAAC,qBAAS,EAACL,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEM,aA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CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/web",
3
- "version": "6.0.0-6-next.63",
3
+ "version": "7.0.0-next-7.8",
4
4
  "description": "web ui middleware",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -20,35 +20,34 @@
20
20
  "verdaccio"
21
21
  ],
22
22
  "engines": {
23
- "node": ">=14",
24
- "npm": ">=6"
23
+ "node": ">=18"
25
24
  },
26
25
  "license": "MIT",
27
26
  "dependencies": {
28
- "@verdaccio/auth": "6.0.0-6-next.55",
29
- "@verdaccio/core": "6.0.0-6-next.76",
30
- "@verdaccio/config": "6.0.0-6-next.76",
31
- "@verdaccio/loaders": "6.0.0-6-next.45",
32
- "@verdaccio/logger": "6.0.0-6-next.44",
33
- "@verdaccio/middleware": "6.0.0-6-next.55",
34
- "@verdaccio/store": "6.0.0-6-next.56",
35
- "@verdaccio/tarball": "11.0.0-6-next.45",
36
- "@verdaccio/url": "11.0.0-6-next.42",
37
- "@verdaccio/utils": "6.0.0-6-next.44",
27
+ "@verdaccio/auth": "7.0.0-next-7.8",
28
+ "@verdaccio/config": "7.0.0-next-7.8",
29
+ "@verdaccio/core": "7.0.0-next-7.8",
30
+ "@verdaccio/loaders": "7.0.0-next-7.8",
31
+ "@verdaccio/logger": "7.0.0-next-7.8",
32
+ "@verdaccio/middleware": "7.0.0-next-7.8",
33
+ "@verdaccio/store": "7.0.0-next-7.8",
34
+ "@verdaccio/tarball": "12.0.0-next-7.8",
35
+ "@verdaccio/url": "12.0.0-next-7.8",
36
+ "@verdaccio/utils": "7.0.0-next-7.8",
38
37
  "debug": "4.3.4",
39
38
  "express": "4.18.2",
40
39
  "lodash": "4.17.21"
41
40
  },
42
41
  "devDependencies": {
43
- "@verdaccio/types": "11.0.0-6-next.25",
44
- "@verdaccio/test-helper": "2.0.0-6-next.8",
45
- "@verdaccio/api": "6.0.0-6-next.59",
46
- "node-html-parser": "4.1.5",
47
- "supertest": "6.3.3",
48
- "nock": "13.2.9",
42
+ "@verdaccio/api": "7.0.0-next-7.8",
43
+ "@verdaccio/test-helper": "3.0.0-next.1",
44
+ "@verdaccio/types": "12.0.0-next.2",
49
45
  "jsdom": "20.0.3",
50
- "verdaccio-auth-memory": "11.0.0-6-next.41",
51
- "verdaccio-memory": "11.0.0-6-next.43"
46
+ "nock": "13.5.1",
47
+ "node-html-parser": "4.1.5",
48
+ "supertest": "6.3.4",
49
+ "verdaccio-auth-memory": "12.0.0-next-7.8",
50
+ "verdaccio-memory": "12.0.0-next-7.8"
52
51
  },
53
52
  "funding": {
54
53
  "type": "opencollective",