integrate-sdk 0.7.9 → 0.7.11
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/dist/adapters/solid-start.js +6 -30
- package/dist/adapters/svelte-kit.js +6 -30
- package/dist/index.js +61 -63
- package/dist/server.js +61 -63
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/oauth/window-manager.d.ts.map +1 -1
- package/dist/src/server.d.ts +39 -29
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/utils/env.d.ts +0 -13
- package/dist/src/utils/env.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -800,32 +800,8 @@ function methodToToolName(methodName, pluginId) {
|
|
|
800
800
|
const snakeCaseMethod = camelToSnake(methodName);
|
|
801
801
|
return `${pluginId}_${snakeCaseMethod}`;
|
|
802
802
|
}
|
|
803
|
-
|
|
804
|
-
// src/utils/env.ts
|
|
805
|
-
function isBrowser() {
|
|
806
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
807
|
-
}
|
|
808
|
-
async function safeReplaceState(url) {
|
|
809
|
-
if (!isBrowser()) {
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
if (typeof globalThis.__sveltekit !== "undefined") {
|
|
813
|
-
try {
|
|
814
|
-
const modulePath = "$app/navigation";
|
|
815
|
-
const importFn = new Function("path", "return import(path)");
|
|
816
|
-
const navigation = await importFn(modulePath);
|
|
817
|
-
if (navigation && typeof navigation.replaceState === "function") {
|
|
818
|
-
navigation.replaceState(url, {});
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
} catch (e) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
window.history.replaceState(null, "", url);
|
|
826
|
-
}
|
|
827
803
|
// src/oauth/window-manager.ts
|
|
828
|
-
function
|
|
804
|
+
function isBrowser() {
|
|
829
805
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
830
806
|
}
|
|
831
807
|
|
|
@@ -834,7 +810,7 @@ class OAuthWindowManager {
|
|
|
834
810
|
popupCheckInterval = null;
|
|
835
811
|
popupCheckTimeout = null;
|
|
836
812
|
openPopup(url, options) {
|
|
837
|
-
if (!
|
|
813
|
+
if (!isBrowser()) {
|
|
838
814
|
throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
|
|
839
815
|
}
|
|
840
816
|
const width = options?.width || 600;
|
|
@@ -867,7 +843,7 @@ class OAuthWindowManager {
|
|
|
867
843
|
return this.popupWindow;
|
|
868
844
|
}
|
|
869
845
|
openRedirect(url) {
|
|
870
|
-
if (!
|
|
846
|
+
if (!isBrowser()) {
|
|
871
847
|
throw new Error("OAuthWindowManager.openRedirect() can only be used in browser environments");
|
|
872
848
|
}
|
|
873
849
|
window.location.href = url;
|
|
@@ -880,7 +856,7 @@ class OAuthWindowManager {
|
|
|
880
856
|
}
|
|
881
857
|
}
|
|
882
858
|
listenForPopupCallback(timeoutMs) {
|
|
883
|
-
if (!
|
|
859
|
+
if (!isBrowser()) {
|
|
884
860
|
return Promise.reject(new Error("OAuth popup callback can only be used in browser environments"));
|
|
885
861
|
}
|
|
886
862
|
return new Promise((resolve, reject) => {
|
|
@@ -927,7 +903,7 @@ class OAuthWindowManager {
|
|
|
927
903
|
});
|
|
928
904
|
}
|
|
929
905
|
listenForRedirectCallback() {
|
|
930
|
-
if (!
|
|
906
|
+
if (!isBrowser()) {
|
|
931
907
|
return Promise.reject(new Error("OAuth redirect callback can only be used in browser environments"));
|
|
932
908
|
}
|
|
933
909
|
return new Promise((resolve, reject) => {
|
|
@@ -945,7 +921,7 @@ class OAuthWindowManager {
|
|
|
945
921
|
const parsed = JSON.parse(decodeURIComponent(oauthCallback));
|
|
946
922
|
code = parsed.code;
|
|
947
923
|
state = parsed.state;
|
|
948
|
-
|
|
924
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
949
925
|
}
|
|
950
926
|
} catch (e) {
|
|
951
927
|
console.error("Failed to parse OAuth callback params from hash:", e);
|
|
@@ -800,32 +800,8 @@ function methodToToolName(methodName, pluginId) {
|
|
|
800
800
|
const snakeCaseMethod = camelToSnake(methodName);
|
|
801
801
|
return `${pluginId}_${snakeCaseMethod}`;
|
|
802
802
|
}
|
|
803
|
-
|
|
804
|
-
// src/utils/env.ts
|
|
805
|
-
function isBrowser() {
|
|
806
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
807
|
-
}
|
|
808
|
-
async function safeReplaceState(url) {
|
|
809
|
-
if (!isBrowser()) {
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
if (typeof globalThis.__sveltekit !== "undefined") {
|
|
813
|
-
try {
|
|
814
|
-
const modulePath = "$app/navigation";
|
|
815
|
-
const importFn = new Function("path", "return import(path)");
|
|
816
|
-
const navigation = await importFn(modulePath);
|
|
817
|
-
if (navigation && typeof navigation.replaceState === "function") {
|
|
818
|
-
navigation.replaceState(url, {});
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
} catch (e) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
window.history.replaceState(null, "", url);
|
|
826
|
-
}
|
|
827
803
|
// src/oauth/window-manager.ts
|
|
828
|
-
function
|
|
804
|
+
function isBrowser() {
|
|
829
805
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
830
806
|
}
|
|
831
807
|
|
|
@@ -834,7 +810,7 @@ class OAuthWindowManager {
|
|
|
834
810
|
popupCheckInterval = null;
|
|
835
811
|
popupCheckTimeout = null;
|
|
836
812
|
openPopup(url, options) {
|
|
837
|
-
if (!
|
|
813
|
+
if (!isBrowser()) {
|
|
838
814
|
throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
|
|
839
815
|
}
|
|
840
816
|
const width = options?.width || 600;
|
|
@@ -867,7 +843,7 @@ class OAuthWindowManager {
|
|
|
867
843
|
return this.popupWindow;
|
|
868
844
|
}
|
|
869
845
|
openRedirect(url) {
|
|
870
|
-
if (!
|
|
846
|
+
if (!isBrowser()) {
|
|
871
847
|
throw new Error("OAuthWindowManager.openRedirect() can only be used in browser environments");
|
|
872
848
|
}
|
|
873
849
|
window.location.href = url;
|
|
@@ -880,7 +856,7 @@ class OAuthWindowManager {
|
|
|
880
856
|
}
|
|
881
857
|
}
|
|
882
858
|
listenForPopupCallback(timeoutMs) {
|
|
883
|
-
if (!
|
|
859
|
+
if (!isBrowser()) {
|
|
884
860
|
return Promise.reject(new Error("OAuth popup callback can only be used in browser environments"));
|
|
885
861
|
}
|
|
886
862
|
return new Promise((resolve, reject) => {
|
|
@@ -927,7 +903,7 @@ class OAuthWindowManager {
|
|
|
927
903
|
});
|
|
928
904
|
}
|
|
929
905
|
listenForRedirectCallback() {
|
|
930
|
-
if (!
|
|
906
|
+
if (!isBrowser()) {
|
|
931
907
|
return Promise.reject(new Error("OAuth redirect callback can only be used in browser environments"));
|
|
932
908
|
}
|
|
933
909
|
return new Promise((resolve, reject) => {
|
|
@@ -945,7 +921,7 @@ class OAuthWindowManager {
|
|
|
945
921
|
const parsed = JSON.parse(decodeURIComponent(oauthCallback));
|
|
946
922
|
code = parsed.code;
|
|
947
923
|
state = parsed.state;
|
|
948
|
-
|
|
924
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
949
925
|
}
|
|
950
926
|
} catch (e) {
|
|
951
927
|
console.error("Failed to parse OAuth callback params from hash:", e);
|
package/dist/index.js
CHANGED
|
@@ -635,50 +635,8 @@ function methodToToolName(methodName, pluginId) {
|
|
|
635
635
|
const snakeCaseMethod = camelToSnake(methodName);
|
|
636
636
|
return `${pluginId}_${snakeCaseMethod}`;
|
|
637
637
|
}
|
|
638
|
-
|
|
639
|
-
// src/utils/env.ts
|
|
640
|
-
function getEnv(key) {
|
|
641
|
-
try {
|
|
642
|
-
const metaEnv = import.meta.env;
|
|
643
|
-
if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
|
|
644
|
-
const value = metaEnv[key];
|
|
645
|
-
if (value !== undefined && value !== null && value !== "") {
|
|
646
|
-
return String(value);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
} catch {}
|
|
650
|
-
if (typeof process !== "undefined" && process.env) {
|
|
651
|
-
const value = process.env[key];
|
|
652
|
-
if (value !== undefined && value !== null && value !== "") {
|
|
653
|
-
return value;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
function isBrowser() {
|
|
659
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
660
|
-
}
|
|
661
|
-
async function safeReplaceState(url) {
|
|
662
|
-
if (!isBrowser()) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
if (typeof globalThis.__sveltekit !== "undefined") {
|
|
666
|
-
try {
|
|
667
|
-
const modulePath = "$app/navigation";
|
|
668
|
-
const importFn = new Function("path", "return import(path)");
|
|
669
|
-
const navigation = await importFn(modulePath);
|
|
670
|
-
if (navigation && typeof navigation.replaceState === "function") {
|
|
671
|
-
navigation.replaceState(url, {});
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
} catch (e) {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
window.history.replaceState(null, "", url);
|
|
679
|
-
}
|
|
680
638
|
// src/oauth/window-manager.ts
|
|
681
|
-
function
|
|
639
|
+
function isBrowser() {
|
|
682
640
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
683
641
|
}
|
|
684
642
|
|
|
@@ -687,7 +645,7 @@ class OAuthWindowManager {
|
|
|
687
645
|
popupCheckInterval = null;
|
|
688
646
|
popupCheckTimeout = null;
|
|
689
647
|
openPopup(url, options) {
|
|
690
|
-
if (!
|
|
648
|
+
if (!isBrowser()) {
|
|
691
649
|
throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
|
|
692
650
|
}
|
|
693
651
|
const width = options?.width || 600;
|
|
@@ -720,7 +678,7 @@ class OAuthWindowManager {
|
|
|
720
678
|
return this.popupWindow;
|
|
721
679
|
}
|
|
722
680
|
openRedirect(url) {
|
|
723
|
-
if (!
|
|
681
|
+
if (!isBrowser()) {
|
|
724
682
|
throw new Error("OAuthWindowManager.openRedirect() can only be used in browser environments");
|
|
725
683
|
}
|
|
726
684
|
window.location.href = url;
|
|
@@ -733,7 +691,7 @@ class OAuthWindowManager {
|
|
|
733
691
|
}
|
|
734
692
|
}
|
|
735
693
|
listenForPopupCallback(timeoutMs) {
|
|
736
|
-
if (!
|
|
694
|
+
if (!isBrowser()) {
|
|
737
695
|
return Promise.reject(new Error("OAuth popup callback can only be used in browser environments"));
|
|
738
696
|
}
|
|
739
697
|
return new Promise((resolve, reject) => {
|
|
@@ -780,7 +738,7 @@ class OAuthWindowManager {
|
|
|
780
738
|
});
|
|
781
739
|
}
|
|
782
740
|
listenForRedirectCallback() {
|
|
783
|
-
if (!
|
|
741
|
+
if (!isBrowser()) {
|
|
784
742
|
return Promise.reject(new Error("OAuth redirect callback can only be used in browser environments"));
|
|
785
743
|
}
|
|
786
744
|
return new Promise((resolve, reject) => {
|
|
@@ -798,7 +756,7 @@ class OAuthWindowManager {
|
|
|
798
756
|
const parsed = JSON.parse(decodeURIComponent(oauthCallback));
|
|
799
757
|
code = parsed.code;
|
|
800
758
|
state = parsed.state;
|
|
801
|
-
|
|
759
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
802
760
|
}
|
|
803
761
|
} catch (e) {
|
|
804
762
|
console.error("Failed to parse OAuth callback params from hash:", e);
|
|
@@ -848,7 +806,7 @@ class OAuthWindowManager {
|
|
|
848
806
|
}
|
|
849
807
|
}
|
|
850
808
|
function sendCallbackToOpener(params) {
|
|
851
|
-
if (!
|
|
809
|
+
if (!isBrowser()) {
|
|
852
810
|
console.error("sendCallbackToOpener() can only be used in browser environments");
|
|
853
811
|
return;
|
|
854
812
|
}
|
|
@@ -1733,7 +1691,7 @@ function processOAuthCallbackFromHash(client) {
|
|
|
1733
1691
|
client.handleOAuthCallback(callbackParams).catch((error) => {
|
|
1734
1692
|
console.error("Failed to process OAuth callback:", error);
|
|
1735
1693
|
});
|
|
1736
|
-
|
|
1694
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
1737
1695
|
}
|
|
1738
1696
|
}
|
|
1739
1697
|
}
|
|
@@ -2111,6 +2069,26 @@ function toNodeHandler(config) {
|
|
|
2111
2069
|
}
|
|
2112
2070
|
};
|
|
2113
2071
|
}
|
|
2072
|
+
// src/utils/env.ts
|
|
2073
|
+
function getEnv(key) {
|
|
2074
|
+
try {
|
|
2075
|
+
const metaEnv = import.meta.env;
|
|
2076
|
+
if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
|
|
2077
|
+
const value = metaEnv[key];
|
|
2078
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
2079
|
+
return String(value);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
} catch {}
|
|
2083
|
+
if (typeof process !== "undefined" && process.env) {
|
|
2084
|
+
const value = process.env[key];
|
|
2085
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
2086
|
+
return value;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2114
2092
|
// src/plugins/github.ts
|
|
2115
2093
|
var GITHUB_TOOLS = [
|
|
2116
2094
|
"github_create_issue",
|
|
@@ -2427,28 +2405,48 @@ var GET = async (req, context) => {
|
|
|
2427
2405
|
const routes = handler.createRoutes();
|
|
2428
2406
|
return routes.GET(req, context);
|
|
2429
2407
|
};
|
|
2430
|
-
function toNextJsHandler(
|
|
2408
|
+
function toNextJsHandler(clientOrOptions, redirectOptions) {
|
|
2409
|
+
let config;
|
|
2410
|
+
let redirectUrl;
|
|
2411
|
+
let errorRedirectUrl;
|
|
2412
|
+
if (!clientOrOptions) {
|
|
2413
|
+
config = globalServerConfig;
|
|
2414
|
+
redirectUrl = redirectOptions?.redirectUrl;
|
|
2415
|
+
errorRedirectUrl = redirectOptions?.errorRedirectUrl;
|
|
2416
|
+
} else if (clientOrOptions.__oauthConfig) {
|
|
2417
|
+
config = clientOrOptions.__oauthConfig;
|
|
2418
|
+
redirectUrl = redirectOptions?.redirectUrl;
|
|
2419
|
+
errorRedirectUrl = redirectOptions?.errorRedirectUrl;
|
|
2420
|
+
} else if (typeof clientOrOptions === "object" && clientOrOptions.providers) {
|
|
2421
|
+
config = {
|
|
2422
|
+
providers: clientOrOptions.providers,
|
|
2423
|
+
serverUrl: clientOrOptions.serverUrl,
|
|
2424
|
+
apiKey: clientOrOptions.apiKey
|
|
2425
|
+
};
|
|
2426
|
+
redirectUrl = clientOrOptions.redirectUrl;
|
|
2427
|
+
errorRedirectUrl = clientOrOptions.errorRedirectUrl;
|
|
2428
|
+
} else {
|
|
2429
|
+
config = null;
|
|
2430
|
+
}
|
|
2431
|
+
if (!config) {
|
|
2432
|
+
throw new Error(`toNextJsHandler requires either:
|
|
2433
|
+
1. A client instance from createMCPServer()
|
|
2434
|
+
2. A config object with providers property
|
|
2435
|
+
3. No arguments (uses global config from createMCPServer)`);
|
|
2436
|
+
}
|
|
2431
2437
|
const POST2 = async (req, context) => {
|
|
2432
|
-
const config = options.config || options.client?.__oauthConfig;
|
|
2433
|
-
if (!config) {
|
|
2434
|
-
return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
|
|
2435
|
-
}
|
|
2436
2438
|
const handler = createNextOAuthHandler(config);
|
|
2437
2439
|
const routes = handler.toNextJsHandler({
|
|
2438
|
-
redirectUrl
|
|
2439
|
-
errorRedirectUrl
|
|
2440
|
+
redirectUrl,
|
|
2441
|
+
errorRedirectUrl
|
|
2440
2442
|
});
|
|
2441
2443
|
return routes.POST(req, context);
|
|
2442
2444
|
};
|
|
2443
2445
|
const GET2 = async (req, context) => {
|
|
2444
|
-
const config = options.config || options.client?.__oauthConfig;
|
|
2445
|
-
if (!config) {
|
|
2446
|
-
return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
|
|
2447
|
-
}
|
|
2448
2446
|
const handler = createNextOAuthHandler(config);
|
|
2449
2447
|
const routes = handler.toNextJsHandler({
|
|
2450
|
-
redirectUrl
|
|
2451
|
-
errorRedirectUrl
|
|
2448
|
+
redirectUrl,
|
|
2449
|
+
errorRedirectUrl
|
|
2452
2450
|
});
|
|
2453
2451
|
return routes.GET(req, context);
|
|
2454
2452
|
};
|
package/dist/server.js
CHANGED
|
@@ -635,50 +635,8 @@ function methodToToolName(methodName, pluginId) {
|
|
|
635
635
|
const snakeCaseMethod = camelToSnake(methodName);
|
|
636
636
|
return `${pluginId}_${snakeCaseMethod}`;
|
|
637
637
|
}
|
|
638
|
-
|
|
639
|
-
// src/utils/env.ts
|
|
640
|
-
function getEnv(key) {
|
|
641
|
-
try {
|
|
642
|
-
const metaEnv = import.meta.env;
|
|
643
|
-
if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
|
|
644
|
-
const value = metaEnv[key];
|
|
645
|
-
if (value !== undefined && value !== null && value !== "") {
|
|
646
|
-
return String(value);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
} catch {}
|
|
650
|
-
if (typeof process !== "undefined" && process.env) {
|
|
651
|
-
const value = process.env[key];
|
|
652
|
-
if (value !== undefined && value !== null && value !== "") {
|
|
653
|
-
return value;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
function isBrowser() {
|
|
659
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
660
|
-
}
|
|
661
|
-
async function safeReplaceState(url) {
|
|
662
|
-
if (!isBrowser()) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
if (typeof globalThis.__sveltekit !== "undefined") {
|
|
666
|
-
try {
|
|
667
|
-
const modulePath = "$app/navigation";
|
|
668
|
-
const importFn = new Function("path", "return import(path)");
|
|
669
|
-
const navigation = await importFn(modulePath);
|
|
670
|
-
if (navigation && typeof navigation.replaceState === "function") {
|
|
671
|
-
navigation.replaceState(url, {});
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
} catch (e) {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
window.history.replaceState(null, "", url);
|
|
679
|
-
}
|
|
680
638
|
// src/oauth/window-manager.ts
|
|
681
|
-
function
|
|
639
|
+
function isBrowser() {
|
|
682
640
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
683
641
|
}
|
|
684
642
|
|
|
@@ -687,7 +645,7 @@ class OAuthWindowManager {
|
|
|
687
645
|
popupCheckInterval = null;
|
|
688
646
|
popupCheckTimeout = null;
|
|
689
647
|
openPopup(url, options) {
|
|
690
|
-
if (!
|
|
648
|
+
if (!isBrowser()) {
|
|
691
649
|
throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
|
|
692
650
|
}
|
|
693
651
|
const width = options?.width || 600;
|
|
@@ -720,7 +678,7 @@ class OAuthWindowManager {
|
|
|
720
678
|
return this.popupWindow;
|
|
721
679
|
}
|
|
722
680
|
openRedirect(url) {
|
|
723
|
-
if (!
|
|
681
|
+
if (!isBrowser()) {
|
|
724
682
|
throw new Error("OAuthWindowManager.openRedirect() can only be used in browser environments");
|
|
725
683
|
}
|
|
726
684
|
window.location.href = url;
|
|
@@ -733,7 +691,7 @@ class OAuthWindowManager {
|
|
|
733
691
|
}
|
|
734
692
|
}
|
|
735
693
|
listenForPopupCallback(timeoutMs) {
|
|
736
|
-
if (!
|
|
694
|
+
if (!isBrowser()) {
|
|
737
695
|
return Promise.reject(new Error("OAuth popup callback can only be used in browser environments"));
|
|
738
696
|
}
|
|
739
697
|
return new Promise((resolve, reject) => {
|
|
@@ -780,7 +738,7 @@ class OAuthWindowManager {
|
|
|
780
738
|
});
|
|
781
739
|
}
|
|
782
740
|
listenForRedirectCallback() {
|
|
783
|
-
if (!
|
|
741
|
+
if (!isBrowser()) {
|
|
784
742
|
return Promise.reject(new Error("OAuth redirect callback can only be used in browser environments"));
|
|
785
743
|
}
|
|
786
744
|
return new Promise((resolve, reject) => {
|
|
@@ -798,7 +756,7 @@ class OAuthWindowManager {
|
|
|
798
756
|
const parsed = JSON.parse(decodeURIComponent(oauthCallback));
|
|
799
757
|
code = parsed.code;
|
|
800
758
|
state = parsed.state;
|
|
801
|
-
|
|
759
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
802
760
|
}
|
|
803
761
|
} catch (e) {
|
|
804
762
|
console.error("Failed to parse OAuth callback params from hash:", e);
|
|
@@ -848,7 +806,7 @@ class OAuthWindowManager {
|
|
|
848
806
|
}
|
|
849
807
|
}
|
|
850
808
|
function sendCallbackToOpener(params) {
|
|
851
|
-
if (!
|
|
809
|
+
if (!isBrowser()) {
|
|
852
810
|
console.error("sendCallbackToOpener() can only be used in browser environments");
|
|
853
811
|
return;
|
|
854
812
|
}
|
|
@@ -1733,7 +1691,7 @@ function processOAuthCallbackFromHash(client) {
|
|
|
1733
1691
|
client.handleOAuthCallback(callbackParams).catch((error) => {
|
|
1734
1692
|
console.error("Failed to process OAuth callback:", error);
|
|
1735
1693
|
});
|
|
1736
|
-
|
|
1694
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
1737
1695
|
}
|
|
1738
1696
|
}
|
|
1739
1697
|
}
|
|
@@ -1937,6 +1895,26 @@ function createNextOAuthHandler(config) {
|
|
|
1937
1895
|
return handlers;
|
|
1938
1896
|
}
|
|
1939
1897
|
|
|
1898
|
+
// src/utils/env.ts
|
|
1899
|
+
function getEnv(key) {
|
|
1900
|
+
try {
|
|
1901
|
+
const metaEnv = import.meta.env;
|
|
1902
|
+
if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
|
|
1903
|
+
const value = metaEnv[key];
|
|
1904
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
1905
|
+
return String(value);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
} catch {}
|
|
1909
|
+
if (typeof process !== "undefined" && process.env) {
|
|
1910
|
+
const value = process.env[key];
|
|
1911
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
1912
|
+
return value;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1940
1918
|
// src/plugins/github.ts
|
|
1941
1919
|
var GITHUB_TOOLS = [
|
|
1942
1920
|
"github_create_issue",
|
|
@@ -2253,28 +2231,48 @@ var GET = async (req, context) => {
|
|
|
2253
2231
|
const routes = handler.createRoutes();
|
|
2254
2232
|
return routes.GET(req, context);
|
|
2255
2233
|
};
|
|
2256
|
-
function toNextJsHandler(
|
|
2234
|
+
function toNextJsHandler(clientOrOptions, redirectOptions) {
|
|
2235
|
+
let config;
|
|
2236
|
+
let redirectUrl;
|
|
2237
|
+
let errorRedirectUrl;
|
|
2238
|
+
if (!clientOrOptions) {
|
|
2239
|
+
config = globalServerConfig;
|
|
2240
|
+
redirectUrl = redirectOptions?.redirectUrl;
|
|
2241
|
+
errorRedirectUrl = redirectOptions?.errorRedirectUrl;
|
|
2242
|
+
} else if (clientOrOptions.__oauthConfig) {
|
|
2243
|
+
config = clientOrOptions.__oauthConfig;
|
|
2244
|
+
redirectUrl = redirectOptions?.redirectUrl;
|
|
2245
|
+
errorRedirectUrl = redirectOptions?.errorRedirectUrl;
|
|
2246
|
+
} else if (typeof clientOrOptions === "object" && clientOrOptions.providers) {
|
|
2247
|
+
config = {
|
|
2248
|
+
providers: clientOrOptions.providers,
|
|
2249
|
+
serverUrl: clientOrOptions.serverUrl,
|
|
2250
|
+
apiKey: clientOrOptions.apiKey
|
|
2251
|
+
};
|
|
2252
|
+
redirectUrl = clientOrOptions.redirectUrl;
|
|
2253
|
+
errorRedirectUrl = clientOrOptions.errorRedirectUrl;
|
|
2254
|
+
} else {
|
|
2255
|
+
config = null;
|
|
2256
|
+
}
|
|
2257
|
+
if (!config) {
|
|
2258
|
+
throw new Error(`toNextJsHandler requires either:
|
|
2259
|
+
1. A client instance from createMCPServer()
|
|
2260
|
+
2. A config object with providers property
|
|
2261
|
+
3. No arguments (uses global config from createMCPServer)`);
|
|
2262
|
+
}
|
|
2257
2263
|
const POST2 = async (req, context) => {
|
|
2258
|
-
const config = options.config || options.client?.__oauthConfig;
|
|
2259
|
-
if (!config) {
|
|
2260
|
-
return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
|
|
2261
|
-
}
|
|
2262
2264
|
const handler = createNextOAuthHandler(config);
|
|
2263
2265
|
const routes = handler.toNextJsHandler({
|
|
2264
|
-
redirectUrl
|
|
2265
|
-
errorRedirectUrl
|
|
2266
|
+
redirectUrl,
|
|
2267
|
+
errorRedirectUrl
|
|
2266
2268
|
});
|
|
2267
2269
|
return routes.POST(req, context);
|
|
2268
2270
|
};
|
|
2269
2271
|
const GET2 = async (req, context) => {
|
|
2270
|
-
const config = options.config || options.client?.__oauthConfig;
|
|
2271
|
-
if (!config) {
|
|
2272
|
-
return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
|
|
2273
|
-
}
|
|
2274
2272
|
const handler = createNextOAuthHandler(config);
|
|
2275
2273
|
const routes = handler.toNextJsHandler({
|
|
2276
|
-
redirectUrl
|
|
2277
|
-
errorRedirectUrl
|
|
2274
|
+
redirectUrl,
|
|
2275
|
+
errorRedirectUrl
|
|
2278
2276
|
});
|
|
2279
2277
|
return routes.GET(req, context);
|
|
2280
2278
|
};
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,OAAO,EAEP,mBAAmB,EAGpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,SA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;OAGG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CA2BzD;AA6DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAChC,SAAS,CAAC,QAAQ,CAAC,CAkErB;AA0CD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAetD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window-manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/window-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"window-manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/window-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AASpE;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,kBAAkB,CAA+C;IACzE,OAAO,CAAC,iBAAiB,CAA8C;IAEvE;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI;IA6C7D;;;;;;;;;;OAUG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQ/B;;;;;;;;;;;;;;;;;OAiBG;IACH,iBAAiB,CACf,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,SAAS,GAAE,MAAsB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAQ/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAkE9B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAiEjC;;OAEG;IACH,OAAO,CAAC,OAAO;IAiBf;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,GAAG,IAAI,CAwBP"}
|
package/dist/src/server.d.ts
CHANGED
|
@@ -122,15 +122,18 @@ export declare const GET: (req: any, context: {
|
|
|
122
122
|
}>;
|
|
123
123
|
}) => Promise<any>;
|
|
124
124
|
/**
|
|
125
|
-
* Create catch-all route handlers
|
|
125
|
+
* Create catch-all route handlers for Next.js
|
|
126
126
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
127
|
+
* Supports two usage patterns:
|
|
128
|
+
* 1. Pass a client instance from createMCPServer
|
|
129
|
+
* 2. Pass config object directly (for inline configuration)
|
|
129
130
|
*
|
|
130
|
-
* @param
|
|
131
|
+
* @param clientOrOptions - Client instance from createMCPServer, or config options
|
|
132
|
+
* @param redirectOptions - Redirect URL configuration (when first param is a client)
|
|
131
133
|
* @returns Object with POST and GET handlers for Next.js catch-all routes
|
|
132
134
|
*
|
|
133
135
|
* @example
|
|
136
|
+
* **Pattern 1: Using client from createMCPServer (Recommended)**
|
|
134
137
|
* ```typescript
|
|
135
138
|
* // lib/integrate-server.ts
|
|
136
139
|
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
@@ -146,45 +149,52 @@ export declare const GET: (req: any, context: {
|
|
|
146
149
|
* });
|
|
147
150
|
*
|
|
148
151
|
* // app/api/integrate/[...all]/route.ts
|
|
149
|
-
*
|
|
150
|
-
* // RECOMMENDED: Import serverClient from your server setup file
|
|
151
152
|
* import { serverClient } from '@/lib/integrate-server';
|
|
152
153
|
* import { toNextJsHandler } from 'integrate-sdk/server';
|
|
153
154
|
*
|
|
154
|
-
* export const { POST, GET } = toNextJsHandler({
|
|
155
|
-
* client: serverClient, // Pass the client from createMCPServer
|
|
155
|
+
* export const { POST, GET } = toNextJsHandler(serverClient, {
|
|
156
156
|
* redirectUrl: '/dashboard',
|
|
157
|
+
* errorRedirectUrl: '/auth-error',
|
|
157
158
|
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* **Pattern 2: Inline configuration**
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // app/api/integrate/[...all]/route.ts
|
|
165
|
+
* import { toNextJsHandler } from 'integrate-sdk/server';
|
|
158
166
|
*
|
|
159
|
-
* // Alternative: Provide config inline
|
|
160
167
|
* export const { POST, GET } = toNextJsHandler({
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
166
|
-
* },
|
|
168
|
+
* providers: {
|
|
169
|
+
* github: {
|
|
170
|
+
* clientId: process.env.GITHUB_CLIENT_ID!,
|
|
171
|
+
* clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
167
172
|
* },
|
|
168
173
|
* },
|
|
169
174
|
* redirectUrl: '/dashboard',
|
|
175
|
+
* errorRedirectUrl: '/auth-error',
|
|
170
176
|
* });
|
|
171
177
|
* ```
|
|
172
178
|
*/
|
|
173
|
-
export declare function toNextJsHandler(
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
export declare function toNextJsHandler(clientOrOptions?: any | {
|
|
180
|
+
/** OAuth provider configurations */
|
|
181
|
+
providers?: Record<string, {
|
|
182
|
+
clientId: string;
|
|
183
|
+
clientSecret: string;
|
|
184
|
+
redirectUri?: string;
|
|
185
|
+
}>;
|
|
186
|
+
/** Server URL for MCP server */
|
|
187
|
+
serverUrl?: string;
|
|
188
|
+
/** API key for authentication */
|
|
189
|
+
apiKey?: string;
|
|
190
|
+
/** URL to redirect to after successful OAuth callback (default: '/') */
|
|
191
|
+
redirectUrl?: string;
|
|
192
|
+
/** URL to redirect to on OAuth error (default: '/auth-error') */
|
|
193
|
+
errorRedirectUrl?: string;
|
|
194
|
+
}, redirectOptions?: {
|
|
195
|
+
/** URL to redirect to after successful OAuth callback (default: '/') */
|
|
186
196
|
redirectUrl?: string;
|
|
187
|
-
/** URL to redirect to on OAuth error */
|
|
197
|
+
/** URL to redirect to on OAuth error (default: '/auth-error') */
|
|
188
198
|
errorRedirectUrl?: string;
|
|
189
199
|
}): {
|
|
190
200
|
POST: (req: any, context: {
|
package/dist/src/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA8CpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC;IAwR/B,2DAA2D;;IAG3D,4DAA4D;;;;;;;;IAG5D,2DAA2D;;;;;;;;IAG3D,oEAAoE;uBAlM3D,OAAO,YACN;QAAE,MAAM,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,KACl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gBAAgB,EACZ,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAC9G;IACE,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,WAMkB,GAAG,KAAG,OAAO,CAAC,QAAQ,CAAC,CAoD/C"}
|
package/dist/src/utils/env.d.ts
CHANGED
|
@@ -15,17 +15,4 @@ export declare function getEnv(key: string): string | undefined;
|
|
|
15
15
|
* @returns Environment variable value or fallback
|
|
16
16
|
*/
|
|
17
17
|
export declare function getEnvWithFallback(key: string, fallback: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Check if running in a browser environment
|
|
20
|
-
*/
|
|
21
|
-
export declare function isBrowser(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Replace the current URL without adding to history
|
|
24
|
-
* Uses SvelteKit's navigation API if available, otherwise falls back to standard History API
|
|
25
|
-
*
|
|
26
|
-
* This prevents the SvelteKit warning about using window.history.replaceState
|
|
27
|
-
*
|
|
28
|
-
* @param url - The URL to replace with (path + search params)
|
|
29
|
-
*/
|
|
30
|
-
export declare function safeReplaceState(url: string): Promise<void>;
|
|
31
18
|
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/utils/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA2BtD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExE
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/utils/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA2BtD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExE"}
|