@verdaccio/api 6.0.0-6-next.59 → 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 +520 -0
- package/LICENSE +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/package.js +0 -1
- package/build/package.js.map +1 -1
- package/build/publish.js +2 -2
- package/build/publish.js.map +1 -1
- package/build/v1/profile.js +0 -1
- package/build/v1/profile.js.map +1 -1
- package/package.json +16 -18
- package/src/index.ts +0 -1
- package/src/publish.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,525 @@
|
|
|
1
1
|
# @verdaccio/api
|
|
2
2
|
|
|
3
|
+
## 7.0.0-next-7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@7.0.0-next-7.7
|
|
8
|
+
- @verdaccio/config@7.0.0-next-7.7
|
|
9
|
+
- @verdaccio/auth@7.0.0-next-7.7
|
|
10
|
+
- @verdaccio/middleware@7.0.0-next-7.7
|
|
11
|
+
- @verdaccio/store@7.0.0-next-7.7
|
|
12
|
+
- @verdaccio/utils@7.0.0-next-7.7
|
|
13
|
+
- @verdaccio/logger@7.0.0-next-7.7
|
|
14
|
+
|
|
15
|
+
## 7.0.0-next.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [e14b064]
|
|
20
|
+
- Updated dependencies [4d96324]
|
|
21
|
+
- @verdaccio/store@7.0.0-next.6
|
|
22
|
+
- @verdaccio/config@7.0.0-next.6
|
|
23
|
+
- @verdaccio/auth@7.0.0-next.6
|
|
24
|
+
- @verdaccio/middleware@7.0.0-next.6
|
|
25
|
+
- @verdaccio/core@7.0.0-next.6
|
|
26
|
+
- @verdaccio/utils@7.0.0-next.6
|
|
27
|
+
- @verdaccio/logger@7.0.0-next.6
|
|
28
|
+
|
|
29
|
+
## 7.0.0-next.5
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- f047cc8: refactor: auth with legacy sign support
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [f047cc8]
|
|
38
|
+
- @verdaccio/middleware@7.0.0-next.5
|
|
39
|
+
- @verdaccio/core@7.0.0-next.5
|
|
40
|
+
- @verdaccio/config@7.0.0-next.5
|
|
41
|
+
- @verdaccio/auth@7.0.0-next.5
|
|
42
|
+
- @verdaccio/store@7.0.0-next.5
|
|
43
|
+
- @verdaccio/logger@7.0.0-next.5
|
|
44
|
+
- @verdaccio/utils@7.0.0-next.5
|
|
45
|
+
|
|
46
|
+
## 7.0.0-next.4
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- @verdaccio/auth@7.0.0-next.4
|
|
51
|
+
- @verdaccio/core@7.0.0-next.4
|
|
52
|
+
- @verdaccio/config@7.0.0-next.4
|
|
53
|
+
- @verdaccio/middleware@7.0.0-next.4
|
|
54
|
+
- @verdaccio/store@7.0.0-next.4
|
|
55
|
+
- @verdaccio/utils@7.0.0-next.4
|
|
56
|
+
- @verdaccio/logger@7.0.0-next.4
|
|
57
|
+
|
|
58
|
+
## 7.0.0-next.3
|
|
59
|
+
|
|
60
|
+
### Major Changes
|
|
61
|
+
|
|
62
|
+
- e7ebccb61: update major dependencies, remove old nodejs support
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [daceb6d87]
|
|
67
|
+
- Updated dependencies [e7ebccb61]
|
|
68
|
+
- @verdaccio/config@7.0.0-next.3
|
|
69
|
+
- @verdaccio/core@7.0.0-next.3
|
|
70
|
+
- @verdaccio/middleware@7.0.0-next.3
|
|
71
|
+
- @verdaccio/utils@7.0.0-next.3
|
|
72
|
+
- @verdaccio/auth@7.0.0-next.3
|
|
73
|
+
- @verdaccio/logger@7.0.0-next.3
|
|
74
|
+
- @verdaccio/store@7.0.0-next.3
|
|
75
|
+
|
|
76
|
+
## 7.0.0-next.2
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- @verdaccio/core@7.0.0-next.2
|
|
81
|
+
- @verdaccio/config@7.0.0-next.2
|
|
82
|
+
- @verdaccio/auth@7.0.0-next.2
|
|
83
|
+
- @verdaccio/middleware@7.0.0-next.2
|
|
84
|
+
- @verdaccio/store@7.0.0-next.2
|
|
85
|
+
- @verdaccio/utils@7.0.0-next.2
|
|
86
|
+
- @verdaccio/logger@7.0.0-next.2
|
|
87
|
+
|
|
88
|
+
## 7.0.0-next.1
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- @verdaccio/core@7.0.0-next.1
|
|
93
|
+
- @verdaccio/config@7.0.0-next.1
|
|
94
|
+
- @verdaccio/auth@7.0.0-next.1
|
|
95
|
+
- @verdaccio/middleware@7.0.0-next.1
|
|
96
|
+
- @verdaccio/store@7.0.0-next.1
|
|
97
|
+
- @verdaccio/utils@7.0.0-next.1
|
|
98
|
+
- @verdaccio/logger@7.0.0-next.1
|
|
99
|
+
|
|
100
|
+
## 7.0.0-next.0
|
|
101
|
+
|
|
102
|
+
### Major Changes
|
|
103
|
+
|
|
104
|
+
- feat!: bump to v7
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies
|
|
109
|
+
- @verdaccio/auth@7.0.0-next.0
|
|
110
|
+
- @verdaccio/config@7.0.0-next.0
|
|
111
|
+
- @verdaccio/core@7.0.0-next.0
|
|
112
|
+
- @verdaccio/logger@7.0.0-next.0
|
|
113
|
+
- @verdaccio/middleware@7.0.0-next.0
|
|
114
|
+
- @verdaccio/store@7.0.0-next.0
|
|
115
|
+
- @verdaccio/utils@7.0.0-next.0
|
|
116
|
+
|
|
117
|
+
## 6.0.0
|
|
118
|
+
|
|
119
|
+
### Major Changes
|
|
120
|
+
|
|
121
|
+
- 292c0a37f: feat!: replace deprecated request dependency by got
|
|
122
|
+
|
|
123
|
+
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.
|
|
124
|
+
|
|
125
|
+
## Notes
|
|
126
|
+
|
|
127
|
+
- Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
|
|
128
|
+
- Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
|
|
129
|
+
- Refactor with promises instead callback wherever is possible
|
|
130
|
+
- ~Document the API~
|
|
131
|
+
- Improve testing, integration tests
|
|
132
|
+
- Bugfix
|
|
133
|
+
- Clean up old validations
|
|
134
|
+
- Improve performance
|
|
135
|
+
|
|
136
|
+
## 💥 Breaking changes
|
|
137
|
+
|
|
138
|
+
- Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
|
|
139
|
+
- 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));`
|
|
140
|
+
- `@verdaccio/streams` stream abort support is legacy is being deprecated removed
|
|
141
|
+
- Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
|
|
142
|
+
|
|
143
|
+
- a828271d6: refactor: download manifest endpoint and integrate fastify
|
|
144
|
+
|
|
145
|
+
Much simpler API for fetching a package
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
const manifest = await storage.getPackageNext({
|
|
149
|
+
name,
|
|
150
|
+
uplinksLook: true,
|
|
151
|
+
req,
|
|
152
|
+
version: queryVersion,
|
|
153
|
+
requestOptions,
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
> not perfect, the `req` still is being passed to the proxy (this has to be refactored at proxy package) and then removed from here, in proxy we pass the request instance to the `request` library.
|
|
158
|
+
|
|
159
|
+
### Details
|
|
160
|
+
|
|
161
|
+
- `async/await` sugar for getPackage()
|
|
162
|
+
- Improve and reuse code between current implementation and new fastify endpoint (add scaffolding for request manifest)
|
|
163
|
+
- Improve performance
|
|
164
|
+
- Add new tests
|
|
165
|
+
|
|
166
|
+
### Breaking changes
|
|
167
|
+
|
|
168
|
+
All storage plugins will stop to work since the storage uses `getPackageNext` method which is Promise based, I won't replace this now because will force me to update all plugins, I'll follow up in another PR. Currently will throw http 500
|
|
169
|
+
|
|
170
|
+
- 459b6fa72: refactor: search v1 endpoint and local-database
|
|
171
|
+
|
|
172
|
+
- refactor search `api v1` endpoint, improve performance
|
|
173
|
+
- remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
|
|
174
|
+
- refactor method storage class
|
|
175
|
+
- create new module `core` to reduce the ammount of modules with utilities
|
|
176
|
+
- use `undici` instead `node-fetch`
|
|
177
|
+
- use `fastify` instead `express` for functional test
|
|
178
|
+
|
|
179
|
+
### Breaking changes
|
|
180
|
+
|
|
181
|
+
- plugin storage API changes
|
|
182
|
+
- remove old search endpoint (return 404)
|
|
183
|
+
- filter local private packages at plugin level
|
|
184
|
+
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
export interface IPluginStorage<T> extends IPlugin {
|
|
189
|
+
add(name: string): Promise<void>;
|
|
190
|
+
remove(name: string): Promise<void>;
|
|
191
|
+
get(): Promise<any>;
|
|
192
|
+
init(): Promise<void>;
|
|
193
|
+
getSecret(): Promise<string>;
|
|
194
|
+
setSecret(secret: string): Promise<any>;
|
|
195
|
+
getPackageStorage(packageInfo: string): IPackageStorage;
|
|
196
|
+
search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;
|
|
197
|
+
saveToken(token: Token): Promise<any>;
|
|
198
|
+
deleteToken(user: string, tokenKey: string): Promise<any>;
|
|
199
|
+
readTokens(filter: TokenFilter): Promise<Token[]>;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- 9fc2e7961: feat(plugins): improve plugin loader
|
|
204
|
+
|
|
205
|
+
### Changes
|
|
206
|
+
|
|
207
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
208
|
+
- Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
|
|
209
|
+
- https://github.com/verdaccio/verdaccio/issues/1394
|
|
210
|
+
- `config.plugins` plugin path validations
|
|
211
|
+
- Updated algorithm for plugin loader.
|
|
212
|
+
- improved documentation (included dev)
|
|
213
|
+
|
|
214
|
+
## Features
|
|
215
|
+
|
|
216
|
+
- Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
|
|
217
|
+
- Custom prefix:
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
// config.yaml
|
|
221
|
+
server:
|
|
222
|
+
pluginPrefix: mycompany
|
|
223
|
+
middleware:
|
|
224
|
+
audit:
|
|
225
|
+
foo: 1
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
|
|
229
|
+
|
|
230
|
+
## Breaking Changes
|
|
231
|
+
|
|
232
|
+
### sinopia plugins
|
|
233
|
+
|
|
234
|
+
- `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
|
|
235
|
+
|
|
236
|
+
### plugin filter
|
|
237
|
+
|
|
238
|
+
- method rename `filter_metadata`->`filterMetadata`
|
|
239
|
+
|
|
240
|
+
### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
|
|
241
|
+
|
|
242
|
+
The plugin receives as first argument `config`, which represents the config of the plugin. Example:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
// config.yaml
|
|
246
|
+
auth:
|
|
247
|
+
plugin:
|
|
248
|
+
foo: 1
|
|
249
|
+
bar: 2
|
|
250
|
+
|
|
251
|
+
export class Plugin<T> {
|
|
252
|
+
public constructor(config: T, options: PluginOptions) {
|
|
253
|
+
console.log(config);
|
|
254
|
+
// {foo:1, bar: 2}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
- 794af76c5: Remove Node 12 support
|
|
260
|
+
|
|
261
|
+
- We need move to the new `undici` and does not support Node.js 12
|
|
262
|
+
|
|
263
|
+
- 10aeb4f13: feat!: experiments config renamed to flags
|
|
264
|
+
|
|
265
|
+
- The `experiments` configuration is renamed to `flags`. The functionality is exactly the same.
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
flags: token: false;
|
|
269
|
+
search: false;
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
- The `self_path` property from the config file is being removed in favor of `config_file` full path.
|
|
273
|
+
- Refactor `config` module, better types and utilities
|
|
274
|
+
|
|
275
|
+
- e367c3f1e: - Replace signature handler for legacy tokens by removing deprecated crypto.createDecipher by createCipheriv
|
|
276
|
+
|
|
277
|
+
- Introduce environment variables for legacy tokens
|
|
278
|
+
|
|
279
|
+
### Code Improvements
|
|
280
|
+
|
|
281
|
+
- Add debug library for improve developer experience
|
|
282
|
+
|
|
283
|
+
### Breaking change
|
|
284
|
+
|
|
285
|
+
- The new signature invalidates all previous tokens generated by Verdaccio 4 or previous versions.
|
|
286
|
+
- The secret key must have 32 characters long.
|
|
287
|
+
|
|
288
|
+
### New environment variables
|
|
289
|
+
|
|
290
|
+
- `VERDACCIO_LEGACY_ALGORITHM`: Allows to define the specific algorithm for the token signature which by default is `aes-256-ctr`
|
|
291
|
+
- `VERDACCIO_LEGACY_ENCRYPTION_KEY`: By default, the token stores in the database, but using this variable allows to get it from memory
|
|
292
|
+
|
|
293
|
+
- 82cb0f2bf: feat!: config.logs throw an error, logging config not longer accept array or logs property
|
|
294
|
+
|
|
295
|
+
### 💥 Breaking change
|
|
296
|
+
|
|
297
|
+
This is valid
|
|
298
|
+
|
|
299
|
+
```yaml
|
|
300
|
+
log: { type: stdout, format: pretty, level: http }
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
This is invalid
|
|
304
|
+
|
|
305
|
+
```yaml
|
|
306
|
+
logs: { type: stdout, format: pretty, level: http }
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
or
|
|
310
|
+
|
|
311
|
+
```yaml
|
|
312
|
+
logs:
|
|
313
|
+
- [{ type: stdout, format: pretty, level: http }]
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Minor Changes
|
|
317
|
+
|
|
318
|
+
- a1986e098: feat: expose middleware utils
|
|
319
|
+
- ef88da3b4: feat: improve support for fs promises older nodejs
|
|
320
|
+
- ae93e039d: fix: expose middleware methods
|
|
321
|
+
- 24b9be020: refactor: improve docker image build with strict dependencies and prod build
|
|
322
|
+
- 631abe1ac: feat: refactor logger
|
|
323
|
+
- b702ea363: abort search request support for proxy
|
|
324
|
+
- 00d1d2a17: chore: env variable for launch fastify
|
|
325
|
+
|
|
326
|
+
- Update fastify to major release `v4.3.0`
|
|
327
|
+
- Update CLI launcher
|
|
328
|
+
|
|
329
|
+
via CLI
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
VERDACCIO_SERVER=fastify verdaccio
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
with docker
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
docker run -it --rm --name verdaccio \
|
|
339
|
+
-e "VERDACCIO_SERVER=8080" -p 8080:8080 \
|
|
340
|
+
-e "VERDACCIO_SERVER=fastify" \
|
|
341
|
+
verdaccio/verdaccio
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
- e54ec4b5d: feat: remove level dependency by lowdb for npm token cli as storage
|
|
345
|
+
|
|
346
|
+
### new npm token database
|
|
347
|
+
|
|
348
|
+
There will be a new database located in your storage named `.token-db.json` which
|
|
349
|
+
will store all references to created tokens, **it does not store tokens**, just
|
|
350
|
+
mask of them and related metadata required to reference them.
|
|
351
|
+
|
|
352
|
+
#### Breaking change
|
|
353
|
+
|
|
354
|
+
If you were relying on `npm token` experiment. This PR will replace the
|
|
355
|
+
used database (level) by a json plain based one (lowbd) which does not
|
|
356
|
+
require Node.js C++ compilation step and has less dependencies. Since was
|
|
357
|
+
a experiment there is no migration step.
|
|
358
|
+
|
|
359
|
+
- b61f762d6: feat: add server rate limit protection to all request
|
|
360
|
+
|
|
361
|
+
To modify custom values, use the server settings property.
|
|
362
|
+
|
|
363
|
+
```markdown
|
|
364
|
+
server:
|
|
365
|
+
|
|
366
|
+
## https://www.npmjs.com/package/express-rate-limit#configuration-options
|
|
367
|
+
|
|
368
|
+
rateLimit:
|
|
369
|
+
windowMs: 1000
|
|
370
|
+
max: 10000
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
The values are intended to be high, if you want to improve security of your server consider
|
|
374
|
+
using different values.
|
|
375
|
+
|
|
376
|
+
- 154b2ecd3: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
|
|
377
|
+
- aa763baec: feat: add typescript project references settings
|
|
378
|
+
|
|
379
|
+
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.
|
|
380
|
+
|
|
381
|
+
It allows to navigate (IDE) trough the packages without need compile the packages.
|
|
382
|
+
|
|
383
|
+
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).
|
|
384
|
+
|
|
385
|
+
- ce013d2fc: refactor: npm star command support reimplemented
|
|
386
|
+
- 62c24b632: feat: add passwordValidationRegex property
|
|
387
|
+
- 5167bb528: feat: ui search support for remote, local and private packages
|
|
388
|
+
|
|
389
|
+
The command `npm search` search globally and return all matches, with this improvement the user interface
|
|
390
|
+
is powered with the same capabilities.
|
|
391
|
+
|
|
392
|
+
The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
|
|
393
|
+
|
|
394
|
+
- 4b29d715b: chore: move improvements from v5 to v6
|
|
395
|
+
|
|
396
|
+
Migrate improvements form v5 to v6:
|
|
397
|
+
|
|
398
|
+
- https://github.com/verdaccio/verdaccio/pull/3158
|
|
399
|
+
- https://github.com/verdaccio/verdaccio/pull/3151
|
|
400
|
+
- https://github.com/verdaccio/verdaccio/pull/2271
|
|
401
|
+
- https://github.com/verdaccio/verdaccio/pull/2787
|
|
402
|
+
- https://github.com/verdaccio/verdaccio/pull/2791
|
|
403
|
+
- https://github.com/verdaccio/verdaccio/pull/2205
|
|
404
|
+
|
|
405
|
+
- b13a3fefd: refactor: improve versions and dist-tag filters
|
|
406
|
+
- 37274e4c8: feat: implement abbreviated manifest
|
|
407
|
+
|
|
408
|
+
Enable abbreviated manifest data by adding the header:
|
|
409
|
+
|
|
410
|
+
```
|
|
411
|
+
curl -H "Accept: application/vnd.npm.install-v1+json" https://registry.npmjs.org/verdaccio
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
It returns a filtered manifest, additionally includes the [time](https://github.com/pnpm/rfcs/pull/2) field by request.
|
|
415
|
+
|
|
416
|
+
Current support for packages managers:
|
|
417
|
+
|
|
418
|
+
- npm: yes
|
|
419
|
+
- pnpm: yes
|
|
420
|
+
- yarn classic: yes
|
|
421
|
+
- yarn modern (+2.x): [no](https://github.com/yarnpkg/berry/pull/3981#issuecomment-1076566096)
|
|
422
|
+
|
|
423
|
+
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format
|
|
424
|
+
|
|
425
|
+
- 45c03819e: refactor: render html middleware
|
|
426
|
+
|
|
427
|
+
### Patch Changes
|
|
428
|
+
|
|
429
|
+
- 43f32687c: fix: abbreviated headers handle quality values
|
|
430
|
+
- 351aeeaa8: fix(deps): @verdaccio/utils should be a prod dep of local-storage
|
|
431
|
+
- a610ef26b: chore: add release step to private regisry on merge changeset pr
|
|
432
|
+
- 34f0f1101: Enable prerelease mode with **changesets**
|
|
433
|
+
- f859d2b1a: fix: official package "-" cannot be synced
|
|
434
|
+
- 168833d85: testing changesets
|
|
435
|
+
- b4cc80017: fix: improve abort request search
|
|
436
|
+
- 68ea21214: ESLint Warnings Fixed
|
|
437
|
+
|
|
438
|
+
Related to issue #1461
|
|
439
|
+
|
|
440
|
+
- max-len: most of the sensible max-len errors are fixed
|
|
441
|
+
- no-unused-vars: most of these types of errors are fixed by deleting not needed declarations
|
|
442
|
+
- @typescript-eslint/no-unused-vars: same as above
|
|
443
|
+
|
|
444
|
+
- b849128de: fix: handle upload scoped tarball
|
|
445
|
+
- Updated dependencies [292c0a37f]
|
|
446
|
+
- Updated dependencies [dc05edfe6]
|
|
447
|
+
- Updated dependencies [a1986e098]
|
|
448
|
+
- Updated dependencies [974cd8c19]
|
|
449
|
+
- Updated dependencies [a828271d6]
|
|
450
|
+
- Updated dependencies [ef88da3b4]
|
|
451
|
+
- Updated dependencies [43f32687c]
|
|
452
|
+
- Updated dependencies [679c19c1b]
|
|
453
|
+
- Updated dependencies [a3a209b5e]
|
|
454
|
+
- Updated dependencies [459b6fa72]
|
|
455
|
+
- Updated dependencies [9fc2e7961]
|
|
456
|
+
- Updated dependencies [9943e2b18]
|
|
457
|
+
- Updated dependencies [ae93e039d]
|
|
458
|
+
- Updated dependencies [24b9be020]
|
|
459
|
+
- Updated dependencies [794af76c5]
|
|
460
|
+
- Updated dependencies [e75c0a3b9]
|
|
461
|
+
- Updated dependencies [351aeeaa8]
|
|
462
|
+
- Updated dependencies [10aeb4f13]
|
|
463
|
+
- Updated dependencies [1d1112805]
|
|
464
|
+
- Updated dependencies [631abe1ac]
|
|
465
|
+
- Updated dependencies [9718e0330]
|
|
466
|
+
- Updated dependencies [7ef599cc4]
|
|
467
|
+
- Updated dependencies [b702ea363]
|
|
468
|
+
- Updated dependencies [1b217fd34]
|
|
469
|
+
- Updated dependencies [e367c3f1e]
|
|
470
|
+
- Updated dependencies [a1da11308]
|
|
471
|
+
- Updated dependencies [d167f92e1]
|
|
472
|
+
- Updated dependencies [d2c65da9c]
|
|
473
|
+
- Updated dependencies [00d1d2a17]
|
|
474
|
+
- Updated dependencies [1810ed0d8]
|
|
475
|
+
- Updated dependencies [a610ef26b]
|
|
476
|
+
- Updated dependencies [ddb6a2239]
|
|
477
|
+
- Updated dependencies [648575aa4]
|
|
478
|
+
- Updated dependencies [b61f762d6]
|
|
479
|
+
- Updated dependencies [4fc21146a]
|
|
480
|
+
- Updated dependencies [d43894e8f]
|
|
481
|
+
- Updated dependencies [154b2ecd3]
|
|
482
|
+
- Updated dependencies [061bfcc8d]
|
|
483
|
+
- Updated dependencies [aa763baec]
|
|
484
|
+
- Updated dependencies [378e907d5]
|
|
485
|
+
- Updated dependencies [16e38df8a]
|
|
486
|
+
- Updated dependencies [34f0f1101]
|
|
487
|
+
- Updated dependencies [82cb0f2bf]
|
|
488
|
+
- Updated dependencies [dc571aabd]
|
|
489
|
+
- Updated dependencies [5ddfa5264]
|
|
490
|
+
- Updated dependencies [b78f35257]
|
|
491
|
+
- Updated dependencies [ce013d2fc]
|
|
492
|
+
- Updated dependencies [f859d2b1a]
|
|
493
|
+
- Updated dependencies [2c594910d]
|
|
494
|
+
- Updated dependencies [6c1eb021b]
|
|
495
|
+
- Updated dependencies [62c24b632]
|
|
496
|
+
- Updated dependencies [0a6412ca9]
|
|
497
|
+
- Updated dependencies [0a6412ca9]
|
|
498
|
+
- Updated dependencies [d08fe29d9]
|
|
499
|
+
- Updated dependencies [5167bb528]
|
|
500
|
+
- Updated dependencies [f86c31ed0]
|
|
501
|
+
- Updated dependencies [65f88b826]
|
|
502
|
+
- Updated dependencies [aeff267d9]
|
|
503
|
+
- Updated dependencies [20c9e43ed]
|
|
504
|
+
- Updated dependencies [b3e8438f6]
|
|
505
|
+
- Updated dependencies [c9d1af0e5]
|
|
506
|
+
- Updated dependencies [730b5d8cc]
|
|
507
|
+
- Updated dependencies [4b29d715b]
|
|
508
|
+
- Updated dependencies [b13a3fefd]
|
|
509
|
+
- Updated dependencies [68ea21214]
|
|
510
|
+
- Updated dependencies [37274e4c8]
|
|
511
|
+
- Updated dependencies [fa274ee44]
|
|
512
|
+
- Updated dependencies [8f43bf17d]
|
|
513
|
+
- Updated dependencies [45c03819e]
|
|
514
|
+
- Updated dependencies [b849128de]
|
|
515
|
+
- @verdaccio/auth@6.0.0
|
|
516
|
+
- @verdaccio/config@6.0.0
|
|
517
|
+
- @verdaccio/core@6.0.0
|
|
518
|
+
- @verdaccio/logger@6.0.0
|
|
519
|
+
- @verdaccio/middleware@6.0.0
|
|
520
|
+
- @verdaccio/store@6.0.0
|
|
521
|
+
- @verdaccio/utils@6.0.0
|
|
522
|
+
|
|
3
523
|
## 6.0.0-6-next.59
|
|
4
524
|
|
|
5
525
|
### Patch Changes
|
package/LICENSE
CHANGED
package/build/index.js
CHANGED
|
@@ -41,7 +41,6 @@ function _default(config, auth, storage) {
|
|
|
41
41
|
strict: false,
|
|
42
42
|
limit: config.max_body_size || '10mb'
|
|
43
43
|
}));
|
|
44
|
-
// @ts-ignore
|
|
45
44
|
app.use((0, _middleware.antiLoop)(config));
|
|
46
45
|
// encode / in a scoped package name to be matched as a single parameter in routes
|
|
47
46
|
app.use(_middleware.encodeScopePackage);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_express","_interopRequireDefault","require","_middleware","_distTags","_package","_ping","_publish","_search","_stars","_user","_profile","_search2","_token","_whoami","obj","__esModule","default","_default","config","auth","storage","app","express","Router","param","validatePackage","validateName","match","use","apiJWTmiddleware","json","strict","limit","max_body_size","antiLoop","encodeScopePackage","whoami","profile","search","user","distTags","publish","ping","stars","v1Search","token","pkg"],"sources":["../src/index.ts"],"sourcesContent":["import express, { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n antiLoop,\n encodeScopePackage,\n match,\n validateName,\n validatePackage,\n} from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport distTags from './dist-tags';\nimport pkg from './package';\nimport ping from './ping';\nimport publish from './publish';\nimport search from './search';\nimport stars from './stars';\nimport user from './user';\nimport profile from './v1/profile';\nimport v1Search from './v1/search';\nimport token from './v1/token';\nimport whoami from './whoami';\n\nexport default function (config: Config, auth: Auth, storage: Storage): Router {\n /* eslint new-cap:off */\n const app = express.Router();\n /* eslint new-cap:off */\n\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble\n app.param('package', validatePackage);\n app.param('filename', validateName);\n app.param('tag', validateName);\n app.param('version', validateName);\n app.param('revision', validateName);\n app.param('token', validateName);\n\n // these can't be safely put into express url for some reason\n // TODO: For some reason? what reason?\n app.param('_rev', match(/^-rev$/));\n app.param('org_couchdb_user', match(/^org\\.couchdb\\.user:/));\n app.use(auth.apiJWTmiddleware());\n app.use(express.json({ strict: false, limit: config.max_body_size || '10mb' }));\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["_express","_interopRequireDefault","require","_middleware","_distTags","_package","_ping","_publish","_search","_stars","_user","_profile","_search2","_token","_whoami","obj","__esModule","default","_default","config","auth","storage","app","express","Router","param","validatePackage","validateName","match","use","apiJWTmiddleware","json","strict","limit","max_body_size","antiLoop","encodeScopePackage","whoami","profile","search","user","distTags","publish","ping","stars","v1Search","token","pkg"],"sources":["../src/index.ts"],"sourcesContent":["import express, { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n antiLoop,\n encodeScopePackage,\n match,\n validateName,\n validatePackage,\n} from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport distTags from './dist-tags';\nimport pkg from './package';\nimport ping from './ping';\nimport publish from './publish';\nimport search from './search';\nimport stars from './stars';\nimport user from './user';\nimport profile from './v1/profile';\nimport v1Search from './v1/search';\nimport token from './v1/token';\nimport whoami from './whoami';\n\nexport default function (config: Config, auth: Auth, storage: Storage): Router {\n /* eslint new-cap:off */\n const app = express.Router();\n /* eslint new-cap:off */\n\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble\n app.param('package', validatePackage);\n app.param('filename', validateName);\n app.param('tag', validateName);\n app.param('version', validateName);\n app.param('revision', validateName);\n app.param('token', validateName);\n\n // these can't be safely put into express url for some reason\n // TODO: For some reason? what reason?\n app.param('_rev', match(/^-rev$/));\n app.param('org_couchdb_user', match(/^org\\.couchdb\\.user:/));\n app.use(auth.apiJWTmiddleware());\n app.use(express.json({ strict: false, limit: config.max_body_size || '10mb' }));\n app.use(antiLoop(config));\n // encode / in a scoped package name to be matched as a single parameter in routes\n app.use(encodeScopePackage);\n // for \"npm whoami\"\n whoami(app);\n profile(app, auth, config);\n search(app);\n user(app, auth, config);\n distTags(app, auth, storage);\n publish(app, auth, storage);\n ping(app);\n stars(app, storage);\n v1Search(app, auth, storage);\n token(app, auth, storage, config);\n pkg(app, auth, storage);\n return app;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAUA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,MAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,KAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,QAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,QAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,OAAA,GAAAb,sBAAA,CAAAC,OAAA;AAA8B,SAAAD,uBAAAc,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEf,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,IAAAsB,iBAAQ,EAACnB,GAAG,EAAEF,IAAI,EAAEC,OAAO,CAAC;EAC5B,IAAAqB,gBAAO,EAACpB,GAAG,EAAEF,IAAI,EAAEC,OAAO,CAAC;EAC3B,IAAAsB,aAAI,EAACrB,GAAG,CAAC;EACT,IAAAsB,cAAK,EAACtB,GAAG,EAAED,OAAO,CAAC;EACnB,IAAAwB,gBAAQ,EAACvB,GAAG,EAAEF,IAAI,EAAEC,OAAO,CAAC;EAC5B,IAAAyB,cAAK,EAACxB,GAAG,EAAEF,IAAI,EAAEC,OAAO,EAAEF,MAAM,CAAC;EACjC,IAAA4B,gBAAG,EAACzB,GAAG,EAAEF,IAAI,EAAEC,OAAO,CAAC;EACvB,OAAOC,GAAG;AACZ"}
|
package/build/package.js
CHANGED
package/build/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":["_debug","_interopRequireDefault","require","_core","_logger","_middleware","_store","obj","__esModule","default","debug","buildDebug","_default","route","auth","storage","can","allow","beforeAll","a","b","logger","trace","afterAll","get","req","_res","next","name","params","package","version","write","query","abbreviated","stringUtils","getByQualityPriorityValue","Storage","ABBREVIATED_HEADER","requestOptions","protocol","headers","host","remoteAddress","socket","byPassCache","manifest","getPackageByOptions","uplinksLook","setHeader","HEADER_TYPE","CONTENT_TYPE","HEADERS","JSON_INSTALL_CHARSET","JSON","err","res","pkgName","filename","abort","AbortController","stream","getTarballNext","signal","on","size","header","CONTENT_LENGTH","once","locals","report_error","url","OCTET_STREAM","pipe"],"sources":["../src/package.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { HEADERS, HEADER_TYPE, stringUtils } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\nconst debug = buildDebug('verdaccio:api:package');\n\nexport default function (route: Router, auth: Auth, storage: Storage): void {\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n route.get(\n '/:package/:version?',\n can('access'),\n async function (\n req: $RequestExtend,\n _res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('init package by version');\n const name = req.params.package;\n let version = req.params.version;\n const write = req.query.write === 'true';\n const abbreviated =\n stringUtils.getByQualityPriorityValue(req.get('Accept')) === Storage.ABBREVIATED_HEADER;\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 byPassCache: write,\n };\n\n try {\n const manifest = await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n abbreviated,\n version,\n requestOptions,\n });\n if (abbreviated) {\n _res.setHeader(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_INSTALL_CHARSET);\n } else {\n _res.setHeader(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON);\n }\n\n next(manifest);\n } catch (err) {\n next(err);\n }\n }\n );\n\n route.get(\n '/:package/-/:filename',\n can('access'),\n async function (req: $RequestExtend, res: $ResponseExtend, next): Promise<void> {\n const { package: pkgName, filename } = req.params;\n const abort = new AbortController();\n try {\n const stream = (await storage.getTarballNext(pkgName, filename, {\n signal: abort.signal,\n // TODO: review why this param\n // enableRemote: true,\n })) as any;\n\n stream.on('content-length', (size) => {\n res.header(HEADER_TYPE.CONTENT_LENGTH, size);\n });\n\n stream.once('error', (err) => {\n res.locals.report_error(err);\n next(err);\n });\n\n req.on('abort', () => {\n debug('request aborted for %o', req.url);\n abort.abort();\n });\n\n res.header(HEADERS.CONTENT_TYPE, HEADERS.OCTET_STREAM);\n stream.pipe(res);\n } catch (err: any) {\n // console.log('catch API error request', err);\n res.locals.report_error(err);\n next(err);\n }\n }\n );\n}\n"],"mappings":";;;;;;AAAA,IA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AACgB,OAAc;MAC3B;MACAC,IAAI,EAAEjB,GAAG,CAACiB,IAAI;MACdC,aAAa,EAAElB,GAAG,CAACmB,MAAM,CAACD,aAAa;MACvCE,WAAW,EAAEb;IACf,CAAC;IAED,IAAI;MACF,MAAMc,QAAQ,GAAG,MAAM/B,OAAO,CAACgC,mBAAmB,CAAC;QACjDnB,IAAI;QACJoB,WAAW,EAAE,IAAI;QACjBd,WAAW;QACXH,OAAO;QACPQ;MACF,CAAC,CAAC;MACF,IAAIL,WAAW,EAAE;QACfR,IAAI,CAACuB,SAAS,CAACC,iBAAW,CAACC,YAAY,EAAEC,aAAO,CAACC,oBAAoB,CAAC;MACxE,CAAC,MAAM;QACL3B,IAAI,CAACuB,SAAS,CAACC,iBAAW,CAACC,YAAY,EAAEC,aAAO,CAACE,IAAI,CAAC;MACxD;MAEA3B,IAAI,CAACmB,QAAQ,CAAC;IAChB,CAAC,CAAC,OAAOS,GAAG,EAAE;MACZ5B,IAAI,CAAC4B,GAAG,CAAC;IACX;EACF,CACF,CAAC;EAED1C,KAAK,CAACW,GAAG,CACP,uBAAuB,EACvBR,GAAG,CAAC,QAAQ,CAAC,EACb,gBAAgBS,GAAmB,EAAE+B,GAAoB,EAAE7B,IAAI,EAAiB;IAC9E,MAAM;MAAEG,OAAO,EAAE2B,OAAO;MAAEC;IAAS,CAAC,GAAGjC,GAAG,CAACI,MAAM;IACjD,MAAM8B,KAAK,GAAG,IAAIC,eAAe,CAAC,CAAC;IACnC,IAAI;MACF,MAAMC,MAAM,GAAI,MAAM9C,OAAO,CAAC+C,cAAc,CAACL,OAAO,EAAEC,QAAQ,EAAE;QAC9DK,MAAM,EAAEJ,KAAK,CAACI;QACd;QACA;MACF,CAAC,CAAS
|
|
1
|
+
{"version":3,"file":"package.js","names":["_debug","_interopRequireDefault","require","_core","_logger","_middleware","_store","obj","__esModule","default","debug","buildDebug","_default","route","auth","storage","can","allow","beforeAll","a","b","logger","trace","afterAll","get","req","_res","next","name","params","package","version","write","query","abbreviated","stringUtils","getByQualityPriorityValue","Storage","ABBREVIATED_HEADER","requestOptions","protocol","headers","host","remoteAddress","socket","byPassCache","manifest","getPackageByOptions","uplinksLook","setHeader","HEADER_TYPE","CONTENT_TYPE","HEADERS","JSON_INSTALL_CHARSET","JSON","err","res","pkgName","filename","abort","AbortController","stream","getTarballNext","signal","on","size","header","CONTENT_LENGTH","once","locals","report_error","url","OCTET_STREAM","pipe"],"sources":["../src/package.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { HEADERS, HEADER_TYPE, stringUtils } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { allow } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\nconst debug = buildDebug('verdaccio:api:package');\n\nexport default function (route: Router, auth: Auth, storage: Storage): void {\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n route.get(\n '/:package/:version?',\n can('access'),\n async function (\n req: $RequestExtend,\n _res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('init package by version');\n const name = req.params.package;\n let version = req.params.version;\n const write = req.query.write === 'true';\n const abbreviated =\n stringUtils.getByQualityPriorityValue(req.get('Accept')) === Storage.ABBREVIATED_HEADER;\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 byPassCache: write,\n };\n\n try {\n const manifest = await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n abbreviated,\n version,\n requestOptions,\n });\n if (abbreviated) {\n _res.setHeader(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_INSTALL_CHARSET);\n } else {\n _res.setHeader(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON);\n }\n\n next(manifest);\n } catch (err) {\n next(err);\n }\n }\n );\n\n route.get(\n '/:package/-/:filename',\n can('access'),\n async function (req: $RequestExtend, res: $ResponseExtend, next): Promise<void> {\n const { package: pkgName, filename } = req.params;\n const abort = new AbortController();\n try {\n const stream = (await storage.getTarballNext(pkgName, filename, {\n signal: abort.signal,\n // TODO: review why this param\n // enableRemote: true,\n })) as any;\n\n stream.on('content-length', (size) => {\n res.header(HEADER_TYPE.CONTENT_LENGTH, size);\n });\n\n stream.once('error', (err) => {\n res.locals.report_error(err);\n next(err);\n });\n\n req.on('abort', () => {\n debug('request aborted for %o', req.url);\n abort.abort();\n });\n\n res.header(HEADERS.CONTENT_TYPE, HEADERS.OCTET_STREAM);\n stream.pipe(res);\n } catch (err: any) {\n // console.log('catch API error request', err);\n res.locals.report_error(err);\n next(err);\n }\n }\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAI3C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,uBAAuB,CAAC;AAElC,SAAAC,SAAUC,KAAa,EAAEC,IAAU,EAAEC,OAAgB,EAAQ;EAC1E,MAAMC,GAAG,GAAG,IAAAC,iBAAK,EAACH,IAAI,EAAE;IACtBI,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;EACFP,KAAK,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
requestOptions: {
|
|
177
177
|
host: req.hostname,
|
|
178
178
|
protocol: req.protocol,
|
|
179
|
-
// @ts-ignore
|
|
180
179
|
headers: req.headers,
|
|
181
180
|
username
|
|
182
|
-
}
|
|
181
|
+
},
|
|
182
|
+
uplinksLook: false
|
|
183
183
|
});
|
|
184
184
|
res.status(_core.HTTP_STATUS.CREATED);
|
|
185
185
|
return next({
|
package/build/publish.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","names":["_debug","_interopRequireDefault","require","_mime","_core","_logger","_middleware","obj","__esModule","default","debug","buildDebug","publish","router","auth","storage","can","allow","beforeAll","a","b","logger","trace","afterAll","put","media","mime","getType","expectJson","publishPackage","delete","req","res","next","packageName","params","package","rev","revision","removePackage","status","HTTP_STATUS","CREATED","ok","API_MESSAGE","PKG_REMOVED","err","filename","removeTarball","TARBALL_REMOVED","_req$remote_user","ac","AbortController","metadata","body","username","remote_user","name","message","updateManifest","signal","requestOptions","host","hostname","protocol","headers","success"],"sources":["../src/publish.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport mime from 'mime';\n\nimport { Auth } from '@verdaccio/auth';\nimport { API_MESSAGE, HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { allow, expectJson, media } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\n// import star from './star';\n\nconst debug = buildDebug('verdaccio:api:publish');\n\n/**\n * Publish a package / update package / un/start a package\n *\n * There are multiples scenarios here to be considered:\n *\n * 1. Publish scenario\n *\n * Publish a package consist of at least 1 step (PUT) with a metadata payload.\n * When a package is published, an _attachment property is present that contains the data\n * of the tarball.\n *\n * Example flow of publish.\n *\n * npm http fetch PUT 201 http://localhost:4873/@scope%2ftest1 9627ms\n npm info lifecycle @scope/test1@1.0.1~publish: @scope/test1@1.0.1\n npm info lifecycle @scope/test1@1.0.1~postpublish: @scope/test1@1.0.1\n + @scope/test1@1.0.1\n npm verb exit [ 0, true ]\n *\n *\n * 2. Unpublish scenario\n *\n * Unpublish consist in 3 steps.\n * 1. Try to fetch metadata -> if it fails, return 404\n * 2. Compute metadata locally (client side) and send a mutate payload excluding the version to\n * be unpublished\n * eg: if metadata reflects 1.0.1, 1.0.2 and 1.0.3, the computed metadata won't include 1.0.3.\n * 3. Once the second step has been successfully finished, delete the tarball.\n *\n * All these steps are consecutive and required, there is no transacions here, if step 3 fails,\n * metadata might get corrupted.\n *\n * Note the unpublish call will suffix in the url a /-rev/14-5d500cfce92f90fd revision number,\n * this not\n * used internally.\n *\n *\n * Example flow of unpublish.\n *\n * There are two possible flows:\n *\n * - Remove all packages (entirely)\n * eg: npm unpublish package-name@* --force\n * eg: npm unpublish package-name --force\n *\n * npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1680ms\n * npm http fetch DELETE 201 http://localhost:4873/custom-name/-/test1-1.0.3.tgz/-rev/16-e11c8db282b2d992 19ms\n *\n * - Remove a specific version\n * eg: npm unpublish package-name@1.0.0 --force\n *\n * Get fresh manifest\n * npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1680ms\n * Update manifest without the version to be unpublished\n * npm http fetch PUT 201 http://localhost:4873/custom-name/-rev/14-5d500cfce92f90fd 956606ms\n * Get fresh manifest (revision should be different)\n * npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1601ms\n * Remove the tarball\n * npm http fetch DELETE 201 http://localhost:4873/custom-name/-/test1-1.0.3.tgz/-rev/16-e11c8db282b2d992 19ms\n * \n * 3. Star a package\n *\n * Permissions: start a package depends of the publish and unpublish permissions, there is no\n * specific flag for star or un start.\n * The URL for star is similar to the unpublish (change package format)\n *\n * npm has no endpoint for star a package, rather mutate the metadata and acts as, the difference\n * is the users property which is part of the payload and the body only includes\n *\n * {\n\t\t \"_id\": pkgName,\n\t \t\"_rev\": \"3-b0cdaefc9bdb77c8\",\n\t\t \"users\": {\n\t\t [username]: boolean value (true, false)\n\t\t }\n\t}\n *\n */\nexport default function publish(router: Router, auth: Auth, storage: Storage): void {\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n router.put(\n '/:package',\n can('publish'),\n media(mime.getType('json')),\n expectJson,\n publishPackage(storage)\n );\n\n router.put(\n '/:package/-rev/:revision',\n can('unpublish'),\n media(mime.getType('json')),\n expectJson,\n publishPackage(storage)\n );\n\n /**\n * Un-publishing an entire package.\n *\n * This scenario happens when the first call detect there is only one version remaining\n * in the metadata, then the client decides to DELETE the resource\n * npm http fetch GET 304 http://localhost:4873/package-name?write=true 1076ms (from cache)\n * npm http fetch DELETE 201 http://localhost:4873/package-name/-rev/18-d8ebe3020bd4ac9c 22ms\n */\n router.delete(\n '/:package/-rev/:revision',\n can('unpublish'),\n async function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n const packageName = req.params.package;\n const rev = req.params.revision;\n\n logger.debug({ packageName }, `unpublishing @{packageName}`);\n try {\n await storage.removePackage(packageName, rev);\n debug('package %s unpublished', packageName);\n res.status(HTTP_STATUS.CREATED);\n return next({ ok: API_MESSAGE.PKG_REMOVED });\n } catch (err) {\n return next(err);\n }\n }\n );\n\n /*\n Remove a tarball, this happens when npm unpublish a package unique version.\n npm http fetch DELETE 201 http://localhost:4873/package-name/-rev/18-d8ebe3020bd4ac9c 22ms\n */\n router.delete(\n '/:package/-/:filename/-rev/:revision',\n can('unpublish'),\n can('publish'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const packageName = req.params.package;\n const { filename, revision } = req.params;\n\n logger.debug(\n { packageName, filename, revision },\n `removing a tarball for @{packageName}-@{tarballName}-@{revision}`\n );\n try {\n await storage.removeTarball(packageName, filename, revision);\n res.status(HTTP_STATUS.CREATED);\n\n logger.debug(\n { packageName, filename, revision },\n `success remove tarball for @{packageName}-@{tarballName}-@{revision}`\n );\n return next({ ok: API_MESSAGE.TARBALL_REMOVED });\n } catch (err) {\n return next(err);\n }\n }\n );\n}\n\nexport function publishPackage(storage: Storage): any {\n return async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const ac = new AbortController();\n const packageName = req.params.package;\n const { revision } = req.params;\n const metadata = req.body;\n const username = req?.remote_user?.name;\n\n try {\n const message = await storage.updateManifest(metadata, {\n name: packageName,\n revision,\n signal: ac.signal,\n requestOptions: {\n host: req.hostname,\n protocol: req.protocol,\n // @ts-ignore\n headers: req.headers,\n username,\n },\n });\n\n res.status(HTTP_STATUS.CREATED);\n\n return next({\n success: true,\n ok: message,\n });\n } catch (err: any) {\n // TODO: review if we need the abort controller here\n next(err);\n }\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAAiE,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAKjE;;AAEA,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,uBAAuB,CAAC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAW,GAAGH,GAAG,CAACI,MAAM,CAACC,OAAO;IACtC,MAAM;MAAEE;IAAS,CAAC,GAAGP,GAAG,CAACI,MAAM;IAC/B,MAAMkB,QAAQ,GAAGtB,GAAG,CAACuB,IAAI;IACzB,MAAMC,QAAQ,GAAGxB,GAAG,aAAHA,GAAG,wBAAAmB,gBAAA,GAAHnB,GAAG,CAAEyB,WAAW,cAAAN,gBAAA,uBAAhBA,gBAAA,CAAkBO,IAAI;IAEvC,IAAI;MACF,MAAMC,OAAO,GAAG,MAAM3C,OAAO,CAAC4C,cAAc,CAACN,QAAQ,EAAE;QACrDI,IAAI,EAAEvB,WAAW;QACjBI,QAAQ;QACRsB,MAAM,EAAET,EAAE,CAACS,MAAM;QACjBC,cAAc,EAAE;UACdC,IAAI,EAAE/B,GAAG,CAACgC,QAAQ;UAClBC,QAAQ,EAAEjC,GAAG,CAACiC,QAAQ;UACtB;UACAC,OAAO,EAAElC,GAAG,CAACkC,OAAO;UACpBV;QACF;MACF,CAAC,CAAC;MAEFvB,GAAG,CAACQ,MAAM,CAACC,iBAAW,CAACC,OAAO,CAAC;MAE/B,OAAOT,IAAI,CAAC;QACViC,OAAO,EAAE,IAAI;QACbvB,EAAE,EAAEe;MACN,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOZ,GAAQ,EAAE;MACjB;MACAb,IAAI,CAACa,GAAG,CAAC;IACX;EACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"publish.js","names":["_debug","_interopRequireDefault","require","_mime","_core","_logger","_middleware","obj","__esModule","default","debug","buildDebug","publish","router","auth","storage","can","allow","beforeAll","a","b","logger","trace","afterAll","put","media","mime","getType","expectJson","publishPackage","delete","req","res","next","packageName","params","package","rev","revision","removePackage","status","HTTP_STATUS","CREATED","ok","API_MESSAGE","PKG_REMOVED","err","filename","removeTarball","TARBALL_REMOVED","_req$remote_user","ac","AbortController","metadata","body","username","remote_user","name","message","updateManifest","signal","requestOptions","host","hostname","protocol","headers","uplinksLook","success"],"sources":["../src/publish.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport mime from 'mime';\n\nimport { Auth } from '@verdaccio/auth';\nimport { API_MESSAGE, HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { allow, expectJson, media } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\n\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';\n\n// import star from './star';\n\nconst debug = buildDebug('verdaccio:api:publish');\n\n/**\n * Publish a package / update package / un/start a package\n *\n * There are multiples scenarios here to be considered:\n *\n * 1. Publish scenario\n *\n * Publish a package consist of at least 1 step (PUT) with a metadata payload.\n * When a package is published, an _attachment property is present that contains the data\n * of the tarball.\n *\n * Example flow of publish.\n *\n * npm http fetch PUT 201 http://localhost:4873/@scope%2ftest1 9627ms\n npm info lifecycle @scope/test1@1.0.1~publish: @scope/test1@1.0.1\n npm info lifecycle @scope/test1@1.0.1~postpublish: @scope/test1@1.0.1\n + @scope/test1@1.0.1\n npm verb exit [ 0, true ]\n *\n *\n * 2. Unpublish scenario\n *\n * Unpublish consist in 3 steps.\n * 1. Try to fetch metadata -> if it fails, return 404\n * 2. Compute metadata locally (client side) and send a mutate payload excluding the version to\n * be unpublished\n * eg: if metadata reflects 1.0.1, 1.0.2 and 1.0.3, the computed metadata won't include 1.0.3.\n * 3. Once the second step has been successfully finished, delete the tarball.\n *\n * All these steps are consecutive and required, there is no transacions here, if step 3 fails,\n * metadata might get corrupted.\n *\n * Note the unpublish call will suffix in the url a /-rev/14-5d500cfce92f90fd revision number,\n * this not\n * used internally.\n *\n *\n * Example flow of unpublish.\n *\n * There are two possible flows:\n *\n * - Remove all packages (entirely)\n * eg: npm unpublish package-name@* --force\n * eg: npm unpublish package-name --force\n *\n * npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1680ms\n * npm http fetch DELETE 201 http://localhost:4873/custom-name/-/test1-1.0.3.tgz/-rev/16-e11c8db282b2d992 19ms\n *\n * - Remove a specific version\n * eg: npm unpublish package-name@1.0.0 --force\n *\n * Get fresh manifest\n * npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1680ms\n * Update manifest without the version to be unpublished\n * npm http fetch PUT 201 http://localhost:4873/custom-name/-rev/14-5d500cfce92f90fd 956606ms\n * Get fresh manifest (revision should be different)\n * npm http fetch GET 200 http://localhost:4873/custom-name?write=true 1601ms\n * Remove the tarball\n * npm http fetch DELETE 201 http://localhost:4873/custom-name/-/test1-1.0.3.tgz/-rev/16-e11c8db282b2d992 19ms\n * \n * 3. Star a package\n *\n * Permissions: start a package depends of the publish and unpublish permissions, there is no\n * specific flag for star or un start.\n * The URL for star is similar to the unpublish (change package format)\n *\n * npm has no endpoint for star a package, rather mutate the metadata and acts as, the difference\n * is the users property which is part of the payload and the body only includes\n *\n * {\n\t\t \"_id\": pkgName,\n\t \t\"_rev\": \"3-b0cdaefc9bdb77c8\",\n\t\t \"users\": {\n\t\t [username]: boolean value (true, false)\n\t\t }\n\t}\n *\n */\nexport default function publish(router: Router, auth: Auth, storage: Storage): void {\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n router.put(\n '/:package',\n can('publish'),\n media(mime.getType('json')),\n expectJson,\n publishPackage(storage)\n );\n\n router.put(\n '/:package/-rev/:revision',\n can('unpublish'),\n media(mime.getType('json')),\n expectJson,\n publishPackage(storage)\n );\n\n /**\n * Un-publishing an entire package.\n *\n * This scenario happens when the first call detect there is only one version remaining\n * in the metadata, then the client decides to DELETE the resource\n * npm http fetch GET 304 http://localhost:4873/package-name?write=true 1076ms (from cache)\n * npm http fetch DELETE 201 http://localhost:4873/package-name/-rev/18-d8ebe3020bd4ac9c 22ms\n */\n router.delete(\n '/:package/-rev/:revision',\n can('unpublish'),\n async function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {\n const packageName = req.params.package;\n const rev = req.params.revision;\n\n logger.debug({ packageName }, `unpublishing @{packageName}`);\n try {\n await storage.removePackage(packageName, rev);\n debug('package %s unpublished', packageName);\n res.status(HTTP_STATUS.CREATED);\n return next({ ok: API_MESSAGE.PKG_REMOVED });\n } catch (err) {\n return next(err);\n }\n }\n );\n\n /*\n Remove a tarball, this happens when npm unpublish a package unique version.\n npm http fetch DELETE 201 http://localhost:4873/package-name/-rev/18-d8ebe3020bd4ac9c 22ms\n */\n router.delete(\n '/:package/-/:filename/-rev/:revision',\n can('unpublish'),\n can('publish'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const packageName = req.params.package;\n const { filename, revision } = req.params;\n\n logger.debug(\n { packageName, filename, revision },\n `removing a tarball for @{packageName}-@{tarballName}-@{revision}`\n );\n try {\n await storage.removeTarball(packageName, filename, revision);\n res.status(HTTP_STATUS.CREATED);\n\n logger.debug(\n { packageName, filename, revision },\n `success remove tarball for @{packageName}-@{tarballName}-@{revision}`\n );\n return next({ ok: API_MESSAGE.TARBALL_REMOVED });\n } catch (err) {\n return next(err);\n }\n }\n );\n}\n\nexport function publishPackage(storage: Storage): any {\n return async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const ac = new AbortController();\n const packageName = req.params.package;\n const { revision } = req.params;\n const metadata = req.body;\n const username = req?.remote_user?.name;\n\n try {\n const message = await storage.updateManifest(metadata, {\n name: packageName,\n revision,\n signal: ac.signal,\n requestOptions: {\n host: req.hostname,\n protocol: req.protocol,\n headers: req.headers as { [key: string]: string },\n username,\n },\n uplinksLook: false,\n });\n\n res.status(HTTP_STATUS.CREATED);\n\n return next({\n success: true,\n ok: message,\n });\n } catch (err: any) {\n // TODO: review if we need the abort controller here\n next(err);\n }\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,KAAA,G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W,WAAW,EAAE;MACf,CAAC,CAAC;MAEFlC,GAAG,CAACQ,MAAM,CAACC,iBAAW,CAACC,OAAO,CAAC;MAE/B,OAAOT,IAAI,CAAC;QACVkC,OAAO,EAAE,IAAI;QACbxB,EAAE,EAAEe;MACN,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOZ,GAAQ,EAAE;MACjB;MACAb,IAAI,CAACa,GAAG,CAAC;IACX;EACF,CAAC;AACH"}
|
package/build/v1/profile.js
CHANGED
|
@@ -51,7 +51,6 @@ function _default(route, auth, config) {
|
|
|
51
51
|
return next(_core.errorUtils.getCode(_core.HTTP_STATUS.UNAUTHORIZED, _core.API_ERROR.PASSWORD_SHORT));
|
|
52
52
|
/* eslint new-cap:off */
|
|
53
53
|
}
|
|
54
|
-
|
|
55
54
|
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
|
56
55
|
if (_lodash.default.isNull(err) === false) {
|
|
57
56
|
return next(_core.errorUtils.getCode(err.status, err.message) || _core.errorUtils.getConflict(err.message));
|
package/build/v1/profile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","names":["_lodash","_interopRequireDefault","require","_core","_middleware","obj","__esModule","default","_default","route","auth","config","buildProfile","name","tfa","email","email_verified","created","updated","cidr_whitelist","fullname","get","rateLimit","userRateLimit","req","res","next","_","isNil","remote_user","status","HTTP_STATUS","UNAUTHORIZED","message","API_ERROR","MUST_BE_LOGGED","post","password","body","_config$serverSetting","validatioUtils","validatePassword","new","serverSettings","passwordValidationRegex","errorUtils","getCode","PASSWORD_SHORT","changePassword","old","err","isUpdated","isNull","getConflict","getInternalError","INTERNAL_SERVER_ERROR","SERVICE_UNAVAILABLE","SUPPORT_ERRORS","TFA_DISABLED","INTERNAL_ERROR","APP_ERROR","PROFILE_ERROR"],"sources":["../../src/v1/profile.ts"],"sourcesContent":["import { Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HTTP_STATUS,\n SUPPORT_ERRORS,\n errorUtils,\n validatioUtils,\n} from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport { Config } from '@verdaccio/types';\n\nimport { $NextFunctionVer, $RequestExtend } from '../../types/custom';\n\nexport interface Profile {\n tfa: boolean;\n name: string;\n email: string;\n email_verified: boolean;\n created: string;\n updated: string;\n cidr_whitelist: string[] | null;\n fullname: string;\n}\n\nexport default function (route: Router, auth: Auth, config: Config): void {\n function buildProfile(name: string): Profile {\n return {\n tfa: false,\n name,\n email: '',\n email_verified: false,\n created: '',\n updated: '',\n cidr_whitelist: null,\n fullname: '',\n };\n }\n\n route.get(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name) === false) {\n return next(buildProfile(req.remote_user.name));\n }\n\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n );\n\n route.post(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password, tfa } = req.body;\n const { name } = req.remote_user;\n\n if (_.isNil(password) === false) {\n if (\n validatioUtils.validatePassword(\n password.new,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n /* eslint new-cap:off */\n return next(errorUtils.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.PASSWORD_SHORT));\n /* eslint new-cap:off */\n }\n\n auth.changePassword(\n name,\n password.old,\n password.new,\n (err, isUpdated): $NextFunctionVer => {\n if (_.isNull(err) === false) {\n return next(\n errorUtils.getCode(err.status, err.message) || errorUtils.getConflict(err.message)\n );\n }\n\n if (isUpdated) {\n return next(buildProfile(req.remote_user.name));\n }\n return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n );\n } else if (_.isNil(tfa) === false) {\n return next(\n errorUtils.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPORT_ERRORS.TFA_DISABLED)\n );\n } else {\n return next(errorUtils.getCode(HTTP_STATUS.INTERNAL_ERROR, APP_ERROR.PROFILE_ERROR));\n }\n }\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAQA,IAAAE,WAAA,GAAAF,OAAA;AAAkD,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAgBnC,SAAAG,SAAUC,KAAa,EAAEC,IAAU,EAAEC,MAAc,EAAQ;EACxE,SAASC,YAAYA,CAACC,IAAY,EAAW;IAC3C,OAAO;MACLC,GAAG,EAAE,KAAK;MACVD,IAAI;MACJE,KAAK,EAAE,EAAE;MACTC,cAAc,EAAE,KAAK;MACrBC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE,EAAE;MACXC,cAAc,EAAE,IAAI;MACpBC,QAAQ,EAAE;IACZ,CAAC;EACH;EAEAX,KAAK,CAACY,GAAG,CACP,gBAAgB,EAChB,IAAAC,qBAAS,EAACX,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEY,aAAa,CAAC,EAChC,UAAUC,GAAmB,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IAC1E,IAAIC,eAAC,CAACC,KAAK,CAACJ,GAAG,CAACK,WAAW,CAAChB,IAAI,CAAC,KAAK,KAAK,EAAE;MAC3C,OAAOa,IAAI,CAACd,YAAY,CAACY,GAAG,CAACK,WAAW,CAAChB,IAAI,CAAC,CAAC;IACjD;IAEAY,GAAG,CAACK,MAAM,CAACC,iBAAW,CAACC,YAAY,CAAC;IACpC,OAAON,IAAI,CAAC;MACVO,OAAO,EAAEC,eAAS,CAACC;IACrB,CAAC,CAAC;EACJ,CACF,CAAC;EAED1B,KAAK,CAAC2B,IAAI,CACR,gBAAgB,EAChB,IAAAd,qBAAS,EAACX,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEY,aAAa,CAAC,EAChC,UAAUC,GAAmB,EAAEC,GAAa,EAAEC,IAAsB,EAAQ;IAC1E,IAAIC,eAAC,CAACC,KAAK,CAACJ,GAAG,CAACK,WAAW,CAAChB,IAAI,CAAC,EAAE;MACjCY,GAAG,CAACK,MAAM,CAACC,iBAAW,CAACC,YAAY,CAAC;MACpC,OAAON,IAAI,CAAC;QACVO,OAAO,EAAEC,eAAS,CAACC;MACrB,CAAC,CAAC;IACJ;IAEA,MAAM;MAAEE,QAAQ;MAAEvB;IAAI,CAAC,GAAGU,GAAG,CAACc,IAAI;IAClC,MAAM;MAAEzB;IAAK,CAAC,GAAGW,GAAG,CAACK,WAAW;IAEhC,IAAIF,eAAC,CAACC,KAAK,CAACS,QAAQ,CAAC,KAAK,KAAK,EAAE;MAAA,IAAAE,qBAAA;MAC/B,IACEC,oBAAc,CAACC,gBAAgB,CAC7BJ,QAAQ,CAACK,GAAG,EACZ/B,MAAM,aAANA,MAAM,wBAAA4B,qBAAA,GAAN5B,MAAM,CAAEgC,cAAc,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBK,uBAC1B,CAAC,KAAK,KAAK,EACX;QACA;QACA,OAAOlB,IAAI,CAACmB,gBAAU,CAACC,OAAO,CAACf,iBAAW,CAACC,YAAY,EAAEE,eAAS,CAACa,cAAc,CAAC,CAAC;QACnF;MACF
|
|
1
|
+
{"version":3,"file":"profile.js","names":["_lodash","_interopRequireDefault","require","_core","_middleware","obj","__esModule","default","_default","route","auth","config","buildProfile","name","tfa","email","email_verified","created","updated","cidr_whitelist","fullname","get","rateLimit","userRateLimit","req","res","next","_","isNil","remote_user","status","HTTP_STATUS","UNAUTHORIZED","message","API_ERROR","MUST_BE_LOGGED","post","password","body","_config$serverSetting","validatioUtils","validatePassword","new","serverSettings","passwordValidationRegex","errorUtils","getCode","PASSWORD_SHORT","changePassword","old","err","isUpdated","isNull","getConflict","getInternalError","INTERNAL_SERVER_ERROR","SERVICE_UNAVAILABLE","SUPPORT_ERRORS","TFA_DISABLED","INTERNAL_ERROR","APP_ERROR","PROFILE_ERROR"],"sources":["../../src/v1/profile.ts"],"sourcesContent":["import { Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HTTP_STATUS,\n SUPPORT_ERRORS,\n errorUtils,\n validatioUtils,\n} from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport { Config } from '@verdaccio/types';\n\nimport { $NextFunctionVer, $RequestExtend } from '../../types/custom';\n\nexport interface Profile {\n tfa: boolean;\n name: string;\n email: string;\n email_verified: boolean;\n created: string;\n updated: string;\n cidr_whitelist: string[] | null;\n fullname: string;\n}\n\nexport default function (route: Router, auth: Auth, config: Config): void {\n function buildProfile(name: string): Profile {\n return {\n tfa: false,\n name,\n email: '',\n email_verified: false,\n created: '',\n updated: '',\n cidr_whitelist: null,\n fullname: '',\n };\n }\n\n route.get(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name) === false) {\n return next(buildProfile(req.remote_user.name));\n }\n\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n );\n\n route.post(\n '/-/npm/v1/user',\n rateLimit(config?.userRateLimit),\n function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password, tfa } = req.body;\n const { name } = req.remote_user;\n\n if (_.isNil(password) === false) {\n if (\n validatioUtils.validatePassword(\n password.new,\n config?.serverSettings?.passwordValidationRegex\n ) === false\n ) {\n /* eslint new-cap:off */\n return next(errorUtils.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.PASSWORD_SHORT));\n /* eslint new-cap:off */\n }\n\n auth.changePassword(\n name,\n password.old,\n password.new,\n (err, isUpdated): $NextFunctionVer => {\n if (_.isNull(err) === false) {\n return next(\n errorUtils.getCode(err.status, err.message) || errorUtils.getConflict(err.message)\n );\n }\n\n if (isUpdated) {\n return next(buildProfile(req.remote_user.name));\n }\n return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n );\n } else if (_.isNil(tfa) === false) {\n return next(\n errorUtils.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPORT_ERRORS.TFA_DISABLED)\n );\n } else {\n return next(errorUtils.getCode(HTTP_STATUS.INTERNAL_ERROR, APP_ERROR.PROFILE_ERROR));\n }\n }\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAQA,IAAAE,WAAA,GAAAF,OAAA;AAAkD,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAgBnC,SAAAG,SAAUC,KAAa,EAAEC,IAAU,EAAEC,MAAc,EAAQ;EACxE,SAASC,YAAYA,CAACC,IAAY,EAAW;IAC3C,OAAO;MACLC,GAAG,EAAE,KAAK;MACVD,IAAI;MACJE,KAAK,EAAE,EAAE;MACTC,cAAc,EAAE,KAAK;MACrBC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE,EAAE;MACXC,cAAc,EAAE,IAAI;MACpBC,QAAQ,EAAE;IACZ,CAAC;EACH;EAEAX,KAAK,CAACY,GAAG,CACP,gBAAgB,EAChB,IAAAC,qBAAS,EAACX,MAAM,aAANA,MAA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AK,EACX;QACA;QACA,OAAOlB,IAAI,CAACmB,gBAAU,CAACC,OAAO,CAACf,iBAAW,CAACC,YAAY,EAAEE,eAAS,CAACa,cAAc,CAAC,CAAC;QACnF;MACF;MAEArC,IAAI,CAACsC,cAAc,CACjBnC,IAAI,EACJwB,QAAQ,CAACY,GAAG,EACZZ,QAAQ,CAACK,GAAG,EACZ,CAACQ,GAAG,EAAEC,SAAS,KAAuB;QACpC,IAAIxB,eAAC,CAACyB,MAAM,CAACF,GAAG,CAAC,KAAK,KAAK,EAAE;UAC3B,OAAOxB,IAAI,CACTmB,gBAAU,CAACC,OAAO,CAACI,GAAG,CAACpB,MAAM,EAAEoB,GAAG,CAACjB,OAAO,CAAC,IAAIY,gBAAU,CAACQ,WAAW,CAACH,GAAG,CAACjB,OAAO,CACnF,CAAC;QACH;QAEA,IAAIkB,SAAS,EAAE;UACb,OAAOzB,IAAI,CAACd,YAAY,CAACY,GAAG,CAACK,WAAW,CAAChB,IAAI,CAAC,CAAC;QACjD;QACA,OAAOa,IAAI,CAACmB,gBAAU,CAACS,gBAAgB,CAACpB,eAAS,CAACqB,qBAAqB,CAAC,CAAC;MAC3E,CACF,CAAC;IACH,CAAC,MAAM,IAAI5B,eAAC,CAACC,KAAK,CAACd,GAAG,CAAC,KAAK,KAAK,EAAE;MACjC,OAAOY,IAAI,CACTmB,gBAAU,CAACC,OAAO,CAACf,iBAAW,CAACyB,mBAAmB,EAAEC,oBAAc,CAACC,YAAY,CACjF,CAAC;IACH,CAAC,MAAM;MACL,OAAOhC,IAAI,CAACmB,gBAAU,CAACC,OAAO,CAACf,iBAAW,CAAC4B,cAAc,EAAEC,eAAS,CAACC,aAAa,CAAC,CAAC;IACtF;EACF,CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-next-7.7",
|
|
4
4
|
"description": "loaders logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -25,34 +25,32 @@
|
|
|
25
25
|
"verdaccio"
|
|
26
26
|
],
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
29
|
-
"npm": ">=6"
|
|
28
|
+
"node": ">=18"
|
|
30
29
|
},
|
|
31
30
|
"license": "MIT",
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@verdaccio/auth": "
|
|
34
|
-
"@verdaccio/config": "
|
|
35
|
-
"@verdaccio/core": "
|
|
36
|
-
"@verdaccio/logger": "
|
|
37
|
-
"@verdaccio/middleware": "
|
|
38
|
-
"@verdaccio/store": "
|
|
39
|
-
"@verdaccio/utils": "
|
|
32
|
+
"@verdaccio/auth": "7.0.0-next-7.7",
|
|
33
|
+
"@verdaccio/config": "7.0.0-next-7.7",
|
|
34
|
+
"@verdaccio/core": "7.0.0-next-7.7",
|
|
35
|
+
"@verdaccio/logger": "7.0.0-next-7.7",
|
|
36
|
+
"@verdaccio/middleware": "7.0.0-next-7.7",
|
|
37
|
+
"@verdaccio/store": "7.0.0-next-7.7",
|
|
38
|
+
"@verdaccio/utils": "7.0.0-next-7.7",
|
|
40
39
|
"abortcontroller-polyfill": "1.7.5",
|
|
41
|
-
"cookies": "0.8.0",
|
|
42
|
-
"debug": "4.3.4",
|
|
43
40
|
"body-parser": "1.20.2",
|
|
41
|
+
"cookies": "0.9.0",
|
|
42
|
+
"debug": "4.3.4",
|
|
44
43
|
"express": "4.18.2",
|
|
45
44
|
"lodash": "4.17.21",
|
|
46
45
|
"mime": "2.6.0",
|
|
47
46
|
"semver": "7.5.4"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@verdaccio/
|
|
51
|
-
"@verdaccio/types": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"mockdate": "3.0.5"
|
|
49
|
+
"@verdaccio/test-helper": "3.0.0-next.1",
|
|
50
|
+
"@verdaccio/types": "12.0.0-next.2",
|
|
51
|
+
"mockdate": "3.0.5",
|
|
52
|
+
"nock": "13.4.0",
|
|
53
|
+
"supertest": "6.3.3"
|
|
56
54
|
},
|
|
57
55
|
"funding": {
|
|
58
56
|
"type": "opencollective",
|
package/src/index.ts
CHANGED
|
@@ -43,7 +43,6 @@ export default function (config: Config, auth: Auth, storage: Storage): Router {
|
|
|
43
43
|
app.param('org_couchdb_user', match(/^org\.couchdb\.user:/));
|
|
44
44
|
app.use(auth.apiJWTmiddleware());
|
|
45
45
|
app.use(express.json({ strict: false, limit: config.max_body_size || '10mb' }));
|
|
46
|
-
// @ts-ignore
|
|
47
46
|
app.use(antiLoop(config));
|
|
48
47
|
// encode / in a scoped package name to be matched as a single parameter in routes
|
|
49
48
|
app.use(encodeScopePackage);
|
package/src/publish.ts
CHANGED
|
@@ -196,10 +196,10 @@ export function publishPackage(storage: Storage): any {
|
|
|
196
196
|
requestOptions: {
|
|
197
197
|
host: req.hostname,
|
|
198
198
|
protocol: req.protocol,
|
|
199
|
-
|
|
200
|
-
headers: req.headers,
|
|
199
|
+
headers: req.headers as { [key: string]: string },
|
|
201
200
|
username,
|
|
202
201
|
},
|
|
202
|
+
uplinksLook: false,
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
res.status(HTTP_STATUS.CREATED);
|