integrate-sdk 0.5.8 → 0.5.9
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/README.md +3 -1
- package/dist/server.js +20 -11
- package/dist/src/server.d.ts +30 -1
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,14 +62,16 @@ That's it! Just import and export:
|
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
// app/api/integrate/[...all]/route.ts
|
|
65
|
+
import { serverClient } from "@/lib/integrate-server";
|
|
65
66
|
import { toNextJsHandler } from "integrate-sdk/server";
|
|
66
67
|
|
|
67
68
|
export const { POST, GET } = toNextJsHandler({
|
|
69
|
+
client: serverClient, // Pass the client
|
|
68
70
|
redirectUrl: "/dashboard",
|
|
69
71
|
});
|
|
70
72
|
```
|
|
71
73
|
|
|
72
|
-
This
|
|
74
|
+
This imports your config from step 1 and handles ALL OAuth operations (authorize, callback, status, disconnect) in one file!
|
|
73
75
|
|
|
74
76
|
### 3. Use in Your App
|
|
75
77
|
|
package/dist/server.js
CHANGED
|
@@ -1992,6 +1992,7 @@ function createMCPServer(config) {
|
|
|
1992
1992
|
singleton: config.singleton ?? true
|
|
1993
1993
|
};
|
|
1994
1994
|
const client = new MCPClient(clientConfig);
|
|
1995
|
+
client.__oauthConfig = { providers };
|
|
1995
1996
|
const { POST, GET } = createOAuthRouteHandlers({ providers });
|
|
1996
1997
|
return {
|
|
1997
1998
|
client,
|
|
@@ -2019,21 +2020,29 @@ var GET = async (req, context) => {
|
|
|
2019
2020
|
const routes = handler.createRoutes();
|
|
2020
2021
|
return routes.GET(req, context);
|
|
2021
2022
|
};
|
|
2022
|
-
function toNextJsHandler(
|
|
2023
|
+
function toNextJsHandler(options) {
|
|
2023
2024
|
const POST2 = async (req, context) => {
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
const
|
|
2025
|
+
const config = options.config || options.client?.__oauthConfig;
|
|
2026
|
+
if (!config) {
|
|
2027
|
+
return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
|
|
2028
|
+
}
|
|
2029
|
+
const handler = createNextOAuthHandler(config);
|
|
2030
|
+
const routes = handler.toNextJsHandler({
|
|
2031
|
+
redirectUrl: options.redirectUrl,
|
|
2032
|
+
errorRedirectUrl: options.errorRedirectUrl
|
|
2033
|
+
});
|
|
2029
2034
|
return routes.POST(req, context);
|
|
2030
2035
|
};
|
|
2031
2036
|
const GET2 = async (req, context) => {
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
const
|
|
2037
|
+
const config = options.config || options.client?.__oauthConfig;
|
|
2038
|
+
if (!config) {
|
|
2039
|
+
return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
|
|
2040
|
+
}
|
|
2041
|
+
const handler = createNextOAuthHandler(config);
|
|
2042
|
+
const routes = handler.toNextJsHandler({
|
|
2043
|
+
redirectUrl: options.redirectUrl,
|
|
2044
|
+
errorRedirectUrl: options.errorRedirectUrl
|
|
2045
|
+
});
|
|
2037
2046
|
return routes.GET(req, context);
|
|
2038
2047
|
};
|
|
2039
2048
|
return { POST: POST2, GET: GET2 };
|
package/dist/src/server.d.ts
CHANGED
|
@@ -146,15 +146,44 @@ export declare const GET: (req: any, context: {
|
|
|
146
146
|
* });
|
|
147
147
|
*
|
|
148
148
|
* // app/api/integrate/[...all]/route.ts
|
|
149
|
+
*
|
|
150
|
+
* // RECOMMENDED: Import serverClient from your server setup file
|
|
151
|
+
* import { serverClient } from '@/lib/integrate-server';
|
|
149
152
|
* import { toNextJsHandler } from 'integrate-sdk/server';
|
|
150
153
|
*
|
|
151
154
|
* export const { POST, GET } = toNextJsHandler({
|
|
155
|
+
* client: serverClient, // Pass the client from createMCPServer
|
|
156
|
+
* redirectUrl: '/dashboard',
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* // Alternative: Provide config inline
|
|
160
|
+
* export const { POST, GET } = toNextJsHandler({
|
|
161
|
+
* config: {
|
|
162
|
+
* providers: {
|
|
163
|
+
* github: {
|
|
164
|
+
* clientId: process.env.GITHUB_CLIENT_ID!,
|
|
165
|
+
* clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
166
|
+
* },
|
|
167
|
+
* },
|
|
168
|
+
* },
|
|
152
169
|
* redirectUrl: '/dashboard',
|
|
153
170
|
* });
|
|
154
171
|
* ```
|
|
155
172
|
*/
|
|
156
|
-
export declare function toNextJsHandler(
|
|
173
|
+
export declare function toNextJsHandler(options: {
|
|
174
|
+
/** Server client instance from createMCPServer (extracts config automatically) */
|
|
175
|
+
client?: any;
|
|
176
|
+
/** Custom OAuth handler config (provide inline) */
|
|
177
|
+
config?: {
|
|
178
|
+
providers: Record<string, {
|
|
179
|
+
clientId: string;
|
|
180
|
+
clientSecret: string;
|
|
181
|
+
redirectUri?: string;
|
|
182
|
+
}>;
|
|
183
|
+
};
|
|
184
|
+
/** URL to redirect to after successful OAuth */
|
|
157
185
|
redirectUrl?: string;
|
|
186
|
+
/** URL to redirect to on OAuth error */
|
|
158
187
|
errorRedirectUrl?: string;
|
|
159
188
|
}): {
|
|
160
189
|
POST: (req: any, context: {
|
package/dist/src/server.d.ts.map
CHANGED
|
@@ -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;AAyCpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,e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