@egdesk/next-api-plugin 1.5.84 → 1.5.86

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 CHANGED
@@ -75,12 +75,25 @@ Published sites do **not** receive `SUPABASE_URL` or the anon key. Visitor Googl
75
75
 
76
76
  Add the **EGDesk** callback (not each site origin) to **Supabase → Authentication → URL Configuration → Redirect URLs**:
77
77
 
78
- - Local (owner and localhost visitor): `http://localhost:54321/auth/callback` exactly. Do not add a path or `?vid=` — Supabase will fall back to the Site URL (`egdesk.cloud`).
78
+ - Local (owner and loopback visitor): `http://localhost:54321/auth/callback` exactly. Do not add a path or `?vid=` — Supabase will fall back to the Site URL (`egdesk.cloud`).
79
79
  - Tunnel: `https://tunneling-service.onrender.com/t/{tunnelId}/visitor-auth/callback/**` or `https://tunneling-service.onrender.com/**`
80
80
 
81
81
  Do not put the pending id in a query string (`?vid=`) — extra query params make Supabase fall back to the Site URL (`egdesk.cloud`).
82
82
 
83
- On a published host, `NEXT_PUBLIC_EGDESK_API_URL` must be the tunnel MCP root (`https://…/t/{id}`), not `http://localhost:8080`. The generated helper will refuse that localhost fallback in the browser.
83
+ ### OAuth bounce by site type
84
+
85
+ | Where the visitor opens the site | Google `redirectTo` (allowlisted) |
86
+ |----------------------------------|-----------------------------------|
87
+ | `localhost` / `127.0.0.1` (:4000 dev, :3000 prod) | `http://localhost:54321/auth/callback` |
88
+ | LAN IP (`192.168.x.x`, etc.) + tunnel env | `{tunnel MCP root}/visitor-auth/callback/{pendingId}` |
89
+ | LAN IP, no tunnel (same PC as EGDesk only) | `http://localhost:54321/auth/callback` |
90
+ | Tunnel URL or custom domain | `{MCP root}/visitor-auth/callback/{pendingId}` |
91
+
92
+ Hosted-coding **prod** (`:3000`) is built with `basePath` `/t/{tunnelId}/p/{project}` — use that prefix in URLs (e.g. `http://localhost:3000/t/{id}/p/my-app/visitor-auth`). EGDesk injects `NEXT_PUBLIC_EGDESK_API_URL` and `NEXT_PUBLIC_EGDESK_API_KEY` at build and `next start` so the client bundle and middleware proxy agree.
93
+
94
+ `localhost` and `127.0.0.1` on the same port are treated as the same site for session checks, but remain distinct origin strings in storage.
95
+
96
+ On a published host, `NEXT_PUBLIC_EGDESK_API_URL` must be the tunnel MCP root (`https://…/t/{id}`), not `http://localhost:8080`. The generated helper will refuse that localhost fallback in the browser on non-dev hosts.
84
97
 
85
98
  Owner MCP (`startDriveAuthLogin`) is a separate credential on the EGDesk machine. Visitor login does not overwrite it.
86
99
 
