qa360 2.3.0 → 2.3.2

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 (507) hide show
  1. package/README.md +155 -262
  2. package/{cli/dist → dist}/commands/ai.js +1 -1
  3. package/{cli/dist → dist}/commands/ask.js +49 -22
  4. package/{cli/dist → dist}/commands/coverage.js +17 -4
  5. package/{cli/dist → dist}/commands/crawl.js +2 -2
  6. package/{cli/dist → dist}/commands/doctor.js +2 -2
  7. package/{cli/dist → dist}/commands/explain.js +2 -2
  8. package/{cli/dist → dist}/commands/flakiness.js +1 -1
  9. package/{cli/dist → dist}/commands/generate.js +12 -5
  10. package/{cli/dist → dist}/commands/history.js +1 -1
  11. package/{cli/dist → dist}/commands/monitor.js +3 -3
  12. package/{cli/dist → dist}/commands/ollama.js +14 -6
  13. package/{cli/dist → dist}/commands/pack.js +2 -2
  14. package/{cli/dist → dist}/commands/regression.js +1 -1
  15. package/{cli/dist → dist}/commands/repair.js +1 -1
  16. package/{cli/dist → dist}/commands/retry.js +1 -1
  17. package/{cli/dist → dist}/commands/run.d.ts +5 -1
  18. package/{cli/dist → dist}/commands/run.js +87 -1
  19. package/{cli/dist → dist}/commands/secrets.js +1 -1
  20. package/{cli/dist → dist}/commands/serve.js +1 -1
  21. package/{cli/dist → dist}/commands/slo.js +1 -1
  22. package/{cli/dist → dist}/commands/verify.js +1 -1
  23. package/{cli/dist → dist}/core/adapters/playwright-native-api.d.ts +2 -0
  24. package/{cli/dist → dist}/core/adapters/playwright-native-api.js +20 -1
  25. package/{cli/dist → dist}/core/adapters/playwright-ui.d.ts +21 -0
  26. package/dist/core/adapters/playwright-ui.js +2050 -0
  27. package/{cli/dist → dist}/core/ai/ollama-provider.d.ts +4 -0
  28. package/{cli/dist → dist}/core/ai/ollama-provider.js +41 -8
  29. package/{cli/dist → dist}/core/artifacts/ui-artifacts.js +24 -4
  30. package/dist/core/auth/backup-codes-provider.d.ts +91 -0
  31. package/dist/core/auth/backup-codes-provider.js +215 -0
  32. package/{cli/dist → dist}/core/auth/basic-auth-provider.d.ts +6 -0
  33. package/{cli/dist → dist}/core/auth/basic-auth-provider.js +24 -6
  34. package/dist/core/auth/digest-auth-provider.d.ts +116 -0
  35. package/dist/core/auth/digest-auth-provider.js +244 -0
  36. package/dist/core/auth/hcaptcha-handler.d.ts +103 -0
  37. package/dist/core/auth/hcaptcha-handler.js +288 -0
  38. package/{cli/dist → dist}/core/auth/index.d.ts +81 -4
  39. package/{cli/dist → dist}/core/auth/index.js +15 -1
  40. package/dist/core/auth/oauth-handler.d.ts +408 -0
  41. package/dist/core/auth/oauth-handler.js +636 -0
  42. package/{cli/dist → dist}/core/auth/oauth2-provider.d.ts +9 -0
  43. package/dist/core/auth/oauth2-provider.js +227 -0
  44. package/dist/core/auth/otp-provider.d.ts +93 -0
  45. package/dist/core/auth/otp-provider.js +288 -0
  46. package/dist/core/auth/recaptcha-handler.d.ts +119 -0
  47. package/dist/core/auth/recaptcha-handler.js +301 -0
  48. package/dist/core/auth/remember-me-handler.d.ts +142 -0
  49. package/dist/core/auth/remember-me-handler.js +255 -0
  50. package/dist/core/auth/saml-handler.d.ts +173 -0
  51. package/dist/core/auth/saml-handler.js +364 -0
  52. package/dist/core/auth/webauthn-handler.d.ts +182 -0
  53. package/dist/core/auth/webauthn-handler.js +310 -0
  54. package/dist/core/crawler/advanced-interactions.d.ts +342 -0
  55. package/dist/core/crawler/advanced-interactions.js +1069 -0
  56. package/dist/core/crawler/blob-url-download-handler.d.ts +145 -0
  57. package/dist/core/crawler/blob-url-download-handler.js +392 -0
  58. package/dist/core/crawler/consent-handler.d.ts +49 -0
  59. package/dist/core/crawler/consent-handler.js +258 -0
  60. package/dist/core/crawler/cookie-manager.d.ts +166 -0
  61. package/dist/core/crawler/cookie-manager.js +353 -0
  62. package/dist/core/crawler/coop-coep-handler.d.ts +136 -0
  63. package/dist/core/crawler/coop-coep-handler.js +338 -0
  64. package/dist/core/crawler/csp-handler.d.ts +151 -0
  65. package/dist/core/crawler/csp-handler.js +415 -0
  66. package/dist/core/crawler/download-handler.d.ts +155 -0
  67. package/dist/core/crawler/download-handler.js +370 -0
  68. package/dist/core/crawler/email-testing-handler.d.ts +214 -0
  69. package/dist/core/crawler/email-testing-handler.js +398 -0
  70. package/dist/core/crawler/error-tracking-handler.d.ts +177 -0
  71. package/dist/core/crawler/error-tracking-handler.js +378 -0
  72. package/dist/core/crawler/form-handler.d.ts +100 -0
  73. package/dist/core/crawler/form-handler.js +465 -0
  74. package/dist/core/crawler/framework-wait-handler.d.ts +96 -0
  75. package/dist/core/crawler/framework-wait-handler.js +464 -0
  76. package/dist/core/crawler/geolocation-handler.d.ts +112 -0
  77. package/dist/core/crawler/geolocation-handler.js +276 -0
  78. package/dist/core/crawler/index.d.ts +78 -0
  79. package/{cli/dist → dist}/core/crawler/index.js +74 -1
  80. package/dist/core/crawler/intelligent-selector-generator.d.ts +164 -0
  81. package/dist/core/crawler/intelligent-selector-generator.js +612 -0
  82. package/{cli/dist → dist}/core/crawler/journey-generator.js +44 -1
  83. package/{cli/dist → dist}/core/crawler/page-analyzer.d.ts +16 -1
  84. package/{cli/dist → dist}/core/crawler/page-analyzer.js +469 -17
  85. package/dist/core/crawler/permissions-handler.d.ts +112 -0
  86. package/dist/core/crawler/permissions-handler.js +236 -0
  87. package/dist/core/crawler/permissions-policy-handler.d.ts +113 -0
  88. package/dist/core/crawler/permissions-policy-handler.js +402 -0
  89. package/dist/core/crawler/presets.d.ts +100 -0
  90. package/dist/core/crawler/presets.js +887 -0
  91. package/dist/core/crawler/repl-debug-handler.d.ts +105 -0
  92. package/dist/core/crawler/repl-debug-handler.js +552 -0
  93. package/dist/core/crawler/reporting-api-handler.d.ts +212 -0
  94. package/dist/core/crawler/reporting-api-handler.js +344 -0
  95. package/{cli/dist → dist}/core/crawler/selector-generator.d.ts +9 -0
  96. package/{cli/dist → dist}/core/crawler/selector-generator.js +99 -23
  97. package/dist/core/crawler/site-profiler.d.ts +89 -0
  98. package/dist/core/crawler/site-profiler.js +290 -0
  99. package/dist/core/crawler/sourcemaps-handler.d.ts +144 -0
  100. package/dist/core/crawler/sourcemaps-handler.js +420 -0
  101. package/dist/core/crawler/stacked-modals-handler.d.ts +118 -0
  102. package/dist/core/crawler/stacked-modals-handler.js +429 -0
  103. package/dist/core/crawler/trusted-types-handler.d.ts +149 -0
  104. package/dist/core/crawler/trusted-types-handler.js +413 -0
  105. package/{cli/dist → dist}/core/crawler/types.d.ts +68 -2
  106. package/dist/core/crawler/wait-strategies.d.ts +108 -0
  107. package/dist/core/crawler/wait-strategies.js +399 -0
  108. package/dist/core/fixtures/factories.d.ts +180 -0
  109. package/dist/core/fixtures/factories.js +279 -0
  110. package/dist/core/fixtures/index.d.ts +6 -0
  111. package/dist/core/fixtures/index.js +6 -0
  112. package/{cli/dist → dist}/core/generation/crawler-pack-generator.d.ts +13 -3
  113. package/dist/core/generation/crawler-pack-generator.js +232 -0
  114. package/{cli/dist → dist}/core/generation/index.d.ts +2 -0
  115. package/{cli/dist → dist}/core/generation/index.js +2 -0
  116. package/{cli/dist → dist}/core/index.d.ts +2 -0
  117. package/{cli/dist → dist}/core/index.js +4 -0
  118. package/dist/core/network/index.d.ts +7 -0
  119. package/dist/core/network/index.js +7 -0
  120. package/dist/core/network/network-manager.d.ts +237 -0
  121. package/dist/core/network/network-manager.js +343 -0
  122. package/dist/core/network/network-simulator.d.ts +158 -0
  123. package/dist/core/network/network-simulator.js +261 -0
  124. package/{cli/dist → dist}/core/pack/validator.js +2 -2
  125. package/{cli/dist → dist}/core/pack-v2/migrator.d.ts +5 -0
  126. package/{cli/dist → dist}/core/pack-v2/migrator.js +81 -6
  127. package/{cli/dist → dist}/core/pack-v2/validator.js +4 -3
  128. package/{cli/dist → dist}/core/pom/base-page.js +1 -1
  129. package/{cli/dist → dist}/core/pom/loader.js +1 -1
  130. package/dist/core/reporting/index.d.ts +9 -0
  131. package/dist/core/reporting/index.js +10 -0
  132. package/dist/core/reporting/junit-reporter.d.ts +114 -0
  133. package/dist/core/reporting/junit-reporter.js +306 -0
  134. package/{cli/dist → dist}/core/runner/e2e-helpers.d.ts +1 -1
  135. package/{cli/dist → dist}/core/runner/e2e-helpers.js +2 -2
  136. package/{cli/dist → dist}/core/runner/phase3-runner.d.ts +3 -0
  137. package/{cli/dist → dist}/core/runner/phase3-runner.js +45 -14
  138. package/dist/core/sharding/test-sharding.d.ts +137 -0
  139. package/dist/core/sharding/test-sharding.js +233 -0
  140. package/dist/core/storage/cookie-manager.d.ts +160 -0
  141. package/dist/core/storage/cookie-manager.js +268 -0
  142. package/dist/core/storage/index.d.ts +7 -0
  143. package/dist/core/storage/index.js +7 -0
  144. package/dist/core/storage/storage-helpers.d.ts +138 -0
  145. package/dist/core/storage/storage-helpers.js +315 -0
  146. package/dist/core/test-helpers/index.d.ts +6 -0
  147. package/dist/core/test-helpers/index.js +6 -0
  148. package/dist/core/test-helpers/state-reset.d.ts +119 -0
  149. package/dist/core/test-helpers/state-reset.js +234 -0
  150. package/{cli/dist → dist}/core/types/pack-v1.d.ts +15 -2
  151. package/{cli/dist → dist}/core/types/pack-v2.d.ts +1 -1
  152. package/dist/core/upload/chunked-uploader.d.ts +150 -0
  153. package/dist/core/upload/chunked-uploader.js +289 -0
  154. package/dist/core/upload/index.d.ts +11 -0
  155. package/dist/core/upload/index.js +8 -0
  156. package/dist/core/upload/mime-validator.d.ts +119 -0
  157. package/dist/core/upload/mime-validator.js +373 -0
  158. package/dist/core/upload/presigned-uploader.d.ts +118 -0
  159. package/dist/core/upload/presigned-uploader.js +274 -0
  160. package/dist/core/utils/device-emulation.d.ts +194 -0
  161. package/dist/core/utils/device-emulation.js +380 -0
  162. package/dist/core/utils/index.d.ts +8 -0
  163. package/dist/core/utils/index.js +8 -0
  164. package/dist/core/utils/retry.d.ts +145 -0
  165. package/dist/core/utils/retry.js +242 -0
  166. package/dist/core/utils/smart-wait.d.ts +133 -0
  167. package/dist/core/utils/smart-wait.js +417 -0
  168. package/dist/core/visual/index.d.ts +7 -0
  169. package/dist/core/visual/index.js +7 -0
  170. package/dist/core/visual/pixel-diff.d.ts +87 -0
  171. package/dist/core/visual/pixel-diff.js +213 -0
  172. package/dist/core/visual/screenshot-helper.d.ts +130 -0
  173. package/dist/core/visual/screenshot-helper.js +223 -0
  174. package/{cli/dist → dist}/index.js +2 -3
  175. package/{cli/dist → dist}/utils/config.d.ts +1 -1
  176. package/{cli/dist → dist}/utils/config.js +36 -3
  177. package/examples/README.md +160 -0
  178. package/examples/accessibility.yml +48 -0
  179. package/examples/api-basic.yml +27 -0
  180. package/examples/complete.yml +146 -0
  181. package/examples/crawler.yml +38 -0
  182. package/examples/fullstack.yml +78 -0
  183. package/examples/security.yml +58 -0
  184. package/examples/ui-advanced.yml +49 -0
  185. package/examples/ui-basic.yml +24 -0
  186. package/package.json +33 -67
  187. package/CHANGELOG.md +0 -330
  188. package/CONTRIBUTING.md +0 -273
  189. package/QUICK_START.md +0 -191
  190. package/cli/CHANGELOG.md +0 -84
  191. package/cli/LICENSE +0 -24
  192. package/cli/README.md +0 -222
  193. package/cli/dist/core/adapters/playwright-ui.js +0 -864
  194. package/cli/dist/core/auth/oauth2-provider.js +0 -114
  195. package/cli/dist/core/coverage/analyzer.d.ts +0 -101
  196. package/cli/dist/core/coverage/analyzer.js +0 -415
  197. package/cli/dist/core/coverage/collector.d.ts +0 -74
  198. package/cli/dist/core/coverage/collector.js +0 -459
  199. package/cli/dist/core/coverage/config.d.ts +0 -37
  200. package/cli/dist/core/coverage/config.js +0 -156
  201. package/cli/dist/core/coverage/index.d.ts +0 -11
  202. package/cli/dist/core/coverage/index.js +0 -15
  203. package/cli/dist/core/coverage/types.d.ts +0 -267
  204. package/cli/dist/core/coverage/types.js +0 -6
  205. package/cli/dist/core/coverage/vault.d.ts +0 -95
  206. package/cli/dist/core/coverage/vault.js +0 -405
  207. package/cli/dist/core/crawler/index.d.ts +0 -57
  208. package/cli/dist/core/fixtures/index.d.ts +0 -8
  209. package/cli/dist/core/fixtures/index.js +0 -8
  210. package/cli/dist/core/generation/crawler-pack-generator.js +0 -231
  211. package/cli/dist/core/reporting/index.d.ts +0 -6
  212. package/cli/dist/core/reporting/index.js +0 -6
  213. package/cli/dist/core/visual/index.d.ts +0 -6
  214. package/cli/dist/core/visual/index.js +0 -6
  215. package/cli/package.json +0 -76
  216. package/core/LICENSE +0 -24
  217. package/core/README.md +0 -105
  218. package/core/package.json +0 -90
  219. package/core/schemas/pack.schema.json +0 -236
  220. /package/{cli/bin → bin}/qa360.js +0 -0
  221. /package/{cli/dist → dist}/cli-minimal.d.ts +0 -0
  222. /package/{cli/dist → dist}/cli-minimal.js +0 -0
  223. /package/{cli/dist → dist}/commands/ai.d.ts +0 -0
  224. /package/{cli/dist → dist}/commands/ask.d.ts +0 -0
  225. /package/{cli/dist → dist}/commands/coverage.d.ts +0 -0
  226. /package/{cli/dist → dist}/commands/crawl.d.ts +0 -0
  227. /package/{cli/dist → dist}/commands/doctor.d.ts +0 -0
  228. /package/{cli/dist → dist}/commands/examples.d.ts +0 -0
  229. /package/{cli/dist → dist}/commands/examples.js +0 -0
  230. /package/{cli/dist → dist}/commands/explain.d.ts +0 -0
  231. /package/{cli/dist → dist}/commands/flakiness.d.ts +0 -0
  232. /package/{cli/dist → dist}/commands/generate.d.ts +0 -0
  233. /package/{cli/dist → dist}/commands/history.d.ts +0 -0
  234. /package/{cli/dist → dist}/commands/init.d.ts +0 -0
  235. /package/{cli/dist → dist}/commands/init.js +0 -0
  236. /package/{cli/dist → dist}/commands/monitor.d.ts +0 -0
  237. /package/{cli/dist → dist}/commands/ollama.d.ts +0 -0
  238. /package/{cli/dist → dist}/commands/pack.d.ts +0 -0
  239. /package/{cli/dist → dist}/commands/regression.d.ts +0 -0
  240. /package/{cli/dist → dist}/commands/repair.d.ts +0 -0
  241. /package/{cli/dist → dist}/commands/report.d.ts +0 -0
  242. /package/{cli/dist → dist}/commands/report.js +0 -0
  243. /package/{cli/dist → dist}/commands/retry.d.ts +0 -0
  244. /package/{cli/dist → dist}/commands/scan.d.ts +0 -0
  245. /package/{cli/dist → dist}/commands/scan.js +0 -0
  246. /package/{cli/dist → dist}/commands/secrets.d.ts +0 -0
  247. /package/{cli/dist → dist}/commands/serve.d.ts +0 -0
  248. /package/{cli/dist → dist}/commands/slo.d.ts +0 -0
  249. /package/{cli/dist → dist}/commands/verify.d.ts +0 -0
  250. /package/{cli/dist → dist}/core/adapters/gitleaks-secrets.d.ts +0 -0
  251. /package/{cli/dist → dist}/core/adapters/gitleaks-secrets.js +0 -0
  252. /package/{cli/dist → dist}/core/adapters/jest-adapter.d.ts +0 -0
  253. /package/{cli/dist → dist}/core/adapters/jest-adapter.js +0 -0
  254. /package/{cli/dist → dist}/core/adapters/k6-perf.d.ts +0 -0
  255. /package/{cli/dist → dist}/core/adapters/k6-perf.js +0 -0
  256. /package/{cli/dist → dist}/core/adapters/osv-deps.d.ts +0 -0
  257. /package/{cli/dist → dist}/core/adapters/osv-deps.js +0 -0
  258. /package/{cli/dist → dist}/core/adapters/playwright-native-adapter.d.ts +0 -0
  259. /package/{cli/dist → dist}/core/adapters/playwright-native-adapter.js +0 -0
  260. /package/{cli/dist → dist}/core/adapters/pytest-adapter.d.ts +0 -0
  261. /package/{cli/dist → dist}/core/adapters/pytest-adapter.js +0 -0
  262. /package/{cli/dist → dist}/core/adapters/semgrep-sast.d.ts +0 -0
  263. /package/{cli/dist → dist}/core/adapters/semgrep-sast.js +0 -0
  264. /package/{cli/dist → dist}/core/adapters/unit-test-types.d.ts +0 -0
  265. /package/{cli/dist → dist}/core/adapters/unit-test-types.js +0 -0
  266. /package/{cli/dist → dist}/core/adapters/vitest-adapter.d.ts +0 -0
  267. /package/{cli/dist → dist}/core/adapters/vitest-adapter.js +0 -0
  268. /package/{cli/dist → dist}/core/adapters/zap-dast.d.ts +0 -0
  269. /package/{cli/dist → dist}/core/adapters/zap-dast.js +0 -0
  270. /package/{cli/dist → dist}/core/ai/anthropic-provider.d.ts +0 -0
  271. /package/{cli/dist → dist}/core/ai/anthropic-provider.js +0 -0
  272. /package/{cli/dist → dist}/core/ai/deepseek-provider.d.ts +0 -0
  273. /package/{cli/dist → dist}/core/ai/deepseek-provider.js +0 -0
  274. /package/{cli/dist → dist}/core/ai/index.d.ts +0 -0
  275. /package/{cli/dist → dist}/core/ai/index.js +0 -0
  276. /package/{cli/dist → dist}/core/ai/llm-client.d.ts +0 -0
  277. /package/{cli/dist → dist}/core/ai/llm-client.js +0 -0
  278. /package/{cli/dist → dist}/core/ai/mock-provider.d.ts +0 -0
  279. /package/{cli/dist → dist}/core/ai/mock-provider.js +0 -0
  280. /package/{cli/dist → dist}/core/ai/openai-provider.d.ts +0 -0
  281. /package/{cli/dist → dist}/core/ai/openai-provider.js +0 -0
  282. /package/{cli/dist → dist}/core/ai/provider-factory.d.ts +0 -0
  283. /package/{cli/dist → dist}/core/ai/provider-factory.js +0 -0
  284. /package/{cli/dist → dist}/core/artifacts/index.d.ts +0 -0
  285. /package/{cli/dist → dist}/core/artifacts/index.js +0 -0
  286. /package/{cli/dist → dist}/core/artifacts/ui-artifacts.d.ts +0 -0
  287. /package/{cli/dist → dist}/core/assertions/engine.d.ts +0 -0
  288. /package/{cli/dist → dist}/core/assertions/engine.js +0 -0
  289. /package/{cli/dist → dist}/core/assertions/index.d.ts +0 -0
  290. /package/{cli/dist → dist}/core/assertions/index.js +0 -0
  291. /package/{cli/dist → dist}/core/assertions/types.d.ts +0 -0
  292. /package/{cli/dist → dist}/core/assertions/types.js +0 -0
  293. /package/{cli/dist → dist}/core/auth/api-key-provider.d.ts +0 -0
  294. /package/{cli/dist → dist}/core/auth/api-key-provider.js +0 -0
  295. /package/{cli/dist → dist}/core/auth/aws-iam-provider.d.ts +0 -0
  296. /package/{cli/dist → dist}/core/auth/aws-iam-provider.js +0 -0
  297. /package/{cli/dist → dist}/core/auth/azure-ad-provider.d.ts +0 -0
  298. /package/{cli/dist → dist}/core/auth/azure-ad-provider.js +0 -0
  299. /package/{cli/dist → dist}/core/auth/gcp-adc-provider.d.ts +0 -0
  300. /package/{cli/dist → dist}/core/auth/gcp-adc-provider.js +0 -0
  301. /package/{cli/dist → dist}/core/auth/jwt-provider.d.ts +0 -0
  302. /package/{cli/dist → dist}/core/auth/jwt-provider.js +0 -0
  303. /package/{cli/dist → dist}/core/auth/manager.d.ts +0 -0
  304. /package/{cli/dist → dist}/core/auth/manager.js +0 -0
  305. /package/{cli/dist → dist}/core/auth/totp-provider.d.ts +0 -0
  306. /package/{cli/dist → dist}/core/auth/totp-provider.js +0 -0
  307. /package/{cli/dist → dist}/core/auth/ui-login-provider.d.ts +0 -0
  308. /package/{cli/dist → dist}/core/auth/ui-login-provider.js +0 -0
  309. /package/{cli/dist → dist}/core/cache/index.d.ts +0 -0
  310. /package/{cli/dist → dist}/core/cache/index.js +0 -0
  311. /package/{cli/dist → dist}/core/cache/lru-cache.d.ts +0 -0
  312. /package/{cli/dist → dist}/core/cache/lru-cache.js +0 -0
  313. /package/{cli/dist/core → dist}/core/coverage/analyzer.d.ts +0 -0
  314. /package/{cli/dist/core → dist}/core/coverage/analyzer.js +0 -0
  315. /package/{cli/dist/core → dist}/core/coverage/collector.d.ts +0 -0
  316. /package/{cli/dist/core → dist}/core/coverage/collector.js +0 -0
  317. /package/{cli/dist/core → dist}/core/coverage/config.d.ts +0 -0
  318. /package/{cli/dist/core → dist}/core/coverage/config.js +0 -0
  319. /package/{cli/dist/core → dist}/core/coverage/index.d.ts +0 -0
  320. /package/{cli/dist/core → dist}/core/coverage/index.js +0 -0
  321. /package/{cli/dist/core → dist}/core/coverage/types.d.ts +0 -0
  322. /package/{cli/dist/core → dist}/core/coverage/types.js +0 -0
  323. /package/{cli/dist/core → dist}/core/coverage/vault.d.ts +0 -0
  324. /package/{cli/dist/core → dist}/core/coverage/vault.js +0 -0
  325. /package/{cli/dist → dist}/core/crawler/journey-generator.d.ts +0 -0
  326. /package/{cli/dist → dist}/core/crawler/types.js +0 -0
  327. /package/{cli/dist → dist}/core/dashboard/assets.d.ts +0 -0
  328. /package/{cli/dist → dist}/core/dashboard/assets.js +0 -0
  329. /package/{cli/dist → dist}/core/dashboard/index.d.ts +0 -0
  330. /package/{cli/dist → dist}/core/dashboard/index.js +0 -0
  331. /package/{cli/dist → dist}/core/dashboard/server.d.ts +0 -0
  332. /package/{cli/dist → dist}/core/dashboard/server.js +0 -0
  333. /package/{cli/dist → dist}/core/dashboard/types.d.ts +0 -0
  334. /package/{cli/dist → dist}/core/dashboard/types.js +0 -0
  335. /package/{cli/dist → dist}/core/discoverer/index.d.ts +0 -0
  336. /package/{cli/dist → dist}/core/discoverer/index.js +0 -0
  337. /package/{cli/dist → dist}/core/fixtures/loader.d.ts +0 -0
  338. /package/{cli/dist → dist}/core/fixtures/loader.js +0 -0
  339. /package/{cli/dist → dist}/core/fixtures/resolver.d.ts +0 -0
  340. /package/{cli/dist → dist}/core/fixtures/resolver.js +0 -0
  341. /package/{cli/dist → dist}/core/fixtures/types.d.ts +0 -0
  342. /package/{cli/dist → dist}/core/fixtures/types.js +0 -0
  343. /package/{cli/dist → dist}/core/flakiness/index.d.ts +0 -0
  344. /package/{cli/dist → dist}/core/flakiness/index.js +0 -0
  345. /package/{cli/dist → dist}/core/generation/code-formatter.d.ts +0 -0
  346. /package/{cli/dist → dist}/core/generation/code-formatter.js +0 -0
  347. /package/{cli/dist → dist}/core/generation/code-generator.d.ts +0 -0
  348. /package/{cli/dist → dist}/core/generation/code-generator.js +0 -0
  349. /package/{cli/dist → dist}/core/generation/generator.d.ts +0 -0
  350. /package/{cli/dist → dist}/core/generation/generator.js +0 -0
  351. /package/{cli/dist → dist}/core/generation/pack-generator.d.ts +0 -0
  352. /package/{cli/dist → dist}/core/generation/pack-generator.js +0 -0
  353. /package/{cli/dist → dist}/core/generation/prompt-builder.d.ts +0 -0
  354. /package/{cli/dist → dist}/core/generation/prompt-builder.js +0 -0
  355. /package/{cli/dist → dist}/core/generation/source-analyzer.d.ts +0 -0
  356. /package/{cli/dist → dist}/core/generation/source-analyzer.js +0 -0
  357. /package/{cli/dist → dist}/core/generation/test-optimizer.d.ts +0 -0
  358. /package/{cli/dist → dist}/core/generation/test-optimizer.js +0 -0
  359. /package/{cli/dist → dist}/core/generation/types.d.ts +0 -0
  360. /package/{cli/dist → dist}/core/generation/types.js +0 -0
  361. /package/{cli/dist → dist}/core/hooks/compose.d.ts +0 -0
  362. /package/{cli/dist → dist}/core/hooks/compose.js +0 -0
  363. /package/{cli/dist → dist}/core/hooks/runner.d.ts +0 -0
  364. /package/{cli/dist → dist}/core/hooks/runner.js +0 -0
  365. /package/{cli/dist → dist}/core/pack/migrator.d.ts +0 -0
  366. /package/{cli/dist → dist}/core/pack/migrator.js +0 -0
  367. /package/{cli/dist → dist}/core/pack/validator.d.ts +0 -0
  368. /package/{cli/dist → dist}/core/pack-v2/index.d.ts +0 -0
  369. /package/{cli/dist → dist}/core/pack-v2/index.js +0 -0
  370. /package/{cli/dist → dist}/core/pack-v2/loader.d.ts +0 -0
  371. /package/{cli/dist → dist}/core/pack-v2/loader.js +0 -0
  372. /package/{cli/dist → dist}/core/pack-v2/validator.d.ts +0 -0
  373. /package/{cli/dist → dist}/core/parallel/index.d.ts +0 -0
  374. /package/{cli/dist → dist}/core/parallel/index.js +0 -0
  375. /package/{cli/dist → dist}/core/parallel/parallel-runner.d.ts +0 -0
  376. /package/{cli/dist → dist}/core/parallel/parallel-runner.js +0 -0
  377. /package/{cli/dist → dist}/core/pom/base-page.d.ts +0 -0
  378. /package/{cli/dist → dist}/core/pom/index.d.ts +0 -0
  379. /package/{cli/dist → dist}/core/pom/index.js +0 -0
  380. /package/{cli/dist → dist}/core/pom/loader.d.ts +0 -0
  381. /package/{cli/dist → dist}/core/pom/types.d.ts +0 -0
  382. /package/{cli/dist → dist}/core/pom/types.js +0 -0
  383. /package/{cli/dist → dist}/core/proof/bundle.d.ts +0 -0
  384. /package/{cli/dist → dist}/core/proof/bundle.js +0 -0
  385. /package/{cli/dist → dist}/core/proof/canonicalize.d.ts +0 -0
  386. /package/{cli/dist → dist}/core/proof/canonicalize.js +0 -0
  387. /package/{cli/dist → dist}/core/proof/index.d.ts +0 -0
  388. /package/{cli/dist → dist}/core/proof/index.js +0 -0
  389. /package/{cli/dist → dist}/core/proof/schema.d.ts +0 -0
  390. /package/{cli/dist → dist}/core/proof/schema.js +0 -0
  391. /package/{cli/dist → dist}/core/proof/signer.d.ts +0 -0
  392. /package/{cli/dist → dist}/core/proof/signer.js +0 -0
  393. /package/{cli/dist → dist}/core/proof/verifier.d.ts +0 -0
  394. /package/{cli/dist → dist}/core/proof/verifier.js +0 -0
  395. /package/{cli/dist → dist}/core/regression/detector.d.ts +0 -0
  396. /package/{cli/dist → dist}/core/regression/detector.js +0 -0
  397. /package/{cli/dist → dist}/core/regression/index.d.ts +0 -0
  398. /package/{cli/dist → dist}/core/regression/index.js +0 -0
  399. /package/{cli/dist → dist}/core/regression/trend-analyzer.d.ts +0 -0
  400. /package/{cli/dist → dist}/core/regression/trend-analyzer.js +0 -0
  401. /package/{cli/dist → dist}/core/regression/types.d.ts +0 -0
  402. /package/{cli/dist → dist}/core/regression/types.js +0 -0
  403. /package/{cli/dist → dist}/core/regression/vault.d.ts +0 -0
  404. /package/{cli/dist → dist}/core/regression/vault.js +0 -0
  405. /package/{cli/dist → dist}/core/repair/engine/fixer.d.ts +0 -0
  406. /package/{cli/dist → dist}/core/repair/engine/fixer.js +0 -0
  407. /package/{cli/dist → dist}/core/repair/engine/suggestion-engine.d.ts +0 -0
  408. /package/{cli/dist → dist}/core/repair/engine/suggestion-engine.js +0 -0
  409. /package/{cli/dist → dist}/core/repair/index.d.ts +0 -0
  410. /package/{cli/dist → dist}/core/repair/index.js +0 -0
  411. /package/{cli/dist → dist}/core/repair/repairer.d.ts +0 -0
  412. /package/{cli/dist → dist}/core/repair/repairer.js +0 -0
  413. /package/{cli/dist → dist}/core/repair/types.d.ts +0 -0
  414. /package/{cli/dist → dist}/core/repair/types.js +0 -0
  415. /package/{cli/dist → dist}/core/repair/utils/error-analyzer.d.ts +0 -0
  416. /package/{cli/dist → dist}/core/repair/utils/error-analyzer.js +0 -0
  417. /package/{cli/dist → dist}/core/reporting/html-reporter.d.ts +0 -0
  418. /package/{cli/dist → dist}/core/reporting/html-reporter.js +0 -0
  419. /package/{cli/dist → dist}/core/retry/flakiness-integration.d.ts +0 -0
  420. /package/{cli/dist → dist}/core/retry/flakiness-integration.js +0 -0
  421. /package/{cli/dist → dist}/core/retry/index.d.ts +0 -0
  422. /package/{cli/dist → dist}/core/retry/index.js +0 -0
  423. /package/{cli/dist → dist}/core/retry/retry-engine.d.ts +0 -0
  424. /package/{cli/dist → dist}/core/retry/retry-engine.js +0 -0
  425. /package/{cli/dist → dist}/core/retry/types.d.ts +0 -0
  426. /package/{cli/dist → dist}/core/retry/types.js +0 -0
  427. /package/{cli/dist → dist}/core/retry/vault.d.ts +0 -0
  428. /package/{cli/dist → dist}/core/retry/vault.js +0 -0
  429. /package/{cli/dist → dist}/core/schemas/pack.schema.json +0 -0
  430. /package/{cli/dist → dist}/core/secrets/crypto.d.ts +0 -0
  431. /package/{cli/dist → dist}/core/secrets/crypto.js +0 -0
  432. /package/{cli/dist → dist}/core/secrets/manager.d.ts +0 -0
  433. /package/{cli/dist → dist}/core/secrets/manager.js +0 -0
  434. /package/{cli/dist → dist}/core/security/redaction-patterns-extended.d.ts +0 -0
  435. /package/{cli/dist → dist}/core/security/redaction-patterns-extended.js +0 -0
  436. /package/{cli/dist → dist}/core/security/redactor.d.ts +0 -0
  437. /package/{cli/dist → dist}/core/security/redactor.js +0 -0
  438. /package/{cli/dist → dist}/core/self-healing/assertion-healer.d.ts +0 -0
  439. /package/{cli/dist → dist}/core/self-healing/assertion-healer.js +0 -0
  440. /package/{cli/dist → dist}/core/self-healing/engine.d.ts +0 -0
  441. /package/{cli/dist → dist}/core/self-healing/engine.js +0 -0
  442. /package/{cli/dist → dist}/core/self-healing/index.d.ts +0 -0
  443. /package/{cli/dist → dist}/core/self-healing/index.js +0 -0
  444. /package/{cli/dist → dist}/core/self-healing/selector-healer.d.ts +0 -0
  445. /package/{cli/dist → dist}/core/self-healing/selector-healer.js +0 -0
  446. /package/{cli/dist → dist}/core/self-healing/types.d.ts +0 -0
  447. /package/{cli/dist → dist}/core/self-healing/types.js +0 -0
  448. /package/{cli/dist → dist}/core/serve/diagnostics-collector.d.ts +0 -0
  449. /package/{cli/dist → dist}/core/serve/diagnostics-collector.js +0 -0
  450. /package/{cli/dist → dist}/core/serve/health-checker.d.ts +0 -0
  451. /package/{cli/dist → dist}/core/serve/health-checker.js +0 -0
  452. /package/{cli/dist → dist}/core/serve/index.d.ts +0 -0
  453. /package/{cli/dist → dist}/core/serve/index.js +0 -0
  454. /package/{cli/dist → dist}/core/serve/metrics-collector.d.ts +0 -0
  455. /package/{cli/dist → dist}/core/serve/metrics-collector.js +0 -0
  456. /package/{cli/dist → dist}/core/serve/process-manager.d.ts +0 -0
  457. /package/{cli/dist → dist}/core/serve/process-manager.js +0 -0
  458. /package/{cli/dist → dist}/core/serve/server.d.ts +0 -0
  459. /package/{cli/dist → dist}/core/serve/server.js +0 -0
  460. /package/{cli/dist → dist}/core/slo/config.d.ts +0 -0
  461. /package/{cli/dist → dist}/core/slo/config.js +0 -0
  462. /package/{cli/dist → dist}/core/slo/index.d.ts +0 -0
  463. /package/{cli/dist → dist}/core/slo/index.js +0 -0
  464. /package/{cli/dist → dist}/core/slo/sli-calculator.d.ts +0 -0
  465. /package/{cli/dist → dist}/core/slo/sli-calculator.js +0 -0
  466. /package/{cli/dist → dist}/core/slo/slo-tracker.d.ts +0 -0
  467. /package/{cli/dist → dist}/core/slo/slo-tracker.js +0 -0
  468. /package/{cli/dist → dist}/core/slo/types.d.ts +0 -0
  469. /package/{cli/dist → dist}/core/slo/types.js +0 -0
  470. /package/{cli/dist → dist}/core/slo/vault.d.ts +0 -0
  471. /package/{cli/dist → dist}/core/slo/vault.js +0 -0
  472. /package/{cli/dist → dist}/core/tui/index.d.ts +0 -0
  473. /package/{cli/dist → dist}/core/tui/index.js +0 -0
  474. /package/{cli/dist → dist}/core/tui/monitor.d.ts +0 -0
  475. /package/{cli/dist → dist}/core/tui/monitor.js +0 -0
  476. /package/{cli/dist → dist}/core/tui/renderer.d.ts +0 -0
  477. /package/{cli/dist → dist}/core/tui/renderer.js +0 -0
  478. /package/{cli/dist → dist}/core/tui/types.d.ts +0 -0
  479. /package/{cli/dist → dist}/core/tui/types.js +0 -0
  480. /package/{cli/dist → dist}/core/types/pack-v1.js +0 -0
  481. /package/{cli/dist → dist}/core/types/pack-v2.js +0 -0
  482. /package/{cli/dist → dist}/core/types/trust-score.d.ts +0 -0
  483. /package/{cli/dist → dist}/core/types/trust-score.js +0 -0
  484. /package/{cli/dist → dist}/core/vault/cas.d.ts +0 -0
  485. /package/{cli/dist → dist}/core/vault/cas.js +0 -0
  486. /package/{cli/dist → dist}/core/vault/index.d.ts +0 -0
  487. /package/{cli/dist → dist}/core/vault/index.js +0 -0
  488. /package/{cli/dist → dist}/core/visual/visual-regression.d.ts +0 -0
  489. /package/{cli/dist → dist}/core/visual/visual-regression.js +0 -0
  490. /package/{cli/dist → dist}/core/watch/index.d.ts +0 -0
  491. /package/{cli/dist → dist}/core/watch/index.js +0 -0
  492. /package/{cli/dist → dist}/core/watch/watch-mode.d.ts +0 -0
  493. /package/{cli/dist → dist}/core/watch/watch-mode.js +0 -0
  494. /package/{cli/dist → dist}/generators/index.d.ts +0 -0
  495. /package/{cli/dist → dist}/generators/index.js +0 -0
  496. /package/{cli/dist → dist}/generators/json-reporter.d.ts +0 -0
  497. /package/{cli/dist → dist}/generators/json-reporter.js +0 -0
  498. /package/{cli/dist → dist}/generators/test-generator.d.ts +0 -0
  499. /package/{cli/dist → dist}/generators/test-generator.js +0 -0
  500. /package/{cli/dist → dist}/index.d.ts +0 -0
  501. /package/{cli/dist → dist}/scanners/dom-scanner.d.ts +0 -0
  502. /package/{cli/dist → dist}/scanners/dom-scanner.js +0 -0
  503. /package/{cli/dist → dist}/scanners/index.d.ts +0 -0
  504. /package/{cli/dist → dist}/scanners/index.js +0 -0
  505. /package/{cli/dist → dist}/schemas/pack.schema.json +0 -0
  506. /package/{cli/dist → dist}/types/scan.d.ts +0 -0
  507. /package/{cli/dist → dist}/types/scan.js +0 -0
