integrate-sdk 0.6.8 → 0.6.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.
@@ -8,6 +8,7 @@ var __export = (target, all) => {
8
8
  set: (newValue) => all[name] = () => newValue
9
9
  });
10
10
  };
11
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
11
12
 
12
13
  // src/adapters/tanstack-start.ts
13
14
  function toTanStackStartHandler(handler) {
package/dist/index.js CHANGED
@@ -2025,64 +2025,10 @@ function toNodeHandler(config) {
2025
2025
  }
2026
2026
  };
2027
2027
  }
2028
- // src/adapters/solid-start.ts
2029
- function toSolidStartHandler(baseHandler) {
2030
- const handler = async (event) => {
2031
- return baseHandler(event.request);
2032
- };
2033
- return {
2034
- GET: handler,
2035
- POST: handler,
2036
- PATCH: handler,
2037
- PUT: handler,
2038
- DELETE: handler
2039
- };
2040
- }
2041
- // src/adapters/svelte-kit.ts
2042
- async function svelteKitHandler({
2043
- authConfig,
2044
- event,
2045
- resolve,
2046
- basePath = "/api/integrate"
2047
- }) {
2048
- const { url } = event;
2049
- const baseUrl = new URL(basePath, url.origin);
2050
- if (!url.pathname.startsWith(baseUrl.pathname)) {
2051
- return resolve(event);
2052
- }
2053
- return authConfig(event.request);
2054
- }
2055
- function toSvelteKitHandler(baseHandler) {
2056
- return async (event) => {
2057
- return baseHandler(event.request);
2058
- };
2059
- }
2060
- // src/adapters/tanstack-start.ts
2061
- function toTanStackStartHandler(handler) {
2062
- const baseHandler = async ({ request }) => {
2063
- return handler(request);
2064
- };
2065
- return {
2066
- GET: baseHandler,
2067
- POST: baseHandler
2068
- };
2069
- }
2070
- var createTanStackOAuthHandler = toTanStackStartHandler;
2071
-
2072
- // src/index.ts
2073
- init_errors();
2074
-
2075
2028
  // src/utils/env.ts
