@oxog/vld 1.1.1 โ†’ 1.3.1

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 (150) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/README.md +1128 -840
  3. package/dist/codecs/index.d.ts +89 -0
  4. package/dist/codecs/index.d.ts.map +1 -0
  5. package/dist/codecs/index.js +256 -0
  6. package/dist/codecs/index.js.map +1 -0
  7. package/dist/coercion/boolean.d.ts.map +1 -1
  8. package/dist/coercion/boolean.js +6 -2
  9. package/dist/coercion/boolean.js.map +1 -1
  10. package/dist/coercion/string.d.ts.map +1 -1
  11. package/dist/coercion/string.js +146 -10
  12. package/dist/coercion/string.js.map +1 -1
  13. package/dist/index.d.ts +14 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +27 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/locales/af.d.ts.map +1 -1
  18. package/dist/locales/af.js +15 -1
  19. package/dist/locales/af.js.map +1 -1
  20. package/dist/locales/ar.d.ts.map +1 -1
  21. package/dist/locales/ar.js +15 -1
  22. package/dist/locales/ar.js.map +1 -1
  23. package/dist/locales/bn.d.ts.map +1 -1
  24. package/dist/locales/bn.js +15 -1
  25. package/dist/locales/bn.js.map +1 -1
  26. package/dist/locales/da.d.ts.map +1 -1
  27. package/dist/locales/da.js +15 -1
  28. package/dist/locales/da.js.map +1 -1
  29. package/dist/locales/de.d.ts.map +1 -1
  30. package/dist/locales/de.js +15 -1
  31. package/dist/locales/de.js.map +1 -1
  32. package/dist/locales/en.d.ts.map +1 -1
  33. package/dist/locales/en.js +15 -1
  34. package/dist/locales/en.js.map +1 -1
  35. package/dist/locales/es-MX.d.ts.map +1 -1
  36. package/dist/locales/es-MX.js +15 -1
  37. package/dist/locales/es-MX.js.map +1 -1
  38. package/dist/locales/es.d.ts.map +1 -1
  39. package/dist/locales/es.js +15 -1
  40. package/dist/locales/es.js.map +1 -1
  41. package/dist/locales/fi.d.ts.map +1 -1
  42. package/dist/locales/fi.js +15 -1
  43. package/dist/locales/fi.js.map +1 -1
  44. package/dist/locales/fr.d.ts.map +1 -1
  45. package/dist/locales/fr.js +15 -1
  46. package/dist/locales/fr.js.map +1 -1
  47. package/dist/locales/hi.d.ts.map +1 -1
  48. package/dist/locales/hi.js +15 -1
  49. package/dist/locales/hi.js.map +1 -1
  50. package/dist/locales/id.d.ts.map +1 -1
  51. package/dist/locales/id.js +15 -1
  52. package/dist/locales/id.js.map +1 -1
  53. package/dist/locales/it.d.ts.map +1 -1
  54. package/dist/locales/it.js +15 -1
  55. package/dist/locales/it.js.map +1 -1
  56. package/dist/locales/ja.d.ts.map +1 -1
  57. package/dist/locales/ja.js +15 -1
  58. package/dist/locales/ja.js.map +1 -1
  59. package/dist/locales/ko.d.ts.map +1 -1
  60. package/dist/locales/ko.js +15 -1
  61. package/dist/locales/ko.js.map +1 -1
  62. package/dist/locales/nl.d.ts.map +1 -1
  63. package/dist/locales/nl.js +15 -1
  64. package/dist/locales/nl.js.map +1 -1
  65. package/dist/locales/no.d.ts.map +1 -1
  66. package/dist/locales/no.js +15 -1
  67. package/dist/locales/no.js.map +1 -1
  68. package/dist/locales/pl.d.ts.map +1 -1
  69. package/dist/locales/pl.js +15 -1
  70. package/dist/locales/pl.js.map +1 -1
  71. package/dist/locales/pt-BR.d.ts.map +1 -1
  72. package/dist/locales/pt-BR.js +15 -1
  73. package/dist/locales/pt-BR.js.map +1 -1
  74. package/dist/locales/pt.d.ts.map +1 -1
  75. package/dist/locales/pt.js +15 -1
  76. package/dist/locales/pt.js.map +1 -1
  77. package/dist/locales/ru.d.ts.map +1 -1
  78. package/dist/locales/ru.js +15 -1
  79. package/dist/locales/ru.js.map +1 -1
  80. package/dist/locales/sv.d.ts.map +1 -1
  81. package/dist/locales/sv.js +15 -1
  82. package/dist/locales/sv.js.map +1 -1
  83. package/dist/locales/sw.d.ts.map +1 -1
  84. package/dist/locales/sw.js +15 -1
  85. package/dist/locales/sw.js.map +1 -1
  86. package/dist/locales/th.d.ts.map +1 -1
  87. package/dist/locales/th.js +15 -1
  88. package/dist/locales/th.js.map +1 -1
  89. package/dist/locales/tr.d.ts.map +1 -1
  90. package/dist/locales/tr.js +15 -1
  91. package/dist/locales/tr.js.map +1 -1
  92. package/dist/locales/types.d.ts +10 -0
  93. package/dist/locales/types.d.ts.map +1 -1
  94. package/dist/locales/types.js.map +1 -1
  95. package/dist/locales/vi.d.ts.map +1 -1
  96. package/dist/locales/vi.js +15 -1
  97. package/dist/locales/vi.js.map +1 -1
  98. package/dist/locales/zh.d.ts.map +1 -1
  99. package/dist/locales/zh.js +15 -1
  100. package/dist/locales/zh.js.map +1 -1
  101. package/dist/utils/codec-utils.d.ts +44 -0
  102. package/dist/utils/codec-utils.d.ts.map +1 -0
  103. package/dist/utils/codec-utils.js +205 -0
  104. package/dist/utils/codec-utils.js.map +1 -0
  105. package/dist/utils/deep-merge.d.ts +1 -0
  106. package/dist/utils/deep-merge.d.ts.map +1 -1
  107. package/dist/utils/deep-merge.js +33 -8
  108. package/dist/utils/deep-merge.js.map +1 -1
  109. package/dist/validators/array.d.ts +5 -0
  110. package/dist/validators/array.d.ts.map +1 -1
  111. package/dist/validators/array.js +30 -1
  112. package/dist/validators/array.js.map +1 -1
  113. package/dist/validators/base64.d.ts +18 -0
  114. package/dist/validators/base64.d.ts.map +1 -0
  115. package/dist/validators/base64.js +65 -0
  116. package/dist/validators/base64.js.map +1 -0
  117. package/dist/validators/codec.d.ts +55 -0
  118. package/dist/validators/codec.d.ts.map +1 -0
  119. package/dist/validators/codec.js +182 -0
  120. package/dist/validators/codec.js.map +1 -0
  121. package/dist/validators/date.d.ts +5 -1
  122. package/dist/validators/date.d.ts.map +1 -1
  123. package/dist/validators/date.js +53 -29
  124. package/dist/validators/date.js.map +1 -1
  125. package/dist/validators/hex.d.ts +17 -0
  126. package/dist/validators/hex.d.ts.map +1 -0
  127. package/dist/validators/hex.js +61 -0
  128. package/dist/validators/hex.js.map +1 -0
  129. package/dist/validators/number.d.ts.map +1 -1
  130. package/dist/validators/number.js +16 -3
  131. package/dist/validators/number.js.map +1 -1
  132. package/dist/validators/object.d.ts +5 -0
  133. package/dist/validators/object.d.ts.map +1 -1
  134. package/dist/validators/object.js +58 -6
  135. package/dist/validators/object.js.map +1 -1
  136. package/dist/validators/record.d.ts.map +1 -1
  137. package/dist/validators/record.js +6 -0
  138. package/dist/validators/record.js.map +1 -1
  139. package/dist/validators/string.d.ts.map +1 -1
  140. package/dist/validators/string.js +86 -4
  141. package/dist/validators/string.js.map +1 -1
  142. package/dist/validators/uint8array.d.ts +25 -0
  143. package/dist/validators/uint8array.d.ts.map +1 -0
  144. package/dist/validators/uint8array.js +87 -0
  145. package/dist/validators/uint8array.js.map +1 -0
  146. package/dist/validators/union.d.ts +1 -0
  147. package/dist/validators/union.d.ts.map +1 -1
  148. package/dist/validators/union.js +31 -20
  149. package/dist/validators/union.js.map +1 -1
  150. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,163 @@ All notable changes to VLD will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.1] - 2025-11-12
