mcp-wordpress 2.4.2 → 2.5.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/README.md +114 -48
- package/dist/ajv-patch.js +34 -0
- 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/__tests__/HttpCacheWrapper.test.js +6 -5
- package/dist/cache/__tests__/HttpCacheWrapper.test.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 +50 -41
- 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.cjs +81 -0
- 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/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/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/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 +31 -31
- package/docs/integrations/cline.md +4 -4
- package/docs/integrations/vs-code.md +9 -8
- package/docs/user-guides/SMITHERY_SETUP.md +10 -10
- package/package.json +44 -25
- 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 +51 -47
- 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
|
@@ -3,40 +3,88 @@
|
|
|
3
3
|
* Handles all authentication methods and token management
|
|
4
4
|
*/
|
|
5
5
|
import { AuthenticationError } from "../../types/client.js";
|
|
6
|
+
import { AUTH_METHODS } from "../../types/wordpress.js";
|
|
7
|
+
import { config } from "../../config/Config.js";
|
|
6
8
|
import { BaseManager } from "./BaseManager.js";
|
|
7
9
|
import { debug } from "../../utils/debug.js";
|
|
8
10
|
export class AuthenticationManager extends BaseManager {
|
|
9
11
|
jwtToken = null;
|
|
10
12
|
authenticated = false;
|
|
13
|
+
authConfig;
|
|
14
|
+
config; // Expose for test compatibility
|
|
15
|
+
constructor(config) {
|
|
16
|
+
// Validate required config fields
|
|
17
|
+
if (!config.siteUrl || config.siteUrl.trim() === "") {
|
|
18
|
+
throw new AuthenticationError("Site URL is required", AUTH_METHODS.APP_PASSWORD);
|
|
19
|
+
}
|
|
20
|
+
// Validate site URL format
|
|
21
|
+
try {
|
|
22
|
+
new URL(config.siteUrl);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new AuthenticationError("Invalid site URL", AUTH_METHODS.APP_PASSWORD);
|
|
26
|
+
}
|
|
27
|
+
// Validate auth method using centralized constants
|
|
28
|
+
const validMethods = Object.values(AUTH_METHODS);
|
|
29
|
+
if (config.authMethod && !validMethods.includes(config.authMethod)) {
|
|
30
|
+
throw new AuthenticationError("Invalid authentication method", config.authMethod);
|
|
31
|
+
}
|
|
32
|
+
// Transform config to match expected format
|
|
33
|
+
const transformedConfig = {
|
|
34
|
+
baseUrl: config.siteUrl,
|
|
35
|
+
timeout: config.timeout || 30000,
|
|
36
|
+
auth: {
|
|
37
|
+
method: config.authMethod || AUTH_METHODS.APP_PASSWORD,
|
|
38
|
+
...(config.username && { username: config.username }),
|
|
39
|
+
...(config.appPassword && { appPassword: config.appPassword }),
|
|
40
|
+
...(config.password && { password: config.password }),
|
|
41
|
+
...(config.apiKey && { apiKey: config.apiKey }),
|
|
42
|
+
...(config.jwtSecret && { secret: config.jwtSecret }),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
super(transformedConfig);
|
|
46
|
+
// Store private config
|
|
47
|
+
this.authConfig = config;
|
|
48
|
+
// Expose config for test compatibility
|
|
49
|
+
this.config = config;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get config for testing purposes
|
|
53
|
+
*/
|
|
54
|
+
getConfig() {
|
|
55
|
+
return { ...this.authConfig };
|
|
56
|
+
}
|
|
11
57
|
/**
|
|
12
58
|
* Get authentication from environment variables
|
|
13
59
|
*/
|
|
14
60
|
static getAuthFromEnv() {
|
|
15
|
-
const
|
|
61
|
+
const cfg = config();
|
|
62
|
+
const wp = cfg.wordpress;
|
|
63
|
+
const method = wp.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
16
64
|
switch (method) {
|
|
17
|
-
case
|
|
65
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
18
66
|
return {
|
|
19
|
-
method:
|
|
20
|
-
username:
|
|
21
|
-
appPassword:
|
|
67
|
+
method: AUTH_METHODS.APP_PASSWORD,
|
|
68
|
+
username: wp.username || "",
|
|
69
|
+
appPassword: wp.appPassword || "",
|
|
22
70
|
};
|
|
23
|
-
case
|
|
71
|
+
case AUTH_METHODS.JWT:
|
|
24
72
|
return {
|
|
25
|
-
method:
|
|
26
|
-
username:
|
|
27
|
-
password:
|
|
28
|
-
secret:
|
|
73
|
+
method: AUTH_METHODS.JWT,
|
|
74
|
+
username: wp.username || "",
|
|
75
|
+
password: wp.jwtPassword || wp.password || "",
|
|
76
|
+
secret: wp.jwtSecret || "",
|
|
29
77
|
};
|
|
30
|
-
case
|
|
78
|
+
case AUTH_METHODS.BASIC:
|
|
31
79
|
return {
|
|
32
|
-
method:
|
|
33
|
-
username:
|
|
34
|
-
password:
|
|
80
|
+
method: AUTH_METHODS.BASIC,
|
|
81
|
+
username: wp.username || "",
|
|
82
|
+
password: wp.password || "",
|
|
35
83
|
};
|
|
36
|
-
case
|
|
84
|
+
case AUTH_METHODS.API_KEY:
|
|
37
85
|
return {
|
|
38
|
-
method:
|
|
39
|
-
apiKey:
|
|
86
|
+
method: AUTH_METHODS.API_KEY,
|
|
87
|
+
apiKey: wp.apiKey || "",
|
|
40
88
|
};
|
|
41
89
|
default:
|
|
42
90
|
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method);
|
|
@@ -44,58 +92,61 @@ export class AuthenticationManager extends BaseManager {
|
|
|
44
92
|
}
|
|
45
93
|
/**
|
|
46
94
|
* Get authentication headers for requests
|
|
95
|
+
*
|
|
96
|
+
* Note: This method is synchronous by design for test compatibility and simplicity.
|
|
97
|
+
* JWT token refresh should be handled externally before calling this method,
|
|
98
|
+
* as automatic refresh would require RequestManager integration.
|
|
47
99
|
*/
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
globalThis.__EXECUTION_CONTEXT__ === "jest") {
|
|
55
|
-
debug.log("Warning: No authentication configuration in test environment, returning empty headers");
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
throw new AuthenticationError("Authentication configuration is required", "app-password");
|
|
59
|
-
}
|
|
60
|
-
switch (auth.method) {
|
|
61
|
-
case "app-password":
|
|
62
|
-
if (!auth.username || !auth.appPassword) {
|
|
63
|
-
throw new AuthenticationError("Username and app password are required", auth.method);
|
|
100
|
+
getAuthHeaders() {
|
|
101
|
+
const method = this.authConfig.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
102
|
+
switch (method) {
|
|
103
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
104
|
+
if (!this.authConfig.username || !this.authConfig.appPassword) {
|
|
105
|
+
throw new AuthenticationError("Username and app password are required", method);
|
|
64
106
|
}
|
|
65
|
-
const credentials = Buffer.from(`${
|
|
107
|
+
const credentials = Buffer.from(`${this.authConfig.username}:${this.authConfig.appPassword}`).toString("base64");
|
|
66
108
|
return { Authorization: `Basic ${credentials}` };
|
|
67
|
-
case
|
|
68
|
-
if (!this.jwtToken) {
|
|
69
|
-
|
|
109
|
+
case AUTH_METHODS.JWT:
|
|
110
|
+
if (!this.authConfig.jwtToken) {
|
|
111
|
+
throw new AuthenticationError("JWT token is required", method);
|
|
70
112
|
}
|
|
71
|
-
return { Authorization: `Bearer ${this.jwtToken}` };
|
|
72
|
-
case
|
|
73
|
-
if (!
|
|
74
|
-
throw new AuthenticationError("Username and password are required",
|
|
113
|
+
return { Authorization: `Bearer ${this.authConfig.jwtToken}` };
|
|
114
|
+
case AUTH_METHODS.BASIC:
|
|
115
|
+
if (!this.authConfig.username || !this.authConfig.password) {
|
|
116
|
+
throw new AuthenticationError("Username and password are required", method);
|
|
75
117
|
}
|
|
76
|
-
const basicCredentials = Buffer.from(`${
|
|
118
|
+
const basicCredentials = Buffer.from(`${this.authConfig.username}:${this.authConfig.password}`).toString("base64");
|
|
77
119
|
return { Authorization: `Basic ${basicCredentials}` };
|
|
78
|
-
case
|
|
79
|
-
if (!
|
|
80
|
-
throw new AuthenticationError("API key is required",
|
|
120
|
+
case AUTH_METHODS.API_KEY:
|
|
121
|
+
if (!this.authConfig.apiKey) {
|
|
122
|
+
throw new AuthenticationError("API key is required", method);
|
|
81
123
|
}
|
|
82
|
-
return { "X-API-Key":
|
|
124
|
+
return { "X-API-Key": this.authConfig.apiKey };
|
|
125
|
+
case AUTH_METHODS.COOKIE:
|
|
126
|
+
// Cookie authentication typically handled by browser
|
|
127
|
+
return {};
|
|
83
128
|
default:
|
|
84
|
-
throw new AuthenticationError(`Unsupported authentication method: ${
|
|
129
|
+
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method);
|
|
85
130
|
}
|
|
86
131
|
}
|
|
87
132
|
/**
|
|
88
133
|
* Authenticate using JWT
|
|
134
|
+
*
|
|
135
|
+
* Note: This method is not fully implemented as it requires integration with
|
|
136
|
+
* the RequestManager to make HTTP requests to the WordPress JWT endpoint.
|
|
137
|
+
* JWT authentication requires the JWT Authentication for WP-API plugin.
|
|
138
|
+
*
|
|
139
|
+
* @throws {AuthenticationError} - JWT auth requires external dependency injection
|
|
89
140
|
*/
|
|
90
141
|
async authenticateJWT() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
throw new AuthenticationError("JWT authentication requires username and password", "jwt");
|
|
142
|
+
if (this.authConfig.authMethod !== AUTH_METHODS.JWT || !this.authConfig.username || !this.authConfig.password) {
|
|
143
|
+
throw new AuthenticationError("JWT authentication requires username and password", AUTH_METHODS.JWT);
|
|
94
144
|
}
|
|
95
145
|
try {
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
146
|
+
// TODO: Implement JWT authentication with RequestManager integration
|
|
147
|
+
// This would require making a POST request to /wp-json/jwt-auth/v1/token
|
|
148
|
+
// with username and password to obtain a JWT token
|
|
149
|
+
throw new AuthenticationError("JWT authentication requires RequestManager integration - not yet implemented", AUTH_METHODS.JWT);
|
|
99
150
|
}
|
|
100
151
|
catch (error) {
|
|
101
152
|
this.handleError(error, "JWT authentication");
|
|
@@ -108,7 +159,7 @@ export class AuthenticationManager extends BaseManager {
|
|
|
108
159
|
try {
|
|
109
160
|
const _headers = await this.getAuthHeaders();
|
|
110
161
|
debug.log("Authentication headers prepared", {
|
|
111
|
-
method: this.
|
|
162
|
+
method: this.authConfig.authMethod,
|
|
112
163
|
});
|
|
113
164
|
// This would need the RequestManager to actually test the connection
|
|
114
165
|
// For now, we'll return true if headers can be generated
|
|
@@ -138,34 +189,181 @@ export class AuthenticationManager extends BaseManager {
|
|
|
138
189
|
* Validate authentication configuration
|
|
139
190
|
*/
|
|
140
191
|
validateAuthConfig() {
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
143
|
-
throw new AuthenticationError("Authentication method is required",
|
|
192
|
+
const method = this.authConfig.authMethod;
|
|
193
|
+
if (!method) {
|
|
194
|
+
throw new AuthenticationError("Authentication method is required", AUTH_METHODS.APP_PASSWORD);
|
|
195
|
+
}
|
|
196
|
+
switch (method) {
|
|
197
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
198
|
+
if (!this.authConfig.username || !this.authConfig.appPassword) {
|
|
199
|
+
throw new AuthenticationError("App password authentication requires username and appPassword", AUTH_METHODS.APP_PASSWORD);
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
case AUTH_METHODS.JWT:
|
|
203
|
+
if (!this.authConfig.username || !this.authConfig.password || !this.authConfig.jwtSecret) {
|
|
204
|
+
throw new AuthenticationError("JWT authentication requires username, password, and secret", AUTH_METHODS.JWT);
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case AUTH_METHODS.BASIC:
|
|
208
|
+
if (!this.authConfig.username || !this.authConfig.password) {
|
|
209
|
+
throw new AuthenticationError("Basic authentication requires username and password", AUTH_METHODS.BASIC);
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
case AUTH_METHODS.API_KEY:
|
|
213
|
+
if (!this.authConfig.apiKey) {
|
|
214
|
+
throw new AuthenticationError("API key authentication requires apiKey", AUTH_METHODS.API_KEY);
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
throw new AuthenticationError(`Unsupported authentication method: ${method}`, method);
|
|
144
219
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Validate credentials for current auth method
|
|
223
|
+
*/
|
|
224
|
+
validateCredentials() {
|
|
225
|
+
const method = this.authConfig.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
226
|
+
switch (method) {
|
|
227
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
228
|
+
if (!this.authConfig.username) {
|
|
229
|
+
throw new AuthenticationError("Username is required", method);
|
|
230
|
+
}
|
|
231
|
+
if (!this.authConfig.appPassword) {
|
|
232
|
+
throw new AuthenticationError("App password is required", method);
|
|
149
233
|
}
|
|
150
234
|
break;
|
|
151
|
-
case
|
|
152
|
-
if (!
|
|
153
|
-
throw new AuthenticationError("JWT
|
|
235
|
+
case AUTH_METHODS.JWT:
|
|
236
|
+
if (!this.authConfig.jwtToken) {
|
|
237
|
+
throw new AuthenticationError("JWT token is required", method);
|
|
154
238
|
}
|
|
155
239
|
break;
|
|
156
|
-
case
|
|
157
|
-
if (!
|
|
158
|
-
throw new AuthenticationError("
|
|
240
|
+
case AUTH_METHODS.BASIC:
|
|
241
|
+
if (!this.authConfig.username) {
|
|
242
|
+
throw new AuthenticationError("Username is required", method);
|
|
243
|
+
}
|
|
244
|
+
if (!this.authConfig.password) {
|
|
245
|
+
throw new AuthenticationError("Password is required", method);
|
|
159
246
|
}
|
|
160
247
|
break;
|
|
161
|
-
case
|
|
162
|
-
if (!
|
|
163
|
-
throw new AuthenticationError("API key
|
|
248
|
+
case AUTH_METHODS.API_KEY:
|
|
249
|
+
if (!this.authConfig.apiKey) {
|
|
250
|
+
throw new AuthenticationError("API key is required", method);
|
|
164
251
|
}
|
|
165
252
|
break;
|
|
166
253
|
default:
|
|
167
|
-
throw new AuthenticationError(`
|
|
254
|
+
throw new AuthenticationError(`Invalid authentication method: ${method}`, method);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Update authentication method and credentials
|
|
259
|
+
*/
|
|
260
|
+
updateAuthMethod(method, credentials) {
|
|
261
|
+
const validMethods = Object.values(AUTH_METHODS);
|
|
262
|
+
if (!validMethods.includes(method)) {
|
|
263
|
+
throw new AuthenticationError("Invalid authentication method", method);
|
|
264
|
+
}
|
|
265
|
+
// Clear all previous credentials to prevent leakage
|
|
266
|
+
delete this.authConfig.username;
|
|
267
|
+
delete this.authConfig.appPassword;
|
|
268
|
+
delete this.authConfig.jwtToken;
|
|
269
|
+
delete this.authConfig.password;
|
|
270
|
+
delete this.authConfig.apiKey;
|
|
271
|
+
delete this.authConfig.tokenExpiry;
|
|
272
|
+
// Set new auth method
|
|
273
|
+
this.authConfig.authMethod = method;
|
|
274
|
+
// Set new credentials with type safety and validation
|
|
275
|
+
switch (method) {
|
|
276
|
+
case AUTH_METHODS.APP_PASSWORD:
|
|
277
|
+
const appCreds = credentials;
|
|
278
|
+
if (!appCreds.username || !appCreds.appPassword) {
|
|
279
|
+
throw new AuthenticationError("Username and app password are required", method);
|
|
280
|
+
}
|
|
281
|
+
this.authConfig.username = appCreds.username;
|
|
282
|
+
this.authConfig.appPassword = appCreds.appPassword;
|
|
283
|
+
break;
|
|
284
|
+
case AUTH_METHODS.JWT:
|
|
285
|
+
const jwtCreds = credentials;
|
|
286
|
+
if (!jwtCreds.jwtToken) {
|
|
287
|
+
throw new AuthenticationError("JWT token is required", method);
|
|
288
|
+
}
|
|
289
|
+
this.authConfig.jwtToken = jwtCreds.jwtToken;
|
|
290
|
+
if (jwtCreds.username) {
|
|
291
|
+
this.authConfig.username = jwtCreds.username;
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
case AUTH_METHODS.BASIC:
|
|
295
|
+
const basicCreds = credentials;
|
|
296
|
+
if (!basicCreds.username || !basicCreds.password) {
|
|
297
|
+
throw new AuthenticationError("Username and password are required", method);
|
|
298
|
+
}
|
|
299
|
+
this.authConfig.username = basicCreds.username;
|
|
300
|
+
this.authConfig.password = basicCreds.password;
|
|
301
|
+
break;
|
|
302
|
+
case AUTH_METHODS.API_KEY:
|
|
303
|
+
const apiCreds = credentials;
|
|
304
|
+
if (!apiCreds.apiKey) {
|
|
305
|
+
throw new AuthenticationError("API key is required", method);
|
|
306
|
+
}
|
|
307
|
+
this.authConfig.apiKey = apiCreds.apiKey;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Refresh JWT token
|
|
313
|
+
*
|
|
314
|
+
* For testing compatibility, this method supports mock JWT refresh.
|
|
315
|
+
* In production, it requires RequestManager integration.
|
|
316
|
+
*/
|
|
317
|
+
async refreshToken() {
|
|
318
|
+
if (this.authConfig.authMethod !== AUTH_METHODS.JWT) {
|
|
319
|
+
throw new AuthenticationError("Token refresh not supported for non-JWT authentication methods", this.authConfig.authMethod);
|
|
320
|
+
}
|
|
321
|
+
// Check if mock refresh method is available (for testing)
|
|
322
|
+
const mockRefreshMethod = this.refreshJwtToken;
|
|
323
|
+
if (typeof mockRefreshMethod === "function") {
|
|
324
|
+
const result = await mockRefreshMethod();
|
|
325
|
+
if (result && typeof result === "object" && "token" in result) {
|
|
326
|
+
const tokenResult = result;
|
|
327
|
+
this.authConfig.jwtToken = tokenResult.token;
|
|
328
|
+
if (tokenResult.expires_in) {
|
|
329
|
+
this.authConfig.tokenExpiry = Date.now() + tokenResult.expires_in * 1000;
|
|
330
|
+
}
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// TODO: Implement JWT token refresh with RequestManager integration
|
|
335
|
+
// This would require making a POST request to /wp-json/jwt-auth/v1/token/validate
|
|
336
|
+
// and updating the stored token and expiry
|
|
337
|
+
throw new AuthenticationError("JWT refresh requires RequestManager integration - not yet implemented", AUTH_METHODS.JWT);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Check if JWT token is expired
|
|
341
|
+
*/
|
|
342
|
+
isTokenExpired() {
|
|
343
|
+
if (this.authConfig.authMethod !== AUTH_METHODS.JWT) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (!this.authConfig.tokenExpiry) {
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
return Date.now() >= this.authConfig.tokenExpiry;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Get authentication status
|
|
353
|
+
*/
|
|
354
|
+
getAuthStatus() {
|
|
355
|
+
const method = this.authConfig.authMethod || AUTH_METHODS.APP_PASSWORD;
|
|
356
|
+
const isExpired = this.isTokenExpired();
|
|
357
|
+
const status = {
|
|
358
|
+
method,
|
|
359
|
+
username: this.authConfig.username,
|
|
360
|
+
isAuthenticated: method === AUTH_METHODS.JWT ? !isExpired : true,
|
|
361
|
+
tokenExpired: isExpired,
|
|
362
|
+
};
|
|
363
|
+
if (method === AUTH_METHODS.JWT && this.authConfig.tokenExpiry) {
|
|
364
|
+
status.tokenExpiry = this.authConfig.tokenExpiry;
|
|
168
365
|
}
|
|
366
|
+
return status;
|
|
169
367
|
}
|
|
170
368
|
}
|
|
171
369
|
//# sourceMappingURL=AuthenticationManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticationManager.js","sourceRoot":"","sources":["../../../src/client/managers/AuthenticationManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAC5C,QAAQ,GAAkB,IAAI,CAAC;IAC/B,aAAa,GAAY,KAAK,CAAC;IAEvC;;OAEG;IACH,MAAM,CAAC,cAAc;QACnB,MAAM,MAAM,GAAgB,OAAO,CAAC,GAAG,CAAC,qBAAoC,IAAI,cAAc,CAAC;QAE/F,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,cAAc;gBACjB,OAAO;oBACL,MAAM,EAAE,cAAc;oBACtB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE;oBAC9C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,EAAE;iBACtD,CAAC;YAEJ,KAAK,KAAK;gBACR,OAAO;oBACL,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE;oBAC9C,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GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,YAAY,CAAC,YAAY,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAExC,MAAM,MAAM,GAAe;YACzB,MAAM;YACN,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ;YAClC,eAAe,EAAE,MAAM,KAAK,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;YAChE,YAAY,EAAE,SAAS;SACxB,CAAC;QAEF,IAAI,MAAM,KAAK,YAAY,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;YAC/D,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACnD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -9,14 +9,14 @@ export declare abstract class BaseManager {
|
|
|
9
9
|
/**
|
|
10
10
|
* Standardized error handling for all managers
|
|
11
11
|
*/
|
|
12
|
-
protected handleError(error:
|
|
12
|
+
protected handleError(error: unknown, operation: string): never;
|
|
13
13
|
/**
|
|
14
14
|
* Standardized success logging
|
|
15
15
|
*/
|
|
16
|
-
protected logSuccess(operation: string, details?:
|
|
16
|
+
protected logSuccess(operation: string, details?: unknown): void;
|
|
17
17
|
/**
|
|
18
18
|
* Validate required parameters
|
|
19
19
|
*/
|
|
20
|
-
protected validateRequired(params: Record<string,
|
|
20
|
+
protected validateRequired(params: Record<string, unknown>, requiredFields: string[]): void;
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=BaseManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseManager.d.ts","sourceRoot":"","sources":["../../../src/client/managers/BaseManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAKnE,8BAAsB,WAAW;IAC/B,SAAS,CAAC,MAAM,EAAE,qBAAqB,CAAC;gBAE5B,MAAM,EAAE,qBAAqB;IAIzC;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"BaseManager.d.ts","sourceRoot":"","sources":["../../../src/client/managers/BaseManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAKnE,8BAAsB,WAAW;IAC/B,SAAS,CAAC,MAAM,EAAE,qBAAqB,CAAC;gBAE5B,MAAM,EAAE,qBAAqB;IAIzC;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;IA0B/D;;OAEG;IACH,SAAS,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAIhE;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI;CAO5F"}
|
|
@@ -18,11 +18,17 @@ export class BaseManager {
|
|
|
18
18
|
if (error instanceof WordPressAPIError) {
|
|
19
19
|
throw error;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// Type guard for error-like objects
|
|
22
|
+
const isErrorLike = (err) => {
|
|
23
|
+
return typeof err === "object" && err !== null;
|
|
24
|
+
};
|
|
25
|
+
if (isErrorLike(error)) {
|
|
26
|
+
if (error.name === "AbortError" || error.code === "ABORT_ERR") {
|
|
27
|
+
throw new WordPressAPIError(`Request timeout after ${this.config.timeout}ms`, 408, "timeout");
|
|
28
|
+
}
|
|
29
|
+
if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
|
|
30
|
+
throw new WordPressAPIError(`Cannot connect to WordPress site: ${this.config.baseUrl}`, 503, "connection_failed");
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
33
|
const message = getErrorMessage(error);
|
|
28
34
|
throw new WordPressAPIError(`${operation} failed: ${message}`, 500, "unknown_error");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseManager.js","sourceRoot":"","sources":["../../../src/client/managers/BaseManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,OAAgB,WAAW;IACrB,MAAM,CAAwB;IAExC,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"BaseManager.js","sourceRoot":"","sources":["../../../src/client/managers/BaseManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,OAAgB,WAAW;IACrB,MAAM,CAAwB;IAExC,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,KAAc,EAAE,SAAiB;QACrD,QAAQ,CAAC,GAAG,SAAS,UAAU,EAAE,KAAgC,CAAC,CAAC;QAEnE,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;YACvC,MAAM,KAAK,CAAC;QACd,CAAC;QAED,oCAAoC;QACpC,MAAM,WAAW,GAAG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CAAC;CACF"}
|
|
@@ -10,11 +10,11 @@ export declare class RequestManager extends BaseManager {
|
|
|
10
10
|
private lastRequestTime;
|
|
11
11
|
private requestInterval;
|
|
12
12
|
private authManager;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(clientConfig: WordPressClientConfig, authManager: AuthenticationManager);
|
|
14
14
|
/**
|
|
15
15
|
* Make HTTP request with retry logic and rate limiting
|
|
16
16
|
*/
|
|
17
|
-
request<T>(method: HTTPMethod, endpoint: string, data?:
|
|
17
|
+
request<T>(method: HTTPMethod, endpoint: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
18
18
|
/**
|
|
19
19
|
* Make request with retry logic
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestManager.d.ts","sourceRoot":"","sources":["../../../src/client/managers/RequestManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RequestManager.d.ts","sourceRoot":"","sources":["../../../src/client/managers/RequestManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG5G,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,qBAAa,cAAe,SAAQ,WAAW;IAC7C,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAwB;gBAE/B,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,qBAAqB;IAenF;;OAEG;IACG,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;IAoBhH;;OAEG;YACW,oBAAoB;IAqClC;;OAEG;YACW,WAAW;IAkEzB;;OAEG;YACW,mBAAmB;IA6BjC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAQhB;;OAEG;YACW,gBAAgB;IAY9B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAOjC;;OAEG;IACH,QAAQ,IAAI,WAAW;CAGxB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Handles all HTTP operations, rate limiting, and retries
|
|
4
4
|
*/
|
|
5
5
|
import { WordPressAPIError, RateLimitError } from "../../types/client.js";
|
|
6
|
+
import { config } from "../../config/Config.js";
|
|
6
7
|
import { BaseManager } from "./BaseManager.js";
|
|
7
8
|
import { debug, startTimer } from "../../utils/debug.js";
|
|
8
9
|
export class RequestManager extends BaseManager {
|
|
@@ -10,10 +11,10 @@ export class RequestManager extends BaseManager {
|
|
|
10
11
|
lastRequestTime = 0;
|
|
11
12
|
requestInterval;
|
|
12
13
|
authManager;
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
14
|
+
constructor(clientConfig, authManager) {
|
|
15
|
+
super(clientConfig);
|
|
15
16
|
this.authManager = authManager;
|
|
16
|
-
this.requestInterval = 60000 /
|
|
17
|
+
this.requestInterval = 60000 / config().security.rateLimit;
|
|
17
18
|
this.stats = {
|
|
18
19
|
totalRequests: 0,
|
|
19
20
|
successfulRequests: 0,
|
|
@@ -55,11 +56,16 @@ export class RequestManager extends BaseManager {
|
|
|
55
56
|
}
|
|
56
57
|
catch (error) {
|
|
57
58
|
lastError = error;
|
|
59
|
+
// Type guard for error-like objects
|
|
60
|
+
const isErrorLike = (err) => {
|
|
61
|
+
return typeof err === "object" && err !== null;
|
|
62
|
+
};
|
|
58
63
|
// Don't retry on authentication errors or client errors
|
|
59
|
-
if (error.statusCode < 500 || attempt === maxRetries) {
|
|
64
|
+
if ((isErrorLike(error) && error.statusCode && error.statusCode < 500) || attempt === maxRetries) {
|
|
60
65
|
throw error;
|
|
61
66
|
}
|
|
62
|
-
|
|
67
|
+
const errorMessage = isErrorLike(error) && error.message ? error.message : String(error);
|
|
68
|
+
debug.log(`Request failed (attempt ${attempt}/${maxRetries}):`, errorMessage);
|
|
63
69
|
// Exponential backoff
|
|
64
70
|
const delay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
|
|
65
71
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
@@ -90,9 +96,13 @@ export class RequestManager extends BaseManager {
|
|
|
90
96
|
};
|
|
91
97
|
if (data && method !== "GET") {
|
|
92
98
|
if (data instanceof FormData ||
|
|
93
|
-
(data && typeof data.append === "function")) {
|
|
99
|
+
(typeof data === "object" && data && "append" in data && typeof data.append === "function")) {
|
|
94
100
|
// For FormData, don't set Content-Type (let fetch set it with boundary)
|
|
95
|
-
|
|
101
|
+
if (fetchOptions.headers &&
|
|
102
|
+
typeof fetchOptions.headers === "object" &&
|
|
103
|
+
"Content-Type" in fetchOptions.headers) {
|
|
104
|
+
delete fetchOptions.headers["Content-Type"];
|
|
105
|
+
}
|
|
96
106
|
fetchOptions.body = data;
|
|
97
107
|
}
|
|
98
108
|
else if (Buffer.isBuffer(data)) {
|
|
@@ -124,13 +134,17 @@ export class RequestManager extends BaseManager {
|
|
|
124
134
|
async handleErrorResponse(response) {
|
|
125
135
|
let errorData = {};
|
|
126
136
|
try {
|
|
127
|
-
|
|
137
|
+
const jsonData = await response.json();
|
|
138
|
+
if (typeof jsonData === "object" && jsonData !== null) {
|
|
139
|
+
errorData = jsonData;
|
|
140
|
+
}
|
|
128
141
|
}
|
|
129
142
|
catch {
|
|
130
143
|
// Ignore JSON parsing errors
|
|
131
144
|
}
|
|
132
|
-
const message = errorData.message
|
|
133
|
-
|
|
145
|
+
const message = (typeof errorData.message === "string" ? errorData.message : undefined) ||
|
|
146
|
+
`HTTP ${response.status}: ${response.statusText}`;
|
|
147
|
+
const code = (typeof errorData.code === "string" ? errorData.code : undefined) || "http_error";
|
|
134
148
|
if (response.status === 429) {
|
|
135
149
|
this.stats.rateLimitHits++;
|
|
136
150
|
throw new RateLimitError(message, Date.now() + 60000); // Retry after 1 minute
|
|
@@ -167,8 +181,7 @@ export class RequestManager extends BaseManager {
|
|
|
167
181
|
updateAverageResponseTime(responseTime) {
|
|
168
182
|
const totalRequests = this.stats.successfulRequests;
|
|
169
183
|
const currentAverage = this.stats.averageResponseTime;
|
|
170
|
-
this.stats.averageResponseTime =
|
|
171
|
-
(currentAverage * (totalRequests - 1) + responseTime) / totalRequests;
|
|
184
|
+
this.stats.averageResponseTime = (currentAverage * (totalRequests - 1) + responseTime) / totalRequests;
|
|
172
185
|
}
|
|
173
186
|
/**
|
|
174
187
|
* Get request statistics
|