i18ntk 2.5.1 → 2.6.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,366 @@
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
+ ## [2.6.0] - 2026-05-03
9
+
10
+ ### Security
11
+ - **CRITICAL**: Fixed 8+ silent-write failures where `safeWriteFileSync` was called without basePath parameter across `utils/config.js`, `utils/config-helper.js`, `utils/secure-errors.js`, and `main/i18ntk-scanner.js`.
12
+ - Replaced all raw `fs` calls (`readdirSync`, `statSync`, `mkdirSync`, `unlinkSync`, `rmSync`) with `SecurityUtils` wrappers in `main/i18ntk-validate.js`, `main/i18ntk-scanner.js`, `main/manage/commands/FixerCommand.js`, and `utils/secure-errors.js`.
13
+ - Fixed path traversal checks in `security.js` and `config-manager.js` — replaced fragile `path.sep`-based comparison with robust `startsWith('..')` prefix check.
14
+ - Hardened `utils/i18n-helper.js` fallback `SecurityUtils` implementation with path containment checks.
15
+ - Fixed `SecurityUtils.safeParseJSON` reference leak — deep-clones objects instead of returning caller's reference.
16
+
17
+ ### Fixed
18
+ - Fixed `main/i18ntk-analyze.js` `this.adminAuth` reference error (local variable was not assigned to instance property).
19
+ - Fixed `main/i18ntk-validate.js` `ExitCodes.CONFIG_ERROR` referenced before declaration.
20
+ - Fixed `main/i18ntk-scanner.js` `fs.readdirSync(projectRoot, { recursive: true })` removed (unsupported in older Node.js).
21
+ - Fixed `main/i18ntk-scanner.js` raw `fs.readdirSync`/`fs.statSync`/`fs.mkdirSync` in `scanDirectory` and `generateReport`.
22
+ - Fixed `main/i18ntk-validate.js` raw `fs.readdirSync`/`fs.mkdirSync`/`fs.unlinkSync` in `getAvailableLanguages`, `getLanguageFiles`, and validation report cleanup.
23
+ - Fixed `utils/secure-errors.js` `safeWriteFileSync` missing basePath and raw `fs.mkdirSync`.
24
+ - Fixed `main/manage/commands/FixerCommand.js` `cleanupOldBackups` using raw `fs.rmSync` without path validation.
25
+ - Fixed `runtime/enhanced.js` process event handler leak (multiple instances) and missing `setInterval.unref()`.
26
+ - Fixed `utils/setup-enforcer.js` async Promise executor anti-pattern.
27
+ - Fixed `utils/config-manager.js` stale `process.cwd()` capture at module load time.
28
+ - Fixed `utils/config-manager.js` `ensureProjectSettingsDir` being a no-op.
29
+ - Fixed `utils/config-helper.js` 7 `safeWriteFileSync` calls missing basePath in `initializeSourceFiles`.
30
+ - Fixed `utils/env-manager.js` `getBoolean` comparison against non-boolean values.
31
+ - Fixed `utils/admin-auth.js` `uncaughtException` handler wrong parameter format.
32
+
33
+ ### Added
34
+ - `SecurityUtils.safeUnlinkSync(filePath, basePath)` — safely delete a file.
35
+ - `SecurityUtils.safeRmdirSync(dirPath, basePath)` — safely remove a directory.
36
+
37
+ ### Changed
38
+ - `configManager.resolvePaths`, `configManager.toRelative`, and config lock path now dynamically resolve via `getUserProjectRoot()`/`getProjectConfigPath()`.
39
+ - `configManager.CONFIG_PATH` is now a getter that dynamically returns the project config path.
40
+ - `configManager.migrateLegacyIfNeeded` exported for testability.
41
+
42
+ ### TypeScript
43
+ - Fixed `runtime/i18ntk.d.ts` `BasicI18nRuntime.translate` and `t` return types from `Promise<string>` to `string`.
44
+
45
+ ### Scripts
46
+ - Fixed `scripts/build-public-package.js` and `scripts/reset-release-state.js` `npm_execpath` fallback for missing env var.
47
+ - Fixed `scripts/lint-locales.js` BOM handling and try-catch for `fs.readdirSync`.
48
+
49
+ ## [2.5.1] - 2026-04-29
50
+
51
+ ### Security
52
+ - Fixed `AdminAuth.verifyPin()` to fail closed when admin config is missing, disabled, or malformed instead of returning success.
53
+ - Fixed auth-required checks to fail closed when settings require admin PIN protection but the admin config is unusable.
54
+ - Normalized admin session expiry handling by storing both `expires` and `expiresAt` and cleaning up both formats consistently.
55
+
56
+ ### Added
57
+ - Added regression tests for admin PIN fail-closed behavior and session expiry cleanup.
58
+
59
+ ### Changed
60
+ - Documented the public npm package staging flow introduced after `2.5.0`.
61
+
62
+ ## [2.5.0] - 2026-04-29
63
+
64
+ ### Security
65
+ - Centralized environment-variable access behind the `utils/env-manager.js` allowlist.
66
+ - Hardened `SecurityUtils.safeJoin()` and path validation against sibling-prefix containment bypasses.
67
+ - Switched admin PIN hash verification to timing-safe comparison.
68
+ - Fixed expired admin session cleanup and unref'd the cleanup timer so it does not keep CLI processes alive.
69
+ - Expanded the release security scanner to inspect nested production source files.
70
+
71
+ ### Fixed
72
+ - Fixed the manager fixer command so applied fixes are written to the same parsed object that is saved.
73
+ - Fixed fixer writes for absolute source directories outside the current working directory.
74
+ - Fixed debug-menu file reads to use `SecurityUtils` wrappers.
75
+ - Fixed `secure-errors` to import its `SecurityUtils` dependency explicitly.
76
+
77
+ ### Changed
78
+ - Updated package and documentation metadata to `2.5.0`.
79
+
80
+ ## [2.4.0] - 2026-04-16
81
+
82
+ ### Changed
83
+ - Disabled npm registry update-check behavior in CLI startup paths.
84
+ - Disabled manager-route backup execution (`i18ntk --command=backup`); standalone `i18ntk-backup` remains available.
85
+ - Disabled setup prerequisite command probing via `PATH` inspection.
86
+ - Updated README/docs/migration guides/environment variable documentation to reflect the above behavior.
87
+
88
+ ## [2.3.8] - 2026-04-13
89
+
90
+ ### Added
91
+ - Added centralized structured logger with standardized prefixes and configurable levels (`error`, `warn`, `info`, `debug`).
92
+ - Added opt-in JSON log output for CI/build pipelines via `JSON_LOG=true`.
93
+ - Added missing-translation-key cache TTL (5 minutes) to prevent repeated key-miss spam.
94
+ - Added build/worker logging utilities for percentage progress and pooled worker activity summaries.
95
+ - Added test coverage for logger timing/progress/worker aggregation behavior.
96
+
97
+ ### Fixed
98
+ - Fixed repeated default-configuration fallback output by emitting a single fallback notice per process.
99
+ - Fixed recursive security/i18n logging interactions that could trigger repeated warning cascades.
100
+ - Fixed false-positive security warnings for internal package/project absolute paths through internal root whitelisting.
101
+
102
+ ### Changed
103
+ - Logging is now silent by default for non-critical output in production-like builds unless `DEBUG_MODE=true`.
104
+ - Security warning reasons now use specific detection details instead of generic "dangerous patterns".
105
+ - Updated package/docs/version metadata to `2.3.8`.
106
+
107
+ ## [2.3.7] - 2026-04-12
108
+
109
+ ### Fixed
110
+ - Removed false-positive path traversal warnings for safe absolute project paths during framework builds.
111
+ - Reduced repeated default-configuration console noise in multi-worker build environments.
112
+
113
+ ### Changed
114
+ - Security event console logging is now fully opt-in via `I18NTK_ENABLE_SECURITY_LOGS=true` (or debug envs).
115
+ - Config-manager diagnostic console logging is now fully opt-in via `I18NTK_ENABLE_LOGS=true` (or debug envs).
116
+ - Updated docs to reflect new default-silent logging behavior and troubleshooting toggles.
117
+
118
+ ## [2.3.6] - 2026-04-12
119
+
120
+ ### Security
121
+ - **Fixed path traversal vulnerability** in temporary file creation
122
+ - **Added `safeJoin` function** for secure path construction
123
+ - **Improved path validation** throughout the codebase
124
+
125
+ ### Fixed
126
+ - Hardened settings reset and backup cleanup paths to reduce risk of broad/deep unintended file deletion.
127
+ - Hardened backup command path handling to keep source/output/restore operations inside project boundaries by default.
128
+ - Fixed backup-class async file operations to consistently use `fs.promises` APIs.
129
+
130
+ ### Changed
131
+ - **Silent security logging by default**: Info-level messages suppressed, warnings/errors shown
132
+ - **Debug mode**: Enable verbose logging with `I18N_DEBUG=true`
133
+ - **Centralized security logging**: All security events use `SecurityUtils.logSecurityEvent()`
134
+ - Made npm registry update checks explicit opt-in via `I18NTK_ENABLE_UPDATE_CHECK`.
135
+ - Updated package/docs/version metadata to `2.3.6`.
136
+
137
+ ## [2.3.4] - 2026-04-12
138
+
139
+ ### Fixed
140
+ - Fixed runtime autosave behavior so configuration write failures no longer hard-throw through request/render paths.
141
+ - Fixed config save race resilience by combining queued writes, cross-process lock files, and unique temp filenames per write.
142
+
143
+ ### Added
144
+ - Added `I18NTK_DISABLE_AUTOSAVE` support to skip disk persistence and keep in-memory config in server/runtime environments.
145
+ - Added config-manager concurrency regression test covering parallel `saveConfig` calls.
146
+
147
+ ### Changed
148
+ - Updated package/docs/version metadata to `2.3.4`.
149
+ - Updated support policy guidance to recommend upgrading from versions below `2.3.4`.
150
+
151
+ ## [2.3.3] - 2026-04-12
152
+
153
+ ### Fixed
154
+ - Fixed production config persistence race across multiple Node processes by adding cross-process file locking for `.i18ntk-config` writes.
155
+ - Fixed intermittent `ENOENT` during atomic config rename operations under concurrent production traffic.
156
+
157
+ ### Changed
158
+ - Updated package/docs/version metadata to `2.3.3`.
159
+ - Updated support policy guidance to recommend upgrading from versions below `2.3.3`.
160
+
161
+ ## [2.3.2] - 2026-04-12
162
+
163
+ ### Added
164
+ - Added startup npm-registry version checks that warn when the installed CLI is behind the latest published `i18ntk` release.
165
+ - Added support for checking all published semver versions up to the current latest tag to improve outdated-version detection reliability.
166
+
167
+ ### Fixed
168
+ - Fixed fatal analyze-command startup failure in manager command flow caused by missing `validateSourceDir` import.
169
+
170
+ ### Changed
171
+ - Updated package/docs/version metadata to `2.3.2`.
172
+ - Updated support policy guidance to recommend upgrading from versions below `2.3.2`.
173
+
174
+ ## [2.3.1] - 2026-04-12
175
+
176
+ ### Fixed
177
+ - Fixed package export-path fallback in `utils/i18n-helper` that could trigger build warnings in production bundlers (`i18ntk/resources/i18n/ui-locales/en.json` not exported).
178
+
179
+ ### Changed
180
+ - Updated package/docs/version metadata to `2.3.1`.
181
+ - Updated support policy guidance to recommend upgrading from versions below `2.3.1`.
182
+
183
+ ## [2.3.0] - 2026-04-12
184
+
185
+ ### Added
186
+ - Added validation summary report output after validation runs.
187
+ - Added init-time backup configuration prompt (default disabled, optional enable).
188
+
189
+ ### Fixed
190
+ - Fixed backup recursion/pollution risk by moving automated fixer backups to a dedicated backup root.
191
+ - Fixed backup retention behavior to keep 1 by default with enforced bounds up to 3.
192
+ - Fixed language discovery in validate/fixer flows to ignore backup/report directories.
193
+
194
+ ### Changed
195
+ - Updated package/docs/version metadata to `2.3.0`.
196
+ - Updated support policy guidance to recommend upgrading from versions below `2.3.0`.
197
+
198
+ ## [2.2.0] - 2026-04-12
199
+
200
+ ### Added
201
+ - Added an explicit upgrade/support notice in docs recommending upgrade from pre-`2.2.0` versions.
202
+ - Added migration guide for `v2.2.0`.
203
+
204
+ ### Fixed
205
+ - Fixed critical sizing workflow regressions.
206
+ - Fixed critical usage-analysis workflow regressions.
207
+ - Fixed runtime locale optimizer dependency path after publish-surface cleanup.
208
+
209
+ ### Changed
210
+ - Reduced publish surface by excluding internal development scripts from npm package artifacts.
211
+ - Excluded legacy fixed artifacts from package output (`main/manage/index-fixed.js`, `utils/security-fixed.js`).
212
+ - Updated package/docs/version metadata to `2.2.0`.
213
+
214
+ ## [2.1.1] - 2026-04-11
215
+
216
+ ### Added
217
+ - Version bump to 2.1.1 for release.
218
+ - Added `SecurityUtils.debugLog` function for consistent debugging.
219
+
220
+ ### Fixed
221
+ - Fixed `SecurityUtils.logSecurityEvent` calls missing `level` parameter in `i18ntk-usage` and `UsageService`.
222
+ - Fixed `level.toLowerCase is not a function` error in usage analysis.
223
+ - Fixed `SecurityUtils.debugLog is not a function` error in sizing analysis.
224
+
225
+ ### Changed
226
+ - Updated package and release metadata to `2.1.1`.
227
+ - Removed legacy `resources/i18n/ui-locales` path references (use `ui-locales/` instead).
228
+ - Updated all UI locale loading to use `ui-locales/` directory.
229
+
230
+ ## [2.1.0] - 2026-04-11
231
+
232
+ ### Added
233
+ - Added a v2.1.0 migration guide and updated release runbook references.
234
+ - Added stricter language-directory filtering in analysis paths to ignore backup/report folders.
235
+
236
+ ### Fixed
237
+ - Fixed interactive menu command flow so it reliably returns to the main menu after command completion.
238
+ - Fixed analysis progress output to report the correct processed-language count.
239
+ - Fixed duplicate report-save output lines during analysis.
240
+ - Fixed framework detection behavior to treat setup-complete projects as internally configured i18ntk projects.
241
+ - Fixed false-positive security warnings for valid configuration fields like `dateFormat`, `timeFormat`, and `reportLanguage`.
242
+ - Fixed locale-loading path fallback behavior to avoid noisy startup errors in global installs.
243
+
244
+ ### Changed
245
+ - Synchronized and normalized UI locale keys across `resources/i18n/ui-locales` and `ui-locales`.
246
+ - Updated package/release metadata to `2.1.0`.
247
+
248
+ ## [2.0.0] - 2026-01-01
249
+
250
+ ### Added
251
+ - Added missing runtime translation keys across `init`, `fixer`, `sizing`, `summary`, `usage`, and settings import/export flows.
252
+ - Added `SecurityUtils.safeParseJSON`, `SecurityUtils.safeReadFile`, and `SecurityUtils.safeWriteFile` compatibility APIs used by v2 command paths.
253
+ - Added source-locale bootstrap behavior during `init` when the source language directory exists but has no translation files.
254
+
255
+ ### Fixed
256
+ - Fixed initialization state detection to use project `.i18ntk-config` setup metadata as the v2 source of truth.
257
+ - Fixed false setup-invalid states caused by BOM-encoded config files during setup checks.
258
+ - Fixed config persistence risk by using atomic writes in `config-manager` save flow.
259
+ - Fixed self-dependency metadata so the package remains zero-dependency in v2.
260
+
261
+ ### Changed
262
+ - Updated package release metadata for the v2 line (`versionInfo`, deprecations, nextVersion).
263
+
264
+ ## [1.10.2] - 2025-08-23
265
+
266
+ ### 🚨 Critical Fix
267
+ - **Fixed projectRoot default path**: Resetting settings now correctly restores `projectRoot` to `/` instead of `./`, ensuring fresh installs work out-of-the-box
268
+
269
+ ### 🆕 New Features
270
+ - **Centralized Environment Variable Management**: Added comprehensive environment variable support with validation and security controls
271
+ - **Enhanced Debug Logging**: Improved debug logging with environment variable support for better troubleshooting
272
+ - **Secure Plugin Loading**: Added path sanitization for module loading to prevent security issues
273
+
274
+ ### 🔒 Security Enhancements
275
+ - **Enhanced Path Validation**: Strengthened path validation and file operations security
276
+ - **Secure Module Loading**: Added path sanitization for all plugin/module loading operations
277
+ - **Environment Variable Security**: Implemented centralized environment variable management with security filtering
278
+
279
+ ### 🛠️ Improvements
280
+ - **Refactored Configuration Handling**: Updated config system with integrated environment variable support
281
+ - **Enhanced Logging System**: Improved debug logging capabilities with environment variable integration
282
+ - **Better Error Handling**: Enhanced error messages and debugging information
283
+
284
+ ### 📚 Documentation
285
+ - **Environment Variables Guide**: Added comprehensive documentation for all supported environment variables
286
+ - **Migration Notes**: Added clear migration guidance for projectRoot path changes
287
+
288
+ ### 🔧 Technical Changes
289
+ - **Package Version**: Updated to v1.10.2 across all files
290
+ - **Security Patches**: Applied security improvements to path handling and file operations
291
+
292
+ ## [1.10.1] - 2025-08-22
293
+
294
+ ### Added
295
+ - **New Terminal-Icons Utility**: Added `terminal-icons` utility for better emoji support in terminal output
296
+ - **Enhanced UI Text Processing**: Improved text processing with terminal-safe fallbacks for special characters
297
+
298
+ ### Fixed
299
+ - Fixed infinite setup loop issue (Hotfix)
300
+ - Resolved version string update inconsistencies
301
+
302
+ ### Changed
303
+ - Update version strings across all files from 1.9.1 to 1.10.1
304
+ - Remove outdated package-lock.json and backup config
305
+
306
+ ## [1.10.0] - 2025-08-22
307
+
308
+ ### Added
309
+ - **Enhanced Runtime API**: Improved framework-agnostic translation runtime with better TypeScript support
310
+ - **Framework Detection**: Enhanced support for Next.js, Nuxt.js, and SvelteKit projects
311
+ - **Reset Script**: Added `reset-for-publish.js` for clean package publishing
312
+ - **Documentation**: Comprehensive updates for new features and improvements
313
+ - **Configuration Persistence**: Fixed configuration changes not being saved to disk
314
+ - **Caching System**: Added configuration caching to prevent redundant initialization
315
+
316
+ ### Fixed
317
+ - **DNR Functionality**: Fixed persistence of "Do Not Remind" settings across version updates
318
+ - **Settings Management**: Improved error handling and logging for settings operations
319
+ - **TypeScript Definitions**: Enhanced type safety and autocomplete for better developer experience
320
+ - **Performance**: Optimized translation lookups with reduced memory footprint
321
+ - **Shell Security**: Verified zero shell access vulnerabilities in setup-enforcer.js
322
+ - **Configuration Loading**: Fixed multiple "Initializing with default configuration" messages
323
+ - **Path Resolution**: Fixed source directory path handling for CLI arguments
324
+
325
+ ### Security
326
+ - **Settings Persistence**: Secure handling of user preferences and framework settings
327
+ - **Error Handling**: Improved error reporting for configuration issues
328
+ - **Dependencies**: Maintained zero runtime dependencies for maximum security
329
+ - **Shell Access**: Confirmed no child_process usage in setup-enforcer.js
330
+ - **Input Validation**: Enhanced path validation for source and output directories
331
+
332
+
333
+
334
+ ## [1.9.1] - 2025-08-14
335
+
336
+ ### Added
337
+ - **Python Support**: Full support for Python frameworks including Django, Flask, FastAPI, and generic Python projects
338
+ - **Enhanced Framework Detection**: Improved accuracy for all supported frameworks with new Python detection algorithms
339
+ - **Common Locale File**: Added `locales/common.json` for shared translation keys across frameworks
340
+ - **Zero Shell Security**: Complete removal of `child_process` dependencies for maximum security
341
+ - **Exit/Cancel Option**: Added option to exit/cancel (press 0) during directory selection in fixer command
342
+
343
+ ### Changed
344
+ - **Security Overhaul**: Replaced all `child_process` imports with native Node.js APIs
345
+ - **Performance**: Maintained 97% performance improvement while adding security enhancements
346
+ - **Framework Detection**: Updated detection patterns for JavaScript, Python, Go, Java, and PHP
347
+ - **File Structure**: Optimized package structure with removed outdated files
348
+ - **Documentation**: Comprehensive updates to reflect new features and security improvements
349
+
350
+ ### Removed
351
+ - **Outdated Test Files**: Cleaned up test directories and removed deprecated test scripts
352
+ - **Debug Tools**: Removed unused benchmark and package test files
353
+ - **Shell Dependencies**: Eliminated all shell command dependencies
354
+ - **Legacy Files**: Removed outdated configuration and development files
355
+
356
+ ### Security
357
+ - **Zero Vulnerabilities**: Successfully passed security audit with 0 vulnerabilities
358
+ - **Memory Safety**: Enhanced memory-safe operations throughout the codebase
359
+ - **Input Validation**: Improved validation for all user inputs and file operations
360
+ - **Dependency Cleanup**: Removed all shell-related dependencies
361
+
362
+ ### Performance
363
+ - **Zero Overhead**: Security enhancements added zero performance overhead
364
+ - **Python Detection**: Minimal overhead from new Python framework detection
365
+ - **Memory Usage**: Maintained <2MB memory usage for all operations
366
+ - **Validation**: Enhanced validation with no performance impact
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # i18ntk v2.5.1
1
+ # i18ntk v2.6.0
2
2
 
