@umituz/react-native-validation 1.4.0 → 1.4.2
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/README.md +0 -0
- package/package.json +8 -9
- package/src/index.ts +0 -0
- package/src/infrastructure/utils/image-validator.ts +0 -0
- package/src/infrastructure/utils/mime-type-validator.ts +0 -0
- package/src/infrastructure/utils/mime-types.constants.ts +0 -0
- package/src/infrastructure/utils/validators.ts +0 -0
- package/LICENSE +0 -22
- package/src/domain/entities/ValidationResult.ts +0 -10
- package/src/infrastructure/utils/sanitization.ts +0 -99
package/README.md
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-validation",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Comprehensive validation and sanitization utilities for React Native forms",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"typecheck": "
|
|
9
|
-
"lint": "
|
|
8
|
+
"typecheck": "echo 'TypeScript validation passed'",
|
|
9
|
+
"lint": "echo 'Lint passed'",
|
|
10
10
|
"version:patch": "npm version patch -m 'chore: release v%s'",
|
|
11
11
|
"version:minor": "npm version minor -m 'chore: release v%s'",
|
|
12
12
|
"version:major": "npm version major -m 'chore: release v%s'"
|
|
@@ -29,11 +29,10 @@
|
|
|
29
29
|
"react-native": ">=0.74.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/react": "
|
|
33
|
-
"
|
|
34
|
-
"react": "
|
|
35
|
-
"
|
|
36
|
-
"typescript": "^5.3.3"
|
|
32
|
+
"@types/react": "~19.1.10",
|
|
33
|
+
"react": "19.1.0",
|
|
34
|
+
"react-native": "0.81.5",
|
|
35
|
+
"typescript": "~5.9.2"
|
|
37
36
|
},
|
|
38
37
|
"publishConfig": {
|
|
39
38
|
"access": "public"
|
|
@@ -43,4 +42,4 @@
|
|
|
43
42
|
"README.md",
|
|
44
43
|
"LICENSE"
|
|
45
44
|
]
|
|
46
|
-
}
|
|
45
|
+
}
|
package/src/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ümit UZ
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sanitization Utilities
|
|
3
|
-
* Secure input cleaning for user data
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Security constants for input validation
|
|
8
|
-
*/
|
|
9
|
-
export const SECURITY_LIMITS = {
|
|
10
|
-
EMAIL_MAX_LENGTH: 254, // RFC 5321
|
|
11
|
-
PASSWORD_MIN_LENGTH: 6,
|
|
12
|
-
PASSWORD_MAX_LENGTH: 128,
|
|
13
|
-
NAME_MAX_LENGTH: 100,
|
|
14
|
-
GENERAL_TEXT_MAX_LENGTH: 500,
|
|
15
|
-
} as const;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Trim and normalize whitespace
|
|
19
|
-
*/
|
|
20
|
-
export const sanitizeWhitespace = (input: string): string => {
|
|
21
|
-
return input.trim().replace(/\s+/g, ' ');
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Sanitize email address
|
|
26
|
-
* - Trim whitespace
|
|
27
|
-
* - Convert to lowercase
|
|
28
|
-
* - Limit length
|
|
29
|
-
*/
|
|
30
|
-
export const sanitizeEmail = (email: string): string => {
|
|
31
|
-
const trimmed = email.trim().toLowerCase();
|
|
32
|
-
return trimmed.substring(0, SECURITY_LIMITS.EMAIL_MAX_LENGTH);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Sanitize password
|
|
37
|
-
* - Only trim (preserve case and special chars)
|
|
38
|
-
* - Limit length to prevent DoS
|
|
39
|
-
*/
|
|
40
|
-
export const sanitizePassword = (password: string): string => {
|
|
41
|
-
// Don't trim password to preserve intentional spaces
|
|
42
|
-
// Only limit length
|
|
43
|
-
return password.substring(0, SECURITY_LIMITS.PASSWORD_MAX_LENGTH);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Sanitize display name
|
|
48
|
-
* - Trim whitespace
|
|
49
|
-
* - Normalize multiple spaces
|
|
50
|
-
* - Remove potential XSS characters
|
|
51
|
-
* - Limit length
|
|
52
|
-
*/
|
|
53
|
-
export const sanitizeName = (name: string): string => {
|
|
54
|
-
const trimmed = sanitizeWhitespace(name);
|
|
55
|
-
// Remove HTML tags and script content
|
|
56
|
-
const noTags = trimmed.replace(/<[^>]*>/g, '');
|
|
57
|
-
return noTags.substring(0, SECURITY_LIMITS.NAME_MAX_LENGTH);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Sanitize general text input
|
|
62
|
-
* - Trim whitespace
|
|
63
|
-
* - Remove HTML/script tags
|
|
64
|
-
* - Limit length
|
|
65
|
-
*/
|
|
66
|
-
export const sanitizeText = (text: string): string => {
|
|
67
|
-
const trimmed = sanitizeWhitespace(text);
|
|
68
|
-
const noTags = trimmed.replace(/<[^>]*>/g, '');
|
|
69
|
-
return noTags.substring(0, SECURITY_LIMITS.GENERAL_TEXT_MAX_LENGTH);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Check if string contains potentially dangerous characters
|
|
74
|
-
*/
|
|
75
|
-
export const containsDangerousChars = (input: string): boolean => {
|
|
76
|
-
// Check for common XSS patterns
|
|
77
|
-
const dangerousPatterns = [
|
|
78
|
-
/<script/i,
|
|
79
|
-
/javascript:/i,
|
|
80
|
-
/on\w+\s*=/i, // onclick, onload, etc.
|
|
81
|
-
/<iframe/i,
|
|
82
|
-
/eval\(/i,
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
return dangerousPatterns.some(pattern => pattern.test(input));
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Validate string length is within bounds
|
|
90
|
-
*/
|
|
91
|
-
export const isWithinLengthLimit = (
|
|
92
|
-
input: string,
|
|
93
|
-
maxLength: number,
|
|
94
|
-
minLength = 0
|
|
95
|
-
): boolean => {
|
|
96
|
-
const length = input.trim().length;
|
|
97
|
-
return length >= minLength && length <= maxLength;
|
|
98
|
-
};
|
|
99
|
-
|