@joyjit/vikunja-mcp 0.3.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.
Files changed (424) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1377 -0
  4. package/dist/auth/AuthManager.d.ts +63 -0
  5. package/dist/auth/AuthManager.d.ts.map +1 -0
  6. package/dist/auth/AuthManager.js +137 -0
  7. package/dist/auth/AuthManager.js.map +1 -0
  8. package/dist/auth/index.d.ts +7 -0
  9. package/dist/auth/index.d.ts.map +1 -0
  10. package/dist/auth/index.js +14 -0
  11. package/dist/auth/index.js.map +1 -0
  12. package/dist/auth/permissions.d.ts +60 -0
  13. package/dist/auth/permissions.d.ts.map +1 -0
  14. package/dist/auth/permissions.js +173 -0
  15. package/dist/auth/permissions.js.map +1 -0
  16. package/dist/client/VikunjaClientFactory.d.ts +32 -0
  17. package/dist/client/VikunjaClientFactory.d.ts.map +1 -0
  18. package/dist/client/VikunjaClientFactory.js +66 -0
  19. package/dist/client/VikunjaClientFactory.js.map +1 -0
  20. package/dist/client.d.ts +57 -0
  21. package/dist/client.d.ts.map +1 -0
  22. package/dist/client.js +128 -0
  23. package/dist/client.js.map +1 -0
  24. package/dist/config/ConfigurationManager.d.ts +63 -0
  25. package/dist/config/ConfigurationManager.d.ts.map +1 -0
  26. package/dist/config/ConfigurationManager.js +243 -0
  27. package/dist/config/ConfigurationManager.js.map +1 -0
  28. package/dist/config/index.d.ts +8 -0
  29. package/dist/config/index.d.ts.map +1 -0
  30. package/dist/config/index.js +27 -0
  31. package/dist/config/index.js.map +1 -0
  32. package/dist/config/types.d.ts +434 -0
  33. package/dist/config/types.d.ts.map +1 -0
  34. package/dist/config/types.js +93 -0
  35. package/dist/config/types.js.map +1 -0
  36. package/dist/formatters/BatchImportResponseFormatter.d.ts +89 -0
  37. package/dist/formatters/BatchImportResponseFormatter.d.ts.map +1 -0
  38. package/dist/formatters/BatchImportResponseFormatter.js +125 -0
  39. package/dist/formatters/BatchImportResponseFormatter.js.map +1 -0
  40. package/dist/index.d.ts +20 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +119 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/middleware/direct-middleware.d.ts +9 -0
  45. package/dist/middleware/direct-middleware.d.ts.map +1 -0
  46. package/dist/middleware/direct-middleware.js +49 -0
  47. package/dist/middleware/direct-middleware.js.map +1 -0
  48. package/dist/middleware/index.d.ts +8 -0
  49. package/dist/middleware/index.d.ts.map +1 -0
  50. package/dist/middleware/index.js +21 -0
  51. package/dist/middleware/index.js.map +1 -0
  52. package/dist/middleware/simplified-rate-limit.d.ts +147 -0
  53. package/dist/middleware/simplified-rate-limit.d.ts.map +1 -0
  54. package/dist/middleware/simplified-rate-limit.js +542 -0
  55. package/dist/middleware/simplified-rate-limit.js.map +1 -0
  56. package/dist/parsers/CSVParser.d.ts +36 -0
  57. package/dist/parsers/CSVParser.d.ts.map +1 -0
  58. package/dist/parsers/CSVParser.js +69 -0
  59. package/dist/parsers/CSVParser.js.map +1 -0
  60. package/dist/parsers/InputParserFactory.d.ts +17 -0
  61. package/dist/parsers/InputParserFactory.d.ts.map +1 -0
  62. package/dist/parsers/InputParserFactory.js +137 -0
  63. package/dist/parsers/InputParserFactory.js.map +1 -0
  64. package/dist/parsers/JSONParser.d.ts +74 -0
  65. package/dist/parsers/JSONParser.d.ts.map +1 -0
  66. package/dist/parsers/JSONParser.js +69 -0
  67. package/dist/parsers/JSONParser.js.map +1 -0
  68. package/dist/services/EntityResolver.d.ts +75 -0
  69. package/dist/services/EntityResolver.d.ts.map +1 -0
  70. package/dist/services/EntityResolver.js +176 -0
  71. package/dist/services/EntityResolver.js.map +1 -0
  72. package/dist/services/TaskCreationService.d.ts +96 -0
  73. package/dist/services/TaskCreationService.d.ts.map +1 -0
  74. package/dist/services/TaskCreationService.js +361 -0
  75. package/dist/services/TaskCreationService.js.map +1 -0
  76. package/dist/storage/SimpleFilterStorage.d.ts +110 -0
  77. package/dist/storage/SimpleFilterStorage.d.ts.map +1 -0
  78. package/dist/storage/SimpleFilterStorage.js +358 -0
  79. package/dist/storage/SimpleFilterStorage.js.map +1 -0
  80. package/dist/storage/index.d.ts +59 -0
  81. package/dist/storage/index.d.ts.map +1 -0
  82. package/dist/storage/index.js +117 -0
  83. package/dist/storage/index.js.map +1 -0
  84. package/dist/tools/auth.d.ts +9 -0
  85. package/dist/tools/auth.d.ts.map +1 -0
  86. package/dist/tools/auth.js +80 -0
  87. package/dist/tools/auth.js.map +1 -0
  88. package/dist/tools/batch-import.d.ts +5 -0
  89. package/dist/tools/batch-import.d.ts.map +1 -0
  90. package/dist/tools/batch-import.js +150 -0
  91. package/dist/tools/batch-import.js.map +1 -0
  92. package/dist/tools/export.d.ts +14 -0
  93. package/dist/tools/export.d.ts.map +1 -0
  94. package/dist/tools/export.js +232 -0
  95. package/dist/tools/export.js.map +1 -0
  96. package/dist/tools/filters.d.ts +8 -0
  97. package/dist/tools/filters.d.ts.map +1 -0
  98. package/dist/tools/filters.js +419 -0
  99. package/dist/tools/filters.js.map +1 -0
  100. package/dist/tools/index.d.ts +36 -0
  101. package/dist/tools/index.d.ts.map +1 -0
  102. package/dist/tools/index.js +87 -0
  103. package/dist/tools/index.js.map +1 -0
  104. package/dist/tools/labels.d.ts +9 -0
  105. package/dist/tools/labels.d.ts.map +1 -0
  106. package/dist/tools/labels.js +152 -0
  107. package/dist/tools/labels.js.map +1 -0
  108. package/dist/tools/projects/crud.d.ts +118 -0
  109. package/dist/tools/projects/crud.d.ts.map +1 -0
  110. package/dist/tools/projects/crud.js +389 -0
  111. package/dist/tools/projects/crud.js.map +1 -0
  112. package/dist/tools/projects/hierarchy.d.ts +68 -0
  113. package/dist/tools/projects/hierarchy.d.ts.map +1 -0
  114. package/dist/tools/projects/hierarchy.js +280 -0
  115. package/dist/tools/projects/hierarchy.js.map +1 -0
  116. package/dist/tools/projects/index.d.ts +17 -0
  117. package/dist/tools/projects/index.d.ts.map +1 -0
  118. package/dist/tools/projects/index.js +169 -0
  119. package/dist/tools/projects/index.js.map +1 -0
  120. package/dist/tools/projects/response-formatter.d.ts +46 -0
  121. package/dist/tools/projects/response-formatter.d.ts.map +1 -0
  122. package/dist/tools/projects/response-formatter.js +131 -0
  123. package/dist/tools/projects/response-formatter.js.map +1 -0
  124. package/dist/tools/projects/sharing.d.ts +89 -0
  125. package/dist/tools/projects/sharing.d.ts.map +1 -0
  126. package/dist/tools/projects/sharing.js +272 -0
  127. package/dist/tools/projects/sharing.js.map +1 -0
  128. package/dist/tools/projects/validation.d.ts +39 -0
  129. package/dist/tools/projects/validation.d.ts.map +1 -0
  130. package/dist/tools/projects/validation.js +129 -0
  131. package/dist/tools/projects/validation.js.map +1 -0
  132. package/dist/tools/projects.d.ts +10 -0
  133. package/dist/tools/projects.d.ts.map +1 -0
  134. package/dist/tools/projects.js +42 -0
  135. package/dist/tools/projects.js.map +1 -0
  136. package/dist/tools/task-assignees.d.ts +13 -0
  137. package/dist/tools/task-assignees.d.ts.map +1 -0
  138. package/dist/tools/task-assignees.js +62 -0
  139. package/dist/tools/task-assignees.js.map +1 -0
  140. package/dist/tools/task-bulk.d.ts +13 -0
  141. package/dist/tools/task-bulk.d.ts.map +1 -0
  142. package/dist/tools/task-bulk.js +113 -0
  143. package/dist/tools/task-bulk.js.map +1 -0
  144. package/dist/tools/task-comments.d.ts +13 -0
  145. package/dist/tools/task-comments.d.ts.map +1 -0
  146. package/dist/tools/task-comments.js +53 -0
  147. package/dist/tools/task-comments.js.map +1 -0
  148. package/dist/tools/task-crud.d.ts +13 -0
  149. package/dist/tools/task-crud.d.ts.map +1 -0
  150. package/dist/tools/task-crud.js +163 -0
  151. package/dist/tools/task-crud.js.map +1 -0
  152. package/dist/tools/task-labels.d.ts +13 -0
  153. package/dist/tools/task-labels.d.ts.map +1 -0
  154. package/dist/tools/task-labels.js +62 -0
  155. package/dist/tools/task-labels.js.map +1 -0
  156. package/dist/tools/task-relations.d.ts +13 -0
  157. package/dist/tools/task-relations.d.ts.map +1 -0
  158. package/dist/tools/task-relations.js +72 -0
  159. package/dist/tools/task-relations.js.map +1 -0
  160. package/dist/tools/task-reminders.d.ts +13 -0
  161. package/dist/tools/task-reminders.d.ts.map +1 -0
  162. package/dist/tools/task-reminders.js +63 -0
  163. package/dist/tools/task-reminders.js.map +1 -0
  164. package/dist/tools/tasks/assignees/AssigneeOperationsService.d.ts +31 -0
  165. package/dist/tools/tasks/assignees/AssigneeOperationsService.d.ts.map +1 -0
  166. package/dist/tools/tasks/assignees/AssigneeOperationsService.js +95 -0
  167. package/dist/tools/tasks/assignees/AssigneeOperationsService.js.map +1 -0
  168. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.d.ts +32 -0
  169. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.d.ts.map +1 -0
  170. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.js +84 -0
  171. package/dist/tools/tasks/assignees/AssigneeResponseFormatter.js.map +1 -0
  172. package/dist/tools/tasks/assignees/AssigneeValidationService.d.ts +36 -0
  173. package/dist/tools/tasks/assignees/AssigneeValidationService.d.ts.map +1 -0
  174. package/dist/tools/tasks/assignees/AssigneeValidationService.js +63 -0
  175. package/dist/tools/tasks/assignees/AssigneeValidationService.js.map +1 -0
  176. package/dist/tools/tasks/assignees/index.d.ts +40 -0
  177. package/dist/tools/tasks/assignees/index.d.ts.map +1 -0
  178. package/dist/tools/tasks/assignees/index.js +72 -0
  179. package/dist/tools/tasks/assignees/index.js.map +1 -0
  180. package/dist/tools/tasks/bulk/BulkOperationValidator.d.ts +51 -0
  181. package/dist/tools/tasks/bulk/BulkOperationValidator.d.ts.map +1 -0
  182. package/dist/tools/tasks/bulk/BulkOperationValidator.js +149 -0
  183. package/dist/tools/tasks/bulk/BulkOperationValidator.js.map +1 -0
  184. package/dist/tools/tasks/bulk-operations-simplified.d.ts +39 -0
  185. package/dist/tools/tasks/bulk-operations-simplified.d.ts.map +1 -0
  186. package/dist/tools/tasks/bulk-operations-simplified.js +249 -0
  187. package/dist/tools/tasks/bulk-operations-simplified.js.map +1 -0
  188. package/dist/tools/tasks/bulk-operations.d.ts +8 -0
  189. package/dist/tools/tasks/bulk-operations.d.ts.map +1 -0
  190. package/dist/tools/tasks/bulk-operations.js +14 -0
  191. package/dist/tools/tasks/bulk-operations.js.map +1 -0
  192. package/dist/tools/tasks/comments/CommentOperationsService.d.ts +23 -0
  193. package/dist/tools/tasks/comments/CommentOperationsService.d.ts.map +1 -0
  194. package/dist/tools/tasks/comments/CommentOperationsService.js +37 -0
  195. package/dist/tools/tasks/comments/CommentOperationsService.js.map +1 -0
  196. package/dist/tools/tasks/comments/CommentResponseFormatter.d.ts +29 -0
  197. package/dist/tools/tasks/comments/CommentResponseFormatter.d.ts.map +1 -0
  198. package/dist/tools/tasks/comments/CommentResponseFormatter.js +69 -0
  199. package/dist/tools/tasks/comments/CommentResponseFormatter.js.map +1 -0
  200. package/dist/tools/tasks/comments/CommentValidationService.d.ts +33 -0
  201. package/dist/tools/tasks/comments/CommentValidationService.d.ts.map +1 -0
  202. package/dist/tools/tasks/comments/CommentValidationService.js +50 -0
  203. package/dist/tools/tasks/comments/CommentValidationService.js.map +1 -0
  204. package/dist/tools/tasks/comments/index.d.ts +38 -0
  205. package/dist/tools/tasks/comments/index.d.ts.map +1 -0
  206. package/dist/tools/tasks/comments/index.js +62 -0
  207. package/dist/tools/tasks/comments/index.js.map +1 -0
  208. package/dist/tools/tasks/constants.d.ts +17 -0
  209. package/dist/tools/tasks/constants.d.ts.map +1 -0
  210. package/dist/tools/tasks/constants.js +36 -0
  211. package/dist/tools/tasks/constants.js.map +1 -0
  212. package/dist/tools/tasks/crud/TaskCreationService.d.ts +26 -0
  213. package/dist/tools/tasks/crud/TaskCreationService.d.ts.map +1 -0
  214. package/dist/tools/tasks/crud/TaskCreationService.js +228 -0
  215. package/dist/tools/tasks/crud/TaskCreationService.js.map +1 -0
  216. package/dist/tools/tasks/crud/TaskDeletionService.d.ts +18 -0
  217. package/dist/tools/tasks/crud/TaskDeletionService.d.ts.map +1 -0
  218. package/dist/tools/tasks/crud/TaskDeletionService.js +89 -0
  219. package/dist/tools/tasks/crud/TaskDeletionService.js.map +1 -0
  220. package/dist/tools/tasks/crud/TaskReadService.d.ts +18 -0
  221. package/dist/tools/tasks/crud/TaskReadService.d.ts.map +1 -0
  222. package/dist/tools/tasks/crud/TaskReadService.js +58 -0
  223. package/dist/tools/tasks/crud/TaskReadService.js.map +1 -0
  224. package/dist/tools/tasks/crud/TaskResponseFormatter.d.ts +18 -0
  225. package/dist/tools/tasks/crud/TaskResponseFormatter.d.ts.map +1 -0
  226. package/dist/tools/tasks/crud/TaskResponseFormatter.js +244 -0
  227. package/dist/tools/tasks/crud/TaskResponseFormatter.js.map +1 -0
  228. package/dist/tools/tasks/crud/TaskUpdateService.d.ts +29 -0
  229. package/dist/tools/tasks/crud/TaskUpdateService.d.ts.map +1 -0
  230. package/dist/tools/tasks/crud/TaskUpdateService.js +231 -0
  231. package/dist/tools/tasks/crud/TaskUpdateService.js.map +1 -0
  232. package/dist/tools/tasks/crud/index.d.ts +16 -0
  233. package/dist/tools/tasks/crud/index.d.ts.map +1 -0
  234. package/dist/tools/tasks/crud/index.js +20 -0
  235. package/dist/tools/tasks/crud/index.js.map +1 -0
  236. package/dist/tools/tasks/filtering/FilterExecutor.d.ts +38 -0
  237. package/dist/tools/tasks/filtering/FilterExecutor.d.ts.map +1 -0
  238. package/dist/tools/tasks/filtering/FilterExecutor.js +200 -0
  239. package/dist/tools/tasks/filtering/FilterExecutor.js.map +1 -0
  240. package/dist/tools/tasks/filtering/FilterValidator.d.ts +56 -0
  241. package/dist/tools/tasks/filtering/FilterValidator.d.ts.map +1 -0
  242. package/dist/tools/tasks/filtering/FilterValidator.js +183 -0
  243. package/dist/tools/tasks/filtering/FilterValidator.js.map +1 -0
  244. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.d.ts +75 -0
  245. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.d.ts.map +1 -0
  246. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.js +193 -0
  247. package/dist/tools/tasks/filtering/TaskFilteringOrchestrator.js.map +1 -0
  248. package/dist/tools/tasks/filtering/evaluators.d.ts +38 -0
  249. package/dist/tools/tasks/filtering/evaluators.d.ts.map +1 -0
  250. package/dist/tools/tasks/filtering/evaluators.js +200 -0
  251. package/dist/tools/tasks/filtering/evaluators.js.map +1 -0
  252. package/dist/tools/tasks/filtering/index.d.ts +11 -0
  253. package/dist/tools/tasks/filtering/index.d.ts.map +1 -0
  254. package/dist/tools/tasks/filtering/index.js +26 -0
  255. package/dist/tools/tasks/filtering/index.js.map +1 -0
  256. package/dist/tools/tasks/index.d.ts +9 -0
  257. package/dist/tools/tasks/index.d.ts.map +1 -0
  258. package/dist/tools/tasks/index.js +245 -0
  259. package/dist/tools/tasks/index.js.map +1 -0
  260. package/dist/tools/tasks/labels.d.ts +39 -0
  261. package/dist/tools/tasks/labels.d.ts.map +1 -0
  262. package/dist/tools/tasks/labels.js +150 -0
  263. package/dist/tools/tasks/labels.js.map +1 -0
  264. package/dist/tools/tasks/reminders.d.ts +39 -0
  265. package/dist/tools/tasks/reminders.d.ts.map +1 -0
  266. package/dist/tools/tasks/reminders.js +147 -0
  267. package/dist/tools/tasks/reminders.js.map +1 -0
  268. package/dist/tools/tasks/types/filters.d.ts +121 -0
  269. package/dist/tools/tasks/types/filters.d.ts.map +1 -0
  270. package/dist/tools/tasks/types/filters.js +7 -0
  271. package/dist/tools/tasks/types/filters.js.map +1 -0
  272. package/dist/tools/tasks/validation.d.ts +44 -0
  273. package/dist/tools/tasks/validation.d.ts.map +1 -0
  274. package/dist/tools/tasks/validation.js +121 -0
  275. package/dist/tools/tasks/validation.js.map +1 -0
  276. package/dist/tools/tasks-relations.d.ts +24 -0
  277. package/dist/tools/tasks-relations.d.ts.map +1 -0
  278. package/dist/tools/tasks-relations.js +203 -0
  279. package/dist/tools/tasks-relations.js.map +1 -0
  280. package/dist/tools/tasks.d.ts +6 -0
  281. package/dist/tools/tasks.d.ts.map +1 -0
  282. package/dist/tools/tasks.js +10 -0
  283. package/dist/tools/tasks.js.map +1 -0
  284. package/dist/tools/teams.d.ts +9 -0
  285. package/dist/tools/teams.d.ts.map +1 -0
  286. package/dist/tools/teams.js +332 -0
  287. package/dist/tools/teams.js.map +1 -0
  288. package/dist/tools/templates.d.ts +9 -0
  289. package/dist/tools/templates.d.ts.map +1 -0
  290. package/dist/tools/templates.js +356 -0
  291. package/dist/tools/templates.js.map +1 -0
  292. package/dist/tools/users.d.ts +9 -0
  293. package/dist/tools/users.d.ts.map +1 -0
  294. package/dist/tools/users.js +239 -0
  295. package/dist/tools/users.js.map +1 -0
  296. package/dist/tools/webhooks.d.ts +11 -0
  297. package/dist/tools/webhooks.d.ts.map +1 -0
  298. package/dist/tools/webhooks.js +378 -0
  299. package/dist/tools/webhooks.js.map +1 -0
  300. package/dist/transforms/base.d.ts +178 -0
  301. package/dist/transforms/base.d.ts.map +1 -0
  302. package/dist/transforms/base.js +134 -0
  303. package/dist/transforms/base.js.map +1 -0
  304. package/dist/transforms/field-selector.d.ts +27 -0
  305. package/dist/transforms/field-selector.d.ts.map +1 -0
  306. package/dist/transforms/field-selector.js +91 -0
  307. package/dist/transforms/field-selector.js.map +1 -0
  308. package/dist/transforms/task.d.ts +207 -0
  309. package/dist/transforms/task.d.ts.map +1 -0
  310. package/dist/transforms/task.js +259 -0
  311. package/dist/transforms/task.js.map +1 -0
  312. package/dist/types/errors.d.ts +55 -0
  313. package/dist/types/errors.d.ts.map +1 -0
  314. package/dist/types/errors.js +44 -0
  315. package/dist/types/errors.js.map +1 -0
  316. package/dist/types/filters.d.ts +146 -0
  317. package/dist/types/filters.d.ts.map +1 -0
  318. package/dist/types/filters.js +22 -0
  319. package/dist/types/filters.js.map +1 -0
  320. package/dist/types/index.d.ts +151 -0
  321. package/dist/types/index.d.ts.map +1 -0
  322. package/dist/types/index.js +24 -0
  323. package/dist/types/index.js.map +1 -0
  324. package/dist/types/node-vikunja-extended.d.ts +36 -0
  325. package/dist/types/node-vikunja-extended.d.ts.map +1 -0
  326. package/dist/types/node-vikunja-extended.js +25 -0
  327. package/dist/types/node-vikunja-extended.js.map +1 -0
  328. package/dist/types/responses.d.ts +118 -0
  329. package/dist/types/responses.d.ts.map +1 -0
  330. package/dist/types/responses.js +26 -0
  331. package/dist/types/responses.js.map +1 -0
  332. package/dist/types/vikunja.d.ts +315 -0
  333. package/dist/types/vikunja.d.ts.map +1 -0
  334. package/dist/types/vikunja.js +7 -0
  335. package/dist/types/vikunja.js.map +1 -0
  336. package/dist/utils/auth-error-handler.d.ts +23 -0
  337. package/dist/utils/auth-error-handler.d.ts.map +1 -0
  338. package/dist/utils/auth-error-handler.js +162 -0
  339. package/dist/utils/auth-error-handler.js.map +1 -0
  340. package/dist/utils/error-handler.d.ts +38 -0
  341. package/dist/utils/error-handler.d.ts.map +1 -0
  342. package/dist/utils/error-handler.js +288 -0
  343. package/dist/utils/error-handler.js.map +1 -0
  344. package/dist/utils/filtering/ClientSideFilteringStrategy.d.ts +13 -0
  345. package/dist/utils/filtering/ClientSideFilteringStrategy.d.ts.map +1 -0
  346. package/dist/utils/filtering/ClientSideFilteringStrategy.js +63 -0
  347. package/dist/utils/filtering/ClientSideFilteringStrategy.js.map +1 -0
  348. package/dist/utils/filtering/FilteringContext.d.ts +27 -0
  349. package/dist/utils/filtering/FilteringContext.d.ts.map +1 -0
  350. package/dist/utils/filtering/FilteringContext.js +43 -0
  351. package/dist/utils/filtering/FilteringContext.js.map +1 -0
  352. package/dist/utils/filtering/HybridFilteringStrategy.d.ts +15 -0
  353. package/dist/utils/filtering/HybridFilteringStrategy.d.ts.map +1 -0
  354. package/dist/utils/filtering/HybridFilteringStrategy.js +55 -0
  355. package/dist/utils/filtering/HybridFilteringStrategy.js.map +1 -0
  356. package/dist/utils/filtering/ServerSideFilteringStrategy.d.ts +13 -0
  357. package/dist/utils/filtering/ServerSideFilteringStrategy.d.ts.map +1 -0
  358. package/dist/utils/filtering/ServerSideFilteringStrategy.js +64 -0
  359. package/dist/utils/filtering/ServerSideFilteringStrategy.js.map +1 -0
  360. package/dist/utils/filtering/TaskFilteringStrategy.d.ts +19 -0
  361. package/dist/utils/filtering/TaskFilteringStrategy.d.ts.map +1 -0
  362. package/dist/utils/filtering/TaskFilteringStrategy.js +10 -0
  363. package/dist/utils/filtering/TaskFilteringStrategy.js.map +1 -0
  364. package/dist/utils/filtering/index.d.ts +13 -0
  365. package/dist/utils/filtering/index.d.ts.map +1 -0
  366. package/dist/utils/filtering/index.js +20 -0
  367. package/dist/utils/filtering/index.js.map +1 -0
  368. package/dist/utils/filtering/types.d.ts +62 -0
  369. package/dist/utils/filtering/types.d.ts.map +1 -0
  370. package/dist/utils/filtering/types.js +6 -0
  371. package/dist/utils/filtering/types.js.map +1 -0
  372. package/dist/utils/filters.d.ts +97 -0
  373. package/dist/utils/filters.d.ts.map +1 -0
  374. package/dist/utils/filters.js +939 -0
  375. package/dist/utils/filters.js.map +1 -0
  376. package/dist/utils/logger.d.ts +26 -0
  377. package/dist/utils/logger.d.ts.map +1 -0
  378. package/dist/utils/logger.js +83 -0
  379. package/dist/utils/logger.js.map +1 -0
  380. package/dist/utils/memory.d.ts +71 -0
  381. package/dist/utils/memory.d.ts.map +1 -0
  382. package/dist/utils/memory.js +194 -0
  383. package/dist/utils/memory.js.map +1 -0
  384. package/dist/utils/performance/batch-processor.d.ts +77 -0
  385. package/dist/utils/performance/batch-processor.d.ts.map +1 -0
  386. package/dist/utils/performance/batch-processor.js +218 -0
  387. package/dist/utils/performance/batch-processor.js.map +1 -0
  388. package/dist/utils/performance/index.d.ts +42 -0
  389. package/dist/utils/performance/index.d.ts.map +1 -0
  390. package/dist/utils/performance/index.js +49 -0
  391. package/dist/utils/performance/index.js.map +1 -0
  392. package/dist/utils/performance/performance-monitor.d.ts +116 -0
  393. package/dist/utils/performance/performance-monitor.d.ts.map +1 -0
  394. package/dist/utils/performance/performance-monitor.js +307 -0
  395. package/dist/utils/performance/performance-monitor.js.map +1 -0
  396. package/dist/utils/response-factory.d.ts +81 -0
  397. package/dist/utils/response-factory.d.ts.map +1 -0
  398. package/dist/utils/response-factory.js +86 -0
  399. package/dist/utils/response-factory.js.map +1 -0
  400. package/dist/utils/retry.d.ts +146 -0
  401. package/dist/utils/retry.d.ts.map +1 -0
  402. package/dist/utils/retry.js +281 -0
  403. package/dist/utils/retry.js.map +1 -0
  404. package/dist/utils/security.d.ts +70 -0
  405. package/dist/utils/security.d.ts.map +1 -0
  406. package/dist/utils/security.js +358 -0
  407. package/dist/utils/security.js.map +1 -0
  408. package/dist/utils/simple-response.d.ts +75 -0
  409. package/dist/utils/simple-response.d.ts.map +1 -0
  410. package/dist/utils/simple-response.js +208 -0
  411. package/dist/utils/simple-response.js.map +1 -0
  412. package/dist/utils/storage-errors.d.ts +9 -0
  413. package/dist/utils/storage-errors.d.ts.map +1 -0
  414. package/dist/utils/storage-errors.js +20 -0
  415. package/dist/utils/storage-errors.js.map +1 -0
  416. package/dist/utils/unicode-fix.d.ts +19 -0
  417. package/dist/utils/unicode-fix.d.ts.map +1 -0
  418. package/dist/utils/unicode-fix.js +70 -0
  419. package/dist/utils/unicode-fix.js.map +1 -0
  420. package/dist/utils/validation.d.ts +103 -0
  421. package/dist/utils/validation.d.ts.map +1 -0
  422. package/dist/utils/validation.js +729 -0
  423. package/dist/utils/validation.js.map +1 -0
  424. package/package.json +148 -0
