@oxog/spark 1.1.1 โ†’ 1.3.0

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 (64) hide show
  1. package/CHANGELOG.md +656 -315
  2. package/LICENSE +20 -20
  3. package/README.md +288 -241
  4. package/package.json +90 -89
  5. package/src/core/application.js +1068 -956
  6. package/src/core/context.js +1098 -830
  7. package/src/core/middleware.js +303 -217
  8. package/src/index.js +183 -280
  9. package/src/middleware/body-parser.js +482 -526
  10. package/src/middleware/cache.js +177 -170
  11. package/src/middleware/compression.js +177 -182
  12. package/src/middleware/cors.js +176 -95
  13. package/src/middleware/health.js +219 -218
  14. package/src/middleware/logger.js +195 -194
  15. package/src/middleware/metrics.js +339 -327
  16. package/src/middleware/rate-limit.js +367 -319
  17. package/src/middleware/security.js +442 -332
  18. package/src/middleware/session.js +647 -529
  19. package/src/middleware/static.js +404 -299
  20. package/src/router/layer.js +197 -117
  21. package/src/router/route.js +149 -123
  22. package/src/router/router.js +705 -755
  23. package/src/utils/async-handler.js +145 -147
  24. package/src/utils/context-pool.js +83 -82
  25. package/src/utils/regex-validator.js +187 -163
  26. package/src/utils/safe-json.js +110 -0
  27. package/types/index.d.ts +538 -291
  28. package/dist/LICENSE +0 -21
  29. package/dist/README.md +0 -242
  30. package/dist/core/application.js +0 -959
  31. package/dist/core/context.js +0 -833
  32. package/dist/core/middleware.js +0 -220
  33. package/dist/core/request.js +0 -335
  34. package/dist/core/response.js +0 -377
  35. package/dist/index.js +0 -280
  36. package/dist/middleware/body-parser.js +0 -528
  37. package/dist/middleware/cache.js +0 -173
  38. package/dist/middleware/compression.js +0 -185
  39. package/dist/middleware/cors.js +0 -97
  40. package/dist/middleware/health.js +0 -221
  41. package/dist/middleware/index.js +0 -23
  42. package/dist/middleware/logger.js +0 -197
  43. package/dist/middleware/metrics.js +0 -330
  44. package/dist/middleware/rate-limit.js +0 -322
  45. package/dist/middleware/security.js +0 -335
  46. package/dist/middleware/session.js +0 -532
  47. package/dist/middleware/static.js +0 -301
  48. package/dist/package.json +0 -62
  49. package/dist/router/layer.js +0 -119
  50. package/dist/router/route.js +0 -125
  51. package/dist/router/router.js +0 -758
  52. package/dist/types/index.d.ts +0 -291
  53. package/dist/utils/async-handler.js +0 -150
  54. package/dist/utils/cache.js +0 -443
  55. package/dist/utils/context-pool.js +0 -85
  56. package/dist/utils/error-types.js +0 -134
  57. package/dist/utils/http.js +0 -415
  58. package/dist/utils/regex-validator.js +0 -166
  59. package/src/core/request.js +0 -335
  60. package/src/core/response.js +0 -377
  61. package/src/middleware/index.js +0 -23
  62. package/src/utils/cache.js +0 -443
  63. package/src/utils/error-types.js +0 -134
  64. package/src/utils/http.js +0 -415
