@verdaccio/config 6.0.0-6-next.75 → 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 +445 -4
- package/LICENSE +1 -1
- package/build/config.d.ts +1 -0
- package/build/config.js +30 -17
- package/build/config.js.map +1 -1
- package/build/package-access.js +3 -5
- package/build/package-access.js.map +1 -1
- package/build/security.js +2 -4
- package/build/security.js.map +1 -1
- package/build/serverSettings.js +1 -2
- package/build/serverSettings.js.map +1 -1
- package/build/token.js +1 -2
- package/build/token.js.map +1 -1
- package/build/uplinks.js +2 -4
- package/build/uplinks.js.map +1 -1
- package/build/user.js +2 -4
- package/build/user.js.map +1 -1
- package/jest.config.js +1 -2
- package/package.json +6 -6
- package/src/config.ts +27 -14
- package/src/package-access.ts +1 -1
- package/test/agent.spec.ts +42 -0
- package/test/builder.spec.ts +6 -0
- package/test/config.spec.ts +29 -0
- package/test/package-access.spec.ts +27 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,446 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
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/utils@7.0.0-next-7.7
|
|
9
|
+
|
|
10
|
+
## 7.0.0-next.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 4d96324: chore(config): increase test coverage
|
|
15
|
+
- @verdaccio/core@7.0.0-next.6
|
|
16
|
+
- @verdaccio/utils@7.0.0-next.6
|
|
17
|
+
|
|
18
|
+
## 7.0.0-next.5
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- f047cc8: refactor: auth with legacy sign support
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [f047cc8]
|
|
27
|
+
- @verdaccio/core@7.0.0-next.5
|
|
28
|
+
- @verdaccio/utils@7.0.0-next.5
|
|
29
|
+
|
|
30
|
+
## 7.0.0-next.4
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- @verdaccio/core@7.0.0-next.4
|
|
35
|
+
- @verdaccio/utils@7.0.0-next.4
|
|
36
|
+
|
|
37
|
+
## 7.0.0-next.3
|
|
38
|
+
|
|
39
|
+
### Major Changes
|
|
40
|
+
|
|
41
|
+
- e7ebccb61: update major dependencies, remove old nodejs support
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- daceb6d87: restore legacy support
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [daceb6d87]
|
|
50
|
+
- Updated dependencies [e7ebccb61]
|
|
51
|
+
- @verdaccio/core@7.0.0-next.3
|
|
52
|
+
- @verdaccio/utils@7.0.0-next.3
|
|
53
|
+
|
|
54
|
+
## 7.0.0-next.2
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- @verdaccio/core@7.0.0-next.2
|
|
59
|
+
- @verdaccio/utils@7.0.0-next.2
|
|
60
|
+
|
|
61
|
+
## 7.0.0-next.1
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- @verdaccio/core@7.0.0-next.1
|
|
66
|
+
- @verdaccio/utils@7.0.0-next.1
|
|
67
|
+
|
|
68
|
+
## 7.0.0-next.0
|
|
69
|
+
|
|
70
|
+
### Major Changes
|
|
71
|
+
|
|
72
|
+
- feat!: bump to v7
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies
|
|
77
|
+
- @verdaccio/core@7.0.0-next.0
|
|
78
|
+
- @verdaccio/utils@7.0.0-next.0
|
|
79
|
+
|
|
80
|
+
## 6.0.0
|
|
81
|
+
|
|
82
|
+
### Major Changes
|
|
83
|
+
|
|
84
|
+
- 292c0a37f: feat!: replace deprecated request dependency by got
|
|
85
|
+
|
|
86
|
+
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.
|
|
87
|
+
|
|
88
|
+
## Notes
|
|
89
|
+
|
|
90
|
+
- Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
|
|
91
|
+
- Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
|
|
92
|
+
- Refactor with promises instead callback wherever is possible
|
|
93
|
+
- ~Document the API~
|
|
94
|
+
- Improve testing, integration tests
|
|
95
|
+
- Bugfix
|
|
96
|
+
- Clean up old validations
|
|
97
|
+
- Improve performance
|
|
98
|
+
|
|
99
|
+
## 💥 Breaking changes
|
|
100
|
+
|
|
101
|
+
- Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
|
|
102
|
+
- 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));`
|
|
103
|
+
- `@verdaccio/streams` stream abort support is legacy is being deprecated removed
|
|
104
|
+
- Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
|
|
105
|
+
|
|
106
|
+
- 459b6fa72: refactor: search v1 endpoint and local-database
|
|
107
|
+
|
|
108
|
+
- refactor search `api v1` endpoint, improve performance
|
|
109
|
+
- remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
|
|
110
|
+
- refactor method storage class
|
|
111
|
+
- create new module `core` to reduce the ammount of modules with utilities
|
|
112
|
+
- use `undici` instead `node-fetch`
|
|
113
|
+
- use `fastify` instead `express` for functional test
|
|
114
|
+
|
|
115
|
+
### Breaking changes
|
|
116
|
+
|
|
117
|
+
- plugin storage API changes
|
|
118
|
+
- remove old search endpoint (return 404)
|
|
119
|
+
- filter local private packages at plugin level
|
|
120
|
+
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
export interface IPluginStorage<T> extends IPlugin {
|
|
125
|
+
add(name: string): Promise<void>;
|
|
126
|
+
remove(name: string): Promise<void>;
|
|
127
|
+
get(): Promise<any>;
|
|
128
|
+
init(): Promise<void>;
|
|
129
|
+
getSecret(): Promise<string>;
|
|
130
|
+
setSecret(secret: string): Promise<any>;
|
|
131
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
132
|
+
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
|
|
133
|
+
saveToken(token: Token): Promise<any>;
|
|
134
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
135
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- 9fc2e7961: feat(plugins): improve plugin loader
|
|
140
|
+
|
|
141
|
+
### Changes
|
|
142
|
+
|
|
143
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
144
|
+
- Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
|
|
145
|
+
- https://github.com/verdaccio/verdaccio/issues/1394
|
|
146
|
+
- `config.plugins` plugin path validations
|
|
147
|
+
- Updated algorithm for plugin loader.
|
|
148
|
+
- improved documentation (included dev)
|
|
149
|
+
|
|
150
|
+
## Features
|
|
151
|
+
|
|
152
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
153
|
+
- Custom prefix:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
// config.yaml
|
|
157
|
+
server:
|
|
158
|
+
pluginPrefix: mycompany
|
|
159
|
+
middleware:
|
|
160
|
+
audit:
|
|
161
|
+
foo: 1
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
|
|
165
|
+
|
|
166
|
+
## Breaking Changes
|
|
167
|
+
|
|
168
|
+
### sinopia plugins
|
|
169
|
+
|
|
170
|
+
- `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
|
|
171
|
+
|
|
172
|
+
### plugin filter
|
|
173
|
+
|
|
174
|
+
- method rename `filter_metadata`->`filterMetadata`
|
|
175
|
+
|
|
176
|
+
### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
|
|
177
|
+
|
|
178
|
+
The plugin receives as first argument `config`, which represents the config of the plugin. Example:
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
// config.yaml
|
|
182
|
+
auth:
|
|
183
|
+
plugin:
|
|
184
|
+
foo: 1
|
|
185
|
+
bar: 2
|
|
186
|
+
|
|
187
|
+
export class Plugin<T> {
|
|
188
|
+
public constructor(config: T, options: PluginOptions) {
|
|
189
|
+
console.log(config);
|
|
190
|
+
// {foo:1, bar: 2}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
- 794af76c5: Remove Node 12 support
|
|
196
|
+
|
|
197
|
+
- We need move to the new `undici` and does not support Node.js 12
|
|
198
|
+
|
|
199
|
+
- 10aeb4f13: feat!: experiments config renamed to flags
|
|
200
|
+
|
|
201
|
+
- The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
flags: token: false;
|
|
205
|
+
search: false;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
- The `self_path` property from the config file is being removed in favor of `config_file` full path.
|
|
209
|
+
- Refactor `config` module, better types and utilities
|
|
210
|
+
|
|
211
|
+
- e367c3f1e: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
|
|
212
|
+
|
|
213
|
+
- Introduce environment variables for legacy tokens
|
|
214
|
+
|
|
215
|
+
### Code Improvements
|
|
216
|
+
|
|
217
|
+
- Add debug library for improve developer experience
|
|
218
|
+
|
|
219
|
+
### Breaking change
|
|
220
|
+
|
|
221
|
+
- The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
|
|
222
|
+
- The secret key must have 32 characters long.
|
|
223
|
+
|
|
224
|
+
### New environment variables
|
|
225
|
+
|
|
226
|
+
- `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
|
|
227
|
+
- `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
|
|
228
|
+
|
|
229
|
+
- 82cb0f2bf: feat!: config.logs throw an error, logging config not longer accept array or logs property
|
|
230
|
+
|
|
231
|
+
### 💥 Breaking change
|
|
232
|
+
|
|
233
|
+
This is valid
|
|
234
|
+
|
|
235
|
+
```yaml
|
|
236
|
+
log: { type: stdout, format: pretty, level: http }
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
This is invalid
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
logs: { type: stdout, format: pretty, level: http }
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
or
|
|
246
|
+
|
|
247
|
+
```yaml
|
|
248
|
+
logs:
|
|
249
|
+
- [{ type: stdout, format: pretty, level: http }]
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
- 8f43bf17d: feat: node api new structure based on promise
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
import { runServer } from "@verdaccio/node-api";
|
|
256
|
+
// or
|
|
257
|
+
import { runServer } from "verdaccio";
|
|
258
|
+
|
|
259
|
+
const app = await runServer(); // default configuration
|
|
260
|
+
const app = await runServer("./config/config.yaml");
|
|
261
|
+
const app = await runServer({ configuration });
|
|
262
|
+
app.listen(4000, (event) => {
|
|
263
|
+
// do something
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Breaking Change
|
|
268
|
+
|
|
269
|
+
If you are using the node-api, the new structure is Promise based and less arguments.
|
|
270
|
+
|
|
271
|
+
### Minor Changes
|
|
272
|
+
|
|
273
|
+
- ef88da3b4: feat: improve support for fs promises older nodejs
|
|
274
|
+
- 1b217fd34: Some verdaccio modules depend on 'mkdirp' library which provides recursive directory creation functionality.
|
|
275
|
+
NodeJS can do this out of the box since v.10.12. The last commit in 'mkdirp' was made in early 2016, and it's mid 2021 now.
|
|
276
|
+
Time to stick with a built-in library solution!
|
|
277
|
+
|
|
278
|
+
- All 'mkdirp' calls are replaced with appropriate 'fs' calls.
|
|
279
|
+
|
|
280
|
+
- d167f92e1: chore: rollback yaml dep support old nodejs versions
|
|
281
|
+
- ddb6a2239: feat: signature package
|
|
282
|
+
- b61f762d6: feat: add server rate limit protection to all request
|
|
283
|
+
|
|
284
|
+
To modify custom values, use the server settings property.
|
|
285
|
+
|
|
286
|
+
```markdown
|
|
287
|
+
server:
|
|
288
|
+
|
|
289
|
+
## https://www.npmjs.com/package/express-rate-limit#configuration-options
|
|
290
|
+
|
|
291
|
+
rateLimit:
|
|
292
|
+
windowMs: 1000
|
|
293
|
+
max: 10000
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
The values are intended to be high, if you want to improve security of your server consider
|
|
297
|
+
using different values.
|
|
298
|
+
|
|
299
|
+
- d43894e8f: feat: rework web header for mobile, add new settings and raw manifest button
|
|
300
|
+
|
|
301
|
+
### New set of variables to hide features
|
|
302
|
+
|
|
303
|
+
Add set of new variables that allow hide different parts of the UI, buttons, footer or download tarballs. _All are
|
|
304
|
+
enabled by default_.
|
|
305
|
+
|
|
306
|
+
```yaml
|
|
307
|
+
# login: true <-- already exist but worth the reminder
|
|
308
|
+
# showInfo: true
|
|
309
|
+
# showSettings: true
|
|
310
|
+
# In combination with darkMode you can force specific theme
|
|
311
|
+
# showThemeSwitch: true
|
|
312
|
+
# showFooter: true
|
|
313
|
+
# showSearch: true
|
|
314
|
+
# showDownloadTarball: true
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
> If you disable `showThemeSwitch` and force `darkMode: true` the local storage settings would be
|
|
318
|
+
> ignored and force all themes to the one in the configuration file.
|
|
319
|
+
|
|
320
|
+
Future could be extended to
|
|
321
|
+
|
|
322
|
+
### Raw button to display manifest package
|
|
323
|
+
|
|
324
|
+
A new experimental feature (enabled by default), button named RAW to be able navigate on the package manifest directly on the ui, kudos to [react-json-view](https://www.npmjs.com/package/react-json-view) that allows an easy integration, not configurable yet until get more feedback.
|
|
325
|
+
|
|
326
|
+
```yaml
|
|
327
|
+
showRaw: true
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
#### Rework header buttons
|
|
331
|
+
|
|
332
|
+
- The header has been rework, the mobile was not looking broken.
|
|
333
|
+
- Removed info button in the header and moved to a dialog
|
|
334
|
+
- Info dialog now contains more information about the project, license and the aid content for Ukrania now is inside of the info modal.
|
|
335
|
+
- Separate settings and info to avoid collapse too much info (for mobile still need some work)
|
|
336
|
+
|
|
337
|
+
- 154b2ecd3: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
|
|
338
|
+
- aa763baec: feat: add typescript project references settings
|
|
339
|
+
|
|
340
|
+
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.
|
|
341
|
+
|
|
342
|
+
It allows to navigate (IDE) trough the packages without need compile the packages.
|
|
343
|
+
|
|
344
|
+
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).
|
|
345
|
+
|
|
346
|
+
- 16e38df8a: feat: trustProxy property
|
|
347
|
+
- dc571aabd: feat: add forceEnhancedLegacySignature
|
|
348
|
+
- 62c24b632: feat: add passwordValidationRegex property
|
|
349
|
+
- d08fe29d9: feat(web): add a config item to web,let the developer can select whet……her enable the html cache
|
|
350
|
+
- 5167bb528: feat: ui search support for remote, local and private packages
|
|
351
|
+
|
|
352
|
+
The command `npm search` search globally and return all matches, with this improvement the user interface
|
|
353
|
+
is powered with the same capabilities.
|
|
354
|
+
|
|
355
|
+
The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
|
|
356
|
+
|
|
357
|
+
- 4b29d715b: chore: move improvements from v5 to v6
|
|
358
|
+
|
|
359
|
+
Migrate improvements form v5 to v6:
|
|
360
|
+
|
|
361
|
+
- https://github.com/verdaccio/verdaccio/pull/3158
|
|
362
|
+
- https://github.com/verdaccio/verdaccio/pull/3151
|
|
363
|
+
- https://github.com/verdaccio/verdaccio/pull/2271
|
|
364
|
+
- https://github.com/verdaccio/verdaccio/pull/2787
|
|
365
|
+
- https://github.com/verdaccio/verdaccio/pull/2791
|
|
366
|
+
- https://github.com/verdaccio/verdaccio/pull/2205
|
|
367
|
+
|
|
368
|
+
- 45c03819e: refactor: render html middleware
|
|
369
|
+
|
|
370
|
+
### Patch Changes
|
|
371
|
+
|
|
372
|
+
- 679c19c1b: Respect the `changePassword` configuration flag to enable changing the password through the web API.
|
|
373
|
+
|
|
374
|
+
> **Note**
|
|
375
|
+
> This feature is still experimental and not fully supported in the default web application.
|
|
376
|
+
|
|
377
|
+
- 9718e0330: fix: build targets for 5x modules
|
|
378
|
+
- 1810ed0d8: Feature
|
|
379
|
+
|
|
380
|
+
- add option to set storage from environment variable VERDACCIO_STORAGE_PATH
|
|
381
|
+
|
|
382
|
+
#### Related tickets
|
|
383
|
+
|
|
384
|
+
https://github.com/verdaccio/verdaccio/issues/1681
|
|
385
|
+
|
|
386
|
+
- a610ef26b: chore: add release step to private regisry on merge changeset pr
|
|
387
|
+
- 34f0f1101: Enable prerelease mode with **changesets**
|
|
388
|
+
- 68ea21214: ESLint Warnings Fixed
|
|
389
|
+
|
|
390
|
+
Related to issue #1461
|
|
391
|
+
|
|
392
|
+
- max-len: most of the sensible max-len errors are fixed
|
|
393
|
+
- no-unused-vars: most of these types of errors are fixed by deleting not needed declarations
|
|
394
|
+
- @typescript-eslint/no-unused-vars: same as above
|
|
395
|
+
|
|
396
|
+
- Updated dependencies [292c0a37f]
|
|
397
|
+
- Updated dependencies [a1986e098]
|
|
398
|
+
- Updated dependencies [974cd8c19]
|
|
399
|
+
- Updated dependencies [a828271d6]
|
|
400
|
+
- Updated dependencies [ef88da3b4]
|
|
401
|
+
- Updated dependencies [43f32687c]
|
|
402
|
+
- Updated dependencies [a3a209b5e]
|
|
403
|
+
- Updated dependencies [459b6fa72]
|
|
404
|
+
- Updated dependencies [24b9be020]
|
|
405
|
+
- Updated dependencies [794af76c5]
|
|
406
|
+
- Updated dependencies [351aeeaa8]
|
|
407
|
+
- Updated dependencies [10aeb4f13]
|
|
408
|
+
- Updated dependencies [9718e0330]
|
|
409
|
+
- Updated dependencies [e367c3f1e]
|
|
410
|
+
- Updated dependencies [a1da11308]
|
|
411
|
+
- Updated dependencies [d2c65da9c]
|
|
412
|
+
- Updated dependencies [00d1d2a17]
|
|
413
|
+
- Updated dependencies [a610ef26b]
|
|
414
|
+
- Updated dependencies [648575aa4]
|
|
415
|
+
- Updated dependencies [b61f762d6]
|
|
416
|
+
- Updated dependencies [154b2ecd3]
|
|
417
|
+
- Updated dependencies [aa763baec]
|
|
418
|
+
- Updated dependencies [378e907d5]
|
|
419
|
+
- Updated dependencies [16e38df8a]
|
|
420
|
+
- Updated dependencies [34f0f1101]
|
|
421
|
+
- Updated dependencies [82cb0f2bf]
|
|
422
|
+
- Updated dependencies [dc571aabd]
|
|
423
|
+
- Updated dependencies [f859d2b1a]
|
|
424
|
+
- Updated dependencies [6c1eb021b]
|
|
425
|
+
- Updated dependencies [62c24b632]
|
|
426
|
+
- Updated dependencies [0a6412ca9]
|
|
427
|
+
- Updated dependencies [5167bb528]
|
|
428
|
+
- Updated dependencies [f86c31ed0]
|
|
429
|
+
- Updated dependencies [c9d1af0e5]
|
|
430
|
+
- Updated dependencies [4b29d715b]
|
|
431
|
+
- Updated dependencies [b13a3fefd]
|
|
432
|
+
- Updated dependencies [68ea21214]
|
|
433
|
+
- Updated dependencies [b849128de]
|
|
434
|
+
- @verdaccio/core@6.0.0
|
|
435
|
+
- @verdaccio/utils@6.0.0
|
|
436
|
+
|
|
437
|
+
## 6.0.0-6-next.76
|
|
438
|
+
|
|
439
|
+
### Patch Changes
|
|
440
|
+
|
|
441
|
+
- @verdaccio/core@6.0.0-6-next.76
|
|
442
|
+
- @verdaccio/utils@6.0.0-6-next.44
|
|
443
|
+
|
|
3
444
|
## 6.0.0-6-next.75
|
|
4
445
|
|
|
5
446
|
### Patch Changes
|
|
@@ -586,14 +1027,14 @@
|
|
|
586
1027
|
- 5c5057fc: feat: node api new structure based on promise
|
|
587
1028
|
|
|
588
1029
|
```js
|
|
589
|
-
import { runServer } from
|
|
1030
|
+
import { runServer } from "@verdaccio/node-api";
|
|
590
1031
|
// or
|
|
591
|
-
import { runServer } from
|
|
1032
|
+
import { runServer } from "verdaccio";
|
|
592
1033
|
|
|
593
1034
|
const app = await runServer(); // default configuration
|
|
594
|
-
const app = await runServer(
|
|
1035
|
+
const app = await runServer("./config/config.yaml");
|
|
595
1036
|
const app = await runServer({ configuration });
|
|
596
|
-
app.listen(4000, event => {
|
|
1037
|
+
app.listen(4000, (event) => {
|
|
597
1038
|
// do something
|
|
598
1039
|
});
|
|
599
1040
|
```
|
package/LICENSE
CHANGED
package/build/config.d.ts
CHANGED
package/build/config.js
CHANGED
|
@@ -20,11 +20,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
21
21
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
22
22
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
23
|
-
const WEB_TITLE = 'Verdaccio';
|
|
23
|
+
const WEB_TITLE = exports.WEB_TITLE = 'Verdaccio';
|
|
24
24
|
|
|
25
25
|
// we limit max 1000 request per 15 minutes on user endpoints
|
|
26
|
-
exports.
|
|
27
|
-
const defaultUserRateLimiting = {
|
|
26
|
+
const defaultUserRateLimiting = exports.defaultUserRateLimiting = {
|
|
28
27
|
windowMs: 15 * 60 * 1000,
|
|
29
28
|
// 15 minutes
|
|
30
29
|
max: 1000
|
|
@@ -33,7 +32,6 @@ const defaultUserRateLimiting = {
|
|
|
33
32
|
/**
|
|
34
33
|
* Coordinates the application configuration
|
|
35
34
|
*/
|
|
36
|
-
exports.defaultUserRateLimiting = defaultUserRateLimiting;
|
|
37
35
|
class Config {
|
|
38
36
|
/**
|
|
39
37
|
* @deprecated use configPath or config.getConfigPath();
|
|
@@ -41,7 +39,12 @@ class Config {
|
|
|
41
39
|
|
|
42
40
|
// @ts-ignore
|
|
43
41
|
|
|
44
|
-
constructor(config,
|
|
42
|
+
constructor(config,
|
|
43
|
+
// forceEnhancedLegacySignature is a property that
|
|
44
|
+
// allows switch a new legacy aes signature token signature
|
|
45
|
+
// for older versions do not want to have this new signature model
|
|
46
|
+
// this property must be false
|
|
47
|
+
configOptions = {
|
|
45
48
|
forceEnhancedLegacySignature: true
|
|
46
49
|
}) {
|
|
47
50
|
var _config$flags$searchR, _config$flags, _config$flags$changeP, _config$flags2;
|
|
@@ -109,6 +112,15 @@ class Config {
|
|
|
109
112
|
this.server_id = (0, _utils.generateRandomHexString)(6);
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
getEnhancedLegacySignature() {
|
|
116
|
+
if (typeof (this === null || this === void 0 ? void 0 : this.security.enhancedLegacySignature) !== 'undefined') {
|
|
117
|
+
if (this.security.enhancedLegacySignature === true) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return this.configOptions.forceEnhancedLegacySignature;
|
|
123
|
+
}
|
|
112
124
|
getConfigPath() {
|
|
113
125
|
return this.configPath;
|
|
114
126
|
}
|
|
@@ -126,7 +138,7 @@ class Config {
|
|
|
126
138
|
* @secret external secret key
|
|
127
139
|
*/
|
|
128
140
|
checkSecretKey(secret) {
|
|
129
|
-
var _this$secret;
|
|
141
|
+
var _this$security, _this$secret;
|
|
130
142
|
debug('check secret key');
|
|
131
143
|
if (typeof secret === 'string' && _lodash.default.isEmpty(secret) === false) {
|
|
132
144
|
this.secret = secret;
|
|
@@ -135,20 +147,21 @@ class Config {
|
|
|
135
147
|
}
|
|
136
148
|
// generate a new a secret key
|
|
137
149
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
138
|
-
debug('
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
debug('generating a new secret key');
|
|
151
|
+
if (this.getEnhancedLegacySignature()) {
|
|
152
|
+
debug('key generated with "enhanced" legacy signature user config');
|
|
141
153
|
this.secret = (0, _token.generateRandomSecretKey)();
|
|
142
154
|
} else {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
debug('key generated with legacy signature user config');
|
|
156
|
+
this.secret = (0, _utils.generateRandomHexString)(32);
|
|
157
|
+
}
|
|
158
|
+
// set this to false allow use old token signature and is not recommended
|
|
159
|
+
// only use for migration reasons, major release will remove this property and
|
|
160
|
+
// set it by default
|
|
161
|
+
if (((_this$security = this.security) === null || _this$security === void 0 ? void 0 : _this$security.enhancedLegacySignature) === false) {
|
|
162
|
+
_core.warningUtils.emit(_warningUtils.Codes.VERWAR005);
|
|
150
163
|
}
|
|
151
|
-
debug('generated a new secret key %s', (_this$secret = this.secret) === null || _this$secret === void 0 ? void 0 : _this$secret.length);
|
|
164
|
+
debug('generated a new secret key length %s', (_this$secret = this.secret) === null || _this$secret === void 0 ? void 0 : _this$secret.length);
|
|
152
165
|
return this.secret;
|
|
153
166
|
}
|
|
154
167
|
}
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["_assert","_interopRequireDefault","require","_debug","_lodash","_core","_warningUtils","_utils","_agent","_packageAccess","_security","_serverSettings","_token","_uplinks","obj","__esModule","default","strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","exports","defaultUserRateLimiting","windowMs","max","Config","constructor","config","configOptions","forceEnhancedLegacySignature","_config$flags$searchR","_config$flags","_config$flags$changeP","_config$flags2","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","_config$config_path","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","changePassword","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","_this$secret","isEmpty","generateRandomSecretKey","enhancedLegacySignature","warningUtils","emit","Codes","VERWAR005","length"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR, warningUtils } from '@verdaccio/core';\nimport { Codes } from '@verdaccio/core/build/warning-utils';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n RateLimit,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings from './serverSettings';\nimport { generateRandomSecretKey } from './token';\nimport { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';\n\nconst strategicConfigProps = ['uplinks', 'packages'];\nconst allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];\nconst debug = buildDebug('verdaccio:config');\n\nexport const WEB_TITLE = 'Verdaccio';\n\n// we limit max 1000 request per 15 minutes on user endpoints\nexport const defaultUserRateLimiting = {\n windowMs: 15 * 60 * 1000, // 15 minutes\n max: 1000,\n};\n\n/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string | undefined;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n public configPath: string;\n /**\n * @deprecated use configPath or config.getConfigPath();\n */\n public self_path: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n private configOptions: { forceEnhancedLegacySignature: boolean };\n public constructor(\n config: ConfigYaml & { config_path: string },\n configOptions = { forceEnhancedLegacySignature: true }\n ) {\n const self = this;\n this.configOptions = configOptions;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n // backport self_path for previous to version 6\n // @ts-expect-error\n config.configPath = config.config_path ?? config.self_path;\n if (!config.configPath) {\n throw new Error('configPath property is required');\n }\n }\n this.configPath = config.configPath;\n this.self_path = this.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n changePassword: config.flags?.changePassword ?? false,\n };\n this.user_agent = config.user_agent;\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n if (typeof this.user_agent === 'undefined') {\n // by default user agent is hidden\n debug('set default user agent');\n this.user_agent = getUserAgent(false);\n }\n\n this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);\n\n // sanity check for strategic config properties\n strategicConfigProps.forEach(function (x): void {\n if (self[x] == null) {\n self[x] = {};\n }\n\n assert(isObject(self[x]), `CONFIG: bad \"${x}\" value (object expected)`);\n });\n\n this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));\n this.packages = normalisePackageAccess(self.packages);\n\n // loading these from ENV if aren't in config\n allowedEnvConfig.forEach((envConf): void => {\n if (!(envConf in self)) {\n self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];\n }\n });\n\n // unique identifier of self server (or a cluster), used to avoid loops\n // @ts-ignore\n if (!this.server_id) {\n this.server_id = generateRandomHexString(6);\n }\n }\n\n public getConfigPath() {\n return this.configPath;\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // generate a new a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n //\n if (this.configOptions.forceEnhancedLegacySignature) {\n this.secret = generateRandomSecretKey();\n } else {\n this.secret =\n this.security.enhancedLegacySignature === true\n ? generateRandomSecretKey()\n : generateRandomHexString(32);\n // set this to false allow use old token signature and is not recommended\n // only use for migration reasons, major release will remove this property and\n // set it by default\n if (this.security.enhancedLegacySignature === false) {\n warningUtils.emit(Codes.VERWAR005);\n }\n }\n\n debug('generated a new secret key %s', this.secret?.length);\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAYA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAA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,QAAQ,CAAC;EACvD;;EAEA;AACF;AACA;AACA;EACSS,cAAcA,CAACC,MAAe,EAAU;IAAA,IAAAC,YAAA;IAC7C3D,KAAK,CAAC,kBAAkB,CAAC;IACzB,IAAI,OAAO0D,MAAM,KAAK,QAAQ,IAAI9B,eAAC,CAACgC,OAAO,CAACF,MAAM,CAAC,KAAK,KAAK,EAAE;MAC7D,IAAI,CAACA,MAAM,GAAGA,MAAM;MACpB1D,KAAK,CAAC,sBAAsB,CAAC;MAC7B,OAAO0D,MAAM;IACf;IACA;IACA;IACA1D,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,IAAI,IAAI,CAACU,aAAa,CAACC,4BAA4B,EAAE;MACnD,IAAI,CAAC+C,MAAM,GAAG,IAAAG,8BAAuB,EAAC,CAAC;IACzC,CAAC,MAAM;MACL,IAAI,CAACH,MAAM,GACT,IAAI,CAAC/B,QAAQ,CAACmC,uBAAuB,KAAK,IAAI,GAC1C,IAAAD,8BAAuB,EAAC,CAAC,GACzB,IAAAR,8BAAuB,EAAC,EAAE,CAAC;MACjC;MACA;MACA;MACA,IAAI,IAAI,CAAC1B,QAAQ,CAACmC,uBAAuB,KAAK,KAAK,EAAE;QACnDC,kBAAY,CAACC,IAAI,CAACC,mBAAK,CAACC,SAAS,CAAC;MACpC;IACF;IAEAlE,KAAK,CAAC,+BAA+B,GAAA2D,YAAA,GAAE,IAAI,CAACD,MAAM,cAAAC,YAAA,uBAAXA,YAAA,CAAaQ,MAAM,CAAC;IAC3D,OAAO,IAAI,CAACT,MAAM;EACpB;AACF;AAACvD,OAAA,CAAAI,MAAA,GAAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"config.js","names":["_assert","_interopRequireDefault","require","_debug","_lodash","_core","_warningUtils","_utils","_agent","_packageAccess","_security","_serverSettings","_token","_uplinks","obj","__esModule","default","strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","exports","defaultUserRateLimiting","windowMs","max","Config","constructor","config","configOptions","forceEnhancedLegacySignature","_config$flags$searchR","_config$flags","_config$flags$changeP","_config$flags2","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","_config$config_path","config_path","self_path","Error","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","changePassword","user_agent","configProp","getUserAgent","userRateLimit","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getEnhancedLegacySignature","enhancedLegacySignature","getConfigPath","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","_this$security","_this$secret","isEmpty","generateRandomSecretKey","warningUtils","emit","Codes","VERWAR005","length"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR, warningUtils } from '@verdaccio/core';\nimport { Codes } from '@verdaccio/core/build/warning-utils';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n RateLimit,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings from './serverSettings';\nimport { generateRandomSecretKey } from './token';\nimport { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';\n\nconst strategicConfigProps = ['uplinks', 'packages'];\nconst allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];\nconst debug = buildDebug('verdaccio:config');\n\nexport const WEB_TITLE = 'Verdaccio';\n\n// we limit max 1000 request per 15 minutes on user endpoints\nexport const defaultUserRateLimiting = {\n windowMs: 15 * 60 * 1000, // 15 minutes\n max: 1000,\n};\n\n/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string | undefined;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n public configPath: string;\n /**\n * @deprecated use configPath or config.getConfigPath();\n */\n public self_path: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n private configOptions: { forceEnhancedLegacySignature: boolean };\n public constructor(\n config: ConfigYaml & { config_path: string },\n // forceEnhancedLegacySignature is a property that\n // allows switch a new legacy aes signature token signature\n // for older versions do not want to have this new signature model\n // this property must be false\n configOptions = { forceEnhancedLegacySignature: true }\n ) {\n const self = this;\n this.configOptions = configOptions;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n // backport self_path for previous to version 6\n // @ts-expect-error\n config.configPath = config.config_path ?? config.self_path;\n if (!config.configPath) {\n throw new Error('configPath property is required');\n }\n }\n this.configPath = config.configPath;\n this.self_path = this.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n changePassword: config.flags?.changePassword ?? false,\n };\n this.user_agent = config.user_agent;\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n if (typeof this.user_agent === 'undefined') {\n // by default user agent is hidden\n debug('set default user agent');\n this.user_agent = getUserAgent(false);\n }\n\n this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);\n\n // sanity check for strategic config properties\n strategicConfigProps.forEach(function (x): void {\n if (self[x] == null) {\n self[x] = {};\n }\n\n assert(isObject(self[x]), `CONFIG: bad \"${x}\" value (object expected)`);\n });\n\n this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));\n this.packages = normalisePackageAccess(self.packages);\n\n // loading these from ENV if aren't in config\n allowedEnvConfig.forEach((envConf): void => {\n if (!(envConf in self)) {\n self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];\n }\n });\n\n // unique identifier of self server (or a cluster), used to avoid loops\n // @ts-ignore\n if (!this.server_id) {\n this.server_id = generateRandomHexString(6);\n }\n }\n\n public getEnhancedLegacySignature() {\n if (typeof this?.security.enhancedLegacySignature !== 'undefined') {\n if (this.security.enhancedLegacySignature === true) {\n return true;\n }\n return false;\n }\n return this.configOptions.forceEnhancedLegacySignature;\n }\n\n public getConfigPath() {\n return this.configPath;\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // generate a new a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generating a new secret key');\n\n if (this.getEnhancedLegacySignature()) {\n debug('key generated with \"enhanced\" legacy signature user config');\n this.secret = generateRandomSecretKey();\n } else {\n debug('key generated with legacy signature user config');\n this.secret = generateRandomHexString(32);\n }\n // set this to false allow use old token signature and is not recommended\n // only use for migration reasons, major release will remove this property and\n // set it by default\n if (this.security?.enhancedLegacySignature === false) {\n warningUtils.emit(Codes.VERWAR005);\n }\n\n debug('generated a new secret key length %s', this.secret?.length);\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAYA,I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ACC,IAAI,CAACC,mBAAK,CAACC,SAAS,CAAC;IACpC;IAEApE,KAAK,CAAC,sCAAsC,GAAA8D,YAAA,GAAE,IAAI,CAACF,MAAM,cAAAE,YAAA,uBAAXA,YAAA,CAAaO,MAAM,CAAC;IAClE,OAAO,IAAI,CAACT,MAAM;EACpB;AACF;AAACzD,OAAA,CAAAI,MAAA,GAAAA,MAAA"}
|
package/build/package-access.js
CHANGED
|
@@ -11,7 +11,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
11
11
|
var _core = require("@verdaccio/core");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
// @deprecated use @verdaccio/core:authUtils
|
|
14
|
-
const ROLES = {
|
|
14
|
+
const ROLES = exports.ROLES = {
|
|
15
15
|
$ALL: '$all',
|
|
16
16
|
ALL: 'all',
|
|
17
17
|
$AUTH: '$authenticated',
|
|
@@ -22,15 +22,13 @@ const ROLES = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// @deprecated use @verdaccio/core:authUtils
|
|
25
|
-
exports.
|
|
26
|
-
const PACKAGE_ACCESS = {
|
|
25
|
+
const PACKAGE_ACCESS = exports.PACKAGE_ACCESS = {
|
|
27
26
|
SCOPE: '@*/*',
|
|
28
27
|
ALL: '**'
|
|
29
28
|
};
|
|
30
|
-
exports.PACKAGE_ACCESS = PACKAGE_ACCESS;
|
|
31
29
|
function normalizeUserList(groupsList) {
|
|
32
30
|
const result = [];
|
|
33
|
-
if (_lodash.default.isNil(groupsList)) {
|
|
31
|
+
if (_lodash.default.isNil(groupsList) || _lodash.default.isEmpty(groupsList)) {
|
|
34
32
|
return result;
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-access.js","names":["_assert","_interopRequireDefault","require","_lodash","_core","obj","__esModule","default","ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","
|
|
1
|
+
{"version":3,"file":"package-access.js","names":["_assert","_interopRequireDefault","require","_lodash","_core","obj","__esModule","default","ROLES","exports","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isEmpty","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","assert","isUndefined"],"sources":["../src/package-access.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { errorUtils } from '@verdaccio/core';\nimport { PackageAccess } from '@verdaccio/types';\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\n// @deprecated use @verdaccio/core:authUtils\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\n// @deprecated use @verdaccio/core:authUtils\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList) || _.isEmpty(groupsList)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA6C,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAO7C;AACO,MAAMG,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnBE,IAAI,EAAE,MAAM;EACZC,GAAG,EAAE,KAAK;EACVC,KAAK,EAAE,gBAAgB;EACvBC,UAAU,EAAE,YAAY;EACxBC,cAAc,EAAE,MAAM;EACtBC,eAAe,EAAE,gBAAgB;EACjCC,oBAAoB,EAAE;AACxB,CAAC;;AAED;AACO,MAAMC,cAAc,GAAAR,OAAA,CAAAQ,cAAA,GAAG;EAC5BC,KAAK,EAAE,MAAM;EACbP,GAAG,EAAE;AACP,CAAC;AAEM,SAASQ,iBAAiBA,CAACC,UAAe,EAAO;EACtD,MAAMC,MAAa,GAAG,EAAE;EACxB,IAAIC,eAAC,CAACC,KAAK,CAACH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0CAAyC,CAAC;MAEjFL,cAAc,CAACK,GAAG,CAAC,CAACJ,MAAM,GAAGpB,iBAAiB,CAAC6B,aAAa,CAACT,MAAM,CAAC;MACpED,cAAc,CAACK,GAAG,CAAC,CAACH,OAAO,GAAGrB,iBAAiB,CAAC6B,aAAa,CAACR,OAAO,CAAC;MACtEF,cAAc,CAACK,GAAG,CAAC,CAACD,KAAK,GAAGvB,iBAAiB,CAAC6B,aAAa,CAACN,KAAK,CAAC;MAClE;MACAJ,cAAc,CAACK,GAAG,CAAC,CAACF,SAAS,GAAGnB,eAAC,CAAC8B,WAAW,CAACJ,aAAa,CAACP,SAAS,CAAC,GAClE,KAAK,GACLtB,iBAAiB,CAAC6B,aAAa,CAACP,SAAS,CAAC;IAChD;EACF;EAEA,OAAOH,cAAc;AACvB"}
|
package/build/security.js
CHANGED
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.defaultSecurity = exports.TIME_EXPIRATION_1H = void 0;
|
|
7
7
|
// TODO: get this from core package
|
|
8
|
-
const TIME_EXPIRATION_1H = '1h';
|
|
9
|
-
exports.TIME_EXPIRATION_1H = TIME_EXPIRATION_1H;
|
|
8
|
+
const TIME_EXPIRATION_1H = exports.TIME_EXPIRATION_1H = '1h';
|
|
10
9
|
const defaultWebTokenOptions = {
|
|
11
10
|
sign: {
|
|
12
11
|
// The expiration token for the website is 7 days
|
|
@@ -17,9 +16,8 @@ const defaultWebTokenOptions = {
|
|
|
17
16
|
const defaultApiTokenConf = {
|
|
18
17
|
legacy: true
|
|
19
18
|
};
|
|
20
|
-
const defaultSecurity = {
|
|
19
|
+
const defaultSecurity = exports.defaultSecurity = {
|
|
21
20
|
web: defaultWebTokenOptions,
|
|
22
21
|
api: defaultApiTokenConf
|
|
23
22
|
};
|
|
24
|
-
exports.defaultSecurity = defaultSecurity;
|
|
25
23
|
//# sourceMappingURL=security.js.map
|
package/build/security.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","names":["TIME_EXPIRATION_1H","exports","defaultWebTokenOptions","sign","expiresIn","verify","defaultApiTokenConf","legacy","defaultSecurity","web","api"],"sources":["../src/security.ts"],"sourcesContent":["import { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,kBAAkB,
|
|
1
|
+
{"version":3,"file":"security.js","names":["TIME_EXPIRATION_1H","exports","defaultWebTokenOptions","sign","expiresIn","verify","defaultApiTokenConf","legacy","defaultSecurity","web","api"],"sources":["../src/security.ts"],"sourcesContent":["import { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAI;AAEtC,MAAME,sBAAkC,GAAG;EACzCC,IAAI,EAAE;IACJ;IACAC,SAAS,EAAEJ;EACb,CAAC;EACDK,MAAM,EAAE,CAAC;AACX,CAAC;AAED,MAAMC,mBAAoC,GAAG;EAC3CC,MAAM,EAAE;AACV,CAAC;AAEM,MAAMC,eAAyB,GAAAP,OAAA,CAAAO,eAAA,GAAG;EACvCC,GAAG,EAAEP,sBAAsB;EAC3BQ,GAAG,EAAEJ;AACP,CAAC"}
|
package/build/serverSettings.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = {
|
|
7
|
+
var _default = exports.default = {
|
|
8
8
|
// https://www.npmjs.com/package/express-rate-limit
|
|
9
9
|
// values are intended to be high, please customize based on own needs
|
|
10
10
|
rateLimit: {
|
|
@@ -14,5 +14,4 @@ var _default = {
|
|
|
14
14
|
// deprecated
|
|
15
15
|
keepAliveTimeout: 60
|
|
16
16
|
};
|
|
17
|
-
exports.default = _default;
|
|
18
17
|
//# sourceMappingURL=serverSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSettings.js","names":["rateLimit","windowMs","max","keepAliveTimeout"
|
|
1
|
+
{"version":3,"file":"serverSettings.js","names":["rateLimit","windowMs","max","keepAliveTimeout"],"sources":["../src/serverSettings.ts"],"sourcesContent":["export default {\n // https://www.npmjs.com/package/express-rate-limit\n // values are intended to be high, please customize based on own needs\n rateLimit: {\n windowMs: 1000,\n max: 10000,\n },\n // deprecated\n keepAliveTimeout: 60,\n};\n"],"mappings":";;;;;;iCAAe;EACb;EACA;EACAA,SAAS,EAAE;IACTC,QAAQ,EAAE,IAAI;IACdC,GAAG,EAAE;EACP,CAAC;EACD;EACAC,gBAAgB,EAAE;AACpB,CAAC"}
|
package/build/token.js
CHANGED
|
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.TOKEN_VALID_LENGTH = void 0;
|
|
7
7
|
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
8
8
|
var _crypto = require("crypto");
|
|
9
|
-
const TOKEN_VALID_LENGTH = 32;
|
|
9
|
+
const TOKEN_VALID_LENGTH = exports.TOKEN_VALID_LENGTH = 32;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Secret key must have 32 characters.
|
|
13
13
|
*/
|
|
14
|
-
exports.TOKEN_VALID_LENGTH = TOKEN_VALID_LENGTH;
|
|
15
14
|
function generateRandomSecretKey() {
|
|
16
15
|
return (0, _crypto.randomBytes)(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);
|
|
17
16
|
}
|
package/build/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","names":["_crypto","require","TOKEN_VALID_LENGTH","exports","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAG,EAAE;;AAEpC;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"token.js","names":["_crypto","require","TOKEN_VALID_LENGTH","exports","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,EAAE;;AAEpC;AACA;AACA;AACO,SAASE,uBAAuBA,CAAA,EAAW;EAChD,OAAO,IAAAC,mBAAW,EAACH,kBAAkB,CAAC,CAACI,QAAQ,CAAC,QAAQ,CAAC,CAACC,SAAS,CAAC,CAAC,EAAEL,kBAAkB,CAAC;AAC5F"}
|
package/build/uplinks.js
CHANGED
|
@@ -12,10 +12,8 @@ var _assert = _interopRequireDefault(require("assert"));
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
13
|
var _utils = require("@verdaccio/utils");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
16
|
-
exports.
|
|
17
|
-
const DEFAULT_UPLINK = 'npmjs';
|
|
18
|
-
exports.DEFAULT_UPLINK = DEFAULT_UPLINK;
|
|
15
|
+
const DEFAULT_REGISTRY = exports.DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
16
|
+
const DEFAULT_UPLINK = exports.DEFAULT_UPLINK = 'npmjs';
|
|
19
17
|
const BLACKLIST = {
|
|
20
18
|
all: true,
|
|
21
19
|
anonymous: true,
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uplinks.js","names":["_assert","_interopRequireDefault","require","_lodash","_utils","obj","__esModule","default","DEFAULT_REGISTRY","exports","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","getMatchedPackagesSpec","proxyList","proxy","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = _.clone(uplinks);\n let newUsers = _.clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = _.clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAA0D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnD,MAAMG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"uplinks.js","names":["_assert","_interopRequireDefault","require","_lodash","_utils","obj","__esModule","default","DEFAULT_REGISTRY","exports","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","getMatchedPackagesSpec","proxyList","proxy","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = _.clone(uplinks);\n let newUsers = _.clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = _.clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAA0D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEnD,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,4BAA4B;AACrD,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,OAAO;AAErC,MAAMC,SAAS,GAAG;EAChBC,GAAG,EAAE,IAAI;EACTC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,IAAI;EACXC,IAAI,EAAE;AACR,CAAC;AAEM,SAASC,iBAAiBA,CAC/BC,OAAwB,EACxBC,KAAU,GAAGR,SAAS,EACL;EACjB,MAAMS,UAAU,GAAGC,eAAC,CAACC,KAAK,CAACJ,OAAO,CAAC;EACnC,IAAIK,QAAQ,GAAGF,eAAC,CAACC,KAAK,CAACH,KAAK,CAAC;EAE7B,KAAK,MAAMK,M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SAAS,EAAE;IACb,OAAOA,SAAS,CAACE,IAAI,CAAEC,IAAI,IAAKP,MAAM,KAAKO,IAAI,CAAC;EAClD;EAEA,OAAO,KAAK;AACd;AAEO,SAAShB,gBAAgBA,CAACiB,IAAY,EAAE5B,KAAU,EAAO;EAC9D,IAAAc,eAAM,EACJc,IAAI,KAAK,KAAK,IACZA,IAAI,KAAK,OAAO,IAChBA,IAAI,KAAK,WAAW,IACpBA,IAAI,KAAK,WAAW,IACpBA,IAAI,KAAK,MAAM,EACjB,gCAAgC,GAAGA,IACrC,CAAC;EACD,IAAAd,eAAM,EAAC,CAACc,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,+BAA+B,GAAGD,IAAI,CAAC;EACjE,IAAAd,eAAM,EAACZ,eAAC,CAAC4B,KAAK,CAAC9B,KAAK,CAAC4B,IAAI,CAAC,CAAC,EAAE,iCAAiC,GAAGA,IAAI,CAAC;EACtE5B,KAAK,CAAC4B,IAAI,CAAC,GAAG,IAAI;EAElB,OAAO5B,KAAK;AACd"}
|
package/build/user.js
CHANGED
|
@@ -10,12 +10,11 @@ var _packageAccess = require("./package-access");
|
|
|
10
10
|
/**
|
|
11
11
|
* All logged users will have by default the group $all and $authenticate
|
|
12
12
|
*/
|
|
13
|
-
const defaultLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$AUTH, _packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_AUTH, _packageAccess.ROLES.ALL];
|
|
13
|
+
const defaultLoggedUserRoles = exports.defaultLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$AUTH, _packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_AUTH, _packageAccess.ROLES.ALL];
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
exports.
|
|
18
|
-
const defaultNonLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$ANONYMOUS,
|
|
17
|
+
const defaultNonLoggedUserRoles = exports.defaultNonLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$ANONYMOUS,
|
|
19
18
|
// groups without '$' are going to be deprecated eventually
|
|
20
19
|
_packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_ANONYMOUS];
|
|
21
20
|
|
|
@@ -23,7 +22,6 @@ _packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_ANONYMOUS];
|
|
|
23
22
|
* Create a RemoteUser object
|
|
24
23
|
* @return {Object} { name: xx, pluginGroups: [], real_groups: [] }
|
|
25
24
|
*/
|
|
26
|
-
exports.defaultNonLoggedUserRoles = defaultNonLoggedUserRoles;
|
|
27
25
|
function createRemoteUser(name, pluginGroups) {
|
|
28
26
|
const isGroupValid = Array.isArray(pluginGroups);
|
|
29
27
|
const groups = Array.from(new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles])));
|
package/build/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["_packageAccess","require","defaultLoggedUserRoles","ROLES","$ALL","$AUTH","DEPRECATED_ALL","DEPRECATED_AUTH","ALL","
|
|
1
|
+
{"version":3,"file":"user.js","names":["_packageAccess","require","defaultLoggedUserRoles","exports","ROLES","$ALL","$AUTH","DEPRECATED_ALL","DEPRECATED_AUTH","ALL","defaultNonLoggedUserRoles","$ANONYMOUS","DEPRECATED_ANONYMOUS","createRemoteUser","name","pluginGroups","isGroupValid","Array","isArray","groups","from","Set","concat","real_groups","createAnonymousRemoteUser","undefined"],"sources":["../src/user.ts"],"sourcesContent":["import { RemoteUser } from '@verdaccio/types';\n\nimport { ROLES } from './package-access';\n\n/**\n * All logged users will have by default the group $all and $authenticate\n */\nexport const defaultLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$AUTH,\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_AUTH,\n ROLES.ALL,\n];\n/**\n *\n */\nexport const defaultNonLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$ANONYMOUS,\n // groups without '$' are going to be deprecated eventually\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_ANONYMOUS,\n];\n\n/**\n * Create a RemoteUser object\n * @return {Object} { name: xx, pluginGroups: [], real_groups: [] }\n */\nexport function createRemoteUser(name: string, pluginGroups: string[]): RemoteUser {\n const isGroupValid: boolean = Array.isArray(pluginGroups);\n const groups = Array.from(\n new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles]))\n );\n\n return {\n name,\n groups,\n real_groups: pluginGroups,\n };\n}\n\n/**\n * Builds an anonymous remote user in case none is logged in.\n * @return {Object} { name: xx, groups: [], real_groups: [] }\n */\nexport function createAnonymousRemoteUser(): RemoteUser {\n return {\n name: undefined,\n groups: [...defaultNonLoggedUserRoles],\n real_groups: [],\n };\n}\n"],"mappings":";;;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CACpCE,oBAAK,CAACC,IAAI,EACVD,oBAAK,CAACE,KAAK,EACXF,oBAAK,CAACG,cAAc,EACpBH,oBAAK,CAACI,eAAe,EACrBJ,oBAAK,CAACK,GAAG,CACV;AACD;AACA;AACA;AACO,MAAMC,yBAAyB,GAAAP,OAAA,CAAAO,yBAAA,GAAG,CACvCN,oBAAK,CAACC,IAAI,EACVD,oBAAK,CAACO,UAAU;AAChB;AACAP,oBAAK,CAACG,cAAc,EACpBH,oBAAK,CAACQ,oBAAoB,CAC3B;;AAED;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,IAAY,EAAEC,YAAsB,EAAc;EACjF,MAAMC,YAAqB,GAAGC,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC;EACzD,MAAMI,MAAM,GAAGF,KAAK,CAACG,IAAI,CACvB,IAAIC,GAAG,CAAC,CAACL,YAAY,GAAGD,YAAY,GAAG,EAAE,EAAEO,MAAM,CAAC,CAAC,GAAGpB,sBAAsB,CAAC,CAAC,CAChF,CAAC;EAED,OAAO;IACLY,IAAI;IACJK,MAAM;IACNI,WAAW,EAAER;EACf,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASS,yBAAyBA,CAAA,EAAe;EACtD,OAAO;IACLV,IAAI,EAAEW,SAAS;IACfN,MAAM,EAAE,CAAC,GAAGT,yBAAyB,CAAC;IACtCa,WAAW,EAAE;EACf,CAAC;AACH"}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-next-7.7",
|
|
4
4
|
"description": "logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"node": ">=12"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@verdaccio/core": "
|
|
33
|
-
"@verdaccio/utils": "
|
|
32
|
+
"@verdaccio/core": "7.0.0-next-7.7",
|
|
33
|
+
"@verdaccio/utils": "7.0.0-next-7.7",
|
|
34
34
|
"debug": "4.3.4",
|
|
35
35
|
"js-yaml": "4.1.0",
|
|
36
36
|
"lodash": "4.17.21",
|
|
37
|
-
"minimatch": "
|
|
37
|
+
"minimatch": "7.4.6",
|
|
38
38
|
"yup": "0.32.11"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/minimatch": "
|
|
42
|
-
"@types/yup": "0.
|
|
41
|
+
"@types/minimatch": "5.1.2",
|
|
42
|
+
"@types/yup": "0.32.0"
|
|
43
43
|
},
|
|
44
44
|
"funding": {
|
|
45
45
|
"type": "opencollective",
|
package/src/config.ts
CHANGED
|
@@ -63,6 +63,10 @@ class Config implements AppConfig {
|
|
|
63
63
|
private configOptions: { forceEnhancedLegacySignature: boolean };
|
|
64
64
|
public constructor(
|
|
65
65
|
config: ConfigYaml & { config_path: string },
|
|
66
|
+
// forceEnhancedLegacySignature is a property that
|
|
67
|
+
// allows switch a new legacy aes signature token signature
|
|
68
|
+
// for older versions do not want to have this new signature model
|
|
69
|
+
// this property must be false
|
|
66
70
|
configOptions = { forceEnhancedLegacySignature: true }
|
|
67
71
|
) {
|
|
68
72
|
const self = this;
|
|
@@ -131,6 +135,16 @@ class Config implements AppConfig {
|
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
public getEnhancedLegacySignature() {
|
|
139
|
+
if (typeof this?.security.enhancedLegacySignature !== 'undefined') {
|
|
140
|
+
if (this.security.enhancedLegacySignature === true) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return this.configOptions.forceEnhancedLegacySignature;
|
|
146
|
+
}
|
|
147
|
+
|
|
134
148
|
public getConfigPath() {
|
|
135
149
|
return this.configPath;
|
|
136
150
|
}
|
|
@@ -156,24 +170,23 @@ class Config implements AppConfig {
|
|
|
156
170
|
}
|
|
157
171
|
// generate a new a secret key
|
|
158
172
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
159
|
-
debug('
|
|
160
|
-
|
|
161
|
-
if (this.
|
|
173
|
+
debug('generating a new secret key');
|
|
174
|
+
|
|
175
|
+
if (this.getEnhancedLegacySignature()) {
|
|
176
|
+
debug('key generated with "enhanced" legacy signature user config');
|
|
162
177
|
this.secret = generateRandomSecretKey();
|
|
163
178
|
} else {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
warningUtils.emit(Codes.VERWAR005);
|
|
173
|
-
}
|
|
179
|
+
debug('key generated with legacy signature user config');
|
|
180
|
+
this.secret = generateRandomHexString(32);
|
|
181
|
+
}
|
|
182
|
+
// set this to false allow use old token signature and is not recommended
|
|
183
|
+
// only use for migration reasons, major release will remove this property and
|
|
184
|
+
// set it by default
|
|
185
|
+
if (this.security?.enhancedLegacySignature === false) {
|
|
186
|
+
warningUtils.emit(Codes.VERWAR005);
|
|
174
187
|
}
|
|
175
188
|
|
|
176
|
-
debug('generated a new secret key %s', this.secret?.length);
|
|
189
|
+
debug('generated a new secret key length %s', this.secret?.length);
|
|
177
190
|
return this.secret;
|
|
178
191
|
}
|
|
179
192
|
}
|
package/src/package-access.ts
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getUserAgent } from '../src';
|
|
2
|
+
|
|
3
|
+
describe('getUserAgent', () => {
|
|
4
|
+
test('should return custom user agent when customUserAgent is true', () => {
|
|
5
|
+
const customUserAgent = true;
|
|
6
|
+
const version = '1.0.0';
|
|
7
|
+
const name = 'MyAgent';
|
|
8
|
+
|
|
9
|
+
const result = getUserAgent(customUserAgent, version, name);
|
|
10
|
+
|
|
11
|
+
expect(result).toBe('MyAgent/1.0.0');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('should return custom user agent when customUserAgent is a non-empty string', () => {
|
|
15
|
+
const customUserAgent = 'CustomAgent/1.0.0';
|
|
16
|
+
const version = '1.0.0';
|
|
17
|
+
const name = 'MyAgent';
|
|
18
|
+
|
|
19
|
+
const result = getUserAgent(customUserAgent, version, name);
|
|
20
|
+
|
|
21
|
+
expect(result).toBe('CustomAgent/1.0.0');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('should return "hidden" when customUserAgent is false', () => {
|
|
25
|
+
const customUserAgent = false;
|
|
26
|
+
const version = '1.0.0';
|
|
27
|
+
const name = 'MyAgent';
|
|
28
|
+
|
|
29
|
+
const result = getUserAgent(customUserAgent, version, name);
|
|
30
|
+
|
|
31
|
+
expect(result).toBe('hidden');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('should return default user agent when customUserAgent is undefined', () => {
|
|
35
|
+
const version = '1.0.0';
|
|
36
|
+
const name = 'MyAgent';
|
|
37
|
+
|
|
38
|
+
const result = getUserAgent(undefined, version, name);
|
|
39
|
+
|
|
40
|
+
expect(result).toBe('MyAgent/1.0.0');
|
|
41
|
+
});
|
|
42
|
+
});
|
package/test/builder.spec.ts
CHANGED
|
@@ -13,6 +13,7 @@ describe('Config builder', () => {
|
|
|
13
13
|
proxy: 'some',
|
|
14
14
|
})
|
|
15
15
|
.addLogger({ level: 'info', type: 'stdout', format: 'json' })
|
|
16
|
+
.addAuth({ htpasswd: { file: '.htpasswd' } })
|
|
16
17
|
.addStorage('/tmp/verdaccio')
|
|
17
18
|
.addSecurity({ api: { legacy: true } });
|
|
18
19
|
expect(config.getConfig()).toEqual({
|
|
@@ -21,6 +22,11 @@ describe('Config builder', () => {
|
|
|
21
22
|
legacy: true,
|
|
22
23
|
},
|
|
23
24
|
},
|
|
25
|
+
auth: {
|
|
26
|
+
htpasswd: {
|
|
27
|
+
file: '.htpasswd',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
24
30
|
storage: '/tmp/verdaccio',
|
|
25
31
|
packages: {
|
|
26
32
|
'upstream/*': {
|
package/test/config.spec.ts
CHANGED
|
@@ -106,6 +106,20 @@ describe('checkSecretKey', () => {
|
|
|
106
106
|
const config = new Config(parseConfigFile(resolveConf('default')));
|
|
107
107
|
expect(typeof config.checkSecretKey('') === 'string').toBeTruthy();
|
|
108
108
|
});
|
|
109
|
+
|
|
110
|
+
test('with enhanced legacy signature', () => {
|
|
111
|
+
const config = new Config(parseConfigFile(resolveConf('default')));
|
|
112
|
+
config.security.enhancedLegacySignature = true;
|
|
113
|
+
expect(typeof config.checkSecretKey() === 'string').toBeTruthy();
|
|
114
|
+
expect(config.secret.length).toBe(32);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('without enhanced legacy signature', () => {
|
|
118
|
+
const config = new Config(parseConfigFile(resolveConf('default')));
|
|
119
|
+
config.security.enhancedLegacySignature = false;
|
|
120
|
+
expect(typeof config.checkSecretKey() === 'string').toBeTruthy();
|
|
121
|
+
expect(config.secret.length).toBe(64);
|
|
122
|
+
});
|
|
109
123
|
});
|
|
110
124
|
|
|
111
125
|
describe('getMatchedPackagesSpec', () => {
|
|
@@ -159,3 +173,18 @@ describe('VERDACCIO_STORAGE_PATH', () => {
|
|
|
159
173
|
delete process.env.VERDACCIO_STORAGE_PATH;
|
|
160
174
|
});
|
|
161
175
|
});
|
|
176
|
+
|
|
177
|
+
describe('configPath', () => {
|
|
178
|
+
test('should set configPath in config', () => {
|
|
179
|
+
const defaultConfig = parseConfigFile(resolveConf('default'));
|
|
180
|
+
const config = new Config(defaultConfig);
|
|
181
|
+
expect(config.getConfigPath()).toBe(path.join(__dirname, '../src/conf/default.yaml'));
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('should throw an error if configPath is not provided', () => {
|
|
185
|
+
const defaultConfig = parseConfigFile(resolveConf('default'));
|
|
186
|
+
defaultConfig.configPath = '';
|
|
187
|
+
defaultConfig.config_path = '';
|
|
188
|
+
expect(() => new Config(defaultConfig)).toThrow('configPath property is required');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
|
|
3
3
|
import { parseConfigFile } from '../src';
|
|
4
|
-
import { PACKAGE_ACCESS, normalisePackageAccess } from '../src/package-access';
|
|
4
|
+
import { PACKAGE_ACCESS, normalisePackageAccess, normalizeUserList } from '../src/package-access';
|
|
5
5
|
import { parseConfigurationFile } from './utils';
|
|
6
6
|
|
|
7
7
|
describe('Package access utilities', () => {
|
|
@@ -123,4 +123,30 @@ describe('Package access utilities', () => {
|
|
|
123
123
|
expect(_.isArray(all.publish)).toBeTruthy();
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
|
+
describe('normaliseUserList', () => {
|
|
127
|
+
test('should normalize user list', () => {
|
|
128
|
+
const groupsList = 'admin superadmin';
|
|
129
|
+
const result = normalizeUserList(groupsList);
|
|
130
|
+
expect(result).toEqual(['admin', 'superadmin']);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('should normalize empty user list', () => {
|
|
134
|
+
const groupsList = '';
|
|
135
|
+
const result = normalizeUserList(groupsList);
|
|
136
|
+
expect(result).toEqual([]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('should normalize user list array', () => {
|
|
140
|
+
const groupsList = ['admin', 'superadmin'];
|
|
141
|
+
const result = normalizeUserList(groupsList);
|
|
142
|
+
expect(result).toEqual(['admin', 'superadmin']);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('should throw error for invalid user list', () => {
|
|
146
|
+
const groupsList = { group: 'admin' };
|
|
147
|
+
expect(() => {
|
|
148
|
+
normalizeUserList(groupsList);
|
|
149
|
+
}).toThrow('CONFIG: bad package acl (array or string expected): {"group":"admin"}');
|
|
150
|
+
});
|
|
151
|
+
});
|
|
126
152
|
});
|