@verdaccio/server 6.0.0-6-next.30 → 6.0.0-6-next.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.babelrc +1 -1
  2. package/CHANGELOG.md +88 -0
  3. package/build/debug/index.d.ts +1 -1
  4. package/build/debug/index.js +1 -1
  5. package/build/debug/index.js.map +1 -1
  6. package/build/env.js.map +1 -1
  7. package/build/index.js.map +1 -1
  8. package/build/server.d.ts +2 -2
  9. package/build/server.js +5 -3
  10. package/build/server.js.map +1 -1
  11. package/build/utils.d.ts +1 -0
  12. package/build/utils.js +19 -0
  13. package/build/utils.js.map +1 -0
  14. package/jest.config.js +7 -2
  15. package/package.json +70 -71
  16. package/src/debug/index.ts +2 -2
  17. package/src/server.ts +8 -7
  18. package/src/utils.ts +11 -0
  19. package/test/_helper.ts +29 -0
  20. package/test/config/conf.yaml +28 -0
  21. package/test/config/no_debug.yaml +26 -0
  22. package/test/config/powered-custom.yaml +29 -0
  23. package/test/config/powered-disabled.yaml +29 -0
  24. package/test/config/web-disabled.yaml +27 -0
  25. package/test/server.spec.ts +113 -0
  26. package/tsconfig.build.json +1 -1
  27. package/tsconfig.json +14 -14
  28. package/jest.setup.js +0 -1
  29. package/test/.eslintrc +0 -8
  30. package/test/README.md +0 -12
  31. package/test/api/api.spec.yaml +0 -87
  32. package/test/api/helpers/publish-api.js +0 -60
  33. package/test/api/helpers/utils.ts +0 -149
  34. package/test/api/htpasswd +0 -10
  35. package/test/api/index.spec.ts +0 -862
  36. package/test/api/mock/store/@jquery/jquery/jquery-1.5.1.tgz +0 -0
  37. package/test/api/mock/store/@jquery/jquery/package.json +0 -76
  38. package/test/api/mock/store/corrupted-package/package.json +0 -12
  39. package/test/api/mock/store/jquery/jquery-1.5.1.tgz +0 -0
  40. package/test/api/mock/store/jquery/package.json +0 -4919
  41. package/test/api/mock/store/npm_test/package.json +0 -75
  42. package/test/api/mock/store/vue/package.json +0 -25169
  43. package/test/api/plugin/filter.ts +0 -25
  44. package/test/basic/basic.yaml +0 -14
  45. package/test/basic/index.spec.ts +0 -64
  46. package/test/jwt/index.spec.ts +0 -163
  47. package/test/jwt/jwt.yaml +0 -35
  48. package/test/jwt/mock/store/vue/package.json +0 -25169
  49. package/test/package-access/index.spec.ts +0 -100
  50. package/test/package-access/mock/store/.gitkeep +0 -0
  51. package/test/package-access/mock/store/jquery/jquery-1.5.1.tgz +0 -0
  52. package/test/package-access/mock/store/jquery/package.json +0 -4919
  53. package/test/package-access/mock/store/vue/package.json +0 -25169
  54. package/test/package-access/pkg.access.yaml +0 -12
  55. package/test/profile/index.spec.ts +0 -129
  56. package/test/profile/mock/store/.gitkeep +0 -0
  57. package/test/profile/profile.yaml +0 -21
  58. package/test/storage/index.spec.ts +0 -219
  59. package/test/storage/mock/store/@jquery/jquery/jquery-1.5.1.tgz +0 -0
  60. package/test/storage/mock/store/@jquery/jquery/package.json +0 -76
  61. package/test/storage/mock/store/corrupted-package/package.json +0 -12
  62. package/test/storage/mock/store/jquery/jquery-1.5.1.tgz +0 -0
  63. package/test/storage/mock/store/jquery/package.json +0 -4919
  64. package/test/storage/mock/store/npm_test/package.json +0 -75
  65. package/test/storage/store.spec.yaml +0 -24
  66. package/test/token/index.spec.ts +0 -227
  67. package/test/token/mock/store/.gitkeep +0 -0
  68. package/test/token/token.spec.yaml +0 -26
  69. package/test/web/index.spec.ts +0 -157
  70. package/test/web/mock/store/.gitkeep +0 -0
  71. package/test/web/partials/forbidden-place.js +0 -50
  72. package/test/web/partials/publish-api.js +0 -50
  73. package/test/web/web.yaml +0 -20
