@inkeep/agents-core 0.0.0-dev-20260125001234 → 0.0.0-dev-20260126174131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/auth/auth-schema.d.ts +82 -82
  2. package/dist/auth/auth.d.ts +57 -57
  3. package/dist/auth/permissions.d.ts +13 -13
  4. package/dist/client-exports.d.ts +3 -3
  5. package/dist/context/TemplateEngine.d.ts +0 -6
  6. package/dist/context/TemplateEngine.js +4 -18
  7. package/dist/data-access/manage/agents.d.ts +46 -46
  8. package/dist/data-access/manage/artifactComponents.d.ts +14 -14
  9. package/dist/data-access/manage/contextConfigs.d.ts +20 -20
  10. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  11. package/dist/data-access/manage/functionTools.d.ts +18 -18
  12. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
  13. package/dist/data-access/manage/subAgentRelations.d.ts +34 -34
  14. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  15. package/dist/data-access/manage/subAgents.d.ts +18 -18
  16. package/dist/data-access/manage/tools.d.ts +30 -30
  17. package/dist/data-access/runtime/apiKeys.d.ts +20 -20
  18. package/dist/data-access/runtime/conversations.d.ts +27 -27
  19. package/dist/data-access/runtime/messages.d.ts +15 -15
  20. package/dist/data-access/runtime/tasks.d.ts +6 -6
  21. package/dist/db/manage/manage-schema.d.ts +377 -377
  22. package/dist/db/runtime/runtime-schema.d.ts +181 -181
  23. package/dist/utils/JsonTransformer.d.ts +1 -3
  24. package/dist/utils/JsonTransformer.js +14 -23
  25. package/dist/utils/jmespath-utils.d.ts +152 -0
  26. package/dist/utils/jmespath-utils.js +213 -0
  27. package/dist/utils/signature-validation.d.ts +2 -39
  28. package/dist/utils/signature-validation.js +1 -69
  29. package/dist/utils/trigger-auth.js +3 -5
  30. package/dist/validation/dolt-schemas.d.ts +1 -1
  31. package/dist/validation/schemas.d.ts +1438 -1438
  32. package/dist/validation/schemas.js +32 -36
  33. package/package.json +1 -1
@@ -6,12 +6,10 @@ interface TransformOptions {
6
6
  }