2076
2029
  function getEnv(key) {
2077
2030
  try {
2078
- const getMetaEnv = () => {
2079
- try {
2080
- return typeof import.meta !== "undefined" ? import.meta.env : undefined;
2081
- } catch {
2082
- return;
2083
- }
2084
- };
2085
- const metaEnv = getMetaEnv();
2031
+ const metaEnv = import.meta.env;
2086
2032
  if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
2087
2033
  const value = metaEnv[key];
2088
2034
  if (value !== undefined && value !== null && value !== "") {
@@ -2206,6 +2152,319 @@ function createSimplePlugin(config) {
2206
2152
  onDisconnect: config.onDisconnect
2207
2153
  };
2208
2154
  }
2155
+
2156
+ // src/server.ts
2157
+ var globalServerConfig = null;
2158
+ function getDefaultRedirectUri() {
2159
+ if (typeof window !== "undefined") {
2160
+ return `${window.location.origin}/api/integrate/oauth/callback`;
2161
+ }
2162
+ const integrateUrl = getEnv("INTEGRATE_URL");
2163
+ if (integrateUrl) {
2164
+ return `${integrateUrl}/api/integrate/oauth/callback`;
2165
+ }
2166
+ const vercelUrl = getEnv("VERCEL_URL");
2167
+ if (vercelUrl) {
2168
+ return `https://${vercelUrl}/api/integrate/oauth/callback`;
2169
+ }
2170
+ return "http://localhost:3000/api/integrate/oauth/callback";
2171
+ }
2172
+ function createMCPServer(config) {
2173
+ if (typeof window !== "undefined") {
2174
+ throw new Error("createMCPServer() should only be called on the server-side. " + "Use createMCPClient() for client-side code.");
2175
+ }
2176
+ const providers = {};
2177
+ const updatedPlugins = config.plugins.map((plugin) => {
2178
+ if (plugin.oauth) {
2179
+ const { clientId, clientSecret, redirectUri: pluginRedirectUri } = plugin.oauth;
2180
+ if (!clientId || !clientSecret) {
2181
+ console.warn(`Warning: Plugin "${plugin.id}" is missing OAuth credentials. ` + `Provide clientId and clientSecret in the plugin configuration.`);
2182
+ return plugin;
2183
+ }
2184
+ const redirectUri = pluginRedirectUri || config.redirectUri || getDefaultRedirectUri();
2185
+ providers[plugin.id] = {
2186
+ clientId,
2187
+ clientSecret,
2188
+ redirectUri
2189
+ };
2190
+ return {
2191
+ ...plugin,
2192
+ oauth: {
2193
+ ...plugin.oauth,
2194
+ redirectUri
2195
+ }
2196
+ };
2197
+ }
2198
+ return plugin;
2199
+ });
2200
+ globalServerConfig = {
2201
+ providers,
2202
+ serverUrl: config.serverUrl,
2203
+ apiKey: config.apiKey
2204
+ };
2205
+ const clientConfig = {
2206
+ ...config,
2207
+ plugins: updatedPlugins,
2208
+ connectionMode: config.connectionMode || "lazy",
2209
+ singleton: config.singleton ?? true
2210
+ };
2211
+ const client = new MCPClient(clientConfig);
2212
+ if (config.apiKey) {
2213
+ client.setRequestHeader("X-API-KEY", config.apiKey);
2214
+ }
2215
+ client.__oauthConfig = {
2216
+ providers,
2217
+ serverUrl: config.serverUrl,
2218
+ apiKey: config.apiKey
2219
+ };
2220
+ const { POST, GET } = createOAuthRouteHandlers({
2221
+ providers,
2222
+ serverUrl: config.serverUrl,
2223
+ apiKey: config.apiKey
2224
+ });
2225
+ const handler = async (request, context) => {
2226
+ const method = request.method.toUpperCase();
2227
+ let action;
2228
+ let segments = [];
2229
+ if (context?.params?.action) {
2230
+ action = context.params.action;
2231
+ } else if (context?.params?.all) {
2232
+ const all = context.params.all;
2233
+ if (Array.isArray(all)) {
2234
+ segments = all;
2235
+ } else if (typeof all === "string") {
2236
+ segments = all.split("/").filter(Boolean);
2237
+ }
2238
+ if (segments.length === 2 && segments[0] === "oauth") {
2239
+ action = segments[1];
2240
+ } else if (segments.length === 1) {
2241
+ action = segments[0];
2242
+ } else if (segments.length > 0) {
2243
+ action = segments[segments.length - 1];
2244
+ }
2245
+ } else {
2246
+ const url = new URL(request.url);
2247
+ const pathParts = url.pathname.split("/").filter(Boolean);
2248
+ segments = pathParts;
2249
+ const oauthIndex = pathParts.indexOf("oauth");
2250
+ if (oauthIndex >= 0 && oauthIndex < pathParts.length - 1) {
2251
+ action = pathParts[oauthIndex + 1];
2252
+ } else if (pathParts.length > 0) {
2253
+ action = pathParts[pathParts.length - 1];
2254
+ } else {
2255
+ action = "callback";
2256
+ }
2257
+ }
2258
+ if (segments.length > 0) {
2259
+ if (segments.length === 2 && segments[0] !== "oauth") {
2260
+ return Response.json({ error: `Invalid route: /${segments.join("/")}` }, { status: 404 });
2261
+ }
2262
+ }
2263
+ if (method === "GET" && action === "callback") {
2264
+ const url = new URL(request.url);
2265
+ const searchParams = url.searchParams;
2266
+ const code = searchParams.get("code");
2267
+ const state = searchParams.get("state");
2268
+ const error = searchParams.get("error");
2269
+ const errorDescription = searchParams.get("error_description");
2270
+ const defaultRedirectUrl = "/";
2271
+ const errorRedirectUrl = "/auth-error";
2272
+ if (error) {
2273
+ const errorMsg = errorDescription || error;
2274
+ console.error("[OAuth Redirect] Error:", errorMsg);
2275
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
2276
+ }
2277
+ if (!code || !state) {
2278
+ console.error("[OAuth Redirect] Missing code or state parameter");
2279
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
2280
+ }
2281
+ let returnUrl = defaultRedirectUrl;
2282
+ try {
2283
+ const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
2284
+ const stateData = parseState2(state);
2285
+ if (stateData.returnUrl) {
2286
+ returnUrl = stateData.returnUrl;
2287
+ }
2288
+ } catch (e) {
2289
+ try {
2290
+ const referrer = request.headers.get("referer") || request.headers.get("referrer");
2291
+ if (referrer) {
2292
+ const referrerUrl = new URL(referrer);
2293
+ const currentUrl = new URL(request.url);
2294
+ if (referrerUrl.origin === currentUrl.origin) {
2295
+ returnUrl = referrerUrl.pathname + referrerUrl.search;
2296
+ }
2297
+ }
2298
+ } catch {}
2299
+ }
2300
+ const targetUrl = new URL(returnUrl, request.url);
2301
+ targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
2302
+ return Response.redirect(targetUrl);
2303
+ }
2304
+ const handlerContext = { params: { action: action || "callback" } };
2305
+ if (method === "POST") {
2306
+ return POST(request, handlerContext);
2307
+ } else if (method === "GET") {
2308
+ return GET(request, handlerContext);
2309
+ } else {
2310
+ return Response.json({ error: `Method ${method} not allowed` }, { status: 405 });
2311
+ }
2312
+ };
2313
+ return {
2314
+ client,
2315
+ POST,
2316
+ GET,
2317
+ handler
2318
+ };
2319
+ }
2320
+ function createOAuthRouteHandlers(config) {
2321
+ const handler = createNextOAuthHandler(config);
2322
+ return handler.createRoutes();
2323
+ }
2324
+ var POST = async (req, context) => {
2325
+ if (!globalServerConfig) {
2326
+ return Response.json({ error: "OAuth not configured. Call createMCPServer() in your server initialization file first." }, { status: 500 });
2327
+ }
2328
+ const handler = createNextOAuthHandler(globalServerConfig);
2329
+ const routes = handler.createRoutes();
2330
+ return routes.POST(req, context);
2331
+ };
2332
+ var GET = async (req, context) => {
2333
+ if (!globalServerConfig) {
2334
+ return Response.json({ error: "OAuth not configured. Call createMCPServer() in your server initialization file first." }, { status: 500 });
2335
+ }
2336
+ const handler = createNextOAuthHandler(globalServerConfig);
2337
+ const routes = handler.createRoutes();
2338
+ return routes.GET(req, context);
2339
+ };
2340
+ function toNextJsHandler(options) {
2341
+ const POST2 = async (req, context) => {
2342
+ const config = options.config || options.client?.__oauthConfig;
2343
+ if (!config) {
2344
+ return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
2345
+ }
2346
+ const handler = createNextOAuthHandler(config);
2347
+ const routes = handler.toNextJsHandler({
2348
+ redirectUrl: options.redirectUrl,
2349
+ errorRedirectUrl: options.errorRedirectUrl
2350
+ });
2351
+ return routes.POST(req, context);
2352
+ };
2353
+ const GET2 = async (req, context) => {
2354
+ const config = options.config || options.client?.__oauthConfig;
2355
+ if (!config) {
2356
+ return Response.json({ error: 'OAuth not configured. You must pass either "client" (from createMCPServer) or "config" to toNextJsHandler().' }, { status: 500 });
2357
+ }
2358
+ const handler = createNextOAuthHandler(config);
2359
+ const routes = handler.toNextJsHandler({
2360
+ redirectUrl: options.redirectUrl,
2361
+ errorRedirectUrl: options.errorRedirectUrl
2362
+ });
2363
+ return routes.GET(req, context);
2364
+ };
2365
+ return { POST: POST2, GET: GET2 };
2366
+ }
2367
+ function toAstroHandler(baseHandler, options) {
2368
+ const defaultRedirectUrl = options?.redirectUrl || "/";
2369
+ const errorRedirectUrl = options?.errorRedirectUrl || "/auth-error";
2370
+ return async (ctx) => {
2371
+ const wrappedHandler = async (request, context) => {
2372
+ const url = new URL(request.url);
2373
+ const method = request.method.toUpperCase();
2374
+ const pathParts = url.pathname.split("/").filter(Boolean);
2375
+ const oauthIndex = pathParts.indexOf("oauth");
2376
+ if (method === "GET" && oauthIndex >= 0 && pathParts[oauthIndex + 1] === "callback") {
2377
+ const searchParams = url.searchParams;
2378
+ const code = searchParams.get("code");
2379
+ const state = searchParams.get("state");
2380
+ const error = searchParams.get("error");
2381
+ const errorDescription = searchParams.get("error_description");
2382
+ if (error) {
2383
+ const errorMsg = errorDescription || error;
2384
+ console.error("[OAuth Redirect] Error:", errorMsg);
2385
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
2386
+ }
2387
+ if (!code || !state) {
2388
+ console.error("[OAuth Redirect] Missing code or state parameter");
2389
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
2390
+ }
2391
+ let returnUrl = defaultRedirectUrl;
2392
+ try {
2393
+ const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
2394
+ const stateData = parseState2(state);
2395
+ if (stateData.returnUrl) {
2396
+ returnUrl = stateData.returnUrl;
2397
+ }
2398
+ } catch (e) {
2399
+ try {
2400
+ const referrer = request.headers.get("referer") || request.headers.get("referrer");
2401
+ if (referrer) {
2402
+ const referrerUrl = new URL(referrer);
2403
+ const currentUrl = new URL(request.url);
2404
+ if (referrerUrl.origin === currentUrl.origin) {
2405
+ returnUrl = referrerUrl.pathname + referrerUrl.search;
2406
+ }
2407
+ }
2408
+ } catch {}
2409
+ }
2410
+ const targetUrl = new URL(returnUrl, request.url);
2411
+ targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
2412
+ return Response.redirect(targetUrl);
2413
+ }
2414
+ return baseHandler(request, context);
2415
+ };
2416
+ return wrappedHandler(ctx.request, { params: { all: ctx.params.all } });
2417
+ };
2418
+ }
2419
+ function toSolidStartHandler(baseHandler, options) {
2420
+ const wrappedHandler = toAstroHandler(baseHandler, options);
2421
+ const handler = async (event) => {
2422
+ return wrappedHandler({ request: event.request, params: {} });
2423
+ };
2424
+ return {
2425
+ GET: handler,
2426
+ POST: handler,
2427
+ PATCH: handler,
2428
+ PUT: handler,
2429
+ DELETE: handler
2430
+ };
2431
+ }
2432
+ function toSvelteKitHandler(baseHandler, options) {
2433
+ const wrappedHandler = toAstroHandler(baseHandler, options);
2434
+ return async (event) => {
2435
+ const all = event.params?.all;
2436
+ return wrappedHandler({ request: event.request, params: { all } });
2437
+ };
2438
+ }
2439
+ // src/adapters/svelte-kit.ts
2440
+ async function svelteKitHandler({
2441
+ authConfig,
2442
+ event,
2443
+ resolve,
2444
+ basePath = "/api/integrate"
2445
+ }) {
2446
+ const { url } = event;
2447
+ const baseUrl = new URL(basePath, url.origin);
2448
+ if (!url.pathname.startsWith(baseUrl.pathname)) {
2449
+ return resolve(event);
2450
+ }
2451
+ return authConfig(event.request);
2452
+ }
2453
+ // src/adapters/tanstack-start.ts
2454
+ function toTanStackStartHandler(handler) {
2455
+ const baseHandler = async ({ request }) => {
2456
+ return handler(request);
2457
+ };
2458
+ return {
2459
+ GET: baseHandler,
2460
+ POST: baseHandler
2461
+ };
2462
+ }
2463
+ var createTanStackOAuthHandler = toTanStackStartHandler;
2464
+
2465
+ // src/index.ts
2466
+ init_errors();
2467
+
2209
2468
  // node_modules/zod/v3/external.js
2210
2469
  var exports_external = {};
2211
2470
  __export(exports_external, {
package/dist/server.js CHANGED
@@ -1855,14 +1855,7 @@ function createNextOAuthHandler(config) {
1855
1855
  // src/utils/env.ts
1856
1856
  function getEnv(key) {
1857
1857
  try {
1858
- const getMetaEnv = () => {
1859
- try {
1860
- return typeof import.meta !== "undefined" ? import.meta.env : undefined;
1861
- } catch {
1862
- return;
1863
- }
1864
- };
1865
- const metaEnv = getMetaEnv();
1858
+ const metaEnv = import.meta.env;
1866
1859
  if (metaEnv && typeof metaEnv === "object" && metaEnv !== null) {
1867
1860
  const value = metaEnv[key];
1868
1861
  if (value !== undefined && value !== null && value !== "") {
@@ -2059,19 +2052,81 @@ function createMCPServer(config) {
2059
2052
  const handler = async (request, context) => {
2060
2053
  const method = request.method.toUpperCase();
2061
2054
  let action;
2055
+ let segments = [];
2062
2056
  if (context?.params?.action) {
2063
2057
  action = context.params.action;
2064
2058
  } else if (context?.params?.all) {
2065
2059
  const all = context.params.all;
2066
2060
  if (Array.isArray(all)) {
2067
- action = all[all.length - 1];
2061
+ segments = all;
2068
2062
  } else if (typeof all === "string") {
2069
- action = all.split("/").pop();
2063
+ segments = all.split("/").filter(Boolean);
2064
+ }
2065
+ if (segments.length === 2 && segments[0] === "oauth") {
2066
+ action = segments[1];
2067
+ } else if (segments.length === 1) {
2068
+ action = segments[0];
2069
+ } else if (segments.length > 0) {
2070
+ action = segments[segments.length - 1];
2070
2071
  }
2071
2072
  } else {
2072
2073
  const url = new URL(request.url);
2073
2074
  const pathParts = url.pathname.split("/").filter(Boolean);
2074
- action = pathParts[pathParts.length - 1] || "callback";
2075
+ segments = pathParts;
2076
+ const oauthIndex = pathParts.indexOf("oauth");
2077
+ if (oauthIndex >= 0 && oauthIndex < pathParts.length - 1) {
2078
+ action = pathParts[oauthIndex + 1];
2079
+ } else if (pathParts.length > 0) {
2080
+ action = pathParts[pathParts.length - 1];
2081
+ } else {
2082
+ action = "callback";
2083
+ }
2084
+ }
2085
+ if (segments.length > 0) {
2086
+ if (segments.length === 2 && segments[0] !== "oauth") {
2087
+ return Response.json({ error: `Invalid route: /${segments.join("/")}` }, { status: 404 });
2088
+ }
2089
+ }
2090
+ if (method === "GET" && action === "callback") {
2091
+ const url = new URL(request.url);
2092
+ const searchParams = url.searchParams;
2093
+ const code = searchParams.get("code");
2094
+ const state = searchParams.get("state");
2095
+ const error = searchParams.get("error");
2096
+ const errorDescription = searchParams.get("error_description");
2097
+ const defaultRedirectUrl = "/";
2098
+ const errorRedirectUrl = "/auth-error";
2099
+ if (error) {
2100
+ const errorMsg = errorDescription || error;
2101
+ console.error("[OAuth Redirect] Error:", errorMsg);
2102
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
2103
+ }
2104
+ if (!code || !state) {
2105
+ console.error("[OAuth Redirect] Missing code or state parameter");
2106
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
2107
+ }
2108
+ let returnUrl = defaultRedirectUrl;
2109
+ try {
2110
+ const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
2111
+ const stateData = parseState2(state);
2112
+ if (stateData.returnUrl) {
2113
+ returnUrl = stateData.returnUrl;
2114
+ }
2115
+ } catch (e) {
2116
+ try {
2117
+ const referrer = request.headers.get("referer") || request.headers.get("referrer");
2118
+ if (referrer) {
2119
+ const referrerUrl = new URL(referrer);
2120
+ const currentUrl = new URL(request.url);
2121
+ if (referrerUrl.origin === currentUrl.origin) {
2122
+ returnUrl = referrerUrl.pathname + referrerUrl.search;
2123
+ }
2124
+ }
2125
+ } catch {}
2126
+ }
2127
+ const targetUrl = new URL(returnUrl, request.url);
2128
+ targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
2129
+ return Response.redirect(targetUrl);
2075
2130
  }
2076
2131
  const handlerContext = { params: { action: action || "callback" } };
2077
2132
  if (method === "POST") {
@@ -2136,8 +2191,83 @@ function toNextJsHandler(options) {
2136
2191
  };
2137
2192
  return { POST: POST2, GET: GET2 };
2138
2193
  }
2194
+ function toAstroHandler(baseHandler, options) {
2195
+ const defaultRedirectUrl = options?.redirectUrl || "/";
2196
+ const errorRedirectUrl = options?.errorRedirectUrl || "/auth-error";
2197
+ return async (ctx) => {
2198
+ const wrappedHandler = async (request, context) => {
2199
+ const url = new URL(request.url);
2200
+ const method = request.method.toUpperCase();
2201
+ const pathParts = url.pathname.split("/").filter(Boolean);
2202
+ const oauthIndex = pathParts.indexOf("oauth");
2203
+ if (method === "GET" && oauthIndex >= 0 && pathParts[oauthIndex + 1] === "callback") {
2204
+ const searchParams = url.searchParams;
2205
+ const code = searchParams.get("code");
2206
+ const state = searchParams.get("state");
2207
+ const error = searchParams.get("error");
2208
+ const errorDescription = searchParams.get("error_description");
2209
+ if (error) {
2210
+ const errorMsg = errorDescription || error;
2211
+ console.error("[OAuth Redirect] Error:", errorMsg);
2212
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent(errorMsg)}`, request.url));
2213
+ }
2214
+ if (!code || !state) {
2215
+ console.error("[OAuth Redirect] Missing code or state parameter");
2216
+ return Response.redirect(new URL(`${errorRedirectUrl}?error=${encodeURIComponent("Invalid OAuth callback")}`, request.url));
2217
+ }
2218
+ let returnUrl = defaultRedirectUrl;
2219
+ try {
2220
+ const { parseState: parseState2 } = await Promise.resolve().then(() => exports_pkce);
2221
+ const stateData = parseState2(state);
2222
+ if (stateData.returnUrl) {
2223
+ returnUrl = stateData.returnUrl;
2224
+ }
2225
+ } catch (e) {
2226
+ try {
2227
+ const referrer = request.headers.get("referer") || request.headers.get("referrer");
2228
+ if (referrer) {
2229
+ const referrerUrl = new URL(referrer);
2230
+ const currentUrl = new URL(request.url);
2231
+ if (referrerUrl.origin === currentUrl.origin) {
2232
+ returnUrl = referrerUrl.pathname + referrerUrl.search;
2233
+ }
2234
+ }
2235
+ } catch {}
2236
+ }
2237
+ const targetUrl = new URL(returnUrl, request.url);
2238
+ targetUrl.hash = `oauth_callback=${encodeURIComponent(JSON.stringify({ code, state }))}`;
2239
+ return Response.redirect(targetUrl);
2240
+ }
2241
+ return baseHandler(request, context);
2242
+ };
2243
+ return wrappedHandler(ctx.request, { params: { all: ctx.params.all } });
2244
+ };
2245
+ }
2246
+ function toSolidStartHandler(baseHandler, options) {
2247
+ const wrappedHandler = toAstroHandler(baseHandler, options);
2248
+ const handler = async (event) => {
2249
+ return wrappedHandler({ request: event.request, params: {} });
2250
+ };
2251
+ return {
2252
+ GET: handler,
2253
+ POST: handler,
2254
+ PATCH: handler,
2255
+ PUT: handler,
2256
+ DELETE: handler
2257
+ };
2258
+ }
2259
+ function toSvelteKitHandler(baseHandler, options) {
2260
+ const wrappedHandler = toAstroHandler(baseHandler, options);
2261
+ return async (event) => {
2262
+ const all = event.params?.all;
2263
+ return wrappedHandler({ request: event.request, params: { all } });
2264
+ };
2265
+ }
2139
2266
  export {
2267
+ toSvelteKitHandler,
2268
+ toSolidStartHandler,
2140
2269
  toNextJsHandler,
2270
+ toAstroHandler,
2141
2271
  gmailPlugin,
2142
2272
  githubPlugin,
2143
2273
  genericOAuthPlugin,
@@ -1,54 +1,8 @@
1
1
  /**
2
2
  * SolidStart OAuth Route Adapter
3
3
  * Provides OAuth route handlers for SolidStart
4
- */
5
- /**
6
- * Create SolidStart OAuth route handlers
7
- *
8
- * Use this to create secure OAuth API routes in your SolidStart application
9
- * that handle authorization with server-side secrets.
10
- *
11
- * @param baseHandler - Handler function from createMCPServer
12
- * @returns Object with GET, POST, PATCH, PUT, DELETE handlers
13
- *
14
- * @example
15
- * ```typescript
16
- * // lib/integrate-server.ts
17
- * import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
18
- *
19
- * export const { client: serverClient, handler } = createMCPServer({
20
- * plugins: [
21
- * githubPlugin({
22
- * clientId: process.env.GITHUB_CLIENT_ID!,
23
- * clientSecret: process.env.GITHUB_CLIENT_SECRET!,
24
- * }),
25
- * ],
26
- * });
27
- *
28
- * // src/routes/api/integrate/[...all].ts
29
- * import { toSolidStartHandler } from 'integrate-sdk/adapters/solid-start';
30
- * import { handler } from '@/lib/integrate-server';
31
- *
32
- * const handlers = toSolidStartHandler(handler);
33
4
  *
34
- * export const { GET, POST, PATCH, PUT, DELETE } = handlers;
35
- * ```
5
+ * Re-exports from server.ts for convenience
36
6
  */
37
- export declare function toSolidStartHandler(baseHandler: (request: Request) => Promise<Response>): {
38
- GET: (event: {
39
- request: Request;
40
- }) => Promise<Response>;
41
- POST: (event: {
42
- request: Request;
43
- }) => Promise<Response>;
44
- PATCH: (event: {
45
- request: Request;
46
- }) => Promise<Response>;
47
- PUT: (event: {
48
- request: Request;
49
- }) => Promise<Response>;
50
- DELETE: (event: {
51
- request: Request;
52
- }) => Promise<Response>;
53
- };
7
+ export { toSolidStartHandler } from '../server.js';
54
8
  //# sourceMappingURL=solid-start.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solid-start.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC;iBACxD;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,QAAQ,CAAC;kBAAxC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,QAAQ,CAAC;mBAAxC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,QAAQ,CAAC;iBAAxC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,QAAQ,CAAC;oBAAxC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,OAAO,CAAC,QAAQ,CAAC;EAWvE"}
1
+ {"version":3,"file":"solid-start.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
@@ -50,8 +50,7 @@ export declare function svelteKitHandler({ authConfig, event, resolve, basePath,
50
50
  * Use this to create secure OAuth API routes in your SvelteKit application
51
51
  * that handle authorization with server-side secrets.
52
52
  *
53
- * @param baseHandler - Handler function from createMCPServer
54
- * @returns Handler function for SvelteKit routes
53
+ * Re-exports from server.ts for convenience
55
54
  *
56
55
  * @example
57
56
  * ```typescript
@@ -68,15 +67,17 @@ export declare function svelteKitHandler({ authConfig, event, resolve, basePath,
68
67
  * });
69
68
  *
70
69
  * // routes/api/integrate/[...all]/+server.ts
71
- * import { toSvelteKitHandler } from 'integrate-sdk/adapters/svelte-kit';
70
+ * import { toSvelteKitHandler } from 'integrate-sdk/server';
72
71
  * import { handler } from '$lib/integrate-server';
73
72
  *
74
- * const svelteKitRoute = toSvelteKitHandler(handler);
73
+ * const svelteKitRoute = toSvelteKitHandler(handler, {
74
+ * redirectUrl: '/dashboard',
75
+ * errorRedirectUrl: '/auth-error',
76
+ * });
75
77
  *
76
78
  * export const POST = svelteKitRoute;
77
79
  * export const GET = svelteKitRoute;
78
80
  * ```
79
81
  */
80
- export declare function toSvelteKitHandler(baseHandler: (request: Request) => Promise<Response>): (event: RequestEvent) => Promise<Response>;
81
- export {};
82
+ export { toSvelteKitHandler } from '../server.js';
82
83
  //# sourceMappingURL=svelte-kit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelte-kit.d.ts","sourceRoot":"","sources":["../../../src/adapters/svelte-kit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,KAAK,YAAY,GAAG,GAAG,CAAC;AACxB,KAAK,eAAe,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,gBAAgB,CAAC,EACnC,UAAU,EACV,KAAK,EACL,OAAO,EACP,QAA2B,GAC9B,EAAE;IACC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,IACrE,OAAO,YAAY,KAAG,OAAO,CAAC,QAAQ,CAAC,CAGxD"}
1
+ {"version":3,"file":"svelte-kit.d.ts","sourceRoot":"","sources":["../../../src/adapters/svelte-kit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,KAAK,YAAY,GAAG,GAAG,CAAC;AACxB,KAAK,eAAe,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,gBAAgB,CAAC,EACnC,UAAU,EACV,KAAK,EACL,OAAO,EACP,QAA2B,GAC9B,EAAE;IACC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}