integrate-sdk 0.3.3 → 0.3.7

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.
Files changed (40) hide show
  1. package/dist/index.js +42 -15
  2. package/dist/server.js +42 -15
  3. package/dist/src/adapters/nextjs-callback.d.ts +44 -0
  4. package/dist/src/adapters/nextjs-callback.d.ts.map +1 -0
  5. package/dist/src/adapters/nextjs.d.ts +6 -2
  6. package/dist/src/adapters/nextjs.d.ts.map +1 -1
  7. package/dist/src/index.d.ts +1 -1
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/oauth/types.d.ts +9 -0
  10. package/dist/src/oauth/types.d.ts.map +1 -1
  11. package/dist/src/oauth/window-manager.d.ts +2 -1
  12. package/dist/src/oauth/window-manager.d.ts.map +1 -1
  13. package/package.json +15 -3
  14. package/src/adapters/auto-routes.ts +217 -0
  15. package/src/adapters/base-handler.ts +212 -0
  16. package/src/adapters/nextjs-callback.tsx +160 -0
  17. package/src/adapters/nextjs.ts +318 -0
  18. package/src/adapters/tanstack-start.ts +264 -0
  19. package/src/client.ts +952 -0
  20. package/src/config/types.ts +180 -0
  21. package/src/errors.ts +207 -0
  22. package/src/index.ts +110 -0
  23. package/src/integrations/vercel-ai.ts +104 -0
  24. package/src/oauth/manager.ts +307 -0
  25. package/src/oauth/pkce.ts +127 -0
  26. package/src/oauth/types.ts +101 -0
  27. package/src/oauth/window-manager.ts +322 -0
  28. package/src/plugins/generic.ts +119 -0
  29. package/src/plugins/github-client.ts +345 -0
  30. package/src/plugins/github.ts +122 -0
  31. package/src/plugins/gmail-client.ts +114 -0
  32. package/src/plugins/gmail.ts +108 -0
  33. package/src/plugins/server-client.ts +20 -0
  34. package/src/plugins/types.ts +89 -0
  35. package/src/protocol/jsonrpc.ts +88 -0
  36. package/src/protocol/messages.ts +145 -0
  37. package/src/server.ts +117 -0
  38. package/src/transport/http-session.ts +322 -0
  39. package/src/transport/http-stream.ts +331 -0
  40. package/src/utils/naming.ts +52 -0
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 action = context.params.action;
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 action = context.params.action;
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.popupCheckInterval = setInterval(() => {
672
- if (this.popupWindow?.closed) {
673
- clearTimeout(timeout);
674
- clearInterval(this.popupCheckInterval);
675
- window.removeEventListener("message", messageHandler);
676
- this.cleanup();
677
- reject(new Error("OAuth popup was closed by user"));
678
- }
679
- }, 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);
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
- const code = params.get("code");
689
- const state = params.get("state");
690
- const error = params.get("error");
691
- 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
+ }
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();
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 action = context.params.action;
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 action = context.params.action;
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.popupCheckInterval = setInterval(() => {
672
- if (this.popupWindow?.closed) {
673
- clearTimeout(timeout);
674
- clearInterval(this.popupCheckInterval);
675
- window.removeEventListener("message", messageHandler);
676
- this.cleanup();
677
- reject(new Error("OAuth popup was closed by user"));
678
- }
679
- }, 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);
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
- const code = params.get("code");
689
- const state = params.get("state");
690
- const error = params.get("error");
691
- 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
+ }
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,44 @@
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/oauth-callback';
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
+ * import { createOAuthCallbackPage } from 'integrate-sdk/oauth-callback';
37
+ *
38
+ * export default createOAuthCallbackPage({
39
+ * redirectUrl: '/dashboard',
40
+ * });
41
+ * ```
42
+ */
43
+ export declare function createOAuthCallbackPage(config?: OAuthCallbackHandlerConfig): () => import("react/jsx-runtime").JSX.Element;
44
+ //# 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;;;;;;;;;;;;GAYG;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,GACtC,OAAO,CAAC,YAAY,CAAC;QAiBxB;;WAEG;iBAEI,WAAW,WACP;YAAE,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,GACtC,OAAO,CAAC,YAAY,CAAC;;EAiB/B"}
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"}
@@ -7,7 +7,7 @@ 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";
@@ -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,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,SAAS,EAC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;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,G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,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,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI;IAwC7D;;;;;;;;;;OAUG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQ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,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",
3
+ "version": "0.3.7",
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",
@@ -26,16 +26,21 @@
26
26
  "./oauth": {
27
27
  "import": "./dist/oauth.js",
28
28
  "types": "./dist/oauth.d.ts"
29
+ },
30
+ "./oauth-callback": {
31
+ "import": "./src/adapters/nextjs-callback.tsx",
32
+ "types": "./dist/adapters/nextjs-callback.d.ts"
29
33
  }
30
34
  },
31
35
  "files": [
32
36
  "dist",
37
+ "src",
33
38
  "index.ts",
34
39
  "server.ts",
35
40
  "oauth.ts"
36
41
  ],
37
42
  "scripts": {
38
- "build": "bun build index.ts server.ts oauth.ts --outdir dist --target node --format esm && bun run build:types",
43
+ "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
44
  "build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
40
45
  "dev": "bun --watch src/index.ts",
41
46
  "type-check": "tsc --noEmit",
@@ -58,11 +63,18 @@
58
63
  "license": "MIT",
59
64
  "devDependencies": {
60
65
  "@types/bun": "latest",
66
+ "@types/react": "^18.0.0",
61
67
  "simple-git-hooks": "^2.13.1",
62
68
  "typescript": "^5.3.3"
63
69
  },
64
70
  "peerDependencies": {
65
- "typescript": ">=5.0.0"
71
+ "typescript": ">=5.0.0",
72
+ "react": ">=18.0.0"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "react": {
76
+ "optional": true
77
+ }
66
78
  },
67
79
  "simple-git-hooks": {
68
80
  "pre-commit": "./scripts/check-version.sh"
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Auto-generated OAuth Routes
3
+ * Automatically creates the correct route handlers based on framework detection
4
+ */
5
+
6
+ import { OAuthHandler, type OAuthHandlerConfig } from './base-handler.js';
7
+
8
+ /**
9
+ * Global OAuth configuration
10
+ * Set by createMCPClient when oauthConfig is provided
11
+ */
12
+ let globalOAuthConfig: OAuthHandlerConfig | null = null;
13
+
14
+ /**
15
+ * Set the global OAuth configuration
16
+ * Called internally by createMCPClient
17
+ */
18
+ export function setGlobalOAuthConfig(config: OAuthHandlerConfig): void {
19
+ globalOAuthConfig = config;
20
+ }
21
+
22
+ /**
23
+ * Get the global OAuth configuration
24
+ */
25
+ export function getGlobalOAuthConfig(): OAuthHandlerConfig | null {
26
+ return globalOAuthConfig;
27
+ }
28
+
29
+ /**
30
+ * Universal OAuth route handler
31
+ * Automatically detects framework and handles all OAuth actions
32
+ *
33
+ * This is the magic function that makes everything "just work"
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * // app/api/integrate/oauth/[action]/route.ts (Next.js)
38
+ * export * from 'integrate-sdk/oauth';
39
+ * ```
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // app/routes/api/integrate/oauth/[action].ts (TanStack Start)
44
+ * export * from 'integrate-sdk/oauth';
45
+ * ```
46
+ */
47
+
48
+ // Framework detection helpers (unused but kept for future enhancements)
49
+ // function isNextJS(request: any): boolean {
50
+ // return (
51
+ // request?.constructor?.name === 'NextRequest' ||
52
+ // typeof request?.nextUrl !== 'undefined' ||
53
+ // typeof (globalThis as any).NextResponse !== 'undefined'
54
+ // );
55
+ // }
56
+
57
+ // function isTanStackStart(request: any): boolean {
58
+ // return (
59
+ // request instanceof Request &&
60
+ // !isNextJS(request)
61
+ // );
62
+ // }
63
+
64
+ /**
65
+ * Universal POST handler
66
+ * Handles authorize and callback actions
67
+ */
68
+ export async function POST(
69
+ req: any,
70
+ context?: { params: { action: string } }
71
+ ): Promise<any> {
72
+ if (!globalOAuthConfig) {
73
+ throw new Error(
74
+ 'OAuth configuration not found. Did you configure oauthProviders in createMCPClient?'
75
+ );
76
+ }
77
+
78
+ const handler = new OAuthHandler(globalOAuthConfig);
79
+ const action = context?.params?.action;
80
+
81
+ if (!action) {
82
+ return createErrorResponse('Missing action parameter', 400);
83
+ }
84
+
85
+ try {
86
+ if (action === 'authorize') {
87
+ const body = await parseRequestBody(req);
88
+ const result = await handler.handleAuthorize(body);
89
+ return createSuccessResponse(result);
90
+ }
91
+
92
+ if (action === 'callback') {
93
+ const body = await parseRequestBody(req);
94
+ const result = await handler.handleCallback(body);
95
+ return createSuccessResponse(result);
96
+ }
97
+
98
+ return createErrorResponse(`Unknown action: ${action}`, 404);
99
+ } catch (error: any) {
100
+ console.error(`[OAuth ${action}] Error:`, error);
101
+ return createErrorResponse(error.message, 500);
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Universal GET handler
107
+ * Handles status action
108
+ */
109
+ export async function GET(
110
+ req: any,
111
+ context?: { params: { action: string } }
112
+ ): Promise<any> {
113
+ if (!globalOAuthConfig) {
114
+ throw new Error(
115
+ 'OAuth configuration not found. Did you configure oauthProviders in createMCPClient?'
116
+ );
117
+ }
118
+
119
+ const handler = new OAuthHandler(globalOAuthConfig);
120
+ const action = context?.params?.action;
121
+
122
+ if (!action) {
123
+ return createErrorResponse('Missing action parameter', 400);
124
+ }
125
+
126
+ try {
127
+ if (action === 'status') {
128
+ const { provider, sessionToken } = parseQueryParams(req);
129
+
130
+ if (!provider || !sessionToken) {
131
+ return createErrorResponse(
132
+ 'Missing provider or session token',
133
+ 400
134
+ );
135
+ }
136
+
137
+ const result = await handler.handleStatus(provider, sessionToken);
138
+ return createSuccessResponse(result);
139
+ }
140
+
141
+ return createErrorResponse(`Unknown action: ${action}`, 404);
142
+ } catch (error: any) {
143
+ console.error(`[OAuth ${action}] Error:`, error);
144
+ return createErrorResponse(error.message, 500);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Parse request body (works for both Next.js and standard Request)
150
+ */
151
+ async function parseRequestBody(req: any): Promise<any> {
152
+ if (typeof req.json === 'function') {
153
+ return await req.json();
154
+ }
155
+ throw new Error('Unable to parse request body');
156
+ }
157
+
158
+ /**
159
+ * Parse query parameters (works for both Next.js and standard Request)
160
+ */
161
+ function parseQueryParams(req: any): { provider?: string; sessionToken?: string } {
162
+ let url: URL;
163
+
164
+ // Next.js
165
+ if (req.nextUrl) {
166
+ url = new URL(req.nextUrl);
167
+ }
168
+ // Standard Request
169
+ else if (req.url) {
170
+ url = new URL(req.url);
171
+ } else {
172
+ return {};
173
+ }
174
+
175
+ const provider = url.searchParams.get('provider') || undefined;
176
+ const sessionToken = req.headers?.get?.('x-session-token') || undefined;
177
+
178
+ return { provider, sessionToken };
179
+ }
180
+
181
+ /**
182
+ * Create success response (works for both frameworks)
183
+ */
184
+ function createSuccessResponse(data: any): any {
185
+ // Try Next.js first
186
+ if (typeof (globalThis as any).NextResponse !== 'undefined') {
187
+ const NextResponse = (globalThis as any).NextResponse;
188
+ return NextResponse.json(data);
189
+ }
190
+
191
+ // Fallback to standard Response
192
+ return new Response(JSON.stringify(data), {
193
+ status: 200,
194
+ headers: { 'Content-Type': 'application/json' },
195
+ });
196
+ }
197
+
198
+ /**
199
+ * Create error response (works for both frameworks)
200
+ */
201
+ function createErrorResponse(message: string, status: number): any {
202
+ // Try Next.js first
203
+ if (typeof (globalThis as any).NextResponse !== 'undefined') {
204
+ const NextResponse = (globalThis as any).NextResponse;
205
+ return NextResponse.json({ error: message }, { status });
206
+ }
207
+
208
+ // Fallback to standard Response
209
+ return new Response(
210
+ JSON.stringify({ error: message }),
211
+ {
212
+ status,
213
+ headers: { 'Content-Type': 'application/json' },
214
+ }
215
+ );
216
+ }
217
+