@vibesdotdev/security 0.0.0-stage → 1.0.0-rc.4

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 (342) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +109 -2
  3. package/dist/cli/index.d.ts +2 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +2 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/cli/plugin.d.ts +15 -0
  8. package/dist/cli/plugin.d.ts.map +1 -0
  9. package/dist/cli/plugin.js +25 -0
  10. package/dist/cli/plugin.js.map +1 -0
  11. package/dist/cli/read-lockfile.d.ts +4 -0
  12. package/dist/cli/read-lockfile.d.ts.map +1 -0
  13. package/dist/cli/read-lockfile.js +74 -0
  14. package/dist/cli/read-lockfile.js.map +1 -0
  15. package/dist/cli/report-output.d.ts +20 -0
  16. package/dist/cli/report-output.d.ts.map +1 -0
  17. package/dist/cli/report-output.js +27 -0
  18. package/dist/cli/report-output.js.map +1 -0
  19. package/dist/cli/shield.cli-group.descriptor.d.ts +9 -0
  20. package/dist/cli/shield.cli-group.descriptor.d.ts.map +1 -0
  21. package/dist/cli/shield.cli-group.descriptor.js +16 -0
  22. package/dist/cli/shield.cli-group.descriptor.js.map +1 -0
  23. package/dist/cli/shield.deps.cli-group.descriptor.d.ts +9 -0
  24. package/dist/cli/shield.deps.cli-group.descriptor.d.ts.map +1 -0
  25. package/dist/cli/shield.deps.cli-group.descriptor.js +17 -0
  26. package/dist/cli/shield.deps.cli-group.descriptor.js.map +1 -0
  27. package/dist/cli/shield.deps.gate.descriptor.d.ts +10 -0
  28. package/dist/cli/shield.deps.gate.descriptor.d.ts.map +1 -0
  29. package/dist/cli/shield.deps.gate.descriptor.js +25 -0
  30. package/dist/cli/shield.deps.gate.descriptor.js.map +1 -0
  31. package/dist/cli/shield.deps.gate.impl.consumer.d.ts +18 -0
  32. package/dist/cli/shield.deps.gate.impl.consumer.d.ts.map +1 -0
  33. package/dist/cli/shield.deps.gate.impl.consumer.js +42 -0
  34. package/dist/cli/shield.deps.gate.impl.consumer.js.map +1 -0
  35. package/dist/cli/shield.deps.scan.descriptor.d.ts +10 -0
  36. package/dist/cli/shield.deps.scan.descriptor.d.ts.map +1 -0
  37. package/dist/cli/shield.deps.scan.descriptor.js +25 -0
  38. package/dist/cli/shield.deps.scan.descriptor.js.map +1 -0
  39. package/dist/cli/shield.deps.scan.impl.consumer.d.ts +16 -0
  40. package/dist/cli/shield.deps.scan.impl.consumer.d.ts.map +1 -0
  41. package/dist/cli/shield.deps.scan.impl.consumer.js +35 -0
  42. package/dist/cli/shield.deps.scan.impl.consumer.js.map +1 -0
  43. package/dist/helpers/constant-time.d.ts +18 -0
  44. package/dist/helpers/constant-time.d.ts.map +1 -0
  45. package/dist/helpers/constant-time.js +49 -0
  46. package/dist/helpers/constant-time.js.map +1 -0
  47. package/dist/helpers/filename-sanitizer.d.ts +2 -0
  48. package/dist/helpers/filename-sanitizer.d.ts.map +1 -0
  49. package/dist/helpers/filename-sanitizer.js +18 -0
  50. package/dist/helpers/filename-sanitizer.js.map +1 -0
  51. package/dist/helpers/forwardable-auth-headers.d.ts +8 -0
  52. package/dist/helpers/forwardable-auth-headers.d.ts.map +1 -0
  53. package/dist/helpers/forwardable-auth-headers.js +44 -0
  54. package/dist/helpers/forwardable-auth-headers.js.map +1 -0
  55. package/dist/helpers/index.d.ts +7 -0
  56. package/dist/helpers/index.d.ts.map +1 -0
  57. package/dist/helpers/index.js +7 -0
  58. package/dist/helpers/index.js.map +1 -0
  59. package/dist/helpers/ip-range.d.ts +3 -0
  60. package/dist/helpers/ip-range.d.ts.map +1 -0
  61. package/dist/helpers/ip-range.js +55 -0
  62. package/dist/helpers/ip-range.js.map +1 -0
  63. package/dist/helpers/mime-classifier.d.ts +3 -0
  64. package/dist/helpers/mime-classifier.d.ts.map +1 -0
  65. package/dist/helpers/mime-classifier.js +29 -0
  66. package/dist/helpers/mime-classifier.js.map +1 -0
  67. package/dist/helpers/pattern-matcher.d.ts +13 -0
  68. package/dist/helpers/pattern-matcher.d.ts.map +1 -0
  69. package/dist/helpers/pattern-matcher.js +29 -0
  70. package/dist/helpers/pattern-matcher.js.map +1 -0
  71. package/dist/implementations/cli-types.d.ts +2 -0
  72. package/dist/implementations/cli-types.d.ts.map +1 -0
  73. package/dist/implementations/cli-types.js +2 -0
  74. package/dist/implementations/cli-types.js.map +1 -0
  75. package/dist/implementations/encryption.d.ts +21 -0
  76. package/dist/implementations/encryption.d.ts.map +1 -0
  77. package/dist/implementations/encryption.js +154 -0
  78. package/dist/implementations/encryption.js.map +1 -0
  79. package/dist/implementations/errors.d.ts +17 -0
  80. package/dist/implementations/errors.d.ts.map +1 -0
  81. package/dist/implementations/errors.js +23 -0
  82. package/dist/implementations/errors.js.map +1 -0
  83. package/dist/implementations/keys.d.ts +24 -0
  84. package/dist/implementations/keys.d.ts.map +1 -0
  85. package/dist/implementations/keys.js +114 -0
  86. package/dist/implementations/keys.js.map +1 -0
  87. package/dist/implementations/redaction-admission.d.ts +24 -0
  88. package/dist/implementations/redaction-admission.d.ts.map +1 -0
  89. package/dist/implementations/redaction-admission.js +44 -0
  90. package/dist/implementations/redaction-admission.js.map +1 -0
  91. package/dist/implementations/redaction.d.ts +32 -0
  92. package/dist/implementations/redaction.d.ts.map +1 -0
  93. package/dist/implementations/redaction.js +47 -0
  94. package/dist/implementations/redaction.js.map +1 -0
  95. package/dist/implementations/redactor.inprocess.impl.d.ts +30 -0
  96. package/dist/implementations/redactor.inprocess.impl.d.ts.map +1 -0
  97. package/dist/implementations/redactor.inprocess.impl.js +26 -0
  98. package/dist/implementations/redactor.inprocess.impl.js.map +1 -0
  99. package/dist/implementations/redactor.subprocess.impl.d.ts +25 -0
  100. package/dist/implementations/redactor.subprocess.impl.d.ts.map +1 -0
  101. package/dist/implementations/redactor.subprocess.impl.js +42 -0
  102. package/dist/implementations/redactor.subprocess.impl.js.map +1 -0
  103. package/dist/implementations/scanner.impl.d.ts +7 -0
  104. package/dist/implementations/scanner.impl.d.ts.map +1 -0
  105. package/dist/implementations/scanner.impl.js +166 -0
  106. package/dist/implementations/scanner.impl.js.map +1 -0
  107. package/dist/index.d.ts +18 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +11 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/kinds/auditor.kind.d.ts +31 -0
  112. package/dist/kinds/auditor.kind.d.ts.map +1 -0
  113. package/dist/kinds/auditor.kind.js +48 -0
  114. package/dist/kinds/auditor.kind.js.map +1 -0
  115. package/dist/kinds/dep-scanner.kind.d.ts +27 -0
  116. package/dist/kinds/dep-scanner.kind.d.ts.map +1 -0
  117. package/dist/kinds/dep-scanner.kind.js +29 -0
  118. package/dist/kinds/dep-scanner.kind.js.map +1 -0
  119. package/dist/kinds/freshness-policy.kind.d.ts +34 -0
  120. package/dist/kinds/freshness-policy.kind.d.ts.map +1 -0
  121. package/dist/kinds/freshness-policy.kind.js +47 -0
  122. package/dist/kinds/freshness-policy.kind.js.map +1 -0
  123. package/dist/kinds/index.d.ts +9 -0
  124. package/dist/kinds/index.d.ts.map +1 -0
  125. package/dist/kinds/index.js +9 -0
  126. package/dist/kinds/index.js.map +1 -0
  127. package/dist/kinds/ioc-feed.kind.d.ts +35 -0
  128. package/dist/kinds/ioc-feed.kind.d.ts.map +1 -0
  129. package/dist/kinds/ioc-feed.kind.js +36 -0
  130. package/dist/kinds/ioc-feed.kind.js.map +1 -0
  131. package/dist/kinds/policy.kind.d.ts +42 -0
  132. package/dist/kinds/policy.kind.d.ts.map +1 -0
  133. package/dist/kinds/policy.kind.js +23 -0
  134. package/dist/kinds/policy.kind.js.map +1 -0
  135. package/dist/kinds/redactor.kind.d.ts +30 -0
  136. package/dist/kinds/redactor.kind.d.ts.map +1 -0
  137. package/dist/kinds/redactor.kind.js +25 -0
  138. package/dist/kinds/redactor.kind.js.map +1 -0
  139. package/dist/kinds/scanner.kind.d.ts +35 -0
  140. package/dist/kinds/scanner.kind.d.ts.map +1 -0
  141. package/dist/kinds/scanner.kind.js +26 -0
  142. package/dist/kinds/scanner.kind.js.map +1 -0
  143. package/dist/schemas/AuditEvent.d.ts +30 -0
  144. package/dist/schemas/AuditEvent.d.ts.map +1 -0
  145. package/dist/schemas/AuditEvent.js +17 -0
  146. package/dist/schemas/AuditEvent.js.map +1 -0
  147. package/dist/schemas/RedactionRule.d.ts +16 -0
  148. package/dist/schemas/RedactionRule.d.ts.map +1 -0
  149. package/dist/schemas/RedactionRule.js +10 -0
  150. package/dist/schemas/RedactionRule.js.map +1 -0
  151. package/dist/schemas/SecurityPolicy.d.ts +21 -0
  152. package/dist/schemas/SecurityPolicy.d.ts.map +1 -0
  153. package/dist/schemas/SecurityPolicy.js +9 -0
  154. package/dist/schemas/SecurityPolicy.js.map +1 -0
  155. package/dist/schemas/ThreatReport.d.ts +25 -0
  156. package/dist/schemas/ThreatReport.d.ts.map +1 -0
  157. package/dist/schemas/ThreatReport.js +14 -0
  158. package/dist/schemas/ThreatReport.js.map +1 -0
  159. package/dist/schemas/contracts/auditor.d.ts +68 -0
  160. package/dist/schemas/contracts/auditor.d.ts.map +1 -0
  161. package/dist/schemas/contracts/auditor.js +13 -0
  162. package/dist/schemas/contracts/auditor.js.map +1 -0
  163. package/dist/schemas/contracts/card.d.ts +106 -0
  164. package/dist/schemas/contracts/card.d.ts.map +1 -0
  165. package/dist/schemas/contracts/card.js +73 -0
  166. package/dist/schemas/contracts/card.js.map +1 -0
  167. package/dist/schemas/contracts/dep-scanner.d.ts +91 -0
  168. package/dist/schemas/contracts/dep-scanner.d.ts.map +1 -0
  169. package/dist/schemas/contracts/dep-scanner.js +27 -0
  170. package/dist/schemas/contracts/dep-scanner.js.map +1 -0
  171. package/dist/schemas/contracts/freshness-policy.d.ts +99 -0
  172. package/dist/schemas/contracts/freshness-policy.d.ts.map +1 -0
  173. package/dist/schemas/contracts/freshness-policy.js +31 -0
  174. package/dist/schemas/contracts/freshness-policy.js.map +1 -0
  175. package/dist/schemas/contracts/ioc-feed.d.ts +85 -0
  176. package/dist/schemas/contracts/ioc-feed.d.ts.map +1 -0
  177. package/dist/schemas/contracts/ioc-feed.js +28 -0
  178. package/dist/schemas/contracts/ioc-feed.js.map +1 -0
  179. package/dist/schemas/contracts/misc.d.ts +11 -0
  180. package/dist/schemas/contracts/misc.d.ts.map +1 -0
  181. package/dist/schemas/contracts/misc.js +4 -0
  182. package/dist/schemas/contracts/misc.js.map +1 -0
  183. package/dist/schemas/contracts/policy.d.ts +93 -0
  184. package/dist/schemas/contracts/policy.d.ts.map +1 -0
  185. package/dist/schemas/contracts/policy.js +25 -0
  186. package/dist/schemas/contracts/policy.js.map +1 -0
  187. package/dist/schemas/contracts/redactor.d.ts +99 -0
  188. package/dist/schemas/contracts/redactor.d.ts.map +1 -0
  189. package/dist/schemas/contracts/redactor.js +34 -0
  190. package/dist/schemas/contracts/redactor.js.map +1 -0
  191. package/dist/schemas/contracts/scanner.d.ts +112 -0
  192. package/dist/schemas/contracts/scanner.d.ts.map +1 -0
  193. package/dist/schemas/contracts/scanner.js +40 -0
  194. package/dist/schemas/contracts/scanner.js.map +1 -0
  195. package/dist/schemas/contracts/widget.d.ts +19 -0
  196. package/dist/schemas/contracts/widget.d.ts.map +1 -0
  197. package/dist/schemas/contracts/widget.js +10 -0
  198. package/dist/schemas/contracts/widget.js.map +1 -0
  199. package/dist/schemas/encryption.d.ts +25 -0
  200. package/dist/schemas/encryption.d.ts.map +1 -0
  201. package/dist/schemas/encryption.js +35 -0
  202. package/dist/schemas/encryption.js.map +1 -0
  203. package/dist/schemas/index.d.ts +6 -0
  204. package/dist/schemas/index.d.ts.map +1 -0
  205. package/dist/schemas/index.js +6 -0
  206. package/dist/schemas/index.js.map +1 -0
  207. package/dist/schemas/policy.d.ts +2 -0
  208. package/dist/schemas/policy.d.ts.map +1 -0
  209. package/dist/schemas/policy.js +2 -0
  210. package/dist/schemas/policy.js.map +1 -0
  211. package/dist/schemas/redactor.d.ts +2 -0
  212. package/dist/schemas/redactor.d.ts.map +1 -0
  213. package/dist/schemas/redactor.js +2 -0
  214. package/dist/schemas/redactor.js.map +1 -0
  215. package/dist/schemas/report-event.d.ts +29 -0
  216. package/dist/schemas/report-event.d.ts.map +1 -0
  217. package/dist/schemas/report-event.js +19 -0
  218. package/dist/schemas/report-event.js.map +1 -0
  219. package/dist/schemas/scanner.d.ts +2 -0
  220. package/dist/schemas/scanner.d.ts.map +1 -0
  221. package/dist/schemas/scanner.js +2 -0
  222. package/dist/schemas/scanner.js.map +1 -0
  223. package/dist/security-client/index.d.ts +3 -0
  224. package/dist/security-client/index.d.ts.map +1 -0
  225. package/dist/security-client/index.js +2 -0
  226. package/dist/security-client/index.js.map +1 -0
  227. package/dist/security-client/security-client.d.ts +34 -0
  228. package/dist/security-client/security-client.d.ts.map +1 -0
  229. package/dist/security-client/security-client.js +54 -0
  230. package/dist/security-client/security-client.js.map +1 -0
  231. package/dist/security.consumer.plugin.d.ts +3 -0
  232. package/dist/security.consumer.plugin.d.ts.map +1 -0
  233. package/dist/security.consumer.plugin.js +28 -0
  234. package/dist/security.consumer.plugin.js.map +1 -0
  235. package/dist/security.plugin.d.ts +16 -0
  236. package/dist/security.plugin.d.ts.map +1 -0
  237. package/dist/security.plugin.js +78 -0
  238. package/dist/security.plugin.js.map +1 -0
  239. package/dist/svelte/index.d.ts +3 -0
  240. package/dist/svelte/index.d.ts.map +1 -0
  241. package/dist/svelte/index.js +2 -0
  242. package/dist/svelte/security-svelte.plugin.d.ts +3 -0
  243. package/dist/svelte/security-svelte.plugin.d.ts.map +1 -0
  244. package/dist/svelte/security-svelte.plugin.js +38 -0
  245. package/dist/svelte/styles.css +8 -0
  246. package/dist/svelte/tool-widgets/SecurityToolCard.svelte +140 -0
  247. package/dist/svelte/tool-widgets/SecurityToolCard.svelte.d.ts +5 -0
  248. package/dist/svelte/tool-widgets/SecurityToolCard.svelte.d.ts.map +1 -0
  249. package/dist/svelte/tool-widgets/index.d.ts +2 -0
  250. package/dist/svelte/tool-widgets/index.d.ts.map +1 -0
  251. package/dist/svelte/tool-widgets/index.js +6 -0
  252. package/dist/tools/check-policy/check-policy.descriptor.d.ts +37 -0
  253. package/dist/tools/check-policy/check-policy.descriptor.d.ts.map +1 -0
  254. package/dist/tools/check-policy/check-policy.descriptor.js +21 -0
  255. package/dist/tools/check-policy/check-policy.descriptor.js.map +1 -0
  256. package/dist/tools/check-policy/check-policy.impl.consumer.d.ts +7 -0
  257. package/dist/tools/check-policy/check-policy.impl.consumer.d.ts.map +1 -0
  258. package/dist/tools/check-policy/check-policy.impl.consumer.js +21 -0
  259. package/dist/tools/check-policy/check-policy.impl.consumer.js.map +1 -0
  260. package/dist/tools/check-policy/index.d.ts +3 -0
  261. package/dist/tools/check-policy/index.d.ts.map +1 -0
  262. package/dist/tools/check-policy/index.js +2 -0
  263. package/dist/tools/check-policy/index.js.map +1 -0
  264. package/dist/tools/check-policy/schemas.d.ts +23 -0
  265. package/dist/tools/check-policy/schemas.d.ts.map +1 -0
  266. package/dist/tools/check-policy/schemas.js +13 -0
  267. package/dist/tools/check-policy/schemas.js.map +1 -0
  268. package/dist/tools/index.d.ts +10 -0
  269. package/dist/tools/index.d.ts.map +1 -0
  270. package/dist/tools/index.js +6 -0
  271. package/dist/tools/index.js.map +1 -0
  272. package/dist/tools/redact-output/index.d.ts +3 -0
  273. package/dist/tools/redact-output/index.d.ts.map +1 -0
  274. package/dist/tools/redact-output/index.js +2 -0
  275. package/dist/tools/redact-output/index.js.map +1 -0
  276. package/dist/tools/redact-output/redact-output.descriptor.d.ts +42 -0
  277. package/dist/tools/redact-output/redact-output.descriptor.d.ts.map +1 -0
  278. package/dist/tools/redact-output/redact-output.descriptor.js +21 -0
  279. package/dist/tools/redact-output/redact-output.descriptor.js.map +1 -0
  280. package/dist/tools/redact-output/redact-output.impl.consumer.d.ts +7 -0
  281. package/dist/tools/redact-output/redact-output.impl.consumer.d.ts.map +1 -0
  282. package/dist/tools/redact-output/redact-output.impl.consumer.js +18 -0
  283. package/dist/tools/redact-output/redact-output.impl.consumer.js.map +1 -0
  284. package/dist/tools/redact-output/schemas.d.ts +28 -0
  285. package/dist/tools/redact-output/schemas.d.ts.map +1 -0
  286. package/dist/tools/redact-output/schemas.js +13 -0
  287. package/dist/tools/redact-output/schemas.js.map +1 -0
  288. package/dist/tools/report-event/index.d.ts +3 -0
  289. package/dist/tools/report-event/index.d.ts.map +1 -0
  290. package/dist/tools/report-event/index.js +2 -0
  291. package/dist/tools/report-event/index.js.map +1 -0
  292. package/dist/tools/report-event/report-event.descriptor.d.ts +43 -0
  293. package/dist/tools/report-event/report-event.descriptor.d.ts.map +1 -0
  294. package/dist/tools/report-event/report-event.descriptor.js +21 -0
  295. package/dist/tools/report-event/report-event.descriptor.js.map +1 -0
  296. package/dist/tools/report-event/report-event.impl.consumer.d.ts +24 -0
  297. package/dist/tools/report-event/report-event.impl.consumer.d.ts.map +1 -0
  298. package/dist/tools/report-event/report-event.impl.consumer.js +61 -0
  299. package/dist/tools/report-event/report-event.impl.consumer.js.map +1 -0
  300. package/dist/tools/report-event/schemas.d.ts +2 -0
  301. package/dist/tools/report-event/schemas.d.ts.map +1 -0
  302. package/dist/tools/report-event/schemas.js +3 -0
  303. package/dist/tools/report-event/schemas.js.map +1 -0
  304. package/dist/tools/scan-input/index.d.ts +3 -0
  305. package/dist/tools/scan-input/index.d.ts.map +1 -0
  306. package/dist/tools/scan-input/index.js +2 -0
  307. package/dist/tools/scan-input/index.js.map +1 -0
  308. package/dist/tools/scan-input/scan-input.descriptor.d.ts +49 -0
  309. package/dist/tools/scan-input/scan-input.descriptor.d.ts.map +1 -0
  310. package/dist/tools/scan-input/scan-input.descriptor.js +21 -0
  311. package/dist/tools/scan-input/scan-input.descriptor.js.map +1 -0
  312. package/dist/tools/scan-input/scan-input.impl.consumer.d.ts +7 -0
  313. package/dist/tools/scan-input/scan-input.impl.consumer.d.ts.map +1 -0
  314. package/dist/tools/scan-input/scan-input.impl.consumer.js +22 -0
  315. package/dist/tools/scan-input/scan-input.impl.consumer.js.map +1 -0
  316. package/dist/tools/scan-input/schemas.d.ts +36 -0
  317. package/dist/tools/scan-input/schemas.d.ts.map +1 -0
  318. package/dist/tools/scan-input/schemas.js +15 -0
  319. package/dist/tools/scan-input/schemas.js.map +1 -0
  320. package/dist/tools/security-tool-card.d.ts +13 -0
  321. package/dist/tools/security-tool-card.d.ts.map +1 -0
  322. package/dist/tools/security-tool-card.js +171 -0
  323. package/dist/tools/security-tool-card.js.map +1 -0
  324. package/dist/tools/security.docs.descriptor.d.ts +17 -0
  325. package/dist/tools/security.docs.descriptor.d.ts.map +1 -0
  326. package/dist/tools/security.docs.descriptor.js +49 -0
  327. package/dist/tools/security.docs.descriptor.js.map +1 -0
  328. package/dist/tui/index.d.ts +2 -0
  329. package/dist/tui/index.d.ts.map +1 -0
  330. package/dist/tui/index.js +2 -0
  331. package/dist/tui/index.js.map +1 -0
  332. package/dist/tui/security-tui.plugin.d.ts +3 -0
  333. package/dist/tui/security-tui.plugin.d.ts.map +1 -0
  334. package/dist/tui/security-tui.plugin.js +31 -0
  335. package/dist/tui/security-tui.plugin.js.map +1 -0
  336. package/dist/tui/tool-widgets/SecurityToolWidget.impl.consumer.d.ts +5 -0
  337. package/dist/tui/tool-widgets/SecurityToolWidget.impl.consumer.d.ts.map +1 -0
  338. package/dist/tui/tool-widgets/SecurityToolWidget.impl.consumer.js +37 -0
  339. package/dist/tui/tool-widgets/SecurityToolWidget.impl.consumer.js.map +1 -0
  340. package/docs/host-boundary.md +186 -0
  341. package/docs/scanner-work.md +29 -0
  342. package/package.json +245 -4