package/CHANGELOG.md CHANGED
@@ -1,316 +1,657 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.1.1] - 2025-08-18
9
-
10
- ### ๐Ÿ› Bug Fixes & Code Quality Improvements
11
-
12
- #### Fixed
13
- - **Code Quality**: Added 'use strict' directives to all source files for better error catching
14
- - **Whitespace Issues**: Removed trailing whitespace in test files
15
- - **Production Logging**: Removed console.log statements from production code
16
- - **Regex Validator**: Fixed async performance check to work synchronously
17
- - **Error Handling**: Improved async error handler to properly emit errors to application
18
- - **Context Pooling**: Verified and maintained proper init() and reset() methods
19
-
20
- #### Added
21
- - **Bug Fix Tests**: Comprehensive test suite to verify all bug fixes
22
- - **Maintenance Scripts**: Added utility scripts for code quality maintenance
23
- - `fix-use-strict.js`: Adds 'use strict' to all source files
24
- - `remove-console-logs.js`: Removes debug logging from production
25
-
26
- #### Security
27
- - No vulnerabilities found in dependencies
28
- - All security tests pass
29
-
30
- ## [1.1.0] - 2025-07-17
31
-
32
- ### ๐Ÿ”ง Production Validation & Bug Fixes
33
-
34
- #### Fixed
35
- - **Router Middleware Bug**: Fixed critical bug where Route HTTP methods only accepted single handlers instead of multiple handlers for middleware composition
36
- - Updated all HTTP methods (get, post, put, delete, etc.) to accept rest parameters (...handlers)
37
- - Fixed middleware chain execution for route-specific middleware
38
- - Ensured proper request flow through middleware stack
39
- - **Session Auto-Save**: Fixed session authentication issues where sessions were being saved after response was sent
40
- - Implemented auto-save functionality in session proxy
41
- - Session data now saves immediately when modified
42
- - Session cookies are set properly during the request lifecycle
43
- - **Port Handling**: Fixed port 0 handling for dynamic port allocation
44
- - Changed from falsy check to explicit undefined check
45
- - Enables proper testing with dynamic port assignment
46
- - **Memory Leak Prevention**: Fixed EventEmitter memory leak warnings in validation tests
47
- - Increased max listeners limit for test environments
48
- - Optimized test iteration counts to prevent memory buildup
49
-
50
- #### Added
51
- - **Complete Production Pipeline**: Comprehensive validation and release preparation system
52
- - 20+ validation checks covering all aspects of production readiness
53
- - Automated testing for all 4 example applications
54
- - Performance benchmarking (4000+ req/sec validated)
55
- - Security vulnerability scanning
56
- - Package size optimization (reduced from 236KB to 65KB)
57
- - Memory leak detection and prevention
58
- - Cross-platform compatibility testing
59
- - **Enhanced Test Coverage**: Achieved 100% test success rate across all components
60
- - Complete test suite for all example applications
61
- - Integration tests for ecommerce API with session authentication
62
- - Unit tests for all middleware components
63
- - Performance and stress testing
64
- - **TypeScript Definitions**: Cleaned and optimized TypeScript definitions
65
- - Self-contained definitions without Node.js dependencies
66
- - Accurate interfaces matching actual implementation
67
- - Fixed method signatures (setCookie vs cookie)
68
- - Enhanced SessionOptions and RateLimitOptions interfaces
69
-
70
- #### Changed
71
- - **Documentation Overhaul**: Completely rewrote all documentation from scratch
72
- - Clean, modern README.md with focused feature highlights
73
- - Comprehensive API Reference with detailed examples
74
- - Step-by-step Getting Started guide with complete tutorials
75
- - Extensive Middleware Guide with advanced patterns and best practices
76
- - Removed unnecessary debug and temporary documentation files
77
- - **Package Optimization**: Streamlined package contents
78
- - Removed debug files and temporary validation artifacts
79
- - Cleaned up development-only files
80
- - Optimized bundle size for production deployment
81
-
82
- #### Improved
83
- - **Error Handling**: Enhanced error messages and validation feedback
84
- - **Performance**: Optimized request handling and middleware execution
85
- - **Security**: Validated all security features are working correctly
86
- - **Reliability**: Extensive testing ensures production-ready stability
87
-
88
- ---
89
-
90
- ## [1.1.0] - 2025-07-16
91
-
92
- ### ๐Ÿ”’ Security Enhancements
93
-
94
- #### Added
95
- - **Path Traversal Protection**: Comprehensive protection against directory traversal attacks in static file middleware
96
- - URL normalization and validation
97
- - Path containment verification
98
- - Malformed URL error handling
99
- - **ReDoS Protection**: Regular Expression Denial of Service protection
100
- - SafeRegexCache with performance testing
101
- - RegexValidator for pattern complexity analysis
102
- - Automatic pattern sanitization for unsafe expressions
103
- - **Header/Cookie Injection Protection**: Prevention of CRLF injection attacks
104
- - Header value validation against null bytes and CRLF characters
105
- - Cookie value sanitization
106
- - Header length limits (8192 characters max)
107
- - **Enhanced Input Validation**: Improved parameter and URL validation throughout the framework
108
-
109
- ### ๐Ÿ›ก๏ธ Memory Management & Performance
110
-
111
- #### Added
112
- - **Memory Leak Protection**: Comprehensive cleanup mechanisms
113
- - Automatic interval cleanup during shutdown
114
- - Cleanup handler registration system
115
- - Graceful shutdown with timeout handling
116
- - **Object Pooling**: Context object reuse for better memory efficiency
117
- - Context.init() and Context.reset() methods
118
- - Reduced garbage collection pressure
119
- - **Buffer Optimizations**: Enhanced memory usage in request handling
120
- - Stream processing improvements
121
- - Optimized string operations
122
-
123
- ### ๐Ÿšจ Error Handling Improvements
124
-
125
- #### Added
126
- - **Advanced Error Handler**: Comprehensive error handling system
127
- - Custom error types with status codes
128
- - AsyncHandler for automatic promise error catching
129
- - Structured error responses with proper HTTP status codes
130
- - Development vs production error detail handling
131
- - **Common HTTP Errors**: Pre-defined error creators
132
- - BadRequest, Unauthorized, Forbidden, NotFound
133
- - MethodNotAllowed, Conflict, TooManyRequests
134
- - InternalServerError, ServiceUnavailable, etc.
135
-
136
- #### Fixed
137
- - **Error Propagation**: Proper error handling through middleware chain
138
- - **Response Formatting**: Consistent error response structure
139
- - **Status Code Handling**: Correct HTTP status codes for different error types
140
-
141
- ### ๐Ÿ”ง Framework Enhancements
142
-
143
- #### Added
144
- - **Enhanced Router**: Improved routing capabilities
145
- - Better path parameter extraction
146
- - Improved route matching performance
147
- - Support for router mounting with path prefixes
148
- - **Middleware Improvements**: Enhanced middleware system
149
- - Better error handling in middleware chain
150
- - Cleanup handler support for middleware
151
- - Improved middleware execution flow
152
-
153
- #### Fixed
154
- - **Case Sensitivity**: Fixed HTTP method handling case sensitivity issues
155
- - **Route Parameters**: Improved parameter extraction and URL decoding
156
- - **Router Mounting**: Fixed app.use() with router and path prefix functionality
157
-
158
- ### ๐Ÿ“ฆ TypeScript & API Improvements
159
-
160
- #### Added
161
- - **Enhanced Type Definitions**: Improved TypeScript support
162
- - Better generic type constraints
163
- - More precise interface definitions
164
- - Enhanced IDE autocomplete support
165
-
166
- ### ๐Ÿงช Testing & Quality
167
-
168
- #### Added
169
- - **Comprehensive Integration Tests**: Full framework testing suite
170
- - Security feature testing
171
- - Memory leak testing
172
- - Error handling validation
173
- - Performance testing
174
- - CORS and middleware testing
175
-
176
- #### Fixed
177
- - **Test Suite**: Stable and reliable testing framework
178
- - **Error Test Coverage**: Complete error handling test coverage
179
-
180
- ### ๐Ÿ”„ Developer Experience
181
-
182
- #### Changed
183
- - **Package.json**: Updated scripts and metadata
184
- - Version bump to 1.1.0
185
- - Updated description highlighting security features
186
- - Added security-related keywords
187
- - Updated test scripts
188
- - **Documentation**: Enhanced code documentation
189
- - Comprehensive JSDoc comments
190
- - Security feature documentation
191
- - API usage examples
192
-
193
- ### ๐Ÿ—๏ธ Internal Improvements
194
-
195
- #### Added
196
- - **Graceful Shutdown**: Proper application shutdown handling
197
- - Signal handling (SIGTERM, SIGINT, SIGBREAK)
198
- - Cleanup handler execution
199
- - Connection draining
200
- - **Error Logging**: Enhanced error logging with context
201
- - **Development Mode**: Better development experience with detailed error reporting
202
-
203
- #### Changed
204
- - **Code Organization**: Improved file structure and module organization
205
- - **Performance Optimizations**: Various micro-optimizations throughout the codebase
206
-
207
- ---
208
-
209
- ## [1.0.0] - 2025-07-15
210
-
211
- ### ๐ŸŽ‰ Initial Release as @oxog/spark
212
-
213
- #### Added
214
- - โœจ Production-ready with comprehensive test suite (434+ tests)
215
- - ๐Ÿ›ก๏ธ Security hardened with OWASP Top 10 compliance
216
- - โšก Blazing fast performance (42,000+ req/sec)
217
- - ๐Ÿ“ Complete TypeScript definitions
218
- - ๐ŸŽฏ Zero dependencies - built on Node.js core
219
- - ๐Ÿ”’ Secure defaults (CORS disabled, CSRF enabled)
220
- - ๐Ÿ’พ Multiple session stores (Memory, File)
221
- - ๐Ÿšฆ Advanced rate limiting strategies
222
- - ๐Ÿ—œ๏ธ Built-in compression support
223
- - ๐Ÿ“Š Comprehensive middleware suite
224
- - ๐Ÿ”ง Developer-friendly with hot reload
225
- - ๐Ÿ“ˆ Production monitoring ready
226
-
227
- #### Security
228
- - ๐Ÿ” Removed all hardcoded secrets
229
- - ๐Ÿ›ก๏ธ Fixed path traversal vulnerabilities
230
- - ๐Ÿ”’ Enhanced CSRF protection
231
- - โœ… Input validation on all user inputs
232
- - ๐Ÿšซ Secure session management
233
-
234
- #### Performance
235
- - ๐Ÿ’จ Sub-millisecond latency (p50: 0.8ms)
236
- - ๐Ÿš€ High throughput (42K+ requests/second)
237
- - ๐Ÿ’พ Low memory footprint (38MB baseline)
238
- - ๐Ÿ“‰ Efficient per-connection memory (<0.1KB)
239
-
240
- #### Developer Experience
241
- - ๐Ÿ› ๏ธ Complete build tooling
242
- - ๐Ÿ“‹ ESLint configuration
243
- - ๐Ÿ“ Comprehensive documentation
244
- - ๐Ÿ’ก Working examples (e-commerce API)
245
- - ๐Ÿงช Extensive test coverage (98.7%)
246
-
247
- ---
248
-
249
- ## Security Advisories
250
-
251
- ### [1.1.0] Security Improvements
252
- - **CVE-2024-SPARK-001**: Fixed path traversal vulnerability in static middleware
253
- - **CVE-2024-SPARK-002**: Added ReDoS protection for regex operations
254
- - **CVE-2024-SPARK-003**: Prevented header/cookie injection attacks
255
- - **CVE-2024-SPARK-004**: Enhanced input validation across all components
256
-
257
- ### Recommendations
258
- - **Upgrade immediately** from version 1.0.0 to 1.1.0 for security fixes
259
- - **Review configurations** to ensure security features are properly enabled
260
- - **Test applications** with the new security features enabled
261
- - **Monitor logs** for any security-related events
262
-
263
- ---
264
-
265
- ## Migration Guide
266
-
267
- ### From 1.0.0 to 1.1.0
268
-
269
- #### Breaking Changes
270
- - None. Version 1.1.0 is fully backward compatible with 1.0.0
271
-
272
- #### New Features Available
273
- 1. **Enhanced Error Handling**:
274
- ```javascript
275
- const { errorHandling } = require('@oxog/spark');
276
-
277
- // Use async handler for automatic error catching
278
- app.get('/users/:id', errorHandling.asyncHandler(async (ctx) => {
279
- const user = await findUser(ctx.params.id);
280
- if (!user) {
281
- throw errorHandling.errors.notFound('User not found');
282
- }
283
- ctx.json(user);
284
- }));
285
- ```
286
-
287
- 2. **Security Features** (automatically enabled):
288
- - Path traversal protection in static middleware
289
- - ReDoS protection in routing
290
- - Header injection protection
291
- - Memory leak protection
292
-
293
- 3. **Graceful Shutdown**:
294
- ```javascript
295
- app.onShutdown(async () => {
296
- await database.close();
297
- console.log('Database connection closed');
298
- });
299
- ```
300
-
301
- #### Recommended Actions
302
- 1. Update package.json to version 1.1.0
303
- 2. Review error handling and consider using new asyncHandler
304
- 3. Test security features in your environment
305
- 4. Add graceful shutdown handlers for your resources
306
-
307
- ---
308
-
309
- ### Links
310
- - ๐Ÿ“ฆ NPM: https://www.npmjs.com/package/@oxog/spark
311
- - ๐Ÿ™ GitHub: https://github.com/ersinkoc/spark
312
- - ๐Ÿ“š Documentation: https://github.com/ersinkoc/spark/tree/main/docs
313
-
314
- ---
315
-
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.3.0] - 2026-12-02
11
+
12
+ ### Changed
13
+ - `engines.node` is now `>=18` (was `>=14.0.0`); CI already tested Node 18 and later only.
14
+ - `"sideEffects": false` is declared, so bundlers can drop unused exports.
15
+ - Errors rethrown from a caught error now carry it as `cause` (`Failed to parse URL`,
16
+ `Invalid redirect URL`, `Invalid regex pattern`, `Invalid JSON`, `Cannot stringify circular
17
+ JSON structure`); messages are unchanged.
18
+
19
+ ### Fixed
20
+ - Types: `Route` is exported as a type only. It was declared as an exported class, so
21
+ `import { Route } from '@oxog/spark'` type-checked but failed at runtime (the class is not
22
+ a runtime export). Found by Are The Types Wrong.
23
+
24
+ ### Internal
25
+ - Tooling: adopted oxog-standard (ESLint 10 with the shared typescript-eslint config, shared
26
+ tsconfig base, managed CI for Node 18 to 26 and Trusted Publishing release workflow,
27
+ packed-archive checks with publint and Are The Types Wrong). Spark stays published as its
28
+ CommonJS sources without a build step.
29
+ - Lint fixes in `src` without runtime effect: unused callback parameters renamed with a `_`
30
+ prefix, two dead initial values removed.
31
+
32
+ ## [1.2.0] - 2026-11-30
33
+
34
+ This release includes the changes listed under 1.1.2, which was never published
35
+ to npm (the last published version is 1.1.1). The test and coverage figures
36
+ quoted for 1.1.2 came from scripts that printed fixed results; this release
37
+ replaces them with a real test suite (145 tests against real HTTP servers,
38
+ enforced coverage thresholds).
39
+
40
+ ### Fixed
41
+
42
+ - **Routing**: any `router.use(fn)` middleware broke every route registered after it
43
+ (the router overwrote `ctx.path` with the matched prefix), so `router.group()` never
44
+ matched either. Middleware mounted with `router.use(path, fn)` now sees the path
45
+ below the prefix, and later layers see the full path.
46
+ - **Routing**: `HEAD` requests to `GET` routes returned 404; they are now answered by
47
+ the `GET` handlers (without a body).
48
+ - **Routing**: `app.use('/api', ...)` and `router.use('/api', ...)` also matched
49
+ `/apiary`; prefixes now match whole path segments.
50
+ - **Routing**: after a handler threw, later matching routes still ran (and could answer
51
+ 200); errors now skip the remaining layers and reach the error handler.
52
+ - **Routing**: malformed percent-encoding in a route parameter (`/users/%E0%A4%A`)
53
+ answered 500; it now answers 400.
54
+ - **Routing**: `router.get()`/`post()`/... returned a `Route`, so chaining
55
+ `router.get(a, h).get(b, h)` threw; they now return the router, as the type
56
+ definitions already said. Routes registered with a trailing slash (`/a/`) now also
57
+ match `/a` unless the router is strict.
58
+ - **Routing**: `app.options(path, handler)` and `router.options(path, handler)` threw
59
+ `TypeError` because the `options` configuration property hid the method; both work
60
+ now and `app.options.port` etc. still read the configuration.
61
+ - **Requests**: a request whose Host header cannot form a URL never got a response
62
+ (and caused an unhandled rejection); it now gets 400.
63
+ - **Errors**: an error whose `status` is not a valid 4xx/5xx code left the request
64
+ hanging; it now answers 500.
65
+ - **Body parser**: errors thrown by later middleware or handlers were caught and
66
+ answered as `400 Bad Request` with the internal error message; they now reach the
67
+ application error handler (500, message hidden in production).
68
+ - **Body parser**: `bodyParser.json()` (and the other fixed-type parsers) rejected every
69
+ bodiless `POST`/`DELETE` and every request of another content type with 400; they now
70
+ skip requests without a body or with a different Content-Type.
71
+ - **Body parser**: `limit` given as a string (`'10kb'`, as the type definitions allow)
72
+ was ignored, so no limit applied; size strings are now parsed.
73
+ - **Body parser**: chunked bodies over the limit answered 400 (multipart/raw reset the
74
+ connection); every oversized body now answers 413 and closes the connection.
75
+ - **Body parser**: multipart uploads corrupted binary files (bytes >= 0x80 were
76
+ re-encoded as UTF-8) and mangled non-ASCII field values; files are now byte-exact and
77
+ fields are decoded as UTF-8. Part headers are matched case-insensitively.
78
+ - **Body parser**: the documented `inflate` option was not implemented; gzip, deflate
79
+ and br request bodies are now decompressed, with the size limit applied after
80
+ decompression (other encodings answer 415).
81
+ - **Static files**: files inside dot-directories were served (`/.git/config`,
82
+ `/.ssh/id_rsa`); every path segment is now checked against the `dotfiles` policy.
83
+ - **Static files**: Range requests answered 200 without `Content-Range`; they now
84
+ answer 206 with correct headers, and unsatisfiable ranges answer 416.
85
+ - **Static files**: files were read fully into memory; they are now streamed with
86
+ backpressure, and client disconnects destroy the file stream.
87
+ - **Rate limiting**: the window never reset, so a client that reached `max` was blocked
88
+ until the process restarted; `X-RateLimit-Reset` was always "now" and `Retry-After`
89
+ was the full window. All three are fixed. The documented `skip` option now works.
90
+ - **CSRF**: tokens were not bound to the client (every token was valid for every user)
91
+ and a token sent only as a cookie was accepted, which browsers attach to cross-site
92
+ requests. Each client now gets its own secret (in the session, or in an HttpOnly
93
+ SameSite=Strict `_csrf` cookie) and tokens are only read from the `x-csrf-token`
94
+ header or `_csrf` body field. Use `ctx.csrfToken()` to issue tokens.
95
+ - **CORS**: responses whose `Access-Control-Allow-Origin` depends on the request did not
96
+ send `Vary: Origin` (shared caches could serve one origin's response to another);
97
+ `origin: true` with `credentials: true` failed every request with 500 instead of
98
+ failing at setup; `origin: true` logged a warning on every request; a function origin
99
+ returning `true` sent `Access-Control-Allow-Origin: true`; all OPTIONS requests were
100
+ swallowed even when not preflights.
101
+ - **Compression**: never compressed `GET` responses (it read the request's
102
+ Content-Type); `compression.gzip()` could send Brotli; `Vary` replaced `Vary: Origin`.
103
+ - **Sessions**: passing any `cookie` option (e.g. `{ maxAge }`) dropped the default
104
+ `HttpOnly`, `SameSite=Lax` and `Path=/` flags, making the session cookie readable by
105
+ scripts. The defaults are now kept.
106
+ - **Sessions**: `MemoryStore` timers kept the process alive for up to `maxAge` (24 h by
107
+ default) after `close()`, and a `maxAge` above ~24.8 days expired sessions
108
+ immediately. Timers are unref'd and capped; expiry is checked on read.
109
+ - **Sessions**: a failing store left the request hanging with an unhandled rejection;
110
+ it now answers 500. `destroy()` clears the cookie with the session cookie's path.
111
+ - **Cookies**: `maxAge` is documented in milliseconds but was sent as `Max-Age` seconds
112
+ unchanged (a "1 hour" cookie lived 41 days); it is now converted to seconds.
113
+ `clearCookie()` now sends `Max-Age=0`.
114
+ - **Redirects**: protocol-relative (`//evil.com`) and backslash (`/\evil.com`) targets
115
+ bypassed the external-redirect check; the `settings` option documented for
116
+ `allowedRedirectDomains`/`allowOpenRedirects`/`trustProxy` was never read, so external
117
+ redirects were impossible to allow. Redirects to the request's own host (http -> https)
118
+ are allowed.
119
+ - **Shutdown**: `close()` left a 10-second timer that kept the process alive, did not
120
+ close idle keep-alive connections on older Node versions, and never terminated hung
121
+ requests. It now closes idle connections immediately, lets in-flight requests finish
122
+ (answering with `Connection: close`), and destroys what is left after
123
+ `shutdownTimeout` (default 10 s).
124
+ - **Process handlers**: every `new Spark()` added `uncaughtException`,
125
+ `unhandledRejection`, `SIGTERM` and `SIGINT` listeners that were never removed, and an
126
+ uncaught exception exited with code 0. Handlers are now installed by `listen()`,
127
+ removed by `close()`, and an uncaught exception exits with code 1.
128
+ - **ESM**: `import { bodyParser, cors, ... } from '@oxog/spark'` failed for everything
129
+ except `Spark`, `App`, `Application`, `Router` and `Context`; all exports are now
130
+ available as named imports.
131
+ - **Types**: the declarations were not resolvable through `exports` (TypeScript
132
+ reported "implicitly has an 'any' type" under `moduleResolution: node16/nodenext`),
133
+ were an ambient `declare module` block, and described a different API in places
134
+ (`listen()` returning a Promise, `createError(status, message)`, missing `static`).
135
+ They are rewritten to match the runtime.
136
+ - **Logger**: hyphenated tokens (`:response-time`, `:content-length`, `:remote-addr`)
137
+ were never replaced, so the default format printed `--time ms`; `:content-length`
138
+ now reports the response length.
139
+ - **Cache middleware**: cached the request body instead of the response, so nothing was
140
+ ever cached; the default store was an unbounded Map. It now caches sent responses
141
+ (not ones that set cookies or are private) in a bounded store.
142
+ - **Health/metrics**: custom health check timeout timers were never cleared; metrics
143
+ tracked unlimited distinct paths (now capped at 1000 plus `(other)`).
144
+ - **errorHandling.errorHandler** sent 5xx messages and stack traces unless
145
+ `NODE_ENV=production`; it now follows the application rule (only in development).
146
+
147
+ ### Added
148
+
149
+ - `ctx.stream(readable)` pipes a stream as the response with backpressure.
150
+ - Application options `settings`, `shutdownTimeout` and `handleSignals`.
151
+ - Top-level exports `csrf`, `csrfToken`, `serveStatic`, `cache`, `asyncHandler`,
152
+ `createError`, `errors` and `version`.
153
+ - `compression({ encodings })`, `staticFiles({ dotfiles: 'allow' | 'deny' | 'ignore' })`,
154
+ `If-Modified-Since` support, RegExp entries in `cors({ origin: [...] })`.
155
+
156
+ ### Changed
157
+
158
+ - The constructor no longer pretends to configure security: the `security` option
159
+ (CORS, CSRF, rate limit, helmet "secure defaults") was never applied and has been
160
+ removed from the documented defaults. Register the middleware with `app.use()`.
161
+ - `app.use()` throws a `TypeError` for arguments that are neither middleware nor a
162
+ router (they were silently ignored).
163
+ - `ctx.redirect()` only redirects to other hosts over http/https (`mailto:` and other
164
+ schemes are refused).
165
+ - The CSRF `_csrf` cookie now holds the client secret, not a token.
166
+ - Static files are sent with `charset=utf-8` for text types, `Accept-Ranges: bytes`,
167
+ and directory redirects keep the mount path.
168
+ - Malformed cookies are no longer logged with `console.error` for every request.
169
+ - Removed modules that were never reachable through the package `exports`
170
+ (`core/request.js`, `core/response.js`, `utils/http.js`, `utils/cache.js`,
171
+ `utils/error-types.js`, `middleware/index.js`) and the stale `dist/` copy that 1.1.1
172
+ shipped.
173
+
174
+ ### Tooling
175
+
176
+ - Real test suite (Vitest, real HTTP requests on ephemeral ports) with enforced coverage
177
+ thresholds; ESLint over `src`, `tests` and `scripts`; TypeScript checks of the
178
+ declarations and README examples; `npm run test:package` packs the archive, installs
179
+ it and imports/type-checks it under ESM, CommonJS and NodeNext.
180
+ - CI on Node 18-24; npm publishing moved to a manual trusted-publishing workflow.
181
+
182
+ ## [1.1.2] - 2025-11-17
183
+
184
+ ### ๐Ÿ”’ Major Security Release - 16 Critical Bug Fixes
185
+
186
+ This release addresses **16 security vulnerabilities and critical bugs** identified through comprehensive repository analysis. All CRITICAL and HIGH priority issues have been resolved.
187
+
188
+ #### ๐Ÿ”ด CRITICAL Security Fixes (5)
189
+
190
+ - **[SECURITY]** Replaced MD5 with SHA-256 for ETag generation to prevent hash collision attacks
191
+ - Files: `src/middleware/static.js`, `src/core/middleware.js`
192
+ - Impact: Prevents cache poisoning via collision attacks
193
+
194
+ - **[SECURITY]** Added JSON parsing depth and size limits to prevent DoS attacks
195
+ - New utility: `src/utils/safe-json.js`
196
+ - Files: `src/core/request.js`, `src/middleware/body-parser.js`
197
+ - Limits: Maximum 20 nesting levels, 1MB-10MB configurable size
198
+ - Impact: Prevents memory exhaustion and CPU DoS via deeply nested JSON
199
+
200
+ - **[SECURITY]** Added query string size limits and prototype pollution protection
201
+ - File: `src/utils/http.js`
202
+ - Limit: 1MB maximum query string size
203
+ - Protection: Null-prototype objects, blocked `__proto__`, `constructor`, `prototype` keys
204
+ - Impact: Prevents memory exhaustion DoS and prototype pollution attacks
205
+
206
+ - **[BUG]** Fixed division by zero in metrics calculation
207
+ - File: `src/middleware/metrics.js`
208
+ - Impact: Prevents Infinity/NaN when metrics accessed immediately after startup
209
+
210
+ - **[BUG]** Fixed LRU eviction logic in rate limiter (was using FIFO instead of LRU)
211
+ - File: `src/middleware/rate-limit.js`
212
+ - Impact: Prevents memory leaks and improves cache efficiency
213
+
214
+ #### ๐ŸŸ  HIGH Priority Fixes (4)
215
+
216
+ - **[BUG]** Fixed cache middleware not sending responses (complete feature failure)
217
+ - File: `src/middleware/cache.js`
218
+ - Impact: Cache middleware now functional - previously cached responses were never sent to clients
219
+
220
+ - **[SECURITY]** Fixed timing attack in basic authentication
221
+ - File: `src/core/middleware.js`
222
+ - Uses `crypto.timingSafeEqual()` for constant-time password comparison
223
+ - Impact: Prevents character-by-character password enumeration via timing side-channel
224
+
225
+ - **[BUG]** Fixed session save race condition
226
+ - File: `src/middleware/session.js`
227
+ - Added mutex flag (`isSaving`) to prevent concurrent saves
228
+ - Impact: Prevents session data loss from rapid property modifications
229
+
230
+ - **[BUG]** Fixed event listener memory leaks on application shutdown
231
+ - File: `src/core/application.js`
232
+ - Properly removes SIGTERM/SIGINT/SIGBREAK handlers
233
+ - Impact: Prevents listener accumulation in test environments and long-running applications
234
+
235
+ #### ๐ŸŸก MEDIUM Priority Fixes (7)
236
+
237
+ - **[BUG]** Fixed timeout resource leak in static file serving
238
+ - File: `src/middleware/static.js`
239
+ - Clears timeout when promise resolves
240
+ - Impact: Prevents timeout handle accumulation
241
+
242
+ - **[BUG]** Fixed type coercion in status code validation
243
+ - File: `src/core/context.js`
244
+ - Strict integer validation, rejects inputs like "200abc"
245
+ - Impact: Catches programming errors, prevents invalid status codes
246
+
247
+ - **[SECURITY]** Fixed URL-encoded path traversal bypass
248
+ - File: `src/middleware/static.js`
249
+ - Double-decode to catch attacks like `%252e%252e`
250
+ - Checks for traversal patterns after decoding
251
+ - Impact: Prevents directory traversal via URL encoding
252
+
253
+ - **[SECURITY]** Fixed information disclosure in error messages
254
+ - File: `src/core/application.js`
255
+ - Generic error messages for 5xx in production
256
+ - Stack traces only in development with explicit flag
257
+ - Impact: Prevents exposure of file paths, internal structure, and sensitive data
258
+
259
+ - **[SECURITY]** Fixed unvalidated redirect destinations (open redirect)
260
+ - File: `src/core/context.js`
261
+ - Blocks dangerous protocols: `javascript:`, `data:`, `vbscript:`, `file:`, `about:`
262
+ - Requires `allowedRedirectDomains` whitelist or explicit `allowOpenRedirects: true`
263
+ - Impact: Prevents open redirect attacks and XSS via protocol injection
264
+
265
+ - **[SECURITY]** Added cookie length validation
266
+ - File: `src/core/context.js`
267
+ - Cookie name max: 256 bytes, Cookie value max: 4096 bytes
268
+ - Impact: Prevents header size limit attacks
269
+
270
+ - **[BUG]** Fixed SameSite empty string edge case
271
+ - File: `src/core/context.js`
272
+ - Validates length before charAt() transformation
273
+ - Impact: Prevents runtime errors from malformed cookie options
274
+
275
+ #### ๐Ÿ†• Added
276
+
277
+ - **Safe JSON Parser Utility** (`src/utils/safe-json.js`)
278
+ - Validates JSON depth (prevents stack overflow)
279
+ - Validates JSON size (prevents memory exhaustion)
280
+ - Detects circular references
281
+ - Reusable across the framework
282
+
283
+ #### ๐Ÿ“š Documentation
284
+
285
+ - Added `COMPREHENSIVE_BUG_ANALYSIS_AND_FIX_REPORT_2025_11_17.md` - Complete analysis of 99+ identified issues
286
+ - Added `FINAL_BUG_FIX_SUMMARY_2025_11_17.md` - Summary of first 12 fixes
287
+ - Added `COMPLETE_BUG_FIX_REPORT_2025_11_17.md` - Comprehensive report of all 16 fixes with deployment guide
288
+
289
+ #### โš™๏ธ Configuration
290
+
291
+ New security settings available:
292
+
293
+ ```javascript
294
+ const app = new Spark({
295
+ settings: {
296
+ // External redirect control (prevents open redirects)
297
+ allowedRedirectDomains: ['yourdomain.com'], // Whitelist (recommended)
298
+ // OR
299
+ allowOpenRedirects: true, // Explicit opt-in (not recommended)
300
+ }
301
+ });
302
+
303
+ // Control error message exposure
304
+ process.env.NODE_ENV = 'production'; // Hides sensitive errors
305
+ process.env.EXPOSE_STACK_TRACES = 'false'; // Disables stack traces even in dev
306
+ ```
307
+
308
+ #### ๐Ÿงช Testing
309
+
310
+ - All tests passing: 34/34 (100% success rate)
311
+ - Test coverage: 100% maintained
312
+ - No breaking changes introduced
313
+ - All examples functional
314
+
315
+ #### ๐Ÿ›ก๏ธ Security Impact
316
+
317
+ **Attack Vectors Eliminated:**
318
+ - โœ… Hash collision attacks (MD5 โ†’ SHA-256)
319
+ - โœ… JSON depth/size DoS (limits enforced)
320
+ - โœ… Query string DoS (1MB limit)
321
+ - โœ… Prototype pollution (dangerous keys blocked)
322
+ - โœ… Timing attacks (constant-time comparisons)
323
+ - โœ… Path traversal via encoding (double-decode protection)
324
+ - โœ… Cache poisoning (functional cache + SHA-256)
325
+ - โœ… Open redirects (protocol + whitelist validation)
326
+ - โœ… Information disclosure (sanitized error messages)
327
+
328
+ **Risk Reduction:**
329
+ - Before: 10 active security vulnerabilities
330
+ - After: 0 critical immediate threats
331
+ - Overall: 100% of critical/high security bugs eliminated
332
+
333
+ #### โš ๏ธ Breaking Changes
334
+
335
+ **None** - All changes are backwards compatible. However, some behaviors are now more strict:
336
+
337
+ - External redirects now require `allowedRedirectDomains` configuration or explicit `allowOpenRedirects: true`
338
+ - Production error messages are now generic for 5xx errors (use `NODE_ENV=development` for detailed errors)
339
+ - Cookie names/values have length limits (256/4096 bytes respectively)
340
+
341
+ #### ๐Ÿ“ฆ Upgrade Notes
342
+
343
+ This is a **recommended security upgrade** for all users. No code changes required, but review the new security configurations for optimal protection.
344
+
345
+ See `COMPLETE_BUG_FIX_REPORT_2025_11_17.md` for detailed production deployment guide.
346
+
347
+ ---
348
+
349
+ ## [1.1.1] - 2025-08-18
350
+
351
+ ### ๐Ÿ› Bug Fixes & Code Quality Improvements
352
+
353
+ #### Fixed
354
+ - **Code Quality**: Added 'use strict' directives to all source files for better error catching
355
+ - **Whitespace Issues**: Removed trailing whitespace in test files
356
+ - **Production Logging**: Removed console.log statements from production code
357
+ - **Regex Validator**: Fixed async performance check to work synchronously
358
+ - **Error Handling**: Improved async error handler to properly emit errors to application
359
+ - **Context Pooling**: Verified and maintained proper init() and reset() methods
360
+
361
+ #### Added
362
+ - **Bug Fix Tests**: Comprehensive test suite to verify all bug fixes
363
+ - **Maintenance Scripts**: Added utility scripts for code quality maintenance
364
+ - `fix-use-strict.js`: Adds 'use strict' to all source files
365
+ - `remove-console-logs.js`: Removes debug logging from production
366
+
367
+ #### Security
368
+ - No vulnerabilities found in dependencies
369
+ - All security tests pass
370
+
371
+ ## [1.1.0] - 2025-07-17
372
+
373
+ ### ๐Ÿ”ง Production Validation & Bug Fixes
374
+
375
+ #### Fixed
376
+ - **Router Middleware Bug**: Fixed critical bug where Route HTTP methods only accepted single handlers instead of multiple handlers for middleware composition
377
+ - Updated all HTTP methods (get, post, put, delete, etc.) to accept rest parameters (...handlers)
378
+ - Fixed middleware chain execution for route-specific middleware
379
+ - Ensured proper request flow through middleware stack
380
+ - **Session Auto-Save**: Fixed session authentication issues where sessions were being saved after response was sent
381
+ - Implemented auto-save functionality in session proxy
382
+ - Session data now saves immediately when modified
383
+ - Session cookies are set properly during the request lifecycle
384
+ - **Port Handling**: Fixed port 0 handling for dynamic port allocation
385
+ - Changed from falsy check to explicit undefined check
386
+ - Enables proper testing with dynamic port assignment
387
+ - **Memory Leak Prevention**: Fixed EventEmitter memory leak warnings in validation tests
388
+ - Increased max listeners limit for test environments
389
+ - Optimized test iteration counts to prevent memory buildup
390
+
391
+ #### Added
392
+ - **Complete Production Pipeline**: Comprehensive validation and release preparation system
393
+ - 20+ validation checks covering all aspects of production readiness
394
+ - Automated testing for all 4 example applications
395
+ - Performance benchmarking (4000+ req/sec validated)
396
+ - Security vulnerability scanning
397
+ - Package size optimization (reduced from 236KB to 65KB)
398
+ - Memory leak detection and prevention
399
+ - Cross-platform compatibility testing
400
+ - **Enhanced Test Coverage**: Achieved 100% test success rate across all components
401
+ - Complete test suite for all example applications
402
+ - Integration tests for ecommerce API with session authentication
403
+ - Unit tests for all middleware components
404
+ - Performance and stress testing
405
+ - **TypeScript Definitions**: Cleaned and optimized TypeScript definitions
406
+ - Self-contained definitions without Node.js dependencies
407
+ - Accurate interfaces matching actual implementation
408
+ - Fixed method signatures (setCookie vs cookie)
409
+ - Enhanced SessionOptions and RateLimitOptions interfaces
410
+
411
+ #### Changed
412
+ - **Documentation Overhaul**: Completely rewrote all documentation from scratch
413
+ - Clean, modern README.md with focused feature highlights
414
+ - Comprehensive API Reference with detailed examples
415
+ - Step-by-step Getting Started guide with complete tutorials
416
+ - Extensive Middleware Guide with advanced patterns and best practices
417
+ - Removed unnecessary debug and temporary documentation files
418
+ - **Package Optimization**: Streamlined package contents
419
+ - Removed debug files and temporary validation artifacts
420
+ - Cleaned up development-only files
421
+ - Optimized bundle size for production deployment
422
+
423
+ #### Improved
424
+ - **Error Handling**: Enhanced error messages and validation feedback
425
+ - **Performance**: Optimized request handling and middleware execution
426
+ - **Security**: Validated all security features are working correctly
427
+ - **Reliability**: Extensive testing ensures production-ready stability
428
+
429
+ ---
430
+
431
+ ## [1.1.0] - 2025-07-16
432
+
433
+ ### ๐Ÿ”’ Security Enhancements
434
+
435
+ #### Added
436
+ - **Path Traversal Protection**: Comprehensive protection against directory traversal attacks in static file middleware
437
+ - URL normalization and validation
438
+ - Path containment verification
439
+ - Malformed URL error handling
440
+ - **ReDoS Protection**: Regular Expression Denial of Service protection
441
+ - SafeRegexCache with performance testing
442
+ - RegexValidator for pattern complexity analysis
443
+ - Automatic pattern sanitization for unsafe expressions
444
+ - **Header/Cookie Injection Protection**: Prevention of CRLF injection attacks
445
+ - Header value validation against null bytes and CRLF characters
446
+ - Cookie value sanitization
447
+ - Header length limits (8192 characters max)
448
+ - **Enhanced Input Validation**: Improved parameter and URL validation throughout the framework
449
+
450
+ ### ๐Ÿ›ก๏ธ Memory Management & Performance
451
+
452
+ #### Added
453
+ - **Memory Leak Protection**: Comprehensive cleanup mechanisms
454
+ - Automatic interval cleanup during shutdown
455
+ - Cleanup handler registration system
456
+ - Graceful shutdown with timeout handling
457
+ - **Object Pooling**: Context object reuse for better memory efficiency
458
+ - Context.init() and Context.reset() methods
459
+ - Reduced garbage collection pressure
460
+ - **Buffer Optimizations**: Enhanced memory usage in request handling
461
+ - Stream processing improvements
462
+ - Optimized string operations
463
+
464
+ ### ๐Ÿšจ Error Handling Improvements
465
+
466
+ #### Added
467
+ - **Advanced Error Handler**: Comprehensive error handling system
468
+ - Custom error types with status codes
469
+ - AsyncHandler for automatic promise error catching
470
+ - Structured error responses with proper HTTP status codes
471
+ - Development vs production error detail handling
472
+ - **Common HTTP Errors**: Pre-defined error creators
473
+ - BadRequest, Unauthorized, Forbidden, NotFound
474
+ - MethodNotAllowed, Conflict, TooManyRequests
475
+ - InternalServerError, ServiceUnavailable, etc.
476
+
477
+ #### Fixed
478
+ - **Error Propagation**: Proper error handling through middleware chain
479
+ - **Response Formatting**: Consistent error response structure
480
+ - **Status Code Handling**: Correct HTTP status codes for different error types
481
+
482
+ ### ๐Ÿ”ง Framework Enhancements
483
+
484
+ #### Added
485
+ - **Enhanced Router**: Improved routing capabilities
486
+ - Better path parameter extraction
487
+ - Improved route matching performance
488
+ - Support for router mounting with path prefixes
489
+ - **Middleware Improvements**: Enhanced middleware system
490
+ - Better error handling in middleware chain
491
+ - Cleanup handler support for middleware
492
+ - Improved middleware execution flow
493
+
494
+ #### Fixed
495
+ - **Case Sensitivity**: Fixed HTTP method handling case sensitivity issues
496
+ - **Route Parameters**: Improved parameter extraction and URL decoding
497
+ - **Router Mounting**: Fixed app.use() with router and path prefix functionality
498
+
499
+ ### ๐Ÿ“ฆ TypeScript & API Improvements
500
+
501
+ #### Added
502
+ - **Enhanced Type Definitions**: Improved TypeScript support
503
+ - Better generic type constraints
504
+ - More precise interface definitions
505
+ - Enhanced IDE autocomplete support
506
+
507
+ ### ๐Ÿงช Testing & Quality
508
+
509
+ #### Added
510
+ - **Comprehensive Integration Tests**: Full framework testing suite
511
+ - Security feature testing
512
+ - Memory leak testing
513
+ - Error handling validation
514
+ - Performance testing
515
+ - CORS and middleware testing
516
+
517
+ #### Fixed
518
+ - **Test Suite**: Stable and reliable testing framework
519
+ - **Error Test Coverage**: Complete error handling test coverage
520
+
521
+ ### ๐Ÿ”„ Developer Experience
522
+
523
+ #### Changed
524
+ - **Package.json**: Updated scripts and metadata
525
+ - Version bump to 1.1.0
526
+ - Updated description highlighting security features
527
+ - Added security-related keywords
528
+ - Updated test scripts
529
+ - **Documentation**: Enhanced code documentation
530
+ - Comprehensive JSDoc comments
531
+ - Security feature documentation
532
+ - API usage examples
533
+
534
+ ### ๐Ÿ—๏ธ Internal Improvements
535
+
536
+ #### Added
537
+ - **Graceful Shutdown**: Proper application shutdown handling
538
+ - Signal handling (SIGTERM, SIGINT, SIGBREAK)
539
+ - Cleanup handler execution
540
+ - Connection draining
541
+ - **Error Logging**: Enhanced error logging with context
542
+ - **Development Mode**: Better development experience with detailed error reporting
543
+
544
+ #### Changed
545
+ - **Code Organization**: Improved file structure and module organization
546
+ - **Performance Optimizations**: Various micro-optimizations throughout the codebase
547
+
548
+ ---
549
+
550
+ ## [1.0.0] - 2025-07-15
551
+
552
+ ### ๐ŸŽ‰ Initial Release as @oxog/spark
553
+
554
+ #### Added
555
+ - โœจ Production-ready with comprehensive test suite (434+ tests)
556
+ - ๐Ÿ›ก๏ธ Security hardened with OWASP Top 10 compliance
557
+ - โšก Blazing fast performance (42,000+ req/sec)
558
+ - ๐Ÿ“ Complete TypeScript definitions
559
+ - ๐ŸŽฏ Zero dependencies - built on Node.js core
560
+ - ๐Ÿ”’ Secure defaults (CORS disabled, CSRF enabled)
561
+ - ๐Ÿ’พ Multiple session stores (Memory, File)
562
+ - ๐Ÿšฆ Advanced rate limiting strategies
563
+ - ๐Ÿ—œ๏ธ Built-in compression support
564
+ - ๐Ÿ“Š Comprehensive middleware suite
565
+ - ๐Ÿ”ง Developer-friendly with hot reload
566
+ - ๐Ÿ“ˆ Production monitoring ready
567
+
568
+ #### Security
569
+ - ๐Ÿ” Removed all hardcoded secrets
570
+ - ๐Ÿ›ก๏ธ Fixed path traversal vulnerabilities
571
+ - ๐Ÿ”’ Enhanced CSRF protection
572
+ - โœ… Input validation on all user inputs
573
+ - ๐Ÿšซ Secure session management
574
+
575
+ #### Performance
576
+ - ๐Ÿ’จ Sub-millisecond latency (p50: 0.8ms)
577
+ - ๐Ÿš€ High throughput (42K+ requests/second)
578
+ - ๐Ÿ’พ Low memory footprint (38MB baseline)
579
+ - ๐Ÿ“‰ Efficient per-connection memory (<0.1KB)
580
+
581
+ #### Developer Experience
582
+ - ๐Ÿ› ๏ธ Complete build tooling
583
+ - ๐Ÿ“‹ ESLint configuration
584
+ - ๐Ÿ“ Comprehensive documentation
585
+ - ๐Ÿ’ก Working examples (e-commerce API)
586
+ - ๐Ÿงช Extensive test coverage (98.7%)
587
+
588
+ ---
589
+
590
+ ## Security Advisories
591
+
592
+ ### [1.1.0] Security Improvements
593
+ - **CVE-2024-SPARK-001**: Fixed path traversal vulnerability in static middleware
594
+ - **CVE-2024-SPARK-002**: Added ReDoS protection for regex operations
595
+ - **CVE-2024-SPARK-003**: Prevented header/cookie injection attacks
596
+ - **CVE-2024-SPARK-004**: Enhanced input validation across all components
597
+
598
+ ### Recommendations
599
+ - **Upgrade immediately** from version 1.0.0 to 1.1.0 for security fixes
600
+ - **Review configurations** to ensure security features are properly enabled
601
+ - **Test applications** with the new security features enabled
602
+ - **Monitor logs** for any security-related events
603
+
604
+ ---
605
+
606
+ ## Migration Guide
607
+
608
+ ### From 1.0.0 to 1.1.0
609
+
610
+ #### Breaking Changes
611
+ - None. Version 1.1.0 is fully backward compatible with 1.0.0
612
+
613
+ #### New Features Available
614
+ 1. **Enhanced Error Handling**:
615
+ ```javascript
616
+ const { errorHandling } = require('@oxog/spark');
617
+
618
+ // Use async handler for automatic error catching
619
+ app.get('/users/:id', errorHandling.asyncHandler(async (ctx) => {
620
+ const user = await findUser(ctx.params.id);
621
+ if (!user) {
622
+ throw errorHandling.errors.notFound('User not found');
623
+ }
624
+ ctx.json(user);
625
+ }));
626
+ ```
627
+
628
+ 2. **Security Features** (automatically enabled):
629
+ - Path traversal protection in static middleware
630
+ - ReDoS protection in routing
631
+ - Header injection protection
632
+ - Memory leak protection
633
+
634
+ 3. **Graceful Shutdown**:
635
+ ```javascript
636
+ app.onShutdown(async () => {
637
+ await database.close();
638
+ console.log('Database connection closed');
639
+ });
640
+ ```
641
+
642
+ #### Recommended Actions
643
+ 1. Update package.json to version 1.1.0
644
+ 2. Review error handling and consider using new asyncHandler
645
+ 3. Test security features in your environment
646
+ 4. Add graceful shutdown handlers for your resources
647
+
648
+ ---
649
+
650
+ ### Links
651
+ - ๐Ÿ“ฆ NPM: https://www.npmjs.com/package/@oxog/spark
652
+ - ๐Ÿ™ GitHub: https://github.com/ersinkoc/spark
653
+ - ๐Ÿ“š Documentation: https://github.com/ersinkoc/spark/tree/main/docs
654
+
655
+ ---
656
+
316
657
  Made with โค๏ธ by Ersin Koรง