9
+
10
+ ### ๐ŸŽฏ **100% Test Success Rate Achieved**
11
+ - **Perfect Test Coverage**: All 695 tests now passing (0 failures)
12
+ - **IPv6 Validation Fix**: Resolved final failing test for IPv6-mapped addresses
13
+ - **Security Validation**: All 4 critical security fixes thoroughly tested
14
+
15
+ ### ๐Ÿ”ง Bug Fixes
16
+ - **IPv6 Validation**: Fixed validation for IPv4-mapped IPv6 addresses (`::ffff:192.0.2.1`)
17
+ - **Test Coverage**: Updated documentation to reflect 695 passing tests (up from 694)
18
+
19
+ ### โœ… Quality Assurance
20
+ - **100% Test Success**: Achieved perfect test success rate across all test suites
21
+ - **Security Hardening**: All security vulnerabilities validated with comprehensive tests
22
+ - **Performance Maintained**: No performance impact from security improvements
23
+
24
+ ## [1.3.0] - 2025-11-12
25
+
26
+ ### ๐Ÿ”’ **Critical Security Update**
27
+ - **SECURITY**: Fixed 4 critical security vulnerabilities identified in comprehensive bug analysis
28
+ - **Enhanced Security**: Comprehensive protection against prototype pollution, ReDoS attacks, and type safety issues
29
+ - **Security-First**: All validators now include security controls while maintaining backwards compatibility
30
+
31
+ ### ๐Ÿ›ก๏ธ Security Fixes Implemented
32
+
33
+ #### **BUG-001: Union Validator Type Safety** โœ… FIXED
34
+ - **Issue**: Constructor name spoofing vulnerability in union validators
35
+ - **Solution**: Replaced constructor name checking with secure feature detection
36
+ - **Impact**: Prevents malicious validator objects from bypassing type checks
37
+ - **Location**: `src/validators/union.ts`
38
+
39
+ #### **BUG-002: Prototype Pollution Prevention** โœ… FIXED
40
+ - **Issue**: Prototype pollution vulnerability in codec utilities
41
+ - **Solution**: Added comprehensive input validation and suspicious content detection
42
+ - **Impact**: Prevents `__proto__`, `constructor`, and `prototype` pollution attacks
43
+ - **Location**: `src/utils/codec-utils.ts`
44
+
45
+ #### **BUG-004: IPv6 ReDoS Prevention** โœ… FIXED
46
+ - **Issue**: Regular Expression Denial of Service (ReDoS) vulnerability in IPv6 validation
47
+ - **Solution**: Replaced complex regex with multi-step validation approach
48
+ - **Impact**: Prevents catastrophic backtracking attacks while maintaining IPv6 support
49
+ - **Location**: `src/validators/string.ts`, `src/coercion/string.ts`
50
+
51
+ #### **BUG-005: Safe String Coercion** โœ… FIXED
52
+ - **Issue**: Unsafe type coercion without length limits or sanitization
53
+ - **Solution**: Added length limits (1M characters) and control character sanitization
54
+ - **Impact**: Prevents DoS attacks and information disclosure through malicious strings
55
+ - **Location**: `src/coercion/string.ts`
56
+
57
+ ### ๐Ÿ“Š Quality Improvements
58
+ - **Test Coverage**: Maintained excellent coverage at **96.55%** with **695 passing tests**
59
+ - **Performance**: All security improvements maintain VLD's performance advantages
60
+ - **Backwards Compatibility**: All changes are fully backwards compatible
61
+ - **Security Testing**: Comprehensive security test suite added with 18 dedicated tests
62
+
63
+ ### ๐Ÿงช Testing & Validation
64
+ - **Security Test Suite**: Added comprehensive security validation tests
65
+ - **Performance Tests**: Verified security fixes don't impact performance
66
+ - **Integration Tests**: Validated compatibility with existing codebases
67
+ - **Memory Tests**: Confirmed no memory leaks with security enhancements
68
+
69
+ ### ๐Ÿ“ Documentation Updates
70
+ - **Security Documentation**: Detailed security analysis reports created
71
+ - **Bug Fix Reports**: Comprehensive documentation of all fixes implemented
72
+ - **Test Coverage**: Updated coverage metrics to reflect new security tests
73
+ - **README**: Updated to reflect latest test coverage and security improvements
74
+
75
+ ### ๐Ÿ”ง Technical Details
76
+ - **Zero Breaking Changes**: All security improvements are backwards compatible
77
+ - **Immutable Architecture**: Security hardening maintains VLD's immutable validator pattern
78
+ - **Type Safety**: Enhanced type checking without compromising TypeScript inference
79
+ - **Error Handling**: Improved error messages for security-related validation failures
80
+
81
+ ## [1.2.0] - 2025-08-24
82
+
83
+ ### ๐ŸŽฏ **100% Test Success Rate Achieved**
84
+ - **569 tests passing** with 0 failures across all test suites
85
+ - **97.3% statement coverage** (up from 97.18%)
86
+ - **93.5% branch coverage**
87
+ - **96.78% function coverage**
88
+ - **97.6% line coverage**
89
+ - All Zod-compatible codec tests now fully passing
90
+
91
+ ### ๐Ÿš€ Major Features Added
92
+
93
+ #### **Codec System - Bidirectional Transformations**
94
+ - **NEW**: Complete codec system for bidirectional data transformations
95
+ - `v.codec()` factory method for creating custom codecs
96
+ - Full encode/decode support with type safety
97
+ - Async codec support with `parseAsync()` and `encodeAsync()` methods
98
+ - Comprehensive error handling for both directions
99
+
100
+ #### **19 Built-in Zod-Compatible Codecs**
101
+
102
+ **String Conversion Codecs:**
103
+ - `stringToNumber` - String โ†” Number with validation
104
+ - `stringToInt` - String โ†” Integer with validation
105
+ - `stringToBigInt` - String โ†” BigInt conversion
106
+ - `numberToBigInt` - Number โ†” BigInt conversion
107
+ - `stringToBoolean` - Flexible string โ†” boolean (`'true'`, `'1'`, `'yes'`, `'on'` โ†’ `true`)
108
+
109
+ **Date Conversion Codecs:**
110
+ - `isoDatetimeToDate` - ISO 8601 string โ†” Date object
111
+ - `epochSecondsToDate` - Unix seconds โ†” Date object
112
+ - `epochMillisToDate` - Unix milliseconds โ†” Date object
113
+
114
+ **JSON and Complex Data:**
115
+ - `jsonCodec()` - Generic JSON string โ†” any type
116
+ - `base64Json()` - Base64-encoded JSON with schema validation
117
+ - `jwtPayload()` - JWT payload decoder (read-only)
118
+
119
+ **URL and Web:**
120
+ - `stringToURL` - String โ†” URL object
121
+ - `stringToHttpURL` - HTTP/HTTPS URL validation and conversion
122
+ - `uriComponent` - URI component encode/decode
123
+
124
+ **Binary Data:**
125
+ - `base64ToBytes` - Base64 โ†” Uint8Array
126
+ - `base64urlToBytes` - URL-safe Base64 โ†” Uint8Array
127
+ - `hexToBytes` - Hexadecimal โ†” Uint8Array
128
+ - `utf8ToBytes` - UTF-8 string โ†” Uint8Array
129
+ - `bytesToUtf8` - Uint8Array โ†” UTF-8 string
130
+
131
+ #### **New Validator Types**
132
+ - `v.base64()` - Base64 string validation with URL-safe mode
133
+ - `v.hex()` - Hexadecimal string validation with lowercase mode
134
+ - `v.uint8Array()` - Uint8Array validation with length constraints
135
+
136
+ #### **Enhanced Utilities**
137
+ - Comprehensive codec utility functions in `codec-utils.ts`
138
+ - Cross-platform Base64 encoding/decoding (Node.js + Browser)
139
+ - Secure error handling for all codec operations
140
+
141
+ ### ๐Ÿ“š Documentation Updates
142
+ - **README.md**: Comprehensive codec documentation with examples
143
+ - **API.md**: Complete codec API reference with TypeScript examples
144
+ - **New Examples**:
145
+ - `examples/codecs.js` - JavaScript codec examples
146
+ - `examples/codecs.ts` - TypeScript codec examples with full type safety
147
+ - Updated CLAUDE.md with codec development guidance
148
+
149
+ ### ๐Ÿ”ง Technical Improvements
150
+ - **Zero Circular Dependencies**: Refactored codec architecture
151
+ - **Full Type Safety**: Complete TypeScript support with inference
152
+ - **97.3% Test Coverage**: Comprehensive test suite with 569 passing tests
153
+ - **Error Message Localization**: All codec errors support 27+ languages
154
+
155
+ ### ๐ŸŽฏ Zod Compatibility
156
+ - **100% Zod Codec Parity**: All Zod codecs implemented and compatible
157
+ - **Beyond Zod**: Additional codecs not available in Zod
158
+ - **Drop-in Replacement**: Seamless migration path from Zod codecs
159
+
160
+ ### Performance
161
+ - **Optimized Transformations**: Efficient bidirectional conversions
162
+ - **Memory Efficient**: Immutable codec architecture prevents leaks
163
+ - **Async Support**: Non-blocking operations for I/O-bound transformations
164
+
8
165
  ## [1.1.1] - 2025-08-18
9
166
 
10
167
  ### Security