@verdaccio/core 8.0.0-next-8.11 → 8.0.0-next-8.13

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.
@@ -1,71 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { validateUnPublishSingleVersion } from '../src/schemes/unpublish-manifest';
4
-
5
- describe('validatePublishSingleVersion', () => {
6
- it('should validate a valid manifest correctly', () => {
7
- const validManifest = {
8
- name: '@juanpicado/test2',
9
- versions: {
10
- '3.0.2-0': {
11
- name: '@juanpicado/test2',
12
- },
13
- },
14
- _rev: '9-17c706cc377dc959',
15
- _id: '@juanpicado/test2',
16
- time: {
17
- created: '2024-11-02T14:33:06.170Z',
18
- modified: '2024-11-02T14:33:22.919Z',
19
- '3.0.2-0': '2024-11-02T14:33:06.208Z',
20
- '3.0.3-0': '2024-11-02T14:33:19.520Z',
21
- },
22
- readme: 'ERROR: No README data found!',
23
- 'dist-tags': {
24
- latest: '3.0.3-0',
25
- },
26
- };
27
-
28
- const result = validateUnPublishSingleVersion(validManifest);
29
- expect(result).toBe(true);
30
- });
31
-
32
- it('should invalidate a manifest missing required properties', () => {
33
- const invalidManifest = {
34
- name: '@juanpicado/test2',
35
- versions: {
36
- '3.0.2-0': {
37
- name: '@juanpicado/test2',
38
- },
39
- },
40
- };
41
-
42
- const result = validateUnPublishSingleVersion(invalidManifest);
43
- expect(result).toBe(false);
44
- });
45
-
46
- it('should invalidate a manifest with empty versions object', () => {
47
- const invalidManifest = {
48
- name: '@juanpicado/test2',
49
- versions: {},
50
- _rev: '9-17c706cc377dc959',
51
- _id: '@juanpicado/test2',
52
- time: {
53
- created: '2024-11-02T14:33:06.170Z',
54
- modified: '2024-11-02T14:33:22.919Z',
55
- '3.0.2-0': '2024-11-02T14:33:06.208Z',
56
- },
57
- readme: 'ERROR: No README data found!',
58
- 'dist-tags': {
59
- latest: '3.0.3-0',
60
- },
61
- };
62
-
63
- const result = validateUnPublishSingleVersion(invalidManifest);
64
- expect(result).toBe(false);
65
- });
66
-
67
- it('should invalidate a null manifest', () => {
68
- const result = validateUnPublishSingleVersion(null);
69
- expect(result).toBe(false);
70
- });
71
- });
@@ -1,182 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
-
3
- import { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS } from '../src/constants';
4
- import {
5
- isObject,
6
- normalizeMetadata,
7
- validateName,
8
- validatePackage,
9
- validatePassword,
10
- validateUserName,
11
- } from '../src/validation-utils';
12
-
13
- describe('validatePackage', () => {
14
- test('should validate package names', () => {
15
- expect(validatePackage('-')).toBeTruthy();
16
- expect(validatePackage('--')).toBeTruthy();
17
- expect(validatePackage('a')).toBeTruthy();
18
- expect(validatePackage('a-')).toBeTruthy();
19
- expect(validatePackage('package-name')).toBeTruthy();
20
- expect(validatePackage('@scope/package-name')).toBeTruthy();
21
- });
22
-
23
- test('should fails on validate package names', () => {
24
- expect(validatePackage('package-name/test/fake')).toBeFalsy();
25
- expect(validatePackage('@/package-name')).toBeFalsy();
26
- expect(validatePackage('$%$%#$%$#%#$%$#')).toBeFalsy();
27
- expect(validatePackage('node_modules')).toBeFalsy();
28
- expect(validatePackage('__proto__')).toBeFalsy();
29
- expect(validatePackage('favicon.ico')).toBeFalsy();
30
- expect(validatePackage('%')).toBeFalsy();
31
- });
32
- });
33
-
34
- describe('isObject', () => {
35
- test('isObject metadata', () => {
36
- expect(isObject({ foo: 'bar' })).toBeTruthy();
37
- // expect(isObject('foo')).toBeTruthy();
38
- expect(isObject(['foo'])).toBeFalsy();
39
- expect(isObject(null)).toBeFalsy();
40
- expect(isObject(undefined)).toBeFalsy();
41
- expect(isObject(true)).toBeFalsy();
42
- });
43
- });
44
-
45
- describe('normalizeMetadata', () => {
46
- test('should fills an empty metadata object', () => {
47
- // intended to fail with flow, do not remove
48
- // @ts-ignore
49
- expect(Object.keys(normalizeMetadata({}))).toContain(DIST_TAGS);
50
- // @ts-ignore
51
- expect(Object.keys(normalizeMetadata({}))).toContain('versions');
52
- // @ts-ignore
53
- expect(Object.keys(normalizeMetadata({}))).toContain('time');
54
- });
55
-
56
- test.skip('should fails the assertions is not an object', () => {
57
- expect(function () {
58
- // @ts-ignore
59
- normalizeMetadata('');
60
- // @ts-ignore
61
- }).toThrow(expect.hasAssertions());
62
- });
63
-
64
- test('should fails the assertions is name does not match', () => {
65
- expect(function () {
66
- // @ts-expect-error
67
- normalizeMetadata({}, 'no-name');
68
- }).toThrowError();
69
- });
70
- });
71
-
72
- describe('validateName', () => {
73
- test('should fails with no string', () => {
74
- // intended to fail with Typescript, do not remove
75
- // @ts-ignore
76
- expect(validateName(null)).toBeFalsy();
77
- // @ts-ignore
78
- expect(validateName(undefined)).toBeFalsy();
79
- });
80
-
81
- test('good ones', () => {
82
- expect(validateName('verdaccio')).toBeTruthy();
83
- expect(validateName('some.weird.package-zzz')).toBeTruthy();
84
- expect(validateName('--0.0.1.tgz')).toBeTruthy();
85
- expect(validateName('old-package@0.1.2.tgz')).toBeTruthy();
86
- // fix https://github.com/verdaccio/verdaccio/issues/1400
87
- expect(validateName('-build-infra')).toBeTruthy();
88
- expect(validateName('@pkg-scoped/without-extension')).toBeTruthy();
89
- });
90
-
91
- test('should be valid using uppercase', () => {
92
- expect(validateName('ETE')).toBeTruthy();
93
- expect(validateName('JSONStream')).toBeTruthy();
94
- });
95
-
96
- test('should fails with path seps', () => {
97
- expect(validateName('some/thing')).toBeFalsy();
98
- expect(validateName('some\\thing')).toBeFalsy();
99
- });
100
-
101
- test('should fail with no hidden files', () => {
102
- expect(validateName('.bin')).toBeFalsy();
103
- });
104
-
105
- test('should fails with reserved words', () => {
106
- expect(validateName('favicon.ico')).toBeFalsy();
107
- expect(validateName('node_modules')).toBeFalsy();
108
- expect(validateName('__proto__')).toBeFalsy();
109
- });
110
-
111
- test('should fails with other options', () => {
112
- expect(validateName('pk g')).toBeFalsy();
113
- expect(validateName('pk\tg')).toBeFalsy();
114
- expect(validateName('pk%20g')).toBeFalsy();
115
- expect(validateName('pk+g')).toBeFalsy();
116
- expect(validateName('pk:g')).toBeFalsy();
117
- });
118
- });
119
-
120
- describe('validatePassword', () => {
121
- test('should validate password according the length', () => {
122
- expect(validatePassword('12345', DEFAULT_PASSWORD_VALIDATION)).toBeTruthy();
123
- });
124
-
125
- test('should validate invalid regex', () => {
126
- // @ts-expect-error
127
- expect(validatePassword('12345', 34234342)).toBeFalsy();
128
- });
129
-
130
- test('should validate invalid regex (undefined)', () => {
131
- expect(validatePassword('12345', undefined)).toBeTruthy();
132
- });
133
-
134
- test('should validate invalid password)', () => {
135
- // @ts-expect-error
136
- expect(validatePassword(undefined)).toBeFalsy();
137
- });
138
-
139
- test('should validate invalid password number)', () => {
140
- // @ts-expect-error
141
- expect(validatePassword(2342344234342)).toBeFalsy();
142
- });
143
-
144
- test('should fails on validate password according the length', () => {
145
- expect(validatePassword('12345', /.{10}$/)).toBeFalsy();
146
- });
147
-
148
- test('should fails handle complex password validation', () => {
149
- expect(validatePassword('12345', /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/)).toBeFalsy();
150
- });
151
-
152
- test('should handle complex password validation', () => {
153
- expect(
154
- validatePassword(
155
- 'c<?_:srdsj&WyZgY}r4:l[F<RgV<}',
156
- /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$/
157
- )
158
- ).toBeTruthy();
159
- });
160
-
161
- test('should fails on validate password according the length and default config', () => {
162
- expect(validatePassword('12')).toBeFalsy();
163
- });
164
-
165
- test('should validate password according the length and default config', () => {
166
- expect(validatePassword('1235678910')).toBeTruthy();
167
- });
168
- });
169
-
170
- describe('validateUserName', () => {
171
- test('should validate username according to expected name', () => {
172
- expect(validateUserName('org.couchdb.user:test', 'test')).toBeTruthy();
173
- });
174
-
175
- test('should fail to validate username if different from expected name', () => {
176
- expect(validateUserName('org.couchdb.user:foouser', 'test')).toBeFalsy();
177
- });
178
-
179
- test('should fail to validate username if not given', () => {
180
- expect(validateUserName(undefined, 'test')).toBeFalsy();
181
- });
182
- });
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./build",
6
- "noImplicitAny": true
7
- },
8
- "include": ["src/**/*"],
9
- "exclude": ["src/**/*.test.ts"]
10
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.reference.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./build",
6
- "composite": true,
7
- "declaration": true,
8
- "noImplicitAny": true
9
- },
10
- "include": ["src/**/*.ts"],
11
- "exclude": ["src/**/*.test.ts"]
12
- }
package/typedoc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["src/index.ts"],
4
- "sort": ["source-order"]
5
- }