3
3
  Zero-dependency internationalization toolkit for setup, scanning, analysis, validation, usage tracking, and translation completion.
4
4
 
@@ -9,52 +9,27 @@ Zero-dependency internationalization toolkit for setup, scanning, analysis, vali
9
9
  [![node](https://img.shields.io/badge/node-%3E%3D16-339933)](https://nodejs.org)
10
10
  [![dependencies](https://img.shields.io/badge/dependencies-0-success)](https://www.npmjs.com/package/i18ntk)
11
11
  [![license](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)
12
- [![socket](https://socket.dev/api/badge/npm/package/i18ntk/2.5.1)](https://socket.dev/npm/package/i18ntk/overview/2.5.1)
12
+ [![socket](https://socket.dev/api/badge/npm/package/i18ntk/2.6.0)](https://socket.dev/npm/package/i18ntk/overview/2.6.0)
13
13
 
14
14
  ## Upgrade Notice
15
15
 
16
- Versions earlier than `2.5.1` may contain known stability and security issues.
17
- They are considered unsupported for production use. Upgrade to `2.5.1` or newer.
18
-
19
- ## v2.5.1 Security Update
20
-
21
- `v2.5.1` is a security and packaging-process update for the `2.5.x` release line.
22
-
23
- ### Change Summary
24
-
25
- - Hardened `utils/admin-auth.js` so `verifyPin()` fails closed when admin config is missing, disabled, or malformed.
26
- - Hardened auth-required checks so enabled PIN protection does not silently bypass authentication when admin config is unusable.
27
- - Normalized admin session expiry handling by storing both `expires` and `expiresAt` and cleaning up either format consistently.
28
- - Marked the root `package.json` as development-only and added a separate public manifest flow.
29
- - Added package scripts to stage, pack, and publish the public npm package from `package.public.json`.
30
- - Added a root publish guard via `prepack` and `prepublishOnly` to block accidental publishing of the development manifest.
31
- - Updated ignore rules to exclude release staging artifacts and public package metadata from the repo/package payload.
32
- - Replaced the expanded `SECURITY.md` policy with a shorter reporting-oriented policy and added community docs links.
33
- - Updated docs and release reset automation to use `npm run package:public` instead of `npm pack --dry-run`.
34
-
35
- ### Files Changed
36
-
37
- - `utils/admin-auth.js`: fixed fail-open PIN verification and session expiry consistency.
38
- - `tests/security.test.js`: added admin-auth fail-closed and session cleanup coverage.
39
- - `package.json`: set development-only metadata, adjusted included files, and added public packaging/publish scripts.
40
- - `package.public.json`: introduced the stripped public npm manifest.
41
- - `scripts/build-public-package.js`: added the public package staging, pack, and publish workflow.
42
- - `scripts/prevent-root-publish.js`: added a guard against publishing the root development manifest.
43
- - `scripts/reset-release-state.js`: switched release validation to the public package build flow.
44
- - `README.md`, `docs/README.md`, `docs/development/AGENTS.md`, `docs/migration-guide-v2.5.1.md`, `docs/migration-guide-v2.5.0.md`: documented the security fix, packaging, and community file layout.
45
- - `SECURITY.md`, `CODE_OF_CONDUCT.md`, `CONTRIBUTING.md`, `FUNDING.md`: updated or added community and security-facing docs.
46
- - `.gitignore`, `.npmignore`: excluded release staging output and public-package metadata.
47
-
48
- ### Audit Trail
49
-
50
- - Risk addressed: AI-based analysis flagged `verifyPin()` as fail-open when admin config was missing or disabled.
51
- - Behavior change: direct `verifyPin()` calls now return `false` unless a usable enabled PIN config exists.
52
- - Behavior change: when settings require PIN auth but admin config is broken, protected auth checks now require authentication and verification fails closed.
53
- - Risk: the root manifest is intentionally non-publishable, so publishing flows must use the public-package scripts.
54
- - Behavior change: `npm pack` and `npm publish` at the repo root are blocked by guard scripts.
55
- - Behavior change: the public npm payload is staged from `package.public.json` rather than the development manifest.
56
- - Validation note: release-state reset now exercises `npm run package:public` as part of its checks.
57
- - Validation note: this documentation update describes the working tree changes used for the packaging split.
16
+ Versions earlier than `2.6.0` may contain known stability and security issues.
17
+ They are considered unsupported for production use. Upgrade to `2.6.0` or newer.
18
+
19
+ ## v2.6.0 Deep-Code Audit Release
20
+
21
+ v2.6.0 is a comprehensive hardening release from a two-pass code audit fixing 35+ bugs and security issues across 18 files. Highlights:
22
+
23
+ - **Critical**: Fixed silent-write failures where `safeWriteFileSync` was called incorrectly across 4 modules.
24
+ - **Security**: Replaced all remaining raw `fs` calls with validated `SecurityUtils` wrappers.
25
+ - **Security**: Fixed path traversal bypass in the fallback `SecurityUtils` implementation.
26
+ - **Security**: Fixed Windows path traversal false negatives (fragile `path.sep` comparison).
27
+ - **Security**: Added `safeUnlinkSync` and `safeRmdirSync` for validated file/directory deletion.
28
+ - **Runtime**: Fixed process event handler leak, missing `setInterval.unref()`, and JSON parse error handling.
29
+ - **TypeScript**: Fixed `BasicI18nRuntime.translate/t` return type from `Promise<string>` to `string`.
30
+ - **Scripts**: Fixed `npm_execpath` fallback in build/release scripts.
31
+
32
+ For the full detailed changelog, see [CHANGELOG.md](./CHANGELOG.md). For migration notes, see [docs/migration-guide-v2.6.0.md](./docs/migration-guide-v2.6.0.md).
58
33
 
59
34
  ## What i18ntk Does
60
35
 
@@ -194,7 +169,7 @@ Example `.i18ntk-config`:
194
169
 
195
170
  ```json
196
171
  {
197
- "version": "2.5.1",
172
+ "version": "2.6.0",
198
173
  "sourceDir": "./locales",
199
174
  "i18nDir": "./locales",
200
175
  "outputDir": "./i18ntk-reports",
@@ -217,6 +192,7 @@ See [docs/api/CONFIGURATION.md](docs/api/CONFIGURATION.md) for the full configur
217
192
  - [Runtime API Guide](https://github.com/vladnoskv/i18ntk/blob/main/docs/runtime.md)
218
193
  - [Scanner Guide](https://github.com/vladnoskv/i18ntk/blob/main/docs/scanner-guide.md)
219
194
  - [Environment Variables](https://github.com/vladnoskv/i18ntk/blob/main/docs/environment-variables.md)
195
+ - [Migration Guide v2.6.0](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v2.6.0.md)
220
196
  - [Migration Guide v2.5.1](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v2.5.1.md)
221
197
  - [Migration Guide v2.5.0](https://github.com/vladnoskv/i18ntk/blob/main/docs/migration-guide-v2.5.0.md)
222
198
 
@@ -252,7 +252,7 @@ class I18nAnalyzer {
252
252
  const relativePath = path.relative(this.sourceDir, fullPath);
253
253
  const shouldExclude = (this.config.excludeFiles || []).some(pattern => {
254
254
  if (typeof pattern === 'string') {
255
- return relativePath === pattern || relativePath.endsWith(path.sep + pattern);
255
+ return relativePath === pattern || relativePath.endsWith('/' + pattern) || relativePath.endsWith('\\' + pattern);
256
256
  }
257
257
  if (pattern instanceof RegExp) {
258
258
  return pattern.test(relativePath);
@@ -908,9 +908,9 @@ try {
908
908
  const isRequired = await adminAuth.isAuthRequired();
909
909
  if (isRequired) {
910
910
  console.log('\n' + t('adminCli.authRequiredForOperation', { operation: 'analyze translations' }));
911
- const cliHelper = require('../utils/cli-helper');
912
- const pin = await cliHelper.promptPin(t('adminCli.enterPin'));
913
- const isValid = await this.adminAuth.verifyPin(pin);
911
+ const cli = require('../utils/cli-helper');
912
+ const pin = await cli.promptPin(t('adminCli.enterPin'));
913
+ const isValid = await adminAuth.verifyPin(pin);
914
914
 
915
915
  if (!isValid) {
916
916
  console.log(t('adminCli.invalidPin'));
@@ -181,9 +181,9 @@ class I18nTextScanner {
181
181
  if (pyproject.includes('Flask')) return 'flask';
182
182
  }
183
183
 
184
- // Check for Python files
185
- const hasPythonFiles = fs.readdirSync(projectRoot, { recursive: true })
186
- .some(file => file.endsWith && file.endsWith('.py'));
184
+ // Check for Python files using safeReaddirSync
185
+ const pythonItems = SecurityUtils.safeReaddirSync(projectRoot, projectRoot, { withFileTypes: true }) || [];
186
+ const hasPythonFiles = pythonItems.some(item => item.isFile && item.name && item.name.endsWith('.py'));
187
187
  if (hasPythonFiles) return 'python';
188
188
  } catch (error) {
189
189
  // Continue to JS frameworks
@@ -420,20 +420,22 @@ class I18nTextScanner {
420
420
  const extensions = ['.js', '.jsx', '.ts', '.tsx', '.vue', '.html', '.svelte', '.py', '.pyx', '.pyi'];
421
421
 
422
422
  const scanRecursive = (currentDir) => {
423
- const items = fs.readdirSync(currentDir);
423
+ const items = SecurityUtils.safeReaddirSync(currentDir, path.dirname(currentDir), { withFileTypes: true });
424
+ if (!items) return;
424
425
 
425
426
  for (const item of items) {
426
- const fullPath = path.join(currentDir, item);
427
- const stat = fs.statSync(fullPath);
427
+ const fullPath = path.join(currentDir, item.name);
428
+ const stat = SecurityUtils.safeStatSync(fullPath, currentDir);
429
+ if (!stat) continue;
428
430
 
429
431
  if (stat.isDirectory()) {
430
- if (!item.startsWith('.') && !this.shouldExcludeFile(fullPath, exclusions)) {
432
+ if (!item.name.startsWith('.') && !this.shouldExcludeFile(fullPath, exclusions)) {
431
433
  scanRecursive(fullPath);
432
434
  }
433
435
  } else if (stat.isFile()) {
434
- const ext = path.extname(item);
436
+ const ext = path.extname(item.name);
435
437
  if (extensions.includes(ext) && !this.shouldExcludeFile(fullPath, exclusions)) {
436
- if (!includeTests && (item.includes('.test.') || item.includes('.spec.'))) {
438
+ if (!includeTests && (item.name.includes('.test.') || item.name.includes('.spec.'))) {
437
439
  continue;
438
440
  }
439
441
 
@@ -455,7 +457,7 @@ class I18nTextScanner {
455
457
 
456
458
  async generateReport(results, outputDir) {
457
459
  if (!SecurityUtils.safeExistsSync(outputDir, path.dirname(outputDir))) {
458
- fs.mkdirSync(outputDir, { recursive: true });
460
+ SecurityUtils.safeMkdirSync(outputDir, process.cwd(), { recursive: true });
459
461
  }
460
462
 
461
463
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
@@ -472,11 +474,11 @@ class I18nTextScanner {
472
474
  };
473
475
 
474
476
  // JSON report
475
- SecurityUtils.safeWriteFileSync(reportFile, JSON.stringify(summary, null, 2), outputDir);
477
+ SecurityUtils.safeWriteFileSync(reportFile, JSON.stringify(summary, null, 2), outputDir, 'utf8');
476
478
 
477
479
  // Markdown summary
478
480
  const mdContent = this.generateMarkdownReport(summary);
479
- SecurityUtils.safeWriteFileSync(summaryFile, mdContent, outputDir);
481
+ SecurityUtils.safeWriteFileSync(summaryFile, mdContent, outputDir, 'utf8');
480
482
 
481
483
  return { reportFile, summaryFile, summary };
482
484
  }
@@ -33,7 +33,7 @@ if (isUppercase) {
33
33
  console.error(' npm run i18ntk:manage');
34
34
  console.error('');
35
35
  console.error('📖 For more information, run: npx i18ntk --help');
36
- process.exit(ExitCodes.CONFIG_ERROR);
36
+ process.exit(1);
37
37
  }
38
38
 
39
39
  const fs = require('fs');
@@ -112,8 +112,8 @@ class I18nValidator {
112
112
  } else {
113
113
  console.warn(t('config.dirFallbackWarning', { dir: this.sourceDir, fallback: this.sourceLanguageDir }) ||
114
114
  `Warning: Directory ${this.sourceDir} not found. Using ${this.sourceLanguageDir}.`);
115
- if (!SecurityUtils.safeExistsSync(this.sourceLanguageDir)) {
116
- fs.mkdirSync(this.sourceLanguageDir, { recursive: true });
115
+ if (!SecurityUtils.safeExistsSync(this.sourceLanguageDir, process.cwd())) {
116
+ SecurityUtils.safeMkdirSync(this.sourceLanguageDir, process.cwd(), { recursive: true });
117
117
  }
118
118
  }
119
119
  }
@@ -204,13 +204,17 @@ class I18nValidator {
204
204
  throw new Error(`Source directory not found: ${this.sourceDir}`);
205
205
  }
206
206
 
207
- const languages = fs.readdirSync(this.sourceDir)
208
- .filter(item => {
209
- const itemPath = path.join(this.sourceDir, item);
210
- return fs.statSync(itemPath).isDirectory() &&
211
- item !== this.config.sourceLanguage &&
212
- !this.isExcludedLanguageDirectory(item);
213
- });
207
+ const items = SecurityUtils.safeReaddirSync(this.sourceDir, process.cwd(), { withFileTypes: true });
208
+ if (!items) {
209
+ throw new Error(`Source directory not found: ${this.sourceDir}`);
210
+ }
211
+
212
+ const languages = items
213
+ .filter(item => {
214
+ return item.isDirectory() &&
215
+ item.name !== this.config.sourceLanguage &&
216
+ !this.isExcludedLanguageDirectory(item.name);
217
+ }).map(item => item.name);
214
218
 
215
219
  return languages;
216
220
  } catch (error) {
@@ -228,11 +232,14 @@ class I18nValidator {
228
232
  return [];
229
233
  }
230
234
 
231
- const files = fs.readdirSync(languageDir)
232
- .filter(file => {
233
- return file.endsWith('.json') &&
234
- !this.config.excludeFiles.includes(file);
235
- });
235
+ const items = SecurityUtils.safeReaddirSync(languageDir, process.cwd(), { withFileTypes: true });
236
+ if (!items) return [];
237
+
238
+ const files = items
239
+ .filter(item => {
240
+ return item.isFile() && item.name.endsWith('.json') &&
241
+ !this.config.excludeFiles.includes(item.name);
242
+ }).map(item => item.name);
236
243
 
237
244
  return files;
238
245
  } catch (error) {
@@ -682,10 +689,10 @@ class I18nValidator {
682
689
 
683
690
  // Delete old validation report if it exists
684
691
  const reportPath = path.join(process.cwd(), 'validation-report.txt');
685
- SecurityUtils.validatePath(reportPath);
692
+ const validatedPath = SecurityUtils.validatePath(reportPath, process.cwd());
686
693
 
687
- if (SecurityUtils.safeExistsSync(reportPath)) {
688
- fs.unlinkSync(reportPath);
694
+ if (validatedPath && SecurityUtils.safeExistsSync(validatedPath, process.cwd())) {
695
+ SecurityUtils.safeUnlinkSync(validatedPath, process.cwd());
689
696
  console.log(t('validate.deletedOldReport'));
690
697
 
691
698
  SecurityUtils.logSecurityEvent(t('validate.fileDeleted'), 'info', {
@@ -129,10 +129,13 @@ class AnalyzeCommand {
129
129
  throw new Error(`Source directory does not exist or is not a directory: ${safePath}`);
130
130
  }
131
131
 
132
- try {
133
- fs.accessSync(safePath, fs.constants.R_OK | fs.constants.W_OK);
134
- } catch {
135
- throw new Error(`Insufficient permissions for source directory: ${safePath}`);
132
+ try {
133
+ const stat = SecurityUtils.safeStatSync(safePath, process.cwd());
134
+ if (!stat || !stat.isDirectory()) {
135
+ throw new Error(`Source directory is not accessible: ${safePath}`);
136
+ }
137
+ } catch (error) {
138
+ throw new Error(`Insufficient permissions for source directory: ${safePath}`);
136
139
  }
137
140
  }
138
141