@@ -0,0 +1,373 @@
1
+ /**
2
+ * MIME Type Validator
3
+ *
4
+ * Validates file types using:
5
+ * - File extension (quick check)
6
+ * - Magic bytes (file signature)
7
+ * - Server-side MIME type validation
8
+ *
9
+ * Supports comprehensive file type detection for:
10
+ * - Images: JPEG, PNG, GIF, WebP, SVG, ICO, AVIF, HEIC
11
+ * - Documents: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX
12
+ * - Audio: MP3, WAV, OGG, FLAC, M4A
13
+ * - Video: MP4, WEBM, AVI, MOV, MKV
14
+ * - Archives: ZIP, RAR, 7Z, TAR, GZIP
15
+ * - And more...
16
+ */
17
+ /**
18
+ * Magic bytes signatures for common file types
19
+ */
20
+ const MAGIC_BYTES = {
21
+ // Images
22
+ jpeg: { signature: [0xFF, 0xD8, 0xFF], offset: 0, mime: 'image/jpeg' },
23
+ png: { signature: [0x89, 0x50, 0x4E, 0x47], offset: 0, mime: 'image/png' },
24
+ gif: { signature: [0x47, 0x49, 0x46, 0x38], offset: 0, mime: 'image/gif' },
25
+ webp: { signature: [0x52, 0x49, 0x46, 0x46], offset: 0, mime: 'image/webp' }, // RIFF
26
+ bmp: { signature: [0x42, 0x4D], offset: 0, mime: 'image/bmp' },
27
+ ico: { signature: [0x00, 0x00, 0x01, 0x00], offset: 0, mime: 'image/x-icon' },
28
+ tiff: { signature: [0x49, 0x49, 0x2A, 0x00], offset: 0, mime: 'image/tiff' }, // Little-endian
29
+ tiff_be: { signature: [0x4D, 0x4D, 0x00, 0x2A], offset: 0, mime: 'image/tiff' }, // Big-endian
30
+ avif: { signature: [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70], offset: 4, mime: 'image/avif' },
31
+ heic: { signature: [0x00, 0x00, 0x00, 0x1C, 0x66, 0x74, 0x79, 0x70], offset: 4, mime: 'image/heic' },
32
+ // Documents
33
+ pdf: { signature: [0x25, 0x50, 0x44, 0x46], offset: 0, mime: 'application/pdf' },
34
+ // DOC (OLE2)
35
+ doc: { signature: [0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1], offset: 0, mime: 'application/msword' },
36
+ // DOCX (ZIP-based)
37
+ docx: { signature: [0x50, 0x4B, 0x03, 0x04], offset: 0, mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' },
38
+ xlsx: { signature: [0x50, 0x4B, 0x03, 0x04], offset: 0, mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' },
39
+ pptx: { signature: [0x50, 0x4B, 0x03, 0x04], offset: 0, mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' },
40
+ odt: { signature: [0x50, 0x4B, 0x03, 0x04], offset: 0, mime: 'application/vnd.oasis.opendocument.text' },
41
+ ods: { signature: [0x50, 0x4B, 0x03, 0x04], offset: 0, mime: 'application/vnd.oasis.opendocument.spreadsheet' },
42
+ // Audio
43
+ mp3: { signature: [0xFF, 0xFB], offset: 0, mime: 'audio/mpeg' },
44
+ mp3_2: { signature: [0xFF, 0xFA], offset: 0, mime: 'audio/mpeg' },
45
+ mp3_id3: { signature: [0x49, 0x44, 0x33], offset: 0, mime: 'audio/mpeg' }, // ID3
46
+ wav: { signature: [0x52, 0x49, 0x46, 0x46], offset: 0, mime: 'audio/wav' }, // RIFF
47
+ ogg: { signature: [0x4F, 0x67, 0x67, 0x53], offset: 0, mime: 'audio/ogg' },
48
+ flac: { signature: [0x66, 0x4C, 0x61, 0x43], offset: 0, mime: 'audio/flac' },
49
+ m4a: { signature: [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70], offset: 4, mime: 'audio/mp4' },
50
+ aiff: { signature: [0x46, 0x4F, 0x52, 0x4D], offset: 0, mime: 'audio/aiff' }, // AIFF
51
+ aiff_2: { signature: [0x41, 0x49, 0x46, 0x46], offset: 0, mime: 'audio/aiff' }, // AIFF
52
+ // Video
53
+ mp4: { signature: [0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70], offset: 4, mime: 'video/mp4' },
54
+ webm: { signature: [0x1A, 0x45, 0xDF, 0xA3], offset: 0, mime: 'video/webm' },
55
+ avi: { signature: [0x52, 0x49, 0x46, 0x46], offset: 0, mime: 'video/x-msvideo' }, // RIFF...AVI
56
+ mov: { signature: [0x00, 0x00, 0x00, 0x14, 0x66, 0x74, 0x79, 0x70], offset: 4, mime: 'video/quicktime' },
57
+ mkv: { signature: [0x1A, 0x45, 0xDF, 0xA3], offset: 0, mime: 'video/x-matroska' },
58
+ flv: { signature: [0x46, 0x4C, 0x56, 0x01], offset: 0, mime: 'video/x-flv' },
59
+ mpeg: { signature: [0x00, 0x00, 0x01, 0xBA], offset: 0, mime: 'video/mpeg' },
60
+ mpeg_ps: { signature: [0x00, 0x00, 0x01, 0xB3], offset: 0, mime: 'video/mpeg' },
61
+ // Archives
62
+ zip: { signature: [0x50, 0x4B, 0x03, 0x04], offset: 0, mime: 'application/zip' },
63
+ zip_empty: { signature: [0x50, 0x4B, 0x05, 0x06], offset: 0, mime: 'application/zip' },
64
+ zip_spanned: { signature: [0x50, 0x4B, 0x07, 0x08], offset: 0, mime: 'application/zip' },
65
+ rar: { signature: [0x52, 0x61, 0x72, 0x21], offset: 0, mime: 'application/vnd.rar' },
66
+ rar_5: { signature: [0x52, 0x61, 0x72, 0x21], offset: 0, mime: 'application/x-rar-compressed' },
67
+ _7z: { signature: [0x37, 0x7A, 0xBC, 0xAF], offset: 0, mime: 'application/x-7z-compressed' },
68
+ tar: { signature: [0x75, 0x73, 0x74, 0x61, 0x72], offset: 257, mime: 'application/x-tar' },
69
+ gzip: { signature: [0x1F, 0x8B], offset: 0, mime: 'application/gzip' },
70
+ bzip2: { signature: [0x42, 0x5A, 0x68], offset: 0, mime: 'application/x-bzip2' },
71
+ // Other
72
+ json: { signature: [0x7B], offset: 0, mime: 'application/json' },
73
+ json_array: { signature: [0x5B], offset: 0, mime: 'application/json' },
74
+ xml: { signature: [0x3C, 0x3F, 0x78, 0x6D, 0x6C], offset: 0, mime: 'application/xml' },
75
+ html: { signature: [0x3C, 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45], offset: 0, mime: 'text/html' },
76
+ html_2: { signature: [0x3C, 0x68, 0x74, 0x6D, 0x6C], offset: 0, mime: 'text/html' },
77
+ svg: { signature: [0x3C, 0x73, 0x76, 0x67], offset: 0, mime: 'image/svg+xml' },
78
+ };
79
+ /**
80
+ * Extension to MIME type mapping
81
+ */
82
+ const EXTENSION_MIME_MAP = {
83
+ // Images
84
+ jpg: 'image/jpeg',
85
+ jpeg: 'image/jpeg',
86
+ png: 'image/png',
87
+ gif: 'image/gif',
88
+ webp: 'image/webp',
89
+ bmp: 'image/bmp',
90
+ ico: 'image/x-icon',
91
+ svg: 'image/svg+xml',
92
+ tif: 'image/tiff',
93
+ tiff: 'image/tiff',
94
+ avif: 'image/avif',
95
+ heic: 'image/heic',
96
+ heif: 'image/heif',
97
+ // Documents
98
+ pdf: 'application/pdf',
99
+ doc: 'application/msword',
100
+ docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
101
+ xls: 'application/vnd.ms-excel',
102
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
103
+ ppt: 'application/vnd.ms-powerpoint',
104
+ pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
105
+ odt: 'application/vnd.oasis.opendocument.text',
106
+ ods: 'application/vnd.oasis.opendocument.spreadsheet',
107
+ odp: 'application/vnd.oasis.opendocument.presentation',
108
+ rtf: 'application/rtf',
109
+ txt: 'text/plain',
110
+ csv: 'text/csv',
111
+ md: 'text/markdown',
112
+ // Audio
113
+ mp3: 'audio/mpeg',
114
+ wav: 'audio/wav',
115
+ ogg: 'audio/ogg',
116
+ flac: 'audio/flac',
117
+ m4a: 'audio/mp4',
118
+ aac: 'audio/aac',
119
+ wma: 'audio/x-ms-wma',
120
+ aiff: 'audio/aiff',
121
+ aif: 'audio/aiff',
122
+ // Video
123
+ mp4: 'video/mp4',
124
+ webm: 'video/webm',
125
+ avi: 'video/x-msvideo',
126
+ mov: 'video/quicktime',
127
+ mkv: 'video/x-matroska',
128
+ flv: 'video/x-flv',
129
+ mpeg: 'video/mpeg',
130
+ mpg: 'video/mpeg',
131
+ m4v: 'video/mp4',
132
+ _3gp: 'video/3gpp',
133
+ _3g2: 'video/3gpp2',
134
+ // Archives
135
+ zip: 'application/zip',
136
+ rar: 'application/vnd.rar',
137
+ '7z': 'application/x-7z-compressed',
138
+ tar: 'application/x-tar',
139
+ gz: 'application/gzip',
140
+ bz2: 'application/x-bzip2',
141
+ iso: 'application/x-iso9660-image',
142
+ // Other
143
+ json: 'application/json',
144
+ xml: 'application/xml',
145
+ html: 'text/html',
146
+ htm: 'text/html',
147
+ css: 'text/css',
148
+ js: 'application/javascript',
149
+ mjs: 'application/javascript',
150
+ ts: 'application/typescript',
151
+ yaml: 'application/x-yaml',
152
+ yml: 'application/x-yaml',
153
+ };
154
+ /**
155
+ * MIME type validator class
156
+ */
157
+ export class MimeValidator {
158
+ config;
159
+ customMappings;
160
+ constructor(config = {}) {
161
+ this.config = {
162
+ allowedTypes: config.allowedTypes || [],
163
+ allowedExtensions: config.allowedExtensions || [],
164
+ maxSize: config.maxSize || Infinity,
165
+ useMagicBytes: config.useMagicBytes !== false,
166
+ customMappings: config.customMappings || {},
167
+ };
168
+ this.customMappings = { ...EXTENSION_MIME_MAP, ...this.config.customMappings };
169
+ }
170
+ /**
171
+ * Validate a file
172
+ */
173
+ async validate(file) {
174
+ const errors = [];
175
+ const warnings = [];
176
+ // Get file info
177
+ const size = file.size;
178
+ const declaredType = file.type;
179
+ const fileName = file.name || '';
180
+ // Extract extension
181
+ const extension = this.getExtension(fileName);
182
+ // Detect MIME type
183
+ const detectedType = await this.detectMimeType(file);
184
+ // Validate size
185
+ if (size > this.config.maxSize) {
186
+ errors.push(`File size ${(size / 1024 / 1024).toFixed(2)}MB exceeds maximum ${(this.config.maxSize / 1024 / 1024).toFixed(2)}MB`);
187
+ }
188
+ // Validate extension
189
+ if (this.config.allowedExtensions.length > 0) {
190
+ if (!extension) {
191
+ errors.push('No file extension found');
192
+ }
193
+ else if (!this.isAllowedExtension(extension)) {
194
+ errors.push(`File extension ".${extension}" is not allowed`);
195
+ }
196
+ }
197
+ // Validate MIME type
198
+ if (this.config.allowedTypes.length > 0) {
199
+ if (!detectedType) {
200
+ errors.push('Could not detect file type');
201
+ }
202
+ else if (!this.isAllowedType(detectedType)) {
203
+ errors.push(`File type "${detectedType}" is not allowed`);
204
+ }
205
+ }
206
+ // Check for extension/MIME mismatch
207
+ if (extension && declaredType && this.customMappings[extension]) {
208
+ const expectedMime = this.customMappings[extension];
209
+ if (declaredType !== expectedMime && declaredType !== '') {
210
+ warnings.push(`Declared type "${declaredType}" doesn't match extension ".${extension}" (expected "${expectedMime}")`);
211
+ }
212
+ }
213
+ return {
214
+ valid: errors.length === 0,
215
+ mimeType: detectedType,
216
+ extension,
217
+ size,
218
+ errors: errors.length > 0 ? errors : undefined,
219
+ warnings: warnings.length > 0 ? warnings : undefined,
220
+ };
221
+ }
222
+ /**
223
+ * Detect MIME type using magic bytes
224
+ */
225
+ async detectMimeType(file) {
226
+ // First try declared type
227
+ if (file.type && this.isValidMimeType(file.type)) {
228
+ return file.type;
229
+ }
230
+ // Try extension-based detection
231
+ const fileName = file.name;
232
+ if (fileName) {
233
+ const ext = this.getExtension(fileName);
234
+ if (ext && this.customMappings[ext]) {
235
+ return this.customMappings[ext];
236
+ }
237
+ }
238
+ // Try magic bytes detection
239
+ if (this.config.useMagicBytes) {
240
+ const magicType = await this.detectFromMagicBytes(file);
241
+ if (magicType) {
242
+ return magicType;
243
+ }
244
+ }
245
+ return file.type || undefined;
246
+ }
247
+ /**
248
+ * Detect MIME type from magic bytes (file signature)
249
+ */
250
+ async detectFromMagicBytes(file) {
251
+ const arrayBuffer = await file.slice(0, 300).arrayBuffer();
252
+ const bytes = new Uint8Array(arrayBuffer);
253
+ for (const [name, info] of Object.entries(MAGIC_BYTES)) {
254
+ if (this.matchesMagicBytes(bytes, info.signature, info.offset)) {
255
+ return info.mime;
256
+ }
257
+ }
258
+ return undefined;
259
+ }
260
+ /**
261
+ * Check if bytes match signature at offset
262
+ */
263
+ matchesMagicBytes(bytes, signature, offset) {
264
+ for (let i = 0; i < signature.length; i++) {
265
+ if (bytes[offset + i] !== signature[i]) {
266
+ return false;
267
+ }
268
+ }
269
+ return true;
270
+ }
271
+ /**
272
+ * Check if MIME type is allowed
273
+ */
274
+ isAllowedType(mimeType) {
275
+ return this.config.allowedTypes.some(allowed => {
276
+ if (allowed.endsWith('/*')) {
277
+ const prefix = allowed.slice(0, -2);
278
+ return mimeType.startsWith(prefix);
279
+ }
280
+ return mimeType === allowed;
281
+ });
282
+ }
283
+ /**
284
+ * Check if extension is allowed
285
+ */
286
+ isAllowedExtension(extension) {
287
+ const normalizedExt = extension.toLowerCase().replace(/^\./, '');
288
+ return this.config.allowedExtensions.some(allowed => {
289
+ const normalizedAllowed = allowed.toLowerCase().replace(/^\./, '');
290
+ return normalizedAllowed === normalizedExt;
291
+ });
292
+ }
293
+ /**
294
+ * Check if a string is a valid MIME type
295
+ */
296
+ isValidMimeType(mimeType) {
297
+ return /^[a-z]+\/[a-z0-9+.-]+$/i.test(mimeType);
298
+ }
299
+ /**
300
+ * Get file extension from filename
301
+ */
302
+ getExtension(fileName) {
303
+ const match = fileName.toLowerCase().match(/\.([a-z0-9]+)$/);
304
+ return match ? match[1] : '';
305
+ }
306
+ /**
307
+ * Get MIME type from extension
308
+ */
309
+ getMimeTypeFromExtension(extension) {
310
+ const normalizedExt = extension.toLowerCase().replace(/^\./, '');
311
+ return this.customMappings[normalizedExt];
312
+ }
313
+ /**
314
+ * Get extension from MIME type
315
+ */
316
+ getExtensionFromMimeType(mimeType) {
317
+ for (const [ext, mime] of Object.entries(this.customMappings)) {
318
+ if (mime === mimeType) {
319
+ return ext;
320
+ }
321
+ }
322
+ return undefined;
323
+ }
324
+ /**
325
+ * Update allowed types
326
+ */
327
+ setAllowedTypes(types) {
328
+ this.config.allowedTypes = types;
329
+ }
330
+ /**
331
+ * Update allowed extensions
332
+ */
333
+ setAllowedExtensions(extensions) {
334
+ this.config.allowedExtensions = extensions;
335
+ }
336
+ /**
337
+ * Update max size
338
+ */
339
+ setMaxSize(size) {
340
+ this.config.maxSize = size;
341
+ }
342
+ }
343
+ /**
344
+ * Create a MIME validator instance
345
+ */
346
+ export function createMimeValidator(config) {
347
+ return new MimeValidator(config);
348
+ }
349
+ /**
350
+ * Validate a file (convenience function)
351
+ */
352
+ export async function validateMimeType(file, config) {
353
+ const validator = new MimeValidator(config);
354
+ return validator.validate(file);
355
+ }
356
+ /**
357
+ * Get MIME type from extension
358
+ */
359
+ export function getMimeTypeFromExtension(extension) {
360
+ return EXTENSION_MIME_MAP[extension.toLowerCase().replace(/^\./, '')];
361
+ }
362
+ /**
363
+ * Get extension from MIME type
364
+ */
365
+ export function getExtensionFromMimeType(mimeType) {
366
+ for (const [ext, mime] of Object.entries(EXTENSION_MIME_MAP)) {
367
+ if (mime === mimeType) {
368
+ return ext;
369
+ }
370
+ }
371
+ return undefined;
372
+ }
373
+ export default MimeValidator;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Presigned URL Uploader
3
+ *
4
+ * Handles file uploads using presigned URLs for cloud storage.
5
+ * Supports:
6
+ * - AWS S3 presigned URLs
7
+ * - Azure Blob Storage SAS URLs
8
+ * - Google Cloud Storage signed URLs
9
+ * - Custom presigned URL providers
10
+ */
11
+ export interface PresignedUrlConfig {
12
+ /** URL to request presigned upload URL */
13
+ presignedUrlEndpoint: string;
14
+ /** HTTP method for presigned URL request (default: POST) */
15
+ method?: 'GET' | 'POST';
16
+ /** Headers for presigned URL request */
17
+ headers?: Record<string, string>;
18
+ /** Fields to include in presigned URL request */
19
+ requestFields?: Record<string, string>;
20
+ /** Query params for presigned URL request */
21
+ requestParams?: Record<string, string>;
22
+ /** File field name (default: 'file') */
23
+ fileField?: string;
24
+ /** Additional fields to include with upload */
25
+ uploadFields?: Record<string, string>;
26
+ /** HTTP method for upload (default: PUT for S3, POST for others) */
27
+ uploadMethod?: 'PUT' | 'POST';
28
+ /** Headers to include with upload */
29
+ uploadHeaders?: Record<string, string>;
30
+ /** Progress callback */
31
+ onProgress?: (progress: UploadProgress) => void;
32
+ }
33
+ export interface PresignedUrlResponse {
34
+ /** The presigned URL for upload */
35
+ url: string;
36
+ /** HTTP method to use (PUT or POST) */
37
+ method?: 'PUT' | 'POST';
38
+ /** Required headers for upload */
39
+ headers?: Record<string, string>;
40
+ /** Required fields for POST upload */
41
+ fields?: Record<string, string>;
42
+ /** File ID/key from server */
43
+ key?: string;
44
+ /** Expiration timestamp */
45
+ expiresAt?: number;
46
+ }
47
+ export interface UploadProgress {
48
+ /** Bytes uploaded */
49
+ loaded: number;
50
+ /** Total bytes */
51
+ total: number;
52
+ /** Percentage (0-100) */
53
+ percentage: number;
54
+ }
55
+ export interface PresignedUploadResult {
56
+ /** Upload success status */
57
+ success: boolean;
58
+ /** File key/ID from server */
59
+ key?: string;
60
+ /** Public URL of uploaded file (if provided) */
61
+ url?: string;
62
+ /** Server response */
63
+ response?: any;
64
+ /** Error if failed */
65
+ error?: string;
66
+ }
67
+ /**
68
+ * Presigned URL uploader class
69
+ */
70
+ export declare class PresignedUploader {
71
+ private config;
72
+ constructor(config: PresignedUrlConfig);
73
+ /**
74
+ * Upload a file using a presigned URL
75
+ */
76
+ upload(file: File | Blob, fileName?: string): Promise<PresignedUploadResult>;
77
+ /**
78
+ * Request a presigned URL from the server
79
+ */
80
+ private requestPresignedUrl;
81
+ /**
82
+ * Upload file to the presigned URL
83
+ */
84
+ private uploadToPresignedUrl;
85
+ /**
86
+ * Upload via PUT request (S3 style)
87
+ */
88
+ private uploadViaPut;
89
+ /**
90
+ * Upload via POST request (multipart/form-data style)
91
+ */
92
+ private uploadViaPost;
93
+ /**
94
+ * Upload multiple files concurrently
95
+ */
96
+ uploadMultiple(files: (File | Blob)[], concurrency?: number): Promise<PresignedUploadResult[]>;
97
+ }
98
+ /**
99
+ * Create a presigned URL uploader instance
100
+ */
101
+ export declare function createPresignedUploader(config: PresignedUrlConfig): PresignedUploader;
102
+ /**
103
+ * Upload a file using a presigned URL (convenience function)
104
+ */
105
+ export declare function uploadWithPresignedUrl(file: File | Blob, config: PresignedUrlConfig): Promise<PresignedUploadResult>;
106
+ /**
107
+ * AWS S3 specific presigned uploader
108
+ */
109
+ export declare class S3PresignedUploader extends PresignedUploader {
110
+ constructor(config: Omit<PresignedUrlConfig, 'uploadMethod'>);
111
+ }
112
+ /**
113
+ * Azure Blob Storage specific presigned uploader
114
+ */
115
+ export declare class AzurePresignedUploader extends PresignedUploader {
116
+ constructor(config: Omit<PresignedUrlConfig, 'uploadMethod'>);
117
+ }
118
+ export default PresignedUploader;