integrate-sdk 0.3.9 → 0.3.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/index.js +77 -8
- package/dist/server.js +77 -8
- package/dist/src/client.d.ts +4 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/oauth/manager.d.ts +21 -0
- package/dist/src/oauth/manager.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
|
@@ -591,7 +591,6 @@ function base64UrlEncode(array) {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
// src/oauth/window-manager.ts
|
|
594
|
-
"use client";
|
|
595
594
|
function isBrowser() {
|
|
596
595
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
597
596
|
}
|
|
@@ -609,6 +608,7 @@ class OAuthWindowManager {
|
|
|
609
608
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
610
609
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
611
610
|
const features = [
|
|
611
|
+
`popup=yes`,
|
|
612
612
|
`width=${width}`,
|
|
613
613
|
`height=${height}`,
|
|
614
614
|
`left=${left}`,
|
|
@@ -620,9 +620,11 @@ class OAuthWindowManager {
|
|
|
620
620
|
"menubar=no",
|
|
621
621
|
"scrollbars=yes",
|
|
622
622
|
"resizable=yes",
|
|
623
|
-
"copyhistory=no"
|
|
623
|
+
"copyhistory=no",
|
|
624
|
+
"noopener=no"
|
|
624
625
|
].join(",");
|
|
625
|
-
|
|
626
|
+
const windowName = `oauth_popup_${Date.now()}`;
|
|
627
|
+
this.popupWindow = window.open(url, windowName, features);
|
|
626
628
|
if (!this.popupWindow) {
|
|
627
629
|
console.warn("Popup was blocked by the browser. Please allow popups for this site.");
|
|
628
630
|
return null;
|
|
@@ -777,8 +779,6 @@ function sendCallbackToOpener(params) {
|
|
|
777
779
|
}
|
|
778
780
|
|
|
779
781
|
// src/oauth/manager.ts
|
|
780
|
-
"use client";
|
|
781
|
-
|
|
782
782
|
class OAuthManager {
|
|
783
783
|
pendingAuths = new Map;
|
|
784
784
|
sessionToken;
|
|
@@ -793,6 +793,7 @@ class OAuthManager {
|
|
|
793
793
|
popupOptions: flowConfig?.popupOptions,
|
|
794
794
|
onAuthCallback: flowConfig?.onAuthCallback
|
|
795
795
|
};
|
|
796
|
+
this.cleanupExpiredPendingAuths();
|
|
796
797
|
}
|
|
797
798
|
async initiateFlow(provider, config) {
|
|
798
799
|
const codeVerifier = generateCodeVerifier();
|
|
@@ -808,6 +809,7 @@ class OAuthManager {
|
|
|
808
809
|
initiatedAt: Date.now()
|
|
809
810
|
};
|
|
810
811
|
this.pendingAuths.set(state, pendingAuth);
|
|
812
|
+
this.savePendingAuthToStorage(state, pendingAuth);
|
|
811
813
|
const authUrl = await this.getAuthorizationUrl(provider, config.scopes, state, codeChallenge, config.redirectUri);
|
|
812
814
|
if (this.flowConfig.mode === "popup") {
|
|
813
815
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
@@ -823,13 +825,17 @@ class OAuthManager {
|
|
|
823
825
|
}
|
|
824
826
|
}
|
|
825
827
|
async handleCallback(code, state) {
|
|
826
|
-
|
|
828
|
+
let pendingAuth = this.pendingAuths.get(state);
|
|
829
|
+
if (!pendingAuth) {
|
|
830
|
+
pendingAuth = this.loadPendingAuthFromStorage(state);
|
|
831
|
+
}
|
|
827
832
|
if (!pendingAuth) {
|
|
828
833
|
throw new Error("Invalid state parameter: no matching OAuth flow found");
|
|
829
834
|
}
|
|
830
835
|
const fiveMinutes = 5 * 60 * 1000;
|
|
831
836
|
if (Date.now() - pendingAuth.initiatedAt > fiveMinutes) {
|
|
832
837
|
this.pendingAuths.delete(state);
|
|
838
|
+
this.removePendingAuthFromStorage(state);
|
|
833
839
|
throw new Error("OAuth flow expired: please try again");
|
|
834
840
|
}
|
|
835
841
|
if (this.flowConfig.onAuthCallback) {
|
|
@@ -844,9 +850,11 @@ class OAuthManager {
|
|
|
844
850
|
this.sessionToken = response.sessionToken;
|
|
845
851
|
this.saveSessionToken(response.sessionToken);
|
|
846
852
|
this.pendingAuths.delete(state);
|
|
853
|
+
this.removePendingAuthFromStorage(state);
|
|
847
854
|
return response.sessionToken;
|
|
848
855
|
} catch (error) {
|
|
849
856
|
this.pendingAuths.delete(state);
|
|
857
|
+
this.removePendingAuthFromStorage(state);
|
|
850
858
|
throw error;
|
|
851
859
|
}
|
|
852
860
|
}
|
|
@@ -907,6 +915,69 @@ class OAuthManager {
|
|
|
907
915
|
}
|
|
908
916
|
}
|
|
909
917
|
}
|
|
918
|
+
savePendingAuthToStorage(state, pendingAuth) {
|
|
919
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
920
|
+
try {
|
|
921
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
922
|
+
window.localStorage.setItem(key, JSON.stringify(pendingAuth));
|
|
923
|
+
} catch (error) {
|
|
924
|
+
console.error("Failed to save pending auth to localStorage:", error);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
loadPendingAuthFromStorage(state) {
|
|
929
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
930
|
+
try {
|
|
931
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
932
|
+
const stored = window.localStorage.getItem(key);
|
|
933
|
+
if (stored) {
|
|
934
|
+
return JSON.parse(stored);
|
|
935
|
+
}
|
|
936
|
+
} catch (error) {
|
|
937
|
+
console.error("Failed to load pending auth from localStorage:", error);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
removePendingAuthFromStorage(state) {
|
|
943
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
944
|
+
try {
|
|
945
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
946
|
+
window.localStorage.removeItem(key);
|
|
947
|
+
} catch (error) {
|
|
948
|
+
console.error("Failed to remove pending auth from localStorage:", error);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
cleanupExpiredPendingAuths() {
|
|
953
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
954
|
+
try {
|
|
955
|
+
const prefix = "integrate_oauth_pending_";
|
|
956
|
+
const fiveMinutes = 5 * 60 * 1000;
|
|
957
|
+
const now = Date.now();
|
|
958
|
+
const keysToRemove = [];
|
|
959
|
+
for (let i = 0;i < window.localStorage.length; i++) {
|
|
960
|
+
const key = window.localStorage.key(i);
|
|
961
|
+
if (key && key.startsWith(prefix)) {
|
|
962
|
+
try {
|
|
963
|
+
const stored = window.localStorage.getItem(key);
|
|
964
|
+
if (stored) {
|
|
965
|
+
const pendingAuth = JSON.parse(stored);
|
|
966
|
+
if (now - pendingAuth.initiatedAt > fiveMinutes) {
|
|
967
|
+
keysToRemove.push(key);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
} catch (error) {
|
|
971
|
+
keysToRemove.push(key);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
976
|
+
} catch (error) {
|
|
977
|
+
console.error("Failed to cleanup expired pending auths:", error);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
910
981
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
911
982
|
const url = `${this.oauthApiBase}/authorize`;
|
|
912
983
|
const response = await fetch(url, {
|
|
@@ -957,8 +1028,6 @@ class OAuthManager {
|
|
|
957
1028
|
}
|
|
958
1029
|
|
|
959
1030
|
// src/client.ts
|
|
960
|
-
"use client";
|
|
961
|
-
|
|
962
1031
|
class SimpleEventEmitter {
|
|
963
1032
|
handlers = new Map;
|
|
964
1033
|
on(event, handler) {
|
package/dist/server.js
CHANGED
|
@@ -591,7 +591,6 @@ function base64UrlEncode(array) {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
// src/oauth/window-manager.ts
|
|
594
|
-
"use client";
|
|
595
594
|
function isBrowser() {
|
|
596
595
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
597
596
|
}
|
|
@@ -609,6 +608,7 @@ class OAuthWindowManager {
|
|
|
609
608
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
610
609
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
611
610
|
const features = [
|
|
611
|
+
`popup=yes`,
|
|
612
612
|
`width=${width}`,
|
|
613
613
|
`height=${height}`,
|
|
614
614
|
`left=${left}`,
|
|
@@ -620,9 +620,11 @@ class OAuthWindowManager {
|
|
|
620
620
|
"menubar=no",
|
|
621
621
|
"scrollbars=yes",
|
|
622
622
|
"resizable=yes",
|
|
623
|
-
"copyhistory=no"
|
|
623
|
+
"copyhistory=no",
|
|
624
|
+
"noopener=no"
|
|
624
625
|
].join(",");
|
|
625
|
-
|
|
626
|
+
const windowName = `oauth_popup_${Date.now()}`;
|
|
627
|
+
this.popupWindow = window.open(url, windowName, features);
|
|
626
628
|
if (!this.popupWindow) {
|
|
627
629
|
console.warn("Popup was blocked by the browser. Please allow popups for this site.");
|
|
628
630
|
return null;
|
|
@@ -777,8 +779,6 @@ function sendCallbackToOpener(params) {
|
|
|
777
779
|
}
|
|
778
780
|
|
|
779
781
|
// src/oauth/manager.ts
|
|
780
|
-
"use client";
|
|
781
|
-
|
|
782
782
|
class OAuthManager {
|
|
783
783
|
pendingAuths = new Map;
|
|
784
784
|
sessionToken;
|
|
@@ -793,6 +793,7 @@ class OAuthManager {
|
|
|
793
793
|
popupOptions: flowConfig?.popupOptions,
|
|
794
794
|
onAuthCallback: flowConfig?.onAuthCallback
|
|
795
795
|
};
|
|
796
|
+
this.cleanupExpiredPendingAuths();
|
|
796
797
|
}
|
|
797
798
|
async initiateFlow(provider, config) {
|
|
798
799
|
const codeVerifier = generateCodeVerifier();
|
|
@@ -808,6 +809,7 @@ class OAuthManager {
|
|
|
808
809
|
initiatedAt: Date.now()
|
|
809
810
|
};
|
|
810
811
|
this.pendingAuths.set(state, pendingAuth);
|
|
812
|
+
this.savePendingAuthToStorage(state, pendingAuth);
|
|
811
813
|
const authUrl = await this.getAuthorizationUrl(provider, config.scopes, state, codeChallenge, config.redirectUri);
|
|
812
814
|
if (this.flowConfig.mode === "popup") {
|
|
813
815
|
this.windowManager.openPopup(authUrl, this.flowConfig.popupOptions);
|
|
@@ -823,13 +825,17 @@ class OAuthManager {
|
|
|
823
825
|
}
|
|
824
826
|
}
|
|
825
827
|
async handleCallback(code, state) {
|
|
826
|
-
|
|
828
|
+
let pendingAuth = this.pendingAuths.get(state);
|
|
829
|
+
if (!pendingAuth) {
|
|
830
|
+
pendingAuth = this.loadPendingAuthFromStorage(state);
|
|
831
|
+
}
|
|
827
832
|
if (!pendingAuth) {
|
|
828
833
|
throw new Error("Invalid state parameter: no matching OAuth flow found");
|
|
829
834
|
}
|
|
830
835
|
const fiveMinutes = 5 * 60 * 1000;
|
|
831
836
|
if (Date.now() - pendingAuth.initiatedAt > fiveMinutes) {
|
|
832
837
|
this.pendingAuths.delete(state);
|
|
838
|
+
this.removePendingAuthFromStorage(state);
|
|
833
839
|
throw new Error("OAuth flow expired: please try again");
|
|
834
840
|
}
|
|
835
841
|
if (this.flowConfig.onAuthCallback) {
|
|
@@ -844,9 +850,11 @@ class OAuthManager {
|
|
|
844
850
|
this.sessionToken = response.sessionToken;
|
|
845
851
|
this.saveSessionToken(response.sessionToken);
|
|
846
852
|
this.pendingAuths.delete(state);
|
|
853
|
+
this.removePendingAuthFromStorage(state);
|
|
847
854
|
return response.sessionToken;
|
|
848
855
|
} catch (error) {
|
|
849
856
|
this.pendingAuths.delete(state);
|
|
857
|
+
this.removePendingAuthFromStorage(state);
|
|
850
858
|
throw error;
|
|
851
859
|
}
|
|
852
860
|
}
|
|
@@ -907,6 +915,69 @@ class OAuthManager {
|
|
|
907
915
|
}
|
|
908
916
|
}
|
|
909
917
|
}
|
|
918
|
+
savePendingAuthToStorage(state, pendingAuth) {
|
|
919
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
920
|
+
try {
|
|
921
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
922
|
+
window.localStorage.setItem(key, JSON.stringify(pendingAuth));
|
|
923
|
+
} catch (error) {
|
|
924
|
+
console.error("Failed to save pending auth to localStorage:", error);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
loadPendingAuthFromStorage(state) {
|
|
929
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
930
|
+
try {
|
|
931
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
932
|
+
const stored = window.localStorage.getItem(key);
|
|
933
|
+
if (stored) {
|
|
934
|
+
return JSON.parse(stored);
|
|
935
|
+
}
|
|
936
|
+
} catch (error) {
|
|
937
|
+
console.error("Failed to load pending auth from localStorage:", error);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
removePendingAuthFromStorage(state) {
|
|
943
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
944
|
+
try {
|
|
945
|
+
const key = `integrate_oauth_pending_${state}`;
|
|
946
|
+
window.localStorage.removeItem(key);
|
|
947
|
+
} catch (error) {
|
|
948
|
+
console.error("Failed to remove pending auth from localStorage:", error);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
cleanupExpiredPendingAuths() {
|
|
953
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
954
|
+
try {
|
|
955
|
+
const prefix = "integrate_oauth_pending_";
|
|
956
|
+
const fiveMinutes = 5 * 60 * 1000;
|
|
957
|
+
const now = Date.now();
|
|
958
|
+
const keysToRemove = [];
|
|
959
|
+
for (let i = 0;i < window.localStorage.length; i++) {
|
|
960
|
+
const key = window.localStorage.key(i);
|
|
961
|
+
if (key && key.startsWith(prefix)) {
|
|
962
|
+
try {
|
|
963
|
+
const stored = window.localStorage.getItem(key);
|
|
964
|
+
if (stored) {
|
|
965
|
+
const pendingAuth = JSON.parse(stored);
|
|
966
|
+
if (now - pendingAuth.initiatedAt > fiveMinutes) {
|
|
967
|
+
keysToRemove.push(key);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
} catch (error) {
|
|
971
|
+
keysToRemove.push(key);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
keysToRemove.forEach((key) => window.localStorage.removeItem(key));
|
|
976
|
+
} catch (error) {
|
|
977
|
+
console.error("Failed to cleanup expired pending auths:", error);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
910
981
|
async getAuthorizationUrl(provider, scopes, state, codeChallenge, redirectUri) {
|
|
911
982
|
const url = `${this.oauthApiBase}/authorize`;
|
|
912
983
|
const response = await fetch(url, {
|
|
@@ -957,8 +1028,6 @@ class OAuthManager {
|
|
|
957
1028
|
}
|
|
958
1029
|
|
|
959
1030
|
// src/client.ts
|
|
960
|
-
"use client";
|
|
961
|
-
|
|
962
1031
|
class SimpleEventEmitter {
|
|
963
1032
|
handlers = new Map;
|
|
964
1033
|
on(event, handler) {
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client
|
|
3
|
+
* Main client class that orchestrates transport, protocol, and plugins
|
|
4
|
+
*/
|
|
1
5
|
import type { MCPTool, MCPToolCallResponse } from "./protocol/messages.js";
|
|
2
6
|
import type { MCPPlugin, OAuthConfig } from "./plugins/types.js";
|
|
3
7
|
import type { MCPClientConfig } from "./config/types.js";
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,OAAO,EAEP,mB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;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,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"}
|
|
@@ -79,6 +79,27 @@ export declare class OAuthManager {
|
|
|
79
79
|
* Save session token to sessionStorage
|
|
80
80
|
*/
|
|
81
81
|
private saveSessionToken;
|
|
82
|
+
/**
|
|
83
|
+
* Save pending auth to localStorage (for redirect flows)
|
|
84
|
+
* Uses localStorage instead of sessionStorage because OAuth may open in a new tab,
|
|
85
|
+
* and sessionStorage is isolated per tab. localStorage is shared across tabs.
|
|
86
|
+
* Keyed by state parameter for security and retrieval.
|
|
87
|
+
*/
|
|
88
|
+
private savePendingAuthToStorage;
|
|
89
|
+
/**
|
|
90
|
+
* Load pending auth from localStorage (after redirect)
|
|
91
|
+
* Returns undefined if not found or invalid
|
|
92
|
+
*/
|
|
93
|
+
private loadPendingAuthFromStorage;
|
|
94
|
+
/**
|
|
95
|
+
* Remove pending auth from localStorage
|
|
96
|
+
*/
|
|
97
|
+
private removePendingAuthFromStorage;
|
|
98
|
+
/**
|
|
99
|
+
* Clean up expired pending auth entries from localStorage
|
|
100
|
+
* Removes any entries older than 5 minutes
|
|
101
|
+
*/
|
|
102
|
+
private cleanupExpiredPendingAuths;
|
|
82
103
|
/**
|
|
83
104
|
* Request authorization URL from user's API route
|
|
84
105
|
* 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":"
|
|
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;;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window-manager.d.ts","sourceRoot":"","sources":["../../../src/oauth/window-manager.ts"],"names":[],"mappings":"
|
|
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"}
|