backend-manager 5.0.180 → 5.0.181
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/package.json
CHANGED
|
@@ -2,6 +2,11 @@ const BaseTest = require('./base-test');
|
|
|
2
2
|
const jetpack = require('fs-jetpack');
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
|
+
// The expected source pattern for bm_api hosting rewrite
|
|
6
|
+
// Includes /backend-manager/* routes and root-level MCP OAuth paths
|
|
7
|
+
// that Claude Chat sends directly (e.g. /authorize, /token, /.well-known/*)
|
|
8
|
+
const BM_API_SOURCE = '{/backend-manager,/backend-manager/**,/.well-known/oauth-protected-resource,/.well-known/oauth-authorization-server}';
|
|
9
|
+
|
|
5
10
|
class HostingRewritesTest extends BaseTest {
|
|
6
11
|
getName() {
|
|
7
12
|
return 'hosting rewrites have bm_api';
|
|
@@ -11,8 +16,8 @@ class HostingRewritesTest extends BaseTest {
|
|
|
11
16
|
const rewrites = this.self.firebaseJSON?.hosting?.rewrites || [];
|
|
12
17
|
const firstRewrite = rewrites[0];
|
|
13
18
|
|
|
14
|
-
// Check first rule is correct
|
|
15
|
-
const firstIsCorrect = firstRewrite?.source ===
|
|
19
|
+
// Check first rule is correct (matches current expected pattern)
|
|
20
|
+
const firstIsCorrect = firstRewrite?.source === BM_API_SOURCE && firstRewrite?.function === 'bm_api';
|
|
16
21
|
|
|
17
22
|
// Check no duplicates exist (only one bm_api rule allowed)
|
|
18
23
|
const bmApiCount = rewrites.filter(r => r.function === 'bm_api').length;
|
|
@@ -26,12 +31,12 @@ class HostingRewritesTest extends BaseTest {
|
|
|
26
31
|
// Set default
|
|
27
32
|
hosting.rewrites = hosting.rewrites || [];
|
|
28
33
|
|
|
29
|
-
// Remove any existing bm_api rewrites
|
|
34
|
+
// Remove any existing bm_api rewrites (handles legacy single-pattern rewrites too)
|
|
30
35
|
hosting.rewrites = hosting.rewrites.filter(rewrite => rewrite.function !== 'bm_api');
|
|
31
36
|
|
|
32
|
-
// Add to top
|
|
37
|
+
// Add to top with full pattern including MCP OAuth paths
|
|
33
38
|
hosting.rewrites.unshift({
|
|
34
|
-
source:
|
|
39
|
+
source: BM_API_SOURCE,
|
|
35
40
|
function: 'bm_api',
|
|
36
41
|
});
|
|
37
42
|
|
package/src/manager/index.js
CHANGED
|
@@ -793,11 +793,9 @@ Manager.prototype.setupFunctions = function (exporter, options) {
|
|
|
793
793
|
const route = self.BemRouter(req, res).resolve();
|
|
794
794
|
|
|
795
795
|
// MCP endpoint — bypass middleware, handle protocol directly
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|| route.routePath === '.well-known/oauth-authorization-server') {
|
|
800
|
-
return self._handleMcp(req, res, route.routePath);
|
|
796
|
+
const mcpRoutePath = resolveMcpRoutePath(route.routePath);
|
|
797
|
+
if (mcpRoutePath) {
|
|
798
|
+
return self._handleMcp(req, res, mcpRoutePath);
|
|
801
799
|
}
|
|
802
800
|
|
|
803
801
|
if (route.isLegacy) {
|
|
@@ -1201,4 +1199,26 @@ function requireJSON5(file, throwError) {
|
|
|
1201
1199
|
}
|
|
1202
1200
|
}
|
|
1203
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Check if a routePath is an MCP-related route and normalize it.
|
|
1204
|
+
* Handles /backend-manager/mcp/* paths and /.well-known/oauth-* discovery.
|
|
1205
|
+
*
|
|
1206
|
+
* @param {string} routePath - Resolved route path from BemRouter
|
|
1207
|
+
* @returns {string|null} - Normalized MCP route path, or null if not MCP
|
|
1208
|
+
*/
|
|
1209
|
+
function resolveMcpRoutePath(routePath) {
|
|
1210
|
+
// Direct MCP paths (via /backend-manager/mcp/*)
|
|
1211
|
+
if (routePath === 'mcp' || routePath.startsWith('mcp/')) {
|
|
1212
|
+
return routePath;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// OAuth discovery (via /.well-known/oauth-*)
|
|
1216
|
+
if (routePath === '.well-known/oauth-protected-resource'
|
|
1217
|
+
|| routePath === '.well-known/oauth-authorization-server') {
|
|
1218
|
+
return routePath;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
return null;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1204
1224
|
module.exports = Manager;
|