@egdesk/next-api-plugin 1.5.84 → 1.5.100
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 +15 -2
- package/dist/generate-chunked-upload-routes.d.ts +5 -0
- package/dist/generate-chunked-upload-routes.js +197 -0
- package/dist/generate-helpers.js +291 -68
- package/dist/generate-middleware.js +21 -14
- package/dist/generate-proxy.js +39 -32
- package/dist/generate-visitor-auth.js +61 -15
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -4
- package/package.json +1 -1
package/dist/generate-proxy.js
CHANGED
|
@@ -93,6 +93,13 @@ function buildEgdeskHeaders(): Record<string, string> {
|
|
|
93
93
|
return headers;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/** Prefer loopback MCP so proxy hops never re-enter the public tunnel. */
|
|
97
|
+
function resolveEgdeskMcpApiUrl(): string {
|
|
98
|
+
const internal = process.env.EGDESK_MCP_INTERNAL_URL;
|
|
99
|
+
if (internal && internal.trim()) return internal.replace(/\\/$/, '');
|
|
100
|
+
return (process.env.NEXT_PUBLIC_EGDESK_API_URL || 'http://localhost:8080').replace(/\\/$/, '');
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
/** Forward this site's origin so EGDesk can bind visitor sessions to this site only. */
|
|
97
104
|
function visitorForwardHeaders(request: NextRequest): Record<string, string> {
|
|
98
105
|
const headers = buildEgdeskHeaders();
|
|
@@ -129,7 +136,7 @@ export async function proxy(request: NextRequest) {
|
|
|
129
136
|
if (pathname.includes('__user_data_proxy')) {
|
|
130
137
|
try {
|
|
131
138
|
const body = await request.text();
|
|
132
|
-
const apiUrl =
|
|
139
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
133
140
|
|
|
134
141
|
// Forward to EGDesk MCP server
|
|
135
142
|
const response = await fetch(\`\${apiUrl}/user-data/tools/call\`, {
|
|
@@ -152,7 +159,7 @@ export async function proxy(request: NextRequest) {
|
|
|
152
159
|
if (pathname.includes('__browser_recording_proxy')) {
|
|
153
160
|
try {
|
|
154
161
|
const body = await request.text();
|
|
155
|
-
const apiUrl =
|
|
162
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
156
163
|
|
|
157
164
|
const response = await fetch(\`\${apiUrl}/browser-recording/tools/call\`, {
|
|
158
165
|
method: 'POST',
|
|
@@ -174,7 +181,7 @@ export async function proxy(request: NextRequest) {
|
|
|
174
181
|
if (pathname.includes('__business_identity_proxy')) {
|
|
175
182
|
try {
|
|
176
183
|
const body = await request.text();
|
|
177
|
-
const apiUrl =
|
|
184
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
178
185
|
|
|
179
186
|
const response = await fetch(\`\${apiUrl}/business-identity/tools/call\`, {
|
|
180
187
|
method: 'POST',
|
|
@@ -196,7 +203,7 @@ export async function proxy(request: NextRequest) {
|
|
|
196
203
|
if (pathname.includes('__ai_center_proxy')) {
|
|
197
204
|
try {
|
|
198
205
|
const body = await request.text();
|
|
199
|
-
const apiUrl =
|
|
206
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
200
207
|
|
|
201
208
|
const response = await fetch(\`\${apiUrl}/ai-center/tools/call\`, {
|
|
202
209
|
method: 'POST',
|
|
@@ -218,7 +225,7 @@ export async function proxy(request: NextRequest) {
|
|
|
218
225
|
if (pathname.includes('__korean_law_proxy')) {
|
|
219
226
|
try {
|
|
220
227
|
const body = await request.text();
|
|
221
|
-
const apiUrl =
|
|
228
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
222
229
|
|
|
223
230
|
const response = await fetch(\`\${apiUrl}/korean-law/tools/call\`, {
|
|
224
231
|
method: 'POST',
|
|
@@ -240,7 +247,7 @@ export async function proxy(request: NextRequest) {
|
|
|
240
247
|
if (pathname.includes('__bizinfo_proxy')) {
|
|
241
248
|
try {
|
|
242
249
|
const body = await request.text();
|
|
243
|
-
const apiUrl =
|
|
250
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
244
251
|
|
|
245
252
|
const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
|
|
246
253
|
method: 'POST',
|
|
@@ -262,7 +269,7 @@ export async function proxy(request: NextRequest) {
|
|
|
262
269
|
if (pathname.includes('__bidnotice_proxy')) {
|
|
263
270
|
try {
|
|
264
271
|
const body = await request.text();
|
|
265
|
-
const apiUrl =
|
|
272
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
266
273
|
|
|
267
274
|
const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
|
|
268
275
|
method: 'POST',
|
|
@@ -284,7 +291,7 @@ export async function proxy(request: NextRequest) {
|
|
|
284
291
|
if (pathname.includes('__koneps_proxy')) {
|
|
285
292
|
try {
|
|
286
293
|
const body = await request.text();
|
|
287
|
-
const apiUrl =
|
|
294
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
288
295
|
|
|
289
296
|
const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
|
|
290
297
|
method: 'POST',
|
|
@@ -306,7 +313,7 @@ export async function proxy(request: NextRequest) {
|
|
|
306
313
|
if (pathname.includes('__nps_proxy')) {
|
|
307
314
|
try {
|
|
308
315
|
const body = await request.text();
|
|
309
|
-
const apiUrl =
|
|
316
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
310
317
|
|
|
311
318
|
const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
|
|
312
319
|
method: 'POST',
|
|
@@ -328,7 +335,7 @@ export async function proxy(request: NextRequest) {
|
|
|
328
335
|
if (pathname.includes('__seo_proxy')) {
|
|
329
336
|
try {
|
|
330
337
|
const body = await request.text();
|
|
331
|
-
const apiUrl =
|
|
338
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
332
339
|
|
|
333
340
|
const response = await fetch(\`\${apiUrl}/seo/tools/call\`, {
|
|
334
341
|
method: 'POST',
|
|
@@ -350,7 +357,7 @@ export async function proxy(request: NextRequest) {
|
|
|
350
357
|
if (pathname.includes('__hosting_coding_proxy')) {
|
|
351
358
|
try {
|
|
352
359
|
const body = await request.text();
|
|
353
|
-
const apiUrl =
|
|
360
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
354
361
|
|
|
355
362
|
const response = await fetch(\`\${apiUrl}/hosting-coding/tools/call\`, {
|
|
356
363
|
method: 'POST',
|
|
@@ -372,7 +379,7 @@ export async function proxy(request: NextRequest) {
|
|
|
372
379
|
if (pathname.includes('__company_research_proxy')) {
|
|
373
380
|
try {
|
|
374
381
|
const body = await request.text();
|
|
375
|
-
const apiUrl =
|
|
382
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
376
383
|
|
|
377
384
|
const response = await fetch(\`\${apiUrl}/company-research/tools/call\`, {
|
|
378
385
|
method: 'POST',
|
|
@@ -394,7 +401,7 @@ export async function proxy(request: NextRequest) {
|
|
|
394
401
|
if (pathname.includes('__local_agent_proxy')) {
|
|
395
402
|
try {
|
|
396
403
|
const body = await request.text();
|
|
397
|
-
const apiUrl =
|
|
404
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
398
405
|
|
|
399
406
|
const response = await fetch(\`\${apiUrl}/local-agent/tools/call\`, {
|
|
400
407
|
method: 'POST',
|
|
@@ -416,7 +423,7 @@ export async function proxy(request: NextRequest) {
|
|
|
416
423
|
if (pathname.includes('__pageindex_proxy')) {
|
|
417
424
|
try {
|
|
418
425
|
const body = await request.text();
|
|
419
|
-
const apiUrl =
|
|
426
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
420
427
|
|
|
421
428
|
const response = await fetch(\`\${apiUrl}/pageindex/tools/call\`, {
|
|
422
429
|
method: 'POST',
|
|
@@ -438,7 +445,7 @@ export async function proxy(request: NextRequest) {
|
|
|
438
445
|
if (pathname.includes('__drive_proxy')) {
|
|
439
446
|
try {
|
|
440
447
|
const body = await request.text();
|
|
441
|
-
const apiUrl =
|
|
448
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
442
449
|
|
|
443
450
|
const response = await fetch(\`\${apiUrl}/drive/tools/call\`, {
|
|
444
451
|
method: 'POST',
|
|
@@ -460,7 +467,7 @@ export async function proxy(request: NextRequest) {
|
|
|
460
467
|
if (pathname.includes('__docs_proxy')) {
|
|
461
468
|
try {
|
|
462
469
|
const body = await request.text();
|
|
463
|
-
const apiUrl =
|
|
470
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
464
471
|
|
|
465
472
|
const response = await fetch(\`\${apiUrl}/docs/tools/call\`, {
|
|
466
473
|
method: 'POST',
|
|
@@ -482,7 +489,7 @@ export async function proxy(request: NextRequest) {
|
|
|
482
489
|
if (pathname.includes('__slides_proxy')) {
|
|
483
490
|
try {
|
|
484
491
|
const body = await request.text();
|
|
485
|
-
const apiUrl =
|
|
492
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
486
493
|
|
|
487
494
|
const response = await fetch(\`\${apiUrl}/slides/tools/call\`, {
|
|
488
495
|
method: 'POST',
|
|
@@ -504,7 +511,7 @@ export async function proxy(request: NextRequest) {
|
|
|
504
511
|
if (pathname.includes('__sheets_proxy')) {
|
|
505
512
|
try {
|
|
506
513
|
const body = await request.text();
|
|
507
|
-
const apiUrl =
|
|
514
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
508
515
|
|
|
509
516
|
const response = await fetch(\`\${apiUrl}/sheets/tools/call\`, {
|
|
510
517
|
method: 'POST',
|
|
@@ -532,7 +539,7 @@ export async function proxy(request: NextRequest) {
|
|
|
532
539
|
return NextResponse.json({ error: 'Path not allowed', path: targetPath }, { status: 400 });
|
|
533
540
|
}
|
|
534
541
|
const method = payload.method === 'POST' ? 'POST' : 'GET';
|
|
535
|
-
const apiUrl =
|
|
542
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
536
543
|
const base = apiUrl.endsWith('/') ? apiUrl : \`\${apiUrl}/\`;
|
|
537
544
|
const url = new URL(targetPath.startsWith('/') ? targetPath.slice(1) : targetPath, base);
|
|
538
545
|
const query = payload.query && typeof payload.query === 'object' ? payload.query as Record<string, unknown> : {};
|
|
@@ -557,7 +564,7 @@ export async function proxy(request: NextRequest) {
|
|
|
557
564
|
if (pathname.includes('__gmail_proxy')) {
|
|
558
565
|
try {
|
|
559
566
|
const body = await request.text();
|
|
560
|
-
const apiUrl =
|
|
567
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
561
568
|
const response = await fetch(\`\${apiUrl}/gmail/tools/call\`, {
|
|
562
569
|
method: 'POST',
|
|
563
570
|
headers: workspaceForwardHeaders(request),
|
|
@@ -576,7 +583,7 @@ export async function proxy(request: NextRequest) {
|
|
|
576
583
|
if (pathname.includes('__apps_script_proxy')) {
|
|
577
584
|
try {
|
|
578
585
|
const body = await request.text();
|
|
579
|
-
const apiUrl =
|
|
586
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
580
587
|
const response = await fetch(\`\${apiUrl}/apps-script/tools/call\`, {
|
|
581
588
|
method: 'POST',
|
|
582
589
|
headers: workspaceForwardHeaders(request),
|
|
@@ -595,7 +602,7 @@ export async function proxy(request: NextRequest) {
|
|
|
595
602
|
if (pathname.includes('__knowledge_wiki_proxy')) {
|
|
596
603
|
try {
|
|
597
604
|
const body = await request.text();
|
|
598
|
-
const apiUrl =
|
|
605
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
599
606
|
|
|
600
607
|
const response = await fetch(\`\${apiUrl}/knowledge-wiki/tools/call\`, {
|
|
601
608
|
method: 'POST',
|
|
@@ -617,7 +624,7 @@ export async function proxy(request: NextRequest) {
|
|
|
617
624
|
if (pathname.includes('__kakao_proxy')) {
|
|
618
625
|
try {
|
|
619
626
|
const body = await request.text();
|
|
620
|
-
const apiUrl =
|
|
627
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
621
628
|
|
|
622
629
|
const response = await fetch(\`\${apiUrl}/kakao/tools/call\`, {
|
|
623
630
|
method: 'POST',
|
|
@@ -639,7 +646,7 @@ export async function proxy(request: NextRequest) {
|
|
|
639
646
|
if (pathname.includes('__phone_proxy')) {
|
|
640
647
|
try {
|
|
641
648
|
const body = await request.text();
|
|
642
|
-
const apiUrl =
|
|
649
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
643
650
|
|
|
644
651
|
const response = await fetch(\`\${apiUrl}/phone/tools/call\`, {
|
|
645
652
|
method: 'POST',
|
|
@@ -661,7 +668,7 @@ export async function proxy(request: NextRequest) {
|
|
|
661
668
|
if (pathname.includes('__instagram_proxy')) {
|
|
662
669
|
try {
|
|
663
670
|
const body = await request.text();
|
|
664
|
-
const apiUrl =
|
|
671
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
665
672
|
|
|
666
673
|
const response = await fetch(\`\${apiUrl}/instagram/tools/call\`, {
|
|
667
674
|
method: 'POST',
|
|
@@ -683,7 +690,7 @@ export async function proxy(request: NextRequest) {
|
|
|
683
690
|
if (pathname.includes('__egdesk_config_proxy')) {
|
|
684
691
|
try {
|
|
685
692
|
const body = await request.text();
|
|
686
|
-
const apiUrl =
|
|
693
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
687
694
|
|
|
688
695
|
const response = await fetch(\`\${apiUrl}/egdesk-config/tools/call\`, {
|
|
689
696
|
method: 'POST',
|
|
@@ -705,7 +712,7 @@ export async function proxy(request: NextRequest) {
|
|
|
705
712
|
if (pathname.includes('__ai_caller_proxy')) {
|
|
706
713
|
try {
|
|
707
714
|
const body = await request.text();
|
|
708
|
-
const apiUrl =
|
|
715
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
709
716
|
|
|
710
717
|
const response = await fetch(\`\${apiUrl}/ai-caller/tools/call\`, {
|
|
711
718
|
method: 'POST',
|
|
@@ -727,7 +734,7 @@ export async function proxy(request: NextRequest) {
|
|
|
727
734
|
if (pathname.includes('__financehub_proxy')) {
|
|
728
735
|
try {
|
|
729
736
|
const body = await request.text();
|
|
730
|
-
const apiUrl =
|
|
737
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
731
738
|
|
|
732
739
|
const response = await fetch(\`\${apiUrl}/financehub/tools/call\`, {
|
|
733
740
|
method: 'POST',
|
|
@@ -749,7 +756,7 @@ export async function proxy(request: NextRequest) {
|
|
|
749
756
|
if (pathname.includes('__blog_proxy')) {
|
|
750
757
|
try {
|
|
751
758
|
const body = await request.text();
|
|
752
|
-
const apiUrl =
|
|
759
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
753
760
|
|
|
754
761
|
const response = await fetch(\`\${apiUrl}/blog/tools/call\`, {
|
|
755
762
|
method: 'POST',
|
|
@@ -771,7 +778,7 @@ export async function proxy(request: NextRequest) {
|
|
|
771
778
|
if (pathname.includes('__youtube_proxy')) {
|
|
772
779
|
try {
|
|
773
780
|
const body = await request.text();
|
|
774
|
-
const apiUrl =
|
|
781
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
775
782
|
|
|
776
783
|
const response = await fetch(\`\${apiUrl}/youtube/tools/call\`, {
|
|
777
784
|
method: 'POST',
|
|
@@ -793,7 +800,7 @@ export async function proxy(request: NextRequest) {
|
|
|
793
800
|
if (pathname.includes('__visitor_auth_proxy')) {
|
|
794
801
|
try {
|
|
795
802
|
const body = await request.text();
|
|
796
|
-
const apiUrl =
|
|
803
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
797
804
|
|
|
798
805
|
const response = await fetch(\`\${apiUrl}/visitor-auth/tools/call\`, {
|
|
799
806
|
method: 'POST',
|
|
@@ -815,7 +822,7 @@ export async function proxy(request: NextRequest) {
|
|
|
815
822
|
if (pathname.includes('__visitor_google_proxy')) {
|
|
816
823
|
try {
|
|
817
824
|
const body = await request.text();
|
|
818
|
-
const apiUrl =
|
|
825
|
+
const apiUrl = resolveEgdeskMcpApiUrl();
|
|
819
826
|
const headers = visitorForwardHeaders(request);
|
|
820
827
|
const authorization = request.headers.get('authorization');
|
|
821
828
|
if (authorization) headers['Authorization'] = authorization;
|
|
@@ -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 }).
|
|
@@ -327,8 +341,37 @@ function isTunnelMcpRoot(value: string): boolean {
|
|
|
327
341
|
}
|
|
328
342
|
}
|
|
329
343
|
|
|
344
|
+
/** Custom-domain MCP roots must not keep /t/{id}; the gateway routes those by Host. */
|
|
345
|
+
function oauthBounceRoot(value: string): string {
|
|
346
|
+
try {
|
|
347
|
+
const parsed = new URL(value);
|
|
348
|
+
const gateway =
|
|
349
|
+
parsed.hostname === 'tunneling-service.onrender.com' ||
|
|
350
|
+
parsed.hostname.endsWith('.egdesk.cloud');
|
|
351
|
+
if (!gateway && /^\\/t\\/[^/]+/.test(parsed.pathname)) return parsed.origin;
|
|
352
|
+
return value.replace(/\\/$/, '');
|
|
353
|
+
} catch {
|
|
354
|
+
return value.replace(/\\/$/, '');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function resolveRemoteMcpRoot(configured: string, tunnelUrl: string): string {
|
|
359
|
+
if (tunnelUrl && isTunnelMcpRoot(tunnelUrl)) {
|
|
360
|
+
return oauthBounceRoot(tunnelUrl);
|
|
361
|
+
}
|
|
362
|
+
if (configured && !isLocalEgdeskUrl(configured)) {
|
|
363
|
+
return oauthBounceRoot(configured);
|
|
364
|
+
}
|
|
365
|
+
return '';
|
|
366
|
+
}
|
|
367
|
+
|
|
330
368
|
/**
|
|
331
|
-
* MCP root
|
|
369
|
+
* MCP root passed to visitor-auth start (egdeskPublicUrl).
|
|
370
|
+
*
|
|
371
|
+
* - Loopback dev → NEXT_PUBLIC_EGDESK_TUNNEL_URL when set, else local MCP (OAuth bounces via :54321).
|
|
372
|
+
* - LAN IP → tunnel MCP root from NEXT_PUBLIC_EGDESK_TUNNEL_URL or non-local API URL (required).
|
|
373
|
+
* - Tunnel/custom domain → tunnel MCP root; never window.location.origin on dev/LAN hosts.
|
|
374
|
+
*
|
|
332
375
|
* Published hosts must never silently fall back to http://localhost:8080.
|
|
333
376
|
*/
|
|
334
377
|
export function resolveEgdeskPublicUrl(): string {
|
|
@@ -340,10 +383,11 @@ export function resolveEgdeskPublicUrl(): string {
|
|
|
340
383
|
(typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_EGDESK_TUNNEL_URL) ||
|
|
341
384
|
''
|
|
342
385
|
).replace(/\\/$/, '');
|
|
343
|
-
const
|
|
386
|
+
const remoteMcpRoot = resolveRemoteMcpRoot(configured, tunnelUrl);
|
|
387
|
+
const localMcpRoot = configured || tunnelUrl || 'http://localhost:8080';
|
|
344
388
|
|
|
345
389
|
if (typeof window === 'undefined') {
|
|
346
|
-
return
|
|
390
|
+
return remoteMcpRoot || localMcpRoot;
|
|
347
391
|
}
|
|
348
392
|
|
|
349
393
|
const hostname = window.location.hostname;
|
|
@@ -352,27 +396,30 @@ export function resolveEgdeskPublicUrl(): string {
|
|
|
352
396
|
const onKnownGateway =
|
|
353
397
|
hostname === 'tunneling-service.onrender.com' || hostname.endsWith('.egdesk.cloud');
|
|
354
398
|
|
|
355
|
-
|
|
399
|
+
// Only the Render/egdesk.cloud gateway uses /t/{id} in the OAuth bounce path.
|
|
400
|
+
// Custom domains (sheetbot.cloud) bounce at {origin}/visitor-auth/callback/{id} — no /t/ prefix.
|
|
401
|
+
if (onTunnelPath && onKnownGateway) {
|
|
356
402
|
return window.location.origin + '/t/' + parts[1];
|
|
357
403
|
}
|
|
358
404
|
|
|
359
405
|
if (isDevSiteHostname(hostname)) {
|
|
360
|
-
if (isPrivateLanHostname(hostname)
|
|
361
|
-
return
|
|
406
|
+
if (isPrivateLanHostname(hostname)) {
|
|
407
|
+
if (remoteMcpRoot) return remoteMcpRoot;
|
|
408
|
+
throw new Error(
|
|
409
|
+
'Visitor Google login from a LAN IP requires NEXT_PUBLIC_EGDESK_TUNNEL_URL or a tunnel MCP root in NEXT_PUBLIC_EGDESK_API_URL (https://…/t/{id}).',
|
|
410
|
+
);
|
|
362
411
|
}
|
|
363
412
|
if (isLoopbackHostname(hostname)) {
|
|
364
|
-
return
|
|
365
|
-
}
|
|
366
|
-
if (preferred && !isLocalEgdeskUrl(preferred)) {
|
|
367
|
-
return preferred;
|
|
413
|
+
return remoteMcpRoot || localMcpRoot;
|
|
368
414
|
}
|
|
415
|
+
if (remoteMcpRoot) return remoteMcpRoot;
|
|
369
416
|
throw new Error(
|
|
370
|
-
'Visitor Google login from a LAN IP requires
|
|
417
|
+
'Visitor Google login from a LAN IP requires NEXT_PUBLIC_EGDESK_TUNNEL_URL or a tunnel MCP root in NEXT_PUBLIC_EGDESK_API_URL (https://…/t/{id}).',
|
|
371
418
|
);
|
|
372
419
|
}
|
|
373
420
|
|
|
374
|
-
if (
|
|
375
|
-
return
|
|
421
|
+
if (remoteMcpRoot) {
|
|
422
|
+
return remoteMcpRoot;
|
|
376
423
|
}
|
|
377
424
|
|
|
378
425
|
console.error(
|
|
@@ -427,8 +474,7 @@ export async function startVisitorGoogleLogin(options: {
|
|
|
427
474
|
);
|
|
428
475
|
const returnTo = new URL(resolveVisitorAppPath('/auth/callback'), window.location.origin);
|
|
429
476
|
returnTo.searchParams.set('next', next);
|
|
430
|
-
//
|
|
431
|
-
// Tunnel / custom domain → {MCP root}/visitor-auth/callback/{pendingId}.
|
|
477
|
+
// OAuth bounce is chosen server-side from returnTo + egdeskPublicUrl — see file header table.
|
|
432
478
|
const egdeskPublicUrl = resolveEgdeskPublicUrl();
|
|
433
479
|
if (isLocalEgdeskUrl(egdeskPublicUrl) && !isDevSiteHostname(window.location.hostname)) {
|
|
434
480
|
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.
|
|
11
|
+
export declare const COMPATIBLE_APP_VERSION = "1.4.105";
|
|
12
12
|
export interface SetupOptions {
|
|
13
13
|
egdeskUrl?: string;
|
|
14
14
|
/** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
|
|
@@ -40,6 +40,7 @@ export type { UserDataTable, UserDataConfig } from './setup-userdata';
|
|
|
40
40
|
export { discoverTables, generateConfigFile, loadTablesFromSchemaFile, updateEnvFiles } from './setup-userdata';
|
|
41
41
|
export { generateMiddleware } from './generate-middleware';
|
|
42
42
|
export { generateProxy } from './generate-proxy';
|
|
43
|
+
export { generateChunkedUploadRoutes } from './generate-chunked-upload-routes';
|
|
43
44
|
export { generateHelpers, generateSchemaFile, ensureSchemaFile, formatEgdeskSchemaFileContent } from './generate-helpers';
|
|
44
45
|
export type { SchemaTableDefinition, EnsureSchemaFileResult, GenerateHelpersOptions } from './generate-helpers';
|
|
45
46
|
export { generateApiWrapper } from './generate-api-wrapper';
|
package/dist/index.js
CHANGED
|
@@ -39,19 +39,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
};
|
|
40
40
|
})();
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.ensureVisitorAuthConfig = exports.generateVisitorAuth = exports.generateApiWrapper = exports.formatEgdeskSchemaFileContent = exports.ensureSchemaFile = exports.generateSchemaFile = exports.generateHelpers = exports.generateProxy = exports.generateMiddleware = exports.updateEnvFiles = exports.loadTablesFromSchemaFile = exports.generateConfigFile = exports.discoverTables = exports.COMPATIBLE_APP_VERSION = void 0;
|
|
42
|
+
exports.ensureVisitorAuthConfig = exports.generateVisitorAuth = exports.generateApiWrapper = exports.formatEgdeskSchemaFileContent = exports.ensureSchemaFile = exports.generateSchemaFile = exports.generateHelpers = exports.generateChunkedUploadRoutes = exports.generateProxy = exports.generateMiddleware = exports.updateEnvFiles = exports.loadTablesFromSchemaFile = exports.generateConfigFile = exports.discoverTables = exports.COMPATIBLE_APP_VERSION = void 0;
|
|
43
43
|
exports.detectNextUseProxy = detectNextUseProxy;
|
|
44
44
|
exports.setupNextApiPlugin = setupNextApiPlugin;
|
|
45
45
|
/**
|
|
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.105';
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
52
|
const setup_userdata_1 = require("./setup-userdata");
|
|
53
53
|
const generate_middleware_1 = require("./generate-middleware");
|
|
54
54
|
const generate_proxy_1 = require("./generate-proxy");
|
|
55
|
+
const generate_chunked_upload_routes_1 = require("./generate-chunked-upload-routes");
|
|
55
56
|
const generate_helpers_1 = require("./generate-helpers");
|
|
56
57
|
const generate_api_wrapper_1 = require("./generate-api-wrapper");
|
|
57
58
|
const generate_visitor_auth_1 = require("./generate-visitor-auth");
|
|
@@ -186,6 +187,7 @@ async function setupNextApiPlugin(projectPath, options = {}) {
|
|
|
186
187
|
columns: table.columns,
|
|
187
188
|
})));
|
|
188
189
|
(0, generate_helpers_1.generateHelpers)(projectPath, { apiKeyNames });
|
|
190
|
+
(0, generate_chunked_upload_routes_1.generateChunkedUploadRoutes)(projectPath);
|
|
189
191
|
(0, generate_api_wrapper_1.generateApiWrapper)(projectPath);
|
|
190
192
|
(0, generate_visitor_auth_1.generateVisitorAuth)(projectPath);
|
|
191
193
|
(0, setup_userdata_1.updateEnvFiles)(projectPath, config, prodTables);
|
|
@@ -196,6 +198,7 @@ async function setupNextApiPlugin(projectPath, options = {}) {
|
|
|
196
198
|
console.log(' - egdesk.config.ts (type-safe config)');
|
|
197
199
|
console.log(' - egdesk.schema.ts (committed seed schema — add to git if newly created)');
|
|
198
200
|
console.log(' - egdesk-helpers.ts (helper functions)');
|
|
201
|
+
console.log(' - app/api/user/files/uploads/* (chunked upload routes)');
|
|
199
202
|
console.log(' - egdesk-visitor-google.ts (generated visitor Google helper — do not edit)');
|
|
200
203
|
console.log(' - egdesk.visitor-auth.ts (site-owned login defaults; never overwritten)');
|
|
201
204
|
console.log(' - src/lib/api.ts (basePath-aware fetch wrapper)');
|
|
@@ -205,8 +208,10 @@ async function setupNextApiPlugin(projectPath, options = {}) {
|
|
|
205
208
|
console.log('');
|
|
206
209
|
console.log('📝 Next steps:');
|
|
207
210
|
console.log(' 1. Add .env.*.local to your .gitignore');
|
|
208
|
-
console.log(' 2.
|
|
209
|
-
console.log('
|
|
211
|
+
console.log(' 2. Supabase Auth redirect URLs (once per EGDesk/tunnel origin):');
|
|
212
|
+
console.log(' - http://localhost:54321/auth/callback (exact — loopback hosted-coding + owner)');
|
|
213
|
+
console.log(' - {EGDesk public URL}/visitor-auth/callback/** (tunnel / LAN IP with tunnel env)');
|
|
214
|
+
console.log(' Loopback → :54321; LAN IP or tunnel → /visitor-auth/callback/{pendingId} (see egdesk-visitor-google.ts header)');
|
|
210
215
|
console.log(' Visitor sessions are bound to each site origin and cannot be reused across sites');
|
|
211
216
|
console.log(' 3. Restart your Next.js dev server');
|
|
212
217
|
console.log(' 4. Import and use helpers in your components:');
|
|
@@ -235,6 +240,8 @@ var generate_middleware_2 = require("./generate-middleware");
|
|
|
235
240
|
Object.defineProperty(exports, "generateMiddleware", { enumerable: true, get: function () { return generate_middleware_2.generateMiddleware; } });
|
|
236
241
|
var generate_proxy_2 = require("./generate-proxy");
|
|
237
242
|
Object.defineProperty(exports, "generateProxy", { enumerable: true, get: function () { return generate_proxy_2.generateProxy; } });
|
|
243
|
+
var generate_chunked_upload_routes_2 = require("./generate-chunked-upload-routes");
|
|
244
|
+
Object.defineProperty(exports, "generateChunkedUploadRoutes", { enumerable: true, get: function () { return generate_chunked_upload_routes_2.generateChunkedUploadRoutes; } });
|
|
238
245
|
var generate_helpers_2 = require("./generate-helpers");
|
|
239
246
|
Object.defineProperty(exports, "generateHelpers", { enumerable: true, get: function () { return generate_helpers_2.generateHelpers; } });
|
|
240
247
|
Object.defineProperty(exports, "generateSchemaFile", { enumerable: true, get: function () { return generate_helpers_2.generateSchemaFile; } });
|