integrate-sdk 0.3.6 → 0.3.8
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 +31 -93
- package/dist/server.js +15 -0
- package/dist/src/adapters/nextjs-oauth-redirect.d.ts +34 -0
- package/dist/src/adapters/nextjs-oauth-redirect.d.ts.map +1 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/oauth/types.d.ts +0 -9
- package/dist/src/oauth/types.d.ts.map +1 -1
- package/dist/src/oauth/window-manager.d.ts +1 -1
- package/dist/src/oauth/window-manager.d.ts.map +1 -1
- package/package.json +3 -10
- package/dist/src/adapters/nextjs-callback.d.ts +0 -40
- package/dist/src/adapters/nextjs-callback.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -699,6 +699,21 @@ class OAuthWindowManager {
|
|
|
699
699
|
let state = params.get("state");
|
|
700
700
|
let error = params.get("error");
|
|
701
701
|
let errorDescription = params.get("error_description");
|
|
702
|
+
if (!code && !error && window.location.hash) {
|
|
703
|
+
try {
|
|
704
|
+
const hash = window.location.hash.substring(1);
|
|
705
|
+
const hashParams = new URLSearchParams(hash);
|
|
706
|
+
const oauthCallback = hashParams.get("oauth_callback");
|
|
707
|
+
if (oauthCallback) {
|
|
708
|
+
const parsed = JSON.parse(decodeURIComponent(oauthCallback));
|
|
709
|
+
code = parsed.code;
|
|
710
|
+
state = parsed.state;
|
|
711
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
712
|
+
}
|
|
713
|
+
} catch (e) {
|
|
714
|
+
console.error("Failed to parse OAuth callback params from hash:", e);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
702
717
|
if (!code && !error) {
|
|
703
718
|
try {
|
|
704
719
|
const stored = sessionStorage.getItem("oauth_callback_params");
|
|
@@ -1356,104 +1371,28 @@ async function clearClientCache() {
|
|
|
1356
1371
|
// src/index.ts
|
|
1357
1372
|
init_nextjs();
|
|
1358
1373
|
|
|
1359
|
-
// src/adapters/nextjs-
|
|
1360
|
-
|
|
1361
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
1362
|
-
"use client";
|
|
1363
|
-
function OAuthCallbackPage(config) {
|
|
1374
|
+
// src/adapters/nextjs-oauth-redirect.ts
|
|
1375
|
+
function createOAuthRedirectHandler(config) {
|
|
1364
1376
|
const redirectUrl = config?.redirectUrl || "/";
|
|
1365
1377
|
const errorRedirectUrl = config?.errorRedirectUrl || "/auth-error";
|
|
1366
|
-
|
|
1367
|
-
const
|
|
1368
|
-
const code =
|
|
1369
|
-
const state =
|
|
1370
|
-
const error =
|
|
1371
|
-
const errorDescription =
|
|
1378
|
+
return async function GET(req) {
|
|
1379
|
+
const { searchParams } = new URL(req.url);
|
|
1380
|
+
const code = searchParams.get("code");
|
|
1381
|
+
const state = searchParams.get("state");
|
|
1382
|
+
const error = searchParams.get("error");
|
|
1383
|
+
const errorDescription = searchParams.get("error_description");
|
|
1372
1384
|
if (error) {
|
|
1373
1385
|
const errorMsg = errorDescription || error;
|
|
1374
|
-
console.error("[OAuth
|
|
1375
|
-
|
|
1376
|
-
return;
|
|
1386
|
+
console.error("[OAuth Redirect] Error:", errorMsg);
|
|
1387
|
+
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, req.url));
|
|
1377
1388
|
}
|
|
1378
1389
|
if (!code || !state) {
|
|
1379
|
-
console.error("[OAuth
|
|
1380
|
-
|
|
1381
|
-
return;
|
|
1390
|
+
console.error("[OAuth Redirect] Missing code or state parameter");
|
|
1391
|
+
return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, req.url));
|
|
1382
1392
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
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);
|
|
1393
|
+
const targetUrl = new URL(redirectUrl, req.url);
|
|
1394
|
+
targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
|
|
1395
|
+
return Response.redirect(targetUrl);
|
|
1457
1396
|
};
|
|
1458
1397
|
}
|
|
1459
1398
|
// src/adapters/tanstack-start.ts
|
|
@@ -1690,7 +1629,7 @@ export {
|
|
|
1690
1629
|
generateCodeChallenge,
|
|
1691
1630
|
createTanStackOAuthHandler,
|
|
1692
1631
|
createSimplePlugin,
|
|
1693
|
-
|
|
1632
|
+
createOAuthRedirectHandler,
|
|
1694
1633
|
createNextOAuthHandler,
|
|
1695
1634
|
createMCPClient,
|
|
1696
1635
|
convertMCPToolsToVercelAI,
|
|
@@ -1701,7 +1640,6 @@ export {
|
|
|
1701
1640
|
OAuthWindowManager,
|
|
1702
1641
|
OAuthManager,
|
|
1703
1642
|
OAuthHandler,
|
|
1704
|
-
OAuthCallbackPage,
|
|
1705
1643
|
MCPMethod,
|
|
1706
1644
|
MCPClient,
|
|
1707
1645
|
IntegrateSDKError,
|
package/dist/server.js
CHANGED
|
@@ -699,6 +699,21 @@ class OAuthWindowManager {
|
|
|
699
699
|
let state = params.get("state");
|
|
700
700
|
let error = params.get("error");
|
|
701
701
|
let errorDescription = params.get("error_description");
|
|
702
|
+
if (!code && !error && window.location.hash) {
|
|
703
|
+
try {
|
|
704
|
+
const hash = window.location.hash.substring(1);
|
|
705
|
+
const hashParams = new URLSearchParams(hash);
|
|
706
|
+
const oauthCallback = hashParams.get("oauth_callback");
|
|
707
|
+
if (oauthCallback) {
|
|
708
|
+
const parsed = JSON.parse(decodeURIComponent(oauthCallback));
|
|
709
|
+
code = parsed.code;
|
|
710
|
+
state = parsed.state;
|
|
711
|
+
window.history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
712
|
+
}
|
|
713
|
+
} catch (e) {
|
|
714
|
+
console.error("Failed to parse OAuth callback params from hash:", e);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
702
717
|
if (!code && !error) {
|
|
703
718
|
try {
|
|
704
719
|
const stored = sessionStorage.getItem("oauth_callback_params");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js OAuth Redirect Handler
|
|
3
|
+
* Handles OAuth callback redirects and forwards parameters to the client
|
|
4
|
+
*/
|
|
5
|
+
type NextRequest = any;
|
|
6
|
+
type NextResponse = any;
|
|
7
|
+
export interface OAuthRedirectConfig {
|
|
8
|
+
/** URL to redirect to after OAuth callback (default: '/') */
|
|
9
|
+
redirectUrl?: string;
|
|
10
|
+
/** URL to redirect to on OAuth error (default: '/auth-error') */
|
|
11
|
+
errorRedirectUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create OAuth redirect handler for Next.js
|
|
15
|
+
*
|
|
16
|
+
* This handler processes OAuth callbacks from providers and redirects
|
|
17
|
+
* to your application with the OAuth parameters encoded in the URL.
|
|
18
|
+
*
|
|
19
|
+
* @param config - Redirect configuration
|
|
20
|
+
* @returns Next.js route handler
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // app/oauth/callback/route.ts
|
|
25
|
+
* import { createOAuthRedirectHandler } from 'integrate-sdk';
|
|
26
|
+
*
|
|
27
|
+
* export const GET = createOAuthRedirectHandler({
|
|
28
|
+
* redirectUrl: '/dashboard',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function createOAuthRedirectHandler(config?: OAuthRedirectConfig): (req: NextRequest) => Promise<NextResponse>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=nextjs-oauth-redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextjs-oauth-redirect.d.ts","sourceRoot":"","sources":["../../../src/adapters/nextjs-oauth-redirect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,KAAK,WAAW,GAAG,GAAG,CAAC;AACvB,KAAK,YAAY,GAAG,GAAG,CAAC;AAExB,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,CAAC,EAAE,mBAAmB,IAI3C,KAAK,WAAW,KAAG,OAAO,CAAC,YAAY,CAAC,CAkCnE"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,11 +7,12 @@ 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,
|
|
10
|
+
export type { OAuthFlowConfig, PopupOptions, AuthStatus, PendingAuth, AuthorizationUrlResponse, OAuthCallbackResponse, OAuthCallbackParams, } 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 {
|
|
14
|
+
export { createOAuthRedirectHandler } from "./adapters/nextjs-oauth-redirect.js";
|
|
15
|
+
export type { OAuthRedirectConfig } from "./adapters/nextjs-oauth-redirect.js";
|
|
15
16
|
export { createTanStackOAuthHandler } from "./adapters/tanstack-start.js";
|
|
16
17
|
export type { MCPClientConfig, ReauthContext, ReauthHandler } from "./config/types.js";
|
|
17
18
|
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,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EACV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B,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,13 +81,4 @@ 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
|
-
}
|
|
93
84
|
//# 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,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAm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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"}
|
|
@@ -64,7 +64,7 @@ export declare class OAuthWindowManager {
|
|
|
64
64
|
*/
|
|
65
65
|
private listenForPopupCallback;
|
|
66
66
|
/**
|
|
67
|
-
* Parse callback parameters from current URL or sessionStorage (for redirect flow)
|
|
67
|
+
* Parse callback parameters from current URL, hash, or sessionStorage (for redirect flow)
|
|
68
68
|
*/
|
|
69
69
|
private listenForRedirectCallback;
|
|
70
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,YA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,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "integrate-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
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
|
|
38
|
+
"build": "bun build index.ts server.ts oauth.ts --outdir dist --target node --format esm && 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,18 +58,11 @@
|
|
|
58
58
|
"license": "MIT",
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/bun": "latest",
|
|
61
|
-
"@types/react": "^18.0.0",
|
|
62
61
|
"simple-git-hooks": "^2.13.1",
|
|
63
62
|
"typescript": "^5.3.3"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
|
-
"typescript": ">=5.0.0"
|
|
67
|
-
"react": ">=18.0.0"
|
|
68
|
-
},
|
|
69
|
-
"peerDependenciesMeta": {
|
|
70
|
-
"react": {
|
|
71
|
-
"optional": true
|
|
72
|
-
}
|
|
65
|
+
"typescript": ">=5.0.0"
|
|
73
66
|
},
|
|
74
67
|
"simple-git-hooks": {
|
|
75
68
|
"pre-commit": "./scripts/check-version.sh"
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|