@@ -169,6 +169,20 @@ const VISITOR_HELPERS = `/**
169
169
  * The opaque session is bound to this site origin and will not work on
170
170
  * another published site that shares the same EGDesk.
171
171
  *
172
+ * OAuth bounce (where Google redirects before returning to this site):
173
+ *
174
+ * | Where you open the site | Google redirectTo |
175
+ * |--------------------------------------|-------------------------------------------|
176
+ * | localhost / 127.0.0.1 (:4000/:3000) | http://localhost:54321/auth/callback |
177
+ * | LAN IP (192.168.x.x) + tunnel env | {tunnel}/visitor-auth/callback/{pendingId}|
178
+ * | LAN IP, no tunnel (same PC only) | http://localhost:54321/auth/callback |
179
+ * | Render / egdesk.cloud tunnel URL | {MCP root}/t/{id}/visitor-auth/callback/{id}|
180
+ * | Custom domain (yourdomain.com) | https://{domain}/visitor-auth/callback/{id} |
181
+ *
182
+ * Prod hosted coding (:3000) is built with basePath /t/{id}/p/{project}.
183
+ * Use that prefix in URLs. EGDesk injects NEXT_PUBLIC_EGDESK_API_URL at build/start.
184
+ * localhost and 127.0.0.1 on the same port count as the same site for session checks.
185
+ *
172
186
  * Generated by @egdesk/next-api-plugin — do not edit.
173
187
  * Customize login UI in your pages. Set default scopes in egdesk.visitor-auth.ts
174
188
  * or pass startVisitorGoogleLogin({ scopes: VISITOR_BASIC_SCOPES }).
@@ -328,7 +342,12 @@ function isTunnelMcpRoot(value: string): boolean {
328
342
  }
329
343
 
330
344
  /**
331
- * MCP root used as the Google/Supabase OAuth bounce.
345
+ * MCP root passed to visitor-auth start (egdeskPublicUrl).
346
+ *
347
+ * - Loopback dev → configured URL or http://localhost:8080 (OAuth still bounces via :54321).
348
+ * - LAN IP → tunnel MCP root from NEXT_PUBLIC_EGDESK_API_URL / _TUNNEL_URL (required).
349
+ * - Tunnel/custom domain → tunnel MCP root; never window.location.origin on dev/LAN hosts.
350
+ *
332
351
  * Published hosts must never silently fall back to http://localhost:8080.
333
352
  */
334
353
  export function resolveEgdeskPublicUrl(): string {
@@ -352,7 +371,9 @@ export function resolveEgdeskPublicUrl(): string {
352
371
  const onKnownGateway =
353
372
  hostname === 'tunneling-service.onrender.com' || hostname.endsWith('.egdesk.cloud');
354
373
 
355
- if (onTunnelPath && (onKnownGateway || !isLoopbackHostname(hostname))) {
374
+ // Only the Render/egdesk.cloud gateway uses /t/{id} in the OAuth bounce path.
375
+ // Custom domains (sheetbot.cloud) bounce at {origin}/visitor-auth/callback/{id} — no /t/ prefix.
376
+ if (onTunnelPath && onKnownGateway) {
356
377
  return window.location.origin + '/t/' + parts[1];
357
378
  }
358
379
 
@@ -427,8 +448,7 @@ export async function startVisitorGoogleLogin(options: {
427
448
  );
428
449
  const returnTo = new URL(resolveVisitorAppPath('/auth/callback'), window.location.origin);
429
450
  returnTo.searchParams.set('next', next);
430
- // Localhost → allowlisted http://localhost:54321/auth/callback.
431
- // Tunnel / custom domain → {MCP root}/visitor-auth/callback/{pendingId}.
451
+ // OAuth bounce is chosen server-side from returnTo + egdeskPublicUrl — see file header table.
432
452
  const egdeskPublicUrl = resolveEgdeskPublicUrl();
433
453
  if (isLocalEgdeskUrl(egdeskPublicUrl) && !isDevSiteHostname(window.location.hostname)) {
434
454
  throw new Error(
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.89";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.91";
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.89';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.91';
50
50
  const fs = __importStar(require("fs"));
51
51
  const path = __importStar(require("path"));
52
52
  const setup_userdata_1 = require("./setup-userdata");
@@ -205,8 +205,10 @@ async function setupNextApiPlugin(projectPath, options = {}) {
205
205
  console.log('');
206
206
  console.log('📝 Next steps:');
207
207
  console.log(' 1. Add .env.*.local to your .gitignore');
208
- console.log(' 2. Add this EGDesk public URL + /visitor-auth/callback/** to Supabase Auth redirect URLs');
209
- console.log(' (once per EGDesk/tunnel origin — not each published site)');
208
+ console.log(' 2. Supabase Auth redirect URLs (once per EGDesk/tunnel origin):');
209
+ console.log(' - http://localhost:54321/auth/callback (exact — loopback hosted-coding + owner)');
210
+ console.log(' - {EGDesk public URL}/visitor-auth/callback/** (tunnel / LAN IP with tunnel env)');
211
+ console.log(' Loopback → :54321; LAN IP or tunnel → /visitor-auth/callback/{pendingId} (see egdesk-visitor-google.ts header)');
210
212
  console.log(' Visitor sessions are bound to each site origin and cannot be reused across sites');
211
213
  console.log(' 3. Restart your Next.js dev server');
212
214
  console.log(' 4. Import and use helpers in your components:');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.84",
3
+ "version": "1.5.86",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",