integrate-sdk 0.3.10 → 0.3.12
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/index.js +115 -4
- package/dist/server.js +115 -4
- package/dist/src/client.d.ts +47 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/oauth/manager.d.ts +26 -0
- package/dist/src/oauth/manager.d.ts.map +1 -1
- package/dist/src/oauth/types.d.ts +13 -1
- package/dist/src/oauth/types.d.ts.map +1 -1
- package/dist/src/oauth/window-manager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -608,6 +608,7 @@ class OAuthWindowManager {
|
|
|
608
608
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
609
609
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
610
610
|
const features = [
|
|
611
|
+
`popup=yes`,
|
|
611
612
|
`width=${width}`,
|
|
612
613
|
`height=${height}`,
|
|
613
614
|
`left=${left}`,
|
|
@@ -619,9 +620,11 @@ class OAuthWindowManager {
|
|
|
619
620
|
"menubar=no",
|
|
620
621
|
"scrollbars=yes",
|
|
621
622
|
"resizable=yes",
|
|
622
|
-
"copyhistory=no"
|
|
623
|
+
"copyhistory=no",
|
|
624
|
+
"noopener=no"
|
|
623
625
|
].join(",");
|
|
624
|
-
|
|
626
|
+
const windowName = `oauth_popup_${Date.now()}`;
|
|
627
|
+
this.popupWindow = window.open(url, windowName, features);
|
|
625
628
|
if (!this.popupWindow) {
|
|
626
629
|
console.warn("Popup was blocked by the browser. Please allow popups for this site.");
|
|
627
630
|
return null;
|
|
@@ -790,6 +793,7 @@ class OAuthManager {
|
|
|
790
793
|
popupOptions: flowConfig?.popupOptions,
|
|
791
794
|
onAuthCallback: flowConfig?.onAuthCallback
|
|
792
795
|
};
|
|
796
|
+
this.cleanupExpiredPendingAuths();
|
|
793
797
|
}
|
|
794
798
|
async initiateFlow(provider, config) {
|
|
795
799
|
const codeVerifier = generateCodeVerifier();
|
|
@@ -805,6 +809,7 @@ class OAuthManager {
|
|
|
805
809
|
initiatedAt: Date.now()
|
|
806
810
|
};
|
|
807
811
|
this.pendingAuths.set(state, pendingAuth);
|
|
812
|
+
this.savePendingAuthToStorage(state, pendingAuth);
|
|
808
813
|
const authUrl = await this.getAuthorizationUrl(provider, config.scopes, state, codeChallenge, config.redirectUri);
|
|
809
814
|
if (this.flowConfig.mode === "popup") {
|
|
810
815
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
@@ -820,13 +825,17 @@ class OAuthManager {
|
|
|
820
825
|
}
|
|
821
826
|
}
|
|
822
827
|
async handleCallback(code, state) {
|
|
823
|
-
|
|
828
|
+
let pendingAuth = this.pendingAuths.get(state);
|
|
829
|
+
if (!pendingAuth) {
|
|
830
|
+
pendingAuth = this.loadPendingAuthFromStorage(state);
|
|
831
|
+
}
|
|
824
832
|
if (!pendingAuth) {
|
|
825
833
|
throw new Error("Invalid state parameter: no matching OAuth flow found");
|
|
826
834
|
}
|
|
827
835
|
const fiveMinutes = 5 * 60 * 1000;
|
|
828
836
|
if (Date.now() - pendingAuth.initiatedAt > fiveMinutes) {
|
|
829
837
|
this.pendingAuths.delete(state);
|
|
838
|
+
this.removePendingAuthFromStorage(state);
|
|
830
839
|
throw new Error("OAuth flow expired: please try again");
|
|
831
840
|
}
|
|
832
841
|
if (this.flowConfig.onAuthCallback) {
|
|
@@ -841,9 +850,11 @@ class OAuthManager {
|
|
|
841
850
|
this.sessionToken = response.sessionToken;
|
|
842
851
|
this.saveSessionToken(response.sessionToken);
|
|
843
852
|
this.pendingAuths.delete(state);
|
|
853
|
+
this.removePendingAuthFromStorage(state);
|
|
844
854
|
return response.sessionToken;
|
|
845
855
|
} catch (error) {
|
|
846
856
|
this.pendingAuths.delete(state);
|
|
857
|
+
this.removePendingAuthFromStorage(state);
|
|
847
858
|
throw error;
|
|
848
859
|
}
|
|
849
860
|
}
|
|
@@ -895,6 +906,24 @@ class OAuthManager {
|
|
|
895
906
|
}
|
|
896
907
|
}
|
|
897
908
|
}
|
|
909
|
+
clearAllPendingAuths() {
|
|
910
|
+
this.pendingAuths.clear();
|
|
911
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
912
|
+
try {
|
|
913
|
+
const prefix = "integrate_oauth_pending_";
|
|
914
|
+
const keysToRemove = [];
|
|
915
|
+
for (let i = 0;i < window.localStorage.length; i++) {
|
|
916
|
+
const key = window.localStorage.key(i);
|
|
917
|
+
if (key && key.startsWith(prefix)) {
|
|
918
|
+
keysToRemove.push(key);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
922
|
+
} catch (error) {
|
|
923
|
+
console.error("Failed to clear pending auths from localStorage:", error);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
898
927
|
saveSessionToken(token) {
|
|
899
928
|
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
900
929
|
try {
|
|
@@ -904,6 +933,69 @@ class OAuthManager {
|
|
|
904
933
|
}
|
|
905
934
|
}
|
|
906
935
|
}
|
|
936
|
+
savePendingAuthToStorage(state, pendingAuth) {
|
|
937
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
938
|
+
try {
|
|
939
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
940
|
+
window.localStorage.setItem(key, JSON.stringify(pendingAuth));
|
|
941
|
+
} catch (error) {
|
|
942
|
+
console.error("Failed to save pending auth to localStorage:", error);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
loadPendingAuthFromStorage(state) {
|
|
947
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
948
|
+
try {
|
|
949
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
950
|
+
const stored = window.localStorage.getItem(key);
|
|
951
|
+
if (stored) {
|
|
952
|
+
return JSON.parse(stored);
|
|
953
|
+
}
|
|
954
|
+
} catch (error) {
|
|
955
|
+
console.error("Failed to load pending auth from localStorage:", error);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
removePendingAuthFromStorage(state) {
|
|
961
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
962
|
+
try {
|
|
963
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
964
|
+
window.localStorage.removeItem(key);
|
|
965
|
+
} catch (error) {
|
|
966
|
+
console.error("Failed to remove pending auth from localStorage:", error);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
cleanupExpiredPendingAuths() {
|
|
971
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
972
|
+
try {
|
|
973
|
+
const prefix = "integrate_oauth_pending_";
|
|
974
|
+
const fiveMinutes = 5 * 60 * 1000;
|
|
975
|
+
const now = Date.now();
|
|
976
|
+
const keysToRemove = [];
|
|
977
|
+
for (let i = 0;i < window.localStorage.length; i++) {
|
|
978
|
+
const key = window.localStorage.key(i);
|
|
979
|
+
if (key && key.startsWith(prefix)) {
|
|
980
|
+
try {
|
|
981
|
+
const stored = window.localStorage.getItem(key);
|
|
982
|
+
if (stored) {
|
|
983
|
+
const pendingAuth = JSON.parse(stored);
|
|
984
|
+
if (now - pendingAuth.initiatedAt > fiveMinutes) {
|
|
985
|
+
keysToRemove.push(key);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
} catch (error) {
|
|
989
|
+
keysToRemove.push(key);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
994
|
+
} catch (error) {
|
|
995
|
+
console.error("Failed to cleanup expired pending auths:", error);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
907
999
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
908
1000
|
const url = `${this.oauthApiBase}/authorize`;
|
|
909
1001
|
const response = await fetch(url, {
|
|
@@ -1286,6 +1378,25 @@ class MCPClient {
|
|
|
1286
1378
|
}
|
|
1287
1379
|
this.oauthManager.clearSessionToken();
|
|
1288
1380
|
}
|
|
1381
|
+
async disconnectProvider(provider) {
|
|
1382
|
+
const plugin = this.plugins.find((p) => p.oauth?.provider === provider);
|
|
1383
|
+
if (!plugin?.oauth) {
|
|
1384
|
+
throw new Error(`No OAuth configuration found for provider: ${provider}`);
|
|
1385
|
+
}
|
|
1386
|
+
this.authState.set(provider, { authenticated: false });
|
|
1387
|
+
this.eventEmitter.emit("auth:disconnect", { provider });
|
|
1388
|
+
}
|
|
1389
|
+
async logout() {
|
|
1390
|
+
this.clearSessionToken();
|
|
1391
|
+
this.oauthManager.clearAllPendingAuths();
|
|
1392
|
+
this.authState.clear();
|
|
1393
|
+
for (const plugin of this.plugins) {
|
|
1394
|
+
if (plugin.oauth) {
|
|
1395
|
+
this.authState.set(plugin.oauth.provider, { authenticated: false });
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
this.eventEmitter.emit("auth:logout", {});
|
|
1399
|
+
}
|
|
1289
1400
|
async disconnect() {
|
|
1290
1401
|
for (const plugin of this.plugins) {
|
|
1291
1402
|
if (plugin.onDisconnect) {
|
|
@@ -1483,7 +1594,7 @@ function createMCPClient(config) {
|
|
|
1483
1594
|
}
|
|
1484
1595
|
}
|
|
1485
1596
|
function processOAuthCallbackFromHash(client) {
|
|
1486
|
-
if (typeof window === "undefined") {
|
|
1597
|
+
if (typeof window === "undefined" || !window.location) {
|
|
1487
1598
|
return;
|
|
1488
1599
|
}
|
|
1489
1600
|
try {
|
package/dist/server.js
CHANGED
|
@@ -608,6 +608,7 @@ class OAuthWindowManager {
|
|
|
608
608
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
609
609
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
610
610
|
const features = [
|
|
611
|
+
`popup=yes`,
|
|
611
612
|
`width=${width}`,
|
|
612
613
|
`height=${height}`,
|
|
613
614
|
`left=${left}`,
|
|
@@ -619,9 +620,11 @@ class OAuthWindowManager {
|
|
|
619
620
|
"menubar=no",
|
|
620
621
|
"scrollbars=yes",
|
|
621
622
|
"resizable=yes",
|
|
622
|
-
"copyhistory=no"
|
|
623
|
+
"copyhistory=no",
|
|
624
|
+
"noopener=no"
|
|
623
625
|
].join(",");
|
|
624
|
-
|
|
626
|
+
const windowName = `oauth_popup_${Date.now()}`;
|
|
627
|
+
this.popupWindow = window.open(url, windowName, features);
|
|
625
628
|
if (!this.popupWindow) {
|
|
626
629
|
console.warn("Popup was blocked by the browser. Please allow popups for this site.");
|
|
627
630
|
return null;
|
|
@@ -790,6 +793,7 @@ class OAuthManager {
|
|
|
790
793
|
popupOptions: flowConfig?.popupOptions,
|
|
791
794
|
onAuthCallback: flowConfig?.onAuthCallback
|
|
792
795
|
};
|
|
796
|
+
this.cleanupExpiredPendingAuths();
|
|
793
797
|
}
|
|
794
798
|
async initiateFlow(provider, config) {
|
|
795
799
|
const codeVerifier = generateCodeVerifier();
|
|
@@ -805,6 +809,7 @@ class OAuthManager {
|
|
|
805
809
|
initiatedAt: Date.now()
|
|
806
810
|
};
|
|
807
811
|
this.pendingAuths.set(state, pendingAuth);
|
|
812
|
+
this.savePendingAuthToStorage(state, pendingAuth);
|
|
808
813
|
const authUrl = await this.getAuthorizationUrl(provider, config.scopes, state, codeChallenge, config.redirectUri);
|
|
809
814
|
if (this.flowConfig.mode === "popup") {
|
|
810
815
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
@@ -820,13 +825,17 @@ class OAuthManager {
|
|
|
820
825
|
}
|
|
821
826
|
}
|
|
822
827
|
async handleCallback(code, state) {
|
|
823
|
-
|
|
828
|
+
let pendingAuth = this.pendingAuths.get(state);
|
|
829
|
+
if (!pendingAuth) {
|
|
830
|
+
pendingAuth = this.loadPendingAuthFromStorage(state);
|
|
831
|
+
}
|
|
824
832
|
if (!pendingAuth) {
|
|
825
833
|
throw new Error("Invalid state parameter: no matching OAuth flow found");
|
|
826
834
|
}
|
|
827
835
|
const fiveMinutes = 5 * 60 * 1000;
|
|
828
836
|
if (Date.now() - pendingAuth.initiatedAt > fiveMinutes) {
|
|
829
837
|
this.pendingAuths.delete(state);
|
|
838
|
+
this.removePendingAuthFromStorage(state);
|
|
830
839
|
throw new Error("OAuth flow expired: please try again");
|
|
831
840
|
}
|
|
832
841
|
if (this.flowConfig.onAuthCallback) {
|
|
@@ -841,9 +850,11 @@ class OAuthManager {
|
|
|
841
850
|
this.sessionToken = response.sessionToken;
|
|
842
851
|
this.saveSessionToken(response.sessionToken);
|
|
843
852
|
this.pendingAuths.delete(state);
|
|
853
|
+
this.removePendingAuthFromStorage(state);
|
|
844
854
|
return response.sessionToken;
|
|
845
855
|
} catch (error) {
|
|
846
856
|
this.pendingAuths.delete(state);
|
|
857
|
+
this.removePendingAuthFromStorage(state);
|
|
847
858
|
throw error;
|
|
848
859
|
}
|
|
849
860
|
}
|
|
@@ -895,6 +906,24 @@ class OAuthManager {
|
|
|
895
906
|
}
|
|
896
907
|
}
|
|
897
908
|
}
|
|
909
|
+
clearAllPendingAuths() {
|
|
910
|
+
this.pendingAuths.clear();
|
|
911
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
912
|
+
try {
|
|
913
|
+
const prefix = "integrate_oauth_pending_";
|
|
914
|
+
const keysToRemove = [];
|
|
915
|
+
for (let i = 0;i < window.localStorage.length; i++) {
|
|
916
|
+
const key = window.localStorage.key(i);
|
|
917
|
+
if (key && key.startsWith(prefix)) {
|
|
918
|
+
keysToRemove.push(key);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
922
|
+
} catch (error) {
|
|
923
|
+
console.error("Failed to clear pending auths from localStorage:", error);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
898
927
|
saveSessionToken(token) {
|
|
899
928
|
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
900
929
|
try {
|
|
@@ -904,6 +933,69 @@ class OAuthManager {
|
|
|
904
933
|
}
|
|
905
934
|
}
|
|
906
935
|
}
|
|
936
|
+
savePendingAuthToStorage(state, pendingAuth) {
|
|
937
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
938
|
+
try {
|
|
939
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
940
|
+
window.localStorage.setItem(key, JSON.stringify(pendingAuth));
|
|
941
|
+
} catch (error) {
|
|
942
|
+
console.error("Failed to save pending auth to localStorage:", error);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
loadPendingAuthFromStorage(state) {
|
|
947
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
948
|
+
try {
|
|
949
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
950
|
+
const stored = window.localStorage.getItem(key);
|
|
951
|
+
if (stored) {
|
|
952
|
+
return JSON.parse(stored);
|
|
953
|
+
}
|
|
954
|
+
} catch (error) {
|
|
955
|
+
console.error("Failed to load pending auth from localStorage:", error);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
removePendingAuthFromStorage(state) {
|
|
961
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
962
|
+
try {
|
|
963
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
964
|
+
window.localStorage.removeItem(key);
|
|
965
|
+
} catch (error) {
|
|
966
|
+
console.error("Failed to remove pending auth from localStorage:", error);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
cleanupExpiredPendingAuths() {
|
|
971
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
972
|
+
try {
|
|
973
|
+
const prefix = "integrate_oauth_pending_";
|
|
974
|
+
const fiveMinutes = 5 * 60 * 1000;
|
|
975
|
+
const now = Date.now();
|
|
976
|
+
const keysToRemove = [];
|
|
977
|
+
for (let i = 0;i < window.localStorage.length; i++) {
|
|
978
|
+
const key = window.localStorage.key(i);
|
|
979
|
+
if (key && key.startsWith(prefix)) {
|
|
980
|
+
try {
|
|
981
|
+
const stored = window.localStorage.getItem(key);
|
|
982
|
+
if (stored) {
|
|
983
|
+
const pendingAuth = JSON.parse(stored);
|
|
984
|
+
if (now - pendingAuth.initiatedAt > fiveMinutes) {
|
|
985
|
+
keysToRemove.push(key);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
} catch (error) {
|
|
989
|
+
keysToRemove.push(key);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
994
|
+
} catch (error) {
|
|
995
|
+
console.error("Failed to cleanup expired pending auths:", error);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
907
999
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
908
1000
|
const url = `${this.oauthApiBase}/authorize`;
|
|
909
1001
|
const response = await fetch(url, {
|
|
@@ -1286,6 +1378,25 @@ class MCPClient {
|
|
|
1286
1378
|
}
|
|
1287
1379
|
this.oauthManager.clearSessionToken();
|
|
1288
1380
|
}
|
|
1381
|
+
async disconnectProvider(provider) {
|
|
1382
|
+
const plugin = this.plugins.find((p) => p.oauth?.provider === provider);
|
|
1383
|
+
if (!plugin?.oauth) {
|
|
1384
|
+
throw new Error(`No OAuth configuration found for provider: ${provider}`);
|
|
1385
|
+
}
|
|
1386
|
+
this.authState.set(provider, { authenticated: false });
|
|
1387
|
+
this.eventEmitter.emit("auth:disconnect", { provider });
|
|
1388
|
+
}
|
|
1389
|
+
async logout() {
|
|
1390
|
+
this.clearSessionToken();
|
|
1391
|
+
this.oauthManager.clearAllPendingAuths();
|
|
1392
|
+
this.authState.clear();
|
|
1393
|
+
for (const plugin of this.plugins) {
|
|
1394
|
+
if (plugin.oauth) {
|
|
1395
|
+
this.authState.set(plugin.oauth.provider, { authenticated: false });
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
this.eventEmitter.emit("auth:logout", {});
|
|
1399
|
+
}
|
|
1289
1400
|
async disconnect() {
|
|
1290
1401
|
for (const plugin of this.plugins) {
|
|
1291
1402
|
if (plugin.onDisconnect) {
|
|
@@ -1483,7 +1594,7 @@ function createMCPClient(config) {
|
|
|
1483
1594
|
}
|
|
1484
1595
|
}
|
|
1485
1596
|
function processOAuthCallbackFromHash(client) {
|
|
1486
|
-
if (typeof window === "undefined") {
|
|
1597
|
+
if (typeof window === "undefined" || !window.location) {
|
|
1487
1598
|
return;
|
|
1488
1599
|
}
|
|
1489
1600
|
try {
|
package/dist/src/client.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type AuthenticationError } from "./errors.js";
|
|
|
9
9
|
import type { GitHubPluginClient } from "./plugins/github-client.js";
|
|
10
10
|
import type { GmailPluginClient } from "./plugins/gmail-client.js";
|
|
11
11
|
import type { ServerPluginClient } from "./plugins/server-client.js";
|
|
12
|
-
import type { AuthStatus, OAuthCallbackParams, OAuthEventHandler, AuthStartedEvent, AuthCompleteEvent, AuthErrorEvent } from "./oauth/types.js";
|
|
12
|
+
import type { AuthStatus, OAuthCallbackParams, OAuthEventHandler, AuthStartedEvent, AuthCompleteEvent, AuthErrorEvent, AuthLogoutEvent, AuthDisconnectEvent } from "./oauth/types.js";
|
|
13
13
|
/**
|
|
14
14
|
* Tool invocation options
|
|
15
15
|
*/
|
|
@@ -160,11 +160,21 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
160
160
|
* client.on('auth:complete', ({ provider, sessionToken }) => {
|
|
161
161
|
* console.log(`${provider} authorized!`);
|
|
162
162
|
* });
|
|
163
|
+
*
|
|
164
|
+
* client.on('auth:disconnect', ({ provider }) => {
|
|
165
|
+
* console.log(`${provider} disconnected`);
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* client.on('auth:logout', () => {
|
|
169
|
+
* console.log('User logged out from all services');
|
|
170
|
+
* });
|
|
163
171
|
* ```
|
|
164
172
|
*/
|
|
165
173
|
on(event: 'auth:started', handler: OAuthEventHandler<AuthStartedEvent>): void;
|
|
166
174
|
on(event: 'auth:complete', handler: OAuthEventHandler<AuthCompleteEvent>): void;
|
|
167
175
|
on(event: 'auth:error', handler: OAuthEventHandler<AuthErrorEvent>): void;
|
|
176
|
+
on(event: 'auth:disconnect', handler: OAuthEventHandler<AuthDisconnectEvent>): void;
|
|
177
|
+
on(event: 'auth:logout', handler: OAuthEventHandler<AuthLogoutEvent>): void;
|
|
168
178
|
/**
|
|
169
179
|
* Remove event listener for OAuth events
|
|
170
180
|
*
|
|
@@ -174,6 +184,8 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
174
184
|
off(event: 'auth:started', handler: OAuthEventHandler<AuthStartedEvent>): void;
|
|
175
185
|
off(event: 'auth:complete', handler: OAuthEventHandler<AuthCompleteEvent>): void;
|
|
176
186
|
off(event: 'auth:error', handler: OAuthEventHandler<AuthErrorEvent>): void;
|
|
187
|
+
off(event: 'auth:disconnect', handler: OAuthEventHandler<AuthDisconnectEvent>): void;
|
|
188
|
+
off(event: 'auth:logout', handler: OAuthEventHandler<AuthLogoutEvent>): void;
|
|
177
189
|
/**
|
|
178
190
|
* Save session token to sessionStorage
|
|
179
191
|
*
|
|
@@ -190,6 +202,40 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
190
202
|
* Clear session token from sessionStorage
|
|
191
203
|
*/
|
|
192
204
|
clearSessionToken(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Disconnect a specific OAuth provider
|
|
207
|
+
* Removes authorization for a single provider while keeping others connected
|
|
208
|
+
*
|
|
209
|
+
* @param provider - Provider name to disconnect (e.g., 'github', 'gmail')
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* // Disconnect only GitHub, keep Gmail connected
|
|
214
|
+
* await client.disconnectProvider('github');
|
|
215
|
+
*
|
|
216
|
+
* // Check if still authorized
|
|
217
|
+
* const isAuthorized = await client.isAuthorized('github'); // false
|
|
218
|
+
*
|
|
219
|
+
* // Re-authorize if needed
|
|
220
|
+
* await client.authorize('github');
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
disconnectProvider(provider: string): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Logout and terminate all OAuth connections
|
|
226
|
+
* Clears all session tokens, pending OAuth state, and resets authentication state for all providers
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* // Logout from all providers
|
|
231
|
+
* await client.logout();
|
|
232
|
+
*
|
|
233
|
+
* // User needs to authorize again for all providers
|
|
234
|
+
* await client.authorize('github');
|
|
235
|
+
* await client.authorize('gmail');
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
logout(): Promise<void>;
|
|
193
239
|
/**
|
|
194
240
|
* Disconnect from the server
|
|
195
241
|
*/
|
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,EAIpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B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AE,MAAM,GAAG,IAAI;IAKpC;;;OAGG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CA2BzD;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;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"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { ToolInvocationOptions } from "./client.js";
|
|
|
7
7
|
export { OAuthManager } from "./oauth/manager.js";
|
|
8
8
|
export { OAuthWindowManager, sendCallbackToOpener } from "./oauth/window-manager.js";
|
|
9
9
|
export { generateCodeVerifier, generateCodeChallenge, generateState } from "./oauth/pkce.js";
|
|
10
|
-
export type { OAuthFlowConfig, PopupOptions, AuthStatus, PendingAuth, AuthorizationUrlResponse, OAuthCallbackResponse, OAuthCallbackParams, OAuthEventType, OAuthEventHandler, AuthStartedEvent, AuthCompleteEvent, AuthErrorEvent, } from "./oauth/types.js";
|
|
10
|
+
export type { OAuthFlowConfig, PopupOptions, AuthStatus, PendingAuth, AuthorizationUrlResponse, OAuthCallbackResponse, OAuthCallbackParams, OAuthEventType, OAuthEventHandler, AuthStartedEvent, AuthCompleteEvent, AuthErrorEvent, AuthDisconnectEvent, AuthLogoutEvent, } from "./oauth/types.js";
|
|
11
11
|
export { OAuthHandler } from "./adapters/base-handler.js";
|
|
12
12
|
export type { OAuthHandlerConfig, AuthorizeRequest, AuthorizeResponse, CallbackRequest, CallbackResponse, StatusResponse, } from "./adapters/base-handler.js";
|
|
13
13
|
export { createNextOAuthHandler } from "./adapters/nextjs.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EACV,eAAe,EACf,YAAY,EACZ,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EACV,eAAe,EACf,YAAY,EACZ,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,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AE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,YAAY,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,EACP,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EACV,cAAc,EACd,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC"}
|
|
@@ -75,10 +75,36 @@ export declare class OAuthManager {
|
|
|
75
75
|
* Clear session token
|
|
76
76
|
*/
|
|
77
77
|
clearSessionToken(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all pending OAuth flows
|
|
80
|
+
* Removes all pending auths from memory and localStorage
|
|
81
|
+
*/
|
|
82
|
+
clearAllPendingAuths(): void;
|
|
78
83
|
/**
|
|
79
84
|
* Save session token to sessionStorage
|
|
80
85
|
*/
|
|
81
86
|
private saveSessionToken;
|
|
87
|
+
/**
|
|
88
|
+
* Save pending auth to localStorage (for redirect flows)
|
|
89
|
+
* Uses localStorage instead of sessionStorage because OAuth may open in a new tab,
|
|
90
|
+
* and sessionStorage is isolated per tab. localStorage is shared across tabs.
|
|
91
|
+
* Keyed by state parameter for security and retrieval.
|
|
92
|
+
*/
|
|
93
|
+
private savePendingAuthToStorage;
|
|
94
|
+
/**
|
|
95
|
+
* Load pending auth from localStorage (after redirect)
|
|
96
|
+
* Returns undefined if not found or invalid
|
|
97
|
+
*/
|
|
98
|
+
private loadPendingAuthFromStorage;
|
|
99
|
+
/**
|
|
100
|
+
* Remove pending auth from localStorage
|
|
101
|
+
*/
|
|
102
|
+
private removePendingAuthFromStorage;
|
|
103
|
+
/**
|
|
104
|
+
* Clean up expired pending auth entries from localStorage
|
|
105
|
+
* Removes any entries older than 5 minutes
|
|
106
|
+
*/
|
|
107
|
+
private cleanupExpiredPendingAuths;
|
|
82
108
|
/**
|
|
83
109
|
* Request authorization URL from user's API route
|
|
84
110
|
* The API route will add OAuth secrets and forward to MCP server
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EAEf,UAAU,EAGX,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,YAAY,CAAS;gBAG3B,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EAEf,UAAU,EAGX,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,YAAY,CAAS;gBAG3B,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAcvC;;;;;;;;;;;;;;;;OAgBG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CxE;;;;;;;;;;;;;OAaG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyDlE;;;;;;;;;;;;;OAaG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAoC5D;;OAEG;IACH,eAAe,IAAI,MAAM,GAAG,SAAS;IAIrC;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKpC;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAWzB;;;OAGG;IACH,oBAAoB,IAAI,IAAI;IAwB5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAWhC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAelC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAWpC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAoClC;;;OAGG;YACW,mBAAmB;IAiCjC;;;OAGG;YACW,oBAAoB;IA8BlC;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -106,10 +106,22 @@ export interface AuthErrorEvent {
|
|
|
106
106
|
/** Error that occurred */
|
|
107
107
|
error: Error;
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Event payload for auth:logout event
|
|
111
|
+
*/
|
|
112
|
+
export interface AuthLogoutEvent {
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Event payload for auth:disconnect event (provider-specific)
|
|
116
|
+
*/
|
|
117
|
+
export interface AuthDisconnectEvent {
|
|
118
|
+
/** Provider that was disconnected */
|
|
119
|
+
provider: string;
|
|
120
|
+
}
|
|
109
121
|
/**
|
|
110
122
|
* All possible OAuth event types
|
|
111
123
|
*/
|
|
112
|
-
export type OAuthEventType = 'auth:started' | 'auth:complete' | 'auth:error';
|
|
124
|
+
export type OAuthEventType = 'auth:started' | 'auth:complete' | 'auth:error' | 'auth:logout' | 'auth:disconnect';
|
|
113
125
|
/**
|
|
114
126
|
* Event handler function type
|
|
115
127
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/oauth/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yCAAyC;IACzC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,oDAAoD;IACpD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,sDAAsD;IACtD,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,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AED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;CAE/B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,eAAe,GAAG,YAAY,GAAG,aAAa,GAAG,iBAAiB,CAAC;AAEjH;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC"}
|
|
@@ -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;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;
|
|
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;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