@composio/core 0.18.1 → 0.20.0
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/{CustomTool-VRfWzMix.d.mts → CustomTool-B3m-188G.d.mts} +1 -1
- package/dist/{CustomTool-Bz0f52QR.mjs → CustomTool-fYEFjSLM.mjs} +1 -1
- package/dist/{FileModifierErrors-CwB-Inm9.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
- package/dist/{SsrfErrors-xhdVE4yw.mjs → SsrfErrors-DiQldIdC.mjs} +32 -17
- package/dist/{Telemetry-Dw9W5RSp.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-P5YUlcfz.mjs → cancellation-Dwa9lGHA.mjs} +7 -5
- package/dist/{composio-Cb3d1jFe.d.mts → composio-B36OXii1.d.mts} +3017 -144
- package/dist/{customTool.types-B6ej_8XZ.d.mts → customTool.types-C436M_D0.d.mts} +525 -101
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +8 -15
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +7 -0
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
- package/dist/docs/reference/sdk-reference/typescript/meta.json +8 -1
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +117 -24
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -10
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +151 -14
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +50 -40
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +26 -25
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
- package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
- package/dist/{errors-Ue9wMrPK.mjs → errors-D_A4b2c2.mjs} +143 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-KE5Fa-af.mjs → fileUtils.node-DNLhLg0W.mjs} +8 -6
- package/dist/index.d.mts +418 -146
- package/dist/index.mjs +2728 -349
- package/dist/models/Files.node.d.mts +2 -3
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +2 -3
- package/dist/platform/node.d.mts +2 -3
- package/dist/platform/workerd.d.mts +2 -3
- package/dist/{sensitiveFileUploadPaths-QN7w4n8v.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
- package/dist/{ssrfGuard.node-BLX6b-Rf.mjs → ssrfGuard.node-BZ270bcu.mjs} +104 -14
- package/dist/{types-CGdgK442.d.mts → types-Br3GBya5.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +19 -10
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.d.mts +12 -4
- package/dist/utils/ssrfGuard.workerd.mjs +2 -2
- package/package.json +9 -9
- package/src/composio.ts +207 -10
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/errors/SDKErrors.ts +52 -0
- package/src/errors/ToolErrors.ts +24 -0
- package/src/errors/ToolRouterErrors.ts +57 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +15 -0
- package/src/lib/toolRouterMcp.ts +132 -0
- package/src/lib/toolRouterParams.ts +116 -29
- package/src/models/ConnectedAccounts.ts +118 -2
- package/src/models/CustomToolkits.ts +169 -0
- package/src/models/Experimental.ts +27 -0
- package/src/models/Keyring.ts +65 -0
- package/src/models/Logs.ts +101 -0
- package/src/models/MCP.ts +29 -15
- package/src/models/ToolRouter.ts +43 -14
- package/src/models/ToolRouterSession.ts +224 -16
- package/src/models/Toolkits.ts +181 -2
- package/src/models/Tools.ts +58 -26
- package/src/models/Triggers.ts +10 -90
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/services/pusher/Pusher.ts +46 -16
- package/src/types/authConfigs.types.ts +2 -0
- package/src/types/connectedAccounts.types.ts +54 -0
- package/src/types/customToolkits.types.ts +102 -0
- package/src/types/keyring.types.ts +32 -0
- package/src/types/logs.types.ts +108 -0
- package/src/types/toolRouter.types.ts +259 -14
- package/src/types/toolkit.types.ts +161 -0
- package/src/types/usage.types.ts +81 -0
- package/src/types/webhooks.types.ts +143 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/jsonSchema.ts +4 -1
- package/src/utils/logger.ts +39 -7
- package/src/utils/sdk.ts +385 -22
- package/src/utils/ssrfGuard.node.ts +127 -13
- package/src/utils/ssrfGuard.workerd.ts +11 -1
- package/src/utils/transformers/connectedAccounts.ts +37 -2
- package/src/utils/transformers/customToolkits.ts +98 -0
- package/src/utils/transformers/keyring.ts +24 -0
- package/src/utils/transformers/logs.ts +85 -0
- package/src/utils/transformers/toolkits.ts +183 -3
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as FileUploadData, t as FileDownloadData } from "../files.types-DeMC_mAW.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
//#region src/models/Files.node.d.ts
|
|
4
|
-
declare class Files {
|
|
4
|
+
export declare class Files {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly fileOptions;
|
|
7
7
|
constructor(client: ComposioClient, fileOptions?: {
|
|
@@ -42,5 +42,4 @@ declare class Files {
|
|
|
42
42
|
mimeType: string;
|
|
43
43
|
}): Promise<FileDownloadData>;
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
|
-
export { Files };
|
|
45
|
+
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as telemetry } from "../Telemetry-
|
|
2
|
-
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-
|
|
1
|
+
import { t as telemetry } from "../Telemetry-JRJJYS4I.mjs";
|
|
2
|
+
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-DNLhLg0W.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/models/Files.node.ts
|
|
5
5
|
var Files = class {
|
|
@@ -4,8 +4,7 @@ import ComposioClient from "@composio/client";
|
|
|
4
4
|
* Files class for Cloudflare Workers / Edge runtimes.
|
|
5
5
|
* All methods throw an error indicating that file operations are not supported.
|
|
6
6
|
*/
|
|
7
|
-
declare class Files {
|
|
7
|
+
export declare class Files {
|
|
8
8
|
constructor(_client: ComposioClient);
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { Files };
|
|
10
|
+
//#endregion
|
package/dist/platform/node.d.mts
CHANGED
|
@@ -4,6 +4,5 @@ import { t as Platform } from "../types-D5A2wzBl.mjs";
|
|
|
4
4
|
* Node.js platform implementation.
|
|
5
5
|
* Provides full file system and OS operations using Node.js built-in modules.
|
|
6
6
|
*/
|
|
7
|
-
declare const platform: Platform;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { platform };
|
|
7
|
+
export declare const platform: Platform;
|
|
8
|
+
//#endregion
|
|
@@ -5,6 +5,5 @@ import { t as Platform } from "../types-D5A2wzBl.mjs";
|
|
|
5
5
|
* Provides stub implementations for file system operations that are unavailable in edge runtimes.
|
|
6
6
|
* All file system operations gracefully return null/empty values or throw descriptive errors.
|
|
7
7
|
*/
|
|
8
|
-
declare const platform: Platform;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { platform };
|
|
8
|
+
export declare const platform: Platform;
|
|
9
|
+
//#endregion
|
package/dist/{sensitiveFileUploadPaths-QN7w4n8v.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ComposioSensitiveFilePathBlockedError } from "./FileModifierErrors-
|
|
1
|
+
import { a as ComposioSensitiveFilePathBlockedError } from "./FileModifierErrors-CdGSABoq.mjs";
|
|
2
2
|
import { platform } from "#platform";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/uuid.ts
|
|
@@ -35,7 +35,7 @@ const uint8ArrayToBase64 = (bytes) => {
|
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/utils/readResponseBody.ts
|
|
37
37
|
/** Maximum size accepted for files fetched from user-supplied URLs (100 MiB). */
|
|
38
|
-
const MAX_URL_UPLOAD_SIZE_BYTES =
|
|
38
|
+
const MAX_URL_UPLOAD_SIZE_BYTES = 104857600;
|
|
39
39
|
const sizeLimitError = (actualSize, maxBytes) => /* @__PURE__ */ new Error(`File size (${actualSize} bytes) exceeds maximum allowed size (${maxBytes} bytes)`);
|
|
40
40
|
/**
|
|
41
41
|
* Read a fetch response without allowing an untrusted server to exhaust memory.
|
|
@@ -176,11 +176,14 @@ const DEFAULT_REMEDIATION = "To upload from this path anyway, set sensitiveFileU
|
|
|
176
176
|
*/
|
|
177
177
|
function assertSafeFileUploadPath(filePath, options) {
|
|
178
178
|
const reason = getSensitiveFileUploadPathBlockReason(filePath, options?.additionalDenySegments);
|
|
179
|
-
if (reason)
|
|
180
|
-
|
|
181
|
-
reason
|
|
182
|
-
|
|
179
|
+
if (reason) {
|
|
180
|
+
const remediation = options?.remediation ?? DEFAULT_REMEDIATION;
|
|
181
|
+
throw new ComposioSensitiveFilePathBlockedError(`Refusing to upload: ${reason}. ${remediation}`, { meta: {
|
|
182
|
+
filePath,
|
|
183
|
+
reason
|
|
184
|
+
} });
|
|
185
|
+
}
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
//#endregion
|
|
186
|
-
export {
|
|
189
|
+
export { readResponseBodyWithLimit as a, uint8ArrayToBase64 as c, MAX_URL_UPLOAD_SIZE_BYTES as i, getRandomShortId as l, assertSafeFileUploadPath as n, arrayBufferToBase64 as o, isBlockedSensitiveFileUploadPath as r, base64ToUint8Array as s, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS as t, getRandomUUID as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ComposioBlockedInternalUrlError } from "./SsrfErrors-
|
|
1
|
+
import { t as ComposioBlockedInternalUrlError } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
2
|
import { lookup } from "node:dns/promises";
|
|
3
3
|
import { isIP } from "node:net";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -187,7 +187,7 @@ const hasCustomGlobalDispatcher = () => {
|
|
|
187
187
|
* to a public address during validation and rebind to an internal one before
|
|
188
188
|
* the connect — a TOCTOU window the Python guard closes the same way.
|
|
189
189
|
*
|
|
190
|
-
*
|
|
190
|
+
* By default, a hop whose effective dispatcher is a configured route — a
|
|
191
191
|
* caller-supplied `init.dispatcher`, a non-stock global dispatcher (a
|
|
192
192
|
* `ProxyAgent` or `EnvHttpProxyAgent` installed via `setGlobalDispatcher`), or
|
|
193
193
|
* the runtime's env-proxy mode (automatic on Bun, opt-in via
|
|
@@ -195,10 +195,86 @@ const hasCustomGlobalDispatcher = () => {
|
|
|
195
195
|
* pre-flight validation. Pinning would dial the validated address instead of
|
|
196
196
|
* the proxy, and the proxy resolves the hostname itself where the SDK cannot
|
|
197
197
|
* see or pin that resolution. The Python guard carries the same residual for
|
|
198
|
-
* the same reason (`_proxy_applies`).
|
|
198
|
+
* the same reason (`_proxy_applies`). Callers that cannot accept that residual
|
|
199
|
+
* can set `requirePinnedConnection`, which fails closed before fetching.
|
|
199
200
|
*/
|
|
200
201
|
const MAX_REDIRECTS = 5;
|
|
201
202
|
/**
|
|
203
|
+
* The Fetch standard's "redirect status" set. A 3xx outside it is not a
|
|
204
|
+
* redirect to follow even when it carries a `location` — `304 Not Modified`
|
|
205
|
+
* and `305 Use Proxy` most of all, and following those would replay the
|
|
206
|
+
* request against a target the caller never asked for. The Python guard
|
|
207
|
+
* follows the same set (`_REDIRECT_STATUS_CODES`).
|
|
208
|
+
*/
|
|
209
|
+
const REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
210
|
+
301,
|
|
211
|
+
302,
|
|
212
|
+
303,
|
|
213
|
+
307,
|
|
214
|
+
308
|
|
215
|
+
]);
|
|
216
|
+
/**
|
|
217
|
+
* Headers that describe a request body, so they have to go when the body does:
|
|
218
|
+
* the Fetch standard's "request-body-header name" set, plus the two the Python
|
|
219
|
+
* guard also drops because `requests` recomputes them from the body it sends.
|
|
220
|
+
*/
|
|
221
|
+
const BODY_HEADERS = [
|
|
222
|
+
"content-encoding",
|
|
223
|
+
"content-language",
|
|
224
|
+
"content-length",
|
|
225
|
+
"content-location",
|
|
226
|
+
"content-type",
|
|
227
|
+
"transfer-encoding"
|
|
228
|
+
];
|
|
229
|
+
/**
|
|
230
|
+
* The method the hop after a redirect uses, or `null` to replay as-is. A
|
|
231
|
+
* returned method also means the request body goes.
|
|
232
|
+
*
|
|
233
|
+
* These are the Fetch standard's redirect rules, which following redirects by
|
|
234
|
+
* hand (`redirect: 'manual'`) means `fetch` never applies for us: `303` points
|
|
235
|
+
* at a result URL that has no use for the original body, so every method loses
|
|
236
|
+
* it and everything but `HEAD` becomes a `GET`; `301`/`302` do the same to a
|
|
237
|
+
* `POST` only; `307`/`308` replay both. Without this, a `303` answering an
|
|
238
|
+
* upload would PUT the payload again at a URL that expects a GET. The Python
|
|
239
|
+
* guard applies the same rules in `safe_request`.
|
|
240
|
+
*/
|
|
241
|
+
const redirectRewrite = (status, method) => {
|
|
242
|
+
if (status === 303) return method === "HEAD" ? "HEAD" : "GET";
|
|
243
|
+
if ((status === 301 || status === 302) && method === "POST") return "GET";
|
|
244
|
+
return null;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Headers that carry a credential for the origin the request was addressed
|
|
248
|
+
* to, so they must not follow a redirect to a different origin. The Fetch
|
|
249
|
+
* standard strips `Authorization` on a cross-origin redirect; `Cookie` and
|
|
250
|
+
* `Proxy-Authorization` go with it the way `requests` and curl drop them on a
|
|
251
|
+
* host change. `redirect: 'manual'` means `fetch` never applies that rule for
|
|
252
|
+
* us either. The Python guard drops the same three (`_CREDENTIAL_HEADERS`).
|
|
253
|
+
*/
|
|
254
|
+
const CREDENTIAL_HEADERS = [
|
|
255
|
+
"authorization",
|
|
256
|
+
"cookie",
|
|
257
|
+
"proxy-authorization"
|
|
258
|
+
];
|
|
259
|
+
const applyRedirectSemantics = (init, status, fromUrl, toUrl) => {
|
|
260
|
+
const method = redirectRewrite(status, (init.method ?? "GET").toUpperCase());
|
|
261
|
+
const crossOrigin = new URL(fromUrl).origin !== new URL(toUrl).origin;
|
|
262
|
+
if (method === null && !crossOrigin) return init;
|
|
263
|
+
const headers = new Headers(init.headers);
|
|
264
|
+
if (method !== null) for (const name of BODY_HEADERS) headers.delete(name);
|
|
265
|
+
if (crossOrigin) for (const name of CREDENTIAL_HEADERS) headers.delete(name);
|
|
266
|
+
if (method === null) return {
|
|
267
|
+
...init,
|
|
268
|
+
headers
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
...init,
|
|
272
|
+
method,
|
|
273
|
+
body: void 0,
|
|
274
|
+
headers
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
202
278
|
* Whether the runtime would route `url` through an env proxy the SDK cannot
|
|
203
279
|
* see into. Bun honors proxy environment variables automatically. Node's
|
|
204
280
|
* built-in `fetch` requires the `NODE_USE_ENV_PROXY` opt-in (Node >= 24), so
|
|
@@ -228,6 +304,7 @@ const IPV4_BLOCKED_CIDRS = [
|
|
|
228
304
|
["172.16.0.0", 12],
|
|
229
305
|
["192.0.0.0", 24],
|
|
230
306
|
["192.0.2.0", 24],
|
|
307
|
+
["192.88.99.0", 24],
|
|
231
308
|
["192.168.0.0", 16],
|
|
232
309
|
["198.18.0.0", 15],
|
|
233
310
|
["198.51.100.0", 24],
|
|
@@ -276,8 +353,14 @@ const isBlockedIpv6 = (ip) => {
|
|
|
276
353
|
const isMappedOrCompat = h[0] === 0 && h[1] === 0 && h[2] === 0 && h[3] === 0 && h[4] === 0 && (h[5] === 65535 || h[5] === 0);
|
|
277
354
|
const isNat64 = h[0] === 100 && h[1] === 65435 && h[2] === 0 && h[3] === 0 && h[4] === 0 && h[5] === 0;
|
|
278
355
|
if (isMappedOrCompat || isNat64) return isBlockedIpv4Long((h[6] << 16 >>> 0 | h[7]) >>> 0);
|
|
356
|
+
if (h[0] === 8193 && (h[1] & 65024) === 0) return true;
|
|
357
|
+
if (h[0] === 8193 && h[1] === 3512) return true;
|
|
358
|
+
if (h[0] === 8194) return true;
|
|
359
|
+
if (h[0] === 100 && h[1] === 65435 && h[2] === 1) return true;
|
|
360
|
+
if (h[0] === 256 && h[1] === 0 && h[2] === 0 && h[3] === 0) return true;
|
|
279
361
|
if ((h[0] & 65024) === 64512) return true;
|
|
280
362
|
if ((h[0] & 65472) === 65152) return true;
|
|
363
|
+
if ((h[0] & 65472) === 65216) return true;
|
|
281
364
|
if ((h[0] & 65280) === 65280) return true;
|
|
282
365
|
return false;
|
|
283
366
|
};
|
|
@@ -331,30 +414,35 @@ const assertSafeFetchTarget = async (rawUrl) => {
|
|
|
331
414
|
* connects to the address it validated, and re-validates and re-pins every
|
|
332
415
|
* redirect hop (redirects are followed manually up to {@link MAX_REDIRECTS}).
|
|
333
416
|
* Intermediate redirect bodies are cancelled; non-redirect responses are
|
|
334
|
-
* returned unchanged.
|
|
417
|
+
* returned unchanged. Each hop carries the method, body, and credential headers
|
|
418
|
+
* the Fetch standard says it should — see {@link applyRedirectSemantics}.
|
|
335
419
|
*
|
|
336
|
-
*
|
|
337
|
-
* `init.dispatcher`, non-stock global dispatcher, env-proxy
|
|
338
|
-
* pinned
|
|
420
|
+
* By default, a hop whose effective dispatcher is a configured route
|
|
421
|
+
* (caller-supplied `init.dispatcher`, non-stock global dispatcher, env-proxy
|
|
422
|
+
* mode) is *not* pinned. Set `requirePinnedConnection` to fail closed instead.
|
|
339
423
|
*/
|
|
340
|
-
const ssrfSafeFetch = async (rawUrl, init = {},
|
|
424
|
+
const ssrfSafeFetch = async (rawUrl, init = {}, optionsOrMaxRedirects = {}) => {
|
|
425
|
+
const options = typeof optionsOrMaxRedirects === "number" ? { maxRedirects: optionsOrMaxRedirects } : optionsOrMaxRedirects;
|
|
426
|
+
const maxRedirects = options.maxRedirects ?? MAX_REDIRECTS;
|
|
341
427
|
let currentUrl = rawUrl;
|
|
428
|
+
let currentInit = init;
|
|
342
429
|
for (let hop = 0; hop <= maxRedirects; hop++) {
|
|
343
430
|
const addresses = await assertSafeFetchTarget(currentUrl);
|
|
344
431
|
const isBun = typeof process.versions.bun === "string";
|
|
345
|
-
const respectConfiguredRoute =
|
|
432
|
+
const respectConfiguredRoute = currentInit.dispatcher !== void 0 || envProxyApplies(new URL(currentUrl), isBun) || hasCustomGlobalDispatcher();
|
|
433
|
+
if (options.requirePinnedConnection && respectConfiguredRoute) throw new ComposioBlockedInternalUrlError("Refusing to fetch through a configured network route because the validated address cannot be pinned", { url: currentUrl });
|
|
346
434
|
const dispatcher = respectConfiguredRoute || isBun ? void 0 : await createPinnedDispatcher(addresses);
|
|
347
435
|
let response;
|
|
348
436
|
try {
|
|
349
437
|
if (isBun && !respectConfiguredRoute) response = await pinnedHttpFetch(currentUrl, {
|
|
350
|
-
...
|
|
438
|
+
...currentInit,
|
|
351
439
|
redirect: "manual"
|
|
352
440
|
}, addresses);
|
|
353
441
|
else response = await fetch(currentUrl, dispatcher === void 0 ? {
|
|
354
|
-
...
|
|
442
|
+
...currentInit,
|
|
355
443
|
redirect: "manual"
|
|
356
444
|
} : {
|
|
357
|
-
...
|
|
445
|
+
...currentInit,
|
|
358
446
|
redirect: "manual",
|
|
359
447
|
dispatcher
|
|
360
448
|
});
|
|
@@ -363,9 +451,11 @@ const ssrfSafeFetch = async (rawUrl, init = {}, maxRedirects = MAX_REDIRECTS) =>
|
|
|
363
451
|
throw error;
|
|
364
452
|
}
|
|
365
453
|
if (dispatcher !== void 0) dispatcher.close().catch(() => void 0);
|
|
366
|
-
if (!(
|
|
454
|
+
if (!(REDIRECT_STATUS_CODES.has(response.status) && response.headers.has("location"))) return response;
|
|
367
455
|
await response.body?.cancel().catch(() => void 0);
|
|
368
|
-
|
|
456
|
+
const nextUrl = new URL(response.headers.get("location"), currentUrl).toString();
|
|
457
|
+
currentInit = applyRedirectSemantics(currentInit, response.status, currentUrl, nextUrl);
|
|
458
|
+
currentUrl = nextUrl;
|
|
369
459
|
}
|
|
370
460
|
throw new ComposioBlockedInternalUrlError(`Refusing to fetch: too many redirects (max ${maxRedirects})`, { url: rawUrl });
|
|
371
461
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ComposioConfig } from "./composio-
|
|
1
|
+
import { tr as BaseComposioProvider } from "./customTool.types-C436M_D0.mjs";
|
|
2
|
+
import { n as ComposioConfig } from "./composio-B36OXii1.mjs";
|
|
3
3
|
//#region src/utils/config-defaults/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Configuration defaults for Composio.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as ConfigDefaults } from "../../types-
|
|
1
|
+
import { t as ConfigDefaults } from "../../types-Br3GBya5.mjs";
|
|
2
2
|
//#region src/utils/config-defaults/ConfigDefaults.node.d.ts
|
|
3
|
-
declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { CONFIG_DEFAULTS };
|
|
3
|
+
export declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
4
|
+
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as ConfigDefaults } from "../../types-
|
|
1
|
+
import { t as ConfigDefaults } from "../../types-Br3GBya5.mjs";
|
|
2
2
|
//#region src/utils/config-defaults/ConfigDefaults.workerd.d.ts
|
|
3
|
-
declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { CONFIG_DEFAULTS };
|
|
3
|
+
export declare const CONFIG_DEFAULTS: ConfigDefaults;
|
|
4
|
+
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Sa as ToolExecuteResponse, _a as Tool, ba as ToolExecuteParams } from "../../customTool.types-C436M_D0.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
//#region src/utils/modifiers/FileToolModifier.node.d.ts
|
|
4
|
-
declare class FileToolModifier {
|
|
4
|
+
export declare class FileToolModifier {
|
|
5
5
|
private client;
|
|
6
6
|
private fileUploadPathOptions;
|
|
7
7
|
constructor(client: ComposioClient, fileUploadPathOptions?: FileToolModifier['fileUploadPathOptions']);
|
|
@@ -19,5 +19,4 @@ declare class FileToolModifier {
|
|
|
19
19
|
signal?: AbortSignal;
|
|
20
20
|
}): Promise<ToolExecuteResponse>;
|
|
21
21
|
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { FileToolModifier };
|
|
22
|
+
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as logger } from "../../SsrfErrors-
|
|
2
|
-
import {
|
|
3
|
-
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-
|
|
4
|
-
import { a as isEmptyFileValue, c as transformProperties, i as getSchemaVariants, l as walkFileUploadableLeaves, o as isPlainObject, r as findSchemaVariantWithFileProperty, t as DELETE_VALUE } from "../../FileToolModifier.utils.neutral-
|
|
5
|
-
import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-
|
|
6
|
-
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-
|
|
1
|
+
import { i as logger } from "../../SsrfErrors-DiQldIdC.mjs";
|
|
2
|
+
import { g as ComposioRequestCancelledError } from "../../errors-D_A4b2c2.mjs";
|
|
3
|
+
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-CdGSABoq.mjs";
|
|
4
|
+
import { a as isEmptyFileValue, c as transformProperties, i as getSchemaVariants, l as walkFileUploadableLeaves, o as isPlainObject, r as findSchemaVariantWithFileProperty, t as DELETE_VALUE } from "../../FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
5
|
+
import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-Dwa9lGHA.mjs";
|
|
6
|
+
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-DNLhLg0W.mjs";
|
|
7
7
|
|
|
8
8
|
//#region src/utils/modifiers/FileToolModifier.node.ts
|
|
9
9
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Sa as ToolExecuteResponse, _a as Tool, ba as ToolExecuteParams } from "../../customTool.types-C436M_D0.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
//#region src/utils/modifiers/FileToolModifier.workerd.d.ts
|
|
4
|
-
declare class FileToolModifier {
|
|
4
|
+
export declare class FileToolModifier {
|
|
5
5
|
constructor(_client: ComposioClient);
|
|
6
6
|
modifyToolSchema(schema: Tool): Promise<Tool>;
|
|
7
7
|
fileUploadModifier(_tool: Tool, _options: {
|
|
@@ -17,5 +17,4 @@ declare class FileToolModifier {
|
|
|
17
17
|
signal?: AbortSignal;
|
|
18
18
|
}): Promise<ToolExecuteResponse>;
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { FileToolModifier };
|
|
20
|
+
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as transformProperties } from "../../FileToolModifier.utils.neutral-
|
|
1
|
+
import { c as transformProperties } from "../../FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/modifiers/FileToolModifier.workerd.ts
|
|
4
4
|
const UNSUPPORTED_MESSAGE = "File upload/download modifiers are not available on edge runtimes yet. Please set `dangerouslyAllowAutoUploadDownloadFiles: false` (or unset it; it defaults to false) or run Composio in another JS runtime (Node.js / Bun).";
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
//#region src/utils/ssrfGuard.node.d.ts
|
|
2
|
+
export interface SsrfSafeFetchOptions {
|
|
3
|
+
/** Maximum number of redirects to follow. Defaults to 5. */
|
|
4
|
+
maxRedirects?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Refuse a request when a configured dispatcher or environment proxy means
|
|
7
|
+
* the connection cannot be pinned to the address validated by the guard.
|
|
8
|
+
*/
|
|
9
|
+
requirePinnedConnection?: boolean;
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* True when `ip` is a private, loopback, link-local, or otherwise
|
|
4
13
|
* non-publicly-routable address. Fails closed (returns `true`) for anything that
|
|
5
14
|
* is not a valid IPv4/IPv6 literal.
|
|
6
15
|
*/
|
|
7
|
-
declare const isBlockedIp: (ip: string) => boolean;
|
|
16
|
+
export declare const isBlockedIp: (ip: string) => boolean;
|
|
8
17
|
/**
|
|
9
18
|
* Validate a single URL: it must be http(s), its host must resolve, and every
|
|
10
19
|
* resolved address must be publicly routable. Throws
|
|
@@ -14,19 +23,20 @@ declare const isBlockedIp: (ip: string) => boolean;
|
|
|
14
23
|
* must connect to *those* rather than let the client resolve the hostname
|
|
15
24
|
* again; see {@link ssrfSafeFetch}.
|
|
16
25
|
*/
|
|
17
|
-
declare const assertSafeFetchTarget: (rawUrl: string) => Promise<string[]>;
|
|
26
|
+
export declare const assertSafeFetchTarget: (rawUrl: string) => Promise<string[]>;
|
|
18
27
|
/**
|
|
19
28
|
* Drop-in replacement for `fetch` that blocks SSRF. Validates the target, then
|
|
20
29
|
* connects to the address it validated, and re-validates and re-pins every
|
|
21
30
|
* redirect hop (redirects are followed manually up to {@link MAX_REDIRECTS}).
|
|
22
31
|
* Intermediate redirect bodies are cancelled; non-redirect responses are
|
|
23
|
-
* returned unchanged.
|
|
32
|
+
* returned unchanged. Each hop carries the method, body, and credential headers
|
|
33
|
+
* the Fetch standard says it should — see {@link applyRedirectSemantics}.
|
|
24
34
|
*
|
|
25
|
-
*
|
|
26
|
-
* `init.dispatcher`, non-stock global dispatcher, env-proxy
|
|
27
|
-
* pinned
|
|
35
|
+
* By default, a hop whose effective dispatcher is a configured route
|
|
36
|
+
* (caller-supplied `init.dispatcher`, non-stock global dispatcher, env-proxy
|
|
37
|
+
* mode) is *not* pinned. Set `requirePinnedConnection` to fail closed instead.
|
|
28
38
|
*/
|
|
29
|
-
declare const ssrfSafeFetch: (rawUrl: string, init?: RequestInit,
|
|
39
|
+
export declare const ssrfSafeFetch: (rawUrl: string, init?: RequestInit, optionsOrMaxRedirects?: SsrfSafeFetchOptions | number) => Promise<Response>;
|
|
30
40
|
/**
|
|
31
41
|
* {@link ssrfSafeFetch} for call sites that must keep working on every runtime.
|
|
32
42
|
*
|
|
@@ -36,6 +46,5 @@ declare const ssrfSafeFetch: (rawUrl: string, init?: RequestInit, maxRedirects?:
|
|
|
36
46
|
* feature from Workers rather than close a hole reachable there. On Node this
|
|
37
47
|
* is the full guard; only the edge build differs.
|
|
38
48
|
*/
|
|
39
|
-
declare const ssrfSafeFetchWhereSupported: (rawUrl: string, init?: RequestInit,
|
|
40
|
-
//#endregion
|
|
41
|
-
export { assertSafeFetchTarget, isBlockedIp, ssrfSafeFetch, ssrfSafeFetchWhereSupported };
|
|
49
|
+
export declare const ssrfSafeFetchWhereSupported: (rawUrl: string, init?: RequestInit, optionsOrMaxRedirects?: SsrfSafeFetchOptions | number) => Promise<Response>;
|
|
50
|
+
//#endregion
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as ssrfSafeFetchWhereSupported, n as isBlockedIp, r as ssrfSafeFetch, t as assertSafeFetchTarget } from "../ssrfGuard.node-
|
|
1
|
+
import { i as ssrfSafeFetchWhereSupported, n as isBlockedIp, r as ssrfSafeFetch, t as assertSafeFetchTarget } from "../ssrfGuard.node-BZ270bcu.mjs";
|
|
2
2
|
|
|
3
3
|
export { assertSafeFetchTarget, isBlockedIp, ssrfSafeFetch, ssrfSafeFetchWhereSupported };
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
//#region src/utils/ssrfGuard.workerd.d.ts
|
|
2
|
+
export interface SsrfSafeFetchOptions {
|
|
3
|
+
/** Maximum number of redirects to follow. Defaults to 5. */
|
|
4
|
+
maxRedirects?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Refuse a request when a configured dispatcher or environment proxy means
|
|
7
|
+
* the connection cannot be pinned to the address validated by the guard.
|
|
8
|
+
*/
|
|
9
|
+
requirePinnedConnection?: boolean;
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* Edge runtimes do not expose the DNS resolution APIs needed to prove that a
|
|
4
13
|
* hostname is publicly routable before connecting. Fail closed instead of
|
|
5
14
|
* falling back to an unguarded fetch.
|
|
6
15
|
*/
|
|
7
|
-
declare const ssrfSafeFetch: (rawUrl: string, _init?: RequestInit,
|
|
16
|
+
export declare const ssrfSafeFetch: (rawUrl: string, _init?: RequestInit, _optionsOrMaxRedirects?: SsrfSafeFetchOptions | number) => Promise<Response>;
|
|
8
17
|
/**
|
|
9
18
|
* Unguarded `fetch`, for the call sites that must keep working here.
|
|
10
19
|
*
|
|
@@ -16,6 +25,5 @@ declare const ssrfSafeFetch: (rawUrl: string, _init?: RequestInit, _maxRedirects
|
|
|
16
25
|
* check, and its `fetch` does not originate inside the caller's network. The
|
|
17
26
|
* Node build applies the full guard.
|
|
18
27
|
*/
|
|
19
|
-
declare const ssrfSafeFetchWhereSupported: (rawUrl: string, init?: RequestInit) => Promise<Response>;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ssrfSafeFetch, ssrfSafeFetchWhereSupported };
|
|
28
|
+
export declare const ssrfSafeFetchWhereSupported: (rawUrl: string, init?: RequestInit) => Promise<Response>;
|
|
29
|
+
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ComposioBlockedInternalUrlError } from "../SsrfErrors-
|
|
1
|
+
import { t as ComposioBlockedInternalUrlError } from "../SsrfErrors-DiQldIdC.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/ssrfGuard.workerd.ts
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ import { t as ComposioBlockedInternalUrlError } from "../SsrfErrors-xhdVE4yw.mjs
|
|
|
6
6
|
* hostname is publicly routable before connecting. Fail closed instead of
|
|
7
7
|
* falling back to an unguarded fetch.
|
|
8
8
|
*/
|
|
9
|
-
const ssrfSafeFetch = async (rawUrl, _init = {},
|
|
9
|
+
const ssrfSafeFetch = async (rawUrl, _init = {}, _optionsOrMaxRedirects = {}) => {
|
|
10
10
|
throw new ComposioBlockedInternalUrlError("URL file uploads are not supported in edge runtimes because the destination cannot be safely validated", {
|
|
11
11
|
url: rawUrl,
|
|
12
12
|
possibleFixes: ["Fetch the public URL yourself and pass a File or ArrayBuffer instead", "Run the URL upload in a Node.js or Bun runtime"]
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22.22.3"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.20.0",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "dist/index.mjs",
|
|
10
10
|
"publishConfig": {
|
|
@@ -112,27 +112,27 @@
|
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@type-challenges/utils": "^0.1.1",
|
|
114
114
|
"@types/semver": "^7.8.0",
|
|
115
|
-
"tsdown": "^0.
|
|
116
|
-
"tsx": "^4.23.
|
|
115
|
+
"tsdown": "^0.23.0",
|
|
116
|
+
"tsx": "^4.23.13",
|
|
117
117
|
"typedoc": "^0.28.20",
|
|
118
118
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
119
|
-
"vitest": "^
|
|
120
|
-
"zod": "^4.4
|
|
119
|
+
"vitest": "^5.0.1",
|
|
120
|
+
"zod": "^4.5.4"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"zod": ">=3.25.76 <5"
|
|
124
124
|
},
|
|
125
125
|
"dependencies": {
|
|
126
|
-
"@composio/client": "0.
|
|
126
|
+
"@composio/client": "2.0.0-rc.8",
|
|
127
127
|
"@types/json-schema": "^7.0.15",
|
|
128
128
|
"is-fs-case-sensitive": "^2.0.0",
|
|
129
|
-
"openai": "^7.
|
|
129
|
+
"openai": "^7.15.0",
|
|
130
130
|
"picocolors": "^1.1.1",
|
|
131
131
|
"pusher-js": "^8.6.0",
|
|
132
132
|
"semver": "^7.8.5",
|
|
133
|
-
"undici": "^7.29.
|
|
133
|
+
"undici": "^7.29.1",
|
|
134
134
|
"zod-to-json-schema": "^3.25.2",
|
|
135
|
-
"@composio/json-schema-to-zod": "0.3.
|
|
135
|
+
"@composio/json-schema-to-zod": "0.3.3"
|
|
136
136
|
},
|
|
137
137
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
138
138
|
"repository": {
|