integrate-sdk 0.3.3 → 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 +144 -15
- package/dist/server.js +42 -15
- package/dist/src/adapters/nextjs-callback.d.ts +40 -0
- package/dist/src/adapters/nextjs-callback.d.ts.map +1 -0
- package/dist/src/adapters/nextjs.d.ts +6 -2
- package/dist/src/adapters/nextjs.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/oauth/types.d.ts +9 -0
- package/dist/src/oauth/types.d.ts.map +1 -1
- package/dist/src/oauth/window-manager.d.ts +2 -1
- package/dist/src/oauth/window-manager.d.ts.map +1 -1
- package/package.json +10 -3
package/dist/index.js
CHANGED
|
@@ -296,7 +296,8 @@ function createNextOAuthHandler(config) {
|
|
|
296
296
|
createRoutes() {
|
|
297
297
|
return {
|
|
298
298
|
async POST(req, context) {
|
|
299
|
-
const
|
|
299
|
+
const params = context.params instanceof Promise ? await context.params : context.params;
|
|
300
|
+
const action = params.action;
|
|
300
301
|
if (action === "authorize") {
|
|
301
302
|
return handlers.authorize(req);
|
|
302
303
|
}
|
|
@@ -306,7 +307,8 @@ function createNextOAuthHandler(config) {
|
|
|
306
307
|
return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
|
|
307
308
|
},
|
|
308
309
|
async GET(req, context) {
|
|
309
|
-
const
|
|
310
|
+
const params = context.params instanceof Promise ? await context.params : context.params;
|
|
311
|
+
const action = params.action;
|
|
310
312
|
if (action === "status") {
|
|
311
313
|
return handlers.status(req);
|
|
312
314
|
}
|
|
@@ -596,6 +598,7 @@ function isBrowser() {
|
|
|
596
598
|
class OAuthWindowManager {
|
|
597
599
|
popupWindow = null;
|
|
598
600
|
popupCheckInterval = null;
|
|
601
|
+
popupCheckTimeout = null;
|
|
599
602
|
openPopup(url, options) {
|
|
600
603
|
if (!isBrowser()) {
|
|
601
604
|
throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
|
|
@@ -651,6 +654,10 @@ class OAuthWindowManager {
|
|
|
651
654
|
const messageHandler = (event) => {
|
|
652
655
|
if (event.data && event.data.type === "oauth_callback") {
|
|
653
656
|
clearTimeout(timeout);
|
|
657
|
+
if (this.popupCheckTimeout) {
|
|
658
|
+
clearTimeout(this.popupCheckTimeout);
|
|
659
|
+
this.popupCheckTimeout = null;
|
|
660
|
+
}
|
|
654
661
|
window.removeEventListener("message", messageHandler);
|
|
655
662
|
const { code, state, error } = event.data;
|
|
656
663
|
if (error) {
|
|
@@ -668,15 +675,18 @@ class OAuthWindowManager {
|
|
|
668
675
|
}
|
|
669
676
|
};
|
|
670
677
|
window.addEventListener("message", messageHandler);
|
|
671
|
-
this.
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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);
|
|
680
690
|
});
|
|
681
691
|
}
|
|
682
692
|
listenForRedirectCallback() {
|
|
@@ -685,10 +695,23 @@ class OAuthWindowManager {
|
|
|
685
695
|
}
|
|
686
696
|
return new Promise((resolve, reject) => {
|
|
687
697
|
const params = new URLSearchParams(window.location.search);
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
+
}
|
|
692
715
|
if (error) {
|
|
693
716
|
const errorMsg = errorDescription || error;
|
|
694
717
|
reject(new Error(`OAuth error: ${errorMsg}`));
|
|
@@ -710,6 +733,10 @@ class OAuthWindowManager {
|
|
|
710
733
|
clearInterval(this.popupCheckInterval);
|
|
711
734
|
this.popupCheckInterval = null;
|
|
712
735
|
}
|
|
736
|
+
if (this.popupCheckTimeout) {
|
|
737
|
+
clearTimeout(this.popupCheckTimeout);
|
|
738
|
+
this.popupCheckTimeout = null;
|
|
739
|
+
}
|
|
713
740
|
}
|
|
714
741
|
close() {
|
|
715
742
|
this.cleanup();
|
|
@@ -1329,6 +1356,106 @@ async function clearClientCache() {
|
|
|
1329
1356
|
// src/index.ts
|
|
1330
1357
|
init_nextjs();
|
|
1331
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;
|
|
1377
|
+
}
|
|
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;
|
|
1382
|
+
}
|
|
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 {
|
|
1393
|
+
try {
|
|
1394
|
+
sessionStorage.setItem("oauth_callback_params", JSON.stringify({ code, state }));
|
|
1395
|
+
} catch (e) {
|
|
1396
|
+
console.error("Failed to store OAuth callback params:", e);
|
|
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"
|
|
1413
|
+
},
|
|
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"
|
|
1426
|
+
}
|
|
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); }
|
|
1445
|
+
}
|
|
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);
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1332
1459
|
// src/adapters/tanstack-start.ts
|
|
1333
1460
|
function createTanStackOAuthHandler(config) {
|
|
1334
1461
|
const handler = new OAuthHandler(config);
|
|
@@ -1563,6 +1690,7 @@ export {
|
|
|
1563
1690
|
generateCodeChallenge,
|
|
1564
1691
|
createTanStackOAuthHandler,
|
|
1565
1692
|
createSimplePlugin,
|
|
1693
|
+
createOAuthCallbackPage,
|
|
1566
1694
|
createNextOAuthHandler,
|
|
1567
1695
|
createMCPClient,
|
|
1568
1696
|
convertMCPToolsToVercelAI,
|
|
@@ -1573,6 +1701,7 @@ export {
|
|
|
1573
1701
|
OAuthWindowManager,
|
|
1574
1702
|
OAuthManager,
|
|
1575
1703
|
OAuthHandler,
|
|
1704
|
+
OAuthCallbackPage,
|
|
1576
1705
|
MCPMethod,
|
|
1577
1706
|
MCPClient,
|
|
1578
1707
|
IntegrateSDKError,
|
package/dist/server.js
CHANGED
|
@@ -296,7 +296,8 @@ function createNextOAuthHandler(config) {
|
|
|
296
296
|
createRoutes() {
|
|
297
297
|
return {
|
|
298
298
|
async POST(req, context) {
|
|
299
|
-
const
|
|
299
|
+
const params = context.params instanceof Promise ? await context.params : context.params;
|
|
300
|
+
const action = params.action;
|
|
300
301
|
if (action === "authorize") {
|
|
301
302
|
return handlers.authorize(req);
|
|
302
303
|
}
|
|
@@ -306,7 +307,8 @@ function createNextOAuthHandler(config) {
|
|
|
306
307
|
return Response.json({ error: `Unknown action: ${action}` }, { status: 404 });
|
|
307
308
|
},
|
|
308
309
|
async GET(req, context) {
|
|
309
|
-
const
|
|
310
|
+
const params = context.params instanceof Promise ? await context.params : context.params;
|
|
311
|
+
const action = params.action;
|
|
310
312
|
if (action === "status") {
|
|
311
313
|
return handlers.status(req);
|
|
312
314
|
}
|
|
@@ -596,6 +598,7 @@ function isBrowser() {
|
|
|
596
598
|
class OAuthWindowManager {
|
|
597
599
|
popupWindow = null;
|
|
598
600
|
popupCheckInterval = null;
|
|
601
|
+
popupCheckTimeout = null;
|
|
599
602
|
openPopup(url, options) {
|
|
600
603
|
if (!isBrowser()) {
|
|
601
604
|
throw new Error("OAuthWindowManager.openPopup() can only be used in browser environments");
|
|
@@ -651,6 +654,10 @@ class OAuthWindowManager {
|
|
|
651
654
|
const messageHandler = (event) => {
|
|
652
655
|
if (event.data && event.data.type === "oauth_callback") {
|
|
653
656
|
clearTimeout(timeout);
|
|
657
|
+
if (this.popupCheckTimeout) {
|
|
658
|
+
clearTimeout(this.popupCheckTimeout);
|
|
659
|
+
this.popupCheckTimeout = null;
|
|
660
|
+
}
|
|
654
661
|
window.removeEventListener("message", messageHandler);
|
|
655
662
|
const { code, state, error } = event.data;
|
|
656
663
|
if (error) {
|
|
@@ -668,15 +675,18 @@ class OAuthWindowManager {
|
|
|
668
675
|
}
|
|
669
676
|
};
|
|
670
677
|
window.addEventListener("message", messageHandler);
|
|
671
|
-
this.
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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);
|
|
680
690
|
});
|
|
681
691
|
}
|
|
682
692
|
listenForRedirectCallback() {
|
|
@@ -685,10 +695,23 @@ class OAuthWindowManager {
|
|
|
685
695
|
}
|
|
686
696
|
return new Promise((resolve, reject) => {
|
|
687
697
|
const params = new URLSearchParams(window.location.search);
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
+
}
|
|
692
715
|
if (error) {
|
|
693
716
|
const errorMsg = errorDescription || error;
|
|
694
717
|
reject(new Error(`OAuth error: ${errorMsg}`));
|
|
@@ -710,6 +733,10 @@ class OAuthWindowManager {
|
|
|
710
733
|
clearInterval(this.popupCheckInterval);
|
|
711
734
|
this.popupCheckInterval = null;
|
|
712
735
|
}
|
|
736
|
+
if (this.popupCheckTimeout) {
|
|
737
|
+
clearTimeout(this.popupCheckTimeout);
|
|
738
|
+
this.popupCheckTimeout = null;
|
|
739
|
+
}
|
|
713
740
|
}
|
|
714
741
|
close() {
|
|
715
742
|
this.cleanup();
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB;IAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;mBACkB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;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,CAAA;SAAE,
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB;IAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;mBACkB,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;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"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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";
|
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,CA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jB,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE/F,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,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,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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AAE,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,CAAC;IACrB,wCAAwC;IACxC,WAAW,EAAE,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;
|
|
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;IAwC7D;;;;;;;;;;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;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "integrate-sdk",
|
|
3
|
-
"version": "0.3.
|
|
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"
|