7
7
  declare class JsonTransformer {
8
8
  private static readonly DEFAULT_TIMEOUT;
9
- private static readonly MAX_EXPRESSION_LENGTH;
10
- private static readonly DANGEROUS_PATTERNS;
11
9
  /**
12
10
  * Validate JMESPath expression for security and correctness
13
11
  */
14
- private static validateJMESPath;
12
+ private static validateExpression;
15
13
  /**
16
14
  * Execute JMESPath with timeout protection
17
15
  */
@@ -1,32 +1,23 @@
1
+ import { DANGEROUS_PATTERNS, MAX_EXPRESSION_LENGTH, compileJMESPath, validateJMESPathSecure } from "./jmespath-utils.js";
1
2
  import { getLogger } from "./logger.js";
2
- import * as jmespath$1 from "jmespath";
3
+ import * as jmespath from "jmespath";
3
4
 
4
5
  //#region src/utils/JsonTransformer.ts
5
- const jmespathExt = jmespath$1;
6
6
  const logger = getLogger("JsonTransformer");
7
7
  var JsonTransformer = class JsonTransformer {
8
8
  static DEFAULT_TIMEOUT = 5e3;
9
- static MAX_EXPRESSION_LENGTH = 1e3;
10
- static DANGEROUS_PATTERNS = [
11
- /\$\{.*\}/,
12
- /eval\s*\(/,
13
- /function\s*\(/,
14
- /constructor/,
15
- /prototype/,
16
- /__proto__/
17
- ];
18
9
  /**
19
10
  * Validate JMESPath expression for security and correctness
20
11
  */
21
- static validateJMESPath(expression, _allowedFunctions) {
12
+ static validateExpression(expression, _allowedFunctions) {
22
13
  if (!expression || typeof expression !== "string") throw new Error("JMESPath expression must be a non-empty string");
23
- if (expression.length > JsonTransformer.MAX_EXPRESSION_LENGTH) throw new Error(`JMESPath expression too long (max ${JsonTransformer.MAX_EXPRESSION_LENGTH} characters)`);
24
- for (const pattern of JsonTransformer.DANGEROUS_PATTERNS) if (pattern.test(expression)) throw new Error(`JMESPath expression contains dangerous pattern: ${pattern.source}`);
25
- try {
26
- jmespathExt.compile(expression);
27
- } catch (error) {
28
- throw new Error(`Invalid JMESPath syntax: ${error instanceof Error ? error.message : String(error)}`);
29
- }
14
+ if (expression.length > MAX_EXPRESSION_LENGTH) throw new Error(`JMESPath expression too long (max ${MAX_EXPRESSION_LENGTH} characters)`);
15
+ for (const pattern of DANGEROUS_PATTERNS) if (pattern.test(expression)) throw new Error(`JMESPath expression contains dangerous pattern: ${pattern.source}`);
16
+ const result = validateJMESPathSecure(expression, {
17
+ maxLength: MAX_EXPRESSION_LENGTH + 1,
18
+ dangerousPatterns: []
19
+ });
20
+ if (!result.valid) throw new Error(`Invalid JMESPath syntax: ${result.error}`);
30
21
  logger.debug("JMESPath expression validated", `${expression.substring(0, 100)}...`);
31
22
  }
32
23
  /**
@@ -38,7 +29,7 @@ var JsonTransformer = class JsonTransformer {
38
29
  reject(/* @__PURE__ */ new Error(`JMESPath transformation timed out after ${timeoutMs}ms`));
39
30
  }, timeoutMs);
40
31
  try {
41
- const result = jmespath$1.search(input, expression);
32
+ const result = jmespath.search(input, expression);
42
33
  clearTimeout(timeout);
43
34
  resolve(result);
44
35
  } catch (error) {
@@ -52,7 +43,7 @@ var JsonTransformer = class JsonTransformer {
52
43
  */
53
44
  static async transform(input, jmesPathExpression, options = {}) {
54
45
  const { timeout = JsonTransformer.DEFAULT_TIMEOUT, allowedFunctions } = options;
55
- JsonTransformer.validateJMESPath(jmesPathExpression, allowedFunctions);
46
+ JsonTransformer.validateExpression(jmesPathExpression, allowedFunctions);
56
47
  try {
57
48
  logger.debug("Executing JMESPath transformation", `inputType: ${typeof input}, expression: ${jmesPathExpression.substring(0, 100)}..., timeout: ${timeout}`);
58
49
  const result = await JsonTransformer.executeWithTimeout(input, jmesPathExpression, timeout);
@@ -74,7 +65,7 @@ var JsonTransformer = class JsonTransformer {
74
65
  if (!key || typeof key !== "string") throw new Error("Object transformation keys must be non-empty strings");
75
66
  if (!path || typeof path !== "string") throw new Error("Object transformation values must be non-empty strings");
76
67
  try {
77
- jmespathExt.compile(path);
68
+ compileJMESPath(path);
78
69
  } catch (error) {
79
70
  throw new Error(`Invalid JMESPath in object transformation value "${path}": ${error instanceof Error ? error.message : String(error)}`);
80
71
  }
@@ -101,7 +92,7 @@ var JsonTransformer = class JsonTransformer {
101
92
  static transformSync(input, jmesPathExpression) {
102
93
  logger.warn("Using deprecated synchronous transform method - security validation bypassed", "");
103
94
  try {
104
- return jmespath$1.search(input, jmesPathExpression);
95
+ return jmespath.search(input, jmesPathExpression);
105
96
  } catch (error) {
106
97
  throw new Error(`JMESPath transformation failed: ${error instanceof Error ? error.message : String(error)}`);
107
98
  }
@@ -0,0 +1,152 @@
1
+ import { z } from "@hono/zod-openapi";
2
+
3
+ //#region src/utils/jmespath-utils.d.ts
4
+
5
+ /**
6
+ * Result of validating a JMESPath expression or regex pattern.
7
+ */
8
+ interface ValidationResult {
9
+ valid: boolean;
10
+ error?: string;
11
+ }
12
+ /**
13
+ * Maximum allowed length for JMESPath expressions.
14
+ */
15
+ declare const MAX_EXPRESSION_LENGTH = 1000;
16
+ /**
17
+ * Validates a JMESPath expression by attempting to compile it.
18
+ * Uses the jmespath package which is already available in the codebase.
19
+ *
20
+ * @param expression - The JMESPath expression to validate
21
+ * @returns ValidationResult with valid flag and optional error message
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const result = validateJMESPath('body.user.id');
26
+ * if (!result.valid) {
27
+ * console.error(result.error);
28
+ * }
29
+ * ```
30
+ */
31
+ declare function validateJMESPath(expression: string): ValidationResult;
32
+ /**
33
+ * Validates a regex pattern by attempting to construct a RegExp object.
34
+ * Returns clear error messages for common regex issues.
35
+ *
36
+ * @param pattern - The regex pattern to validate (without delimiters)
37
+ * @returns ValidationResult with valid flag and optional error message
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const result = validateRegex('v\\d+,(.+)');
42
+ * if (!result.valid) {
43
+ * console.error(result.error);
44
+ * }
45
+ * ```
46
+ */
47
+ declare function validateRegex(pattern: string): ValidationResult;
48
+ /**
49
+ * Compiles a JMESPath expression.
50
+ * Wrapper around jmespath.compile() with proper typing.
51
+ *
52
+ * @param expression - The JMESPath expression to compile
53
+ * @returns The compiled expression object
54
+ * @throws Error if the expression is invalid
55
+ */
56
+ declare function compileJMESPath(expression: string): unknown;
57
+ /**
58
+ * Safely searches data using a JMESPath expression.
59
+ * Wrapper around jmespath.search() with proper typing.
60
+ *
61
+ * @param data - The object to search (e.g., template context, webhook body, tool result)
62
+ * @param expression - The JMESPath expression
63
+ * @returns The search result
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const data = { users: [{ name: 'Alice' }] };
68
+ * const name = searchJMESPath<string>(data, 'users[0].name');
69
+ * // name is 'Alice'
70
+ *
71
+ * // Common use cases:
72
+ * // - Template contexts: { headers: {...}, body: {...} }
73
+ * // - Webhook payloads: { event: "...", data: {...} }
74
+ * // - Tool results: { status: "success", result: {...} }
75
+ * ```
76
+ */
77
+ declare function searchJMESPath<T = unknown>(data: Record<string, unknown>, expression: string): T;
78
+ /**
79
+ * Normalize a JMESPath expression by wrapping property names with dashes in quotes.
80
+ * JMESPath requires identifiers with special characters (like dashes) to be quoted.
81
+ *
82
+ * @param path - The JMESPath expression to normalize
83
+ * @returns The normalized JMESPath expression
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * normalizeJMESPath('headers.x-tenant-id');
88
+ * // Returns: 'headers."x-tenant-id"'
89
+ *
90
+ * normalizeJMESPath('api-responses[0].response-code');
91
+ * // Returns: '"api-responses"[0]."response-code"'
92
+ *
93
+ * normalizeJMESPath('simple.path');
94
+ * // Returns: 'simple.path' (unchanged)
95
+ * ```
96
+ */
97
+ declare function normalizeJMESPath(path: string): string;
98
+ /**
99
+ * Dangerous patterns that should not appear in JMESPath expressions.
100
+ * These patterns are checked during secure validation to prevent injection attacks.
101
+ */
102
+ declare const DANGEROUS_PATTERNS: RegExp[];
103
+ /**
104
+ * Options for secure JMESPath validation.
105
+ */
106
+ interface SecurityOptions {
107
+ maxLength?: number;
108
+ dangerousPatterns?: RegExp[];
109
+ }
110
+ /**
111
+ * Validates a JMESPath expression with security checks.
112
+ * Performs checks in order of cost: length (O(1)), patterns (O(n)), compile (expensive).
113
+ *
114
+ * @param expression - The JMESPath expression to validate
115
+ * @param options - Optional security options
116
+ * @returns ValidationResult with valid flag and optional error message
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const result = validateJMESPathSecure('body.user.id');
121
+ * if (!result.valid) {
122
+ * console.error(result.error);
123
+ * }
124
+ *
125
+ * // With custom options
126
+ * const result2 = validateJMESPathSecure('expression', { maxLength: 500 });
127
+ * ```
128
+ */
129
+ declare function validateJMESPathSecure(expression: string, options?: SecurityOptions): ValidationResult;
130
+ /**
131
+ * Options for jmespathString Zod schema factory.
132
+ */
133
+ interface JMESPathStringOptions {
134
+ maxLength?: number;
135
+ }
136
+ /**
137
+ * Creates a Zod string schema for JMESPath expressions with OpenAPI-visible constraints.
138
+ * Includes maxLength constraint and a description with valid/invalid examples.
139
+ *
140
+ * @param options - Optional configuration for the schema
141
+ * @returns A Zod string schema with maxLength and description
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const schema = z.object({
146
+ * transform: jmespathString().optional(),
147
+ * });
148
+ * ```
149
+ */
150
+ declare function jmespathString(options?: JMESPathStringOptions): z.ZodString;
151
+ //#endregion
152
+ export { DANGEROUS_PATTERNS, JMESPathStringOptions, MAX_EXPRESSION_LENGTH, SecurityOptions, ValidationResult, compileJMESPath, jmespathString, normalizeJMESPath, searchJMESPath, validateJMESPath, validateJMESPathSecure, validateRegex };
@@ -0,0 +1,213 @@
1
+ import { z } from "@hono/zod-openapi";
2
+ import * as jmespath from "jmespath";
3
+
4
+ //#region src/utils/jmespath-utils.ts
5
+ const jmespathExt = jmespath;
6
+ /**
7
+ * Maximum allowed length for JMESPath expressions.
8
+ */
9
+ const MAX_EXPRESSION_LENGTH = 1e3;
10
+ /**
11
+ * Validates a JMESPath expression by attempting to compile it.
12
+ * Uses the jmespath package which is already available in the codebase.
13
+ *
14
+ * @param expression - The JMESPath expression to validate
15
+ * @returns ValidationResult with valid flag and optional error message
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const result = validateJMESPath('body.user.id');
20
+ * if (!result.valid) {
21
+ * console.error(result.error);
22
+ * }
23
+ * ```
24
+ */
25
+ function validateJMESPath(expression) {
26
+ if (!expression || typeof expression !== "string") return {
27
+ valid: false,
28
+ error: "JMESPath expression must be a non-empty string"
29
+ };
30
+ try {
31
+ jmespathExt.compile(expression);
32
+ return { valid: true };
33
+ } catch (error) {
34
+ return {
35
+ valid: false,
36
+ error: `Invalid JMESPath expression: ${error instanceof Error ? error.message : String(error)}`
37
+ };
38
+ }
39
+ }
40
+ /**
41
+ * Validates a regex pattern by attempting to construct a RegExp object.
42
+ * Returns clear error messages for common regex issues.
43
+ *
44
+ * @param pattern - The regex pattern to validate (without delimiters)
45
+ * @returns ValidationResult with valid flag and optional error message
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const result = validateRegex('v\\d+,(.+)');
50
+ * if (!result.valid) {
51
+ * console.error(result.error);
52
+ * }
53
+ * ```
54
+ */
55
+ function validateRegex(pattern) {
56
+ if (pattern === null || pattern === void 0) return {
57
+ valid: false,
58
+ error: "Regex pattern must be provided"
59
+ };
60
+ if (typeof pattern !== "string") return {
61
+ valid: false,
62
+ error: "Regex pattern must be a string"
63
+ };
64
+ if (pattern === "") return { valid: true };
65
+ try {
66
+ new RegExp(pattern);
67
+ return { valid: true };
68
+ } catch (error) {
69
+ return {
70
+ valid: false,
71
+ error: `Invalid regex pattern: ${error instanceof Error ? error.message : String(error)}`
72
+ };
73
+ }
74
+ }
75
+ /**
76
+ * Compiles a JMESPath expression.
77
+ * Wrapper around jmespath.compile() with proper typing.
78
+ *
79
+ * @param expression - The JMESPath expression to compile
80
+ * @returns The compiled expression object
81
+ * @throws Error if the expression is invalid
82
+ */
83
+ function compileJMESPath(expression) {
84
+ return jmespathExt.compile(expression);
85
+ }
86
+ /**
87
+ * Safely searches data using a JMESPath expression.
88
+ * Wrapper around jmespath.search() with proper typing.
89
+ *
90
+ * @param data - The object to search (e.g., template context, webhook body, tool result)
91
+ * @param expression - The JMESPath expression
92
+ * @returns The search result
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const data = { users: [{ name: 'Alice' }] };
97
+ * const name = searchJMESPath<string>(data, 'users[0].name');
98
+ * // name is 'Alice'
99
+ *
100
+ * // Common use cases:
101
+ * // - Template contexts: { headers: {...}, body: {...} }
102
+ * // - Webhook payloads: { event: "...", data: {...} }
103
+ * // - Tool results: { status: "success", result: {...} }
104
+ * ```
105
+ */
106
+ function searchJMESPath(data, expression) {
107
+ return jmespath.search(data, expression);
108
+ }
109
+ /**
110
+ * Normalize a JMESPath expression by wrapping property names with dashes in quotes.
111
+ * JMESPath requires identifiers with special characters (like dashes) to be quoted.
112
+ *
113
+ * @param path - The JMESPath expression to normalize
114
+ * @returns The normalized JMESPath expression
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * normalizeJMESPath('headers.x-tenant-id');
119
+ * // Returns: 'headers."x-tenant-id"'
120
+ *
121
+ * normalizeJMESPath('api-responses[0].response-code');
122
+ * // Returns: '"api-responses"[0]."response-code"'
123
+ *
124
+ * normalizeJMESPath('simple.path');
125
+ * // Returns: 'simple.path' (unchanged)
126
+ * ```
127
+ */
128
+ function normalizeJMESPath(path) {
129
+ return path.split(".").map((segment) => {
130
+ if (!segment.includes("-")) return segment;
131
+ if (segment.startsWith("\"") && segment.includes("\"")) return segment;
132
+ const bracketIndex = segment.indexOf("[");
133
+ if (bracketIndex !== -1) return `"${segment.substring(0, bracketIndex)}"${segment.substring(bracketIndex)}`;
134
+ return `"${segment}"`;
135
+ }).join(".");
136
+ }
137
+ /**
138
+ * Dangerous patterns that should not appear in JMESPath expressions.
139
+ * These patterns are checked during secure validation to prevent injection attacks.
140
+ */
141
+ const DANGEROUS_PATTERNS = [
142
+ /\$\{.*\}/,
143
+ /eval\s*\(/,
144
+ /function\s*\(/,
145
+ /constructor/,
146
+ /prototype/,
147
+ /__proto__/
148
+ ];
149
+ /**
150
+ * Validates a JMESPath expression with security checks.
151
+ * Performs checks in order of cost: length (O(1)), patterns (O(n)), compile (expensive).
152
+ *
153
+ * @param expression - The JMESPath expression to validate
154
+ * @param options - Optional security options
155
+ * @returns ValidationResult with valid flag and optional error message
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const result = validateJMESPathSecure('body.user.id');
160
+ * if (!result.valid) {
161
+ * console.error(result.error);
162
+ * }
163
+ *
164
+ * // With custom options
165
+ * const result2 = validateJMESPathSecure('expression', { maxLength: 500 });
166
+ * ```
167
+ */
168
+ function validateJMESPathSecure(expression, options) {
169
+ if (!expression || typeof expression !== "string") return {
170
+ valid: false,
171
+ error: "JMESPath expression must be a non-empty string"
172
+ };
173
+ const maxLength = options?.maxLength ?? MAX_EXPRESSION_LENGTH;
174
+ const patterns = options?.dangerousPatterns ?? DANGEROUS_PATTERNS;
175
+ if (expression.length > maxLength) return {
176
+ valid: false,
177
+ error: `JMESPath expression exceeds maximum length of ${maxLength} characters`
178
+ };
179
+ for (const pattern of patterns) if (pattern.test(expression)) return {
180
+ valid: false,
181
+ error: `JMESPath expression contains dangerous pattern: ${pattern.source}`
182
+ };
183
+ try {
184
+ jmespathExt.compile(expression);
185
+ return { valid: true };
186
+ } catch (error) {
187
+ return {
188
+ valid: false,
189
+ error: `Invalid JMESPath expression: ${error instanceof Error ? error.message : String(error)}`
190
+ };
191
+ }
192
+ }
193
+ /**
194
+ * Creates a Zod string schema for JMESPath expressions with OpenAPI-visible constraints.
195
+ * Includes maxLength constraint and a description with valid/invalid examples.
196
+ *
197
+ * @param options - Optional configuration for the schema
198
+ * @returns A Zod string schema with maxLength and description
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const schema = z.object({
203
+ * transform: jmespathString().optional(),
204
+ * });
205
+ * ```
206
+ */
207
+ function jmespathString(options) {
208
+ const maxLen = options?.maxLength ?? MAX_EXPRESSION_LENGTH;
209
+ return z.string().max(maxLen).describe(`JMESPath expression (max ${maxLen} chars). Valid: "data.items[0].name", "results[?status=='active']", "keys(@)". Invalid: "\${...}" (template injection), "eval(...)", "constructor", "__proto__".`);
210
+ }
211
+
212
+ //#endregion
213
+ export { DANGEROUS_PATTERNS, MAX_EXPRESSION_LENGTH, compileJMESPath, jmespathString, normalizeJMESPath, searchJMESPath, validateJMESPath, validateJMESPathSecure, validateRegex };
@@ -1,39 +1,2 @@
1
- //#region src/utils/signature-validation.d.ts
2
- interface ValidationResult {
3
- valid: boolean;
4
- error?: string;
5
- }
6
- /**
7
- * Validates a JMESPath expression by attempting to compile it.
8
- * Uses the jmespath package which is already available in the codebase.
9
- *
10
- * @param expression - The JMESPath expression to validate
11
- * @returns ValidationResult with valid flag and optional error message
12
- *
13
- * @example
14
- * ```typescript
15
- * const result = validateJMESPath('body.user.id');
16
- * if (!result.valid) {
17
- * console.error(result.error);
18
- * }
19
- * ```
20
- */
21
- declare function validateJMESPath(expression: string): ValidationResult;
22
- /**
23
- * Validates a regex pattern by attempting to construct a RegExp object.
24
- * Returns clear error messages for common regex issues.
25
- *
26
- * @param pattern - The regex pattern to validate (without delimiters)
27
- * @returns ValidationResult with valid flag and optional error message
28
- *
29
- * @example
30
- * ```typescript
31
- * const result = validateRegex('v\\d+,(.+)');
32
- * if (!result.valid) {
33
- * console.error(result.error);
34
- * }
35
- * ```
36
- */
37
- declare function validateRegex(pattern: string): ValidationResult;
38
- //#endregion
39
- export { ValidationResult, validateJMESPath, validateRegex };
1
+ import { ValidationResult, validateJMESPath, validateRegex } from "./jmespath-utils.js";
2
+ export { type ValidationResult, validateJMESPath, validateRegex };
@@ -1,71 +1,3 @@
1
- import * as jmespath$1 from "jmespath";
1
+ import { validateJMESPath, validateRegex } from "./jmespath-utils.js";
2
2
 
3
- //#region src/utils/signature-validation.ts
4
- /**
5
- * Validates a JMESPath expression by attempting to compile it.
6
- * Uses the jmespath package which is already available in the codebase.
7
- *
8
- * @param expression - The JMESPath expression to validate
9
- * @returns ValidationResult with valid flag and optional error message
10
- *
11
- * @example
12
- * ```typescript
13
- * const result = validateJMESPath('body.user.id');
14
- * if (!result.valid) {
15
- * console.error(result.error);
16
- * }
17
- * ```
18
- */
19
- function validateJMESPath(expression) {
20
- if (!expression || typeof expression !== "string") return {
21
- valid: false,
22
- error: "JMESPath expression must be a non-empty string"
23
- };
24
- try {
25
- jmespath$1.compile(expression);
26
- return { valid: true };
27
- } catch (error) {
28
- return {
29
- valid: false,
30
- error: `Invalid JMESPath expression: ${error instanceof Error ? error.message : String(error)}`
31
- };
32
- }
33
- }
34
- /**
35
- * Validates a regex pattern by attempting to construct a RegExp object.
36
- * Returns clear error messages for common regex issues.
37
- *
38
- * @param pattern - The regex pattern to validate (without delimiters)
39
- * @returns ValidationResult with valid flag and optional error message
40
- *
41
- * @example
42
- * ```typescript
43
- * const result = validateRegex('v\\d+,(.+)');
44
- * if (!result.valid) {
45
- * console.error(result.error);
46
- * }
47
- * ```
48
- */
49
- function validateRegex(pattern) {
50
- if (pattern === null || pattern === void 0) return {
51
- valid: false,
52
- error: "Regex pattern must be provided"
53
- };
54
- if (typeof pattern !== "string") return {
55
- valid: false,
56
- error: "Regex pattern must be a string"
57
- };
58
- if (pattern === "") return { valid: true };
59
- try {
60
- new RegExp(pattern);
61
- return { valid: true };
62
- } catch (error) {
63
- return {
64
- valid: false,
65
- error: `Invalid regex pattern: ${error instanceof Error ? error.message : String(error)}`
66
- };
67
- }
68
- }
69
-
70
- //#endregion
71
3
  export { validateJMESPath, validateRegex };
@@ -1,4 +1,4 @@
1
- import * as jmespath$1 from "jmespath";
1
+ import { searchJMESPath } from "./jmespath-utils.js";
2
2
  import { createHmac, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
3
3
  import { promisify } from "node:util";
4
4
 
@@ -100,8 +100,7 @@ function extractSignature(c, config, body) {
100
100
  value = c.req.header(headerKey);
101
101
  } else if (signature.source === "query") value = c.req.query(signature.key);
102
102
  else if (signature.source === "body") try {
103
- const bodyData = JSON.parse(body);
104
- value = jmespath$1.search(bodyData, signature.key);
103
+ value = searchJMESPath(JSON.parse(body), signature.key);
105
104
  } catch {
106
105
  return null;
107
106
  }
@@ -134,8 +133,7 @@ function extractComponent(c, component, body, caseSensitive) {
134
133
  value = c.req.header(headerKey);
135
134
  } else if (component.source === "body") if (!component.key) value = body;
136
135
  else try {
137
- const bodyData = JSON.parse(body);
138
- value = jmespath$1.search(bodyData, component.key);
136
+ value = searchJMESPath(JSON.parse(body), component.key);
139
137
  } catch {
140
138
  return component.required ? null : "";
141
139
  }
@@ -32,8 +32,8 @@ declare const BranchNameParamsSchema: z.ZodObject<{
32
32
  }, z.core.$strip>;
33
33
  declare const ResolvedRefSchema: z.ZodObject<{
34
34
  type: z.ZodEnum<{
35
- commit: "commit";
36
35
  tag: "tag";
36
+ commit: "commit";
37
37
  branch: "branch";
38
38
  }>;
39
39
  name: z.ZodString;