@composio/core 0.18.0 → 0.19.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-C4tv-GL1.mjs → CustomTool-BMlZfJVz.mjs} +16 -6
- package/dist/{CustomTool-BKhHv2hJ.d.mts → CustomTool-CB5vm1Jc.d.mts} +1 -1
- package/dist/{FileModifierErrors-B8V8_3VE.mjs → FileModifierErrors-BqFmpRsm.mjs} +1 -1
- package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
- package/dist/{SsrfErrors-DNJt57GL.mjs → SsrfErrors-C91YhASE.mjs} +137 -13
- package/dist/{Telemetry-CBtSnWrm.mjs → Telemetry-HlftxMx6.mjs} +2 -34
- package/dist/{cancellation-jUVItfHw.mjs → cancellation-CXpfmiVo.mjs} +7 -5
- package/dist/{composio-CldtZUyC.d.mts → composio-DLGaeN70.d.mts} +333 -32
- package/dist/{customTool.types-DC5fPOOi.d.mts → customTool.types-BAmEh3MB.d.mts} +131 -38
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +3 -13
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +50 -6
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +4 -4
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +33 -23
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +3 -2
- package/dist/{errors-DyZt79fi.mjs → errors-BuEKehbI.mjs} +23 -3
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-BwpUOF0s.mjs → fileUtils.node-L7XD8UPr.mjs} +11 -9
- package/dist/index.d.mts +164 -104
- package/dist/index.mjs +382 -153
- 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-B0w8dqpv.mjs → sensitiveFileUploadPaths-B6pBt9lO.mjs} +10 -7
- package/dist/{ssrfGuard.node-DlxO8uzr.mjs → ssrfGuard.node-B9xQB4za.mjs} +197 -30
- package/dist/{types-BgsRW-XH.d.mts → types-CxLPO0Xq.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 +26 -8
- package/src/errors/ToolErrors.ts +24 -0
- package/src/index.ts +4 -0
- package/src/models/CustomTool.ts +41 -6
- package/src/models/MCP.ts +29 -15
- package/src/models/RemoteFile.ts +54 -36
- package/src/models/ToolRouter.ts +1 -0
- package/src/models/ToolRouterSession.ts +115 -13
- package/src/models/Toolkits.ts +1 -2
- package/src/models/Tools.ts +55 -25
- package/src/models/Triggers.ts +22 -2
- package/src/services/pusher/Pusher.ts +29 -10
- package/src/telemetry/redact.ts +133 -6
- package/src/types/toolRouter.types.ts +54 -3
- package/src/types/toolkit.types.ts +17 -0
- package/src/utils/fileUtils.node.ts +10 -2
- package/src/utils/jsonSchema.ts +4 -1
- package/src/utils/logger.ts +6 -6
- package/src/utils/pinnedDispatcher.node.ts +109 -13
- package/src/utils/sdk.ts +1 -1
- package/src/utils/ssrfGuard.node.ts +153 -27
- package/src/utils/ssrfGuard.workerd.ts +15 -1
- package/src/utils/transformers/toolkits.ts +79 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ValidationError } from "./errors-
|
|
1
|
+
import { _ as ValidationError } from "./errors-BuEKehbI.mjs";
|
|
2
2
|
import { z as z$1 } from "zod/v3";
|
|
3
3
|
import * as z4 from "zod/v4";
|
|
4
4
|
import * as zodToJsonSchema from "zod-to-json-schema";
|
|
@@ -375,26 +375,32 @@ function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
|
|
|
375
375
|
};
|
|
376
376
|
for (const handle of tools) registerHandle(handle, handle.extendsToolkit);
|
|
377
377
|
if (toolkits) for (const tk of toolkits) for (const handle of tk.tools) registerHandle(handle, tk.slug);
|
|
378
|
-
const findHandle = (originalSlug, toolkit) => {
|
|
378
|
+
const findHandle = (finalSlug, originalSlug, toolkit) => {
|
|
379
379
|
const originalSlugKey = originalSlug.toUpperCase();
|
|
380
380
|
const qualifiedMatch = handlesByQualifiedOriginalSlug.get(qualifiedOriginalSlugKey(toolkit, originalSlugKey));
|
|
381
381
|
if (qualifiedMatch) return qualifiedMatch;
|
|
382
382
|
const bareMatches = handlesByOriginalSlug.get(originalSlugKey) ?? [];
|
|
383
|
-
|
|
383
|
+
if (bareMatches.length === 0) return void 0;
|
|
384
|
+
if (toolkit === void 0 && bareMatches.length === 1) return bareMatches[0];
|
|
385
|
+
const registered = [...new Set(bareMatches.map((m) => (m.toolkit ?? "custom").toUpperCase()))].sort();
|
|
386
|
+
throw new ValidationError(`Cannot map custom tool "${finalSlug}": original slug "${originalSlug}" for toolkit "${toolkit ?? "custom"}" has no exact local match. Registered for toolkits: ${registered.join(", ")}.`);
|
|
384
387
|
};
|
|
385
388
|
const addEntry = (finalSlug, originalSlug, toolkit) => {
|
|
386
389
|
const resolvedToolkit = toolkit ?? void 0;
|
|
387
|
-
const match = findHandle(originalSlug, resolvedToolkit);
|
|
390
|
+
const match = findHandle(finalSlug, originalSlug, resolvedToolkit);
|
|
388
391
|
if (!match) return;
|
|
389
392
|
const finalSlugKey = finalSlug.toUpperCase();
|
|
390
393
|
if (byFinalSlug.has(finalSlugKey)) throw new ValidationError(`Custom tool slug collision: "${finalSlug}" is already registered.`);
|
|
394
|
+
const entryToolkit = resolvedToolkit ?? match.toolkit;
|
|
395
|
+
const qualifiedKey = qualifiedOriginalSlugKey(entryToolkit, originalSlug);
|
|
396
|
+
if (byToolkitAndOriginalSlug.has(qualifiedKey)) throw new ValidationError(`Custom tool slug collision: original slug "${match.handle.slug}" is already registered for toolkit "${entryToolkit ?? "custom"}".`);
|
|
391
397
|
const entry = {
|
|
392
398
|
handle: match.handle,
|
|
393
399
|
finalSlug,
|
|
394
|
-
toolkit:
|
|
400
|
+
toolkit: entryToolkit
|
|
395
401
|
};
|
|
396
402
|
byFinalSlug.set(finalSlugKey, entry);
|
|
397
|
-
byToolkitAndOriginalSlug.set(
|
|
403
|
+
byToolkitAndOriginalSlug.set(qualifiedKey, entry);
|
|
398
404
|
addOriginalSlugAlias({
|
|
399
405
|
byOriginalSlug,
|
|
400
406
|
ambiguousOriginalSlugs,
|
|
@@ -404,6 +410,10 @@ function buildCustomToolsMapFromResponse(tools, toolkits, experimental) {
|
|
|
404
410
|
};
|
|
405
411
|
if (experimental?.custom_tools) for (const ct of experimental.custom_tools) addEntry(ct.slug, ct.original_slug, ct.extends_toolkit);
|
|
406
412
|
if (experimental?.custom_toolkits) for (const ctk of experimental.custom_toolkits) for (const ct of ctk.tools) addEntry(ct.slug, ct.original_slug, ctk.slug);
|
|
413
|
+
for (const [originalSlugKey, matches] of handlesByOriginalSlug) if (matches.length > 1) {
|
|
414
|
+
byOriginalSlug.delete(originalSlugKey);
|
|
415
|
+
ambiguousOriginalSlugs.add(originalSlugKey);
|
|
416
|
+
}
|
|
407
417
|
return {
|
|
408
418
|
byFinalSlug,
|
|
409
419
|
byOriginalSlug,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-
|
|
1
|
+
import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-BAmEh3MB.mjs";
|
|
2
2
|
import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
|
|
3
3
|
//#region src/models/CustomTool.d.ts
|
|
4
4
|
/**
|
|
@@ -19,8 +19,10 @@ const transformSchema = (property) => {
|
|
|
19
19
|
if (property.anyOf) newProperty.anyOf = property.anyOf.map(transformSchema);
|
|
20
20
|
if (property.oneOf) newProperty.oneOf = property.oneOf.map(transformSchema);
|
|
21
21
|
if (property.allOf) newProperty.allOf = property.allOf.map(transformSchema);
|
|
22
|
-
if (property.items)
|
|
23
|
-
|
|
22
|
+
if (property.items) {
|
|
23
|
+
if (Array.isArray(property.items)) newProperty.items = property.items.map(transformSchema);
|
|
24
|
+
else newProperty.items = transformSchema(property.items);
|
|
25
|
+
}
|
|
24
26
|
return newProperty;
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
@@ -55,6 +55,125 @@ const COMPOSIO_LOG_LEVEL = getEnvVariable("COMPOSIO_LOG_LEVEL");
|
|
|
55
55
|
const IS_DEVELOPMENT_OR_CI = getEnvVariable("DEVELOPMENT") || getEnvVariable("CI") || false;
|
|
56
56
|
const DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID = "files";
|
|
57
57
|
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/telemetry/redact.ts
|
|
60
|
+
/**
|
|
61
|
+
* Best-effort redaction of secrets from free-form error text before it is sent
|
|
62
|
+
* to the telemetry endpoint.
|
|
63
|
+
*
|
|
64
|
+
* Error `message` and `stack` fields routinely interpolate URLs (with
|
|
65
|
+
* query-string tokens / presigned signatures), `Authorization` headers, API
|
|
66
|
+
* keys, and connected-account identifiers. None of that should leave the
|
|
67
|
+
* process. Structured telemetry fields never carry raw secrets, so only the two
|
|
68
|
+
* free-form strings are passed through here.
|
|
69
|
+
*
|
|
70
|
+
* This is defence-in-depth, not a proof: it targets the shapes we have seen
|
|
71
|
+
* leak. When in doubt it over-redacts rather than under-redacts.
|
|
72
|
+
*/
|
|
73
|
+
const REDACTED = "[REDACTED]";
|
|
74
|
+
const SECRET_KEY_PATTERN = String.raw`authorization|auth|api[-_]?key|apikey|x-api-key|access[-_]?token|refresh[-_]?token|client[-_]?secret|secret|password|passwd|pwd`;
|
|
75
|
+
const SECRET_KEY_WITH_PREFIX_PATTERN = String.raw`(?:[A-Za-z0-9]+_)*(?:${SECRET_KEY_PATTERN})`;
|
|
76
|
+
const QUOTED_SECRET_KEY_PREFIX = String.raw`(["'])(${SECRET_KEY_WITH_PREFIX_PATTERN})\1(\s*[:=]+\s*)`;
|
|
77
|
+
const BARE_SECRET_KEY_PREFIX = String.raw`(?<![A-Za-z0-9"'])(${SECRET_KEY_PATTERN})\b(\s*[:=]+\s*)`;
|
|
78
|
+
const ESCAPED_SECRET_KEY_PREFIX = String.raw`(?<![A-Za-z0-9])(${SECRET_KEY_PATTERN})\b((?:\\["'])?\s*[:=]+\s*)`;
|
|
79
|
+
const SECRET_PAIR_PREFIX = String.raw`(?<![A-Za-z0-9])(${SECRET_KEY_PATTERN})\b(["']?\s*[:=]+\s*)`;
|
|
80
|
+
const BARE_KEY_DOUBLE_QUOTED_VALUE = new RegExp(String.raw`${BARE_SECRET_KEY_PREFIX}"((?:\\.|[^"\\\r\n])*)"`, "gi");
|
|
81
|
+
const BARE_KEY_SINGLE_QUOTED_VALUE = new RegExp(String.raw`${BARE_SECRET_KEY_PREFIX}'((?:\\.|[^'\\\r\n])*)'`, "gi");
|
|
82
|
+
const BARE_KEY_ESCAPED_DOUBLE_QUOTED_VALUE = new RegExp(String.raw`${ESCAPED_SECRET_KEY_PREFIX}\\"((?:\\.|[^"\\\r\n])*)\\"`, "gi");
|
|
83
|
+
const BARE_KEY_ESCAPED_SINGLE_QUOTED_VALUE = new RegExp(String.raw`${ESCAPED_SECRET_KEY_PREFIX}\\'((?:\\.|[^'\\\r\n])*)\\'`, "gi");
|
|
84
|
+
const SECRET_PAIR_UNQUOTED = new RegExp(String.raw`${SECRET_PAIR_PREFIX}(?!\\["'])([^\s"',}&]+)`, "gi");
|
|
85
|
+
const CONTAINS_QUOTED_FIELD = /(?:^|[,{\s])(["'])[^"'\\\r\n]+\1\s*[:=]\s*$/;
|
|
86
|
+
const REDACTION_RULES = [
|
|
87
|
+
[/(\bhttps?:\/\/[^\s?#'"]+)\?[^\s'"]*/gi, `$1?${REDACTED}`],
|
|
88
|
+
[/\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]+/gi, `$1 ${REDACTED}`],
|
|
89
|
+
[new RegExp(String.raw`${QUOTED_SECRET_KEY_PREFIX}"(?:\\.|[^"\\\r\n])*"`, "gi"), `$1$2$1$3"${REDACTED}"`],
|
|
90
|
+
[new RegExp(String.raw`${QUOTED_SECRET_KEY_PREFIX}'(?:\\.|[^'\\\r\n])*'`, "gi"), `$1$2$1$3'${REDACTED}'`]
|
|
91
|
+
];
|
|
92
|
+
const isWordCharacter = (character) => /[\p{L}\p{N}_]/u.test(character);
|
|
93
|
+
const activeQuotesAt = (input, offsets) => {
|
|
94
|
+
const activeQuotes = /* @__PURE__ */ new Map();
|
|
95
|
+
let quote;
|
|
96
|
+
let escaped = false;
|
|
97
|
+
let lastOffset = -1;
|
|
98
|
+
for (const offset of offsets) lastOffset = Math.max(lastOffset, offset);
|
|
99
|
+
for (let position = 0; position < input.length; position += 1) {
|
|
100
|
+
const character = input[position];
|
|
101
|
+
if (offsets.has(position)) {
|
|
102
|
+
activeQuotes.set(position, quote);
|
|
103
|
+
if (position === lastOffset) break;
|
|
104
|
+
}
|
|
105
|
+
if (character === "\n" || character === "\r") {
|
|
106
|
+
quote = void 0;
|
|
107
|
+
escaped = false;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const previous = position > 0 && !["\n", "\r"].includes(input[position - 1]) ? input[position - 1] : "";
|
|
111
|
+
const following = input[position + 1] ?? "";
|
|
112
|
+
if (!quote) {
|
|
113
|
+
if (character === "\"" || character === "'" && !isWordCharacter(previous)) quote = character;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (escaped) escaped = false;
|
|
117
|
+
else if (character === "\\") escaped = true;
|
|
118
|
+
else if (character === quote) {
|
|
119
|
+
if (quote === "'" && isWordCharacter(previous) && isWordCharacter(following)) continue;
|
|
120
|
+
quote = void 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return activeQuotes;
|
|
124
|
+
};
|
|
125
|
+
const completesQuotedFieldAt = (input, index, quote) => {
|
|
126
|
+
let escaped = false;
|
|
127
|
+
for (let position = index; position < input.length; position += 1) {
|
|
128
|
+
const character = input[position];
|
|
129
|
+
if (character === "\n" || character === "\r") return false;
|
|
130
|
+
if (escaped) {
|
|
131
|
+
escaped = false;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (character === "\\") {
|
|
135
|
+
escaped = true;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (character !== quote) continue;
|
|
139
|
+
let separator = position + 1;
|
|
140
|
+
while (separator < input.length && /\s/.test(input[separator])) separator += 1;
|
|
141
|
+
return input[separator] === ":" || input[separator] === "=";
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
};
|
|
145
|
+
const redactBareQuotedValue = (input, pattern, quote) => {
|
|
146
|
+
pattern.lastIndex = 0;
|
|
147
|
+
const matches = Array.from(input.matchAll(pattern));
|
|
148
|
+
if (matches.length === 0) return input;
|
|
149
|
+
const activeQuotes = activeQuotesAt(input, new Set(matches.map((match) => match.index)));
|
|
150
|
+
const parts = [];
|
|
151
|
+
let cursor = 0;
|
|
152
|
+
for (const match of matches) {
|
|
153
|
+
const offset = match.index;
|
|
154
|
+
parts.push(input.slice(cursor, offset));
|
|
155
|
+
if (activeQuotes.get(offset) === quote && (completesQuotedFieldAt(input, offset + match[0].length, quote) || CONTAINS_QUOTED_FIELD.test(match[3]))) parts.push(match[0]);
|
|
156
|
+
else parts.push(`${match[1]}${match[2]}${quote}${REDACTED}${quote}`);
|
|
157
|
+
cursor = offset + match[0].length;
|
|
158
|
+
}
|
|
159
|
+
parts.push(input.slice(cursor));
|
|
160
|
+
return parts.join("");
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Redact common secret shapes from a free-form string. Returns the input
|
|
164
|
+
* unchanged when it is empty or `undefined`.
|
|
165
|
+
*/
|
|
166
|
+
const redactSensitiveText = (input) => {
|
|
167
|
+
if (!input) return input;
|
|
168
|
+
let output = input;
|
|
169
|
+
for (const [pattern, replacement] of REDACTION_RULES) output = output.replace(pattern, replacement);
|
|
170
|
+
output = output.replace(BARE_KEY_ESCAPED_DOUBLE_QUOTED_VALUE, `$1$2\\"${REDACTED}\\"`);
|
|
171
|
+
output = output.replace(BARE_KEY_ESCAPED_SINGLE_QUOTED_VALUE, `$1$2\\'${REDACTED}\\'`);
|
|
172
|
+
output = redactBareQuotedValue(output, BARE_KEY_DOUBLE_QUOTED_VALUE, "\"");
|
|
173
|
+
output = redactBareQuotedValue(output, BARE_KEY_SINGLE_QUOTED_VALUE, "'");
|
|
174
|
+
return output.replace(SECRET_PAIR_UNQUOTED, `$1$2${REDACTED}`);
|
|
175
|
+
};
|
|
176
|
+
|
|
58
177
|
//#endregion
|
|
59
178
|
//#region src/utils/logger.ts
|
|
60
179
|
const LOG_LEVELS = {
|
|
@@ -86,14 +205,17 @@ var Logger = class {
|
|
|
86
205
|
const formattedArgs = args.map((arg, index) => {
|
|
87
206
|
if (typeof arg === "object") return JSON.stringify(arg);
|
|
88
207
|
else {
|
|
89
|
-
if (index === 0)
|
|
90
|
-
|
|
208
|
+
if (index === 0) {
|
|
209
|
+
if (args.length > 1) return pc.yellow(`${arg}`);
|
|
210
|
+
else return String(arg);
|
|
211
|
+
}
|
|
91
212
|
return String(arg);
|
|
92
213
|
}
|
|
93
214
|
}).join("\n");
|
|
94
|
-
|
|
215
|
+
const redactedArgs = redactSensitiveText(formattedArgs) ?? formattedArgs;
|
|
216
|
+
if (!this.includeTimestamp) return redactedArgs;
|
|
95
217
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
96
|
-
return `${pc.gray(timestamp)} - ${
|
|
218
|
+
return `${pc.gray(timestamp)} - ${redactedArgs}`;
|
|
97
219
|
}
|
|
98
220
|
shouldLog(level) {
|
|
99
221
|
return LOG_LEVELS[level] <= LOG_LEVELS[this.level];
|
|
@@ -200,14 +322,16 @@ var ComposioError$1 = class ComposioError$1 extends Error {
|
|
|
200
322
|
if (statusCode !== void 0) data.statusCode = statusCode;
|
|
201
323
|
if (meta) data.meta = meta;
|
|
202
324
|
if (possibleFixes) data.possibleFixes = possibleFixes;
|
|
203
|
-
if (includeStack && stack)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
325
|
+
if (includeStack && stack) {
|
|
326
|
+
if (stack.includes("Caused by:")) {
|
|
327
|
+
const [currentStack, causeStack] = stack.split("Caused by:");
|
|
328
|
+
data.stack = [
|
|
329
|
+
...currentStack.split("\n").slice(1),
|
|
330
|
+
"Caused by:",
|
|
331
|
+
...causeStack.split("\n")
|
|
332
|
+
];
|
|
333
|
+
} else data.stack = stack.split("\n").slice(1);
|
|
334
|
+
}
|
|
211
335
|
return data;
|
|
212
336
|
}
|
|
213
337
|
/**
|
|
@@ -381,4 +505,4 @@ var ComposioBlockedInternalUrlError = class extends ComposioError$1 {
|
|
|
381
505
|
};
|
|
382
506
|
|
|
383
507
|
//#endregion
|
|
384
|
-
export {
|
|
508
|
+
export { redactSensitiveText as a, DEFAULT_BASE_URL as c, TEMP_FILES_DIRECTORY_NAME as d, USER_DATA_FILE_NAME as f, getEnvsWithPrefix as h, logger as i, DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID as l, getEnvVariable as m, SsrfErrorCodes as n, COMPOSIO_DIR as o, constants_exports as p, ComposioError$1 as r, COMPOSIO_LOG_LEVEL as s, ComposioBlockedInternalUrlError as t, IS_DEVELOPMENT_OR_CI as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as logger,
|
|
2
|
-
import {
|
|
1
|
+
import { a as redactSensitiveText, i as logger, m as getEnvVariable, r as ComposioError$1 } from "./SsrfErrors-C91YhASE.mjs";
|
|
2
|
+
import { u as getRandomUUID } from "./sensitiveFileUploadPaths-B6pBt9lO.mjs";
|
|
3
3
|
import { ComposioError } from "@composio/client";
|
|
4
4
|
|
|
5
5
|
//#region src/types/telemetry.types.ts
|
|
@@ -115,38 +115,6 @@ var TelemetryService = class {
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/telemetry/redact.ts
|
|
120
|
-
/**
|
|
121
|
-
* Best-effort redaction of secrets from free-form error text before it is sent
|
|
122
|
-
* to the telemetry endpoint.
|
|
123
|
-
*
|
|
124
|
-
* Error `message` and `stack` fields routinely interpolate URLs (with
|
|
125
|
-
* query-string tokens / presigned signatures), `Authorization` headers, API
|
|
126
|
-
* keys, and connected-account identifiers. None of that should leave the
|
|
127
|
-
* process. Structured telemetry fields never carry raw secrets, so only the two
|
|
128
|
-
* free-form strings are passed through here.
|
|
129
|
-
*
|
|
130
|
-
* This is defence-in-depth, not a proof: it targets the shapes we have seen
|
|
131
|
-
* leak. When in doubt it over-redacts rather than under-redacts.
|
|
132
|
-
*/
|
|
133
|
-
const REDACTED = "[REDACTED]";
|
|
134
|
-
const REDACTION_RULES = [
|
|
135
|
-
[/(\bhttps?:\/\/[^\s?#'"]+)\?[^\s'"]*/gi, `$1?${REDACTED}`],
|
|
136
|
-
[/\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]+/gi, `$1 ${REDACTED}`],
|
|
137
|
-
[/(?<![A-Za-z0-9])(authorization|api[-_]?key|apikey|x-api-key|access[-_]?token|refresh[-_]?token|client[-_]?secret|secret|password|passwd|pwd)\b(["']?\s*[:=]+\s*)(["']?)([^\s"',}&]+)\3/gi, `$1$2$3${REDACTED}$3`]
|
|
138
|
-
];
|
|
139
|
-
/**
|
|
140
|
-
* Redact common secret shapes from a free-form string. Returns the input
|
|
141
|
-
* unchanged when it is empty or `undefined`.
|
|
142
|
-
*/
|
|
143
|
-
const redactSensitiveText = (input) => {
|
|
144
|
-
if (!input) return input;
|
|
145
|
-
let output = input;
|
|
146
|
-
for (const [pattern, replacement] of REDACTION_RULES) output = output.replace(pattern, replacement);
|
|
147
|
-
return output;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
118
|
//#endregion
|
|
151
119
|
//#region src/telemetry/Telemetry.ts
|
|
152
120
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as logger } from "./SsrfErrors-
|
|
2
|
-
import { f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, m as isRequestAbortError } from "./errors-
|
|
3
|
-
import { o as isPlainObject } from "./FileToolModifier.utils.neutral-
|
|
1
|
+
import { i as logger } from "./SsrfErrors-C91YhASE.mjs";
|
|
2
|
+
import { f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, m as isRequestAbortError } from "./errors-BuEKehbI.mjs";
|
|
3
|
+
import { o as isPlainObject } from "./FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
4
4
|
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/jsonSchema.ts
|
|
@@ -345,7 +345,8 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
|
|
|
345
345
|
if (strict && schema) schema = removeNonRequiredProperties(schema);
|
|
346
346
|
return jsonSchemaToZod(schema);
|
|
347
347
|
} catch (error) {
|
|
348
|
-
|
|
348
|
+
const detail = error instanceof Error ? `: ${error.message}` : "";
|
|
349
|
+
throw new JsonSchemaToZodError(`Failed to convert JSON Schema to Zod Schema${detail}`, { cause: error });
|
|
349
350
|
}
|
|
350
351
|
}
|
|
351
352
|
const MAX_STRICT_CHANGES = 50;
|
|
@@ -694,7 +695,8 @@ async function withCancellation(call, signal) {
|
|
|
694
695
|
} catch (error) {
|
|
695
696
|
if (signal?.aborted && isRequestAbortError(error)) {
|
|
696
697
|
const underlyingMessage = error instanceof Error ? error.message : "";
|
|
697
|
-
|
|
698
|
+
const message = underlyingMessage ? `Request was cancelled by the caller: ${underlyingMessage}` : "Request was cancelled by the caller";
|
|
699
|
+
throw new ComposioRequestCancelledError(message, { cause: error instanceof Error ? error : void 0 });
|
|
698
700
|
}
|
|
699
701
|
throw error;
|
|
700
702
|
}
|