@@ -0,0 +1,729 @@
1
+ "use strict";
2
+ /**
3
+ * Comprehensive Input Sanitization and Security Validation Layer
4
+ *
5
+ * Provides enterprise-grade protection against:
6
+ * - XSS attacks (script injection, HTML injection)
7
+ * - SQL injection (UNION, boolean-based, time-based)
8
+ * - Command injection (shell command execution)
9
+ * - Path traversal attacks
10
+ * - LDAP injection
11
+ * - NoSQL injection
12
+ * - Unicode and encoding bypasses
13
+ * - Content Security Policy violations
14
+ *
15
+ * Integration: Works seamlessly with existing security.ts credential masking
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.validationInternals = void 0;
19
+ exports.sanitizeString = sanitizeString;
20
+ exports.validateField = validateField;
21
+ exports.validateOperator = validateOperator;
22
+ exports.validateLogicalOperator = validateLogicalOperator;
23
+ exports.validateValue = validateValue;
24
+ exports.validateCondition = validateCondition;
25
+ exports.validateFilterExpression = validateFilterExpression;
26
+ exports.safeJsonStringify = safeJsonStringify;
27
+ exports.safeJsonParse = safeJsonParse;
28
+ exports.validateId = validateId;
29
+ exports.validateAndConvertId = validateAndConvertId;
30
+ const zod_1 = require("zod");
31
+ const errors_1 = require("../types/errors");
32
+ /**
33
+ * Maximum allowed nesting depth for filter expressions (prevents DoS)
34
+ */
35
+ const MAX_NESTING_DEPTH = 10;
36
+ /**
37
+ * Maximum allowed number of conditions per expression (prevents DoS)
38
+ */
39
+ const MAX_CONDITIONS = 50;
40
+ /**
41
+ * Maximum string length for filter values (prevents storage bloat)
42
+ */
43
+ const MAX_STRING_LENGTH = 1000;
44
+ /**
45
+ * Zod schemas for type-safe validation
46
+ */
47
+ const FieldSchema = zod_1.z.enum([
48
+ 'done', 'priority', 'percentDone', 'dueDate', 'assignees',
49
+ 'labels', 'created', 'updated', 'title', 'description'
50
+ ]);
51
+ const OperatorSchema = zod_1.z.enum([
52
+ '=', '!=', '>', '>=', '<', '<=', 'like', 'in', 'not in'
53
+ ]);
54
+ const LogicalOperatorSchema = zod_1.z.enum(['&&', '||']);
55
+ /**
56
+ * Server-appropriate security validation patterns
57
+ * Created fresh each call to avoid regex state issues
58
+ */
59
+ /**
60
+ * Allowed characters for additional strictness (optional, can be relaxed)
61
+ */
62
+ /**
63
+ * Validate and sanitize a string value to prevent XSS using pattern matching + HTML escaping
64
+ * Server-appropriate approach that avoids DOM parsing while providing comprehensive protection
65
+ */
66
+ function sanitizeString(value) {
67
+ if (typeof value !== 'string') {
68
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Value must be a string');
69
+ }
70
+ if (value.length > MAX_STRING_LENGTH) {
71
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `String value exceeds maximum length of ${MAX_STRING_LENGTH}`);
72
+ }
73
+ // Step 1: Check for dangerous HTML/JavaScript patterns and REJECT them (don't sanitize)
74
+ // Convert to lowercase for case-insensitive pattern matching
75
+ const lowerValue = value.toLowerCase();
76
+ // Create fresh patterns each time to avoid regex state issues
77
+ const dangerousPatterns = [
78
+ // Enhanced XSS patterns - comprehensive script and injection detection
79
+ /<script[^>]*>/gi,
80
+ /<\/script>/gi,
81
+ /<iframe[^>]*>/gi,
82
+ /<\/iframe>/gi,
83
+ /<object[^>]*>/gi,
84
+ /<\/object>/gi,
85
+ /<embed[^>]*>/gi,
86
+ /<link[^>]*>/gi,
87
+ /<meta[^>]*>/gi,
88
+ /<svg[^>]*>/gi,
89
+ /<\/svg>/gi,
90
+ /<style[^>]*>/gi,
91
+ /<\/style>/gi,
92
+ /<img[^>]*on[^>]*>/gi,
93
+ /<div[^>]*on[^>]*>/gi,
94
+ /<a[^>]*on[^>]*>/gi,
95
+ /<body[^>]*on[^>]*>/gi,
96
+ /<form[^>]*on[^>]*>/gi,
97
+ /<input[^>]*on[^>]*>/gi,
98
+ /<button[^>]*on[^>]*>/gi,
99
+ /<select[^>]*on[^>]*>/gi,
100
+ /<textarea[^>]*on[^>]*>/gi,
101
+ // Event handlers with attributes (more specific to avoid false positives)
102
+ /on\w+\s*=\s*["'][^"']*["']/gi,
103
+ /onclick/gi,
104
+ /onload/gi,
105
+ /onerror/gi,
106
+ /onmouseover/gi,
107
+ /onmouseout/gi,
108
+ /onmousedown/gi,
109
+ /onmouseup/gi,
110
+ /onkeydown/gi,
111
+ /onkeyup/gi,
112
+ /onkeypress/gi,
113
+ /onfocus/gi,
114
+ /onblur/gi,
115
+ /onchange/gi,
116
+ /onsubmit/gi,
117
+ /onreset/gi,
118
+ /onselect/gi,
119
+ /onunload/gi,
120
+ /onabort/gi,
121
+ /oncanplay/gi,
122
+ /oncanplaythrough/gi,
123
+ /oncuechange/gi,
124
+ /ondurationchange/gi,
125
+ /onemptied/gi,
126
+ /onended/gi,
127
+ /onerror/gi,
128
+ /onloadeddata/gi,
129
+ /onloadedmetadata/gi,
130
+ /onloadstart/gi,
131
+ /onpause/gi,
132
+ /onplay/gi,
133
+ /onplaying/gi,
134
+ /onprogress/gi,
135
+ /onratechange/gi,
136
+ /onseeked/gi,
137
+ /onseeking/gi,
138
+ /onstalled/gi,
139
+ /onsuspend/gi,
140
+ /ontimeupdate/gi,
141
+ /onvolumechange/gi,
142
+ /onwaiting/gi,
143
+ // Dangerous protocols and schemes
144
+ /javascript:/gi,
145
+ /vbscript:/gi,
146
+ /data:text\/html/gi,
147
+ /data:application\/javascript/gi,
148
+ /data:text\/javascript/gi,
149
+ /data:text\/vbscript/gi,
150
+ /data:application\/x-javascript/gi,
151
+ // CSS-based attacks
152
+ /expression\s*\(/gi,
153
+ /@import/gi,
154
+ /url\s*\(/gi,
155
+ /binding\s*:/gi,
156
+ /behavior\s*:/gi,
157
+ /-moz-binding\s*:/gi,
158
+ /-o-link\s*:/gi,
159
+ /-webkit-binding\s*:/gi,
160
+ // SQL injection patterns (narrow: only time-delay/blind injection and
161
+ // SQL Server procedures — not plain English words like Create/Update/Select)
162
+ /(\b(WAITFOR\s+DELAY|SLEEP\s*\(|BENCHMARK\s*\(|DBMS_PIPE\.RECEIVE_MESSAGE)\b)/gi,
163
+ /(\b(XP_|SP_)\w+)/gi, // SQL Server extended procedures
164
+ // HTML comments (XSS vector; previously caught via the removed SQL `--` pattern)
165
+ /<!--/gi,
166
+ // Command injection patterns (more specific to avoid false positives)
167
+ // Removed the broad shell pattern to allow safe HTML tags through unchanged
168
+ /(\b(wget|curl|nc|netcat|telnet|ssh|ftp|sftp)\b)/gi,
169
+ /(rm\s+-rf|del\s+\/s|format|fdisk|mkfs)/gi,
170
+ /(>\s*\/dev\/null|2>&1|\|\|)/gi,
171
+ /(\$\([^)]*\)|`[^`]*`)/gi, // Command substitution
172
+ // Path traversal patterns
173
+ /(\.\.[/\\])/gi,
174
+ /(%2e%2e[/\\])/gi,
175
+ /(%2e%2e%2f)/gi, // URL-encoded ../
176
+ /(%2e%2e%5c)/gi, // URL-encoded ..\
177
+ /(\/etc\/passwd|\/etc\/shadow|\/proc\/)/gi,
178
+ /(c:\\\\windows\\\\system32|\\\\..\\\\)/gi,
179
+ // LDAP injection patterns
180
+ /(\*\)\([&*)]*)/gi,
181
+ /(\*\)([^)]*\*)*)/gi,
182
+ /(\|\()([^)]*)(\)\|)/gi,
183
+ /(!\()([^)]*)(\))/gi,
184
+ // NoSQL injection patterns (quoted and unquoted Mongo operator keys)
185
+ /(\$\w+\s*:)/gi, // $gt: / $where:
186
+ /("\$\w+"\s*:)/gi, // "$gt": / "$where":
187
+ /(\{\s*"?\$where"?\s*:)/gi,
188
+ /(\{\s*"?\$ne"?\s*:)/gi,
189
+ /(\{\s*"?\$gt"?\s*:)/gi,
190
+ /(\{\s*"?\$regex"?\s*:)/gi,
191
+ // HTML5 dangerous attributes
192
+ /formaction\s*=/gi,
193
+ /poster\s*=/gi,
194
+ /autofocus\s*=/gi,
195
+ /controls\s*=/gi,
196
+ /autoplay\s*=/gi,
197
+ /loop\s*=/gi,
198
+ /muted\s*=/gi,
199
+ // Unicode and encoding bypass attempts
200
+ /[\u200b-\u200f\u2060\u180e\ufeff]/g, // Zero-width and invisible characters
201
+ /[\uFE00-\uFE0F]/g, // Variation selectors
202
+ /\\u[0-9a-fA-F]{4}/g, // Unicode escapes
203
+ /\\x[0-9a-fA-F]{2}/g, // Hex escapes
204
+ // Prototype pollution patterns
205
+ /(__proto__|constructor|prototype)/gi,
206
+ // Content Security Policy violations
207
+ /(base64|atob|btoa|eval|Function|setTimeout|setInterval)\s*\(/gi,
208
+ /(document\.(write|writeln|open|close)|window\.(open|location|navigate))/gi,
209
+ // HTML-encoded dangerous content (prevent XSS through encoded vectors)
210
+ /&lt;script[^&]*&gt;/gi,
211
+ /&lt;\/script&gt;/gi,
212
+ /&lt;iframe[^&]*&gt;/gi,
213
+ /&lt;\/iframe&gt;/gi,
214
+ /&lt;object[^&]*&gt;/gi,
215
+ /&lt;svg[^&]*&gt;/gi,
216
+ /&lt;img[^&]*on[^&]*&gt;/gi,
217
+ /&lt;div[^&]*on[^&]*&gt;/gi,
218
+ /&lt;a[^&]*on[^&]*&gt;/gi,
219
+ /&lt;body[^&]*on[^&]*&gt;/gi,
220
+ /&lt;style[^&]*&gt;/gi,
221
+ /&lt;form[^&]*on[^&]*&gt;/gi,
222
+ /javascript:[^&]*/gi,
223
+ /on\w+[^&]*=/gi,
224
+ /&lt;!--.*?--&gt;/gis, // HTML-encoded comments
225
+ ];
226
+ for (const pattern of dangerousPatterns) {
227
+ // Reset regex lastIndex to avoid state issues with global flags
228
+ pattern.lastIndex = 0;
229
+ if (pattern.test(lowerValue)) {
230
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'String contains potentially dangerous content');
231
+ }
232
+ }
233
+ // Step 2: Apply comprehensive sanitization for safe content
234
+ // First, normalize Unicode to prevent bypass attacks
235
+ let normalizedValue = value.normalize('NFC');
236
+ // Remove dangerous Unicode characters that weren't caught by pattern matching
237
+ normalizedValue = normalizedValue.replace(/[\u200b-\u200f\u2060\u180e\ufeff]/g, '');
238
+ normalizedValue = normalizedValue.replace(/[\uFE00-\uFE0F]/g, '');
239
+ // Apply path traversal sanitization for file system safety
240
+ normalizedValue = normalizedValue.replace(/\.\.[/\\]/g, '...');
241
+ normalizedValue = normalizedValue.replace(/%2e%2e[/\\]/gi, '...');
242
+ normalizedValue = normalizedValue.replace(/\/etc\/passwd/gi, 'etc/passwd');
243
+ normalizedValue = normalizedValue.replace(/c:\\windows\\system32/gi, 'c:/windows/system32');
244
+ // Do not HTML-encode: callers send JSON to the Vikunja API, which stores
245
+ // strings as-is. Encoding here corrupts titles (Jun's → Jun&#x27;s) and
246
+ // Vikunja HTML descriptions (<p>…</p> → &lt;p&gt;…).
247
+ return normalizedValue;
248
+ }
249
+ /**
250
+ * Validate a field name against Zod schema
251
+ */
252
+ function validateField(field) {
253
+ if (typeof field !== 'string') {
254
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Field must be a string');
255
+ }
256
+ // Check for prototype pollution attempts first
257
+ const pollutionPatterns = ['__proto__', 'constructor', 'prototype', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__'];
258
+ if (pollutionPatterns.includes(field)) {
259
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Invalid field name: potential prototype pollution');
260
+ }
261
+ try {
262
+ const result = FieldSchema.parse(field);
263
+ return result;
264
+ }
265
+ catch (error) {
266
+ if (error instanceof zod_1.z.ZodError) {
267
+ {
268
+ const [firstIssue] = error.issues;
269
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Invalid field: ${firstIssue ? firstIssue.message : 'Unknown validation error'}`);
270
+ }
271
+ }
272
+ throw error;
273
+ }
274
+ }
275
+ /**
276
+ * Validate an operator against Zod schema
277
+ */
278
+ function validateOperator(operator) {
279
+ if (typeof operator !== 'string') {
280
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Operator must be a string');
281
+ }
282
+ try {
283
+ const result = OperatorSchema.parse(operator);
284
+ return result;
285
+ }
286
+ catch (error) {
287
+ if (error instanceof zod_1.z.ZodError) {
288
+ {
289
+ const [firstIssue] = error.issues;
290
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Invalid operator: ${firstIssue ? firstIssue.message : 'Unknown validation error'}`);
291
+ }
292
+ }
293
+ throw error;
294
+ }
295
+ }
296
+ /**
297
+ * Validate a logical operator against Zod schema
298
+ */
299
+ function validateLogicalOperator(operator) {
300
+ if (typeof operator !== 'string') {
301
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Logical operator must be a string');
302
+ }
303
+ try {
304
+ const result = LogicalOperatorSchema.parse(operator);
305
+ return result;
306
+ }
307
+ catch (error) {
308
+ if (error instanceof zod_1.z.ZodError) {
309
+ {
310
+ const [firstIssue] = error.issues;
311
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Invalid logical operator: ${firstIssue ? firstIssue.message : 'Unknown validation error'}`);
312
+ }
313
+ }
314
+ throw error;
315
+ }
316
+ }
317
+ /**
318
+ * Validate and normalize a value using custom logic (more comprehensive than Zod for this use case)
319
+ */
320
+ function validateValue(value) {
321
+ // Handle null/undefined
322
+ if (value === null || value === undefined) {
323
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Invalid value type');
324
+ }
325
+ // Handle string values
326
+ if (typeof value === 'string') {
327
+ return value;
328
+ }
329
+ // Handle boolean values
330
+ if (typeof value === 'boolean') {
331
+ return value;
332
+ }
333
+ // Handle number values with infinite/NaN checks
334
+ if (typeof value === 'number') {
335
+ if (!Number.isFinite(value)) {
336
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Numeric values must be finite, not infinite or NaN');
337
+ }
338
+ return value;
339
+ }
340
+ // Handle array values
341
+ if (Array.isArray(value)) {
342
+ if (value.length > 100) {
343
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Array values cannot exceed 100 elements');
344
+ }
345
+ if (value.length === 0) {
346
+ return [];
347
+ }
348
+ // Check array type consistency with proper type guards
349
+ const firstElementType = typeof value[0];
350
+ if (firstElementType !== 'string' && firstElementType !== 'number') {
351
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Array elements must be all strings or all finite numbers, not mixed');
352
+ }
353
+ // Validate all elements are of the same type and valid
354
+ for (let i = 0; i < value.length; i++) {
355
+ const element = value[i];
356
+ const elementType = typeof element;
357
+ // Additional safety: reject null/undefined/object elements
358
+ if (element === null || element === undefined || typeof element === 'object') {
359
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Array elements must be strings, numbers, or booleans, not objects');
360
+ }
361
+ if (elementType !== firstElementType) {
362
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Array elements must be all strings or all finite numbers, not mixed');
363
+ }
364
+ if (firstElementType === 'number') {
365
+ if (!Number.isFinite(element)) {
366
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Array numeric values must be finite, not infinite or NaN');
367
+ }
368
+ }
369
+ if (firstElementType === 'string') {
370
+ // Apply comprehensive input sanitization to all string array elements
371
+ try {
372
+ value[i] = sanitizeString(element);
373
+ }
374
+ catch (sanitizationError) {
375
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Array element ${i} contains potentially dangerous content: ${sanitizationError instanceof Error ? sanitizationError.message : 'Unknown error'}`);
376
+ }
377
+ }
378
+ }
379
+ // Type-safe return — earlier checks limit elements to string or number
380
+ if (firstElementType === 'string') {
381
+ return value;
382
+ }
383
+ return value;
384
+ }
385
+ // Reject all other types
386
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Invalid value type');
387
+ }
388
+ /**
389
+ * Schema for filter conditions
390
+ */
391
+ const ConditionSchema = zod_1.z.object({
392
+ field: FieldSchema,
393
+ operator: OperatorSchema,
394
+ value: zod_1.z.union([
395
+ zod_1.z.string(),
396
+ zod_1.z.number(),
397
+ zod_1.z.boolean(),
398
+ zod_1.z.array(zod_1.z.string()),
399
+ zod_1.z.array(zod_1.z.number()),
400
+ zod_1.z.null()
401
+ ]),
402
+ });
403
+ /**
404
+ * Validate a filter condition object using Zod schema
405
+ */
406
+ function validateCondition(condition) {
407
+ try {
408
+ const result = ConditionSchema.parse(condition);
409
+ return result;
410
+ }
411
+ catch (error) {
412
+ if (error instanceof zod_1.z.ZodError) {
413
+ {
414
+ const [firstIssue] = error.issues;
415
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Invalid condition: ${firstIssue ? firstIssue.message : 'Condition validation failed'}`);
416
+ }
417
+ }
418
+ throw error;
419
+ }
420
+ }
421
+ /**
422
+ * Zod schema for filter groups
423
+ */
424
+ const FilterGroupSchema = zod_1.z.object({
425
+ operator: LogicalOperatorSchema,
426
+ conditions: zod_1.z.array(ConditionSchema).min(1).max(MAX_CONDITIONS)
427
+ });
428
+ /**
429
+ * Zod schema for filter expressions
430
+ */
431
+ const FilterExpressionSchema = zod_1.z.object({
432
+ groups: zod_1.z.array(FilterGroupSchema).min(1).max(MAX_NESTING_DEPTH),
433
+ operator: LogicalOperatorSchema.optional()
434
+ }).refine((expr) => {
435
+ // Check total conditions across all groups
436
+ const totalConditions = expr.groups.reduce((sum, group) => sum + group.conditions.length, 0);
437
+ return totalConditions <= MAX_CONDITIONS;
438
+ }, {
439
+ message: `Filter expression cannot exceed ${MAX_CONDITIONS} total conditions`
440
+ });
441
+ /**
442
+ * Validate a filter expression using Zod schema with comprehensive type safety
443
+ */
444
+ function validateFilterExpression(expression) {
445
+ try {
446
+ // Use Zod for comprehensive type-safe validation
447
+ const result = FilterExpressionSchema.parse(expression);
448
+ // Validate each condition individually for additional safety
449
+ for (let i = 0; i < result.groups.length; i++) {
450
+ const group = result.groups[i];
451
+ if (!group) {
452
+ continue;
453
+ }
454
+ validateLogicalOperator(group.operator);
455
+ for (let j = 0; j < group.conditions.length; j++) {
456
+ validateCondition(group.conditions[j]);
457
+ }
458
+ }
459
+ // Type-safe return - Zod has validated the structure
460
+ return result;
461
+ }
462
+ catch (error) {
463
+ if (error instanceof zod_1.z.ZodError) {
464
+ // Check for specific Zod errors and provide better error messages
465
+ const firstIssue = error.issues[0];
466
+ if (firstIssue) {
467
+ // Handle empty groups array
468
+ if (firstIssue.code === 'too_small' && firstIssue.path.length > 0 && firstIssue.path[firstIssue.path.length - 1] === 'groups') {
469
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Filter expression must have at least one group');
470
+ }
471
+ // Handle exceed maximum nesting depth or array size
472
+ if (firstIssue.code === 'too_big') {
473
+ if (firstIssue.message.includes('Array must contain at most 10 element(s)')) {
474
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Filter expression exceeds maximum nesting depth of 10');
475
+ }
476
+ if (firstIssue.message.includes('conditions') || firstIssue.message.includes('50') || firstIssue.message.includes('Array must contain at most 50')) {
477
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Filter expression cannot exceed 50 total conditions');
478
+ }
479
+ // Generic too_big error for filter expressions
480
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Filter expression exceeds maximum nesting depth of 10');
481
+ }
482
+ // Handle "Required" errors which might indicate missing required fields in deeply nested structures
483
+ if (firstIssue.code === 'invalid_type' && firstIssue.message === 'Required') {
484
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Filter expression exceeds maximum nesting depth of 10');
485
+ }
486
+ // Check if any issue mentions conditions or 50
487
+ if (error.issues.some(issue => issue.message.includes('conditions') ||
488
+ issue.message.includes('50') ||
489
+ issue.message.includes('Array must contain at most 50'))) {
490
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'Filter expression cannot exceed 50 total conditions');
491
+ }
492
+ }
493
+ const errorDetails = error.issues.map(issue => issue.message).join('; ');
494
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Invalid filter expression: ${errorDetails}`);
495
+ }
496
+ if (error instanceof errors_1.MCPError) {
497
+ throw error; // Re-throw MCPError as-is
498
+ }
499
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Filter expression validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
500
+ }
501
+ }
502
+ /**
503
+ * Safely stringify JSON with comprehensive protection
504
+ * Prevents prototype pollution and sanitizes string values
505
+ */
506
+ function safeJsonStringify(obj) {
507
+ try {
508
+ // Validate the object structure first - this will throw for invalid structures
509
+ const validated = validateFilterExpression(obj);
510
+ // Create a safe copy to prevent prototype pollution
511
+ const safeObj = createSafeObjectCopy(validated);
512
+ // Recursively sanitize string values in the object (but not operators)
513
+ const sanitizedObj = sanitizeObjectStrings(safeObj);
514
+ const jsonString = JSON.stringify(sanitizedObj);
515
+ return jsonString; // No need to sanitize the JSON string itself since we sanitized values
516
+ }
517
+ catch (error) {
518
+ if (error instanceof errors_1.MCPError) {
519
+ throw error; // Re-throw MCPError as-is
520
+ }
521
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Failed to stringify object: ${error instanceof Error ? error.message : 'Unknown error'}`);
522
+ }
523
+ }
524
+ /**
525
+ * Safely parse JSON with comprehensive protection
526
+ * Prevents prototype pollution and validates against dangerous content
527
+ */
528
+ function safeJsonParse(jsonString) {
529
+ if (typeof jsonString !== 'string') {
530
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'JSON string must be a string');
531
+ }
532
+ // Check for maximum length
533
+ if (jsonString.length > 50000) {
534
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'JSON string exceeds maximum length');
535
+ }
536
+ // Check for prototype pollution patterns before parsing
537
+ if (containsPrototypePollution(jsonString)) {
538
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, 'JSON contains potentially dangerous prototype pollution patterns');
539
+ }
540
+ try {
541
+ const parsed = JSON.parse(jsonString);
542
+ // Create a safe copy to prevent prototype pollution attacks
543
+ const safeObj = createSafeObjectCopy(parsed);
544
+ // Validate and sanitize the parsed object
545
+ return validateFilterExpression(safeObj);
546
+ }
547
+ catch (error) {
548
+ if (error instanceof SyntaxError) {
549
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Invalid JSON: ${error.message}`);
550
+ }
551
+ if (error instanceof errors_1.MCPError) {
552
+ throw error; // Re-throw our validation errors
553
+ }
554
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `Failed to parse JSON: ${error instanceof Error ? error.message : 'Unknown error'}`);
555
+ }
556
+ }
557
+ /**
558
+ * Validate ID parameters
559
+ */
560
+ function validateId(id, fieldName) {
561
+ if (typeof id !== 'number' || !Number.isInteger(id) || id <= 0) {
562
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `${fieldName} must be a positive integer`);
563
+ }
564
+ }
565
+ /**
566
+ * Validate and convert ID from various formats
567
+ */
568
+ function validateAndConvertId(id, fieldName) {
569
+ // Handle booleans - true converts to 1, false is rejected
570
+ if (typeof id === 'boolean') {
571
+ if (id === true) {
572
+ return 1;
573
+ }
574
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `${fieldName} must be a positive integer`);
575
+ }
576
+ if (typeof id === 'string') {
577
+ // Use Number() instead of parseInt for better conversion handling
578
+ // This handles hex strings like '0x42', exponential like '1e5', etc.
579
+ const parsed = Number(id);
580
+ if (!Number.isFinite(parsed) || !Number.isInteger(parsed) || parsed <= 0) {
581
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `${fieldName} must be a positive integer`);
582
+ }
583
+ return parsed;
584
+ }
585
+ if (typeof id === 'number') {
586
+ validateId(id, fieldName);
587
+ return id;
588
+ }
589
+ throw new errors_1.MCPError(errors_1.ErrorCode.VALIDATION_ERROR, `${fieldName} must be a number or positive integer string`);
590
+ }
591
+ /**
592
+ * Helper functions for comprehensive input sanitization
593
+ */
594
+ /**
595
+ * Checks for prototype pollution patterns in JSON strings
596
+ */
597
+ function containsPrototypePollution(jsonString) {
598
+ const lowerJson = jsonString.toLowerCase();
599
+ // Check for dangerous prototype pollution patterns
600
+ const pollutionPatterns = [
601
+ '__proto__',
602
+ 'constructor',
603
+ 'prototype',
604
+ '"__proto__":',
605
+ '"constructor":',
606
+ '"prototype":',
607
+ '"__proto__":',
608
+ '{"__proto__"',
609
+ 'constructor.prototype',
610
+ '__defineGetter__',
611
+ '__defineSetter__',
612
+ '__lookupGetter__',
613
+ '__lookupSetter__'
614
+ ];
615
+ return pollutionPatterns.some(pattern => lowerJson.includes(pattern));
616
+ }
617
+ /**
618
+ * Creates a deep copy of an object while preventing prototype pollution
619
+ */
620
+ function createSafeObjectCopy(obj, visited = new WeakSet()) {
621
+ // Handle null and primitive types
622
+ if (obj === null || typeof obj !== 'object') {
623
+ return obj;
624
+ }
625
+ // Prevent circular reference issues
626
+ if (visited.has(obj)) {
627
+ return null;
628
+ }
629
+ visited.add(obj);
630
+ // Handle arrays
631
+ if (Array.isArray(obj)) {
632
+ return obj.map(item => createSafeObjectCopy(item, visited));
633
+ }
634
+ // Handle Date objects
635
+ if (obj instanceof Date) {
636
+ return new Date(obj.getTime());
637
+ }
638
+ // Handle objects - create safe copy without prototype chain
639
+ const safeObj = {};
640
+ for (const key in obj) {
641
+ // Skip dangerous prototype properties
642
+ if (isSafeProperty(key)) {
643
+ try {
644
+ const value = obj[key];
645
+ safeObj[key] = createSafeObjectCopy(value, visited);
646
+ }
647
+ catch {
648
+ // Skip properties that cause errors during copying
649
+ continue;
650
+ }
651
+ }
652
+ }
653
+ return safeObj;
654
+ }
655
+ /**
656
+ * Checks if a property key is safe (not dangerous for prototype pollution)
657
+ */
658
+ function isSafeProperty(key) {
659
+ const dangerousKeys = [
660
+ '__proto__',
661
+ 'constructor',
662
+ 'prototype',
663
+ '__defineGetter__',
664
+ '__defineSetter__',
665
+ '__lookupGetter__',
666
+ '__lookupSetter__',
667
+ 'hasOwnProperty',
668
+ 'isPrototypeOf',
669
+ 'propertyIsEnumerable',
670
+ 'toLocaleString',
671
+ 'toString',
672
+ 'valueOf'
673
+ ];
674
+ return !dangerousKeys.includes(key) && typeof key === 'string';
675
+ }
676
+ /**
677
+ * Recursively sanitizes all string values in an object
678
+ * Skips known operator values to avoid HTML entity encoding
679
+ */
680
+ function sanitizeObjectStrings(obj, visited = new WeakSet(), key = null) {
681
+ // Handle null and primitive types
682
+ if (obj === null || typeof obj !== 'object') {
683
+ if (typeof obj === 'string') {
684
+ // Don't sanitize known operator values
685
+ const knownOperators = ['=', '!=', '>', '>=', '<', '<=', 'like', 'in', 'not in', '&&', '||'];
686
+ if (knownOperators.includes(obj)) {
687
+ return obj;
688
+ }
689
+ return sanitizeString(obj);
690
+ }
691
+ return obj;
692
+ }
693
+ // Prevent circular reference issues
694
+ if (visited.has(obj)) {
695
+ return null;
696
+ }
697
+ visited.add(obj);
698
+ // Handle arrays
699
+ if (Array.isArray(obj)) {
700
+ return obj.map(item => sanitizeObjectStrings(item, visited, key));
701
+ }
702
+ // Handle Date objects (don't modify)
703
+ if (obj instanceof Date) {
704
+ return obj;
705
+ }
706
+ // Handle objects
707
+ const sanitizedObj = {};
708
+ for (const key in obj) {
709
+ if (isSafeProperty(key)) {
710
+ try {
711
+ const value = obj[key];
712
+ sanitizedObj[key] = sanitizeObjectStrings(value, visited, key);
713
+ }
714
+ catch {
715
+ // Skip properties that cause errors during sanitization
716
+ continue;
717
+ }
718
+ }
719
+ }
720
+ return sanitizedObj;
721
+ }
722
+ /** Test-only exports for deep-copy / sanitize helpers */
723
+ exports.validationInternals = {
724
+ createSafeObjectCopy,
725
+ sanitizeObjectStrings,
726
+ isSafeProperty,
727
+ containsPrototypePollution,
728
+ };
729
+ //# sourceMappingURL=validation.js.map