@@ -1,12 +0,0 @@
1
- storage: ./storage_default_storage
2
- auth:
3
- htpasswd:
4
- file: ./htpasswd
5
- packages:
6
- '@*/*':
7
- access: $all
8
- proxy: remote
9
- '**':
10
- access: $all
11
- proxy: remote
12
- log: { type: stdout, format: pretty, level: warn }
@@ -1,129 +0,0 @@
1
- import path from 'path';
2
- import request from 'supertest';
3
-
4
- import { API_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '@verdaccio/core';
5
- import { logger, setup } from '@verdaccio/logger';
6
- import { mockServer } from '@verdaccio/mock';
7
- import {
8
- DOMAIN_SERVERS,
9
- configExample,
10
- generateRamdonStorage,
11
- getNewToken,
12
- getProfile,
13
- postProfile,
14
- } from '@verdaccio/mock';
15
-
16
- import endPointAPI from '../../src';
17
-
18
- setup([]);
19
-
20
- describe('endpoint user profile', () => {
21
- let app;
22
- let mockRegistry;
23
- jest.setTimeout(20000);
24
-
25
- beforeAll(async () => {
26
- const store = generateRamdonStorage();
27
- const mockServerPort = 55544;
28
- const configForTest = configExample(
29
- {
30
- storage: store,
31
- uplinks: {
32
- remote: {
33
- url: `http://${DOMAIN_SERVERS}:${mockServerPort}`,
34
- },
35
- },
36
- config_path: store,
37
- },
38
- 'profile.yaml',
39
- __dirname
40
- );
41
-
42
- app = await endPointAPI(configForTest);
43
- const binPath = require.resolve('verdaccio/bin/verdaccio');
44
- const storePath = path.join(__dirname, '/mock/store');
45
- mockRegistry = await mockServer(mockServerPort, { storePath, silence: true }).init(binPath);
46
- });
47
-
48
- afterAll(function () {
49
- const [registry, pid] = mockRegistry;
50
- registry.stop();
51
- logger.info(`registry ${pid} has been stopped`);
52
- });
53
-
54
- test('should fetch a profile of logged user', async () => {
55
- const credentials = { name: 'JotaJWT', password: 'secretPass' };
56
- const token = await getNewToken(request(app), credentials);
57
- const [err1, res1] = await getProfile(request(app), token);
58
- expect(err1).toBeNull();
59
- expect(res1.body.name).toBe(credentials.name);
60
- });
61
-
62
- describe('change password', () => {
63
- test('should change password successfully', async () => {
64
- const credentials = { name: 'userTest2000', password: 'secretPass000' };
65
- const body = {
66
- password: {
67
- new: '12345678',
68
- old: credentials.password,
69
- },
70
- };
71
- const token = await getNewToken(request(app), credentials);
72
- const [err1, res1] = await postProfile(request(app), body, token);
73
-
74
- expect(err1).toBeNull();
75
- expect(res1.body.name).toBe(credentials.name);
76
- });
77
-
78
- test('should change password is too short', async () => {
79
- const credentials = { name: 'userTest2001', password: 'secretPass001' };
80
- const body = {
81
- password: {
82
- new: 'p1',
83
- old: credentials.password,
84
- },
85
- };
86
- const token = await getNewToken(request(app), credentials);
87
- const [, resp] = await postProfile(request(app), body, token, HTTP_STATUS.UNAUTHORIZED);
88
-
89
- expect(resp.error).not.toBeNull();
90
- /* eslint new-cap: 0 */
91
- expect(resp.error.text).toMatch(API_ERROR.PASSWORD_SHORT());
92
- });
93
- });
94
-
95
- describe('change tfa', () => {
96
- test('should report TFA is disabled', async () => {
97
- const credentials = { name: 'userTest2002', password: 'secretPass002' };
98
- const body = {
99
- tfa: {},
100
- };
101
- const token = await getNewToken(request(app), credentials);
102
- const [, resp] = await postProfile(
103
- request(app),
104
- body,
105
- token,
106
- HTTP_STATUS.SERVICE_UNAVAILABLE
107
- );
108
-
109
- expect(resp.error).not.toBeNull();
110
- expect(resp.error.text).toMatch(SUPPORT_ERRORS.TFA_DISABLED);
111
- });
112
- });
113
-
114
- describe('error handling', () => {
115
- test('should forbid to fetch a profile with invalid token', async () => {
116
- const [, resp] = await getProfile(request(app), `fakeToken`, HTTP_STATUS.UNAUTHORIZED);
117
-
118
- expect(resp.error).not.toBeNull();
119
- expect(resp.error.text).toMatch(API_ERROR.MUST_BE_LOGGED);
120
- });
121
-
122
- test('should forbid to update a profile with invalid token', async () => {
123
- const [, resp] = await postProfile(request(app), {}, `fakeToken`, HTTP_STATUS.UNAUTHORIZED);
124
-
125
- expect(resp.error).not.toBeNull();
126
- expect(resp.error.text).toMatch(API_ERROR.MUST_BE_LOGGED);
127
- });
128
- });
129
- });
File without changes
@@ -1,21 +0,0 @@
1
- storage: ./storage
2
- plugins: ./plugins
3
- web:
4
- title: Verdaccio
5
- auth:
6
- htpasswd:
7
- file: ./htpasswd
8
- security:
9
- api:
10
- jwt:
11
- sign:
12
- expiresIn: 10m
13
- notBefore: 0
14
- packages:
15
- '@*/*':
16
- access: $authenticated
17
- publish: $authenticated
18
- '**':
19
- access: $authenticated
20
- publish: $authenticated
21
- log: { type: stdout, format: pretty, level: warn }
@@ -1,219 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { Writable } from 'stream';
4
-
5
- import { Config as AppConfig } from '@verdaccio/config';
6
- import { API_ERROR, HTTP_STATUS } from '@verdaccio/core';
7
- import { logger, setup } from '@verdaccio/logger';
8
- import { DOMAIN_SERVERS, configExample, generateRamdonStorage, mockServer } from '@verdaccio/mock';
9
- import { Storage } from '@verdaccio/store';
10
- import { Config } from '@verdaccio/types';
11
-
12
- setup([]);
13
-
14
- const mockServerPort = 55548;
15
-
16
- const generateStorage = async function () {
17
- const storagePath = generateRamdonStorage();
18
- const storageConfig = configExample(
19
- {
20
- config_path: storagePath,
21
- storage: storagePath,
22
- uplinks: {
23
- npmjs: {
24
- url: `http://${DOMAIN_SERVERS}:${mockServerPort}`,
25
- },
26
- },
27
- },
28
- 'store.spec.yaml',
29
- __dirname
30
- );
31
-
32
- const config: Config = new AppConfig(storageConfig);
33
- const store: Storage = new Storage(config);
34
- await store.init(config, []);
35
-
36
- return store;
37
- };
38
-
39
- const generateSameUplinkStorage = async function () {
40
- const storagePath = generateRamdonStorage();
41
- const storageConfig = configExample(
42
- {
43
- config_path: storagePath,
44
- storage: storagePath,
45
- packages: {
46
- jquery: {
47
- access: ['$all'],
48
- publish: ['$all'],
49
- proxy: ['cached'],
50
- },
51
- '@jquery/*': {
52
- access: ['$all'],
53
- publish: ['$all'],
54
- proxy: ['notcached'],
55
- },
56
- },
57
- uplinks: {
58
- cached: {
59
- url: `http://${DOMAIN_SERVERS}:${mockServerPort}`,
60
- cache: true,
61
- },
62
- notcached: {
63
- url: `http://${DOMAIN_SERVERS}:${mockServerPort}`,
64
- cache: false,
65
- },
66
- },
67
- },
68
- 'store.spec.yaml',
69
- __dirname
70
- );
71
-
72
- const config: Config = new AppConfig(storageConfig);
73
- const store: Storage = new Storage(config);
74
- await store.init(config, []);
75
-
76
- return store;
77
- };
78
-
79
- const createNullStream = () =>
80
- new Writable({
81
- write: function (chunk, encoding, next) {
82
- next();
83
- },
84
- });
85
-
86
- describe('StorageTest', () => {
87
- let mockRegistry;
88
-
89
- beforeAll(async () => {
90
- const binPath = require.resolve('verdaccio/bin/verdaccio');
91
- const storePath = path.join(__dirname, '/mock/store');
92
- mockRegistry = await mockServer(mockServerPort, { storePath, silence: true }).init(binPath);
93
- return;
94
- });
95
-
96
- afterAll(function () {
97
- const [registry, pid] = mockRegistry;
98
- registry.stop();
99
- logger.info(`registry ${pid} has been stopped`);
100
- });
101
-
102
- test('should be defined', async () => {
103
- const storage: Storage = await generateStorage();
104
-
105
- expect(storage).toBeDefined();
106
- });
107
-
108
- describe('test getTarball', () => {
109
- test.skip(
110
- 'should select right uplink given package.proxy for' + ' upstream tarballs',
111
- async (done) => {
112
- const storage: Storage = await generateSameUplinkStorage();
113
- const notcachedSpy = jest.spyOn(storage.uplinks.notcached, 'fetchTarball');
114
- const cachedSpy = jest.spyOn(storage.uplinks.cached, 'fetchTarball');
115
-
116
- await new Promise((res, rej) => {
117
- const reader = storage.getTarball('jquery', 'jquery-1.5.1.tgz');
118
- reader.on('end', () => {
119
- expect(notcachedSpy).toHaveBeenCalledTimes(0);
120
- expect(cachedSpy).toHaveBeenCalledTimes(1);
121
- expect(cachedSpy).toHaveBeenCalledWith(
122
- 'http://localhost:55548/jquery/-/jquery-1.5.1.tgz'
123
- );
124
- res();
125
- });
126
- reader.on('error', (err) => {
127
- rej(err);
128
- });
129
- reader.pipe(createNullStream());
130
- });
131
-
132
- // Reset counters.
133
- cachedSpy.mockClear();
134
- notcachedSpy.mockClear();
135
-
136
- await new Promise((res, rej) => {
137
- const reader = storage.getTarball('@jquery/jquery', 'jquery-1.5.1.tgz');
138
- reader.on('end', () => {
139
- expect(cachedSpy).toHaveBeenCalledTimes(0);
140
- expect(notcachedSpy).toHaveBeenCalledTimes(1);
141
- expect(notcachedSpy).toHaveBeenCalledWith(
142
- 'http://localhost:55548/@jquery%2fjquery/-/jquery-1.5.1.tgz'
143
- );
144
- res();
145
- });
146
- reader.on('error', (err) => {
147
- rej(err);
148
- });
149
- reader.pipe(createNullStream());
150
- });
151
-
152
- done();
153
- }
154
- );
155
- });
156
-
157
- describe('test _syncUplinksMetadata', () => {
158
- test('should fetch from uplink jquery metadata from registry', async () => {
159
- const storage: Storage = await generateStorage();
160
-
161
- return new Promise((resolve) => {
162
- // @ts-ignore
163
- storage._syncUplinksMetadata('jquery', null, {}, (err, metadata) => {
164
- expect(err).toBeNull();
165
- expect(metadata).toBeDefined();
166
- expect(metadata).toBeInstanceOf(Object);
167
- resolve(metadata);
168
- });
169
- });
170
- });
171
-
172
- test('should fails on fetch from uplink non existing from registry', async () => {
173
- const storage: Storage = await generateStorage();
174
- return new Promise((resolve) => {
175
- storage._syncUplinksMetadata('@verdaccio/404', null, {}, (err, _metadata, errors) => {
176
- expect(err).not.toBeNull();
177
- expect(errors).toBeInstanceOf(Array);
178
- expect(errors[0][0].statusCode).toBe(HTTP_STATUS.NOT_FOUND);
179
- expect(errors[0][0].message).toMatch(API_ERROR.NOT_PACKAGE_UPLINK);
180
- resolve(errors);
181
- });
182
- });
183
- });
184
-
185
- test('should fails on fetch from uplink corrupted pkg from registry', async () => {
186
- const storage: Storage = await generateStorage();
187
- return new Promise((resolve) => {
188
- // @ts-ignore
189
- storage._syncUplinksMetadata('corrupted-package', null, {}, (err, metadata, errors) => {
190
- expect(err).not.toBeNull();
191
- expect(errors).toBeInstanceOf(Array);
192
- expect(errors[0][0].statusCode).toBe(HTTP_STATUS.INTERNAL_ERROR);
193
- expect(errors[0][0].message).toMatch(API_ERROR.BAD_STATUS_CODE);
194
- resolve(errors);
195
- });
196
- });
197
- });
198
-
199
- test.skip('should not touch if the package exists and has no uplinks', async (done) => {
200
- const storagePath = generateRamdonStorage();
201
- const storage: Storage = (await generateStorage()) as Storage;
202
- const metadataSource = path.join(__dirname, '../../partials/metadata');
203
- const metadataPath = path.join(storagePath, 'npm_test/package.json');
204
-
205
- fs.mkdirSync(path.join(storagePath, 'npm_test'));
206
- fs.writeFileSync(metadataPath, fs.readFileSync(metadataSource));
207
- const metadata = JSON.parse(fs.readFileSync(metadataPath).toString());
208
- // @ts-ignore
209
- storage.localStorage.updateVersions = jest.fn(storage.localStorage.updateVersions);
210
- expect(metadata).toBeDefined();
211
- storage._syncUplinksMetadata('npm_test', metadata, {}, (err) => {
212
- expect(err).toBeNull();
213
- // @ts-ignore
214
- expect(storage.localStorage.updateVersions).not.toHaveBeenCalled();
215
- done();
216
- });
217
- });
218
- });
219
- });
@@ -1,76 +0,0 @@
1
- {
2
- "name": "@jquery/jquery",
3
- "versions": {
4
- "1.5.1": {
5
- "name": "@jquery/jquery",
6
- "description": "jQuery: The Write Less, Do More, JavaScript Library",
7
- "url": "jquery.com",
8
- "keywords": [
9
- "util",
10
- "dom",
11
- "jquery"
12
- ],
13
- "author": {
14
- "name": "John Resig",
15
- "email": "jeresig@gmail.com"
16
- },
17
- "contributors": [],
18
- "dependencies": {
19
- "jsdom": "=0.1.20",
20
- "htmlparser": ">= 1.7.3"
21
- },
22
- "lib": "lib",
23
- "main": "./dist/node-jquery.js",
24
- "version": "1.5.1",
25
- "_id": "@jquery/jquery@1.5.1",
26
- "engines": {
27
- "node": "*"
28
- },
29
- "_engineSupported": true,
30
- "_npmVersion": "0.3.15",
31
- "_nodeVersion": "v0.4.2",
32
- "directories": {
33
- "lib": "./lib"
34
- },
35
- "files": [
36
- ""
37
- ],
38
- "_defaultsLoaded": true,
39
- "dist": {
40
- "shasum": "2ae2d661e906c1a01e044a71bb5b2743942183e5",
41
- "tarball": "https://registry.npmjs.org/@jquery%2jquery/-/jquery-1.5.1.tgz"
42
- },
43
- "deprecated": "Versions of the jquery npm package older than 1.9.0 are patched versions that don't work in web browsers. Please upgrade to >=1.11.0."
44
- }
45
- },
46
- "time": {
47
- "modified": "2018-05-21T21:39:54.702Z",
48
- "created": "2011-03-19T07:19:56.392Z",
49
- "1.5.1": "2011-03-19T07:19:56.956Z"
50
- },
51
- "dist-tags": {
52
- "beta": "3.0.0",
53
- "latest": "3.3.1",
54
- "jota": "1.6.3"
55
- },
56
- "_uplinks": {
57
- "npmjs": {
58
- "etag": "W/\"252f0a131cedd3ea82dfefd6fa049558\"",
59
- "fetched": 1529779934081
60
- }
61
- },
62
- "_distfiles": {
63
- "jquery-1.5.1.tgz": {
64
- "url": "https://registry.npmjs.org/@jquery%2jquery/-/jquery-1.5.1.tgz",
65
- "sha": "2ae2d661e906c1a01e044a71bb5b2743942183e5",
66
- "registry": "npmjs"
67
- }
68
- },
69
- "_attachments": {
70
- "jquery-1.5.1.tgz": {
71
- "shasum": "2ae2d661e906c1a01e044a71bb5b2743942183e5"
72
- }
73
- },
74
- "_rev": "60-fed4915c27b9c1e6",
75
- "readme": "# jQuery\n\n> jQuery is a fast, small, and feature-rich JavaScript library.\n\nFor information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).\nFor source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).\n\nIf upgrading, please see the [blog post for 3.3.1](https://blog.jquery.com/2017/03/20/jquery-3.3.1-now-available/). This includes notable differences from the previous version and a more readable changelog.\n\n## Including jQuery\n\nBelow are some of the most common ways to include jQuery.\n\n### Browser\n\n#### Script tag\n\n```html\n<script src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script>\n```\n\n#### Babel\n\n[Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.\n\n```js\nimport $ from \"jquery\";\n```\n\n#### Browserify/Webpack\n\nThere are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...\n\n```js\nvar $ = require(\"jquery\");\n```\n\n#### AMD (Asynchronous Module Definition)\n\nAMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).\n\n```js\ndefine([\"jquery\"], function($) {\n\n});\n```\n\n### Node\n\nTo include jQuery in [Node](nodejs.org), first install with npm.\n\n```sh\nnpm install jquery\n```\n\nFor jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.\n\n```js\nrequire(\"jsdom\").env(\"\", function(err, window) {\n\tif (err) {\n\t\tconsole.error(err);\n\t\treturn;\n\t}\n\n\tvar $ = require(\"jquery\")(window);\n});\n```"
76
- }
@@ -1,12 +0,0 @@
1
- {
2
- "name": "corrupted-package"
3
- "version": {},
4
- "dist-tags": {},
5
- "_distfiles": {},
6
- "_attachments": {},
7
- "_uplinks": {},
8
- "time": {},
9
- "_rev": "0-0000000000000000",
10
- "readme": "",
11
- "versions": {}
12
- }