@automattic/mcp-wordpress-remote 0.2.3 → 0.2.4
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/dist/proxy.js +17 -3
- package/package.json +1 -1
package/dist/proxy.js
CHANGED
|
@@ -1266,10 +1266,18 @@ var WP_PERSISTENT_CONFIG = {
|
|
|
1266
1266
|
var PersistentWPOAuthClientProvider = class {
|
|
1267
1267
|
constructor(options) {
|
|
1268
1268
|
this.authPromise = null;
|
|
1269
|
+
const isWpCom = isWordPressComSite(options.serverUrl || "");
|
|
1270
|
+
const recommendedConfig = getRecommendedOAuthConfig(options.serverUrl || "");
|
|
1269
1271
|
this.options = {
|
|
1270
1272
|
...WP_PERSISTENT_CONFIG,
|
|
1271
1273
|
...options
|
|
1272
1274
|
};
|
|
1275
|
+
if (isWpCom && recommendedConfig.authorizationEndpoint) {
|
|
1276
|
+
this.options.authorizeEndpoint = recommendedConfig.authorizationEndpoint;
|
|
1277
|
+
logger.debug("Using WordPress.com OAuth endpoint", "OAUTH", {
|
|
1278
|
+
endpoint: recommendedConfig.authorizationEndpoint
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1273
1281
|
this.serverUrlHash = generateServerUrlHash(this.options.serverUrl);
|
|
1274
1282
|
this.events = new EventEmitter2();
|
|
1275
1283
|
this.events.setMaxListeners(10);
|
|
@@ -1278,7 +1286,9 @@ var PersistentWPOAuthClientProvider = class {
|
|
|
1278
1286
|
serverUrl: this.options.serverUrl,
|
|
1279
1287
|
serverHash: this.serverUrlHash,
|
|
1280
1288
|
clientId: this.options.clientId || "auto-generated",
|
|
1281
|
-
callbackPort: this.options.callbackPort
|
|
1289
|
+
callbackPort: this.options.callbackPort,
|
|
1290
|
+
authorizeEndpoint: this.options.authorizeEndpoint,
|
|
1291
|
+
isWordPressCom: isWpCom
|
|
1282
1292
|
});
|
|
1283
1293
|
}
|
|
1284
1294
|
/**
|
|
@@ -1462,7 +1472,6 @@ var PersistentWPOAuthClientProvider = class {
|
|
|
1462
1472
|
* Build the WordPress authorization URL
|
|
1463
1473
|
*/
|
|
1464
1474
|
buildAuthorizationUrl(callbackUrl, state) {
|
|
1465
|
-
const baseUrl = this.options.serverUrl.replace(/\/+$/, "");
|
|
1466
1475
|
const authEndpoint = this.options.authorizeEndpoint || WP_PERSISTENT_CONFIG.authorizeEndpoint;
|
|
1467
1476
|
const params = new URLSearchParams({
|
|
1468
1477
|
response_type: "token",
|
|
@@ -1474,7 +1483,12 @@ var PersistentWPOAuthClientProvider = class {
|
|
|
1474
1483
|
if (this.options.clientId) {
|
|
1475
1484
|
params.set("client_id", this.options.clientId);
|
|
1476
1485
|
}
|
|
1477
|
-
|
|
1486
|
+
if (authEndpoint.startsWith("http://") || authEndpoint.startsWith("https://")) {
|
|
1487
|
+
return `${authEndpoint}?${params.toString()}`;
|
|
1488
|
+
} else {
|
|
1489
|
+
const baseUrl = this.options.serverUrl.replace(/\/+$/, "");
|
|
1490
|
+
return `${baseUrl}${authEndpoint}?${params.toString()}`;
|
|
1491
|
+
}
|
|
1478
1492
|
}
|
|
1479
1493
|
/**
|
|
1480
1494
|
* Generate a secure state parameter
|