@verdaccio/core 6.0.0-6-next.47 → 6.0.0-6-next.49

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,10 +1,11 @@
1
- import { DIST_TAGS } from '../src/constants';
1
+ import { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS } from '../src/constants';
2
2
  import { validatePublishSingleVersion } from '../src/schemes/publish-manifest';
3
3
  import {
4
4
  isObject,
5
5
  normalizeMetadata,
6
6
  validateName,
7
7
  validatePackage,
8
+ validatePassword,
8
9
  } from '../src/validation-utils';
9
10
 
10
11
  describe('validatePackage', () => {
@@ -166,3 +167,53 @@ describe('validatePublishSingleVersion', () => {
166
167
  ).toBeFalsy();
167
168
  });
168
169
  });
170
+
171
+ describe('validatePassword', () => {
172
+ test('should validate password according the length', () => {
173
+ expect(validatePassword('12345', DEFAULT_PASSWORD_VALIDATION)).toBeTruthy();
174
+ });
175
+
176
+ test('should validate invalid regex', () => {
177
+ // @ts-expect-error
178
+ expect(validatePassword('12345', 34234342)).toBeFalsy();
179
+ });
180
+
181
+ test('should validate invalid regex (undefined)', () => {
182
+ expect(validatePassword('12345', undefined)).toBeTruthy();
183
+ });
184
+
185
+ test('should validate invalid password)', () => {
186
+ // @ts-expect-error
187
+ expect(validatePassword(undefined)).toBeFalsy();
188
+ });
189
+
190
+ test('should validate invalid password number)', () => {
191
+ // @ts-expect-error
192
+ expect(validatePassword(2342344234342)).toBeFalsy();
193
+ });
194
+
195
+ test('should fails on validate password according the length', () => {
196
+ expect(validatePassword('12345', /.{10}$/)).toBeFalsy();
197
+ });
198
+
199
+ test('should fails handle complex password validation', () => {
200
+ expect(validatePassword('12345', /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/)).toBeFalsy();
201
+ });
202
+
203
+ test('should handle complex password validation', () => {
204
+ expect(
205
+ validatePassword(
206
+ 'c<?_:srdsj&WyZgY}r4:l[F<RgV<}',
207
+ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$/
208
+ )
209
+ ).toBeTruthy();
210
+ });
211
+
212
+ test('should fails on validate password according the length and default config', () => {
213
+ expect(validatePassword('12')).toBeFalsy();
214
+ });
215
+
216
+ test('should validate password according the length and default config', () => {
217
+ expect(validatePassword('1235678910')).toBeTruthy();
218
+ });
219
+ });
@@ -2,7 +2,8 @@
2
2
  "extends": "../../../tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "./src",
5
- "outDir": "./build"
5
+ "outDir": "./build",
6
+ "noImplicitAny": true
6
7
  },
7
8
  "include": ["src/**/*"],
8
9
  "exclude": ["src/**/*.test.ts"]
package/tsconfig.json CHANGED
@@ -4,7 +4,8 @@
4
4
  "rootDir": "./src",
5
5
  "outDir": "./build",
6
6
  "composite": true,
7
- "declaration": true
7
+ "declaration": true,
8
+ "noImplicitAny": true
8
9
  },
9
10
  "include": ["src/**/*.ts"],
10
11
  "exclude": ["src/**/*.test.ts"]
package/typedoc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["src/index.ts"],
4
+ "sort": ["source-order"]
5
+ }