@egdesk/next-api-plugin 1.5.49 → 1.5.50
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 +6 -1
- package/dist/generate-visitor-auth.js +19 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,12 @@ NEXT_PUBLIC_EGDESK_API_KEY=your-api-key-here
|
|
|
72
72
|
|
|
73
73
|
Published sites do **not** receive `SUPABASE_URL` or the anon key. Visitor Google sign-in is brokered by EGDesk: the site redirects through `{EGDESK_API}/visitor-auth`, EGDesk creates an Auth user, and the site stores an opaque session id bound to **this site's origin**. Another published site on the same EGDesk cannot reuse that session.
|
|
74
74
|
|
|
75
|
-
Add the **EGDesk** callback (not each site origin) to **Supabase → Authentication → URL Configuration → Redirect URLs
|
|
75
|
+
Add the **EGDesk** callback (not each site origin) to **Supabase → Authentication → URL Configuration → Redirect URLs**:
|
|
76
|
+
|
|
77
|
+
- Local: `http://localhost:54321/auth/callback`
|
|
78
|
+
- Tunnel: `https://tunneling-service.onrender.com/t/{tunnelId}/visitor-auth/callback` or `https://tunneling-service.onrender.com/**`
|
|
79
|
+
|
|
80
|
+
Do not add `?vid=` — extra query params make Supabase fall back to the Site URL (`egdesk.cloud`).
|
|
76
81
|
|
|
77
82
|
Owner MCP (`startDriveAuthLogin`) is a separate credential on the EGDesk machine. Visitor login does not overwrite it.
|
|
78
83
|
|
|
@@ -202,6 +202,22 @@ export function resolveVisitorAppPath(path: string): string {
|
|
|
202
202
|
return base + normalized;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/** MCP root for the public tunnel, e.g. https://tunneling-service.onrender.com/t/{id} */
|
|
206
|
+
export function resolveEgdeskPublicUrl(): string {
|
|
207
|
+
const configured =
|
|
208
|
+
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_API_URL) ||
|
|
209
|
+
'http://localhost:8080';
|
|
210
|
+
if (typeof window === 'undefined') return configured;
|
|
211
|
+
const parts = window.location.pathname.split('/').filter(Boolean);
|
|
212
|
+
const onTunnelGateway =
|
|
213
|
+
window.location.hostname === 'tunneling-service.onrender.com' ||
|
|
214
|
+
window.location.hostname.endsWith('.egdesk.cloud');
|
|
215
|
+
if (onTunnelGateway && parts[0] === 't' && parts[1]) {
|
|
216
|
+
return window.location.origin + '/t/' + parts[1];
|
|
217
|
+
}
|
|
218
|
+
return configured;
|
|
219
|
+
}
|
|
220
|
+
|
|
205
221
|
async function callVisitorAuth(tool: string, args: Record<string, unknown> = {}) {
|
|
206
222
|
const response = await apiFetch('/__visitor_auth_proxy', {
|
|
207
223
|
method: 'POST',
|
|
@@ -244,15 +260,13 @@ export async function startVisitorGoogleLogin(options: {
|
|
|
244
260
|
);
|
|
245
261
|
const returnTo = new URL(resolveVisitorAppPath('/auth/callback'), window.location.origin);
|
|
246
262
|
returnTo.searchParams.set('next', next);
|
|
247
|
-
//
|
|
248
|
-
|
|
249
|
-
const egdeskPublicUrl =
|
|
250
|
-
process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080';
|
|
263
|
+
// Localhost → EGDesk :54321. Tunnel site → {gateway}/t/{id}/visitor-auth/callback.
|
|
264
|
+
const egdeskPublicUrl = resolveEgdeskPublicUrl();
|
|
251
265
|
|
|
252
266
|
const result = await callVisitorAuth('start', {
|
|
253
267
|
returnTo: returnTo.toString(),
|
|
254
268
|
egdeskPublicUrl,
|
|
255
|
-
forceConsent: options.forceConsent
|
|
269
|
+
forceConsent: options.forceConsent === true,
|
|
256
270
|
});
|
|
257
271
|
if (!result?.authUrl) {
|
|
258
272
|
throw new Error(result?.error || 'Failed to start visitor Google login');
|
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.
|
|
11
|
+
export declare const COMPATIBLE_APP_VERSION = "1.4.59";
|
|
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.
|
|
49
|
+
exports.COMPATIBLE_APP_VERSION = '1.4.59';
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
52
|
const setup_userdata_1 = require("./setup-userdata");
|