@egdesk/next-api-plugin 1.5.111 → 1.5.112

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.
@@ -84,6 +84,45 @@ function removeIfExists(filePath) {
84
84
  console.warn(`⚠️ Could not remove ${filePath}:`, error);
85
85
  }
86
86
  }
87
+ /** site-origin mode (HANDOFF §9.2): Google redirects to the operator custom domain. */
88
+ const VISITOR_AUTH_CALLBACK_ROUTE = `import { NextRequest, NextResponse } from 'next/server';
89
+
90
+ /**
91
+ * Proxies operator/end-user direct OAuth callbacks to desktop MCP.
92
+ * Generated by @egdesk/next-api-plugin — do not edit.
93
+ */
94
+ function resolveEgdeskMcpInternalUrl(): string {
95
+ const internal = process.env.EGDESK_MCP_INTERNAL_URL;
96
+ if (internal && internal.trim()) return internal.replace(/\\/$/, '');
97
+ return 'http://localhost:8080';
98
+ }
99
+
100
+ export async function GET(request: NextRequest) {
101
+ const internal = resolveEgdeskMcpInternalUrl();
102
+ const incoming = new URL(request.url);
103
+ const target = new URL(\`\${internal}/visitor-auth/callback\`);
104
+ target.search = incoming.search;
105
+ const origin = request.headers.get('origin') || incoming.origin;
106
+ const response = await fetch(target.toString(), {
107
+ method: 'GET',
108
+ redirect: 'manual',
109
+ headers: {
110
+ Origin: origin,
111
+ 'X-Visitor-Origin': origin,
112
+ },
113
+ cache: 'no-store',
114
+ });
115
+ const location = response.headers.get('location');
116
+ if (response.status >= 300 && response.status < 400 && location) {
117
+ return NextResponse.redirect(location, response.status);
118
+ }
119
+ const text = await response.text();
120
+ return new NextResponse(text, {
121
+ status: response.status,
122
+ headers: { 'Content-Type': response.headers.get('content-type') || 'text/html; charset=utf-8' },
123
+ });
124
+ }
125
+ `;
87
126
  const CALLBACK_PAGE = `'use client';
88
127
 
89
128
  /**
@@ -709,6 +748,7 @@ function generateVisitorAuth(projectPath) {
709
748
  const appDir = resolveAppDir(projectPath);
710
749
  ensureVisitorAuthConfig(projectPath);
711
750
  writeGenerated(path.join(appDir, 'auth', 'callback', 'page.tsx'), CALLBACK_PAGE);
751
+ writeGenerated(path.join(appDir, 'visitor-auth', 'callback', 'route.ts'), VISITOR_AUTH_CALLBACK_ROUTE);
712
752
  writeGenerated(path.join(projectPath, 'egdesk-visitor-google.ts'), VISITOR_HELPERS);
713
753
  writeGenerated(path.join(projectPath, 'egdesk-visitor-gcp-byo.tsx'), VISITOR_GCP_BYO_COMPONENT);
714
754
  removeIfExists(path.join(appDir, 'api', 'visitor-google', 'route.ts'));
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.116";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.117";
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.116';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.117';
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.111",
3
+ "version": "1.5.112",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",