integrate-sdk 0.8.26 → 0.8.27
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/auto-routes.js +5 -42
- package/dist/adapters/base-handler.d.ts.map +1 -1
- package/dist/adapters/index.js +5 -42
- package/dist/adapters/nextjs.js +5 -42
- package/dist/adapters/node.js +5 -42
- package/dist/adapters/svelte-kit.js +5 -42
- package/dist/adapters/tanstack-start.js +5 -42
- package/dist/index.js +5 -42
- package/dist/oauth.js +5 -42
- package/dist/server.js +5 -42
- package/dist/src/adapters/base-handler.d.ts.map +1 -1
- package/dist/src/oauth/manager.d.ts +8 -4
- package/dist/src/oauth/manager.d.ts.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -669,13 +669,10 @@ class OAuthManager {
|
|
|
669
669
|
};
|
|
670
670
|
this.pendingAuths.set(state, pendingAuth);
|
|
671
671
|
this.savePendingAuthToStorage(state, pendingAuth);
|
|
672
|
-
console.log("[OAuth] Requesting authorization URL, flow mode:", this.flowConfig.mode);
|
|
673
672
|
const authUrl = await this.getAuthorizationUrl(provider, state, codeChallenge, config.redirectUri, codeVerifier);
|
|
674
|
-
console.log("[OAuth] Received authorization URL, length:", authUrl?.length);
|
|
675
673
|
if (!authUrl || authUrl.trim() === "") {
|
|
676
674
|
throw new Error("Received empty authorization URL from server");
|
|
677
675
|
}
|
|
678
|
-
console.log("[OAuth] Opening authorization URL, mode:", this.flowConfig.mode);
|
|
679
676
|
if (this.flowConfig.mode === "popup") {
|
|
680
677
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
681
678
|
try {
|
|
@@ -686,7 +683,6 @@ class OAuthManager {
|
|
|
686
683
|
throw error;
|
|
687
684
|
}
|
|
688
685
|
} else {
|
|
689
|
-
console.log("[OAuth] Redirecting to authorization URL:", authUrl.substring(0, 100) + (authUrl.length > 100 ? "..." : ""));
|
|
690
686
|
this.windowManager.openRedirect(authUrl);
|
|
691
687
|
}
|
|
692
688
|
}
|
|
@@ -881,7 +877,6 @@ class OAuthManager {
|
|
|
881
877
|
return;
|
|
882
878
|
}
|
|
883
879
|
if (this.skipLocalStorage) {
|
|
884
|
-
console.log(`[OAuth] Token for ${provider} stored in memory only (skipLocalStorage: true). Configure setProviderToken/getProviderToken callbacks for persistence.`);
|
|
885
880
|
return;
|
|
886
881
|
}
|
|
887
882
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
@@ -958,9 +953,6 @@ class OAuthManager {
|
|
|
958
953
|
}
|
|
959
954
|
}
|
|
960
955
|
savePendingAuthToStorage(state, pendingAuth) {
|
|
961
|
-
if (this.skipLocalStorage) {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
956
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
965
957
|
try {
|
|
966
958
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -971,9 +963,6 @@ class OAuthManager {
|
|
|
971
963
|
}
|
|
972
964
|
}
|
|
973
965
|
loadPendingAuthFromStorage(state) {
|
|
974
|
-
if (this.skipLocalStorage) {
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
966
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
978
967
|
try {
|
|
979
968
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -988,9 +977,6 @@ class OAuthManager {
|
|
|
988
977
|
return;
|
|
989
978
|
}
|
|
990
979
|
removePendingAuthFromStorage(state) {
|
|
991
|
-
if (this.skipLocalStorage) {
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
980
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
995
981
|
try {
|
|
996
982
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -1001,9 +987,6 @@ class OAuthManager {
|
|
|
1001
987
|
}
|
|
1002
988
|
}
|
|
1003
989
|
cleanupExpiredPendingAuths() {
|
|
1004
|
-
if (this.skipLocalStorage) {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
990
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
1008
991
|
try {
|
|
1009
992
|
const prefix = "integrate_oauth_pending_";
|
|
@@ -1058,15 +1041,11 @@ class OAuthManager {
|
|
|
1058
1041
|
}
|
|
1059
1042
|
const data = await response.json();
|
|
1060
1043
|
if (!data.authorizationUrl) {
|
|
1061
|
-
console.error("[OAuth] Authorization URL is missing from response:", data);
|
|
1062
1044
|
throw new Error("Authorization URL is missing from server response");
|
|
1063
1045
|
}
|
|
1064
1046
|
if (typeof data.authorizationUrl !== "string" || data.authorizationUrl.trim() === "") {
|
|
1065
|
-
console.error("[OAuth] Invalid authorization URL received:", data.authorizationUrl);
|
|
1066
1047
|
throw new Error("Invalid authorization URL received from server");
|
|
1067
1048
|
}
|
|
1068
|
-
const urlPreview = data.authorizationUrl.length > 100 ? data.authorizationUrl.substring(0, 100) + "..." : data.authorizationUrl;
|
|
1069
|
-
console.log("[OAuth] Received authorization URL from API route:", urlPreview);
|
|
1070
1049
|
return data.authorizationUrl;
|
|
1071
1050
|
}
|
|
1072
1051
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
@@ -6708,7 +6687,6 @@ function createMCPServer(config) {
|
|
|
6708
6687
|
}
|
|
6709
6688
|
}
|
|
6710
6689
|
if (!targetOrigin) {
|
|
6711
|
-
console.warn("[OAuth] Could not determine frontend origin for redirect. Using request origin as fallback.");
|
|
6712
6690
|
targetOrigin = new URL(webRequest.url).origin;
|
|
6713
6691
|
}
|
|
6714
6692
|
const targetUrl = new URL(returnUrl, targetOrigin);
|
|
@@ -7252,7 +7230,6 @@ class OAuthHandler {
|
|
|
7252
7230
|
} else {
|
|
7253
7231
|
authorizeRequest = request;
|
|
7254
7232
|
}
|
|
7255
|
-
console.log("[handleAuthorize] Received request for provider:", authorizeRequest.provider, "has codeVerifier:", !!authorizeRequest.codeVerifier, "has frontendOrigin:", !!authorizeRequest.frontendOrigin);
|
|
7256
7233
|
const providerConfig = this.config.providers[authorizeRequest.provider];
|
|
7257
7234
|
if (!providerConfig) {
|
|
7258
7235
|
throw new Error(`Provider ${authorizeRequest.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
@@ -7293,22 +7270,14 @@ class OAuthHandler {
|
|
|
7293
7270
|
const data = await response.json();
|
|
7294
7271
|
const result = data;
|
|
7295
7272
|
if (!result.authorizationUrl) {
|
|
7296
|
-
console.error("[OAuth] MCP server did not return authorizationUrl:", data);
|
|
7297
7273
|
throw new Error("MCP server failed to return authorization URL");
|
|
7298
7274
|
}
|
|
7299
|
-
const urlPreview = result.authorizationUrl.length > 100 ? result.authorizationUrl.substring(0, 100) + "..." : result.authorizationUrl;
|
|
7300
|
-
console.log("[OAuth] Generated authorization URL:", urlPreview);
|
|
7301
7275
|
if (authorizeRequest.codeVerifier) {
|
|
7302
7276
|
try {
|
|
7303
7277
|
const { storeCodeVerifier: storeCodeVerifier2 } = await Promise.resolve().then(() => (init_server(), exports_server));
|
|
7304
7278
|
storeCodeVerifier2(authorizeRequest.state, authorizeRequest.codeVerifier, authorizeRequest.provider, authorizeRequest.frontendOrigin);
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
console.warn("[OAuth] Failed to store codeVerifier:", error);
|
|
7308
|
-
}
|
|
7309
|
-
} else {
|
|
7310
|
-
console.log("[OAuth] No codeVerifier provided in authorize request");
|
|
7311
|
-
}
|
|
7279
|
+
} catch (error) {}
|
|
7280
|
+
} else {}
|
|
7312
7281
|
if (webRequest) {
|
|
7313
7282
|
try {
|
|
7314
7283
|
const { detectSessionContext: detectSessionContext2 } = await Promise.resolve().then(() => exports_session_detector);
|
|
@@ -7325,9 +7294,7 @@ class OAuthHandler {
|
|
|
7325
7294
|
const cookieValue = await createContextCookie2(context, authorizeRequest.provider, secret);
|
|
7326
7295
|
result.setCookie = getSetCookieHeader2(cookieValue);
|
|
7327
7296
|
}
|
|
7328
|
-
} catch (error) {
|
|
7329
|
-
console.warn("[OAuth] Failed to capture user context:", error);
|
|
7330
|
-
}
|
|
7297
|
+
} catch (error) {}
|
|
7331
7298
|
}
|
|
7332
7299
|
return result;
|
|
7333
7300
|
}
|
|
@@ -7361,9 +7328,7 @@ class OAuthHandler {
|
|
|
7361
7328
|
context = contextData.context;
|
|
7362
7329
|
}
|
|
7363
7330
|
}
|
|
7364
|
-
} catch (error) {
|
|
7365
|
-
console.warn("[OAuth] Failed to restore user context:", error);
|
|
7366
|
-
}
|
|
7331
|
+
} catch (error) {}
|
|
7367
7332
|
}
|
|
7368
7333
|
const url = new URL("/oauth/callback", this.serverUrl);
|
|
7369
7334
|
const response = await fetch(url.toString(), {
|
|
@@ -7398,9 +7363,7 @@ class OAuthHandler {
|
|
|
7398
7363
|
scopes: result.scopes
|
|
7399
7364
|
};
|
|
7400
7365
|
await this.config.setProviderToken(callbackRequest.provider, tokenData, context);
|
|
7401
|
-
} catch (error) {
|
|
7402
|
-
console.error("[OAuth] Failed to save provider token:", error);
|
|
7403
|
-
}
|
|
7366
|
+
} catch (error) {}
|
|
7404
7367
|
}
|
|
7405
7368
|
if (webRequest) {
|
|
7406
7369
|
const { getClearCookieHeader: getClearCookieHeader2 } = await Promise.resolve().then(() => exports_context_cookie);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../../src/adapters/base-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAO3D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,iDAAiD;QACjD,QAAQ,EAAE,MAAM,CAAC;QACjB,qDAAqD;QACrD,YAAY,EAAE,MAAM,CAAC;QACrB,qCAAqC;QACrC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8CAA8C;QAC9C,MAAM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AAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;gBAEb,MAAM,EAAE,kBAAkB;IAW9C;;OAEG;IACH,OAAO,CAAC,UAAU;IAalB;;;OAGG;IACH,oBAAoB,IAAI,OAAO;IAI/B;;;;;;;;;;OAUG;IACG,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4HtF;;;;;;;;;;OAUG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0GnF;;;;;;;;;OASG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BlF;;;;;;;;;;;OAWG;IACG,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2D1H;;;;;;;;;;;;;OAaG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAkDrG"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -669,13 +669,10 @@ class OAuthManager {
|
|
|
669
669
|
};
|
|
670
670
|
this.pendingAuths.set(state, pendingAuth);
|
|
671
671
|
this.savePendingAuthToStorage(state, pendingAuth);
|
|
672
|
-
console.log("[OAuth] Requesting authorization URL, flow mode:", this.flowConfig.mode);
|
|
673
672
|
const authUrl = await this.getAuthorizationUrl(provider, state, codeChallenge, config.redirectUri, codeVerifier);
|
|
674
|
-
console.log("[OAuth] Received authorization URL, length:", authUrl?.length);
|
|
675
673
|
if (!authUrl || authUrl.trim() === "") {
|
|
676
674
|
throw new Error("Received empty authorization URL from server");
|
|
677
675
|
}
|
|
678
|
-
console.log("[OAuth] Opening authorization URL, mode:", this.flowConfig.mode);
|
|
679
676
|
if (this.flowConfig.mode === "popup") {
|
|
680
677
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
681
678
|
try {
|
|
@@ -686,7 +683,6 @@ class OAuthManager {
|
|
|
686
683
|
throw error;
|
|
687
684
|
}
|
|
688
685
|
} else {
|
|
689
|
-
console.log("[OAuth] Redirecting to authorization URL:", authUrl.substring(0, 100) + (authUrl.length > 100 ? "..." : ""));
|
|
690
686
|
this.windowManager.openRedirect(authUrl);
|
|
691
687
|
}
|
|
692
688
|
}
|
|
@@ -881,7 +877,6 @@ class OAuthManager {
|
|
|
881
877
|
return;
|
|
882
878
|
}
|
|
883
879
|
if (this.skipLocalStorage) {
|
|
884
|
-
console.log(`[OAuth] Token for ${provider} stored in memory only (skipLocalStorage: true). Configure setProviderToken/getProviderToken callbacks for persistence.`);
|
|
885
880
|
return;
|
|
886
881
|
}
|
|
887
882
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
@@ -958,9 +953,6 @@ class OAuthManager {
|
|
|
958
953
|
}
|
|
959
954
|
}
|
|
960
955
|
savePendingAuthToStorage(state, pendingAuth) {
|
|
961
|
-
if (this.skipLocalStorage) {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
956
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
965
957
|
try {
|
|
966
958
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -971,9 +963,6 @@ class OAuthManager {
|
|
|
971
963
|
}
|
|
972
964
|
}
|
|
973
965
|
loadPendingAuthFromStorage(state) {
|
|
974
|
-
if (this.skipLocalStorage) {
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
966
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
978
967
|
try {
|
|
979
968
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -988,9 +977,6 @@ class OAuthManager {
|
|
|
988
977
|
return;
|
|
989
978
|
}
|
|
990
979
|
removePendingAuthFromStorage(state) {
|
|
991
|
-
if (this.skipLocalStorage) {
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
980
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
995
981
|
try {
|
|
996
982
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -1001,9 +987,6 @@ class OAuthManager {
|
|
|
1001
987
|
}
|
|
1002
988
|
}
|
|
1003
989
|
cleanupExpiredPendingAuths() {
|
|
1004
|
-
if (this.skipLocalStorage) {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
990
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
1008
991
|
try {
|
|
1009
992
|
const prefix = "integrate_oauth_pending_";
|
|
@@ -1058,15 +1041,11 @@ class OAuthManager {
|
|
|
1058
1041
|
}
|
|
1059
1042
|
const data = await response.json();
|
|
1060
1043
|
if (!data.authorizationUrl) {
|
|
1061
|
-
console.error("[OAuth] Authorization URL is missing from response:", data);
|
|
1062
1044
|
throw new Error("Authorization URL is missing from server response");
|
|
1063
1045
|
}
|
|
1064
1046
|
if (typeof data.authorizationUrl !== "string" || data.authorizationUrl.trim() === "") {
|
|
1065
|
-
console.error("[OAuth] Invalid authorization URL received:", data.authorizationUrl);
|
|
1066
1047
|
throw new Error("Invalid authorization URL received from server");
|
|
1067
1048
|
}
|
|
1068
|
-
const urlPreview = data.authorizationUrl.length > 100 ? data.authorizationUrl.substring(0, 100) + "..." : data.authorizationUrl;
|
|
1069
|
-
console.log("[OAuth] Received authorization URL from API route:", urlPreview);
|
|
1070
1049
|
return data.authorizationUrl;
|
|
1071
1050
|
}
|
|
1072
1051
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
@@ -6708,7 +6687,6 @@ function createMCPServer(config) {
|
|
|
6708
6687
|
}
|
|
6709
6688
|
}
|
|
6710
6689
|
if (!targetOrigin) {
|
|
6711
|
-
console.warn("[OAuth] Could not determine frontend origin for redirect. Using request origin as fallback.");
|
|
6712
6690
|
targetOrigin = new URL(webRequest.url).origin;
|
|
6713
6691
|
}
|
|
6714
6692
|
const targetUrl = new URL(returnUrl, targetOrigin);
|
|
@@ -7252,7 +7230,6 @@ class OAuthHandler {
|
|
|
7252
7230
|
} else {
|
|
7253
7231
|
authorizeRequest = request;
|
|
7254
7232
|
}
|
|
7255
|
-
console.log("[handleAuthorize] Received request for provider:", authorizeRequest.provider, "has codeVerifier:", !!authorizeRequest.codeVerifier, "has frontendOrigin:", !!authorizeRequest.frontendOrigin);
|
|
7256
7233
|
const providerConfig = this.config.providers[authorizeRequest.provider];
|
|
7257
7234
|
if (!providerConfig) {
|
|
7258
7235
|
throw new Error(`Provider ${authorizeRequest.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
@@ -7293,22 +7270,14 @@ class OAuthHandler {
|
|
|
7293
7270
|
const data = await response.json();
|
|
7294
7271
|
const result = data;
|
|
7295
7272
|
if (!result.authorizationUrl) {
|
|
7296
|
-
console.error("[OAuth] MCP server did not return authorizationUrl:", data);
|
|
7297
7273
|
throw new Error("MCP server failed to return authorization URL");
|
|
7298
7274
|
}
|
|
7299
|
-
const urlPreview = result.authorizationUrl.length > 100 ? result.authorizationUrl.substring(0, 100) + "..." : result.authorizationUrl;
|
|
7300
|
-
console.log("[OAuth] Generated authorization URL:", urlPreview);
|
|
7301
7275
|
if (authorizeRequest.codeVerifier) {
|
|
7302
7276
|
try {
|
|
7303
7277
|
const { storeCodeVerifier: storeCodeVerifier2 } = await Promise.resolve().then(() => (init_server(), exports_server));
|
|
7304
7278
|
storeCodeVerifier2(authorizeRequest.state, authorizeRequest.codeVerifier, authorizeRequest.provider, authorizeRequest.frontendOrigin);
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
console.warn("[OAuth] Failed to store codeVerifier:", error);
|
|
7308
|
-
}
|
|
7309
|
-
} else {
|
|
7310
|
-
console.log("[OAuth] No codeVerifier provided in authorize request");
|
|
7311
|
-
}
|
|
7279
|
+
} catch (error) {}
|
|
7280
|
+
} else {}
|
|
7312
7281
|
if (webRequest) {
|
|
7313
7282
|
try {
|
|
7314
7283
|
const { detectSessionContext: detectSessionContext2 } = await Promise.resolve().then(() => exports_session_detector);
|
|
@@ -7325,9 +7294,7 @@ class OAuthHandler {
|
|
|
7325
7294
|
const cookieValue = await createContextCookie2(context, authorizeRequest.provider, secret);
|
|
7326
7295
|
result.setCookie = getSetCookieHeader2(cookieValue);
|
|
7327
7296
|
}
|
|
7328
|
-
} catch (error) {
|
|
7329
|
-
console.warn("[OAuth] Failed to capture user context:", error);
|
|
7330
|
-
}
|
|
7297
|
+
} catch (error) {}
|
|
7331
7298
|
}
|
|
7332
7299
|
return result;
|
|
7333
7300
|
}
|
|
@@ -7361,9 +7328,7 @@ class OAuthHandler {
|
|
|
7361
7328
|
context = contextData.context;
|
|
7362
7329
|
}
|
|
7363
7330
|
}
|
|
7364
|
-
} catch (error) {
|
|
7365
|
-
console.warn("[OAuth] Failed to restore user context:", error);
|
|
7366
|
-
}
|
|
7331
|
+
} catch (error) {}
|
|
7367
7332
|
}
|
|
7368
7333
|
const url = new URL("/oauth/callback", this.serverUrl);
|
|
7369
7334
|
const response = await fetch(url.toString(), {
|
|
@@ -7398,9 +7363,7 @@ class OAuthHandler {
|
|
|
7398
7363
|
scopes: result.scopes
|
|
7399
7364
|
};
|
|
7400
7365
|
await this.config.setProviderToken(callbackRequest.provider, tokenData, context);
|
|
7401
|
-
} catch (error) {
|
|
7402
|
-
console.error("[OAuth] Failed to save provider token:", error);
|
|
7403
|
-
}
|
|
7366
|
+
} catch (error) {}
|
|
7404
7367
|
}
|
|
7405
7368
|
if (webRequest) {
|
|
7406
7369
|
const { getClearCookieHeader: getClearCookieHeader2 } = await Promise.resolve().then(() => exports_context_cookie);
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -669,13 +669,10 @@ class OAuthManager {
|
|
|
669
669
|
};
|
|
670
670
|
this.pendingAuths.set(state, pendingAuth);
|
|
671
671
|
this.savePendingAuthToStorage(state, pendingAuth);
|
|
672
|
-
console.log("[OAuth] Requesting authorization URL, flow mode:", this.flowConfig.mode);
|
|
673
672
|
const authUrl = await this.getAuthorizationUrl(provider, state, codeChallenge, config.redirectUri, codeVerifier);
|
|
674
|
-
console.log("[OAuth] Received authorization URL, length:", authUrl?.length);
|
|
675
673
|
if (!authUrl || authUrl.trim() === "") {
|
|
676
674
|
throw new Error("Received empty authorization URL from server");
|
|
677
675
|
}
|
|
678
|
-
console.log("[OAuth] Opening authorization URL, mode:", this.flowConfig.mode);
|
|
679
676
|
if (this.flowConfig.mode === "popup") {
|
|
680
677
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
681
678
|
try {
|
|
@@ -686,7 +683,6 @@ class OAuthManager {
|
|
|
686
683
|
throw error;
|
|
687
684
|
}
|
|
688
685
|
} else {
|
|
689
|
-
console.log("[OAuth] Redirecting to authorization URL:", authUrl.substring(0, 100) + (authUrl.length > 100 ? "..." : ""));
|
|
690
686
|
this.windowManager.openRedirect(authUrl);
|
|
691
687
|
}
|
|
692
688
|
}
|
|
@@ -881,7 +877,6 @@ class OAuthManager {
|
|
|
881
877
|
return;
|
|
882
878
|
}
|
|
883
879
|
if (this.skipLocalStorage) {
|
|
884
|
-
console.log(`[OAuth] Token for ${provider} stored in memory only (skipLocalStorage: true). Configure setProviderToken/getProviderToken callbacks for persistence.`);
|
|
885
880
|
return;
|
|
886
881
|
}
|
|
887
882
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
@@ -958,9 +953,6 @@ class OAuthManager {
|
|
|
958
953
|
}
|
|
959
954
|
}
|
|
960
955
|
savePendingAuthToStorage(state, pendingAuth) {
|
|
961
|
-
if (this.skipLocalStorage) {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
956
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
965
957
|
try {
|
|
966
958
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -971,9 +963,6 @@ class OAuthManager {
|
|
|
971
963
|
}
|
|
972
964
|
}
|
|
973
965
|
loadPendingAuthFromStorage(state) {
|
|
974
|
-
if (this.skipLocalStorage) {
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
966
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
978
967
|
try {
|
|
979
968
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -988,9 +977,6 @@ class OAuthManager {
|
|
|
988
977
|
return;
|
|
989
978
|
}
|
|
990
979
|
removePendingAuthFromStorage(state) {
|
|
991
|
-
if (this.skipLocalStorage) {
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
980
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
995
981
|
try {
|
|
996
982
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -1001,9 +987,6 @@ class OAuthManager {
|
|
|
1001
987
|
}
|
|
1002
988
|
}
|
|
1003
989
|
cleanupExpiredPendingAuths() {
|
|
1004
|
-
if (this.skipLocalStorage) {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
990
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
1008
991
|
try {
|
|
1009
992
|
const prefix = "integrate_oauth_pending_";
|
|
@@ -1058,15 +1041,11 @@ class OAuthManager {
|
|
|
1058
1041
|
}
|
|
1059
1042
|
const data = await response.json();
|
|
1060
1043
|
if (!data.authorizationUrl) {
|
|
1061
|
-
console.error("[OAuth] Authorization URL is missing from response:", data);
|
|
1062
1044
|
throw new Error("Authorization URL is missing from server response");
|
|
1063
1045
|
}
|
|
1064
1046
|
if (typeof data.authorizationUrl !== "string" || data.authorizationUrl.trim() === "") {
|
|
1065
|
-
console.error("[OAuth] Invalid authorization URL received:", data.authorizationUrl);
|
|
1066
1047
|
throw new Error("Invalid authorization URL received from server");
|
|
1067
1048
|
}
|
|
1068
|
-
const urlPreview = data.authorizationUrl.length > 100 ? data.authorizationUrl.substring(0, 100) + "..." : data.authorizationUrl;
|
|
1069
|
-
console.log("[OAuth] Received authorization URL from API route:", urlPreview);
|
|
1070
1049
|
return data.authorizationUrl;
|
|
1071
1050
|
}
|
|
1072
1051
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
@@ -6708,7 +6687,6 @@ function createMCPServer(config) {
|
|
|
6708
6687
|
}
|
|
6709
6688
|
}
|
|
6710
6689
|
if (!targetOrigin) {
|
|
6711
|
-
console.warn("[OAuth] Could not determine frontend origin for redirect. Using request origin as fallback.");
|
|
6712
6690
|
targetOrigin = new URL(webRequest.url).origin;
|
|
6713
6691
|
}
|
|
6714
6692
|
const targetUrl = new URL(returnUrl, targetOrigin);
|
|
@@ -7252,7 +7230,6 @@ class OAuthHandler {
|
|
|
7252
7230
|
} else {
|
|
7253
7231
|
authorizeRequest = request;
|
|
7254
7232
|
}
|
|
7255
|
-
console.log("[handleAuthorize] Received request for provider:", authorizeRequest.provider, "has codeVerifier:", !!authorizeRequest.codeVerifier, "has frontendOrigin:", !!authorizeRequest.frontendOrigin);
|
|
7256
7233
|
const providerConfig = this.config.providers[authorizeRequest.provider];
|
|
7257
7234
|
if (!providerConfig) {
|
|
7258
7235
|
throw new Error(`Provider ${authorizeRequest.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
@@ -7293,22 +7270,14 @@ class OAuthHandler {
|
|
|
7293
7270
|
const data = await response.json();
|
|
7294
7271
|
const result = data;
|
|
7295
7272
|
if (!result.authorizationUrl) {
|
|
7296
|
-
console.error("[OAuth] MCP server did not return authorizationUrl:", data);
|
|
7297
7273
|
throw new Error("MCP server failed to return authorization URL");
|
|
7298
7274
|
}
|
|
7299
|
-
const urlPreview = result.authorizationUrl.length > 100 ? result.authorizationUrl.substring(0, 100) + "..." : result.authorizationUrl;
|
|
7300
|
-
console.log("[OAuth] Generated authorization URL:", urlPreview);
|
|
7301
7275
|
if (authorizeRequest.codeVerifier) {
|
|
7302
7276
|
try {
|
|
7303
7277
|
const { storeCodeVerifier: storeCodeVerifier2 } = await Promise.resolve().then(() => (init_server(), exports_server));
|
|
7304
7278
|
storeCodeVerifier2(authorizeRequest.state, authorizeRequest.codeVerifier, authorizeRequest.provider, authorizeRequest.frontendOrigin);
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
console.warn("[OAuth] Failed to store codeVerifier:", error);
|
|
7308
|
-
}
|
|
7309
|
-
} else {
|
|
7310
|
-
console.log("[OAuth] No codeVerifier provided in authorize request");
|
|
7311
|
-
}
|
|
7279
|
+
} catch (error) {}
|
|
7280
|
+
} else {}
|
|
7312
7281
|
if (webRequest) {
|
|
7313
7282
|
try {
|
|
7314
7283
|
const { detectSessionContext: detectSessionContext2 } = await Promise.resolve().then(() => exports_session_detector);
|
|
@@ -7325,9 +7294,7 @@ class OAuthHandler {
|
|
|
7325
7294
|
const cookieValue = await createContextCookie2(context, authorizeRequest.provider, secret);
|
|
7326
7295
|
result.setCookie = getSetCookieHeader2(cookieValue);
|
|
7327
7296
|
}
|
|
7328
|
-
} catch (error) {
|
|
7329
|
-
console.warn("[OAuth] Failed to capture user context:", error);
|
|
7330
|
-
}
|
|
7297
|
+
} catch (error) {}
|
|
7331
7298
|
}
|
|
7332
7299
|
return result;
|
|
7333
7300
|
}
|
|
@@ -7361,9 +7328,7 @@ class OAuthHandler {
|
|
|
7361
7328
|
context = contextData.context;
|
|
7362
7329
|
}
|
|
7363
7330
|
}
|
|
7364
|
-
} catch (error) {
|
|
7365
|
-
console.warn("[OAuth] Failed to restore user context:", error);
|
|
7366
|
-
}
|
|
7331
|
+
} catch (error) {}
|
|
7367
7332
|
}
|
|
7368
7333
|
const url = new URL("/oauth/callback", this.serverUrl);
|
|
7369
7334
|
const response = await fetch(url.toString(), {
|
|
@@ -7398,9 +7363,7 @@ class OAuthHandler {
|
|
|
7398
7363
|
scopes: result.scopes
|
|
7399
7364
|
};
|
|
7400
7365
|
await this.config.setProviderToken(callbackRequest.provider, tokenData, context);
|
|
7401
|
-
} catch (error) {
|
|
7402
|
-
console.error("[OAuth] Failed to save provider token:", error);
|
|
7403
|
-
}
|
|
7366
|
+
} catch (error) {}
|
|
7404
7367
|
}
|
|
7405
7368
|
if (webRequest) {
|
|
7406
7369
|
const { getClearCookieHeader: getClearCookieHeader2 } = await Promise.resolve().then(() => exports_context_cookie);
|
package/dist/adapters/node.js
CHANGED
|
@@ -669,13 +669,10 @@ class OAuthManager {
|
|
|
669
669
|
};
|
|
670
670
|
this.pendingAuths.set(state, pendingAuth);
|
|
671
671
|
this.savePendingAuthToStorage(state, pendingAuth);
|
|
672
|
-
console.log("[OAuth] Requesting authorization URL, flow mode:", this.flowConfig.mode);
|
|
673
672
|
const authUrl = await this.getAuthorizationUrl(provider, state, codeChallenge, config.redirectUri, codeVerifier);
|
|
674
|
-
console.log("[OAuth] Received authorization URL, length:", authUrl?.length);
|
|
675
673
|
if (!authUrl || authUrl.trim() === "") {
|
|
676
674
|
throw new Error("Received empty authorization URL from server");
|
|
677
675
|
}
|
|
678
|
-
console.log("[OAuth] Opening authorization URL, mode:", this.flowConfig.mode);
|
|
679
676
|
if (this.flowConfig.mode === "popup") {
|
|
680
677
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
681
678
|
try {
|
|
@@ -686,7 +683,6 @@ class OAuthManager {
|
|
|
686
683
|
throw error;
|
|
687
684
|
}
|
|
688
685
|
} else {
|
|
689
|
-
console.log("[OAuth] Redirecting to authorization URL:", authUrl.substring(0, 100) + (authUrl.length > 100 ? "..." : ""));
|
|
690
686
|
this.windowManager.openRedirect(authUrl);
|
|
691
687
|
}
|
|
692
688
|
}
|
|
@@ -881,7 +877,6 @@ class OAuthManager {
|
|
|
881
877
|
return;
|
|
882
878
|
}
|
|
883
879
|
if (this.skipLocalStorage) {
|
|
884
|
-
console.log(`[OAuth] Token for ${provider} stored in memory only (skipLocalStorage: true). Configure setProviderToken/getProviderToken callbacks for persistence.`);
|
|
885
880
|
return;
|
|
886
881
|
}
|
|
887
882
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
@@ -958,9 +953,6 @@ class OAuthManager {
|
|
|
958
953
|
}
|
|
959
954
|
}
|
|
960
955
|
savePendingAuthToStorage(state, pendingAuth) {
|
|
961
|
-
if (this.skipLocalStorage) {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
956
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
965
957
|
try {
|
|
966
958
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -971,9 +963,6 @@ class OAuthManager {
|
|
|
971
963
|
}
|
|
972
964
|
}
|
|
973
965
|
loadPendingAuthFromStorage(state) {
|
|
974
|
-
if (this.skipLocalStorage) {
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
966
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
978
967
|
try {
|
|
979
968
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -988,9 +977,6 @@ class OAuthManager {
|
|
|
988
977
|
return;
|
|
989
978
|
}
|
|
990
979
|
removePendingAuthFromStorage(state) {
|
|
991
|
-
if (this.skipLocalStorage) {
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
980
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
995
981
|
try {
|
|
996
982
|
const key = `integrate_oauth_pending_${state}`;
|
|
@@ -1001,9 +987,6 @@ class OAuthManager {
|
|
|
1001
987
|
}
|
|
1002
988
|
}
|
|
1003
989
|
cleanupExpiredPendingAuths() {
|
|
1004
|
-
if (this.skipLocalStorage) {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
990
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
1008
991
|
try {
|
|
1009
992
|
const prefix = "integrate_oauth_pending_";
|
|
@@ -1058,15 +1041,11 @@ class OAuthManager {
|
|
|
1058
1041
|
}
|
|
1059
1042
|
const data = await response.json();
|
|
1060
1043
|
if (!data.authorizationUrl) {
|
|
1061
|
-
console.error("[OAuth] Authorization URL is missing from response:", data);
|
|
1062
1044
|
throw new Error("Authorization URL is missing from server response");
|
|
1063
1045
|
}
|
|
1064
1046
|
if (typeof data.authorizationUrl !== "string" || data.authorizationUrl.trim() === "") {
|
|
1065
|
-
console.error("[OAuth] Invalid authorization URL received:", data.authorizationUrl);
|
|
1066
1047
|
throw new Error("Invalid authorization URL received from server");
|
|
1067
1048
|
}
|
|
1068
|
-
const urlPreview = data.authorizationUrl.length > 100 ? data.authorizationUrl.substring(0, 100) + "..." : data.authorizationUrl;
|
|
1069
|
-
console.log("[OAuth] Received authorization URL from API route:", urlPreview);
|
|
1070
1049
|
return data.authorizationUrl;
|
|
1071
1050
|
}
|
|
1072
1051
|
async exchangeCodeForToken(provider, code, codeVerifier, state) {
|
|
@@ -6708,7 +6687,6 @@ function createMCPServer(config) {
|
|
|
6708
6687
|
}
|
|
6709
6688
|
}
|
|
6710
6689
|
if (!targetOrigin) {
|
|
6711
|
-
console.warn("[OAuth] Could not determine frontend origin for redirect. Using request origin as fallback.");
|
|
6712
6690
|
targetOrigin = new URL(webRequest.url).origin;
|
|
6713
6691
|
}
|
|
6714
6692
|
const targetUrl = new URL(returnUrl, targetOrigin);
|
|
@@ -7252,7 +7230,6 @@ class OAuthHandler {
|
|
|
7252
7230
|
} else {
|
|
7253
7231
|
authorizeRequest = request;
|
|
7254
7232
|
}
|
|
7255
|
-
console.log("[handleAuthorize] Received request for provider:", authorizeRequest.provider, "has codeVerifier:", !!authorizeRequest.codeVerifier, "has frontendOrigin:", !!authorizeRequest.frontendOrigin);
|
|
7256
7233
|
const providerConfig = this.config.providers[authorizeRequest.provider];
|
|
7257
7234
|
if (!providerConfig) {
|
|
7258
7235
|
throw new Error(`Provider ${authorizeRequest.provider} not configured. Add OAuth credentials to your API route configuration.`);
|
|
@@ -7293,22 +7270,14 @@ class OAuthHandler {
|
|
|
7293
7270
|
const data = await response.json();
|
|
7294
7271
|
const result = data;
|
|
7295
7272
|
if (!result.authorizationUrl) {
|
|
7296
|
-
console.error("[OAuth] MCP server did not return authorizationUrl:", data);
|
|
7297
7273
|
throw new Error("MCP server failed to return authorization URL");
|
|
7298
7274
|
}
|
|
7299
|
-
const urlPreview = result.authorizationUrl.length > 100 ? result.authorizationUrl.substring(0, 100) + "..." : result.authorizationUrl;
|
|
7300
|
-
console.log("[OAuth] Generated authorization URL:", urlPreview);
|
|
7301
7275
|
if (authorizeRequest.codeVerifier) {
|
|
7302
7276
|
try {
|
|
7303
7277
|
const { storeCodeVerifier: storeCodeVerifier2 } = await Promise.resolve().then(() => (init_server(), exports_server));
|
|
7304
7278
|
storeCodeVerifier2(authorizeRequest.state, authorizeRequest.codeVerifier, authorizeRequest.provider, authorizeRequest.frontendOrigin);
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
console.warn("[OAuth] Failed to store codeVerifier:", error);
|
|
7308
|
-
}
|
|
7309
|
-
} else {
|
|
7310
|
-
console.log("[OAuth] No codeVerifier provided in authorize request");
|
|
7311
|
-
}
|
|
7279
|
+
} catch (error) {}
|
|
7280
|
+
} else {}
|
|
7312
7281
|
if (webRequest) {
|
|
7313
7282
|
try {
|
|
7314
7283
|
const { detectSessionContext: detectSessionContext2 } = await Promise.resolve().then(() => exports_session_detector);
|
|
@@ -7325,9 +7294,7 @@ class OAuthHandler {
|
|
|
7325
7294
|
const cookieValue = await createContextCookie2(context, authorizeRequest.provider, secret);
|
|
7326
7295
|
result.setCookie = getSetCookieHeader2(cookieValue);
|
|
7327
7296
|
}
|
|
7328
|
-
} catch (error) {
|
|
7329
|
-
console.warn("[OAuth] Failed to capture user context:", error);
|
|
7330
|
-
}
|
|
7297
|
+
} catch (error) {}
|
|
7331
7298
|
}
|
|
7332
7299
|
return result;
|
|
7333
7300
|
}
|
|
@@ -7361,9 +7328,7 @@ class OAuthHandler {
|
|
|
7361
7328
|
context = contextData.context;
|
|
7362
7329
|
}
|
|
7363
7330
|
}
|
|
7364
|
-
} catch (error) {
|
|
7365
|
-
console.warn("[OAuth] Failed to restore user context:", error);
|
|
7366
|
-
}
|
|
7331
|
+
} catch (error) {}
|
|
7367
7332
|
}
|
|
7368
7333
|
const url = new URL("/oauth/callback", this.serverUrl);
|
|
7369
7334
|
const response = await fetch(url.toString(), {
|
|
@@ -7398,9 +7363,7 @@ class OAuthHandler {
|
|
|
7398
7363
|
scopes: result.scopes
|
|
7399
7364
|
};
|
|
7400
7365
|
await this.config.setProviderToken(callbackRequest.provider, tokenData, context);
|
|
7401
|
-
} catch (error) {
|
|
7402
|
-
console.error("[OAuth] Failed to save provider token:", error);
|
|
7403
|
-
}
|
|
7366
|
+
} catch (error) {}
|
|
7404
7367
|
}
|
|
7405
7368
|
if (webRequest) {
|
|
7406
7369
|
const { getClearCookieHeader: getClearCookieHeader2 } = await Promise.resolve().then(() => exports_context_cookie);
|