integrate-sdk 0.2.3 → 0.3.1
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 +164 -77
- package/dist/adapters/auto-routes.d.ts +51 -0
- package/dist/adapters/auto-routes.d.ts.map +1 -0
- package/dist/adapters/base-handler.d.ts +106 -0
- package/dist/adapters/base-handler.d.ts.map +1 -0
- package/dist/adapters/nextjs.d.ts +223 -0
- package/dist/adapters/nextjs.d.ts.map +1 -0
- package/dist/adapters/tanstack-start.d.ts +169 -0
- package/dist/adapters/tanstack-start.d.ts.map +1 -0
- package/dist/client.d.ts +93 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/config/types.d.ts +60 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/oauth/manager.d.ts +93 -0
- package/dist/oauth/manager.d.ts.map +1 -0
- package/dist/oauth/pkce.d.ts +47 -0
- package/dist/oauth/pkce.d.ts.map +1 -0
- package/dist/oauth/types.d.ts +84 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/window-manager.d.ts +103 -0
- package/dist/oauth/window-manager.d.ts.map +1 -0
- package/dist/oauth.js +194 -0
- package/dist/plugins/github.d.ts +24 -7
- package/dist/plugins/github.d.ts.map +1 -1
- package/dist/plugins/gmail.d.ts +25 -7
- package/dist/plugins/gmail.d.ts.map +1 -1
- package/dist/plugins/types.d.ts +16 -4
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/server.d.ts +54 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/src/index.js +1556 -0
- package/dist/{index.js → src/server.js} +617 -41
- package/dist/transport/http-session.d.ts +23 -0
- package/dist/transport/http-session.d.ts.map +1 -1
- package/oauth.ts +20 -0
- package/package.json +17 -7
- package/server.ts +12 -0
package/README.md
CHANGED
|
@@ -12,8 +12,9 @@ A type-safe TypeScript SDK for connecting to the Integrate MCP (Model Context Pr
|
|
|
12
12
|
- 🔌 **Plugin-Based Architecture** - Enable only the integrations you need
|
|
13
13
|
- 🔒 **Fully Typed API** - Type-safe methods with autocomplete (e.g., `client.github.createIssue()`)
|
|
14
14
|
- 💡 **IntelliSense Support** - Full TypeScript support with parameter hints
|
|
15
|
-
-
|
|
16
|
-
- 🔐 **OAuth
|
|
15
|
+
- ⚡ **Automatic Connection Management** - Lazy connection, auto-cleanup, singleton pattern
|
|
16
|
+
- 🔐 **Complete OAuth Flow** - Built-in OAuth 2.0 with PKCE (popup/redirect modes)
|
|
17
|
+
- 🌍 **Universal** - Works in browser and Node.js environments
|
|
17
18
|
- 🛠️ **Extensible** - Configure plugins for any server-supported integration
|
|
18
19
|
- 📦 **Zero Dependencies** - Lightweight implementation
|
|
19
20
|
|
|
@@ -27,44 +28,135 @@ bun add integrate-sdk
|
|
|
27
28
|
|
|
28
29
|
## Quick Start
|
|
29
30
|
|
|
31
|
+
### Server-Side Setup
|
|
32
|
+
|
|
33
|
+
First, create your server configuration with OAuth secrets:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// lib/integrate-server.ts (server-side only!)
|
|
37
|
+
import { createMCPServer, githubPlugin, gmailPlugin } from 'integrate-sdk/server';
|
|
38
|
+
|
|
39
|
+
export const { client: serverClient, handlers } = createMCPServer({
|
|
40
|
+
plugins: [
|
|
41
|
+
githubPlugin({
|
|
42
|
+
clientId: process.env.GITHUB_CLIENT_ID,
|
|
43
|
+
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
|
44
|
+
scopes: ['repo', 'user'],
|
|
45
|
+
}),
|
|
46
|
+
gmailPlugin({
|
|
47
|
+
clientId: process.env.GMAIL_CLIENT_ID,
|
|
48
|
+
clientSecret: process.env.GMAIL_CLIENT_SECRET,
|
|
49
|
+
scopes: ['gmail.readonly'],
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Create OAuth route (handles authorization automatically):
|
|
56
|
+
|
|
30
57
|
```typescript
|
|
31
|
-
|
|
58
|
+
// app/api/integrate/oauth/[action]/route.ts
|
|
59
|
+
export * from 'integrate-sdk/oauth';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Use the server client in API routes or server components:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// app/api/repos/route.ts
|
|
66
|
+
import { serverClient } from '@/lib/integrate-server';
|
|
67
|
+
|
|
68
|
+
export async function GET() {
|
|
69
|
+
// Automatically connects on first call - no manual setup needed!
|
|
70
|
+
const repos = await serverClient.github.listOwnRepos({ per_page: 10 });
|
|
71
|
+
return Response.json({ repos });
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Client-Side Setup
|
|
76
|
+
|
|
77
|
+
Use in your client components (no secrets needed):
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
'use client';
|
|
81
|
+
import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
32
82
|
|
|
33
|
-
// Create a client with plugins
|
|
34
83
|
const client = createMCPClient({
|
|
35
84
|
plugins: [
|
|
36
85
|
githubPlugin({
|
|
37
|
-
|
|
38
|
-
clientSecret
|
|
39
|
-
scopes: ["repo", "user"],
|
|
86
|
+
scopes: ['repo', 'user'],
|
|
87
|
+
// No clientId or clientSecret needed!
|
|
40
88
|
}),
|
|
41
89
|
],
|
|
90
|
+
oauthFlow: { mode: 'popup' },
|
|
42
91
|
});
|
|
43
92
|
|
|
44
|
-
//
|
|
45
|
-
await client.
|
|
93
|
+
// Authorize user (opens popup)
|
|
94
|
+
await client.authorize('github');
|
|
46
95
|
|
|
47
|
-
//
|
|
96
|
+
// Use the client - automatically connects!
|
|
48
97
|
const result = await client.github.createIssue({
|
|
49
|
-
owner:
|
|
50
|
-
repo:
|
|
51
|
-
title:
|
|
52
|
-
body:
|
|
98
|
+
owner: 'owner',
|
|
99
|
+
repo: 'repo',
|
|
100
|
+
title: 'Bug report',
|
|
101
|
+
body: 'Description of the bug',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log('Issue created:', result);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**That's it!** The SDK automatically:
|
|
108
|
+
- ✅ Connects on first method call (no manual `connect()` needed)
|
|
109
|
+
- ✅ Cleans up on exit (no manual `disconnect()` needed)
|
|
110
|
+
- ✅ Manages OAuth tokens securely through your API routes
|
|
111
|
+
- ✅ Provides full type safety with autocomplete
|
|
112
|
+
|
|
113
|
+
### Connection Management
|
|
114
|
+
|
|
115
|
+
The SDK automatically manages connections for you - no manual `connect()` or `disconnect()` calls needed!
|
|
116
|
+
|
|
117
|
+
**Features:**
|
|
118
|
+
- **Lazy Connection**: Automatically connects on first method call
|
|
119
|
+
- **Auto-Cleanup**: Cleans up on process exit
|
|
120
|
+
- **Singleton Pattern**: Reuses connections efficiently (configurable)
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// ✅ Default behavior - automatic connection
|
|
124
|
+
const client = createMCPClient({
|
|
125
|
+
plugins: [
|
|
126
|
+
githubPlugin({
|
|
127
|
+
scopes: ['repo', 'user'],
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
53
130
|
});
|
|
54
131
|
|
|
55
|
-
|
|
132
|
+
// Use immediately - no connect() needed!
|
|
133
|
+
await client.authorize('github');
|
|
134
|
+
await client.github.listRepos({ username: 'octocat' });
|
|
56
135
|
|
|
57
|
-
//
|
|
58
|
-
const
|
|
59
|
-
|
|
136
|
+
// ✅ Want manual control? Use manual mode
|
|
137
|
+
const manualClient = createMCPClient({
|
|
138
|
+
plugins: [githubPlugin({ scopes: ['repo'] })],
|
|
139
|
+
connectionMode: 'manual',
|
|
140
|
+
singleton: false,
|
|
60
141
|
});
|
|
61
142
|
|
|
62
|
-
|
|
63
|
-
await
|
|
143
|
+
await manualClient.connect();
|
|
144
|
+
await manualClient.authorize('github');
|
|
145
|
+
await manualClient.github.listRepos({ username: 'octocat' });
|
|
146
|
+
await manualClient.disconnect();
|
|
64
147
|
```
|
|
65
148
|
|
|
66
149
|
**Need help?** Check out the [complete documentation](https://integrate.dev) for detailed guides, examples, and API reference.
|
|
67
150
|
|
|
151
|
+
## Browser & Server Support
|
|
152
|
+
|
|
153
|
+
The SDK works in both environments:
|
|
154
|
+
|
|
155
|
+
- **Browser**: Use `createMCPClient()` from `'integrate-sdk'` - handles OAuth UI (popup/redirect)
|
|
156
|
+
- **Server**: Use `createMCPServer()` from `'integrate-sdk/server'` - includes OAuth secrets for API routes
|
|
157
|
+
|
|
158
|
+
See [Quick Start](#quick-start) above for complete examples.
|
|
159
|
+
|
|
68
160
|
## Why Use Integrate SDK?
|
|
69
161
|
|
|
70
162
|
### Typed Plugin Methods
|
|
@@ -98,88 +190,82 @@ await client.server.listToolsByIntegration({ integration: "github" });
|
|
|
98
190
|
await client._callToolByName("slack_send_message", { channel: "#general", text: "Hello" });
|
|
99
191
|
```
|
|
100
192
|
|
|
101
|
-
##
|
|
193
|
+
## OAuth Authorization
|
|
102
194
|
|
|
103
|
-
|
|
195
|
+
The SDK implements OAuth 2.0 Authorization Code Flow with PKCE for secure authorization.
|
|
104
196
|
|
|
105
|
-
|
|
197
|
+
**Key Features:**
|
|
198
|
+
- ✅ Popup or redirect flow modes
|
|
199
|
+
- ✅ Session token management
|
|
200
|
+
- ✅ Multiple provider support
|
|
201
|
+
- ✅ PKCE security
|
|
106
202
|
|
|
203
|
+
**Basic Usage:**
|
|
107
204
|
```typescript
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
113
|
-
scopes: ["repo", "user"],
|
|
114
|
-
}),
|
|
115
|
-
],
|
|
116
|
-
});
|
|
205
|
+
// Check authorization
|
|
206
|
+
if (!await client.isAuthorized('github')) {
|
|
207
|
+
await client.authorize('github'); // Opens popup or redirects
|
|
208
|
+
}
|
|
117
209
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// Use typed methods
|
|
121
|
-
await client.github.getRepo({ owner: "facebook", repo: "react" });
|
|
122
|
-
await client.github.createIssue({ owner: "user", repo: "repo", title: "Bug" });
|
|
123
|
-
await client.github.listPullRequests({ owner: "user", repo: "repo", state: "open" });
|
|
210
|
+
// Use authorized client
|
|
211
|
+
const repos = await client.github.listOwnRepos({});
|
|
124
212
|
```
|
|
125
213
|
|
|
126
|
-
|
|
214
|
+
For complete OAuth setup including:
|
|
215
|
+
- Popup vs redirect flows
|
|
216
|
+
- Session token management
|
|
217
|
+
- Multiple providers
|
|
218
|
+
- Callback page setup
|
|
127
219
|
|
|
128
|
-
|
|
220
|
+
See the [`/examples`](/examples) directory or [OAuth documentation](https://integrate.dev/docs/guides/oauth-flow).
|
|
129
221
|
|
|
130
|
-
|
|
222
|
+
## Built-in Plugins
|
|
131
223
|
|
|
132
|
-
|
|
133
|
-
const client = createMCPClient({
|
|
134
|
-
plugins: [
|
|
135
|
-
gmailPlugin({
|
|
136
|
-
clientId: process.env.GMAIL_CLIENT_ID!,
|
|
137
|
-
clientSecret: process.env.GMAIL_CLIENT_SECRET!,
|
|
138
|
-
}),
|
|
139
|
-
],
|
|
140
|
-
});
|
|
224
|
+
### GitHub Plugin
|
|
141
225
|
|
|
142
|
-
|
|
226
|
+
Access GitHub repositories, issues, pull requests, and more with type-safe methods.
|
|
143
227
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
await client.
|
|
147
|
-
await client.
|
|
228
|
+
```typescript
|
|
229
|
+
// Available methods
|
|
230
|
+
await client.github.getRepo({ owner: 'facebook', repo: 'react' });
|
|
231
|
+
await client.github.createIssue({ owner: 'user', repo: 'repo', title: 'Bug' });
|
|
232
|
+
await client.github.listPullRequests({ owner: 'user', repo: 'repo', state: 'open' });
|
|
233
|
+
await client.github.listOwnRepos({});
|
|
148
234
|
```
|
|
149
235
|
|
|
150
|
-
[→
|
|
236
|
+
[→ GitHub plugin documentation](https://integrate.dev/docs/plugins/github)
|
|
151
237
|
|
|
152
|
-
###
|
|
238
|
+
### Gmail Plugin
|
|
153
239
|
|
|
154
|
-
|
|
240
|
+
Send emails, manage labels, and search messages with type-safe methods.
|
|
155
241
|
|
|
156
242
|
```typescript
|
|
157
|
-
|
|
243
|
+
// Available methods
|
|
244
|
+
await client.gmail.sendEmail({ to: 'user@example.com', subject: 'Hello', body: 'Hi!' });
|
|
245
|
+
await client.gmail.listEmails({ maxResults: 10, q: 'is:unread' });
|
|
246
|
+
await client.gmail.searchEmails({ query: 'from:notifications@github.com' });
|
|
247
|
+
```
|
|
158
248
|
|
|
159
|
-
|
|
160
|
-
const slackPlugin = genericOAuthPlugin({
|
|
161
|
-
id: "slack",
|
|
162
|
-
provider: "slack",
|
|
163
|
-
clientId: process.env.SLACK_CLIENT_ID!,
|
|
164
|
-
clientSecret: process.env.SLACK_CLIENT_SECRET!,
|
|
165
|
-
scopes: ["chat:write", "channels:read"],
|
|
166
|
-
tools: ["slack_send_message", "slack_list_channels"], // Must exist on server
|
|
167
|
-
});
|
|
249
|
+
[→ Gmail plugin documentation](https://integrate.dev/docs/plugins/gmail)
|
|
168
250
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
251
|
+
### Additional Integrations
|
|
252
|
+
|
|
253
|
+
Use `genericOAuthPlugin` to configure any server-supported integration:
|
|
172
254
|
|
|
173
|
-
|
|
255
|
+
```typescript
|
|
256
|
+
import { genericOAuthPlugin } from 'integrate-sdk/server';
|
|
174
257
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
258
|
+
const slackPlugin = genericOAuthPlugin({
|
|
259
|
+
id: 'slack',
|
|
260
|
+
provider: 'slack',
|
|
261
|
+
clientId: process.env.SLACK_CLIENT_ID,
|
|
262
|
+
clientSecret: process.env.SLACK_CLIENT_SECRET,
|
|
263
|
+
scopes: ['chat:write', 'channels:read'],
|
|
264
|
+
tools: ['slack_send_message', 'slack_list_channels'],
|
|
179
265
|
});
|
|
180
266
|
```
|
|
181
267
|
|
|
182
|
-
|
|
268
|
+
See [`/examples`](/examples) for complete setup patterns.
|
|
183
269
|
|
|
184
270
|
## Vercel AI SDK Integration
|
|
185
271
|
|
|
@@ -209,6 +295,7 @@ const result = await generateText({
|
|
|
209
295
|
For detailed guides, API reference, and examples, visit the [complete documentation](https://integrate.dev):
|
|
210
296
|
|
|
211
297
|
- **[Getting Started](https://integrate.dev/docs/getting-started/installation)** - Installation and quick start
|
|
298
|
+
- **[OAuth Flow](https://integrate.dev/docs/guides/oauth-flow)** - OAuth 2.0 authorization guide
|
|
212
299
|
- **[Plugins](https://integrate.dev/docs/plugins)** - Built-in plugins and configuration
|
|
213
300
|
- **[Vercel AI SDK](https://integrate.dev/docs/integrations/vercel-ai)** - AI model integration
|
|
214
301
|
- **[Advanced Usage](https://integrate.dev/docs/guides/advanced-usage)** - Error handling, retries, and more
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated OAuth Routes
|
|
3
|
+
* Automatically creates the correct route handlers based on framework detection
|
|
4
|
+
*/
|
|
5
|
+
import { type OAuthHandlerConfig } from './base-handler.js';
|
|
6
|
+
/**
|
|
7
|
+
* Set the global OAuth configuration
|
|
8
|
+
* Called internally by createMCPClient
|
|
9
|
+
*/
|
|
10
|
+
export declare function setGlobalOAuthConfig(config: OAuthHandlerConfig): void;
|
|
11
|
+
/**
|
|
12
|
+
* Get the global OAuth configuration
|
|
13
|
+
*/
|
|
14
|
+
export declare function getGlobalOAuthConfig(): OAuthHandlerConfig | null;
|
|
15
|
+
/**
|
|
16
|
+
* Universal OAuth route handler
|
|
17
|
+
* Automatically detects framework and handles all OAuth actions
|
|
18
|
+
*
|
|
19
|
+
* This is the magic function that makes everything "just work"
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // app/api/integrate/oauth/[action]/route.ts (Next.js)
|
|
24
|
+
* export * from 'integrate-sdk/oauth';
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // app/routes/api/integrate/oauth/[action].ts (TanStack Start)
|
|
30
|
+
* export * from 'integrate-sdk/oauth';
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Universal POST handler
|
|
35
|
+
* Handles authorize and callback actions
|
|
36
|
+
*/
|
|
37
|
+
export declare function POST(req: any, context?: {
|
|
38
|
+
params: {
|
|
39
|
+
action: string;
|
|
40
|
+
};
|
|
41
|
+
}): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* Universal GET handler
|
|
44
|
+
* Handles status action
|
|
45
|
+
*/
|
|
46
|
+
export declare function GET(req: any, context?: {
|
|
47
|
+
params: {
|
|
48
|
+
action: string;
|
|
49
|
+
};
|
|
50
|
+
}): Promise<any>;
|
|
51
|
+
//# sourceMappingURL=auto-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-routes.d.ts","sourceRoot":"","sources":["../../src/adapters/auto-routes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAQ1E;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,GAAG,IAAI,CAEhE;AAED;;;;;;;;;;;;;;;;;GAiBG;AAkBH;;;GAGG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,GAAG,EACR,OAAO,CAAC,EAAE;IAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACvC,OAAO,CAAC,GAAG,CAAC,CAgCd;AAED;;;GAGG;AACH,wBAAsB,GAAG,CACvB,GAAG,EAAE,GAAG,EACR,OAAO,CAAC,EAAE;IAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACvC,OAAO,CAAC,GAAG,CAAC,CAkCd"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base OAuth Handler
|
|
3
|
+
* Framework-agnostic OAuth route logic for secure server-side token management
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* OAuth handler configuration
|
|
7
|
+
* OAuth credentials for each provider
|
|
8
|
+
*/
|
|
9
|
+
export interface OAuthHandlerConfig {
|
|
10
|
+
/** OAuth configurations by provider */
|
|
11
|
+
providers: Record<string, {
|
|
12
|
+
/** OAuth client ID from environment variables */
|
|
13
|
+
clientId: string;
|
|
14
|
+
/** OAuth client secret from environment variables */
|
|
15
|
+
clientSecret: string;
|
|
16
|
+
/** Optional redirect URI override */
|
|
17
|
+
redirectUri?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Request body for authorize endpoint
|
|
22
|
+
*/
|
|
23
|
+
export interface AuthorizeRequest {
|
|
24
|
+
provider: string;
|
|
25
|
+
scopes: string[];
|
|
26
|
+
state: string;
|
|
27
|
+
codeChallenge: string;
|
|
28
|
+
codeChallengeMethod: string;
|
|
29
|
+
redirectUri?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Response from authorize endpoint
|
|
33
|
+
*/
|
|
34
|
+
export interface AuthorizeResponse {
|
|
35
|
+
authorizationUrl: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Request body for callback endpoint
|
|
39
|
+
*/
|
|
40
|
+
export interface CallbackRequest {
|
|
41
|
+
provider: string;
|
|
42
|
+
code: string;
|
|
43
|
+
codeVerifier: string;
|
|
44
|
+
state: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Response from callback endpoint
|
|
48
|
+
*/
|
|
49
|
+
export interface CallbackResponse {
|
|
50
|
+
sessionToken: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
scopes: string[];
|
|
53
|
+
expiresAt?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Response from status endpoint
|
|
57
|
+
*/
|
|
58
|
+
export interface StatusResponse {
|
|
59
|
+
authorized: boolean;
|
|
60
|
+
provider: string;
|
|
61
|
+
scopes?: string[];
|
|
62
|
+
expiresAt?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* OAuth Handler
|
|
66
|
+
* Handles OAuth authorization flows by proxying requests to MCP server
|
|
67
|
+
* with server-side OAuth credentials from environment variables
|
|
68
|
+
*/
|
|
69
|
+
export declare class OAuthHandler {
|
|
70
|
+
private config;
|
|
71
|
+
private readonly serverUrl;
|
|
72
|
+
constructor(config: OAuthHandlerConfig);
|
|
73
|
+
/**
|
|
74
|
+
* Handle authorization URL request
|
|
75
|
+
* Gets authorization URL from MCP server with full OAuth credentials
|
|
76
|
+
*
|
|
77
|
+
* @param request - Authorization request from client
|
|
78
|
+
* @returns Authorization URL to redirect/open for user
|
|
79
|
+
*
|
|
80
|
+
* @throws Error if provider is not configured
|
|
81
|
+
* @throws Error if MCP server request fails
|
|
82
|
+
*/
|
|
83
|
+
handleAuthorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Handle OAuth callback
|
|
86
|
+
* Exchanges authorization code for session token
|
|
87
|
+
*
|
|
88
|
+
* @param request - Callback request with authorization code
|
|
89
|
+
* @returns Session token and authorization details
|
|
90
|
+
*
|
|
91
|
+
* @throws Error if MCP server request fails
|
|
92
|
+
*/
|
|
93
|
+
handleCallback(request: CallbackRequest): Promise<CallbackResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Handle authorization status check
|
|
96
|
+
* Checks if a provider is currently authorized
|
|
97
|
+
*
|
|
98
|
+
* @param provider - Provider to check
|
|
99
|
+
* @param sessionToken - Session token from client
|
|
100
|
+
* @returns Authorization status
|
|
101
|
+
*
|
|
102
|
+
* @throws Error if MCP server request fails
|
|
103
|
+
*/
|
|
104
|
+
handleStatus(provider: string, sessionToken: string): Promise<StatusResponse>;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=base-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../src/adapters/base-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,iDAAiD;QACjD,QAAQ,EAAE,MAAM,CAAC;QACjB,qDAAqD;QACrD,YAAY,EAAE,MAAM,CAAC;QACrB,qCAAqC;QACrC,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,qBAAa,YAAY;IAGX,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;gBAExB,MAAM,EAAE,kBAAkB;IAE9C;;;;;;;;;OASG;IACG,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0C5E;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0BzE;;;;;;;;;OASG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CA4BpF"}
|