@@ -0,0 +1,17 @@
1
+ import type { ValidationErrorDetails } from '../schemas/contracts/misc.ts';
2
+ export type { ValidationErrorDetails, ValidationErrorDetailValue } from '../schemas/contracts/misc.ts';
3
+ import { CapabilityError } from '@vibesdotdev/kernel';
4
+ import type { ZodIssue } from 'zod/v4';
5
+ /**
6
+ * Validation error for consistent error handling across security utilities.
7
+ *
8
+ * A `CapabilityError` with the taxonomy code `INVALID_INPUT`. The caller's own
9
+ * validation code (`'CSRF_ERROR'`, `'VALIDATION_ERROR'`, …) is its `reason`.
10
+ * Record details are the error's `details`; Zod issues are its `issues`.
11
+ */
12
+ export declare class ValidationError extends CapabilityError {
13
+ /** The Zod issues that failed validation, when the caller passed them. */
14
+ readonly issues?: readonly ZodIssue[];
15
+ constructor(message: string, reason: string, details?: ValidationErrorDetails, options?: ErrorOptions);
16
+ }
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/implementations/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACvG,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IACnD,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,YAAY;CASrG"}
@@ -0,0 +1,23 @@
1
+ import { CapabilityError } from '@vibesdotdev/kernel';
2
+ /**
3
+ * Validation error for consistent error handling across security utilities.
4
+ *
5
+ * A `CapabilityError` with the taxonomy code `INVALID_INPUT`. The caller's own
6
+ * validation code (`'CSRF_ERROR'`, `'VALIDATION_ERROR'`, …) is its `reason`.
7
+ * Record details are the error's `details`; Zod issues are its `issues`.
8
+ */
9
+ export class ValidationError extends CapabilityError {
10
+ /** The Zod issues that failed validation, when the caller passed them. */
11
+ issues;
12
+ constructor(message, reason, details, options) {
13
+ super(message, 'INVALID_INPUT', {
14
+ reason,
15
+ details: Array.isArray(details) ? undefined : details,
16
+ cause: options?.cause
17
+ });
18
+ this.name = 'ValidationError';
19
+ if (Array.isArray(details))
20
+ this.issues = details;
21
+ }
22
+ }
23
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/implementations/errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,eAAe;IACnD,0EAA0E;IACjE,MAAM,CAAuB;IAEtC,YAAY,OAAe,EAAE,MAAc,EAAE,OAAgC,EAAE,OAAsB;QACpG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE;YAC/B,MAAM;YACN,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;YACrD,KAAK,EAAE,OAAO,EAAE,KAAK;SACrB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;IACnD,CAAC;CACD"}
@@ -0,0 +1,24 @@
1
+ export type { EncryptionKeyRuntime, KeyFileSystem } from '../schemas/encryption.ts';
2
+ import { type EncryptionKeyRuntime, type KeyFileSystem } from '../schemas/encryption.ts';
3
+ import { type RuntimeRef } from '@vibesdotdev/kernel';
4
+ export declare const SECRET_ENCRYPTION_KEY_CREDENTIAL: {
5
+ readonly source: "secret";
6
+ readonly key: "SECRET_ENCRYPTION_KEY";
7
+ };
8
+ export declare function readOrCreateKeyFile(configDir: string, fs?: KeyFileSystem): string;
9
+ export declare function boundEncryptionKeyHex(runtime: Pick<RuntimeRef, 'resolveCredential'>): Promise<string | null>;
10
+ /**
11
+ * The runtime's encryption key: the `SECRET_ENCRYPTION_KEY` credential bound in
12
+ * the Secrets owner (`runtime.resolveCredential`), else, on a non-cloud host,
13
+ * the key persisted under the config root. A cloud host without a bound key is
14
+ * refused. The host environment is never consulted.
15
+ */
16
+ export declare function resolveEncryptionKeyHex(runtime: EncryptionKeyRuntime): Promise<string>;
17
+ /**
18
+ * The key co-located with an encrypted store under `baseDir`. This is the
19
+ * store's own root of trust, so it cannot resolve through the Secrets owner it
20
+ * unlocks: the host-bound `SECRET_ENCRYPTION_KEY` is the one declared host read,
21
+ * else the key persisted under `{baseDir}/config`.
22
+ */
23
+ export declare function resolveEncryptionKeyHexForBase(runtime: Pick<RuntimeRef, 'getEnv'>, baseDir: string): string;
24
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/implementations/keys.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAA2C,KAAK,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClI,OAAO,EAA4D,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOhH,eAAO,MAAM,gCAAgC;;;CAGL,CAAC;AAsDzC,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAE,aAAgC,GAAG,MAAM,CAenG;AAiBD,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC,GAC5C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxB;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAK5F;AAED;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EACnC,OAAO,EAAE,MAAM,GACb,MAAM,CAIR"}
@@ -0,0 +1,114 @@
1
+ import { KeyFileSystemSchema, parseEncryptionKey } from "../schemas/encryption.js";
2
+ import { CapabilityError, CaughtFailureSchema } from '@vibesdotdev/kernel';
3
+ import { getPathRoots } from '@vibesdotdev/paths';
4
+ import { z } from 'zod/v4';
5
+ const ENCRYPTION_KEY_LENGTH = 32;
6
+ export const SECRET_ENCRYPTION_KEY_CREDENTIAL = {
7
+ source: 'secret',
8
+ key: 'SECRET_ENCRYPTION_KEY'
9
+ };
10
+ const UNBOUND_CREDENTIAL_REASONS = new Set(['credential-not-set', 'no-store']);
11
+ function generateKeyHex() {
12
+ const bytes = new Uint8Array(ENCRYPTION_KEY_LENGTH);
13
+ crypto.getRandomValues(bytes);
14
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
15
+ }
16
+ function hostFileSystem() {
17
+ const fsModule = globalThis.process?.getBuiltinModule?.('node:fs');
18
+ if (!fsModule) {
19
+ throw new CapabilityError('This host has no filesystem for a persisted encryption key; configure SECRET_ENCRYPTION_KEY.', 'UNAVAILABLE', { reason: 'encryption-key-unconfigured', retryable: false });
20
+ }
21
+ return fsModule;
22
+ }
23
+ const ErrnoSchema = z.object({ code: z.string() });
24
+ function hasErrnoCode(failure) {
25
+ return failure instanceof Error && ErrnoSchema.safeParse(failure).success;
26
+ }
27
+ function errnoCode(failure) {
28
+ return hasErrnoCode(failure) ? failure.code : null;
29
+ }
30
+ function keyFileError(keyPath, action, cause) {
31
+ return new CapabilityError(`The encryption key file ${keyPath} could not be ${action}.`, 'UNAVAILABLE', {
32
+ reason: 'encryption-key-unreadable',
33
+ retryable: false,
34
+ details: { path: keyPath, code: errnoCode(cause) },
35
+ cause
36
+ });
37
+ }
38
+ function readKeyFile(fs, keyPath) {
39
+ try {
40
+ return parseEncryptionKey(String(fs.readFileSync(keyPath, 'utf-8')).trim());
41
+ }
42
+ catch (error) {
43
+ if (error instanceof CapabilityError)
44
+ throw error;
45
+ const failure = CaughtFailureSchema.parse(error);
46
+ if (hasErrnoCode(failure) && failure.code === 'ENOENT')
47
+ return null;
48
+ throw keyFileError(keyPath, 'read', failure);
49
+ }
50
+ }
51
+ export function readOrCreateKeyFile(configDir, fs = hostFileSystem()) {
52
+ fs = KeyFileSystemSchema.parse(fs);
53
+ const keyPath = `${configDir.replace(/[\\/]+$/, '')}/encryption.key`;
54
+ const existing = readKeyFile(fs, keyPath);
55
+ if (existing)
56
+ return existing;
57
+ const generated = generateKeyHex();
58
+ try {
59
+ fs.mkdirSync(configDir, { recursive: true });
60
+ fs.writeFileSync(keyPath, generated, { mode: 0o600, flag: 'wx' });
61
+ return generated;
62
+ }
63
+ catch (error) {
64
+ const failure = CaughtFailureSchema.parse(error);
65
+ if (hasErrnoCode(failure) && failure.code === 'EEXIST')
66
+ return readWinnerKey(fs, keyPath, failure);
67
+ throw keyFileError(keyPath, 'written', failure);
68
+ }
69
+ }
70
+ function readWinnerKey(fs, keyPath, lostRace) {
71
+ const winner = readKeyFile(fs, keyPath);
72
+ if (!winner)
73
+ throw keyFileError(keyPath, 'read after a concurrent create', lostRace);
74
+ return winner;
75
+ }
76
+ function cloudKeyUnconfigured() {
77
+ return new CapabilityError('SECRET_ENCRYPTION_KEY must be bound on a cloud host. ' +
78
+ `Provide a ${ENCRYPTION_KEY_LENGTH * 2}-character hex string (${ENCRYPTION_KEY_LENGTH} bytes).`, 'UNAVAILABLE', { reason: 'encryption-key-unconfigured', retryable: false });
79
+ }
80
+ export async function boundEncryptionKeyHex(runtime) {
81
+ const resolved = await runtime.resolveCredential(SECRET_ENCRYPTION_KEY_CREDENTIAL);
82
+ if (resolved.ok)
83
+ return resolved.value;
84
+ if (UNBOUND_CREDENTIAL_REASONS.has(resolved.error.reason))
85
+ return null;
86
+ throw resolved.error;
87
+ }
88
+ /**
89
+ * The runtime's encryption key: the `SECRET_ENCRYPTION_KEY` credential bound in
90
+ * the Secrets owner (`runtime.resolveCredential`), else, on a non-cloud host,
91
+ * the key persisted under the config root. A cloud host without a bound key is
92
+ * refused. The host environment is never consulted.
93
+ */
94
+ export async function resolveEncryptionKeyHex(runtime) {
95
+ const bound = await boundEncryptionKeyHex(runtime);
96
+ if (bound)
97
+ return parseEncryptionKey(bound);
98
+ if (runtime.scope.hardware === 'cloud')
99
+ throw cloudKeyUnconfigured();
100
+ return readOrCreateKeyFile(getPathRoots(runtime).configDir);
101
+ }
102
+ /**
103
+ * The key co-located with an encrypted store under `baseDir`. This is the
104
+ * store's own root of trust, so it cannot resolve through the Secrets owner it
105
+ * unlocks: the host-bound `SECRET_ENCRYPTION_KEY` is the one declared host read,
106
+ * else the key persisted under `{baseDir}/config`.
107
+ */
108
+ export function resolveEncryptionKeyHexForBase(runtime, baseDir) {
109
+ const configured = runtime.getEnv('SECRET_ENCRYPTION_KEY');
110
+ if (configured)
111
+ return parseEncryptionKey(configured);
112
+ return readOrCreateKeyFile(`${baseDir.replace(/[\\/]+$/, '')}/config`);
113
+ }
114
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/implementations/keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAiD,MAAM,0BAA0B,CAAC;AAClI,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAuC,MAAM,qBAAqB,CAAC;AAEhH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC/C,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,uBAAuB;CACW,CAAC;AAEzC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAAC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AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAA6B;IAC1E,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,KAAK;QAAE,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO;QAAE,MAAM,oBAAoB,EAAE,CAAC;IACrE,OAAO,mBAAmB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AAEH,MAAM,UAAU,8BAA8B,CAC7C,OAAmC,EACnC,OAAe;IAEf,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAC3D,IAAI,UAAU;QAAE,OAAO,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACtD,OAAO,mBAAmB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { CapabilityError } from '@vibesdotdev/kernel';
2
+ import { type RedactionRule, type RedactionRuleInput } from '../schemas/RedactionRule.ts';
3
+ import { type SecurityRedactorResult } from '../schemas/redactor.ts';
4
+ /** The rules a built-in redactor applies when the caller supplies none. */
5
+ export declare const DEFAULT_REDACTION_RULES: RedactionRule[];
6
+ /**
7
+ * Built-in admission shared by every built-in redactor: content and rule-count
8
+ * limits, then each applied rule's regex source compiles. Value-free refusals.
9
+ */
10
+ export declare function admitBuiltinRedaction(content: string, rules?: RedactionRuleInput[]): {
11
+ content: string;
12
+ rules: {
13
+ id: string;
14
+ name: string;
15
+ pattern: string;
16
+ replacement: string;
17
+ target: "metadata" | "content" | "header";
18
+ enabled: boolean;
19
+ }[];
20
+ };
21
+ export declare function redactionBudgetExceeded(): CapabilityError;
22
+ /** Admit span output (in-process value or the child's parsed stdout); a budget outcome refuses. */
23
+ export declare function admitRedactionOutput(output: unknown): SecurityRedactorResult;
24
+ //# sourceMappingURL=redaction-admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction-admission.d.ts","sourceRoot":"","sources":["../../src/implementations/redaction-admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyC,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAA6D,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhI,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,EAAE,aAAa,EAIlD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,kBAAkB,EAA4B;;;;;;;;;;EAe3G;AAED,wBAAgB,uBAAuB,IAAI,eAAe,CAIzD;AAKD,mGAAmG;AACnG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,sBAAsB,CAI5E"}
@@ -0,0 +1,44 @@
1
+ import { CapabilityError, CaughtFailureSchema, valueFreeFailure } from '@vibesdotdev/kernel';
2
+ import {} from "../schemas/RedactionRule.js";
3
+ import * as z from 'zod/v4';
4
+ import { BuiltinRedactionInputSchema, SecurityRedactorResultSchema } from "../schemas/redactor.js";
5
+ /** The rules a built-in redactor applies when the caller supplies none. */
6
+ export const DEFAULT_REDACTION_RULES = [
7
+ { id: 'email', name: 'Email', pattern: '(?<!href=")[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}', replacement: '[EMAIL REDACTED]', enabled: true, target: 'content' },
8
+ { id: 'ssn', name: 'SSN', pattern: '\\b\\d{3}[-.\\s]?\\d{2}[-.\\s]?\\d{4}\\b', replacement: '[SSN REDACTED]', enabled: true, target: 'content' },
9
+ { id: 'key', name: 'API Key', pattern: '(?<![a-zA-Z0-9])(sk-|pk_)[a-zA-Z0-9]{20,}', replacement: '[API KEY REDACTED]', enabled: true, target: 'content' }
10
+ ];
11
+ /**
12
+ * Built-in admission shared by every built-in redactor: content and rule-count
13
+ * limits, then each applied rule's regex source compiles. Value-free refusals.
14
+ */
15
+ export function admitBuiltinRedaction(content, rules = DEFAULT_REDACTION_RULES) {
16
+ const input = BuiltinRedactionInputSchema.parse({ content, rules });
17
+ for (const rule of input.rules) {
18
+ if (!rule.enabled || rule.target !== 'content')
19
+ continue;
20
+ try {
21
+ new RegExp(rule.pattern, 'g');
22
+ }
23
+ catch (cause) {
24
+ throw new CapabilityError('The redaction pattern is invalid.', 'INVALID_INPUT', {
25
+ reason: 'redaction-pattern-invalid', retryable: false, details: { ruleId: rule.id, failure: valueFreeFailure(CaughtFailureSchema.parse(cause)) }
26
+ });
27
+ }
28
+ }
29
+ return input;
30
+ }
31
+ export function redactionBudgetExceeded() {
32
+ return new CapabilityError('Redaction exceeded its execution budget.', 'UNAVAILABLE', {
33
+ reason: 'redaction-budget-exceeded', retryable: false
34
+ });
35
+ }
36
+ /** `redactSpans` output from either path: a result, or the value-free budget outcome. */
37
+ const RedactionBudgetOutcomeSchema = z.object({ budgetExceeded: z.literal(true) });
38
+ /** Admit span output (in-process value or the child's parsed stdout); a budget outcome refuses. */
39
+ export function admitRedactionOutput(output) {
40
+ if (RedactionBudgetOutcomeSchema.safeParse(output).success)
41
+ throw redactionBudgetExceeded();
42
+ return SecurityRedactorResultSchema.parse(output);
43
+ }
44
+ //# sourceMappingURL=redaction-admission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction-admission.js","sourceRoot":"","sources":["../../src/implementations/redaction-admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAA+C,MAAM,6BAA6B,CAAC;AAC1F,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OA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BAAgB,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;aACnJ,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,uBAAuB;IACnC,OAAO,IAAI,eAAe,CAAC,0CAA0C,EAAE,aAAa,EAAE;QAClF,MAAM,EAAE,2BAA2B,EAAE,SAAS,EAAE,KAAK;KACxD,CAAC,CAAC;AACP,CAAC;AAED,yFAAyF;AACzF,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEnF,mGAAmG;AACnG,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAChD,IAAI,4BAA4B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO;QACtD,MAAM,uBAAuB,EAAE,CAAC;IACpC,OAAO,4BAA4B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { RedactionRule } from '../schemas/RedactionRule.ts';
2
+ /**
3
+ * The most candidate spans one call may collect across every rule. Content is
4
+ * capped at 262,144 code units and rules at 64, so without this bound a
5
+ * zero-width rule set could hold millions of spans. Each `exec` that matches
6
+ * adds one span, so this also bounds the number of regex steps.
7
+ */
8
+ export declare const MAX_REDACTION_CANDIDATES = 65536;
9
+ /**
10
+ * Pure span redaction shared by every built-in redactor. Self-contained: the
11
+ * subprocess implementation ships this function's source into its child, so it
12
+ * references nothing outside its own body. All coordinates are original UTF-16
13
+ * offsets. Returns `{ budgetExceeded: true }` instead of a result once
14
+ * `maxCandidates` spans would be exceeded.
15
+ */
16
+ export declare function redactSpans(content: string, rules: RedactionRule[], maxCandidates: number): {
17
+ budgetExceeded: true;
18
+ redacted?: undefined;
19
+ matches?: undefined;
20
+ redactorAvailable?: undefined;
21
+ } | {
22
+ redacted: string;
23
+ matches: {
24
+ pattern: string;
25
+ index: number;
26
+ length: number;
27
+ replacement: string;
28
+ }[];
29
+ redactorAvailable: boolean;
30
+ budgetExceeded?: undefined;
31
+ };
32
+ //# sourceMappingURL=redaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../src/implementations/redaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,aAAa,EAAE,MAAM;;;;;;;;;;;;;;;EAiCzF"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The most candidate spans one call may collect across every rule. Content is
3
+ * capped at 262,144 code units and rules at 64, so without this bound a
4
+ * zero-width rule set could hold millions of spans. Each `exec` that matches
5
+ * adds one span, so this also bounds the number of regex steps.
6
+ */
7
+ export const MAX_REDACTION_CANDIDATES = 65_536;
8
+ /**
9
+ * Pure span redaction shared by every built-in redactor. Self-contained: the
10
+ * subprocess implementation ships this function's source into its child, so it
11
+ * references nothing outside its own body. All coordinates are original UTF-16
12
+ * offsets. Returns `{ budgetExceeded: true }` instead of a result once
13
+ * `maxCandidates` spans would be exceeded.
14
+ */
15
+ export function redactSpans(content, rules, maxCandidates) {
16
+ const candidates = [];
17
+ for (const [order, rule] of rules.entries()) {
18
+ if (!rule.enabled || rule.target !== 'content')
19
+ continue;
20
+ const pattern = new RegExp(rule.pattern, 'g');
21
+ let match;
22
+ while ((match = pattern.exec(content)) !== null) {
23
+ if (candidates.length >= maxCandidates)
24
+ return { budgetExceeded: true };
25
+ candidates.push({ pattern: rule.pattern, index: match.index, length: match[0].length, replacement: rule.replacement, order });
26
+ if (match[0].length === 0)
27
+ pattern.lastIndex = match.index + 1;
28
+ }
29
+ }
30
+ // Earlier start wins; caller rule order breaks ties. An accepted span excludes overlapping spans.
31
+ candidates.sort((a, b) => a.index - b.index || a.order - b.order);
32
+ const matches = [];
33
+ let cursor = 0;
34
+ let redacted = '';
35
+ let lastStart = -1;
36
+ for (const { order: _order, ...match } of candidates) {
37
+ if (match.index < cursor || match.index === lastStart)
38
+ continue;
39
+ redacted += content.slice(cursor, match.index) + match.replacement;
40
+ cursor = match.index + match.length;
41
+ lastStart = match.index;
42
+ matches.push(match);
43
+ }
44
+ redacted += content.slice(cursor);
45
+ return { redacted, matches, redactorAvailable: true };
46
+ }
47
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../../src/implementations/redaction.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAsB,EAAE,aAAqB;IACtF,MAAM,UAAU,GAEX,EAAE,CAAC;IACR,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAC1C,SAAS;QACb,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC9C,IAAI,KAA6B,CAAC;QAClC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC9C,IAAI,UAAU,CAAC,MAAM,IAAI,aAAa;gBAClC,OAAO,EAAE,cAAc,EAAE,IAAa,EAAE,CAAC;YAC7C,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK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}
@@ -0,0 +1,30 @@
1
+ import type { KindContext } from '@vibesdotdev/kernel';
2
+ import { type RedactionRuleInput } from '../schemas/RedactionRule.ts';
3
+ import type { SecurityRedactorDescriptor } from '../schemas/redactor.ts';
4
+ /**
5
+ * Built-in redactor for every hardware that cannot spawn a supervised child
6
+ * (Cloudflare Workers, browsers). Same admission, same span semantics and the
7
+ * same candidate budget as the subprocess redactor, run in the caller's isolate.
8
+ *
9
+ * Bounds: content 262,144 code units, 64 rules, 4,096-unit patterns, and at
10
+ * most MAX_REDACTION_CANDIDATES spans (which also bounds regex steps). There is
11
+ * no wall-clock deadline: workerd freezes `Date.now()`/`performance.now()`
12
+ * during synchronous compute, so a clock check could never fire, and one
13
+ * `RegExp.exec` cannot be interrupted in-process. The host's CPU limit is the
14
+ * backstop for a single catastrophically backtracking caller pattern.
15
+ */
16
+ export default class InProcessRedactor {
17
+ readonly descriptor: SecurityRedactorDescriptor;
18
+ constructor(descriptor: SecurityRedactorDescriptor, _context: KindContext);
19
+ redact(content: string, rules?: RedactionRuleInput[]): Promise<{
20
+ redacted: string;
21
+ matches: {
22
+ pattern: string;
23
+ index: number;
24
+ length: number;
25
+ replacement: string;
26
+ }[];
27
+ redactorAvailable: boolean;
28
+ }>;
29
+ }
30
+ //# sourceMappingURL=redactor.inprocess.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactor.inprocess.impl.d.ts","sourceRoot":"","sources":["../../src/implementations/redactor.inprocess.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAIzE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACtB,QAAQ,CAAC,UAAU,EAAE,0BAA0B;gBAAtC,UAAU,EAAE,0BAA0B,EAAE,QAAQ,EAAE,WAAW;IAC5E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,kBAAkB,EAAE;;;;;;;;;;CAI7D"}
@@ -0,0 +1,26 @@
1
+ import {} from "../schemas/RedactionRule.js";
2
+ import { MAX_REDACTION_CANDIDATES, redactSpans } from "./redaction.js";
3
+ import { admitBuiltinRedaction, admitRedactionOutput } from "./redaction-admission.js";
4
+ /**
5
+ * Built-in redactor for every hardware that cannot spawn a supervised child
6
+ * (Cloudflare Workers, browsers). Same admission, same span semantics and the
7
+ * same candidate budget as the subprocess redactor, run in the caller's isolate.
8
+ *
9
+ * Bounds: content 262,144 code units, 64 rules, 4,096-unit patterns, and at
10
+ * most MAX_REDACTION_CANDIDATES spans (which also bounds regex steps). There is
11
+ * no wall-clock deadline: workerd freezes `Date.now()`/`performance.now()`
12
+ * during synchronous compute, so a clock check could never fire, and one
13
+ * `RegExp.exec` cannot be interrupted in-process. The host's CPU limit is the
14
+ * backstop for a single catastrophically backtracking caller pattern.
15
+ */
16
+ export default class InProcessRedactor {
17
+ descriptor;
18
+ constructor(descriptor, _context) {
19
+ this.descriptor = descriptor;
20
+ }
21
+ async redact(content, rules) {
22
+ const input = admitBuiltinRedaction(content, rules);
23
+ return admitRedactionOutput(redactSpans(input.content, input.rules, MAX_REDACTION_CANDIDATES));
24
+ }
25
+ }
26
+ //# sourceMappingURL=redactor.inprocess.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactor.inprocess.impl.js","sourceRoot":"","sources":["../../src/implementations/redactor.inprocess.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEvF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACb;IAArB,YAAqB,UAAsC,EAAE,QAAqB;QAA7D,eAAU,GAAV,UAAU,CAA4B;IAA2B,CAAC;IACvF,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,KAA4B;QACtD,MAAM,KAAK,GAAG,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC;IACnG,CAAC;CACJ"}
@@ -0,0 +1,25 @@
1
+ import { type KindContext } from '@vibesdotdev/kernel';
2
+ import { type RedactionRuleInput } from '../schemas/RedactionRule.ts';
3
+ import type { SecurityRedactorDescriptor } from '../schemas/redactor.ts';
4
+ /**
5
+ * Consumer-hardware built-in redactor. Matching runs in the execution owner's
6
+ * supervised Node child, so a catastrophically backtracking caller pattern is
7
+ * preempted at a one-second deadline instead of blocking the host's event loop.
8
+ * This preemption is what the in-process redactor cannot provide.
9
+ */
10
+ export default class SubprocessRedactor {
11
+ readonly descriptor: SecurityRedactorDescriptor;
12
+ private readonly context;
13
+ constructor(descriptor: SecurityRedactorDescriptor, context: KindContext);
14
+ redact(content: string, rules?: RedactionRuleInput[]): Promise<{
15
+ redacted: string;
16
+ matches: {
17
+ pattern: string;
18
+ index: number;
19
+ length: number;
20
+ replacement: string;
21
+ }[];
22
+ redactorAvailable: boolean;
23
+ }>;
24
+ }
25
+ //# sourceMappingURL=redactor.subprocess.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactor.subprocess.impl.d.ts","sourceRoot":"","sources":["../../src/implementations/redactor.subprocess.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAIzE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACvB,QAAQ,CAAC,UAAU,EAAE,0BAA0B;IAAE,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAhE,UAAU,EAAE,0BAA0B,EAAmB,OAAO,EAAE,WAAW;IAC5F,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,kBAAkB,EAAE;;;;;;;;;;CAsB7D"}
@@ -0,0 +1,42 @@
1
+ import { CapabilityError } from '@vibesdotdev/kernel';
2
+ import { runTimedCapture, whichCommand } from '@vibesdotdev/kernel/execution';
3
+ import {} from "../schemas/RedactionRule.js";
4
+ import { MAX_REDACTION_CANDIDATES, redactSpans } from "./redaction.js";
5
+ import { admitBuiltinRedaction, admitRedactionOutput, redactionBudgetExceeded } from "./redaction-admission.js";
6
+ /**
7
+ * Consumer-hardware built-in redactor. Matching runs in the execution owner's
8
+ * supervised Node child, so a catastrophically backtracking caller pattern is
9
+ * preempted at a one-second deadline instead of blocking the host's event loop.
10
+ * This preemption is what the in-process redactor cannot provide.
11
+ */
12
+ export default class SubprocessRedactor {
13
+ descriptor;
14
+ context;
15
+ constructor(descriptor, context) {
16
+ this.descriptor = descriptor;
17
+ this.context = context;
18
+ }
19
+ async redact(content, rules) {
20
+ const input = admitBuiltinRedaction(content, rules);
21
+ const command = await whichCommand(this.context.runtime, 'node');
22
+ if (!command)
23
+ throw new CapabilityError('A JavaScript execution host is required for bounded redaction.', 'UNAVAILABLE', {
24
+ reason: 'redaction-execution-unavailable', retryable: false
25
+ });
26
+ // Input stays on stdin, never argv. Execution owns the child, deadline and process-tree termination.
27
+ const program = `let input=''; for await (const chunk of process.stdin) input+=chunk;
28
+ const {content,rules}=JSON.parse(input);
29
+ process.stdout.write(JSON.stringify((${redactSpans.toString()})(content,rules,${MAX_REDACTION_CANDIDATES})));`;
30
+ const result = await runTimedCapture(this.context.runtime, command, ['--input-type=module', '-e', program], {
31
+ envMode: 'replace', env: {}, stdin: JSON.stringify(input), timeoutMs: 1000
32
+ });
33
+ if (result.timedOut)
34
+ throw redactionBudgetExceeded();
35
+ if (result.exitCode !== 0)
36
+ throw new CapabilityError('The redaction execution failed.', 'UNAVAILABLE', {
37
+ reason: 'redaction-execution-failed', retryable: false
38
+ });
39
+ return admitRedactionOutput(JSON.parse(result.stdout));
40
+ }
41
+ }
42
+ //# sourceMappingURL=redactor.subprocess.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactor.subprocess.impl.js","sourceRoot":"","sources":["../../src/implementations/redactor.subprocess.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAA2B,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEhH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACd;IAAyD;IAA9E,YAAqB,UAAsC,EAAmB,OAAoB;QAA7E,eAAU,GAAV,UAAU,CAA4B;QAAmB,YAAO,GAAP,OAAO,CAAa;IAAI,CAAC;IACvG,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,KAA4B;QACtD,MAAM,KAAK,GAAG,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjE,IAAI,CAAC,OAAO;YACR,MAAM,IAAI,eAAe,CAAC,gEAAgE,EAAE,aAAa,EAAE;gBACvG,MAAM,EAAE,iCAAiC,EAAE,SAAS,EAAE,KAAK;aAC9D,CAAC,CAAC;QACP,qGAAqG;QACrG,MAAM,OAAO,GAAG;;0CAEkB,WAAW,CAAC,QAAQ,EAAE,mBAAmB,wBAAwB,MAAM,CAAC;QAC1G,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,qBAAqB,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE;YACxG,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI;SAC7E,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,QAAQ;YACf,MAAM,uBAAuB,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC;YACrB,MAAM,IAAI,eAAe,CAAC,iCAAiC,EAAE,aAAa,EAAE;gBACxE,MAAM,EAAE,4BAA4B,EAAE,SAAS,EAAE,KAAK;aACzD,CAAC,CAAC;QACP,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ"}
@@ -0,0 +1,7 @@
1
+ import type { SecurityScannerDescriptor, SecurityScannerOptionsInput, SecurityScannerResult } from '../schemas/scanner.ts';
2
+ export default class BuiltinScanner {
3
+ readonly descriptor: SecurityScannerDescriptor;
4
+ constructor(descriptor: SecurityScannerDescriptor);
5
+ scan(content: string, options?: SecurityScannerOptionsInput): Promise<SecurityScannerResult>;
6
+ }
7
+ //# sourceMappingURL=scanner.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.impl.d.ts","sourceRoot":"","sources":["../../src/implementations/scanner.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAmL3H,MAAM,CAAC,OAAO,OAAO,cAAc;IACtB,QAAQ,CAAC,UAAU,EAAE,yBAAyB;gBAArC,UAAU,EAAE,yBAAyB;IACpD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAOlG"}