@verdaccio/api 8.1.0-next-8.3 → 8.1.0-next-8.5
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 +43 -0
- package/build/dist-tags.d.ts +2 -1
- package/build/dist-tags.js +3 -4
- package/build/dist-tags.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +9 -8
- package/build/index.js.map +1 -1
- package/build/package.d.ts +2 -1
- package/build/package.js +20 -6
- package/build/package.js.map +1 -1
- package/build/publish.d.ts +3 -2
- package/build/publish.js +30 -15
- package/build/publish.js.map +1 -1
- package/build/search.d.ts +2 -1
- package/build/search.js +2 -3
- package/build/search.js.map +1 -1
- package/build/user.d.ts +2 -1
- package/build/user.js +3 -4
- package/build/user.js.map +1 -1
- package/build/v1/search.d.ts +2 -1
- package/build/v1/search.js +3 -4
- package/build/v1/search.js.map +1 -1
- package/build/v1/token.d.ts +2 -1
- package/build/v1/token.js +8 -9
- package/build/v1/token.js.map +1 -1
- package/package.json +13 -13
- package/src/dist-tags.ts +2 -2
- package/src/index.ts +11 -9
- package/src/package.ts +19 -4
- package/src/publish.ts +30 -9
- package/src/search.ts +2 -2
- package/src/user.ts +7 -3
- package/src/v1/search.ts +2 -2
- package/src/v1/token.ts +8 -2
- package/test/integration/distTag.spec.ts +3 -0
- package/test/integration/package.spec.ts +4 -3
- package/test/integration/publish.spec.ts +3 -3
- package/test/integration/star.spec.ts +1 -1
package/src/v1/search.ts
CHANGED
|
@@ -3,9 +3,9 @@ import _ from 'lodash';
|
|
|
3
3
|
|
|
4
4
|
import { Auth } from '@verdaccio/auth';
|
|
5
5
|
import { HTTP_STATUS, searchUtils } from '@verdaccio/core';
|
|
6
|
-
import { logger } from '@verdaccio/logger';
|
|
7
6
|
import { Storage } from '@verdaccio/store';
|
|
8
7
|
import { Manifest } from '@verdaccio/types';
|
|
8
|
+
import { Logger } from '@verdaccio/types';
|
|
9
9
|
|
|
10
10
|
const debug = buildDebug('verdaccio:api:search');
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ const debug = buildDebug('verdaccio:api:search');
|
|
|
15
15
|
* - {"objects":[],"total":0,"time":"Sun Jul 25 2021 14:09:11 GMT+0000 (Coordinated Universal Time)"}
|
|
16
16
|
* req: 'GET /-/v1/search?text=react&size=20&frpom=0&quality=0.65&popularity=0.98&maintenance=0.5'
|
|
17
17
|
*/
|
|
18
|
-
export default function (route, auth: Auth, storage: Storage): void {
|
|
18
|
+
export default function (route, auth: Auth, storage: Storage, logger: Logger): void {
|
|
19
19
|
function checkAccess(pkg: any, auth: any, remoteUser): Promise<Manifest | null> {
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
21
21
|
auth.allow_access({ packageName: pkg?.package?.name }, remoteUser, function (err, allowed) {
|
package/src/v1/token.ts
CHANGED
|
@@ -4,10 +4,10 @@ import _ from 'lodash';
|
|
|
4
4
|
import { getApiToken } from '@verdaccio/auth';
|
|
5
5
|
import { Auth } from '@verdaccio/auth';
|
|
6
6
|
import { HEADERS, HTTP_STATUS, SUPPORT_ERRORS, errorUtils } from '@verdaccio/core';
|
|
7
|
-
import { logger } from '@verdaccio/logger';
|
|
8
7
|
import { rateLimit } from '@verdaccio/middleware';
|
|
9
8
|
import { Storage } from '@verdaccio/store';
|
|
10
9
|
import { Config, RemoteUser, Token } from '@verdaccio/types';
|
|
10
|
+
import { Logger } from '@verdaccio/types';
|
|
11
11
|
import { mask, stringToMD5 } from '@verdaccio/utils';
|
|
12
12
|
|
|
13
13
|
import { $NextFunctionVer, $RequestExtend } from '../../types/custom';
|
|
@@ -24,7 +24,13 @@ function normalizeToken(token: Token): NormalizeToken {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// https://github.com/npm/npm-profile/blob/latest/lib/index.js
|
|
27
|
-
export default function (
|
|
27
|
+
export default function (
|
|
28
|
+
route: Router,
|
|
29
|
+
auth: Auth,
|
|
30
|
+
storage: Storage,
|
|
31
|
+
config: Config,
|
|
32
|
+
logger: Logger
|
|
33
|
+
): void {
|
|
28
34
|
route.get(
|
|
29
35
|
'/-/npm/v1/tokens',
|
|
30
36
|
rateLimit(config?.userRateLimit),
|
|
@@ -2,9 +2,12 @@ import supertest from 'supertest';
|
|
|
2
2
|
import { beforeEach, describe, expect, test } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
5
|
+
import { setup } from '@verdaccio/logger';
|
|
5
6
|
|
|
6
7
|
import { getDisTags, initializeServer, publishVersion } from './_helper';
|
|
7
8
|
|
|
9
|
+
setup({});
|
|
10
|
+
|
|
8
11
|
describe('package', () => {
|
|
9
12
|
let app;
|
|
10
13
|
beforeEach(async () => {
|
|
@@ -31,12 +31,13 @@ describe('package', () => {
|
|
|
31
31
|
['@scope/foo2', 'foo2-1.0.0.tgz'],
|
|
32
32
|
])('should fails if tarball does not exist', async (pkg, fileName) => {
|
|
33
33
|
await publishVersion(app, pkg, '1.0.1');
|
|
34
|
-
|
|
34
|
+
await supertest(app)
|
|
35
35
|
.get(`/${pkg}/-/${fileName}`)
|
|
36
36
|
.set(HEADERS.ACCEPT, HEADERS.JSON)
|
|
37
37
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.OCTET_STREAM)
|
|
38
38
|
.expect(HTTP_STATUS.NOT_FOUND);
|
|
39
39
|
});
|
|
40
|
+
|
|
40
41
|
test.todo('check content length file header');
|
|
41
42
|
test.todo('fails on file was aborted');
|
|
42
43
|
});
|
|
@@ -97,8 +98,8 @@ describe('package', () => {
|
|
|
97
98
|
expect(response.body.time).toBeDefined();
|
|
98
99
|
expect(response.body.modified).toBeDefined();
|
|
99
100
|
expect(response.body[DIST_TAGS]).toEqual({ latest: '1.0.0' });
|
|
100
|
-
expect(response.body.readme).
|
|
101
|
-
expect(response.body._rev).
|
|
101
|
+
expect(response.body.readme).toBeDefined();
|
|
102
|
+
expect(response.body._rev).toBeDefined();
|
|
102
103
|
expect(response.body.users).not.toBeDefined();
|
|
103
104
|
}
|
|
104
105
|
);
|
|
@@ -57,7 +57,7 @@ describe('publish', () => {
|
|
|
57
57
|
async (pkgName) => {
|
|
58
58
|
const app = await initializeServer('publish.yaml');
|
|
59
59
|
await publishVersion(app, pkgName, '1.0.0');
|
|
60
|
-
|
|
60
|
+
new Promise((resolve) => {
|
|
61
61
|
publishVersion(app, pkgName, '1.0.0')
|
|
62
62
|
.expect(HTTP_STATUS.CONFLICT)
|
|
63
63
|
.then((response) => {
|
|
@@ -73,7 +73,7 @@ describe('publish', () => {
|
|
|
73
73
|
describe('no proxies setup', () => {
|
|
74
74
|
test.each([['foo', '@scope/foo']])('should publish a package', async (pkgName) => {
|
|
75
75
|
const app = await initializeServer('publish.yaml');
|
|
76
|
-
|
|
76
|
+
new Promise((resolve) => {
|
|
77
77
|
publishVersion(app, pkgName, '1.0.0')
|
|
78
78
|
.expect(HTTP_STATUS.CREATED)
|
|
79
79
|
.then((response) => {
|
|
@@ -86,7 +86,7 @@ describe('publish', () => {
|
|
|
86
86
|
test.each([['foo', '@scope/foo']])('should publish a new package', async (pkgName) => {
|
|
87
87
|
const pkgMetadata = generatePackageMetadata(pkgName, '1.0.0');
|
|
88
88
|
const app = await initializeServer('publish.yaml');
|
|
89
|
-
|
|
89
|
+
new Promise((resolve) => {
|
|
90
90
|
supertest(app)
|
|
91
91
|
.put(`/${encodeURIComponent(pkgName)}`)
|
|
92
92
|
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
|
|
@@ -65,7 +65,7 @@ describe('star', () => {
|
|
|
65
65
|
const app = await initializeServer('star.yaml');
|
|
66
66
|
const token = await getNewToken(app, { name: userLogged, password: 'secretPass' });
|
|
67
67
|
await publishVersion(app, pkgName, '1.0.0', undefined, token).expect(HTTP_STATUS.CREATED);
|
|
68
|
-
|
|
68
|
+
await supertest(app)
|
|
69
69
|
.get(`/-/_view/starredByUser?key_xxxxx=other`)
|
|
70
70
|
.set('Accept', HEADERS.JSON)
|
|
71
71
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|