mcp4openapi 0.2.8 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/README.md +143 -63
  2. package/dist/scripts/validate-profile.js +3 -3
  3. package/dist/scripts/validate-profile.js.map +1 -1
  4. package/dist/src/argument-normalizer.d.ts +5 -0
  5. package/dist/src/argument-normalizer.d.ts.map +1 -0
  6. package/dist/src/argument-normalizer.js +61 -0
  7. package/dist/src/argument-normalizer.js.map +1 -0
  8. package/dist/src/auth/oauth-provider.d.ts +131 -0
  9. package/dist/src/auth/oauth-provider.d.ts.map +1 -0
  10. package/dist/src/auth/oauth-provider.js +839 -0
  11. package/dist/src/auth/oauth-provider.js.map +1 -0
  12. package/dist/src/cli-config.d.ts +9 -0
  13. package/dist/src/cli-config.d.ts.map +1 -0
  14. package/dist/src/cli-config.js +111 -0
  15. package/dist/src/cli-config.js.map +1 -0
  16. package/dist/src/core/cli-config.d.ts +9 -0
  17. package/dist/src/core/cli-config.d.ts.map +1 -0
  18. package/dist/src/core/cli-config.js +125 -0
  19. package/dist/src/core/cli-config.js.map +1 -0
  20. package/dist/src/core/constants.d.ts +86 -0
  21. package/dist/src/core/constants.d.ts.map +1 -0
  22. package/dist/src/core/constants.js +86 -0
  23. package/dist/src/core/constants.js.map +1 -0
  24. package/dist/src/core/errors.d.ts +59 -0
  25. package/dist/src/core/errors.d.ts.map +1 -0
  26. package/dist/src/core/errors.js +119 -0
  27. package/dist/src/core/errors.js.map +1 -0
  28. package/dist/src/core/filtering.d.ts +19 -0
  29. package/dist/src/core/filtering.d.ts.map +1 -0
  30. package/dist/src/core/filtering.js +292 -0
  31. package/dist/src/core/filtering.js.map +1 -0
  32. package/dist/src/core/index.d.ts +26 -0
  33. package/dist/src/core/index.d.ts.map +1 -0
  34. package/dist/src/core/index.js +276 -0
  35. package/dist/src/core/index.js.map +1 -0
  36. package/dist/src/core/lib.d.ts +8 -0
  37. package/dist/src/core/lib.d.ts.map +1 -0
  38. package/dist/src/core/lib.js +7 -0
  39. package/dist/src/core/lib.js.map +1 -0
  40. package/dist/src/core/logger.d.ts +59 -0
  41. package/dist/src/core/logger.d.ts.map +1 -0
  42. package/dist/src/core/logger.js +197 -0
  43. package/dist/src/core/logger.js.map +1 -0
  44. package/dist/src/core/metrics.d.ts +97 -0
  45. package/dist/src/core/metrics.d.ts.map +1 -0
  46. package/dist/src/core/metrics.js +273 -0
  47. package/dist/src/core/metrics.js.map +1 -0
  48. package/dist/src/core/naming-warnings.d.ts +23 -0
  49. package/dist/src/core/naming-warnings.d.ts.map +1 -0
  50. package/dist/src/core/naming-warnings.js +83 -0
  51. package/dist/src/core/naming-warnings.js.map +1 -0
  52. package/dist/src/core/naming.d.ts +58 -0
  53. package/dist/src/core/naming.d.ts.map +1 -0
  54. package/dist/src/core/naming.js +510 -0
  55. package/dist/src/core/naming.js.map +1 -0
  56. package/dist/src/errors.d.ts +6 -0
  57. package/dist/src/errors.d.ts.map +1 -1
  58. package/dist/src/errors.js +15 -6
  59. package/dist/src/errors.js.map +1 -1
  60. package/dist/src/filtering.d.ts +19 -0
  61. package/dist/src/filtering.d.ts.map +1 -0
  62. package/dist/src/filtering.js +292 -0
  63. package/dist/src/filtering.js.map +1 -0
  64. package/dist/src/generated-schemas.d.ts +290 -79
  65. package/dist/src/generated-schemas.d.ts.map +1 -1
  66. package/dist/src/generated-schemas.js +17 -2
  67. package/dist/src/generated-schemas.js.map +1 -1
  68. package/dist/src/http-transport-config.d.ts +6 -0
  69. package/dist/src/http-transport-config.d.ts.map +1 -0
  70. package/dist/src/http-transport-config.js +47 -0
  71. package/dist/src/http-transport-config.js.map +1 -0
  72. package/dist/src/http-transport.d.ts +63 -13
  73. package/dist/src/http-transport.d.ts.map +1 -1
  74. package/dist/src/http-transport.js +1045 -482
  75. package/dist/src/http-transport.js.map +1 -1
  76. package/dist/src/index.d.ts +1 -6
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/index.js +1 -170
  79. package/dist/src/index.js.map +1 -1
  80. package/dist/src/interceptors.d.ts +1 -0
  81. package/dist/src/interceptors.d.ts.map +1 -1
  82. package/dist/src/interceptors.js +73 -63
  83. package/dist/src/interceptors.js.map +1 -1
  84. package/dist/src/lib.d.ts +1 -7
  85. package/dist/src/lib.d.ts.map +1 -1
  86. package/dist/src/lib.js +1 -6
  87. package/dist/src/lib.js.map +1 -1
  88. package/dist/src/logger.d.ts +5 -0
  89. package/dist/src/logger.d.ts.map +1 -1
  90. package/dist/src/logger.js +9 -1
  91. package/dist/src/logger.js.map +1 -1
  92. package/dist/src/mcp/mcp-server-manager.d.ts +20 -0
  93. package/dist/src/mcp/mcp-server-manager.d.ts.map +1 -0
  94. package/dist/src/mcp/mcp-server-manager.js +38 -0
  95. package/dist/src/mcp/mcp-server-manager.js.map +1 -0
  96. package/dist/src/mcp/mcp-server.d.ts +205 -0
  97. package/dist/src/mcp/mcp-server.d.ts.map +1 -0
  98. package/dist/src/mcp/mcp-server.js +1473 -0
  99. package/dist/src/mcp/mcp-server.js.map +1 -0
  100. package/dist/src/mcp-server-manager.d.ts +20 -0
  101. package/dist/src/mcp-server-manager.d.ts.map +1 -0
  102. package/dist/src/mcp-server-manager.js +38 -0
  103. package/dist/src/mcp-server-manager.js.map +1 -0
  104. package/dist/src/mcp-server.d.ts +28 -0
  105. package/dist/src/mcp-server.d.ts.map +1 -1
  106. package/dist/src/mcp-server.js +406 -109
  107. package/dist/src/mcp-server.js.map +1 -1
  108. package/dist/src/metrics.d.ts +11 -0
  109. package/dist/src/metrics.d.ts.map +1 -1
  110. package/dist/src/metrics.js +61 -0
  111. package/dist/src/metrics.js.map +1 -1
  112. package/dist/src/oauth-provider.d.ts +5 -0
  113. package/dist/src/oauth-provider.d.ts.map +1 -1
  114. package/dist/src/oauth-provider.js +29 -1
  115. package/dist/src/oauth-provider.js.map +1 -1
  116. package/dist/src/openapi/openapi-parser.d.ts +70 -0
  117. package/dist/src/openapi/openapi-parser.d.ts.map +1 -0
  118. package/dist/src/openapi/openapi-parser.js +458 -0
  119. package/dist/src/openapi/openapi-parser.js.map +1 -0
  120. package/dist/src/profile/profile-loader.d.ts +78 -0
  121. package/dist/src/profile/profile-loader.d.ts.map +1 -0
  122. package/dist/src/profile/profile-loader.js +490 -0
  123. package/dist/src/profile/profile-loader.js.map +1 -0
  124. package/dist/src/profile/profile-registry.d.ts +19 -0
  125. package/dist/src/profile/profile-registry.d.ts.map +1 -0
  126. package/dist/src/profile/profile-registry.js +43 -0
  127. package/dist/src/profile/profile-registry.js.map +1 -0
  128. package/dist/src/profile/profile-resolver.d.ts +41 -0
  129. package/dist/src/profile/profile-resolver.d.ts.map +1 -0
  130. package/dist/src/profile/profile-resolver.js +324 -0
  131. package/dist/src/profile/profile-resolver.js.map +1 -0
  132. package/dist/src/profile/startup-profile.d.ts +17 -0
  133. package/dist/src/profile/startup-profile.d.ts.map +1 -0
  134. package/dist/src/profile/startup-profile.js +30 -0
  135. package/dist/src/profile/startup-profile.js.map +1 -0
  136. package/dist/src/profile/startup-validation.d.ts +11 -0
  137. package/dist/src/profile/startup-validation.d.ts.map +1 -0
  138. package/dist/src/profile/startup-validation.js +21 -0
  139. package/dist/src/profile/startup-validation.js.map +1 -0
  140. package/dist/src/profile-loader.d.ts +1 -0
  141. package/dist/src/profile-loader.d.ts.map +1 -1
  142. package/dist/src/profile-loader.js +14 -3
  143. package/dist/src/profile-loader.js.map +1 -1
  144. package/dist/src/profile-registry.d.ts +18 -0
  145. package/dist/src/profile-registry.d.ts.map +1 -0
  146. package/dist/src/profile-registry.js +26 -0
  147. package/dist/src/profile-registry.js.map +1 -0
  148. package/dist/src/profile-resolver.d.ts +19 -0
  149. package/dist/src/profile-resolver.d.ts.map +1 -0
  150. package/dist/src/profile-resolver.js +167 -0
  151. package/dist/src/profile-resolver.js.map +1 -0
  152. package/dist/src/proxy-executor.d.ts.map +1 -1
  153. package/dist/src/proxy-executor.js +7 -0
  154. package/dist/src/proxy-executor.js.map +1 -1
  155. package/dist/src/startup-profile.d.ts +17 -0
  156. package/dist/src/startup-profile.d.ts.map +1 -0
  157. package/dist/src/startup-profile.js +30 -0
  158. package/dist/src/startup-profile.js.map +1 -0
  159. package/dist/src/startup-validation.d.ts +11 -0
  160. package/dist/src/startup-validation.d.ts.map +1 -0
  161. package/dist/src/startup-validation.js +21 -0
  162. package/dist/src/startup-validation.js.map +1 -0
  163. package/dist/src/testing/dynamic-mock-server.d.ts +24 -0
  164. package/dist/src/testing/dynamic-mock-server.d.ts.map +1 -0
  165. package/dist/src/testing/dynamic-mock-server.js +138 -0
  166. package/dist/src/testing/dynamic-mock-server.js.map +1 -0
  167. package/dist/src/testing/request-assertions.d.ts +5 -0
  168. package/dist/src/testing/request-assertions.d.ts.map +1 -0
  169. package/dist/src/testing/request-assertions.js +165 -0
  170. package/dist/src/testing/request-assertions.js.map +1 -0
  171. package/dist/src/testing/template-utils.d.ts +10 -0
  172. package/dist/src/testing/template-utils.d.ts.map +1 -0
  173. package/dist/src/testing/template-utils.js +72 -0
  174. package/dist/src/testing/template-utils.js.map +1 -0
  175. package/dist/src/testing/test-http-utils.d.ts +1 -1
  176. package/dist/src/testing/test-http-utils.d.ts.map +1 -1
  177. package/dist/src/testing/test-http-utils.js +1 -1
  178. package/dist/src/testing/test-http-utils.js.map +1 -1
  179. package/dist/src/testing/test-loader.d.ts +6 -0
  180. package/dist/src/testing/test-loader.d.ts.map +1 -0
  181. package/dist/src/testing/test-loader.js +212 -0
  182. package/dist/src/testing/test-loader.js.map +1 -0
  183. package/dist/src/testing/test-schema.d.ts +1270 -0
  184. package/dist/src/testing/test-schema.d.ts.map +1 -0
  185. package/dist/src/testing/test-schema.js +76 -0
  186. package/dist/src/testing/test-schema.js.map +1 -0
  187. package/dist/src/tool-filter/compat.d.ts +49 -0
  188. package/dist/src/tool-filter/compat.d.ts.map +1 -0
  189. package/dist/src/tool-filter/compat.js +72 -0
  190. package/dist/src/tool-filter/compat.js.map +1 -0
  191. package/dist/src/tool-filter/config/env-config-parser.d.ts +38 -0
  192. package/dist/src/tool-filter/config/env-config-parser.d.ts.map +1 -0
  193. package/dist/src/tool-filter/config/env-config-parser.js +103 -0
  194. package/dist/src/tool-filter/config/env-config-parser.js.map +1 -0
  195. package/dist/src/tool-filter/config/header-config-parser.d.ts +37 -0
  196. package/dist/src/tool-filter/config/header-config-parser.d.ts.map +1 -0
  197. package/dist/src/tool-filter/config/header-config-parser.js +118 -0
  198. package/dist/src/tool-filter/config/header-config-parser.js.map +1 -0
  199. package/dist/src/tool-filter/errors.d.ts +18 -0
  200. package/dist/src/tool-filter/errors.d.ts.map +1 -0
  201. package/dist/src/tool-filter/errors.js +21 -0
  202. package/dist/src/tool-filter/errors.js.map +1 -0
  203. package/dist/src/tool-filter/filter/filter-engine.d.ts +45 -0
  204. package/dist/src/tool-filter/filter/filter-engine.d.ts.map +1 -0
  205. package/dist/src/tool-filter/filter/filter-engine.js +94 -0
  206. package/dist/src/tool-filter/filter/filter-engine.js.map +1 -0
  207. package/dist/src/tool-filter/filter/filter-rules.d.ts +44 -0
  208. package/dist/src/tool-filter/filter/filter-rules.d.ts.map +1 -0
  209. package/dist/src/tool-filter/filter/filter-rules.js +72 -0
  210. package/dist/src/tool-filter/filter/filter-rules.js.map +1 -0
  211. package/dist/src/tool-filter/filter/global-tool-filter.d.ts +40 -0
  212. package/dist/src/tool-filter/filter/global-tool-filter.d.ts.map +1 -0
  213. package/dist/src/tool-filter/filter/global-tool-filter.js +92 -0
  214. package/dist/src/tool-filter/filter/global-tool-filter.js.map +1 -0
  215. package/dist/src/tool-filter/filter/session-tool-filter.d.ts +29 -0
  216. package/dist/src/tool-filter/filter/session-tool-filter.d.ts.map +1 -0
  217. package/dist/src/tool-filter/filter/session-tool-filter.js +69 -0
  218. package/dist/src/tool-filter/filter/session-tool-filter.js.map +1 -0
  219. package/dist/src/tool-filter/index.d.ts +25 -0
  220. package/dist/src/tool-filter/index.d.ts.map +1 -0
  221. package/dist/src/tool-filter/index.js +30 -0
  222. package/dist/src/tool-filter/index.js.map +1 -0
  223. package/dist/src/tool-filter/integration/tool-filter-service.d.ts +44 -0
  224. package/dist/src/tool-filter/integration/tool-filter-service.d.ts.map +1 -0
  225. package/dist/src/tool-filter/integration/tool-filter-service.js +68 -0
  226. package/dist/src/tool-filter/integration/tool-filter-service.js.map +1 -0
  227. package/dist/src/tool-filter/operation/operation-classifier.d.ts +20 -0
  228. package/dist/src/tool-filter/operation/operation-classifier.d.ts.map +1 -0
  229. package/dist/src/tool-filter/operation/operation-classifier.js +26 -0
  230. package/dist/src/tool-filter/operation/operation-classifier.js.map +1 -0
  231. package/dist/src/tool-filter/operation/operation-detector.d.ts +30 -0
  232. package/dist/src/tool-filter/operation/operation-detector.d.ts.map +1 -0
  233. package/dist/src/tool-filter/operation/operation-detector.js +96 -0
  234. package/dist/src/tool-filter/operation/operation-detector.js.map +1 -0
  235. package/dist/src/tool-filter/operation/operation-resolver.d.ts +22 -0
  236. package/dist/src/tool-filter/operation/operation-resolver.d.ts.map +1 -0
  237. package/dist/src/tool-filter/operation/operation-resolver.js +32 -0
  238. package/dist/src/tool-filter/operation/operation-resolver.js.map +1 -0
  239. package/dist/src/tool-filter/regex/regex-compiler.d.ts +22 -0
  240. package/dist/src/tool-filter/regex/regex-compiler.d.ts.map +1 -0
  241. package/dist/src/tool-filter/regex/regex-compiler.js +56 -0
  242. package/dist/src/tool-filter/regex/regex-compiler.js.map +1 -0
  243. package/dist/src/tool-filter/regex/regex-validator.d.ts +24 -0
  244. package/dist/src/tool-filter/regex/regex-validator.d.ts.map +1 -0
  245. package/dist/src/tool-filter/regex/regex-validator.js +58 -0
  246. package/dist/src/tool-filter/regex/regex-validator.js.map +1 -0
  247. package/dist/src/tool-filter/types.d.ts +92 -0
  248. package/dist/src/tool-filter/types.d.ts.map +1 -0
  249. package/dist/src/tool-filter/types.js +5 -0
  250. package/dist/src/tool-filter/types.js.map +1 -0
  251. package/dist/src/tool-filter/utils.d.ts +11 -0
  252. package/dist/src/tool-filter/utils.d.ts.map +1 -0
  253. package/dist/src/tool-filter/utils.js +13 -0
  254. package/dist/src/tool-filter/utils.js.map +1 -0
  255. package/dist/src/tool-filter.d.ts +65 -0
  256. package/dist/src/tool-filter.d.ts.map +1 -0
  257. package/dist/src/tool-filter.js +471 -0
  258. package/dist/src/tool-filter.js.map +1 -0
  259. package/dist/src/tool-generator.d.ts +1 -0
  260. package/dist/src/tool-generator.d.ts.map +1 -1
  261. package/dist/src/tool-generator.js +15 -6
  262. package/dist/src/tool-generator.js.map +1 -1
  263. package/dist/src/tooling/composite-executor.d.ts +77 -0
  264. package/dist/src/tooling/composite-executor.d.ts.map +1 -0
  265. package/dist/src/tooling/composite-executor.js +198 -0
  266. package/dist/src/tooling/composite-executor.js.map +1 -0
  267. package/dist/src/tooling/dag-executor.d.ts +49 -0
  268. package/dist/src/tooling/dag-executor.d.ts.map +1 -0
  269. package/dist/src/tooling/dag-executor.js +138 -0
  270. package/dist/src/tooling/dag-executor.js.map +1 -0
  271. package/dist/src/tooling/proxy-executor.d.ts +86 -0
  272. package/dist/src/tooling/proxy-executor.d.ts.map +1 -0
  273. package/dist/src/tooling/proxy-executor.js +501 -0
  274. package/dist/src/tooling/proxy-executor.js.map +1 -0
  275. package/dist/src/tooling/tool-generator.d.ts +67 -0
  276. package/dist/src/tooling/tool-generator.d.ts.map +1 -0
  277. package/dist/src/tooling/tool-generator.js +222 -0
  278. package/dist/src/tooling/tool-generator.js.map +1 -0
  279. package/dist/src/transport/http-client-factory.d.ts +65 -0
  280. package/dist/src/transport/http-client-factory.d.ts.map +1 -0
  281. package/dist/src/transport/http-client-factory.js +143 -0
  282. package/dist/src/transport/http-client-factory.js.map +1 -0
  283. package/dist/src/transport/http-transport-config.d.ts +6 -0
  284. package/dist/src/transport/http-transport-config.d.ts.map +1 -0
  285. package/dist/src/transport/http-transport-config.js +63 -0
  286. package/dist/src/transport/http-transport-config.js.map +1 -0
  287. package/dist/src/transport/http-transport.d.ts +329 -0
  288. package/dist/src/transport/http-transport.d.ts.map +1 -0
  289. package/dist/src/transport/http-transport.js +2584 -0
  290. package/dist/src/transport/http-transport.js.map +1 -0
  291. package/dist/src/transport/interceptors.d.ts +119 -0
  292. package/dist/src/transport/interceptors.d.ts.map +1 -0
  293. package/dist/src/transport/interceptors.js +413 -0
  294. package/dist/src/transport/interceptors.js.map +1 -0
  295. package/dist/src/transport/profile-index.d.ts +84 -0
  296. package/dist/src/transport/profile-index.d.ts.map +1 -0
  297. package/dist/src/transport/profile-index.js +405 -0
  298. package/dist/src/transport/profile-index.js.map +1 -0
  299. package/dist/src/types/http-transport.d.ts +26 -0
  300. package/dist/src/types/http-transport.d.ts.map +1 -1
  301. package/dist/src/types/openapi.d.ts +3 -0
  302. package/dist/src/types/openapi.d.ts.map +1 -1
  303. package/dist/src/types/profile.d.ts +16 -1
  304. package/dist/src/types/profile.d.ts.map +1 -1
  305. package/dist/src/validation/argument-normalizer.d.ts +6 -0
  306. package/dist/src/validation/argument-normalizer.d.ts.map +1 -0
  307. package/dist/src/validation/argument-normalizer.js +70 -0
  308. package/dist/src/validation/argument-normalizer.js.map +1 -0
  309. package/dist/src/validation/jsonrpc-validator.d.ts +27 -0
  310. package/dist/src/validation/jsonrpc-validator.d.ts.map +1 -0
  311. package/dist/src/validation/jsonrpc-validator.js +58 -0
  312. package/dist/src/validation/jsonrpc-validator.js.map +1 -0
  313. package/dist/src/validation/schema-validator.d.ts +30 -0
  314. package/dist/src/validation/schema-validator.d.ts.map +1 -0
  315. package/dist/src/validation/schema-validator.js +128 -0
  316. package/dist/src/validation/schema-validator.js.map +1 -0
  317. package/dist/src/validation/validation-utils.d.ts +49 -0
  318. package/dist/src/validation/validation-utils.d.ts.map +1 -0
  319. package/dist/src/validation/validation-utils.js +139 -0
  320. package/dist/src/validation/validation-utils.js.map +1 -0
  321. package/html/profile-index.html +386 -0
  322. package/package.json +10 -3
  323. package/profile-schema.json +77 -3
  324. package/profiles/gitlab/developer-profile-oauth.json +1520 -0
  325. package/profiles/gitlab/developer-profile-oauth.test.json +3432 -0
  326. package/profiles/gitlab/developer-profile.json +1508 -0
  327. package/profiles/gitlab/developer-profile.test.json +3432 -0
  328. package/profiles/gitlab/openapi.yaml +6891 -0
  329. package/profiles/n8n/openapi.yaml +2441 -0
  330. package/profiles/n8n/profile-optimized.json +965 -0
  331. package/profiles/n8n/profile-optimized.test.json +1078 -0
  332. package/profiles/n8n/profile.json +1033 -0
  333. package/profiles/n8n/profile.test.json +983 -0
  334. package/profiles/n8n-nodes/openapi.yaml +24 -0
  335. package/profiles/n8n-nodes/profile-nodes.json +44 -0
  336. package/profiles/n8n-nodes/profile-nodes.test.json +91 -0
  337. package/profiles/semgrep/openapi.yaml +4706 -0
  338. package/profiles/semgrep/profile.json +692 -0
  339. package/profiles/semgrep/profile.test.json +471 -0
  340. package/profiles/youtrack/openapi.json +16976 -0
  341. package/profiles/youtrack/profile.json +608 -0
  342. package/profiles/youtrack/profile.test.json +1926 -0
  343. package/dist/src/testing/fixtures.d.ts +0 -684
  344. package/dist/src/testing/fixtures.d.ts.map +0 -1
  345. package/dist/src/testing/fixtures.js +0 -528
  346. package/dist/src/testing/fixtures.js.map +0 -1
  347. package/dist/src/testing/mock-gitlab-server.d.ts +0 -43
  348. package/dist/src/testing/mock-gitlab-server.d.ts.map +0 -1
  349. package/dist/src/testing/mock-gitlab-server.js +0 -1026
  350. package/dist/src/testing/mock-gitlab-server.js.map +0 -1
  351. package/dist/src/testing/mock-semgrep-server.d.ts +0 -32
  352. package/dist/src/testing/mock-semgrep-server.d.ts.map +0 -1
  353. package/dist/src/testing/mock-semgrep-server.js +0 -213
  354. package/dist/src/testing/mock-semgrep-server.js.map +0 -1
  355. package/dist/src/testing/mock-youtrack-server.d.ts +0 -11
  356. package/dist/src/testing/mock-youtrack-server.d.ts.map +0 -1
  357. package/dist/src/testing/mock-youtrack-server.js +0 -152
  358. package/dist/src/testing/mock-youtrack-server.js.map +0 -1
