integrate-sdk 0.3.2 → 0.3.6

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 CHANGED
@@ -1,4 +1,21 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
6
+ var __toCommonJS = (from) => {
7
+ var entry = __moduleCache.get(from), desc;
8
+ if (entry)
9
+ return entry;
10
+ entry = __defProp({}, "__esModule", { value: true });
11
+ if (from && typeof from === "object" || typeof from === "function")
12
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ }));
16
+ __moduleCache.set(from, entry);
17
+ return entry;
18
+ };
2
19
  var __export = (target, all) => {
3
20
  for (var name in all)
4
21
  __defProp(target, name, {
@@ -148,6 +165,162 @@ var init_errors = __esm(() => {
148
165
  };
149
166
  });
150
167
 
168
+ // src/adapters/base-handler.ts
169
+ class OAuthHandler {
170
+ config;
171
+ serverUrl = MCP_SERVER_URL2;
172
+ constructor(config) {
173
+ this.config = config;
174
+ }
175
+ async handleAuthorize(request) {
176
+ const providerConfig = this.config.providers[request.provider];
177
+ if (!providerConfig) {
178
+ throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
179
+ }
180
+ if (!providerConfig.clientId || !providerConfig.clientSecret) {
181
+ throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
182
+ }
183
+ const url = new URL("/oauth/authorize", this.serverUrl);
184
+ url.searchParams.set("provider", request.provider);
185
+ url.searchParams.set("client_id", providerConfig.clientId);
186
+ url.searchParams.set("client_secret", providerConfig.clientSecret);
187
+ url.searchParams.set("scope", request.scopes.join(","));
188
+ url.searchParams.set("state", request.state);
189
+ url.searchParams.set("code_challenge", request.codeChallenge);
190
+ url.searchParams.set("code_challenge_method", request.codeChallengeMethod);
191
+ const redirectUri = request.redirectUri || providerConfig.redirectUri;
192
+ if (redirectUri) {
193
+ url.searchParams.set("redirect_uri", redirectUri);
194
+ }
195
+ const response = await fetch(url.toString(), {
196
+ method: "GET"
197
+ });
198
+ if (!response.ok) {
199
+ const error = await response.text();
200
+ throw new Error(`MCP server failed to generate authorization URL: ${error}`);
201
+ }
202
+ const data = await response.json();
203
+ return data;
204
+ }
205
+ async handleCallback(request) {
206
+ const url = new URL("/oauth/callback", this.serverUrl);
207
+ const response = await fetch(url.toString(), {
208
+ method: "POST",
209
+ headers: {
210
+ "Content-Type": "application/json"
211
+ },
212
+ body: JSON.stringify({
213
+ provider: request.provider,
214
+ code: request.code,
215
+ code_verifier: request.codeVerifier,
216
+ state: request.state
217
+ })
218
+ });
219
+ if (!response.ok) {
220
+ const error = await response.text();
221
+ throw new Error(`MCP server failed to exchange authorization code: ${error}`);
222
+ }
223
+ const data = await response.json();
224
+ return data;
225
+ }
226
+ async handleStatus(provider, sessionToken) {
227
+ const url = new URL("/oauth/status", this.serverUrl);
228
+ url.searchParams.set("provider", provider);
229
+ const response = await fetch(url.toString(), {
230
+ method: "GET",
231
+ headers: {
232
+ "X-Session-Token": sessionToken
233
+ }
234
+ });
235
+ if (!response.ok) {
236
+ if (response.status === 401) {
237
+ return {
238
+ authorized: false,
239
+ provider
240
+ };
241
+ }
242
+ const error = await response.text();
243
+ throw new Error(`MCP server failed to check authorization status: ${error}`);
244
+ }
245
+ const data = await response.json();
246
+ return data;
247
+ }
248
+ }
249
+ var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
250
+
251
+ // src/adapters/nextjs.ts
252
+ var exports_nextjs = {};
253
+ __export(exports_nextjs, {
254
+ createNextOAuthHandler: () => createNextOAuthHandler
255
+ });
256
+ function createNextOAuthHandler(config) {
257
+ const handler = new OAuthHandler(config);
258
+ const handlers = {
259
+ async authorize(req) {
260
+ try {
261
+ const body = await req.json();
262
+ const result = await handler.handleAuthorize(body);
263
+ return Response.json(result);
264
+ } catch (error) {
265
+ console.error("[OAuth Authorize] Error:", error);
266
+ return Response.json({ error: error.message || "Failed to get authorization URL" }, { status: 500 });
267
+ }
268
+ },
269
+ async callback(req) {
270
+ try {
271
+ const body = await req.json();
272
+ const result = await handler.handleCallback(body);
273
+ return Response.json(result);
274
+ } catch (error) {
275
+ console.error("[OAuth Callback] Error:", error);
276
+ return Response.json({ error: error.message || "Failed to exchange authorization code" }, { status: 500 });
277
+ }
278
+ },
279
+ async status(req) {
280
+ try {
281
+ const provider = req.nextUrl.searchParams.get("provider");
282
+ const sessionToken = req.headers.get("x-session-token");
283
+ if (!provider) {
284
+ return Response.json({ error: "Missing provider query parameter" }, { status: 400 });
285
+ }
286
+ if (!sessionToken) {
287
+ return Response.json({ error: "Missing X-Session-Token header" }, { status: 400 });
288
+ }
289
+ const result = await handler.handleStatus(provider, sessionToken);
290
+ return Response.json(result);
291
+ } catch (error) {
292
+ console.error("[OAuth Status] Error:", error);
293
+ return Response.json({ error: error.message || "Failed to check authorization status" }, { status: 500 });
294
+ }
295
+ },
296
+ createRoutes() {
297
+ return {
298
+ async POST(req, context) {
299
+ const params = context.params instanceof Promise ? await context.params : context.params;
300
+ const action = params.action;
301
+ if (action === "authorize") {
302
+ return handlers.authorize(req);
303
+ }
304
+ if (action === "callback") {
305
+ return handlers.callback(req);
306
+ }
307
+ return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
308
+ },
309
+ async GET(req, context) {
310
+ const params = context.params instanceof Promise ? await context.params : context.params;
311
+ const action = params.action;
312
+ if (action === "status") {
313
+ return handlers.status(req);
314
+ }
315
+ return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
316
+ }
317
+ };
318
+ }
319
+ };
320
+ return handlers;
321
+ }
322
+ var init_nextjs = () => {};
323
+
151
324
  // src/protocol/jsonrpc.ts
152
325
  function parseMessage(message) {
153
326
  try {
@@ -425,6 +598,7 @@ function isBrowser() {
425
598
  class OAuthWindowManager {
426
599
  popupWindow = null;
427
600
  popupCheckInterval = null;
601
+ popupCheckTimeout = null;
428
602
  openPopup(url, options) {
429
603
  if (!isBrowser()) {
430
604
  throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
@@ -480,6 +654,10 @@ class OAuthWindowManager {
480
654
  const messageHandler = (event) => {
481
655
  if (event.data && event.data.type === "oauth_callback") {
482
656
  clearTimeout(timeout);
657
+ if (this.popupCheckTimeout) {
658
+ clearTimeout(this.popupCheckTimeout);
659
+ this.popupCheckTimeout = null;
660
+ }
483
661
  window.removeEventListener("message", messageHandler);
484
662
  const { code, state, error } = event.data;
485
663
  if (error) {
@@ -497,15 +675,18 @@ class OAuthWindowManager {
497
675
  }
498
676
  };
499
677
  window.addEventListener("message", messageHandler);
500
- this.popupCheckInterval = setInterval(() => {
501
- if (this.popupWindow?.closed) {
502
- clearTimeout(timeout);
503
- clearInterval(this.popupCheckInterval);
504
- window.removeEventListener("message", messageHandler);
505
- this.cleanup();
506
- reject(new Error("OAuth popup was closed by user"));
507
- }
508
- }, 500);
678
+ this.popupCheckTimeout = setTimeout(() => {
679
+ this.popupCheckTimeout = null;
680
+ this.popupCheckInterval = setInterval(() => {
681
+ if (this.popupWindow?.closed) {
682
+ clearTimeout(timeout);
683
+ clearInterval(this.popupCheckInterval);
684
+ window.removeEventListener("message", messageHandler);
685
+ this.cleanup();
686
+ reject(new Error("OAuth popup was closed by user"));
687
+ }
688
+ }, 500);
689
+ }, 2000);
509
690
  });
510
691
  }
511
692
  listenForRedirectCallback() {
@@ -514,10 +695,23 @@ class OAuthWindowManager {
514
695
  }
515
696
  return new Promise((resolve, reject) => {
516
697
  const params = new URLSearchParams(window.location.search);
517
- const code = params.get("code");
518
- const state = params.get("state");
519
- const error = params.get("error");
520
- const errorDescription = params.get("error_description");
698
+ let code = params.get("code");
699
+ let state = params.get("state");
700
+ let error = params.get("error");
701
+ let errorDescription = params.get("error_description");
702
+ if (!code && !error) {
703
+ try {
704
+ const stored = sessionStorage.getItem("oauth_callback_params");
705
+ if (stored) {
706
+ const parsed = JSON.parse(stored);
707
+ code = parsed.code;
708
+ state = parsed.state;
709
+ sessionStorage.removeItem("oauth_callback_params");
710
+ }
711
+ } catch (e) {
712
+ console.error("Failed to parse OAuth callback params from sessionStorage:", e);
713
+ }
714
+ }
521
715
  if (error) {
522
716
  const errorMsg = errorDescription || error;
523
717
  reject(new Error(`OAuth error: ${errorMsg}`));
@@ -539,6 +733,10 @@ class OAuthWindowManager {
539
733
  clearInterval(this.popupCheckInterval);
540
734
  this.popupCheckInterval = null;
541
735
  }
736
+ if (this.popupCheckTimeout) {
737
+ clearTimeout(this.popupCheckTimeout);
738
+ this.popupCheckTimeout = null;
739
+ }
542
740
  }
543
741
  close() {
544
742
  this.cleanup();
@@ -1154,153 +1352,109 @@ async function clearClientCache() {
1154
1352
  }
1155
1353
  }));
1156
1354
  }
1157
- // src/adapters/base-handler.ts
1158
- var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
1159
1355
 
1160
- class OAuthHandler {
1161
- config;
1162
- serverUrl = MCP_SERVER_URL2;
1163
- constructor(config) {
1164
- this.config = config;
1165
- }
1166
- async handleAuthorize(request) {
1167
- const providerConfig = this.config.providers[request.provider];
1168
- if (!providerConfig) {
1169
- throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
1170
- }
1171
- if (!providerConfig.clientId || !providerConfig.clientSecret) {
1172
- throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
1173
- }
1174
- const url = new URL("/oauth/authorize", this.serverUrl);
1175
- url.searchParams.set("provider", request.provider);
1176
- url.searchParams.set("client_id", providerConfig.clientId);
1177
- url.searchParams.set("client_secret", providerConfig.clientSecret);
1178
- url.searchParams.set("scope", request.scopes.join(","));
1179
- url.searchParams.set("state", request.state);
1180
- url.searchParams.set("code_challenge", request.codeChallenge);
1181
- url.searchParams.set("code_challenge_method", request.codeChallengeMethod);
1182
- const redirectUri = request.redirectUri || providerConfig.redirectUri;
1183
- if (redirectUri) {
1184
- url.searchParams.set("redirect_uri", redirectUri);
1185
- }
1186
- const response = await fetch(url.toString(), {
1187
- method: "GET"
1188
- });
1189
- if (!response.ok) {
1190
- const error = await response.text();
1191
- throw new Error(`MCP server failed to generate authorization URL: ${error}`);
1192
- }
1193
- const data = await response.json();
1194
- return data;
1195
- }
1196
- async handleCallback(request) {
1197
- const url = new URL("/oauth/callback", this.serverUrl);
1198
- const response = await fetch(url.toString(), {
1199
- method: "POST",
1200
- headers: {
1201
- "Content-Type": "application/json"
1202
- },
1203
- body: JSON.stringify({
1204
- provider: request.provider,
1205
- code: request.code,
1206
- code_verifier: request.codeVerifier,
1207
- state: request.state
1208
- })
1209
- });
1210
- if (!response.ok) {
1211
- const error = await response.text();
1212
- throw new Error(`MCP server failed to exchange authorization code: ${error}`);
1356
+ // src/index.ts
1357
+ init_nextjs();
1358
+
1359
+ // src/adapters/nextjs-callback.tsx
1360
+ import { useEffect } from "react";
1361
+ import { jsxDEV } from "react/jsx-dev-runtime";
1362
+ "use client";
1363
+ function OAuthCallbackPage(config) {
1364
+ const redirectUrl = config?.redirectUrl || "/";
1365
+ const errorRedirectUrl = config?.errorRedirectUrl || "/auth-error";
1366
+ useEffect(() => {
1367
+ const params = new URLSearchParams(window.location.search);
1368
+ const code = params.get("code");
1369
+ const state = params.get("state");
1370
+ const error = params.get("error");
1371
+ const errorDescription = params.get("error_description");
1372
+ if (error) {
1373
+ const errorMsg = errorDescription || error;
1374
+ console.error("[OAuth Callback] Error:", errorMsg);
1375
+ window.location.href = `${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`;
1376
+ return;
1213
1377
  }
1214
- const data = await response.json();
1215
- return data;
1216
- }
1217
- async handleStatus(provider, sessionToken) {
1218
- const url = new URL("/oauth/status", this.serverUrl);
1219
- url.searchParams.set("provider", provider);
1220
- const response = await fetch(url.toString(), {
1221
- method: "GET",
1222
- headers: {
1223
- "X-Session-Token": sessionToken
1224
- }
1225
- });
1226
- if (!response.ok) {
1227
- if (response.status === 401) {
1228
- return {
1229
- authorized: false,
1230
- provider
1231
- };
1232
- }
1233
- const error = await response.text();
1234
- throw new Error(`MCP server failed to check authorization status: ${error}`);
1378
+ if (!code || !state) {
1379
+ console.error("[OAuth Callback] Missing code or state parameter");
1380
+ window.location.href = `${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`;
1381
+ return;
1235
1382
  }
1236
- const data = await response.json();
1237
- return data;
1238
- }
1239
- }
1240
- // src/adapters/nextjs.ts
1241
- function createNextOAuthHandler(config) {
1242
- const handler = new OAuthHandler(config);
1243
- const handlers = {
1244
- async authorize(req) {
1245
- try {
1246
- const body = await req.json();
1247
- const result = await handler.handleAuthorize(body);
1248
- return Response.json(result);
1249
- } catch (error) {
1250
- console.error("[OAuth Authorize] Error:", error);
1251
- return Response.json({ error: error.message || "Failed to get authorization URL" }, { status: 500 });
1252
- }
1253
- },
1254
- async callback(req) {
1255
- try {
1256
- const body = await req.json();
1257
- const result = await handler.handleCallback(body);
1258
- return Response.json(result);
1259
- } catch (error) {
1260
- console.error("[OAuth Callback] Error:", error);
1261
- return Response.json({ error: error.message || "Failed to exchange authorization code" }, { status: 500 });
1262
- }
1263
- },
1264
- async status(req) {
1383
+ if (window.opener) {
1384
+ window.opener.postMessage({
1385
+ type: "oauth_callback",
1386
+ code,
1387
+ state
1388
+ }, "*");
1389
+ setTimeout(() => {
1390
+ window.close();
1391
+ }, 100);
1392
+ } else {
1265
1393
  try {
1266
- const provider = req.nextUrl.searchParams.get("provider");
1267
- const sessionToken = req.headers.get("x-session-token");
1268
- if (!provider) {
1269
- return Response.json({ error: "Missing provider query parameter" }, { status: 400 });
1270
- }
1271
- if (!sessionToken) {
1272
- return Response.json({ error: "Missing X-Session-Token header" }, { status: 400 });
1273
- }
1274
- const result = await handler.handleStatus(provider, sessionToken);
1275
- return Response.json(result);
1276
- } catch (error) {
1277
- console.error("[OAuth Status] Error:", error);
1278
- return Response.json({ error: error.message || "Failed to check authorization status" }, { status: 500 });
1394
+ sessionStorage.setItem("oauth_callback_params", JSON.stringify({ code, state }));
1395
+ } catch (e) {
1396
+ console.error("Failed to store OAuth callback params:", e);
1279
1397
  }
1398
+ setTimeout(() => {
1399
+ window.location.href = redirectUrl;
1400
+ }, 500);
1401
+ }
1402
+ }, [redirectUrl, errorRedirectUrl]);
1403
+ return /* @__PURE__ */ jsxDEV("div", {
1404
+ style: {
1405
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
1406
+ display: "flex",
1407
+ alignItems: "center",
1408
+ justifyContent: "center",
1409
+ minHeight: "100vh",
1410
+ margin: 0,
1411
+ background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1412
+ color: "white"
1280
1413
  },
1281
- createRoutes() {
1282
- return {
1283
- async POST(req, context) {
1284
- const action = context.params.action;
1285
- if (action === "authorize") {
1286
- return handlers.authorize(req);
1414
+ children: /* @__PURE__ */ jsxDEV("div", {
1415
+ style: { textAlign: "center", padding: "2rem" },
1416
+ children: [
1417
+ /* @__PURE__ */ jsxDEV("div", {
1418
+ style: {
1419
+ border: "3px solid rgba(255, 255, 255, 0.3)",
1420
+ borderRadius: "50%",
1421
+ borderTop: "3px solid white",
1422
+ width: "40px",
1423
+ height: "40px",
1424
+ animation: "spin 1s linear infinite",
1425
+ margin: "0 auto 1rem"
1287
1426
  }
1288
- if (action === "callback") {
1289
- return handlers.callback(req);
1427
+ }, undefined, false, undefined, this),
1428
+ /* @__PURE__ */ jsxDEV("h1", {
1429
+ style: {
1430
+ margin: "0 0 0.5rem",
1431
+ fontSize: "1.5rem",
1432
+ fontWeight: 600
1433
+ },
1434
+ children: "Authorization Complete"
1435
+ }, undefined, false, undefined, this),
1436
+ /* @__PURE__ */ jsxDEV("p", {
1437
+ style: { margin: 0, opacity: 0.9, fontSize: "0.875rem" },
1438
+ children: "This window will close automatically..."
1439
+ }, undefined, false, undefined, this),
1440
+ /* @__PURE__ */ jsxDEV("style", {
1441
+ children: `
1442
+ @keyframes spin {
1443
+ 0% { transform: rotate(0deg); }
1444
+ 100% { transform: rotate(360deg); }
1290
1445
  }
1291
- return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
1292
- },
1293
- async GET(req, context) {
1294
- const action = context.params.action;
1295
- if (action === "status") {
1296
- return handlers.status(req);
1297
- }
1298
- return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
1299
- }
1300
- };
1301
- }
1446
+ `
1447
+ }, undefined, false, undefined, this)
1448
+ ]
1449
+ }, undefined, true, undefined, this)
1450
+ }, undefined, false, undefined, this);
1451
+ }
1452
+ function createOAuthCallbackPage(config) {
1453
+ return function OAuthCallback() {
1454
+ return /* @__PURE__ */ jsxDEV(OAuthCallbackPage, {
1455
+ ...config
1456
+ }, undefined, false, undefined, this);
1302
1457
  };
1303
- return handlers;
1304
1458
  }
1305
1459
  // src/adapters/tanstack-start.ts
1306
1460
  function createTanStackOAuthHandler(config) {
@@ -1536,6 +1690,7 @@ export {
1536
1690
  generateCodeChallenge,
1537
1691
  createTanStackOAuthHandler,
1538
1692
  createSimplePlugin,
1693
+ createOAuthCallbackPage,
1539
1694
  createNextOAuthHandler,
1540
1695
  createMCPClient,
1541
1696
  convertMCPToolsToVercelAI,
@@ -1546,6 +1701,7 @@ export {
1546
1701
  OAuthWindowManager,
1547
1702
  OAuthManager,
1548
1703
  OAuthHandler,
1704
+ OAuthCallbackPage,
1549
1705
  MCPMethod,
1550
1706
  MCPClient,
1551
1707
  IntegrateSDKError,
package/dist/oauth.js CHANGED
@@ -1,4 +1,21 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
6
+ var __toCommonJS = (from) => {
7
+ var entry = __moduleCache.get(from), desc;
8
+ if (entry)
9
+ return entry;
10
+ entry = __defProp({}, "__esModule", { value: true });
11
+ if (from && typeof from === "object" || typeof from === "function")
12
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ }));
16
+ __moduleCache.set(from, entry);
17
+ return entry;
18
+ };
2
19
  var __export = (target, all) => {
3
20
  for (var name in all)
4
21
  __defProp(target, name, {
@@ -11,8 +28,6 @@ var __export = (target, all) => {
11
28
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
12
29
 
13
30
  // src/adapters/base-handler.ts
14
- var MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
15
-
16
31
  class OAuthHandler {
17
32
  config;
18
33
  serverUrl = MCP_SERVER_URL;
@@ -93,12 +108,10 @@ class OAuthHandler {
93
108
  return data;
94
109
  }
95
110
  }
111
+ var MCP_SERVER_URL = "https://mcp.integrate.dev/api/v1/mcp";
96
112
 
97
113
  // src/adapters/auto-routes.ts
98
114
  var globalOAuthConfig = null;
99
- function setGlobalOAuthConfig(config) {
100
- globalOAuthConfig = config;
101
- }
102
115
  async function POST(req, context) {
103
116
  if (!globalOAuthConfig) {
104
117
  throw new Error("OAuth configuration not found. Did you configure oauthProviders in createMCPClient?");
package/dist/server.js CHANGED
@@ -1,4 +1,21 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
6
+ var __toCommonJS = (from) => {
7
+ var entry = __moduleCache.get(from), desc;
8
+ if (entry)
9
+ return entry;
10
+ entry = __defProp({}, "__esModule", { value: true });
11
+ if (from && typeof from === "object" || typeof from === "function")
12
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ }));
16
+ __moduleCache.set(from, entry);
17
+ return entry;
18
+ };
2
19
  var __export = (target, all) => {
3
20
  for (var name in all)
4
21
  __defProp(target, name, {
@@ -148,6 +165,162 @@ var init_errors = __esm(() => {
148
165
  };
149
166
  });
150
167
 
168
+ // src/adapters/base-handler.ts
169
+ class OAuthHandler {
170
+ config;
171
+ serverUrl = MCP_SERVER_URL2;
172
+ constructor(config) {
173
+ this.config = config;
174
+ }
175
+ async handleAuthorize(request) {
176
+ const providerConfig = this.config.providers[request.provider];
177
+ if (!providerConfig) {
178
+ throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
179
+ }
180
+ if (!providerConfig.clientId || !providerConfig.clientSecret) {
181
+ throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
182
+ }
183
+ const url = new URL("/oauth/authorize", this.serverUrl);
184
+ url.searchParams.set("provider", request.provider);
185
+ url.searchParams.set("client_id", providerConfig.clientId);
186
+ url.searchParams.set("client_secret", providerConfig.clientSecret);
187
+ url.searchParams.set("scope", request.scopes.join(","));
188
+ url.searchParams.set("state", request.state);
189
+ url.searchParams.set("code_challenge", request.codeChallenge);
190
+ url.searchParams.set("code_challenge_method", request.codeChallengeMethod);
191
+ const redirectUri = request.redirectUri || providerConfig.redirectUri;
192
+ if (redirectUri) {
193
+ url.searchParams.set("redirect_uri", redirectUri);
194
+ }
195
+ const response = await fetch(url.toString(), {
196
+ method: "GET"
197
+ });
198
+ if (!response.ok) {
199
+ const error = await response.text();
200
+ throw new Error(`MCP server failed to generate authorization URL: ${error}`);
201
+ }
202
+ const data = await response.json();
203
+ return data;
204
+ }
205
+ async handleCallback(request) {
206
+ const url = new URL("/oauth/callback", this.serverUrl);
207
+ const response = await fetch(url.toString(), {
208
+ method: "POST",
209
+ headers: {
210
+ "Content-Type": "application/json"
211
+ },
212
+ body: JSON.stringify({
213
+ provider: request.provider,
214
+ code: request.code,
215
+ code_verifier: request.codeVerifier,
216
+ state: request.state
217
+ })
218
+ });
219
+ if (!response.ok) {
220
+ const error = await response.text();
221
+ throw new Error(`MCP server failed to exchange authorization code: ${error}`);
222
+ }
223
+ const data = await response.json();
224
+ return data;
225
+ }
226
+ async handleStatus(provider, sessionToken) {
227
+ const url = new URL("/oauth/status", this.serverUrl);
228
+ url.searchParams.set("provider", provider);
229
+ const response = await fetch(url.toString(), {
230
+ method: "GET",
231
+ headers: {
232
+ "X-Session-Token": sessionToken
233
+ }
234
+ });
235
+ if (!response.ok) {
236
+ if (response.status === 401) {
237
+ return {
238
+ authorized: false,
239
+ provider
240
+ };
241
+ }
242
+ const error = await response.text();
243
+ throw new Error(`MCP server failed to check authorization status: ${error}`);
244
+ }
245
+ const data = await response.json();
246
+ return data;
247
+ }
248
+ }
249
+ var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
250
+
251
+ // src/adapters/nextjs.ts
252
+ var exports_nextjs = {};
253
+ __export(exports_nextjs, {
254
+ createNextOAuthHandler: () => createNextOAuthHandler
255
+ });
256
+ function createNextOAuthHandler(config) {
257
+ const handler = new OAuthHandler(config);
258
+ const handlers = {
259
+ async authorize(req) {
260
+ try {
261
+ const body = await req.json();
262
+ const result = await handler.handleAuthorize(body);
263
+ return Response.json(result);
264
+ } catch (error) {
265
+ console.error("[OAuth Authorize] Error:", error);
266
+ return Response.json({ error: error.message || "Failed to get authorization URL" }, { status: 500 });
267
+ }
268
+ },
269
+ async callback(req) {
270
+ try {
271
+ const body = await req.json();
272
+ const result = await handler.handleCallback(body);
273
+ return Response.json(result);
274
+ } catch (error) {
275
+ console.error("[OAuth Callback] Error:", error);
276
+ return Response.json({ error: error.message || "Failed to exchange authorization code" }, { status: 500 });
277
+ }
278
+ },
279
+ async status(req) {
280
+ try {
281
+ const provider = req.nextUrl.searchParams.get("provider");
282
+ const sessionToken = req.headers.get("x-session-token");
283
+ if (!provider) {
284
+ return Response.json({ error: "Missing provider query parameter" }, { status: 400 });
285
+ }
286
+ if (!sessionToken) {
287
+ return Response.json({ error: "Missing X-Session-Token header" }, { status: 400 });
288
+ }
289
+ const result = await handler.handleStatus(provider, sessionToken);
290
+ return Response.json(result);
291
+ } catch (error) {
292
+ console.error("[OAuth Status] Error:", error);
293
+ return Response.json({ error: error.message || "Failed to check authorization status" }, { status: 500 });
294
+ }
295
+ },
296
+ createRoutes() {
297
+ return {
298
+ async POST(req, context) {
299
+ const params = context.params instanceof Promise ? await context.params : context.params;
300
+ const action = params.action;
301
+ if (action === "authorize") {
302
+ return handlers.authorize(req);
303
+ }
304
+ if (action === "callback") {
305
+ return handlers.callback(req);
306
+ }
307
+ return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
308
+ },
309
+ async GET(req, context) {
310
+ const params = context.params instanceof Promise ? await context.params : context.params;
311
+ const action = params.action;
312
+ if (action === "status") {
313
+ return handlers.status(req);
314
+ }
315
+ return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
316
+ }
317
+ };
318
+ }
319
+ };
320
+ return handlers;
321
+ }
322
+ var init_nextjs = () => {};
323
+
151
324
  // src/protocol/jsonrpc.ts
152
325
  function parseMessage(message) {
153
326
  try {
@@ -425,6 +598,7 @@ function isBrowser() {
425
598
  class OAuthWindowManager {
426
599
  popupWindow = null;
427
600
  popupCheckInterval = null;
601
+ popupCheckTimeout = null;
428
602
  openPopup(url, options) {
429
603
  if (!isBrowser()) {
430
604
  throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
@@ -480,6 +654,10 @@ class OAuthWindowManager {
480
654
  const messageHandler = (event) => {
481
655
  if (event.data && event.data.type === "oauth_callback") {
482
656
  clearTimeout(timeout);
657
+ if (this.popupCheckTimeout) {
658
+ clearTimeout(this.popupCheckTimeout);
659
+ this.popupCheckTimeout = null;
660
+ }
483
661
  window.removeEventListener("message", messageHandler);
484
662
  const { code, state, error } = event.data;
485
663
  if (error) {
@@ -497,15 +675,18 @@ class OAuthWindowManager {
497
675
  }
498
676
  };
499
677
  window.addEventListener("message", messageHandler);
500
- this.popupCheckInterval = setInterval(() => {
501
- if (this.popupWindow?.closed) {
502
- clearTimeout(timeout);
503
- clearInterval(this.popupCheckInterval);
504
- window.removeEventListener("message", messageHandler);
505
- this.cleanup();
506
- reject(new Error("OAuth popup was closed by user"));
507
- }
508
- }, 500);
678
+ this.popupCheckTimeout = setTimeout(() => {
679
+ this.popupCheckTimeout = null;
680
+ this.popupCheckInterval = setInterval(() => {
681
+ if (this.popupWindow?.closed) {
682
+ clearTimeout(timeout);
683
+ clearInterval(this.popupCheckInterval);
684
+ window.removeEventListener("message", messageHandler);
685
+ this.cleanup();
686
+ reject(new Error("OAuth popup was closed by user"));
687
+ }
688
+ }, 500);
689
+ }, 2000);
509
690
  });
510
691
  }
511
692
  listenForRedirectCallback() {
@@ -514,10 +695,23 @@ class OAuthWindowManager {
514
695
  }
515
696
  return new Promise((resolve, reject) => {
516
697
  const params = new URLSearchParams(window.location.search);
517
- const code = params.get("code");
518
- const state = params.get("state");
519
- const error = params.get("error");
520
- const errorDescription = params.get("error_description");
698
+ let code = params.get("code");
699
+ let state = params.get("state");
700
+ let error = params.get("error");
701
+ let errorDescription = params.get("error_description");
702
+ if (!code && !error) {
703
+ try {
704
+ const stored = sessionStorage.getItem("oauth_callback_params");
705
+ if (stored) {
706
+ const parsed = JSON.parse(stored);
707
+ code = parsed.code;
708
+ state = parsed.state;
709
+ sessionStorage.removeItem("oauth_callback_params");
710
+ }
711
+ } catch (e) {
712
+ console.error("Failed to parse OAuth callback params from sessionStorage:", e);
713
+ }
714
+ }
521
715
  if (error) {
522
716
  const errorMsg = errorDescription || error;
523
717
  reject(new Error(`OAuth error: ${errorMsg}`));
@@ -539,6 +733,10 @@ class OAuthWindowManager {
539
733
  clearInterval(this.popupCheckInterval);
540
734
  this.popupCheckInterval = null;
541
735
  }
736
+ if (this.popupCheckTimeout) {
737
+ clearTimeout(this.popupCheckTimeout);
738
+ this.popupCheckTimeout = null;
739
+ }
542
740
  }
543
741
  close() {
544
742
  this.cleanup();
@@ -1155,185 +1353,6 @@ async function clearClientCache() {
1155
1353
  }));
1156
1354
  }
1157
1355
 
1158
- // src/adapters/base-handler.ts
1159
- var MCP_SERVER_URL2 = "https://mcp.integrate.dev/api/v1/mcp";
1160
-
1161
- class OAuthHandler {
1162
- config;
1163
- serverUrl = MCP_SERVER_URL2;
1164
- constructor(config) {
1165
- this.config = config;
1166
- }
1167
- async handleAuthorize(request) {
1168
- const providerConfig = this.config.providers[request.provider];
1169
- if (!providerConfig) {
1170
- throw new Error(`Provider ${request.provider} not configured. Add OAuth credentials to your API route configuration.`);
1171
- }
1172
- if (!providerConfig.clientId || !providerConfig.clientSecret) {
1173
- throw new Error(`Missing OAuth credentials for ${request.provider}. Check your environment variables.`);
1174
- }
1175
- const url = new URL("/oauth/authorize", this.serverUrl);
1176
- url.searchParams.set("provider", request.provider);
1177
- url.searchParams.set("client_id", providerConfig.clientId);
1178
- url.searchParams.set("client_secret", providerConfig.clientSecret);
1179
- url.searchParams.set("scope", request.scopes.join(","));
1180
- url.searchParams.set("state", request.state);
1181
- url.searchParams.set("code_challenge", request.codeChallenge);
1182
- url.searchParams.set("code_challenge_method", request.codeChallengeMethod);
1183
- const redirectUri = request.redirectUri || providerConfig.redirectUri;
1184
- if (redirectUri) {
1185
- url.searchParams.set("redirect_uri", redirectUri);
1186
- }
1187
- const response = await fetch(url.toString(), {
1188
- method: "GET"
1189
- });
1190
- if (!response.ok) {
1191
- const error = await response.text();
1192
- throw new Error(`MCP server failed to generate authorization URL: ${error}`);
1193
- }
1194
- const data = await response.json();
1195
- return data;
1196
- }
1197
- async handleCallback(request) {
1198
- const url = new URL("/oauth/callback", this.serverUrl);
1199
- const response = await fetch(url.toString(), {
1200
- method: "POST",
1201
- headers: {
1202
- "Content-Type": "application/json"
1203
- },
1204
- body: JSON.stringify({
1205
- provider: request.provider,
1206
- code: request.code,
1207
- code_verifier: request.codeVerifier,
1208
- state: request.state
1209
- })
1210
- });
1211
- if (!response.ok) {
1212
- const error = await response.text();
1213
- throw new Error(`MCP server failed to exchange authorization code: ${error}`);
1214
- }
1215
- const data = await response.json();
1216
- return data;
1217
- }
1218
- async handleStatus(provider, sessionToken) {
1219
- const url = new URL("/oauth/status", this.serverUrl);
1220
- url.searchParams.set("provider", provider);
1221
- const response = await fetch(url.toString(), {
1222
- method: "GET",
1223
- headers: {
1224
- "X-Session-Token": sessionToken
1225
- }
1226
- });
1227
- if (!response.ok) {
1228
- if (response.status === 401) {
1229
- return {
1230
- authorized: false,
1231
- provider
1232
- };
1233
- }
1234
- const error = await response.text();
1235
- throw new Error(`MCP server failed to check authorization status: ${error}`);
1236
- }
1237
- const data = await response.json();
1238
- return data;
1239
- }
1240
- }
1241
-
1242
- // src/adapters/auto-routes.ts
1243
- var globalOAuthConfig = null;
1244
- function setGlobalOAuthConfig(config) {
1245
- globalOAuthConfig = config;
1246
- }
1247
- async function POST(req, context) {
1248
- if (!globalOAuthConfig) {
1249
- throw new Error("OAuth configuration not found. Did you configure oauthProviders in createMCPClient?");
1250
- }
1251
- const handler = new OAuthHandler(globalOAuthConfig);
1252
- const action = context?.params?.action;
1253
- if (!action) {
1254
- return createErrorResponse("Missing action parameter", 400);
1255
- }
1256
- try {
1257
- if (action === "authorize") {
1258
- const body = await parseRequestBody(req);
1259
- const result = await handler.handleAuthorize(body);
1260
- return createSuccessResponse(result);
1261
- }
1262
- if (action === "callback") {
1263
- const body = await parseRequestBody(req);
1264
- const result = await handler.handleCallback(body);
1265
- return createSuccessResponse(result);
1266
- }
1267
- return createErrorResponse(`Unknown action: ${action}`, 404);
1268
- } catch (error) {
1269
- console.error(`[OAuth ${action}] Error:`, error);
1270
- return createErrorResponse(error.message, 500);
1271
- }
1272
- }
1273
- async function GET(req, context) {
1274
- if (!globalOAuthConfig) {
1275
- throw new Error("OAuth configuration not found. Did you configure oauthProviders in createMCPClient?");
1276
- }
1277
- const handler = new OAuthHandler(globalOAuthConfig);
1278
- const action = context?.params?.action;
1279
- if (!action) {
1280
- return createErrorResponse("Missing action parameter", 400);
1281
- }
1282
- try {
1283
- if (action === "status") {
1284
- const { provider, sessionToken } = parseQueryParams(req);
1285
- if (!provider || !sessionToken) {
1286
- return createErrorResponse("Missing provider or session token", 400);
1287
- }
1288
- const result = await handler.handleStatus(provider, sessionToken);
1289
- return createSuccessResponse(result);
1290
- }
1291
- return createErrorResponse(`Unknown action: ${action}`, 404);
1292
- } catch (error) {
1293
- console.error(`[OAuth ${action}] Error:`, error);
1294
- return createErrorResponse(error.message, 500);
1295
- }
1296
- }
1297
- async function parseRequestBody(req) {
1298
- if (typeof req.json === "function") {
1299
- return await req.json();
1300
- }
1301
- throw new Error("Unable to parse request body");
1302
- }
1303
- function parseQueryParams(req) {
1304
- let url;
1305
- if (req.nextUrl) {
1306
- url = new URL(req.nextUrl);
1307
- } else if (req.url) {
1308
- url = new URL(req.url);
1309
- } else {
1310
- return {};
1311
- }
1312
- const provider = url.searchParams.get("provider") || undefined;
1313
- const sessionToken = req.headers?.get?.("x-session-token") || undefined;
1314
- return { provider, sessionToken };
1315
- }
1316
- function createSuccessResponse(data) {
1317
- if (typeof globalThis.NextResponse !== "undefined") {
1318
- const NextResponse = globalThis.NextResponse;
1319
- return NextResponse.json(data);
1320
- }
1321
- return new Response(JSON.stringify(data), {
1322
- status: 200,
1323
- headers: { "Content-Type": "application/json" }
1324
- });
1325
- }
1326
- function createErrorResponse(message, status) {
1327
- if (typeof globalThis.NextResponse !== "undefined") {
1328
- const NextResponse = globalThis.NextResponse;
1329
- return NextResponse.json({ error: message }, { status });
1330
- }
1331
- return new Response(JSON.stringify({ error: message }), {
1332
- status,
1333
- headers: { "Content-Type": "application/json" }
1334
- });
1335
- }
1336
-
1337
1356
  // src/plugins/github.ts
1338
1357
  var GITHUB_TOOLS = [
1339
1358
  "github_create_issue",
@@ -1461,17 +1480,19 @@ function createMCPServer(config) {
1461
1480
  };
1462
1481
  }
1463
1482
  }
1464
- if (Object.keys(providers).length > 0) {
1465
- setGlobalOAuthConfig({ providers });
1466
- }
1467
1483
  const client = new MCPClient(config);
1484
+ const { POST, GET } = createOAuthRouteHandlers({ providers });
1468
1485
  return {
1469
1486
  client,
1470
- handlers: {
1471
- info: "To use OAuth handlers, create a route file and add: export * from 'integrate-sdk/oauth'"
1472
- }
1487
+ POST,
1488
+ GET
1473
1489
  };
1474
1490
  }
1491
+ function createOAuthRouteHandlers(config) {
1492
+ const { createNextOAuthHandler: createNextOAuthHandler2 } = (init_nextjs(), __toCommonJS(exports_nextjs));
1493
+ const handler = createNextOAuthHandler2(config);
1494
+ return handler.createRoutes();
1495
+ }
1475
1496
  export {
1476
1497
  gmailPlugin,
1477
1498
  githubPlugin,
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Next.js OAuth Callback Handler
3
+ * Provides a pre-built OAuth callback page component for Next.js App Router
4
+ *
5
+ * This eliminates the need for users to manually create callback pages.
6
+ */
7
+ import type { OAuthCallbackHandlerConfig } from '../oauth/types.js';
8
+ /**
9
+ * OAuth Callback Page Component
10
+ *
11
+ * This component:
12
+ * 1. Extracts OAuth callback parameters (code, state, error) from URL
13
+ * 2. Sends them to the opener window (for popup mode) via postMessage
14
+ * 3. Stores them in sessionStorage (for redirect mode)
15
+ * 4. Redirects to the configured URL
16
+ *
17
+ * @param config - Callback handler configuration
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * // app/oauth/callback/page.tsx
22
+ * import { OAuthCallbackPage } from 'integrate-sdk';
23
+ *
24
+ * export default function CallbackPage() {
25
+ * return <OAuthCallbackPage redirectUrl="/dashboard" />;
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function OAuthCallbackPage(config?: OAuthCallbackHandlerConfig): import("react/jsx-runtime").JSX.Element;
30
+ /**
31
+ * Create a default export wrapper for easier usage
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * // app/oauth/callback/page.tsx
36
+ * export { default } from 'integrate-sdk/oauth-callback';
37
+ * ```
38
+ */
39
+ export declare function createOAuthCallbackPage(config?: OAuthCallbackHandlerConfig): () => import("react/jsx-runtime").JSX.Element;
40
+ //# sourceMappingURL=nextjs-callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextjs-callback.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs-callback.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,0BAA0B,2CA2GpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,0BAA0B,iDAI1E"}
@@ -207,7 +207,9 @@ export declare function createNextOAuthHandler(config: OAuthHandlerConfig): {
207
207
  POST(req: NextRequest, context: {
208
208
  params: {
209
209
  action: string;
210
- };
210
+ } | Promise<{
211
+ action: string;
212
+ }>;
211
213
  }): Promise<NextResponse>;
212
214
  /**
213
215
  * GET handler for status action
@@ -215,7 +217,9 @@ export declare function createNextOAuthHandler(config: OAuthHandlerConfig): {
215
217
  GET(req: NextRequest, context: {
216
218
  params: {
217
219
  action: string;
218
- };
220
+ } | Promise<{
221
+ action: string;
222
+ }>;
219
223
  }): Promise<NextResponse>;
220
224
  };
221
225
  };
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,KAAK,WAAW,GAAG,GAAG,CAAC;AACvB,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB;;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yCG;kBACiB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;gBACe,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA8BrD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;QAGC;;WAEG;kBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,GACpE,OAAO,CAAC,YAAY,CAAC;QAmBxB;;WAEG;iBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,GAAG,OAAO,CAAC;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,GACpE,OAAO,CAAC,YAAY,CAAC;;EAmB/B"}
@@ -7,10 +7,11 @@ 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, } from "./oauth/types.js";
10
+ export type { OAuthFlowConfig, PopupOptions, AuthStatus, PendingAuth, AuthorizationUrlResponse, OAuthCallbackResponse, OAuthCallbackParams, OAuthCallbackHandlerConfig, } 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";
14
+ export { OAuthCallbackPage, createOAuthCallbackPage } from "./adapters/nextjs-callback.js";
14
15
  export { createTanStackOAuthHandler } from "./adapters/tanstack-start.js";
15
16
  export type { MCPClientConfig, ReauthContext, ReauthHandler } from "./config/types.js";
16
17
  export { IntegrateSDKError, AuthenticationError, AuthorizationError, TokenExpiredError, ConnectionError, ToolCallError, isAuthError, isTokenExpiredError, isAuthorizationError, parseServerError, } from "./errors.js";
@@ -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,GACpB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAG1E,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvF,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,oBA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CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG3F,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,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"}
@@ -81,4 +81,13 @@ export interface OAuthCallbackParams {
81
81
  /** State parameter for CSRF protection */
82
82
  state: string;
83
83
  }
84
+ /**
85
+ * Configuration for OAuth callback route handler
86
+ */
87
+ export interface OAuthCallbackHandlerConfig {
88
+ /** URL to redirect to after successful OAuth (default: '/') */
89
+ redirectUrl?: string;
90
+ /** URL to redirect to on OAuth error (default: '/auth-error') */
91
+ errorRedirectUrl?: string;
92
+ }
84
93
  //# sourceMappingURL=types.d.ts.map
@@ -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,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MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -13,6 +13,7 @@ import type { PopupOptions, OAuthCallbackParams } from "./types.js";
13
13
  export declare class OAuthWindowManager {
14
14
  private popupWindow;
15
15
  private popupCheckInterval;
16
+ private popupCheckTimeout;
16
17
  /**
17
18
  * Open OAuth authorization in a popup window
18
19
  *
@@ -63,7 +64,7 @@ export declare class OAuthWindowManager {
63
64
  */
64
65
  private listenForPopupCallback;
65
66
  /**
66
- * Parse callback parameters from current URL (for redirect flow)
67
+ * Parse callback parameters from current URL or sessionStorage (for redirect flow)
67
68
  */
68
69
  private listenForRedirectCallback;
69
70
  /**
@@ -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;IAEzE;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,GAAG,EAAE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,GAAG,UAAU,EAC1B,SAAS,GAAE,MAAsB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAQ/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAkE9B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA6CjC;;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"}
@@ -16,7 +16,7 @@ import type { MCPPlugin } from './plugins/types.js';
16
16
  * // lib/integrate-server.ts (server-side only!)
17
17
  * import { createMCPServer, githubPlugin, gmailPlugin } from 'integrate-sdk/server';
18
18
  *
19
- * export const { client: serverClient, handlers } = createMCPServer({
19
+ * export const { client: serverClient, POST, GET } = createMCPServer({
20
20
  * plugins: [
21
21
  * githubPlugin({
22
22
  * clientId: process.env.GITHUB_CLIENT_ID!,
@@ -35,16 +35,16 @@ import type { MCPPlugin } from './plugins/types.js';
35
35
  * Then in your route file:
36
36
  * ```typescript
37
37
  * // app/api/integrate/oauth/[action]/route.ts
38
- * export * from 'integrate-sdk/oauth';
38
+ * export { POST, GET } from '@/lib/integrate-server';
39
39
  * ```
40
40
  */
41
41
  export declare function createMCPServer<TPlugins extends readonly MCPPlugin[]>(config: MCPClientConfig<TPlugins>): {
42
42
  /** Server-side MCP client instance */
43
43
  client: MCPClient<TPlugins>;
44
- /** OAuth route handlers (use by importing 'integrate-sdk/oauth' in your route file) */
45
- handlers: {
46
- info: string;
47
- };
44
+ /** OAuth POST handler - export this from your route file */
45
+ POST: any;
46
+ /** OAuth GET handler - export this from your route file */
47
+ GET: any;
48
48
  };
49
49
  export type { MCPPlugin } from './plugins/types.js';
50
50
  export type { MCPClientConfig } from './config/types.js';
@@ -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;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC;IA8C/B,sCAAsC;;IAGtC,uFAAuF;;;;EAK1F;AAGD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
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;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC;IA4C/B,sCAAsC;;IAGtC,4DAA4D;;IAG5D,2DAA2D;;EAG9D;AAaD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integrate-sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.6",
4
4
  "description": "Type-safe TypeScript SDK for MCP Client with plugin-based OAuth provider configuration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "oauth.ts"
36
36
  ],
37
37
  "scripts": {
38
- "build": "bun build index.ts server.ts oauth.ts --outdir dist --target node --format esm && bun run build:types",
38
+ "build": "bun build index.ts server.ts oauth.ts --outdir dist --target node --format esm --external react --external react/jsx-runtime && bun run build:types",
39
39
  "build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
40
40
  "dev": "bun --watch src/index.ts",
41
41
  "type-check": "tsc --noEmit",
@@ -58,11 +58,18 @@
58
58
  "license": "MIT",
59
59
  "devDependencies": {
60
60
  "@types/bun": "latest",
61
+ "@types/react": "^18.0.0",
61
62
  "simple-git-hooks": "^2.13.1",
62
63
  "typescript": "^5.3.3"
63
64
  },
64
65
  "peerDependencies": {
65
- "typescript": ">=5.0.0"
66
+ "typescript": ">=5.0.0",
67
+ "react": ">=18.0.0"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "react": {
71
+ "optional": true
72
+ }
66
73
  },
67
74
  "simple-git-hooks": {
68
75
  "pre-commit": "./scripts/check-version.sh"