mcp-wordpress 2.4.2 → 2.5.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.
- package/README.md +124 -54
- package/bin/status.js +1 -1
- package/dist/cache/CacheInvalidation.d.ts +3 -1
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +10 -4
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +3 -2
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +11 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts +7 -6
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +8 -5
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/index.d.ts +3 -3
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts +23 -9
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js +4 -1
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/MockWordPressClient.d.ts +2 -1
- package/dist/client/MockWordPressClient.d.ts.map +1 -1
- package/dist/client/MockWordPressClient.js +3 -1
- package/dist/client/MockWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +17 -13
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +135 -30
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +2 -3
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthenticationManager.d.ts +55 -2
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +269 -71
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts +3 -3
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +11 -5
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/RequestManager.d.ts +2 -2
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +25 -12
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/config/Config.d.ts +155 -0
- package/dist/config/Config.d.ts.map +1 -0
- package/dist/config/Config.js +215 -0
- package/dist/config/Config.js.map +1 -0
- package/dist/config/ConfigurationSchema.d.ts +21 -21
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +19 -2
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -1
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js +73 -43
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.d.ts +9 -8
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
- package/dist/docs/DocumentationGenerator.js +10 -7
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
- package/dist/docs/MarkdownFormatter.js +3 -2
- package/dist/docs/MarkdownFormatter.js.map +1 -1
- package/dist/dxt-entry.js +15 -14
- package/dist/dxt-entry.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -21
- package/dist/index.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts +13 -7
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +69 -27
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceAnalytics.d.ts +8 -2
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
- package/dist/performance/PerformanceAnalytics.js +17 -47
- package/dist/performance/PerformanceAnalytics.js.map +1 -1
- package/dist/performance/PerformanceMonitor.d.ts +2 -1
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
- package/dist/performance/PerformanceMonitor.js +12 -13
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/performance/index.d.ts +2 -2
- package/dist/performance/index.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.d.ts +1 -0
- package/dist/security/AISecurityScanner.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.js +22 -12
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.d.ts +4 -3
- package/dist/security/AutomatedRemediation.d.ts.map +1 -1
- package/dist/security/AutomatedRemediation.js +46 -15
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts +13 -9
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +4 -2
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +1 -1
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +38 -29
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfig.d.ts +3 -3
- package/dist/security/SecurityConfig.d.ts.map +1 -1
- package/dist/security/SecurityConfig.js +13 -9
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/security/SecurityConfigManager.d.ts +2 -2
- package/dist/security/SecurityConfigManager.d.ts.map +1 -1
- package/dist/security/SecurityConfigManager.js +20 -15
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityMonitoring.d.ts +2 -2
- package/dist/security/SecurityMonitoring.d.ts.map +1 -1
- package/dist/security/SecurityMonitoring.js +19 -17
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReviewer.d.ts.map +1 -1
- package/dist/security/SecurityReviewer.js +10 -7
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/index.d.ts +24 -23
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +52 -23
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts +12 -4
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js +96 -22
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts +2 -2
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js +10 -5
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/src/cache/CacheInvalidation.d.ts +120 -0
- package/dist/src/cache/CacheInvalidation.d.ts.map +1 -0
- package/dist/src/cache/CacheInvalidation.js +355 -0
- package/dist/src/cache/CacheInvalidation.js.map +1 -0
- package/dist/src/cache/CacheManager.d.ts +149 -0
- package/dist/src/cache/CacheManager.d.ts.map +1 -0
- package/dist/src/cache/CacheManager.js +326 -0
- package/dist/src/cache/CacheManager.js.map +1 -0
- package/dist/src/cache/HttpCacheWrapper.d.ts +122 -0
- package/dist/src/cache/HttpCacheWrapper.d.ts.map +1 -0
- package/dist/src/cache/HttpCacheWrapper.js +283 -0
- package/dist/src/cache/HttpCacheWrapper.js.map +1 -0
- package/dist/src/cache/index.d.ts +12 -0
- package/dist/src/cache/index.d.ts.map +1 -0
- package/dist/src/cache/index.js +9 -0
- package/dist/src/cache/index.js.map +1 -0
- package/dist/src/client/CachedWordPressClient.d.ts +174 -0
- package/dist/src/client/CachedWordPressClient.d.ts.map +1 -0
- package/dist/src/client/CachedWordPressClient.js +345 -0
- package/dist/src/client/CachedWordPressClient.js.map +1 -0
- package/dist/src/client/MockWordPressClient.d.ts +56 -0
- package/dist/src/client/MockWordPressClient.d.ts.map +1 -0
- package/dist/src/client/MockWordPressClient.js +371 -0
- package/dist/src/client/MockWordPressClient.js.map +1 -0
- package/dist/src/client/api.d.ts +235 -0
- package/dist/src/client/api.d.ts.map +1 -0
- package/dist/src/client/api.js +896 -0
- package/dist/src/client/api.js.map +1 -0
- package/dist/src/client/auth.d.ts +121 -0
- package/dist/src/client/auth.d.ts.map +1 -0
- package/dist/src/client/auth.js +429 -0
- package/dist/src/client/auth.js.map +1 -0
- package/dist/src/client/managers/AuthenticationManager.d.ts +92 -0
- package/dist/src/client/managers/AuthenticationManager.d.ts.map +1 -0
- package/dist/src/client/managers/AuthenticationManager.js +369 -0
- package/dist/src/client/managers/AuthenticationManager.js.map +1 -0
- package/dist/src/client/managers/BaseManager.d.ts +22 -0
- package/dist/src/client/managers/BaseManager.d.ts.map +1 -0
- package/dist/src/client/managers/BaseManager.js +53 -0
- package/dist/src/client/managers/BaseManager.js.map +1 -0
- package/dist/src/client/managers/RequestManager.d.ts +47 -0
- package/dist/src/client/managers/RequestManager.d.ts.map +1 -0
- package/dist/src/client/managers/RequestManager.js +193 -0
- package/dist/src/client/managers/RequestManager.js.map +1 -0
- package/dist/src/client/managers/index.d.ts +8 -0
- package/dist/src/client/managers/index.d.ts.map +1 -0
- package/dist/src/client/managers/index.js +8 -0
- package/dist/src/client/managers/index.js.map +1 -0
- package/dist/src/config/Config.d.ts +155 -0
- package/dist/src/config/Config.d.ts.map +1 -0
- package/dist/src/config/Config.js +215 -0
- package/dist/src/config/Config.js.map +1 -0
- package/dist/src/config/ConfigurationSchema.d.ts +281 -0
- package/dist/src/config/ConfigurationSchema.d.ts.map +1 -0
- package/dist/src/config/ConfigurationSchema.js +205 -0
- package/dist/src/config/ConfigurationSchema.js.map +1 -0
- package/dist/src/config/ServerConfiguration.d.ts +47 -0
- package/dist/src/config/ServerConfiguration.d.ts.map +1 -0
- package/dist/src/config/ServerConfiguration.js +255 -0
- package/dist/src/config/ServerConfiguration.js.map +1 -0
- package/dist/src/docs/DocumentationGenerator.d.ts +185 -0
- package/dist/src/docs/DocumentationGenerator.d.ts.map +1 -0
- package/dist/src/docs/DocumentationGenerator.js +777 -0
- package/dist/src/docs/DocumentationGenerator.js.map +1 -0
- package/dist/src/docs/MarkdownFormatter.d.ts +84 -0
- package/dist/src/docs/MarkdownFormatter.d.ts.map +1 -0
- package/dist/src/docs/MarkdownFormatter.js +458 -0
- package/dist/src/docs/MarkdownFormatter.js.map +1 -0
- package/dist/src/docs/index.d.ts +8 -0
- package/dist/src/docs/index.d.ts.map +1 -0
- package/dist/src/docs/index.js +7 -0
- package/dist/src/docs/index.js.map +1 -0
- package/dist/src/dxt-entry.d.ts +6 -0
- package/dist/src/dxt-entry.d.ts.map +1 -0
- package/dist/src/dxt-entry.js +39 -0
- package/dist/src/dxt-entry.js.map +1 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +143 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/performance/MetricsCollector.d.ts +145 -0
- package/dist/src/performance/MetricsCollector.d.ts.map +1 -0
- package/dist/src/performance/MetricsCollector.js +368 -0
- package/dist/src/performance/MetricsCollector.js.map +1 -0
- package/dist/src/performance/PerformanceAnalytics.d.ts +168 -0
- package/dist/src/performance/PerformanceAnalytics.d.ts.map +1 -0
- package/dist/src/performance/PerformanceAnalytics.js +570 -0
- package/dist/src/performance/PerformanceAnalytics.js.map +1 -0
- package/dist/src/performance/PerformanceMonitor.d.ts +203 -0
- package/dist/src/performance/PerformanceMonitor.d.ts.map +1 -0
- package/dist/src/performance/PerformanceMonitor.js +478 -0
- package/dist/src/performance/PerformanceMonitor.js.map +1 -0
- package/dist/src/performance/index.d.ts +11 -0
- package/dist/src/performance/index.d.ts.map +1 -0
- package/dist/src/performance/index.js +8 -0
- package/dist/src/performance/index.js.map +1 -0
- package/dist/src/security/AISecurityScanner.d.ts +176 -0
- package/dist/src/security/AISecurityScanner.d.ts.map +1 -0
- package/dist/src/security/AISecurityScanner.js +655 -0
- package/dist/src/security/AISecurityScanner.js.map +1 -0
- package/dist/src/security/AutomatedRemediation.d.ts +146 -0
- package/dist/src/security/AutomatedRemediation.d.ts.map +1 -0
- package/dist/src/security/AutomatedRemediation.js +566 -0
- package/dist/src/security/AutomatedRemediation.js.map +1 -0
- package/dist/src/security/InputValidator.d.ts +219 -0
- package/dist/src/security/InputValidator.d.ts.map +1 -0
- package/dist/src/security/InputValidator.js +295 -0
- package/dist/src/security/InputValidator.js.map +1 -0
- package/dist/src/security/SecurityCIPipeline.d.ts +213 -0
- package/dist/src/security/SecurityCIPipeline.d.ts.map +1 -0
- package/dist/src/security/SecurityCIPipeline.js +693 -0
- package/dist/src/security/SecurityCIPipeline.js.map +1 -0
- package/dist/src/security/SecurityConfig.d.ts +129 -0
- package/dist/src/security/SecurityConfig.d.ts.map +1 -0
- package/dist/src/security/SecurityConfig.js +266 -0
- package/dist/src/security/SecurityConfig.js.map +1 -0
- package/dist/src/security/SecurityConfigManager.d.ts +294 -0
- package/dist/src/security/SecurityConfigManager.d.ts.map +1 -0
- package/dist/src/security/SecurityConfigManager.js +558 -0
- package/dist/src/security/SecurityConfigManager.js.map +1 -0
- package/dist/src/security/SecurityMonitoring.d.ts +245 -0
- package/dist/src/security/SecurityMonitoring.d.ts.map +1 -0
- package/dist/src/security/SecurityMonitoring.js +598 -0
- package/dist/src/security/SecurityMonitoring.js.map +1 -0
- package/dist/src/security/SecurityReviewer.d.ts +168 -0
- package/dist/src/security/SecurityReviewer.d.ts.map +1 -0
- package/dist/src/security/SecurityReviewer.js +686 -0
- package/dist/src/security/SecurityReviewer.js.map +1 -0
- package/dist/src/security/index.d.ts +183 -0
- package/dist/src/security/index.d.ts.map +1 -0
- package/dist/src/security/index.js +218 -0
- package/dist/src/security/index.js.map +1 -0
- package/dist/src/server/ConnectionTester.d.ts +32 -0
- package/dist/src/server/ConnectionTester.d.ts.map +1 -0
- package/dist/src/server/ConnectionTester.js +135 -0
- package/dist/src/server/ConnectionTester.js.map +1 -0
- package/dist/src/server/ToolRegistry.d.ts +50 -0
- package/dist/src/server/ToolRegistry.d.ts.map +1 -0
- package/dist/src/server/ToolRegistry.js +219 -0
- package/dist/src/server/ToolRegistry.js.map +1 -0
- package/dist/src/server.d.ts +7 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +7 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/tools/BaseToolManager.d.ts +62 -0
- package/dist/src/tools/BaseToolManager.d.ts.map +1 -0
- package/dist/src/tools/BaseToolManager.js +195 -0
- package/dist/src/tools/BaseToolManager.js.map +1 -0
- package/dist/src/tools/auth.d.ts +50 -0
- package/dist/src/tools/auth.d.ts.map +1 -0
- package/dist/src/tools/auth.js +133 -0
- package/dist/src/tools/auth.js.map +1 -0
- package/dist/src/tools/cache.d.ts +260 -0
- package/dist/src/tools/cache.d.ts.map +1 -0
- package/dist/src/tools/cache.js +232 -0
- package/dist/src/tools/cache.js.map +1 -0
- package/dist/src/tools/comments.d.ts +33 -0
- package/dist/src/tools/comments.d.ts.map +1 -0
- package/dist/src/tools/comments.js +235 -0
- package/dist/src/tools/comments.js.map +1 -0
- package/dist/src/tools/index.d.ts +11 -0
- package/dist/src/tools/index.d.ts.map +1 -0
- package/dist/src/tools/index.js +11 -0
- package/dist/src/tools/index.js.map +1 -0
- package/dist/src/tools/media.d.ts +70 -0
- package/dist/src/tools/media.d.ts.map +1 -0
- package/dist/src/tools/media.js +248 -0
- package/dist/src/tools/media.js.map +1 -0
- package/dist/src/tools/pages.d.ts +32 -0
- package/dist/src/tools/pages.d.ts.map +1 -0
- package/dist/src/tools/pages.js +215 -0
- package/dist/src/tools/pages.js.map +1 -0
- package/dist/src/tools/performance.d.ts +73 -0
- package/dist/src/tools/performance.d.ts.map +1 -0
- package/dist/src/tools/performance.js +922 -0
- package/dist/src/tools/performance.js.map +1 -0
- package/dist/src/tools/posts/PostHandlers.d.ts +46 -0
- package/dist/src/tools/posts/PostHandlers.d.ts.map +1 -0
- package/dist/src/tools/posts/PostHandlers.js +400 -0
- package/dist/src/tools/posts/PostHandlers.js.map +1 -0
- package/dist/src/tools/posts/PostToolDefinitions.d.ts +37 -0
- package/dist/src/tools/posts/PostToolDefinitions.d.ts.map +1 -0
- package/dist/src/tools/posts/PostToolDefinitions.js +236 -0
- package/dist/src/tools/posts/PostToolDefinitions.js.map +1 -0
- package/dist/src/tools/posts/index.d.ts +138 -0
- package/dist/src/tools/posts/index.d.ts.map +1 -0
- package/dist/src/tools/posts/index.js +163 -0
- package/dist/src/tools/posts/index.js.map +1 -0
- package/dist/src/tools/posts.d.ts +15 -0
- package/dist/src/tools/posts.d.ts.map +1 -0
- package/dist/src/tools/posts.js +16 -0
- package/dist/src/tools/posts.js.map +1 -0
- package/dist/src/tools/site.d.ts +32 -0
- package/dist/src/tools/site.d.ts.map +1 -0
- package/dist/src/tools/site.js +234 -0
- package/dist/src/tools/site.js.map +1 -0
- package/dist/src/tools/taxonomies.d.ts +36 -0
- package/dist/src/tools/taxonomies.d.ts.map +1 -0
- package/dist/src/tools/taxonomies.js +286 -0
- package/dist/src/tools/taxonomies.js.map +1 -0
- package/dist/src/tools/users.d.ts +33 -0
- package/dist/src/tools/users.d.ts.map +1 -0
- package/dist/src/tools/users.js +308 -0
- package/dist/src/tools/users.js.map +1 -0
- package/dist/src/types/client.d.ts +223 -0
- package/dist/src/types/client.d.ts.map +1 -0
- package/dist/src/types/client.js +97 -0
- package/dist/src/types/client.js.map +1 -0
- package/dist/src/types/enhanced.d.ts +237 -0
- package/dist/src/types/enhanced.d.ts.map +1 -0
- package/dist/src/types/enhanced.js +49 -0
- package/dist/src/types/enhanced.js.map +1 -0
- package/dist/src/types/index.d.ts +160 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +14 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/mcp.d.ts +178 -0
- package/dist/src/types/mcp.d.ts.map +1 -0
- package/dist/src/types/mcp.js +7 -0
- package/dist/src/types/mcp.js.map +1 -0
- package/dist/src/types/requests.d.ts +322 -0
- package/dist/src/types/requests.d.ts.map +1 -0
- package/dist/src/types/requests.js +8 -0
- package/dist/src/types/requests.js.map +1 -0
- package/dist/src/types/tools.d.ts +506 -0
- package/dist/src/types/tools.d.ts.map +1 -0
- package/dist/src/types/tools.js +8 -0
- package/dist/src/types/tools.js.map +1 -0
- package/dist/src/types/wordpress.d.ts +471 -0
- package/dist/src/types/wordpress.d.ts.map +1 -0
- package/dist/src/types/wordpress.js +14 -0
- package/dist/src/types/wordpress.js.map +1 -0
- package/dist/src/utils/debug.d.ts +71 -0
- package/dist/src/utils/debug.d.ts.map +1 -0
- package/dist/src/utils/debug.js +235 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/enhancedError.d.ts +61 -0
- package/dist/src/utils/enhancedError.d.ts.map +1 -0
- package/dist/src/utils/enhancedError.js +221 -0
- package/dist/src/utils/enhancedError.js.map +1 -0
- package/dist/src/utils/error.d.ts +17 -0
- package/dist/src/utils/error.d.ts.map +1 -0
- package/dist/src/utils/error.js +108 -0
- package/dist/src/utils/error.js.map +1 -0
- package/dist/src/utils/logger.d.ts +106 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +280 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/streaming.d.ts +104 -0
- package/dist/src/utils/streaming.d.ts.map +1 -0
- package/dist/src/utils/streaming.js +331 -0
- package/dist/src/utils/streaming.js.map +1 -0
- package/dist/src/utils/toolWrapper.d.ts +42 -0
- package/dist/src/utils/toolWrapper.d.ts.map +1 -0
- package/dist/src/utils/toolWrapper.js +101 -0
- package/dist/src/utils/toolWrapper.js.map +1 -0
- package/dist/src/utils/validation/core.d.ts +21 -0
- package/dist/src/utils/validation/core.d.ts.map +1 -0
- package/dist/src/utils/validation/core.js +71 -0
- package/dist/src/utils/validation/core.js.map +1 -0
- package/dist/src/utils/validation/index.d.ts +25 -0
- package/dist/src/utils/validation/index.d.ts.map +1 -0
- package/dist/src/utils/validation/index.js +29 -0
- package/dist/src/utils/validation/index.js.map +1 -0
- package/dist/src/utils/validation/network.d.ts +19 -0
- package/dist/src/utils/validation/network.d.ts.map +1 -0
- package/dist/src/utils/validation/network.js +93 -0
- package/dist/src/utils/validation/network.js.map +1 -0
- package/dist/src/utils/validation/rateLimit.d.ts +21 -0
- package/dist/src/utils/validation/rateLimit.d.ts.map +1 -0
- package/dist/src/utils/validation/rateLimit.js +43 -0
- package/dist/src/utils/validation/rateLimit.js.map +1 -0
- package/dist/src/utils/validation/security.d.ts +29 -0
- package/dist/src/utils/validation/security.d.ts.map +1 -0
- package/dist/src/utils/validation/security.js +327 -0
- package/dist/src/utils/validation/security.js.map +1 -0
- package/dist/src/utils/validation/wordpress.d.ts +31 -0
- package/dist/src/utils/validation/wordpress.d.ts.map +1 -0
- package/dist/src/utils/validation/wordpress.js +146 -0
- package/dist/src/utils/validation/wordpress.js.map +1 -0
- package/dist/src/utils/validation.d.ts +15 -0
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/src/utils/validation.js +27 -0
- package/dist/src/utils/validation.js.map +1 -0
- package/dist/tests/vitest.setup.d.ts +6 -0
- package/dist/tests/vitest.setup.d.ts.map +1 -0
- package/dist/tests/vitest.setup.js +39 -0
- package/dist/tests/vitest.setup.js.map +1 -0
- package/dist/tools/BaseToolManager.d.ts +47 -11
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js +168 -29
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts +16 -10
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +3 -2
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts +30 -30
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js +1 -6
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts +20 -20
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +16 -9
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/media.d.ts +18 -16
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +16 -15
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts +19 -17
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +16 -12
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts +11 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +67 -34
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts/PostHandlers.d.ts +46 -0
- package/dist/tools/posts/PostHandlers.d.ts.map +1 -0
- package/dist/tools/posts/PostHandlers.js +400 -0
- package/dist/tools/posts/PostHandlers.js.map +1 -0
- package/dist/tools/posts/PostToolDefinitions.d.ts +37 -0
- package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -0
- package/dist/tools/posts/PostToolDefinitions.js +236 -0
- package/dist/tools/posts/PostToolDefinitions.js.map +1 -0
- package/dist/tools/posts/index.d.ts +138 -0
- package/dist/tools/posts/index.d.ts.map +1 -0
- package/dist/tools/posts/index.js +163 -0
- package/dist/tools/posts/index.js.map +1 -0
- package/dist/tools/posts.d.ts +10 -246
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +11 -723
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/site.d.ts +19 -18
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +14 -10
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +23 -24
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js +24 -18
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts +20 -15
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +12 -8
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +48 -41
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js +30 -5
- package/dist/types/client.js.map +1 -1
- package/dist/types/enhanced.d.ts +237 -0
- package/dist/types/enhanced.d.ts.map +1 -0
- package/dist/types/enhanced.js +49 -0
- package/dist/types/enhanced.js.map +1 -0
- package/dist/types/index.d.ts +15 -12
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/mcp.d.ts +12 -12
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/requests.d.ts +322 -0
- package/dist/types/requests.d.ts.map +1 -0
- package/dist/types/requests.js +8 -0
- package/dist/types/requests.js.map +1 -0
- package/dist/types/tools.d.ts +506 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +8 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/wordpress.d.ts +43 -15
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/types/wordpress.js +8 -1
- package/dist/types/wordpress.js.map +1 -1
- package/dist/utils/debug.d.ts +19 -11
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +46 -10
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/enhancedError.d.ts +8 -8
- package/dist/utils/enhancedError.d.ts.map +1 -1
- package/dist/utils/enhancedError.js.map +1 -1
- package/dist/utils/error.d.ts +2 -4
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +42 -5
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/logger.d.ts +106 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +280 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/streaming.d.ts +9 -9
- package/dist/utils/streaming.d.ts.map +1 -1
- package/dist/utils/streaming.js +71 -52
- package/dist/utils/streaming.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts +9 -7
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation/core.d.ts +21 -0
- package/dist/utils/validation/core.d.ts.map +1 -0
- package/dist/utils/validation/core.js +71 -0
- package/dist/utils/validation/core.js.map +1 -0
- package/dist/utils/validation/index.d.ts +25 -0
- package/dist/utils/validation/index.d.ts.map +1 -0
- package/dist/utils/validation/index.js +29 -0
- package/dist/utils/validation/index.js.map +1 -0
- package/dist/utils/validation/network.d.ts +19 -0
- package/dist/utils/validation/network.d.ts.map +1 -0
- package/dist/utils/validation/network.js +93 -0
- package/dist/utils/validation/network.js.map +1 -0
- package/dist/utils/validation/rateLimit.d.ts +21 -0
- package/dist/utils/validation/rateLimit.d.ts.map +1 -0
- package/dist/utils/validation/rateLimit.js +43 -0
- package/dist/utils/validation/rateLimit.js.map +1 -0
- package/dist/utils/validation/security.d.ts +29 -0
- package/dist/utils/validation/security.d.ts.map +1 -0
- package/dist/utils/validation/security.js +327 -0
- package/dist/utils/validation/security.js.map +1 -0
- package/dist/utils/validation/wordpress.d.ts +31 -0
- package/dist/utils/validation/wordpress.d.ts.map +1 -0
- package/dist/utils/validation/wordpress.js +146 -0
- package/dist/utils/validation/wordpress.js.map +1 -0
- package/dist/utils/validation.d.ts +13 -82
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +25 -343
- package/dist/utils/validation.js.map +1 -1
- package/docs/BADGE_UPDATES.md +132 -0
- package/docs/CI_CD_IMPROVEMENTS.md +191 -0
- package/docs/INCREMENTAL_COVERAGE.md +183 -0
- package/docs/INSTALLATION.md +4 -2
- package/docs/TROUBLESHOOTING.md +2 -1
- package/docs/api/README.md +3 -1
- package/docs/api/openapi.json +5 -1
- package/docs/api/summary.json +1 -1
- package/docs/api/tools/wp_create_post.md +12 -14
- package/docs/developer/TESTING.md +24 -19
- package/docs/examples/claude-desktop-config.md +1 -1
- package/docs/examples/docker-production.md +100 -93
- package/docs/examples/multi-site-setup.md +5 -4
- package/docs/examples/single-site-setup.md +3 -4
- package/docs/examples/use-case-workflows.md +4 -5
- package/docs/integrations/claude-desktop.md +39 -34
- package/docs/integrations/cline.md +4 -4
- package/docs/integrations/vs-code.md +9 -8
- package/docs/user-guides/DXT_INSTALLATION.md +2 -1
- package/docs/user-guides/SMITHERY_SETUP.md +10 -10
- package/package.json +57 -39
- package/src/cache/CacheInvalidation.ts +12 -5
- package/src/cache/CacheManager.ts +18 -15
- package/src/cache/HttpCacheWrapper.ts +30 -59
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +6 -5
- package/src/cache/index.ts +3 -14
- package/src/client/CachedWordPressClient.ts +32 -30
- package/src/client/MockWordPressClient.ts +4 -2
- package/src/client/api.ts +186 -64
- package/src/client/auth.ts +15 -40
- package/src/client/managers/AuthenticationManager.ts +337 -77
- package/src/client/managers/BaseManager.ts +18 -30
- package/src/client/managers/RequestManager.ts +39 -44
- package/src/config/Config.ts +308 -0
- package/src/config/ConfigurationSchema.ts +23 -2
- package/src/config/ServerConfiguration.ts +73 -49
- package/src/docs/DocumentationGenerator.ts +50 -39
- package/src/docs/MarkdownFormatter.ts +19 -29
- package/src/dxt-entry.cjs +26 -16
- package/src/dxt-entry.ts +17 -27
- package/src/index.ts +42 -28
- package/src/performance/MetricsCollector.ts +108 -86
- package/src/performance/PerformanceAnalytics.ts +69 -164
- package/src/performance/PerformanceMonitor.ts +32 -47
- package/src/performance/index.ts +2 -10
- package/src/security/AISecurityScanner.ts +22 -12
- package/src/security/AutomatedRemediation.ts +49 -18
- package/src/security/InputValidator.ts +9 -6
- package/src/security/SecurityCIPipeline.ts +53 -37
- package/src/security/SecurityConfig.ts +22 -22
- package/src/security/SecurityConfigManager.ts +23 -19
- package/src/security/SecurityMonitoring.ts +24 -21
- package/src/security/SecurityReviewer.ts +10 -7
- package/src/security/index.ts +64 -29
- package/src/server/ConnectionTester.ts +120 -31
- package/src/server/ToolRegistry.ts +31 -21
- package/src/tools/BaseToolManager.ts +286 -33
- package/src/tools/auth.ts +20 -8
- package/src/tools/cache.ts +5 -15
- package/src/tools/comments.ts +34 -48
- package/src/tools/media.ts +41 -53
- package/src/tools/pages.ts +32 -54
- package/src/tools/performance.ts +141 -176
- package/src/tools/posts/PostHandlers.ts +474 -0
- package/src/tools/posts/PostToolDefinitions.ts +250 -0
- package/src/tools/posts/index.ts +192 -0
- package/src/tools/posts.ts +24 -780
- package/src/tools/site.ts +34 -19
- package/src/tools/taxonomies.ts +41 -57
- package/src/tools/users.ts +28 -16
- package/src/types/client.ts +114 -138
- package/src/types/enhanced.ts +318 -0
- package/src/types/index.ts +51 -30
- package/src/types/mcp.ts +20 -42
- package/src/types/requests.ts +378 -0
- package/src/types/tools.ts +608 -0
- package/src/types/wordpress.ts +56 -34
- package/src/utils/debug.ts +77 -59
- package/src/utils/enhancedError.ts +8 -8
- package/src/utils/error.ts +53 -31
- package/src/utils/logger.ts +351 -0
- package/src/utils/streaming.ts +86 -68
- package/src/utils/toolWrapper.ts +10 -12
- package/src/utils/validation/core.ts +108 -0
- package/src/utils/validation/index.ts +36 -0
- package/src/utils/validation/network.ts +132 -0
- package/src/utils/validation/rateLimit.ts +54 -0
- package/src/utils/validation/security.ts +361 -0
- package/src/utils/validation/wordpress.ts +180 -0
- package/src/utils/validation.ts +47 -470
- package/dist/cache/__tests__/CacheInvalidation.test.d.ts +0 -5
- package/dist/cache/__tests__/CacheInvalidation.test.d.ts.map +0 -1
- package/dist/cache/__tests__/CacheInvalidation.test.js +0 -238
- package/dist/cache/__tests__/CacheInvalidation.test.js.map +0 -1
- package/dist/cache/__tests__/CacheManager.test.d.ts +0 -5
- package/dist/cache/__tests__/CacheManager.test.d.ts.map +0 -1
- package/dist/cache/__tests__/CacheManager.test.js +0 -233
- package/dist/cache/__tests__/CacheManager.test.js.map +0 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.d.ts +0 -5
- package/dist/cache/__tests__/CachedWordPressClient.test.d.ts.map +0 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.js +0 -231
- package/dist/cache/__tests__/CachedWordPressClient.test.js.map +0 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts +0 -5
- package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts.map +0 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +0 -299
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +0 -1
|
@@ -3,122 +3,203 @@
|
|
|
3
3
|
* Handles all authentication methods and token management
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
AuthConfig,
|
|
8
|
+
WordPressClientConfig,
|
|
9
|
+
AuthStatus,
|
|
10
|
+
AppPasswordCredentials,
|
|
11
|
+
JwtCredentials,
|
|
12
|
+
BasicCredentials,
|
|
13
|
+
ApiKeyCredentials,
|
|
14
|
+
} from "../../types/client.js";
|
|
7
15
|
import { AuthenticationError } from "../../types/client.js";
|
|
16
|
+
import { AUTH_METHODS, type AuthMethod } from "../../types/wordpress.js";
|
|
17
|
+
import { config } from "../../config/Config.js";
|
|
8
18
|
import { BaseManager } from "./BaseManager.js";
|
|
9
19
|
import { debug } from "../../utils/debug.js";
|
|
10
20
|
|
|
21
|
+
interface AuthManagerConfig extends WordPressClientConfig {
|
|
22
|
+
siteUrl: string; // Required based on constructor validation
|
|
23
|
+
authMethod: AuthMethod; // Use proper AuthMethod type
|
|
24
|
+
username?: string;
|
|
25
|
+
appPassword?: string;
|
|
26
|
+
password?: string;
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
jwtSecret?: string;
|
|
29
|
+
jwtToken?: string;
|
|
30
|
+
tokenExpiry?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
export class AuthenticationManager extends BaseManager {
|
|
12
34
|
private jwtToken: string | null = null;
|
|
13
35
|
private authenticated: boolean = false;
|
|
36
|
+
private authConfig: AuthManagerConfig;
|
|
37
|
+
public config: AuthManagerConfig; // Expose for test compatibility
|
|
38
|
+
|
|
39
|
+
constructor(config: AuthManagerConfig) {
|
|
40
|
+
// Validate required config fields
|
|
41
|
+
if (!config.siteUrl || config.siteUrl.trim() === "") {
|
|
42
|
+
throw new AuthenticationError("Site URL is required", AUTH_METHODS.APP_PASSWORD);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Validate site URL format
|
|
46
|
+
try {
|
|
47
|
+
new URL(config.siteUrl);
|
|
48
|
+
} catch {
|
|
49
|
+
throw new AuthenticationError("Invalid site URL", AUTH_METHODS.APP_PASSWORD);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Validate auth method using centralized constants
|
|
53
|
+
const validMethods = Object.values(AUTH_METHODS);
|
|
54
|
+
if (config.authMethod && !validMethods.includes(config.authMethod)) {
|
|
55
|
+
throw new AuthenticationError("Invalid authentication method", config.authMethod);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Transform config to match expected format
|
|
59
|
+
const transformedConfig: WordPressClientConfig = {
|
|
60
|
+
baseUrl: config.siteUrl,
|
|
61
|
+
timeout: config.timeout || 30000,
|
|
62
|
+
auth: {
|
|
63
|
+
method: config.authMethod || AUTH_METHODS.APP_PASSWORD,
|
|
64
|
+
...(config.username && { username: config.username }),
|
|
65
|
+
...(config.appPassword && { appPassword: config.appPassword }),
|
|
66
|
+
...(config.password && { password: config.password }),
|
|
67
|
+
...(config.apiKey && { apiKey: config.apiKey }),
|
|
68
|
+
...(config.jwtSecret && { secret: config.jwtSecret }),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
super(transformedConfig);
|
|
73
|
+
|
|
74
|
+
// Store private config
|
|
75
|
+
this.authConfig = config;
|
|
76
|
+
// Expose config for test compatibility
|
|
77
|
+
this.config = config;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get config for testing purposes
|
|
82
|
+
*/
|
|
83
|
+
getConfig(): AuthManagerConfig {
|
|
84
|
+
return { ...this.authConfig };
|
|
85
|
+
}
|
|
14
86
|
|
|
15
87
|
/**
|
|
16
88
|
* Get authentication from environment variables
|
|
17
89
|
*/
|
|
18
90
|
static getAuthFromEnv(): AuthConfig {
|
|
19
|
-
const
|
|
91
|
+
const cfg = config();
|
|
92
|
+
const wp = cfg.wordpress;
|
|
93
|
+
const method: AuthMethod = (wp.authMethod as AuthMethod) || AUTH_METHODS.APP_PASSWORD;
|
|
20
94
|
|
|
21
95
|
switch (method) {
|
|
22
|
-
case
|
|
96
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
23
97
|
return {
|
|
24
|
-
method:
|
|
25
|
-
username:
|
|
26
|
-
appPassword:
|
|
98
|
+
method: AUTH_METHODS.APP_PASSWORD,
|
|
99
|
+
username: wp.username || "",
|
|
100
|
+
appPassword: wp.appPassword || "",
|
|
27
101
|
};
|
|
28
102
|
|
|
29
|
-
case
|
|
103
|
+
case AUTH_METHODS.JWT:
|
|
30
104
|
return {
|
|
31
|
-
method:
|
|
32
|
-
username:
|
|
33
|
-
password:
|
|
34
|
-
secret:
|
|
105
|
+
method: AUTH_METHODS.JWT,
|
|
106
|
+
username: wp.username || "",
|
|
107
|
+
password: wp.jwtPassword || wp.password || "",
|
|
108
|
+
secret: wp.jwtSecret || "",
|
|
35
109
|
};
|
|
36
110
|
|
|
37
|
-
case
|
|
111
|
+
case AUTH_METHODS.BASIC:
|
|
38
112
|
return {
|
|
39
|
-
method:
|
|
40
|
-
username:
|
|
41
|
-
password:
|
|
113
|
+
method: AUTH_METHODS.BASIC,
|
|
114
|
+
username: wp.username || "",
|
|
115
|
+
password: wp.password || "",
|
|
42
116
|
};
|
|
43
117
|
|
|
44
|
-
case
|
|
118
|
+
case AUTH_METHODS.API_KEY:
|
|
45
119
|
return {
|
|
46
|
-
method:
|
|
47
|
-
apiKey:
|
|
120
|
+
method: AUTH_METHODS.API_KEY,
|
|
121
|
+
apiKey: wp.apiKey || "",
|
|
48
122
|
};
|
|
49
123
|
|
|
50
124
|
default:
|
|
51
|
-
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method);
|
|
125
|
+
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method as AuthMethod);
|
|
52
126
|
}
|
|
53
127
|
}
|
|
54
128
|
|
|
55
129
|
/**
|
|
56
130
|
* Get authentication headers for requests
|
|
131
|
+
*
|
|
132
|
+
* Note: This method is synchronous by design for test compatibility and simplicity.
|
|
133
|
+
* JWT token refresh should be handled externally before calling this method,
|
|
134
|
+
* as automatic refresh would require RequestManager integration.
|
|
57
135
|
*/
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
if (!auth) {
|
|
62
|
-
// In test environments, return empty headers instead of throwing
|
|
63
|
-
if (
|
|
64
|
-
process.env.NODE_ENV === "test" ||
|
|
65
|
-
process.env.CI === "true" ||
|
|
66
|
-
(globalThis as any).__EXECUTION_CONTEXT__ === "jest"
|
|
67
|
-
) {
|
|
68
|
-
debug.log("Warning: No authentication configuration in test environment, returning empty headers");
|
|
69
|
-
return {};
|
|
70
|
-
}
|
|
71
|
-
throw new AuthenticationError("Authentication configuration is required", "app-password");
|
|
72
|
-
}
|
|
136
|
+
getAuthHeaders(): Record<string, string> {
|
|
137
|
+
const method = this.authConfig.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
73
138
|
|
|
74
|
-
switch (
|
|
75
|
-
case
|
|
76
|
-
if (!
|
|
77
|
-
throw new AuthenticationError("Username and app password are required",
|
|
139
|
+
switch (method) {
|
|
140
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
141
|
+
if (!this.authConfig.username || !this.authConfig.appPassword) {
|
|
142
|
+
throw new AuthenticationError("Username and app password are required", method);
|
|
78
143
|
}
|
|
79
144
|
|
|
80
|
-
const credentials = Buffer.from(`${
|
|
145
|
+
const credentials = Buffer.from(`${this.authConfig.username}:${this.authConfig.appPassword}`).toString(
|
|
146
|
+
"base64",
|
|
147
|
+
);
|
|
81
148
|
return { Authorization: `Basic ${credentials}` };
|
|
82
149
|
|
|
83
|
-
case
|
|
84
|
-
if (!this.jwtToken) {
|
|
85
|
-
|
|
150
|
+
case AUTH_METHODS.JWT:
|
|
151
|
+
if (!this.authConfig.jwtToken) {
|
|
152
|
+
throw new AuthenticationError("JWT token is required", method);
|
|
86
153
|
}
|
|
87
|
-
return { Authorization: `Bearer ${this.jwtToken}` };
|
|
154
|
+
return { Authorization: `Bearer ${this.authConfig.jwtToken}` };
|
|
88
155
|
|
|
89
|
-
case
|
|
90
|
-
if (!
|
|
91
|
-
throw new AuthenticationError("Username and password are required",
|
|
156
|
+
case AUTH_METHODS.BASIC:
|
|
157
|
+
if (!this.authConfig.username || !this.authConfig.password) {
|
|
158
|
+
throw new AuthenticationError("Username and password are required", method);
|
|
92
159
|
}
|
|
93
160
|
|
|
94
|
-
const basicCredentials = Buffer.from(`${
|
|
161
|
+
const basicCredentials = Buffer.from(`${this.authConfig.username}:${this.authConfig.password}`).toString(
|
|
162
|
+
"base64",
|
|
163
|
+
);
|
|
95
164
|
return { Authorization: `Basic ${basicCredentials}` };
|
|
96
165
|
|
|
97
|
-
case
|
|
98
|
-
if (!
|
|
99
|
-
throw new AuthenticationError("API key is required",
|
|
166
|
+
case AUTH_METHODS.API_KEY:
|
|
167
|
+
if (!this.authConfig.apiKey) {
|
|
168
|
+
throw new AuthenticationError("API key is required", method);
|
|
100
169
|
}
|
|
101
|
-
return { "X-API-Key":
|
|
170
|
+
return { "X-API-Key": this.authConfig.apiKey };
|
|
171
|
+
|
|
172
|
+
case AUTH_METHODS.COOKIE:
|
|
173
|
+
// Cookie authentication typically handled by browser
|
|
174
|
+
return {};
|
|
102
175
|
|
|
103
176
|
default:
|
|
104
|
-
throw new AuthenticationError(`Unsupported authentication method: ${
|
|
177
|
+
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method as AuthMethod);
|
|
105
178
|
}
|
|
106
179
|
}
|
|
107
180
|
|
|
108
181
|
/**
|
|
109
182
|
* Authenticate using JWT
|
|
183
|
+
*
|
|
184
|
+
* Note: This method is not fully implemented as it requires integration with
|
|
185
|
+
* the RequestManager to make HTTP requests to the WordPress JWT endpoint.
|
|
186
|
+
* JWT authentication requires the JWT Authentication for WP-API plugin.
|
|
187
|
+
*
|
|
188
|
+
* @throws {AuthenticationError} - JWT auth requires external dependency injection
|
|
110
189
|
*/
|
|
111
190
|
private async authenticateJWT(): Promise<void> {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (auth.method !== "jwt" || !auth.username || !auth.password) {
|
|
115
|
-
throw new AuthenticationError("JWT authentication requires username and password", "jwt");
|
|
191
|
+
if (this.authConfig.authMethod !== AUTH_METHODS.JWT || !this.authConfig.username || !this.authConfig.password) {
|
|
192
|
+
throw new AuthenticationError("JWT authentication requires username and password", AUTH_METHODS.JWT);
|
|
116
193
|
}
|
|
117
194
|
|
|
118
195
|
try {
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
|
|
196
|
+
// TODO: Implement JWT authentication with RequestManager integration
|
|
197
|
+
// This would require making a POST request to /wp-json/jwt-auth/v1/token
|
|
198
|
+
// with username and password to obtain a JWT token
|
|
199
|
+
throw new AuthenticationError(
|
|
200
|
+
"JWT authentication requires RequestManager integration - not yet implemented",
|
|
201
|
+
AUTH_METHODS.JWT,
|
|
202
|
+
);
|
|
122
203
|
} catch (error) {
|
|
123
204
|
this.handleError(error, "JWT authentication");
|
|
124
205
|
}
|
|
@@ -131,7 +212,7 @@ export class AuthenticationManager extends BaseManager {
|
|
|
131
212
|
try {
|
|
132
213
|
const _headers = await this.getAuthHeaders();
|
|
133
214
|
debug.log("Authentication headers prepared", {
|
|
134
|
-
method: this.
|
|
215
|
+
method: this.authConfig.authMethod,
|
|
135
216
|
});
|
|
136
217
|
|
|
137
218
|
// This would need the RequestManager to actually test the connection
|
|
@@ -164,42 +245,221 @@ export class AuthenticationManager extends BaseManager {
|
|
|
164
245
|
* Validate authentication configuration
|
|
165
246
|
*/
|
|
166
247
|
validateAuthConfig(): void {
|
|
167
|
-
const
|
|
248
|
+
const method = this.authConfig.authMethod;
|
|
168
249
|
|
|
169
|
-
if (!
|
|
170
|
-
throw new AuthenticationError("Authentication method is required",
|
|
250
|
+
if (!method) {
|
|
251
|
+
throw new AuthenticationError("Authentication method is required", AUTH_METHODS.APP_PASSWORD);
|
|
171
252
|
}
|
|
172
253
|
|
|
173
|
-
switch (
|
|
174
|
-
case
|
|
175
|
-
if (!
|
|
254
|
+
switch (method) {
|
|
255
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
256
|
+
if (!this.authConfig.username || !this.authConfig.appPassword) {
|
|
176
257
|
throw new AuthenticationError(
|
|
177
258
|
"App password authentication requires username and appPassword",
|
|
178
|
-
|
|
259
|
+
AUTH_METHODS.APP_PASSWORD,
|
|
179
260
|
);
|
|
180
261
|
}
|
|
181
262
|
break;
|
|
182
263
|
|
|
183
|
-
case
|
|
184
|
-
if (!
|
|
185
|
-
throw new AuthenticationError("JWT authentication requires username, password, and secret",
|
|
264
|
+
case AUTH_METHODS.JWT:
|
|
265
|
+
if (!this.authConfig.username || !this.authConfig.password || !this.authConfig.jwtSecret) {
|
|
266
|
+
throw new AuthenticationError("JWT authentication requires username, password, and secret", AUTH_METHODS.JWT);
|
|
186
267
|
}
|
|
187
268
|
break;
|
|
188
269
|
|
|
189
|
-
case
|
|
190
|
-
if (!
|
|
191
|
-
throw new AuthenticationError("Basic authentication requires username and password",
|
|
270
|
+
case AUTH_METHODS.BASIC:
|
|
271
|
+
if (!this.authConfig.username || !this.authConfig.password) {
|
|
272
|
+
throw new AuthenticationError("Basic authentication requires username and password", AUTH_METHODS.BASIC);
|
|
192
273
|
}
|
|
193
274
|
break;
|
|
194
275
|
|
|
195
|
-
case
|
|
196
|
-
if (!
|
|
197
|
-
throw new AuthenticationError("API key authentication requires apiKey",
|
|
276
|
+
case AUTH_METHODS.API_KEY:
|
|
277
|
+
if (!this.authConfig.apiKey) {
|
|
278
|
+
throw new AuthenticationError("API key authentication requires apiKey", AUTH_METHODS.API_KEY);
|
|
198
279
|
}
|
|
199
280
|
break;
|
|
200
281
|
|
|
201
282
|
default:
|
|
202
|
-
throw new AuthenticationError(`Unsupported authentication method: ${
|
|
283
|
+
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Validate credentials for current auth method
|
|
289
|
+
*/
|
|
290
|
+
validateCredentials(): void {
|
|
291
|
+
const method = this.authConfig.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
292
|
+
|
|
293
|
+
switch (method) {
|
|
294
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
295
|
+
if (!this.authConfig.username) {
|
|
296
|
+
throw new AuthenticationError("Username is required", method);
|
|
297
|
+
}
|
|
298
|
+
if (!this.authConfig.appPassword) {
|
|
299
|
+
throw new AuthenticationError("App password is required", method);
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
|
|
303
|
+
case AUTH_METHODS.JWT:
|
|
304
|
+
if (!this.authConfig.jwtToken) {
|
|
305
|
+
throw new AuthenticationError("JWT token is required", method);
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
|
|
309
|
+
case AUTH_METHODS.BASIC:
|
|
310
|
+
if (!this.authConfig.username) {
|
|
311
|
+
throw new AuthenticationError("Username is required", method);
|
|
312
|
+
}
|
|
313
|
+
if (!this.authConfig.password) {
|
|
314
|
+
throw new AuthenticationError("Password is required", method);
|
|
315
|
+
}
|
|
316
|
+
break;
|
|
317
|
+
|
|
318
|
+
case AUTH_METHODS.API_KEY:
|
|
319
|
+
if (!this.authConfig.apiKey) {
|
|
320
|
+
throw new AuthenticationError("API key is required", method);
|
|
321
|
+
}
|
|
322
|
+
break;
|
|
323
|
+
|
|
324
|
+
default:
|
|
325
|
+
throw new AuthenticationError(`Invalid authentication method: ${method}`, method);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Update authentication method and credentials
|
|
331
|
+
*/
|
|
332
|
+
updateAuthMethod(
|
|
333
|
+
method: AuthMethod,
|
|
334
|
+
credentials: AppPasswordCredentials | JwtCredentials | BasicCredentials | ApiKeyCredentials,
|
|
335
|
+
): void {
|
|
336
|
+
const validMethods = Object.values(AUTH_METHODS);
|
|
337
|
+
if (!validMethods.includes(method)) {
|
|
338
|
+
throw new AuthenticationError("Invalid authentication method", method);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Clear all previous credentials to prevent leakage
|
|
342
|
+
delete this.authConfig.username;
|
|
343
|
+
delete this.authConfig.appPassword;
|
|
344
|
+
delete this.authConfig.jwtToken;
|
|
345
|
+
delete this.authConfig.password;
|
|
346
|
+
delete this.authConfig.apiKey;
|
|
347
|
+
delete this.authConfig.tokenExpiry;
|
|
348
|
+
|
|
349
|
+
// Set new auth method
|
|
350
|
+
this.authConfig.authMethod = method;
|
|
351
|
+
|
|
352
|
+
// Set new credentials with type safety and validation
|
|
353
|
+
switch (method) {
|
|
354
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
355
|
+
const appCreds = credentials as AppPasswordCredentials;
|
|
356
|
+
if (!appCreds.username || !appCreds.appPassword) {
|
|
357
|
+
throw new AuthenticationError("Username and app password are required", method);
|
|
358
|
+
}
|
|
359
|
+
this.authConfig.username = appCreds.username;
|
|
360
|
+
this.authConfig.appPassword = appCreds.appPassword;
|
|
361
|
+
break;
|
|
362
|
+
|
|
363
|
+
case AUTH_METHODS.JWT:
|
|
364
|
+
const jwtCreds = credentials as JwtCredentials;
|
|
365
|
+
if (!jwtCreds.jwtToken) {
|
|
366
|
+
throw new AuthenticationError("JWT token is required", method);
|
|
367
|
+
}
|
|
368
|
+
this.authConfig.jwtToken = jwtCreds.jwtToken;
|
|
369
|
+
if (jwtCreds.username) {
|
|
370
|
+
this.authConfig.username = jwtCreds.username;
|
|
371
|
+
}
|
|
372
|
+
break;
|
|
373
|
+
|
|
374
|
+
case AUTH_METHODS.BASIC:
|
|
375
|
+
const basicCreds = credentials as BasicCredentials;
|
|
376
|
+
if (!basicCreds.username || !basicCreds.password) {
|
|
377
|
+
throw new AuthenticationError("Username and password are required", method);
|
|
378
|
+
}
|
|
379
|
+
this.authConfig.username = basicCreds.username;
|
|
380
|
+
this.authConfig.password = basicCreds.password;
|
|
381
|
+
break;
|
|
382
|
+
|
|
383
|
+
case AUTH_METHODS.API_KEY:
|
|
384
|
+
const apiCreds = credentials as ApiKeyCredentials;
|
|
385
|
+
if (!apiCreds.apiKey) {
|
|
386
|
+
throw new AuthenticationError("API key is required", method);
|
|
387
|
+
}
|
|
388
|
+
this.authConfig.apiKey = apiCreds.apiKey;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Refresh JWT token
|
|
395
|
+
*
|
|
396
|
+
* For testing compatibility, this method supports mock JWT refresh.
|
|
397
|
+
* In production, it requires RequestManager integration.
|
|
398
|
+
*/
|
|
399
|
+
async refreshToken(): Promise<void> {
|
|
400
|
+
if (this.authConfig.authMethod !== AUTH_METHODS.JWT) {
|
|
401
|
+
throw new AuthenticationError(
|
|
402
|
+
"Token refresh not supported for non-JWT authentication methods",
|
|
403
|
+
this.authConfig.authMethod,
|
|
404
|
+
);
|
|
203
405
|
}
|
|
406
|
+
|
|
407
|
+
// Check if mock refresh method is available (for testing)
|
|
408
|
+
const mockRefreshMethod = (this as Record<string, unknown>).refreshJwtToken;
|
|
409
|
+
if (typeof mockRefreshMethod === "function") {
|
|
410
|
+
const result = await mockRefreshMethod();
|
|
411
|
+
if (result && typeof result === "object" && "token" in result) {
|
|
412
|
+
const tokenResult = result as { token: string; expires_in?: number };
|
|
413
|
+
this.authConfig.jwtToken = tokenResult.token;
|
|
414
|
+
if (tokenResult.expires_in) {
|
|
415
|
+
this.authConfig.tokenExpiry = Date.now() + tokenResult.expires_in * 1000;
|
|
416
|
+
}
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// TODO: Implement JWT token refresh with RequestManager integration
|
|
422
|
+
// This would require making a POST request to /wp-json/jwt-auth/v1/token/validate
|
|
423
|
+
// and updating the stored token and expiry
|
|
424
|
+
throw new AuthenticationError(
|
|
425
|
+
"JWT refresh requires RequestManager integration - not yet implemented",
|
|
426
|
+
AUTH_METHODS.JWT,
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Check if JWT token is expired
|
|
432
|
+
*/
|
|
433
|
+
isTokenExpired(): boolean {
|
|
434
|
+
if (this.authConfig.authMethod !== AUTH_METHODS.JWT) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (!this.authConfig.tokenExpiry) {
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return Date.now() >= this.authConfig.tokenExpiry;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Get authentication status
|
|
447
|
+
*/
|
|
448
|
+
getAuthStatus(): AuthStatus {
|
|
449
|
+
const method = this.authConfig.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
450
|
+
const isExpired = this.isTokenExpired();
|
|
451
|
+
|
|
452
|
+
const status: AuthStatus = {
|
|
453
|
+
method,
|
|
454
|
+
username: this.authConfig.username,
|
|
455
|
+
isAuthenticated: method === AUTH_METHODS.JWT ? !isExpired : true,
|
|
456
|
+
tokenExpired: isExpired,
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
if (method === AUTH_METHODS.JWT && this.authConfig.tokenExpiry) {
|
|
460
|
+
status.tokenExpiry = this.authConfig.tokenExpiry;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return status;
|
|
204
464
|
}
|
|
205
465
|
}
|
|
@@ -18,58 +18,46 @@ export abstract class BaseManager {
|
|
|
18
18
|
/**
|
|
19
19
|
* Standardized error handling for all managers
|
|
20
20
|
*/
|
|
21
|
-
protected handleError(error:
|
|
22
|
-
logError(`${operation} failed:`, error);
|
|
21
|
+
protected handleError(error: unknown, operation: string): never {
|
|
22
|
+
logError(`${operation} failed:`, error as Record<string, unknown>);
|
|
23
23
|
|
|
24
24
|
if (error instanceof WordPressAPIError) {
|
|
25
25
|
throw error;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
// Type guard for error-like objects
|
|
29
|
+
const isErrorLike = (err: unknown): err is { name?: string; code?: string; message?: string } => {
|
|
30
|
+
return typeof err === "object" && err !== null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (isErrorLike(error)) {
|
|
34
|
+
if (error.name === "AbortError" || error.code === "ABORT_ERR") {
|
|
35
|
+
throw new WordPressAPIError(`Request timeout after ${this.config.timeout}ms`, 408, "timeout");
|
|
36
|
+
}
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
503,
|
|
40
|
-
"connection_failed",
|
|
41
|
-
);
|
|
38
|
+
if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
|
|
39
|
+
throw new WordPressAPIError(`Cannot connect to WordPress site: ${this.config.baseUrl}`, 503, "connection_failed");
|
|
40
|
+
}
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
const message = getErrorMessage(error);
|
|
45
|
-
throw new WordPressAPIError(
|
|
46
|
-
`${operation} failed: ${message}`,
|
|
47
|
-
500,
|
|
48
|
-
"unknown_error",
|
|
49
|
-
);
|
|
44
|
+
throw new WordPressAPIError(`${operation} failed: ${message}`, 500, "unknown_error");
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
/**
|
|
53
48
|
* Standardized success logging
|
|
54
49
|
*/
|
|
55
|
-
protected logSuccess(operation: string, details?:
|
|
50
|
+
protected logSuccess(operation: string, details?: unknown): void {
|
|
56
51
|
debug.log(`${operation} completed successfully`, details);
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
/**
|
|
60
55
|
* Validate required parameters
|
|
61
56
|
*/
|
|
62
|
-
protected validateRequired(
|
|
63
|
-
params: Record<string, any>,
|
|
64
|
-
requiredFields: string[],
|
|
65
|
-
): void {
|
|
57
|
+
protected validateRequired(params: Record<string, unknown>, requiredFields: string[]): void {
|
|
66
58
|
for (const field of requiredFields) {
|
|
67
59
|
if (params[field] === undefined || params[field] === null) {
|
|
68
|
-
throw new WordPressAPIError(
|
|
69
|
-
`Missing required parameter: ${field}`,
|
|
70
|
-
400,
|
|
71
|
-
"missing_parameter",
|
|
72
|
-
);
|
|
60
|
+
throw new WordPressAPIError(`Missing required parameter: ${field}`, 400, "missing_parameter");
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
63
|
}
|