@@ -0,0 +1,70 @@
1
+ export function normalizeArguments(toolDef, args) {
2
+ const normalized = { ...args };
3
+ for (const [paramName, paramDef] of Object.entries(toolDef.parameters)) {
4
+ const value = normalized[paramName];
5
+ if (value === undefined) {
6
+ continue;
7
+ }
8
+ const mappedEntries = normalizeObjectEntries(paramDef, value);
9
+ if (mappedEntries !== undefined) {
10
+ normalized[paramName] = mappedEntries;
11
+ continue;
12
+ }
13
+ const mappedArrayItems = normalizeArrayItems(paramDef, value);
14
+ if (mappedArrayItems !== undefined) {
15
+ normalized[paramName] = mappedArrayItems;
16
+ }
17
+ }
18
+ return normalized;
19
+ }
20
+ export function applyParameterDefaults(toolDef, args) {
21
+ const normalized = { ...args };
22
+ for (const [paramName, paramDef] of Object.entries(toolDef.parameters)) {
23
+ if (normalized[paramName] === undefined && paramDef.default !== undefined) {
24
+ normalized[paramName] = paramDef.default;
25
+ }
26
+ }
27
+ return normalized;
28
+ }
29
+ function normalizeObjectEntries(paramDef, value) {
30
+ if (!paramDef.object_entries_to_array) {
31
+ return undefined;
32
+ }
33
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
34
+ return undefined;
35
+ }
36
+ const { key_field, value_field, wrap_value_field } = paramDef.object_entries_to_array;
37
+ const entries = Object.entries(value);
38
+ return entries.map(([key, entryValue]) => ({
39
+ [key_field]: key,
40
+ [value_field]: wrapObjectValue(entryValue, wrap_value_field),
41
+ }));
42
+ }
43
+ function wrapObjectValue(value, wrapValueField) {
44
+ if (!wrapValueField) {
45
+ return value;
46
+ }
47
+ if (typeof value === 'object' && value !== null) {
48
+ return value;
49
+ }
50
+ return { [wrapValueField]: value };
51
+ }
52
+ function normalizeArrayItems(paramDef, value) {
53
+ if (!paramDef.array_item_to_object) {
54
+ return undefined;
55
+ }
56
+ if (!Array.isArray(value)) {
57
+ return undefined;
58
+ }
59
+ const { key_field } = paramDef.array_item_to_object;
60
+ return value.map(item => {
61
+ if (typeof item === 'object' && item !== null && !Array.isArray(item)) {
62
+ return item;
63
+ }
64
+ if (['string', 'number', 'boolean'].includes(typeof item)) {
65
+ return { [key_field]: item };
66
+ }
67
+ return item;
68
+ });
69
+ }
70
+ //# sourceMappingURL=argument-normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argument-normalizer.js","sourceRoot":"","sources":["../../../src/validation/argument-normalizer.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,kBAAkB,CAChC,OAAuB,EACvB,IAA6B;IAE7B,MAAM,UAAU,GAAwB,EAAE,GAAG,IAAI,EAAE,CAAA;IAEnD,KAAK,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACvE,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;QACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAQ;QACV,CAAC;QAED,MAAM,aAAa,GAAG,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC7D,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YAChC,UAAU,CAAC,SAAS,CAAC,GAAG,aAAa,CAAA;YACrC,SAAQ;QACV,CAAC;QAED,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC7D,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,UAAU,CAAC,SAAS,CAAC,GAAG,gBAAgB,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAuB,EACvB,IAA6B;IAE7B,MAAM,UAAU,GAAwB,EAAE,GAAG,IAAI,EAAE,CAAA;IAEnD,KAAK,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACvE,IAAI,UAAU,CAAC,SA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AQ,CAAC,oBAAoB,EAAE,CAAC;QACnC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,oBAAoB,CAAA;IAEnD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACtE,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC;YAC1D,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * JSON-RPC message validation utilities
3
+ *
4
+ * Why: Eliminates code duplication between http-transport.ts and mcp-server.ts
5
+ * These functions validate JSON-RPC 2.0 message types used in MCP protocol.
6
+ */
7
+ /**
8
+ * Check if message is an initialize request
9
+ */
10
+ export declare function isInitializeRequest(message: unknown): boolean;
11
+ /**
12
+ * Check if message is a tool call request
13
+ */
14
+ export declare function isToolCallRequest(message: unknown): boolean;
15
+ /**
16
+ * Check if message is a tools/list request
17
+ */
18
+ export declare function isToolsListRequest(message: unknown): boolean;
19
+ /**
20
+ * Check if message is a valid JSON-RPC request object
21
+ */
22
+ export declare function isJsonRpcRequest(message: unknown): boolean;
23
+ /**
24
+ * Check if message is a valid JSON-RPC response object
25
+ */
26
+ export declare function isJsonRpcResponse(message: unknown): boolean;
27
+ //# sourceMappingURL=jsonrpc-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc-validator.d.ts","sourceRoot":"","sources":["../../../src/validation/jsonrpc-validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAI7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAI3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAI5D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS3D"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * JSON-RPC message validation utilities
3
+ *
4
+ * Why: Eliminates code duplication between http-transport.ts and mcp-server.ts
5
+ * These functions validate JSON-RPC 2.0 message types used in MCP protocol.
6
+ */
7
+ /**
8
+ * Check if message is an initialize request
9
+ */
10
+ export function isInitializeRequest(message) {
11
+ if (typeof message !== 'object' || message === null)
12
+ return false;
13
+ const req = message;
14
+ return req.method === 'initialize';
15
+ }
16
+ /**
17
+ * Check if message is a tool call request
18
+ */
19
+ export function isToolCallRequest(message) {
20
+ if (typeof message !== 'object' || message === null)
21
+ return false;
22
+ const req = message;
23
+ return req.method === 'tools/call';
24
+ }
25
+ /**
26
+ * Check if message is a tools/list request
27
+ */
28
+ export function isToolsListRequest(message) {
29
+ if (typeof message !== 'object' || message === null)
30
+ return false;
31
+ const req = message;
32
+ return req.method === 'tools/list';
33
+ }
34
+ /**
35
+ * Check if message is a valid JSON-RPC request object
36
+ */
37
+ export function isJsonRpcRequest(message) {
38
+ if (typeof message !== 'object' || message === null)
39
+ return false;
40
+ const req = message;
41
+ return (typeof req.jsonrpc === 'string' &&
42
+ req.jsonrpc === '2.0' &&
43
+ typeof req.method === 'string' &&
44
+ 'id' in req);
45
+ }
46
+ /**
47
+ * Check if message is a valid JSON-RPC response object
48
+ */
49
+ export function isJsonRpcResponse(message) {
50
+ if (typeof message !== 'object' || message === null)
51
+ return false;
52
+ const resp = message;
53
+ return (typeof resp.jsonrpc === 'string' &&
54
+ resp.jsonrpc === '2.0' &&
55
+ 'id' in resp &&
56
+ ('result' in resp || 'error' in resp));
57
+ }
58
+ //# sourceMappingURL=jsonrpc-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc-validator.js","sourceRoot":"","sources":["../../../src/validation/jsonrpc-validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,GAAG,GAAG,OAAkC,CAAC;IAC/C,OAAO,GAAG,CAAC,MAAM,KAAK,YAAY,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,GAAG,GAAG,OAAkC,CAAC;IAC/C,OAAO,GAAG,CAAC,MAAM,KAAK,YAAY,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,GAAG,GAAG,OAAkC,CAAC;IAC/C,OAAO,GAAG,CAAC,MAAM,KAAK,YAAY,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,GAAG,GAAG,OAAkC,CAAC;IAC/C,OAAO,CACL,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAC/B,GAAG,CAAC,OAAO,KAAK,KAAK;QACrB,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;QAC9B,IAAI,IAAI,GAAG,CACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,IAAI,GAAG,OAAkC,CAAC;IAChD,OAAO,CACL,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;QAChC,IAAI,CAAC,OAAO,KAAK,KAAK;QACtB,IAAI,IAAI,IAAI;QACZ,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC,CACtC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Request body schema validator
3
+ *
4
+ * Why: Catch invalid requests before sending to API. Better error messages for users.
5
+ * Validates against OpenAPI schema definitions.
6
+ */
7
+ import type { SchemaInfo, OperationInfo } from '../types/openapi.js';
8
+ export interface ValidationResult {
9
+ valid: boolean;
10
+ errors?: ValidationError[];
11
+ }
12
+ export interface ValidationError {
13
+ path: string;
14
+ message: string;
15
+ schema: SchemaInfo;
16
+ value: unknown;
17
+ }
18
+ export declare class SchemaValidator {
19
+ /**
20
+ * Validate request body against OpenAPI schema
21
+ *
22
+ * Why: Prevents sending malformed requests. OpenAPI schema is the source of truth.
23
+ */
24
+ validateRequestBody(operation: OperationInfo, body: unknown): ValidationResult;
25
+ /**
26
+ * Recursively validate data against schema
27
+ */
28
+ private validateAgainstSchema;
29
+ }
30
+ //# sourceMappingURL=schema-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../../src/validation/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGrE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qBAAa,eAAe;IAC1B;;;;OAIG;IACH,mBAAmB,CACjB,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,OAAO,GACZ,gBAAgB;IAgBnB;;OAEG;IACH,OAAO,CAAC,qBAAqB;CA2H9B"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Request body schema validator
3
+ *
4
+ * Why: Catch invalid requests before sending to API. Better error messages for users.
5
+ * Validates against OpenAPI schema definitions.
6
+ */
7
+ import { isEmail, isUri } from './validation-utils.js';
8
+ export class SchemaValidator {
9
+ /**
10
+ * Validate request body against OpenAPI schema
11
+ *
12
+ * Why: Prevents sending malformed requests. OpenAPI schema is the source of truth.
13
+ */
14
+ validateRequestBody(operation, body) {
15
+ if (!operation.requestBody?.content['application/json']?.schema) {
16
+ return { valid: true };
17
+ }
18
+ const schema = operation.requestBody.content['application/json'].schema;
19
+ const errors = [];
20
+ this.validateAgainstSchema(body, schema, '', errors);
21
+ return {
22
+ valid: errors.length === 0,
23
+ errors: errors.length > 0 ? errors : undefined,
24
+ };
25
+ }
26
+ /**
27
+ * Recursively validate data against schema
28
+ */
29
+ validateAgainstSchema(data, schema, path, errors) {
30
+ // Null/undefined handling
31
+ if (data === null || data === undefined) {
32
+ if (schema.type && schema.type !== 'null') {
33
+ errors.push({
34
+ path: path || '(root)',
35
+ message: `Expected ${schema.type}, got ${data}`,
36
+ schema,
37
+ value: data,
38
+ });
39
+ }
40
+ return;
41
+ }
42
+ // Type validation
43
+ if (schema.type) {
44
+ const actualType = Array.isArray(data) ? 'array' : typeof data;
45
+ // OpenAPI 'integer' is a subtype of 'number' with format constraint
46
+ const expectedType = schema.type === 'integer' ? 'number' : schema.type;
47
+ if (actualType !== expectedType) {
48
+ errors.push({
49
+ path: path || '(root)',
50
+ message: `Expected ${schema.type}, got ${actualType}`,
51
+ schema,
52
+ value: data,
53
+ });
54
+ return; // Stop validation if type is wrong
55
+ }
56
+ // Additional integer validation: check it's actually an integer
57
+ if (schema.type === 'integer' && typeof data === 'number') {
58
+ if (!Number.isInteger(data)) {
59
+ errors.push({
60
+ path: path || '(root)',
61
+ message: `Expected integer, got number`,
62
+ schema,
63
+ value: data,
64
+ });
65
+ }
66
+ }
67
+ }
68
+ // Enum validation
69
+ // Note: Using 'as any' here is safe - we're checking if value exists in enum array
70
+ // TypeScript doesn't know the enum values at compile time
71
+ if (schema.enum && !schema.enum.includes(data)) {
72
+ errors.push({
73
+ path: path || '(root)',
74
+ message: `Value must be one of: ${schema.enum.join(', ')}`,
75
+ schema,
76
+ value: data,
77
+ });
78
+ }
79
+ // Object properties validation
80
+ if (schema.type === 'object' && schema.properties) {
81
+ const obj = data;
82
+ // Check required properties
83
+ for (const required of schema.required || []) {
84
+ if (obj[required] === undefined) {
85
+ errors.push({
86
+ path: path ? `${path}.${required}` : required,
87
+ message: 'Required property is missing',
88
+ schema,
89
+ value: undefined,
90
+ });
91
+ }
92
+ }
93
+ // Validate each property
94
+ for (const [key, value] of Object.entries(obj)) {
95
+ if (schema.properties[key]) {
96
+ this.validateAgainstSchema(value, schema.properties[key], path ? `${path}.${key}` : key, errors);
97
+ }
98
+ // Note: Not validating additionalProperties (too strict for most APIs)
99
+ }
100
+ }
101
+ // Array items validation
102
+ if (schema.type === 'array' && schema.items && Array.isArray(data)) {
103
+ data.forEach((item, index) => {
104
+ this.validateAgainstSchema(item, schema.items, `${path}[${index}]`, errors);
105
+ });
106
+ }
107
+ // String format validation (basic)
108
+ if (schema.type === 'string' && schema.format && typeof data === 'string') {
109
+ if (schema.format === 'email' && !isEmail(data)) {
110
+ errors.push({
111
+ path: path || '(root)',
112
+ message: 'Invalid email format',
113
+ schema,
114
+ value: data,
115
+ });
116
+ }
117
+ if (schema.format === 'uri' && !isUri(data)) {
118
+ errors.push({
119
+ path: path || '(root)',
120
+ message: 'Invalid URI format',
121
+ schema,
122
+ value: data,
123
+ });
124
+ }
125
+ }
126
+ }
127
+ }
128
+ //# sourceMappingURL=schema-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-validator.js","sourceRoot":"","sources":["../../../src/validation/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAcvD,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,mBAAmB,CACjB,SAAwB,EACxB,IAAa;QAEb,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;YAChE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC;QACxE,MAAM,MAAM,GAAsB,EAAE,CAAC;QAErC,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAErD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SAC/C,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,qBAAqB,CAC3B,IAAa,EACb,MAAkB,EAClB,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
+ * Validation utilities for common data types
3
+ *
4
+ * Why: Provides reusable validation functions for email, URI, and other formats
5
+ * Centralizes validation logic and ensures consistency across the application
6
+ */
7
+ /**
8
+ * Validates that a property name is safe to use as dynamic object key.
9
+ * Prevents prototype pollution attacks.
10
+ */
11
+ export declare function isSafePropertyName(name: string): boolean;
12
+ /**
13
+ * Escape special regex characters in a string.
14
+ * Prevents ReDoS attacks when using dynamic strings in RegExp.
15
+ */
16
+ export declare function escapeRegExp(str: string): string;
17
+ /**
18
+ * Redact specific header from headers object (case-insensitive)
19
+ */
20
+ export declare function redactHeader(headers: unknown, headerName: string): Record<string, unknown>;
21
+ /**
22
+ * Redact query parameter from URL string
23
+ */
24
+ export declare function redactQueryParam(url: string | undefined, paramName: string): string;
25
+ /**
26
+ * Redact parameter from params object
27
+ */
28
+ export declare function redactParam(params: unknown, paramName: string): Record<string, unknown>;
29
+ /**
30
+ * Validates if a string is a valid email address
31
+ */
32
+ export declare function isEmail(value: string): boolean;
33
+ /**
34
+ * Validates if a string is a valid URI
35
+ */
36
+ export declare function isUri(value: string): boolean;
37
+ /**
38
+ * Escape HTML special characters to prevent XSS attacks
39
+ *
40
+ * Why: User-provided strings in error messages must be sanitized
41
+ * before being returned in JSON responses that might be rendered as HTML.
42
+ *
43
+ * Uses escape-html library for reliable HTML entity escaping.
44
+ *
45
+ * @param str - String to escape (can be undefined or null)
46
+ * @returns Escaped string safe for HTML rendering, empty string if input is falsy
47
+ */
48
+ export declare function escapeHtmlSafe(str: string | undefined | null): string;
49
+ //# sourceMappingURL=validation-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-utils.d.ts","sourceRoot":"","sources":["../../../src/validation/validation-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,SAAS,EAAE,MAAM,GAChB,MAAM,CAiCR;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG9C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO5C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAGrE"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Validation utilities for common data types
3
+ *
4
+ * Why: Provides reusable validation functions for email, URI, and other formats
5
+ * Centralizes validation logic and ensures consistency across the application
6
+ */
7
+ import escapeHtml from 'escape-html';
8
+ /** Property names that must never be used as dynamic object keys */
9
+ const FORBIDDEN_PROPERTY_NAMES = new Set([
10
+ '__proto__',
11
+ 'constructor',
12
+ 'prototype',
13
+ '__defineGetter__',
14
+ '__defineSetter__',
15
+ '__lookupGetter__',
16
+ '__lookupSetter__',
17
+ 'hasOwnProperty',
18
+ 'isPrototypeOf',
19
+ 'propertyIsEnumerable',
20
+ 'toLocaleString',
21
+ 'toString',
22
+ 'valueOf',
23
+ ]);
24
+ /**
25
+ * Validates that a property name is safe to use as dynamic object key.
26
+ * Prevents prototype pollution attacks.
27
+ */
28
+ export function isSafePropertyName(name) {
29
+ return !FORBIDDEN_PROPERTY_NAMES.has(name);
30
+ }
31
+ /**
32
+ * Escape special regex characters in a string.
33
+ * Prevents ReDoS attacks when using dynamic strings in RegExp.
34
+ */
35
+ export function escapeRegExp(str) {
36
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
37
+ }
38
+ /**
39
+ * Redact specific header from headers object (case-insensitive)
40
+ */
41
+ export function redactHeader(headers, headerName) {
42
+ if (!headers || typeof headers !== 'object')
43
+ return {};
44
+ const redacted = { ...headers };
45
+ for (const key of Object.keys(redacted)) {
46
+ if (key.toLowerCase() === headerName.toLowerCase()) {
47
+ redacted[key] = '[REDACTED]';
48
+ }
49
+ }
50
+ return redacted;
51
+ }
52
+ /**
53
+ * Redact query parameter from URL string
54
+ */
55
+ export function redactQueryParam(url, paramName) {
56
+ if (!url)
57
+ return '';
58
+ // Enforce safe paramName (alphanumeric, underscore, dash) length <= 64
59
+ if (!/^[A-Za-z0-9_-]{1,64}$/.test(paramName)) {
60
+ return url; // Unsafe param name; return original unmodified
61
+ }
62
+ try {
63
+ const urlObj = new URL(url);
64
+ if (urlObj.searchParams.has(paramName)) {
65
+ urlObj.searchParams.set(paramName, '[REDACTED]');
66
+ }
67
+ return urlObj.toString();
68
+ }
69
+ catch {
70
+ // Fallback: manual parsing without dynamic RegExp to avoid ReDoS concerns
71
+ // Split on '?' then process query string key-value pairs
72
+ const qIndex = url.indexOf('?');
73
+ if (qIndex === -1)
74
+ return url;
75
+ const base = url.substring(0, qIndex);
76
+ const query = url.substring(qIndex + 1);
77
+ const parts = query.split('&');
78
+ const redactedParts = parts.map(part => {
79
+ const eqIndex = part.indexOf('=');
80
+ if (eqIndex === -1)
81
+ return part; // skip malformed segment
82
+ const key = part.substring(0, eqIndex);
83
+ if (key === paramName) {
84
+ // Encode [REDACTED] for consistency with URLSearchParams behavior
85
+ return key + '=%5BREDACTED%5D';
86
+ }
87
+ return part;
88
+ });
89
+ return base + '?' + redactedParts.join('&');
90
+ }
91
+ }
92
+ /**
93
+ * Redact parameter from params object
94
+ */
95
+ export function redactParam(params, paramName) {
96
+ if (!params || typeof params !== 'object')
97
+ return {};
98
+ const redacted = { ...params };
99
+ if (paramName in redacted) {
100
+ redacted[paramName] = '[REDACTED]';
101
+ }
102
+ return redacted;
103
+ }
104
+ /**
105
+ * Validates if a string is a valid email address
106
+ */
107
+ export function isEmail(value) {
108
+ // codeql[js/polynomial-redos] Simple validation; not intended to fully validate RFC emails.
109
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
110
+ }
111
+ /**
112
+ * Validates if a string is a valid URI
113
+ */
114
+ export function isUri(value) {
115
+ try {
116
+ new URL(value);
117
+ return true;
118
+ }
119
+ catch {
120
+ return false;
121
+ }
122
+ }
123
+ /**
124
+ * Escape HTML special characters to prevent XSS attacks
125
+ *
126
+ * Why: User-provided strings in error messages must be sanitized
127
+ * before being returned in JSON responses that might be rendered as HTML.
128
+ *
129
+ * Uses escape-html library for reliable HTML entity escaping.
130
+ *
131
+ * @param str - String to escape (can be undefined or null)
132
+ * @returns Escaped string safe for HTML rendering, empty string if input is falsy
133
+ */
134
+ export function escapeHtmlSafe(str) {
135
+ if (!str)
136
+ return '';
137
+ return escapeHtml(String(str));
138
+ }
139
+ //# sourceMappingURL=validation-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-utils.js","sourceRoot":"","sources":["../../../src/validation/validation-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,oEAAoE;AACpE,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IACvC,WAAW;IACX,aAAa;IACb,WAAW;IACX,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;IACf,sBAAsB;IACtB,gBAAgB;IAChB,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC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