@egdesk/next-api-plugin 1.5.110 → 1.5.111

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.
@@ -138,6 +138,27 @@ function resolveVisitorAuthMcpApiUrl(): string {
138
138
  return 'http://localhost:8080';
139
139
  }
140
140
 
141
+ /** Phase 7b visitor BYO tools must hit desktop MCP (secrets), not the tunnel gateway. */
142
+ const VISITOR_AUTH_DESKTOP_ONLY_TOOLS = new Set(['register_gcp', 'gcp_status', 'forget_gcp']);
143
+
144
+ function resolveVisitorAuthMcpApiUrlForTool(tool: string): string {
145
+ if (VISITOR_AUTH_DESKTOP_ONLY_TOOLS.has(tool)) {
146
+ const internal = process.env.EGDESK_MCP_INTERNAL_URL;
147
+ if (internal && internal.trim()) return internal.replace(/\\/$/, '');
148
+ return 'http://localhost:8080';
149
+ }
150
+ return resolveVisitorAuthMcpApiUrl();
151
+ }
152
+
153
+ function visitorAuthToolFromProxyBody(body: string): string {
154
+ try {
155
+ const parsed = JSON.parse(body) as { tool?: string; op?: string };
156
+ return String(parsed.tool || parsed.op || '').trim();
157
+ } catch {
158
+ return '';
159
+ }
160
+ }
161
+
141
162
  export async function middleware(request: NextRequest) {
142
163
  const { pathname } = request.nextUrl;
143
164
 
@@ -463,7 +484,7 @@ export async function middleware(request: NextRequest) {
463
484
  if (pathname.includes('__visitor_auth_proxy')) {
464
485
  try {
465
486
  const body = await request.text();
466
- const apiUrl = resolveVisitorAuthMcpApiUrl();
487
+ const apiUrl = resolveVisitorAuthMcpApiUrlForTool(visitorAuthToolFromProxyBody(body));
467
488
 
468
489
  const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
469
490
  method: 'POST',
@@ -116,6 +116,27 @@ function resolveVisitorAuthMcpApiUrl(): string {
116
116
  return 'http://localhost:8080';
117
117
  }
118
118
 
119
+ /** Phase 7b visitor BYO tools must hit desktop MCP (secrets), not the tunnel gateway. */
120
+ const VISITOR_AUTH_DESKTOP_ONLY_TOOLS = new Set(['register_gcp', 'gcp_status', 'forget_gcp']);
121
+
122
+ function resolveVisitorAuthMcpApiUrlForTool(tool: string): string {
123
+ if (VISITOR_AUTH_DESKTOP_ONLY_TOOLS.has(tool)) {
124
+ const internal = process.env.EGDESK_MCP_INTERNAL_URL;
125
+ if (internal && internal.trim()) return internal.replace(/\\/$/, '');
126
+ return 'http://localhost:8080';
127
+ }
128
+ return resolveVisitorAuthMcpApiUrl();
129
+ }
130
+
131
+ function visitorAuthToolFromProxyBody(body: string): string {
132
+ try {
133
+ const parsed = JSON.parse(body) as { tool?: string; op?: string };
134
+ return String(parsed.tool || parsed.op || '').trim();
135
+ } catch {
136
+ return '';
137
+ }
138
+ }
139
+
119
140
  /** Forward this site's origin so EGDesk can bind visitor sessions to this site only. */
120
141
  function visitorForwardHeaders(request: NextRequest): Record<string, string> {
121
142
  const headers = buildEgdeskHeaders();
@@ -816,7 +837,7 @@ export async function proxy(request: NextRequest) {
816
837
  if (pathname.includes('__visitor_auth_proxy')) {
817
838
  try {
818
839
  const body = await request.text();
819
- const apiUrl = resolveVisitorAuthMcpApiUrl();
840
+ const apiUrl = resolveVisitorAuthMcpApiUrlForTool(visitorAuthToolFromProxyBody(body));
820
841
 
821
842
  const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
822
843
  method: 'POST',
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * The minimum EGDesk app version this plugin version is compatible with.
9
9
  * The app checks this at setup time and warns on mismatch.
10
10
  */
11
- export declare const COMPATIBLE_APP_VERSION = "1.4.115";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.116";
12
12
  export interface SetupOptions {
13
13
  egdeskUrl?: string;
14
14
  /** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ exports.setupNextApiPlugin = setupNextApiPlugin;
46
46
  * The minimum EGDesk app version this plugin version is compatible with.
47
47
  * The app checks this at setup time and warns on mismatch.
48
48
  */
49
- exports.COMPATIBLE_APP_VERSION = '1.4.115';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.116';
50
50
  const fs = __importStar(require("fs"));
51
51
  const path = __importStar(require("path"));
52
52
  const setup_userdata_1 = require("./setup-userdata");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.110",
3
+ "version": "1.5.111",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",