resuxjs 0.3.11 → 0.4.0-beta.3

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 (361) hide show
  1. package/README.md +23 -1
  2. package/dist/bin.d.ts +1 -2
  3. package/dist/bin.js +5 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/build/index.d.ts +29 -0
  6. package/dist/build/index.js +51 -0
  7. package/dist/build/index.js.map +1 -0
  8. package/dist/cli.d.ts +19 -8
  9. package/dist/cli.js +2653 -3688
  10. package/dist/cli.js.map +1 -1
  11. package/dist/compiler/adapter.d.ts +19 -15
  12. package/dist/compiler/adapter.js +69 -93
  13. package/dist/compiler/adapter.js.map +1 -1
  14. package/dist/compiler/dev-warnings.d.ts +14 -10
  15. package/dist/compiler/dev-warnings.js +247 -319
  16. package/dist/compiler/dev-warnings.js.map +1 -1
  17. package/dist/compiler/directives.d.ts +7 -3
  18. package/dist/compiler/directives.js +125 -150
  19. package/dist/compiler/directives.js.map +1 -1
  20. package/dist/compiler/implementation.d.ts +117 -112
  21. package/dist/compiler/implementation.js +2954 -3426
  22. package/dist/compiler/index.d.ts +19 -15
  23. package/dist/compiler/index.js +69 -93
  24. package/dist/compiler/index.js.map +1 -1
  25. package/dist/core/config.d.ts +19 -10
  26. package/dist/core/config.js +42 -25
  27. package/dist/core/config.js.map +1 -1
  28. package/dist/core/hooks.d.ts +133 -131
  29. package/dist/core/hooks.js +45 -55
  30. package/dist/core/hooks.js.map +1 -1
  31. package/dist/core/index.d.ts +5 -4
  32. package/dist/core/index.js +6 -5
  33. package/dist/core/module-container.d.ts +97 -93
  34. package/dist/core/module-container.js +180 -185
  35. package/dist/core/module-container.js.map +1 -1
  36. package/dist/core/resux.d.ts +20 -15
  37. package/dist/core/resux.js +18 -13
  38. package/dist/core/resux.js.map +1 -1
  39. package/dist/create-bin.d.ts +1 -2
  40. package/dist/create-bin.js +5 -0
  41. package/dist/create-bin.js.map +1 -1
  42. package/dist/create.d.ts +6 -2
  43. package/dist/create.js +496 -638
  44. package/dist/create.js.map +1 -1
  45. package/dist/deploy/cloudflare.d.ts +7 -2
  46. package/dist/deploy/cloudflare.js +31 -34
  47. package/dist/deploy/cloudflare.js.map +1 -1
  48. package/dist/deploy/common.d.ts +19 -15
  49. package/dist/deploy/common.js +119 -188
  50. package/dist/deploy/common.js.map +1 -1
  51. package/dist/deploy/framework-runtime.d.ts +5 -1
  52. package/dist/deploy/framework-runtime.js +44 -48
  53. package/dist/deploy/framework-runtime.js.map +1 -1
  54. package/dist/deploy/index.d.ts +8 -3
  55. package/dist/deploy/index.js +56 -80
  56. package/dist/deploy/index.js.map +1 -1
  57. package/dist/deploy/netlify.d.ts +7 -2
  58. package/dist/deploy/netlify.js +41 -41
  59. package/dist/deploy/netlify.js.map +1 -1
  60. package/dist/deploy/node.d.ts +7 -2
  61. package/dist/deploy/node.js +24 -19
  62. package/dist/deploy/node.js.map +1 -1
  63. package/dist/deploy/production-report.d.ts +5 -1
  64. package/dist/deploy/production-report.js +15 -14
  65. package/dist/deploy/production-report.js.map +1 -1
  66. package/dist/deploy/runtime-dependencies.d.ts +8 -4
  67. package/dist/deploy/runtime-dependencies.js +158 -220
  68. package/dist/deploy/runtime-dependencies.js.map +1 -1
  69. package/dist/deploy/static.d.ts +7 -2
  70. package/dist/deploy/static.js +17 -14
  71. package/dist/deploy/static.js.map +1 -1
  72. package/dist/deploy/types.d.ts +33 -29
  73. package/dist/deploy/types.js +1 -2
  74. package/dist/deploy/vercel.d.ts +8 -3
  75. package/dist/deploy/vercel.js +138 -188
  76. package/dist/deploy/vercel.js.map +1 -1
  77. package/dist/fonts/index.d.ts +19 -14
  78. package/dist/fonts/index.js +115 -134
  79. package/dist/fonts/index.js.map +1 -1
  80. package/dist/globals.d.ts +79 -78
  81. package/dist/globals.js +1 -2
  82. package/dist/halal-core/ai/classifyProject.d.ts +9 -4
  83. package/dist/halal-core/ai/classifyProject.js +82 -95
  84. package/dist/halal-core/ai/classifyProject.js.map +1 -1
  85. package/dist/halal-core/ai/classifyRuntimeContent.d.ts +8 -3
  86. package/dist/halal-core/ai/classifyRuntimeContent.js +78 -95
  87. package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
  88. package/dist/halal-core/ai/createProjectSummary.d.ts +40 -36
  89. package/dist/halal-core/ai/createProjectSummary.js +39 -39
  90. package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
  91. package/dist/halal-core/ai/halalClassifierPrompt.d.ts +5 -1
  92. package/dist/halal-core/ai/halalClassifierPrompt.js +5 -1
  93. package/dist/halal-core/ai/halalClassifierPrompt.js.map +1 -1
  94. package/dist/halal-core/ai/redactSensitiveData.d.ts +5 -1
  95. package/dist/halal-core/ai/redactSensitiveData.js +82 -110
  96. package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
  97. package/dist/halal-core/ai/validateAiResponse.d.ts +7 -2
  98. package/dist/halal-core/ai/validateAiResponse.js +56 -83
  99. package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
  100. package/dist/halal-core/cli/check.d.ts +5 -1
  101. package/dist/halal-core/cli/check.js +28 -30
  102. package/dist/halal-core/cli/check.js.map +1 -1
  103. package/dist/halal-core/cli/explain.d.ts +5 -1
  104. package/dist/halal-core/cli/explain.js +27 -31
  105. package/dist/halal-core/cli/explain.js.map +1 -1
  106. package/dist/halal-core/cli/report.d.ts +5 -1
  107. package/dist/halal-core/cli/report.js +14 -10
  108. package/dist/halal-core/cli/report.js.map +1 -1
  109. package/dist/halal-core/cli/submitReview.d.ts +5 -1
  110. package/dist/halal-core/cli/submitReview.js +13 -9
  111. package/dist/halal-core/cli/submitReview.js.map +1 -1
  112. package/dist/halal-core/cli/verifyReview.d.ts +5 -1
  113. package/dist/halal-core/cli/verifyReview.js +17 -15
  114. package/dist/halal-core/cli/verifyReview.js.map +1 -1
  115. package/dist/halal-core/config.d.ts +39 -35
  116. package/dist/halal-core/config.js +77 -118
  117. package/dist/halal-core/config.js.map +1 -1
  118. package/dist/halal-core/crypto/integrity.d.ts +12 -8
  119. package/dist/halal-core/crypto/integrity.js +65 -87
  120. package/dist/halal-core/crypto/integrity.js.map +1 -1
  121. package/dist/halal-core/enforce.d.ts +9 -5
  122. package/dist/halal-core/enforce.js +90 -105
  123. package/dist/halal-core/enforce.js.map +1 -1
  124. package/dist/halal-core/index.d.ts +20 -16
  125. package/dist/halal-core/index.js +19 -19
  126. package/dist/halal-core/lifecycle.d.ts +5 -1
  127. package/dist/halal-core/lifecycle.js +16 -13
  128. package/dist/halal-core/lifecycle.js.map +1 -1
  129. package/dist/halal-core/policy.d.ts +7 -2
  130. package/dist/halal-core/policy.js +7 -2
  131. package/dist/halal-core/policy.js.map +1 -1
  132. package/dist/halal-core/report/formatBrowserOverlay.d.ts +7 -2
  133. package/dist/halal-core/report/formatBrowserOverlay.js +10 -8
  134. package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
  135. package/dist/halal-core/report/formatTerminalReport.d.ts +7 -2
  136. package/dist/halal-core/report/formatTerminalReport.js +27 -37
  137. package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
  138. package/dist/halal-core/report/generateHalalReport.d.ts +11 -6
  139. package/dist/halal-core/report/generateHalalReport.js +25 -27
  140. package/dist/halal-core/report/generateHalalReport.js.map +1 -1
  141. package/dist/halal-core/report/signReport.d.ts +8 -3
  142. package/dist/halal-core/report/signReport.js +17 -12
  143. package/dist/halal-core/report/signReport.js.map +1 -1
  144. package/dist/halal-core/report/verifyReport.d.ts +14 -9
  145. package/dist/halal-core/report/verifyReport.js +52 -41
  146. package/dist/halal-core/report/verifyReport.js.map +1 -1
  147. package/dist/halal-core/review/createReviewRequest.d.ts +7 -2
  148. package/dist/halal-core/review/createReviewRequest.js +21 -17
  149. package/dist/halal-core/review/createReviewRequest.js.map +1 -1
  150. package/dist/halal-core/review/reviewPolicy.d.ts +7 -3
  151. package/dist/halal-core/review/reviewPolicy.js +19 -17
  152. package/dist/halal-core/review/reviewPolicy.js.map +1 -1
  153. package/dist/halal-core/review/signedReviewFile.d.ts +17 -12
  154. package/dist/halal-core/review/signedReviewFile.js +25 -22
  155. package/dist/halal-core/review/signedReviewFile.js.map +1 -1
  156. package/dist/halal-core/review/verifyReviewApproval.d.ts +12 -8
  157. package/dist/halal-core/review/verifyReviewApproval.js +69 -62
  158. package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
  159. package/dist/halal-core/rules/adultContentRules.d.ts +6 -2
  160. package/dist/halal-core/rules/adultContentRules.js +23 -23
  161. package/dist/halal-core/rules/adultContentRules.js.map +1 -1
  162. package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +6 -2
  163. package/dist/halal-core/rules/alcoholDrugVapeRules.js +22 -22
  164. package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
  165. package/dist/halal-core/rules/childSafetyRules.d.ts +6 -2
  166. package/dist/halal-core/rules/childSafetyRules.js +19 -19
  167. package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
  168. package/dist/halal-core/rules/coreCategories.d.ts +10 -6
  169. package/dist/halal-core/rules/coreCategories.js +237 -110
  170. package/dist/halal-core/rules/coreCategories.js.map +1 -1
  171. package/dist/halal-core/rules/cyberAbuseRules.d.ts +6 -2
  172. package/dist/halal-core/rules/cyberAbuseRules.js +27 -27
  173. package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
  174. package/dist/halal-core/rules/defaultBlockedRules.d.ts +24 -19
  175. package/dist/halal-core/rules/defaultBlockedRules.js +156 -199
  176. package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
  177. package/dist/halal-core/rules/dependencyRules.d.ts +11 -7
  178. package/dist/halal-core/rules/dependencyRules.js +50 -56
  179. package/dist/halal-core/rules/dependencyRules.js.map +1 -1
  180. package/dist/halal-core/rules/endpointRules.d.ts +9 -5
  181. package/dist/halal-core/rules/endpointRules.js +21 -23
  182. package/dist/halal-core/rules/endpointRules.js.map +1 -1
  183. package/dist/halal-core/rules/environmentalHarmRules.d.ts +6 -2
  184. package/dist/halal-core/rules/environmentalHarmRules.js +17 -17
  185. package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
  186. package/dist/halal-core/rules/financeRibaRules.d.ts +6 -2
  187. package/dist/halal-core/rules/financeRibaRules.js +20 -20
  188. package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
  189. package/dist/halal-core/rules/gamblingRules.d.ts +6 -2
  190. package/dist/halal-core/rules/gamblingRules.js +22 -22
  191. package/dist/halal-core/rules/gamblingRules.js.map +1 -1
  192. package/dist/halal-core/rules/generalHarmRules.d.ts +6 -2
  193. package/dist/halal-core/rules/generalHarmRules.js +15 -15
  194. package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
  195. package/dist/halal-core/rules/healthHarmRules.d.ts +6 -2
  196. package/dist/halal-core/rules/healthHarmRules.js +19 -19
  197. package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
  198. package/dist/halal-core/rules/keywordRules.d.ts +13 -9
  199. package/dist/halal-core/rules/keywordRules.js +90 -39
  200. package/dist/halal-core/rules/keywordRules.js.map +1 -1
  201. package/dist/halal-core/rules/privacyAbuseRules.d.ts +6 -2
  202. package/dist/halal-core/rules/privacyAbuseRules.js +21 -21
  203. package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
  204. package/dist/halal-core/rules/scamFraudRules.d.ts +6 -2
  205. package/dist/halal-core/rules/scamFraudRules.js +29 -29
  206. package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
  207. package/dist/halal-core/rules/selfHarmRules.d.ts +6 -2
  208. package/dist/halal-core/rules/selfHarmRules.js +17 -17
  209. package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
  210. package/dist/halal-core/rules/violenceExtremismRules.d.ts +6 -2
  211. package/dist/halal-core/rules/violenceExtremismRules.js +30 -30
  212. package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
  213. package/dist/halal-core/runtime/guard.d.ts +22 -17
  214. package/dist/halal-core/runtime/guard.js +163 -183
  215. package/dist/halal-core/runtime/guard.js.map +1 -1
  216. package/dist/halal-core/runtime/index.d.ts +5 -4
  217. package/dist/halal-core/runtime/index.js +5 -5
  218. package/dist/halal-core/runtime/reviewedMemory.d.ts +10 -5
  219. package/dist/halal-core/runtime/reviewedMemory.js +75 -110
  220. package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
  221. package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +17 -12
  222. package/dist/halal-core/runtime/serializeRuntimeContent.js +133 -156
  223. package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
  224. package/dist/halal-core/runtime/types.d.ts +55 -50
  225. package/dist/halal-core/runtime/types.js +1 -2
  226. package/dist/halal-core/scanner/scanApiRoutes.d.ts +5 -1
  227. package/dist/halal-core/scanner/scanApiRoutes.js +33 -36
  228. package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
  229. package/dist/halal-core/scanner/scanComponents.d.ts +5 -1
  230. package/dist/halal-core/scanner/scanComponents.js +13 -13
  231. package/dist/halal-core/scanner/scanComponents.js.map +1 -1
  232. package/dist/halal-core/scanner/scanContent.d.ts +8 -4
  233. package/dist/halal-core/scanner/scanContent.js +192 -261
  234. package/dist/halal-core/scanner/scanContent.js.map +1 -1
  235. package/dist/halal-core/scanner/scanDependencies.d.ts +5 -1
  236. package/dist/halal-core/scanner/scanDependencies.js +17 -15
  237. package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
  238. package/dist/halal-core/scanner/scanDomains.d.ts +7 -3
  239. package/dist/halal-core/scanner/scanDomains.js +12 -12
  240. package/dist/halal-core/scanner/scanDomains.js.map +1 -1
  241. package/dist/halal-core/scanner/scanEnvNames.d.ts +5 -1
  242. package/dist/halal-core/scanner/scanEnvNames.js +24 -26
  243. package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
  244. package/dist/halal-core/scanner/scanMetadata.d.ts +9 -5
  245. package/dist/halal-core/scanner/scanMetadata.js +21 -29
  246. package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
  247. package/dist/halal-core/scanner/scanPages.d.ts +5 -1
  248. package/dist/halal-core/scanner/scanPages.js +13 -15
  249. package/dist/halal-core/scanner/scanPages.js.map +1 -1
  250. package/dist/halal-core/scanner/scanProject.d.ts +19 -12
  251. package/dist/halal-core/scanner/scanProject.js +44 -49
  252. package/dist/halal-core/scanner/scanProject.js.map +1 -1
  253. package/dist/halal-core/scanner/scanRoutes.d.ts +5 -1
  254. package/dist/halal-core/scanner/scanRoutes.js +33 -39
  255. package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
  256. package/dist/halal-core/scanner/scanTranslations.d.ts +5 -1
  257. package/dist/halal-core/scanner/scanTranslations.js +22 -29
  258. package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
  259. package/dist/halal-core/status.d.ts +17 -13
  260. package/dist/halal-core/status.js +1 -2
  261. package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +5 -1
  262. package/dist/halal-core/tamper/verifyCoreIntegrity.js +27 -24
  263. package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
  264. package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +5 -1
  265. package/dist/halal-core/tamper/verifyLifecycleHooks.js +13 -12
  266. package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
  267. package/dist/halal-core/tamper/verifyReportSignature.d.ts +9 -4
  268. package/dist/halal-core/tamper/verifyReportSignature.js +20 -14
  269. package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
  270. package/dist/halal.d.ts +20 -1
  271. package/dist/halal.js +19 -2
  272. package/dist/i18n/index.d.ts +44 -40
  273. package/dist/i18n/index.js +218 -288
  274. package/dist/i18n/index.js.map +1 -1
  275. package/dist/i18n/shared.d.ts +33 -29
  276. package/dist/i18n/shared.js +204 -266
  277. package/dist/i18n/shared.js.map +1 -1
  278. package/dist/icons/index.d.ts +160 -154
  279. package/dist/icons/index.js +323 -273
  280. package/dist/icons/index.js.map +1 -1
  281. package/dist/index.d.ts +8 -1
  282. package/dist/index.js +8 -2
  283. package/dist/kit/index.d.ts +32 -27
  284. package/dist/kit/index.js +46 -43
  285. package/dist/kit/index.js.map +1 -1
  286. package/dist/nitro-server/index.d.ts +10 -6
  287. package/dist/nitro-server/index.js +6 -2
  288. package/dist/nitro-server/index.js.map +1 -1
  289. package/dist/node.d.ts +9 -4
  290. package/dist/node.js +89 -116
  291. package/dist/node.js.map +1 -1
  292. package/dist/reactivity/computed.d.ts +11 -6
  293. package/dist/reactivity/computed.js +46 -53
  294. package/dist/reactivity/computed.js.map +1 -1
  295. package/dist/reactivity/effect.d.ts +23 -18
  296. package/dist/reactivity/effect.js +105 -147
  297. package/dist/reactivity/effect.js.map +1 -1
  298. package/dist/reactivity/index.d.ts +8 -8
  299. package/dist/reactivity/index.js +8 -8
  300. package/dist/reactivity/reactive.d.ts +9 -5
  301. package/dist/reactivity/reactive.js +95 -134
  302. package/dist/reactivity/reactive.js.map +1 -1
  303. package/dist/reactivity/readonly.d.ts +2 -1
  304. package/dist/reactivity/readonly.js +3 -2
  305. package/dist/reactivity/ref.d.ts +23 -21
  306. package/dist/reactivity/ref.js +71 -81
  307. package/dist/reactivity/ref.js.map +1 -1
  308. package/dist/reactivity/scheduler.d.ts +8 -5
  309. package/dist/reactivity/scheduler.js +67 -69
  310. package/dist/reactivity/scheduler.js.map +1 -1
  311. package/dist/reactivity/types.d.ts +29 -25
  312. package/dist/reactivity/types.js +1 -2
  313. package/dist/reactivity/utils.d.ts +17 -13
  314. package/dist/reactivity/utils.js +25 -24
  315. package/dist/reactivity/utils.js.map +1 -1
  316. package/dist/reactivity/watch.d.ts +8 -4
  317. package/dist/reactivity/watch.js +74 -103
  318. package/dist/reactivity/watch.js.map +1 -1
  319. package/dist/runtime/core.d.ts +32 -0
  320. package/dist/runtime/core.js +155 -0
  321. package/dist/runtime/core.js.map +1 -0
  322. package/dist/runtime/index.d.ts +649 -622
  323. package/dist/runtime/index.js +4105 -5243
  324. package/dist/runtime/index.js.map +1 -1
  325. package/dist/runtime/reactivity.d.ts +7 -0
  326. package/dist/runtime/reactivity.js +7 -0
  327. package/dist/runtime/resume.d.ts +80 -0
  328. package/dist/runtime/resume.js +482 -0
  329. package/dist/runtime/resume.js.map +1 -0
  330. package/dist/runtime/router.d.ts +21 -0
  331. package/dist/runtime/router.js +60 -0
  332. package/dist/runtime/router.js.map +1 -0
  333. package/dist/runtime/streaming.d.ts +25 -0
  334. package/dist/runtime/streaming.js +200 -0
  335. package/dist/runtime/streaming.js.map +1 -0
  336. package/dist/security/media-fetch.d.ts +33 -0
  337. package/dist/security/media-fetch.js +302 -0
  338. package/dist/security/media-fetch.js.map +1 -0
  339. package/dist/security/path-boundary.d.ts +8 -0
  340. package/dist/security/path-boundary.js +71 -0
  341. package/dist/security/path-boundary.js.map +1 -0
  342. package/dist/ui/index.d.ts +1774 -1768
  343. package/dist/ui/index.js +974 -674
  344. package/dist/ui/index.js.map +1 -1
  345. package/dist/vite-builder/index.d.ts +9 -5
  346. package/dist/vite-builder/index.js +6 -2
  347. package/dist/vite-builder/index.js.map +1 -1
  348. package/package.json +46 -86
  349. package/dist/compiler/implementation.js.map +0 -1
  350. package/dist/core/index.js.map +0 -1
  351. package/dist/deploy/types.js.map +0 -1
  352. package/dist/globals.js.map +0 -1
  353. package/dist/halal-core/index.js.map +0 -1
  354. package/dist/halal-core/runtime/index.js.map +0 -1
  355. package/dist/halal-core/runtime/types.js.map +0 -1
  356. package/dist/halal-core/status.js.map +0 -1
  357. package/dist/halal.js.map +0 -1
  358. package/dist/index.js.map +0 -1
  359. package/dist/reactivity/index.js.map +0 -1
  360. package/dist/reactivity/readonly.js.map +0 -1
  361. package/dist/reactivity/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../../src/halal-core/runtime/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CA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,QAAQ,CAAC,iBAAiB;KAC9C,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAgB;IACrC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"guard.js","names":[],"sources":["../../../src/halal-core/runtime/guard.ts"],"sourcesContent":["import { classifyRuntimeContentWithAi } from \"../ai/classifyRuntimeContent.js\";\nimport { evaluateRules } from \"../rules/defaultBlockedRules.js\";\nimport { scanDomains } from \"../scanner/scanDomains.js\";\nimport type { HalalCheckResult, HalalGuardStatus } from \"../status.js\";\nimport {\n createRuntimeContentFingerprint,\n findReviewedRuntimeDecision,\n} from \"./reviewedMemory.js\";\nimport {\n prepareRuntimeContent,\n type RuntimeContentInspectionIssue,\n} from \"./serializeRuntimeContent.js\";\nimport type {\n HalalRuntimeContent,\n HalalRuntimeDecision,\n HalalRuntimeGuardOptions,\n} from \"./types.js\";\n\nconst STATUS_RANK: Record<HalalGuardStatus, number> = {\n allowed: 0,\n warning: 1,\n review_required: 2,\n blocked: 3,\n};\n\nconst RISK_RANK: Record<HalalCheckResult[\"riskLevel\"], number> = {\n low: 0,\n medium: 1,\n high: 2,\n critical: 3,\n};\n\nexport class HalalRuntimeBlockedError extends Error {\n readonly decision: HalalRuntimeDecision;\n\n constructor(decision: HalalRuntimeDecision) {\n super(decision.reasons[0] || \"Runtime content was rejected by the halal guard.\");\n this.name = \"HalalRuntimeBlockedError\";\n this.decision = decision;\n }\n}\n\nexport function createHalalRuntimeGuard(options: HalalRuntimeGuardOptions = {}) {\n return {\n check(content: HalalRuntimeContent): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent(content, options);\n },\n\n checkDynamicPage(content: Omit<HalalRuntimeContent, \"kind\">): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent({ ...content, kind: \"dynamic_page\" }, options);\n },\n\n checkAd(content: Omit<HalalRuntimeContent, \"kind\">): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent({ ...content, kind: \"advertisement\" }, options);\n },\n\n async assertAllowed(content: HalalRuntimeContent): Promise<HalalRuntimeDecision> {\n const decision = await evaluateHalalRuntimeContent(content, options);\n if (!decision.allowed) {\n throw new HalalRuntimeBlockedError(decision);\n }\n return decision;\n },\n\n async filterAds<T extends Omit<HalalRuntimeContent, \"kind\">>(ads: readonly T[]) {\n const checked = await Promise.all(ads.map(async (ad) => ({\n ad,\n decision: await evaluateHalalRuntimeContent({ ...ad, kind: \"advertisement\" }, options),\n })));\n return {\n allowed: checked.filter((entry) => entry.decision.allowed).map((entry) => entry.ad),\n rejected: checked.filter((entry) => !entry.decision.allowed),\n };\n },\n };\n}\n\nexport async function evaluateHalalRuntimeContent(\n content: HalalRuntimeContent,\n options: HalalRuntimeGuardOptions = {},\n): Promise<HalalRuntimeDecision> {\n const serialized = prepareRuntimeContent(content, options.maxContentCharacters);\n const fingerprint = createRuntimeContentFingerprint(content);\n const file = `runtime:${content.kind}:${content.id || content.route || \"anonymous\"}`;\n const scannedResult = evaluateRules({\n routes: content.route ? [content.route] : [],\n pages: content.kind === \"dynamic_page\" && content.route ? [content.route] : [],\n components: [],\n metadata: {\n title: content.title,\n description: content.advertiser\n ? `Advertiser: ${content.advertiser}`\n : `${content.kind} runtime content`,\n },\n envNames: [],\n dependencies: {},\n i18nWords: [],\n contentTexts: [{ file, text: serialized.localText }],\n endpoints: scanDomains([{ file, text: serialized.localText }]),\n }, options.policy ?? {});\n\n let localResult = scannedResult;\n if (serialized.truncated) {\n localResult = mergeResults(\n localResult,\n truncatedContentResult(file, serialized.maxCharacters),\n );\n }\n if (serialized.inspectionIssues.length > 0) {\n localResult = mergeResults(\n localResult,\n uninspectableContentResult(file, serialized.inspectionIssues),\n );\n }\n\n const reviewed = findReviewedRuntimeDecision(\n content,\n options.reviewedDecisions,\n options.reviewSecret,\n );\n if (reviewed) {\n const reviewedResult = decisionFromReviewedMemory(content, fingerprint, reviewed, options.strict === true);\n if (STATUS_RANK[reviewedResult.status] >= STATUS_RANK[localResult.status]\n || STATUS_RANK[localResult.status] <= STATUS_RANK.warning) {\n return reviewedResult;\n }\n }\n\n if (localResult.status === \"blocked\") {\n return finalizeDecision(content, fingerprint, localResult, \"local_rules\", options.strict === true);\n }\n\n const aiResult = await classifyRuntimeContentWithAi(\n content,\n serialized.aiText,\n localResult,\n options.ai,\n );\n const requiresAi = content.kind === \"advertisement\"\n ? options.ai?.requireForAds !== false\n : options.ai?.requireForDynamicContent === true;\n\n if (!aiResult && requiresAi) {\n const unverified = mergeResults(localResult, {\n status: \"review_required\",\n riskLevel: \"medium\",\n categories: [content.kind === \"advertisement\" ? \"unverified_ad\" : \"unverified_dynamic_content\"],\n confidence: 0,\n reasons: [\"Required runtime AI verification is not configured or unavailable.\"],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Do not render this content until AI verification or signed human review is available.\",\n });\n return finalizeDecision(content, fingerprint, unverified, \"local_rules\", options.strict === true);\n }\n\n const result = aiResult ? mergeResults(localResult, aiResult) : localResult;\n return finalizeDecision(\n content,\n fingerprint,\n result,\n aiResult ? \"local_and_ai\" : \"local_rules\",\n options.strict === true,\n );\n}\n\nfunction truncatedContentResult(file: string, maxCharacters: number): HalalCheckResult {\n return {\n status: \"review_required\",\n riskLevel: \"medium\",\n categories: [\"runtime_content_truncated\"],\n confidence: 1,\n reasons: [\n `Runtime content exceeded the ${maxCharacters}-character scan limit and was not fully inspected.`,\n ],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Increase maxContentCharacters or complete a manual review before rendering.\",\n };\n}\n\nfunction uninspectableContentResult(\n file: string,\n issues: readonly RuntimeContentInspectionIssue[],\n): HalalCheckResult {\n const issueDescriptions = issues.map((issue) => {\n if (issue === \"max_depth\") return \"maximum serialization depth was reached\";\n if (issue === \"unreadable_property\") return \"one or more properties could not be read\";\n return \"one or more objects could not be inspected\";\n });\n\n return {\n status: \"review_required\",\n riskLevel: \"high\",\n categories: [\"runtime_content_uninspectable\"],\n confidence: 1,\n reasons: [\n `Runtime content could not be fully inspected: ${uniqueStrings(issueDescriptions).join(\"; \")}.`,\n ],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Normalize runtime content to plain inspectable data or complete a manual review before rendering.\",\n };\n}\n\nfunction decisionFromReviewedMemory(\n content: HalalRuntimeContent,\n fingerprint: string,\n reviewed: NonNullable<HalalRuntimeGuardOptions[\"reviewedDecisions\"]>[number],\n strict: boolean,\n): HalalRuntimeDecision {\n const result: HalalCheckResult = {\n status: reviewed.status,\n riskLevel: reviewed.status === \"blocked\"\n ? \"high\"\n : reviewed.status === \"review_required\"\n ? \"medium\"\n : reviewed.status === \"warning\"\n ? \"medium\"\n : \"low\",\n categories: reviewed.categories,\n confidence: 1,\n reasons: [`Signed review by ${reviewed.reviewerId}: ${reviewed.reason}`],\n matchedFiles: [],\n matchedSnippets: [],\n recommendedAction: reviewed.status === \"allowed\"\n ? \"Render the exact reviewed content.\"\n : \"Follow the signed runtime review decision.\",\n };\n return finalizeDecision(content, fingerprint, result, \"reviewed_memory\", strict);\n}\n\nfunction finalizeDecision(\n content: HalalRuntimeContent,\n fingerprint: string,\n result: HalalCheckResult,\n source: HalalRuntimeDecision[\"source\"],\n strict: boolean,\n): HalalRuntimeDecision {\n return {\n ...result,\n contentKind: content.kind,\n fingerprint,\n source,\n allowed: result.status === \"allowed\" || (result.status === \"warning\" && !strict),\n };\n}\n\nfunction mergeResults(left: HalalCheckResult, right: HalalCheckResult): HalalCheckResult {\n const leftRank = STATUS_RANK[left.status];\n const rightRank = STATUS_RANK[right.status];\n const dominant = rightRank > leftRank ? right : left;\n const riskLevel = RISK_RANK[right.riskLevel] > RISK_RANK[left.riskLevel]\n ? right.riskLevel\n : left.riskLevel;\n const confidence = leftRank === rightRank\n ? Math.max(left.confidence, right.confidence)\n : dominant.confidence;\n\n return {\n status: dominant.status,\n riskLevel,\n categories: uniqueStrings([...left.categories, ...right.categories]),\n confidence,\n reasons: uniqueStrings([...left.reasons, ...right.reasons]),\n matchedFiles: uniqueStrings([...left.matchedFiles, ...right.matchedFiles]),\n matchedSnippets: uniqueStrings([...left.matchedSnippets, ...right.matchedSnippets]),\n recommendedAction: dominant.recommendedAction,\n };\n}\n\nfunction uniqueStrings(values: string[]): string[] {\n return [...new Set(values.filter(Boolean))];\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,cAAgD;CACpD,SAAS;CACT,SAAS;CACT,iBAAiB;CACjB,SAAS;CACV;AAED,MAAM,YAA2D;CAC/D,KAAK;CACL,QAAQ;CACR,MAAM;CACN,UAAU;CACX;AAED,IAAa,2BAAb,cAA8C,MAAM;CAClD,AAAS;CAET,YAAY,UAAgC;AAC1C,QAAM,SAAS,QAAQ,MAAM,mDAAmD;AAChF,OAAK,OAAO;AACZ,OAAK,WAAW;;;AAIpB,SAAgB,wBAAwB,UAAoC,EAAE,EAAE;AAC9E,QAAO;EACL,MAAM,SAA6D;AACjE,UAAO,4BAA4B,SAAS,QAAQ;;EAGtD,iBAAiB,SAA2E;AAC1F,UAAO,4BAA4B;IAAE,GAAG;IAAS,MAAM;IAAgB,EAAE,QAAQ;;EAGnF,QAAQ,SAA2E;AACjF,UAAO,4BAA4B;IAAE,GAAG;IAAS,MAAM;IAAiB,EAAE,QAAQ;;EAGpF,MAAM,cAAc,SAA6D;GAC/E,MAAM,WAAW,MAAM,4BAA4B,SAAS,QAAQ;AACpE,OAAI,CAAC,SAAS,QACZ,OAAM,IAAI,yBAAyB,SAAS;AAE9C,UAAO;;EAGT,MAAM,UAAuD,KAAmB;GAC9E,MAAM,UAAU,MAAM,QAAQ,IAAI,IAAI,IAAI,OAAO,QAAQ;IACvD;IACA,UAAU,MAAM,4BAA4B;KAAE,GAAG;KAAI,MAAM;KAAiB,EAAE,QAAQ;IACvF,EAAE,CAAC;AACJ,UAAO;IACL,SAAS,QAAQ,QAAQ,UAAU,MAAM,SAAS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";
3
- export * from "./reviewedMemory.js";
4
- export * from "./guard.js";
1
+ import { HalalRuntimeAiOptions, HalalRuntimeContent, HalalRuntimeContentKind, HalalRuntimeDecision, HalalRuntimeDecisionSource, HalalRuntimeGuardOptions, HalalRuntimeReviewDecision, HalalRuntimeReviewInput, SignedHalalRuntimeDecision } from "./types.js";
2
+ import { PreparedRuntimeContent, RuntimeContentInspectionIssue, prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical } from "./serializeRuntimeContent.js";
3
+ import { createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, findReviewedRuntimeDecision, verifySignedHalalRuntimeDecision } from "./reviewedMemory.js";
4
+ import { HalalRuntimeBlockedError, createHalalRuntimeGuard, evaluateHalalRuntimeContent } from "./guard.js";
5
+ export { HalalRuntimeAiOptions, HalalRuntimeBlockedError, HalalRuntimeContent, HalalRuntimeContentKind, HalalRuntimeDecision, HalalRuntimeDecisionSource, HalalRuntimeGuardOptions, HalalRuntimeReviewDecision, HalalRuntimeReviewInput, PreparedRuntimeContent, RuntimeContentInspectionIssue, SignedHalalRuntimeDecision, createHalalRuntimeGuard, createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, evaluateHalalRuntimeContent, findReviewedRuntimeDecision, prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical, verifySignedHalalRuntimeDecision };
@@ -1,5 +1,5 @@
1
- export * from "./types.js";
2
- export * from "./serializeRuntimeContent.js";
3
- export * from "./reviewedMemory.js";
4
- export * from "./guard.js";
5
- //# sourceMappingURL=index.js.map
1
+ import { prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical } from "./serializeRuntimeContent.js";
2
+ import { createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, findReviewedRuntimeDecision, verifySignedHalalRuntimeDecision } from "./reviewedMemory.js";
3
+ import { HalalRuntimeBlockedError, createHalalRuntimeGuard, evaluateHalalRuntimeContent } from "./guard.js";
4
+
5
+ export { HalalRuntimeBlockedError, createHalalRuntimeGuard, createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, evaluateHalalRuntimeContent, findReviewedRuntimeDecision, prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical, verifySignedHalalRuntimeDecision };
@@ -1,5 +1,10 @@
1
- import type { HalalRuntimeContent, HalalRuntimeReviewInput, SignedHalalRuntimeDecision } from "./types.js";
2
- export declare function createRuntimeContentFingerprint(content: HalalRuntimeContent, _maxContentCharacters?: number): string;
3
- export declare function createSignedHalalRuntimeDecision(content: HalalRuntimeContent, review: HalalRuntimeReviewInput, secret?: string): SignedHalalRuntimeDecision;
4
- export declare function verifySignedHalalRuntimeDecision(decision: unknown, secret?: string): decision is SignedHalalRuntimeDecision;
5
- export declare function findReviewedRuntimeDecision(content: HalalRuntimeContent, decisions: readonly SignedHalalRuntimeDecision[] | undefined, secret?: string, _maxContentCharacters?: number): SignedHalalRuntimeDecision | undefined;
1
+ import { HalalRuntimeContent, HalalRuntimeReviewInput, SignedHalalRuntimeDecision } from "./types.js";
2
+
3
+ //#region src/halal-core/runtime/reviewedMemory.d.ts
4
+ declare function createRuntimeContentFingerprint(content: HalalRuntimeContent, _maxContentCharacters?: number): string;
5
+ declare function createSignedHalalRuntimeDecision(content: HalalRuntimeContent, review: HalalRuntimeReviewInput, secret?: string): SignedHalalRuntimeDecision;
6
+ declare function verifySignedHalalRuntimeDecision(decision: unknown, secret?: string): decision is SignedHalalRuntimeDecision;
7
+ declare function findReviewedRuntimeDecision(content: HalalRuntimeContent, decisions: readonly SignedHalalRuntimeDecision[] | undefined, secret?: string, _maxContentCharacters?: number): SignedHalalRuntimeDecision | undefined;
8
+ //#endregion
9
+ export { createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, findReviewedRuntimeDecision, verifySignedHalalRuntimeDecision };
10
+ //# sourceMappingURL=reviewedMemory.d.ts.map
@@ -1,131 +1,96 @@
1
- import { createHash } from "node:crypto";
2
- import { createIntegritySignature, verifyIntegritySignature, } from "../crypto/integrity.js";
1
+ import { createIntegritySignature, verifyIntegritySignature } from "../crypto/integrity.js";
3
2
  import { serializeRuntimeContentCanonical } from "./serializeRuntimeContent.js";
3
+ import { createHash } from "node:crypto";
4
+
5
+ //#region src/halal-core/runtime/reviewedMemory.ts
4
6
  const REVIEW_SECRET_ENV = "RESUX_HALAL_REVIEW_SECRET";
5
- const MAX_CLOCK_SKEW_MS = 5 * 60 * 1_000;
7
+ const MAX_CLOCK_SKEW_MS = 300 * 1e3;
6
8
  const STATUS_RANK = {
7
- allowed: 0,
8
- warning: 1,
9
- review_required: 2,
10
- blocked: 3,
9
+ allowed: 0,
10
+ warning: 1,
11
+ review_required: 2,
12
+ blocked: 3
11
13
  };
12
- export function createRuntimeContentFingerprint(content, _maxContentCharacters) {
13
- const canonical = serializeRuntimeContentCanonical(content);
14
- return createHash("sha256").update(canonical).digest("hex");
14
+ function createRuntimeContentFingerprint(content, _maxContentCharacters) {
15
+ const canonical = serializeRuntimeContentCanonical(content);
16
+ return createHash("sha256").update(canonical).digest("hex");
15
17
  }
16
- export function createSignedHalalRuntimeDecision(content, review, secret) {
17
- const createdAt = new Date();
18
- const unsigned = {
19
- version: 1,
20
- fingerprint: createRuntimeContentFingerprint(content),
21
- status: review.status,
22
- categories: normalizeCategories(review.categories),
23
- reason: requireText(review.reason, "Review reason"),
24
- reviewerId: requireText(review.reviewerId, "Reviewer ID"),
25
- createdAt: createdAt.toISOString(),
26
- ...(review.expiresAt
27
- ? { expiresAt: validateFutureDate(review.expiresAt, "Review expiry", createdAt.getTime()) }
28
- : {}),
29
- };
30
- return {
31
- ...unsigned,
32
- signature: createIntegritySignature(unsigned, {
33
- envName: REVIEW_SECRET_ENV,
34
- secret,
35
- requireSecret: true,
36
- }),
37
- };
18
+ function createSignedHalalRuntimeDecision(content, review, secret) {
19
+ const createdAt = /* @__PURE__ */ new Date();
20
+ const unsigned = {
21
+ version: 1,
22
+ fingerprint: createRuntimeContentFingerprint(content),
23
+ status: review.status,
24
+ categories: normalizeCategories(review.categories),
25
+ reason: requireText(review.reason, "Review reason"),
26
+ reviewerId: requireText(review.reviewerId, "Reviewer ID"),
27
+ createdAt: createdAt.toISOString(),
28
+ ...review.expiresAt ? { expiresAt: validateFutureDate(review.expiresAt, "Review expiry", createdAt.getTime()) } : {}
29
+ };
30
+ return {
31
+ ...unsigned,
32
+ signature: createIntegritySignature(unsigned, {
33
+ envName: REVIEW_SECRET_ENV,
34
+ secret,
35
+ requireSecret: true
36
+ })
37
+ };
38
38
  }
39
- export function verifySignedHalalRuntimeDecision(decision, secret) {
40
- if (!isRecord(decision) || decision.version !== 1 || typeof decision.signature !== "string") {
41
- return false;
42
- }
43
- if (!isValidStatus(decision.status)
44
- || typeof decision.fingerprint !== "string"
45
- || !/^[a-f0-9]{64}$/.test(decision.fingerprint)
46
- || typeof decision.reason !== "string"
47
- || !decision.reason.trim()
48
- || typeof decision.reviewerId !== "string"
49
- || !decision.reviewerId.trim()
50
- || typeof decision.createdAt !== "string"
51
- || !Array.isArray(decision.categories)
52
- || decision.categories.some((entry) => typeof entry !== "string")) {
53
- return false;
54
- }
55
- const createdAt = Date.parse(decision.createdAt);
56
- if (!Number.isFinite(createdAt) || createdAt > Date.now() + MAX_CLOCK_SKEW_MS) {
57
- return false;
58
- }
59
- if (decision.expiresAt !== undefined) {
60
- if (typeof decision.expiresAt !== "string") {
61
- return false;
62
- }
63
- const expiresAt = Date.parse(decision.expiresAt);
64
- if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || expiresAt <= createdAt) {
65
- return false;
66
- }
67
- }
68
- const { signature, ...unsigned } = decision;
69
- return verifyIntegritySignature(unsigned, signature, {
70
- envName: REVIEW_SECRET_ENV,
71
- secret,
72
- requireSecret: true,
73
- });
39
+ function verifySignedHalalRuntimeDecision(decision, secret) {
40
+ if (!isRecord(decision) || decision.version !== 1 || typeof decision.signature !== "string") return false;
41
+ if (!isValidStatus(decision.status) || typeof decision.fingerprint !== "string" || !/^[a-f0-9]{64}$/.test(decision.fingerprint) || typeof decision.reason !== "string" || !decision.reason.trim() || typeof decision.reviewerId !== "string" || !decision.reviewerId.trim() || typeof decision.createdAt !== "string" || !Array.isArray(decision.categories) || decision.categories.some((entry) => typeof entry !== "string")) return false;
42
+ const createdAt = Date.parse(decision.createdAt);
43
+ if (!Number.isFinite(createdAt) || createdAt > Date.now() + MAX_CLOCK_SKEW_MS) return false;
44
+ if (decision.expiresAt !== void 0) {
45
+ if (typeof decision.expiresAt !== "string") return false;
46
+ const expiresAt = Date.parse(decision.expiresAt);
47
+ if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || expiresAt <= createdAt) return false;
48
+ }
49
+ const { signature, ...unsigned } = decision;
50
+ return verifyIntegritySignature(unsigned, signature, {
51
+ envName: REVIEW_SECRET_ENV,
52
+ secret,
53
+ requireSecret: true
54
+ });
74
55
  }
75
- export function findReviewedRuntimeDecision(content, decisions, secret, _maxContentCharacters) {
76
- if (!decisions?.length) {
77
- return undefined;
78
- }
79
- const fingerprint = createRuntimeContentFingerprint(content);
80
- let selected;
81
- for (const decision of decisions) {
82
- if (decision.fingerprint !== fingerprint
83
- || !verifySignedHalalRuntimeDecision(decision, secret)) {
84
- continue;
85
- }
86
- if (!selected || isNewerOrStricter(decision, selected)) {
87
- selected = decision;
88
- }
89
- }
90
- return selected;
56
+ function findReviewedRuntimeDecision(content, decisions, secret, _maxContentCharacters) {
57
+ if (!decisions?.length) return;
58
+ const fingerprint = createRuntimeContentFingerprint(content);
59
+ let selected;
60
+ for (const decision of decisions) {
61
+ if (decision.fingerprint !== fingerprint || !verifySignedHalalRuntimeDecision(decision, secret)) continue;
62
+ if (!selected || isNewerOrStricter(decision, selected)) selected = decision;
63
+ }
64
+ return selected;
91
65
  }
92
66
  function isNewerOrStricter(candidate, current) {
93
- const candidateCreatedAt = Date.parse(candidate.createdAt);
94
- const currentCreatedAt = Date.parse(current.createdAt);
95
- if (candidateCreatedAt !== currentCreatedAt) {
96
- return candidateCreatedAt > currentCreatedAt;
97
- }
98
- return STATUS_RANK[candidate.status] > STATUS_RANK[current.status];
67
+ const candidateCreatedAt = Date.parse(candidate.createdAt);
68
+ const currentCreatedAt = Date.parse(current.createdAt);
69
+ if (candidateCreatedAt !== currentCreatedAt) return candidateCreatedAt > currentCreatedAt;
70
+ return STATUS_RANK[candidate.status] > STATUS_RANK[current.status];
99
71
  }
100
72
  function normalizeCategories(categories) {
101
- if (!categories)
102
- return [];
103
- return [...new Set(categories.map((entry) => entry.trim()).filter(Boolean))].slice(0, 50);
73
+ if (!categories) return [];
74
+ return [...new Set(categories.map((entry) => entry.trim()).filter(Boolean))].slice(0, 50);
104
75
  }
105
76
  function requireText(value, label) {
106
- const normalized = String(value || "").trim();
107
- if (!normalized) {
108
- throw new Error(`${label} is required.`);
109
- }
110
- return normalized.slice(0, 2_000);
77
+ const normalized = String(value || "").trim();
78
+ if (!normalized) throw new Error(`${label} is required.`);
79
+ return normalized.slice(0, 2e3);
111
80
  }
112
81
  function validateFutureDate(value, label, createdAt) {
113
- const timestamp = Date.parse(value);
114
- if (!Number.isFinite(timestamp)) {
115
- throw new Error(`${label} must be a valid date.`);
116
- }
117
- if (timestamp <= createdAt) {
118
- throw new Error(`${label} must be later than the review creation time.`);
119
- }
120
- return new Date(timestamp).toISOString();
82
+ const timestamp = Date.parse(value);
83
+ if (!Number.isFinite(timestamp)) throw new Error(`${label} must be a valid date.`);
84
+ if (timestamp <= createdAt) throw new Error(`${label} must be later than the review creation time.`);
85
+ return new Date(timestamp).toISOString();
121
86
  }
122
87
  function isValidStatus(value) {
123
- return value === "allowed"
124
- || value === "warning"
125
- || value === "review_required"
126
- || value === "blocked";
88
+ return value === "allowed" || value === "warning" || value === "review_required" || value === "blocked";
127
89
  }
128
90
  function isRecord(value) {
129
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
91
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
130
92
  }
93
+
94
+ //#endregion
95
+ export { createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, findReviewedRuntimeDecision, verifySignedHalalRuntimeDecision };
131
96
  //# sourceMappingURL=reviewedMemory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reviewedMemory.js","sourceRoot":"","sources":["../../../src/halal-core/runtime/reviewedMemory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAOhF,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AACtD,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;AACzC,MAAM,WAAW,GAAyD;IACxE,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,CAAC;IAClB,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,UAAU,+BAA+B,CAC7C,OAA4B,EAC5B,qBAA8B;IAE9B,MAAM,SAAS,GAAG,gCAAgC,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,OAA4B,EAC5B,MAA+B,EAC/B,MAAe;IAEf,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG;QACf,OAAO,EAAE,CAAU;QACnB,WAAW,EAAE,+BAA+B,CAAC,OAAO,CAAC;QACrD,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC;QAClD,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;QACnD,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,aA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,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa,EAAE,KAAa,EAAE,SAAiB;IACzE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wBAAwB,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,SAAS,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,+CAA+C,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,SAAS;WACrB,KAAK,KAAK,SAAS;WACnB,KAAK,KAAK,iBAAiB;WAC3B,KAAK,KAAK,SAAS,CAAC;AAC3B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC"}
1
+ {"version":3,"file":"reviewedMemory.js","names":[],"sources":["../../../src/halal-core/runtime/reviewedMemory.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n createIntegritySignature,\n verifyIntegritySignature,\n} from \"../crypto/integrity.js\";\nimport { serializeRuntimeContentCanonical } from \"./serializeRuntimeContent.js\";\nimport type {\n HalalRuntimeContent,\n HalalRuntimeReviewInput,\n SignedHalalRuntimeDecision,\n} from \"./types.js\";\n\nconst REVIEW_SECRET_ENV = \"RESUX_HALAL_REVIEW_SECRET\";\nconst MAX_CLOCK_SKEW_MS = 5 * 60 * 1_000;\nconst STATUS_RANK: Record<SignedHalalRuntimeDecision[\"status\"], number> = {\n allowed: 0,\n warning: 1,\n review_required: 2,\n blocked: 3,\n};\n\nexport function createRuntimeContentFingerprint(\n content: HalalRuntimeContent,\n _maxContentCharacters?: number,\n): string {\n const canonical = serializeRuntimeContentCanonical(content);\n return createHash(\"sha256\").update(canonical).digest(\"hex\");\n}\n\nexport function createSignedHalalRuntimeDecision(\n content: HalalRuntimeContent,\n review: HalalRuntimeReviewInput,\n secret?: string,\n): SignedHalalRuntimeDecision {\n const createdAt = new Date();\n const unsigned = {\n version: 1 as const,\n fingerprint: createRuntimeContentFingerprint(content),\n status: review.status,\n categories: normalizeCategories(review.categories),\n reason: requireText(review.reason, \"Review reason\"),\n reviewerId: requireText(review.reviewerId, \"Reviewer ID\"),\n createdAt: createdAt.toISOString(),\n ...(review.expiresAt\n ? { expiresAt: validateFutureDate(review.expiresAt, \"Review expiry\", createdAt.getTime()) }\n : {}),\n };\n\n return {\n ...unsigned,\n signature: createIntegritySignature(unsigned, {\n envName: REVIEW_SECRET_ENV,\n secret,\n requireSecret: true,\n }),\n };\n}\n\nexport function verifySignedHalalRuntimeDecision(\n decision: unknown,\n secret?: string,\n): decision is SignedHalalRuntimeDecision {\n if (!isRecord(decision) || decision.version !== 1 || typeof decision.signature !== \"string\") {\n return false;\n }\n if (!isValidStatus(decision.status)\n || typeof decision.fingerprint !== \"string\"\n || !/^[a-f0-9]{64}$/.test(decision.fingerprint)\n || typeof decision.reason !== \"string\"\n || !decision.reason.trim()\n || typeof decision.reviewerId !== \"string\"\n || !decision.reviewerId.trim()\n || typeof decision.createdAt !== \"string\"\n || !Array.isArray(decision.categories)\n || decision.categories.some((entry) => typeof entry !== \"string\")) {\n return false;\n }\n\n const createdAt = Date.parse(decision.createdAt);\n if (!Number.isFinite(createdAt) || createdAt > Date.now() + MAX_CLOCK_SKEW_MS) {\n return false;\n }\n if (decision.expiresAt !== undefined) {\n if (typeof decision.expiresAt !== \"string\") {\n return false;\n }\n const expiresAt = Date.parse(decision.expiresAt);\n if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || expiresAt <= createdAt) {\n return false;\n }\n }\n\n const { signature, ...unsigned } = decision;\n return verifyIntegritySignature(unsigned, signature, {\n envName: REVIEW_SECRET_ENV,\n secret,\n requireSecret: true,\n });\n}\n\nexport function findReviewedRuntimeDecision(\n content: HalalRuntimeContent,\n decisions: readonly SignedHalalRuntimeDecision[] | undefined,\n secret?: string,\n _maxContentCharacters?: number,\n): SignedHalalRuntimeDecision | undefined {\n if (!decisions?.length) {\n return undefined;\n }\n\n const fingerprint = createRuntimeContentFingerprint(content);\n let selected: SignedHalalRuntimeDecision | undefined;\n\n for (const decision of decisions) {\n if (decision.fingerprint !== fingerprint\n || !verifySignedHalalRuntimeDecision(decision, secret)) {\n continue;\n }\n if (!selected || isNewerOrStricter(decision, selected)) {\n selected = decision;\n }\n }\n\n return selected;\n}\n\nfunction isNewerOrStricter(\n candidate: SignedHalalRuntimeDecision,\n current: SignedHalalRuntimeDecision,\n): boolean {\n const candidateCreatedAt = Date.parse(candidate.createdAt);\n const currentCreatedAt = Date.parse(current.createdAt);\n if (candidateCreatedAt !== currentCreatedAt) {\n return candidateCreatedAt > currentCreatedAt;\n }\n return STATUS_RANK[candidate.status] > STATUS_RANK[current.status];\n}\n\nfunction normalizeCategories(categories: string[] | undefined): string[] {\n if (!categories) return [];\n return [...new Set(categories.map((entry) => entry.trim()).filter(Boolean))].slice(0, 50);\n}\n\nfunction requireText(value: string, label: string): string {\n const normalized = String(value || \"\").trim();\n if (!normalized) {\n throw new Error(`${label} is required.`);\n }\n return normalized.slice(0, 2_000);\n}\n\nfunction validateFutureDate(value: string, label: string, createdAt: number): string {\n const timestamp = Date.parse(value);\n if (!Number.isFinite(timestamp)) {\n throw new Error(`${label} must be a valid date.`);\n }\n if (timestamp <= createdAt) {\n throw new Error(`${label} must be later than the review creation time.`);\n }\n return new Date(timestamp).toISOString();\n}\n\nfunction isValidStatus(value: unknown): value is SignedHalalRuntimeDecision[\"status\"] {\n return value === \"allowed\"\n || value === \"warning\"\n || value === \"review_required\"\n || value === \"blocked\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n"],"mappings":";;;;;AAYA,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB,MAAS;AACnC,MAAM,cAAoE;CACxE,SAAS;CACT,SAAS;CACT,iBAAiB;CACjB,SAAS;CACV;AAED,SAAgB,gCACd,SACA,uBACQ;CACR,MAAM,YAAY,iCAAiC,QAAQ;AAC3D,QAAO,WAAW,SAAS,CAAC,OAAO,UAAU,CAAC,OAAO,MAAM;;AAG7D,SAAgB,iCACd,SACA,QACA,QAC4B;CAC5B,MAAM,4BAAY,IAAI,MAAM;CAC5B,MAAM,WAAW;EACf,SAAS;EACT,aAAa,gCAAgC,QAAQ;EACrD,QAAQ,OAAO;EACf,YAAY,oBAAoB,OAAO,WAAW;EAClD,QAAQ,YAAY,OAAO,QAAQ,gBAAgB;EACnD,YAAY,YAAY,OAAO,YAAY,cAAc;EACzD,WAAW,UAAU,aAAa;EAClC,GAAI,OAAO,YACP,EAAE,WAAW,mBAAmB,OAAO,WAAW,iBAAiB,UAAU,SAAS,CAAC,EAAE,GACzF,EAAE;EACP;AAED,QAAO;EACL,GAAG;EACH,WAAW,yBAAyB,UAAU;GAC5C,SAAS;GACT;GACA,eAAe;GAChB,CAAC;EACH;;AAGH,SAAgB,iCACd,UACA,QACwC;AACxC,KAAI,CAAC,SAAS,SAAS,IAAI,SAAS,YAAY,KAAK,OAAO,SAAS,cAAc,SACjF,QAAO;AAET,KAAI,CAAC,cAAc,SAAS,OAAO,IAC9B,OAAO,SAAS,gBAAgB,YAChC,CAAC,iBAAiB,KAAK,SAAS,YAAY,IAC5C,OAAO,SAAS,WAAW,YAC3B,CAAC,SAAS,OAAO,MAAM,IACvB,OAAO,SAAS,eAAe,YAC/B,CAAC,SAAS,WAAW,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GAAG,GAAG;;AAG3F,SAAS,YAAY,OAAe,OAAuB;CACzD,MAAM,aAAa,OAAO,SAAS,GAAG,CAAC,MAAM;AAC7C,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,GAAG,MAAM,eAAe;AAE1C,QAAO,WAAW,MAAM,GAAG,IAAM;;AAGnC,SAAS,mBAAmB,OAAe,OAAe,WAA2B;CACnF,MAAM,YAAY,KAAK,MAAM,MAAM;AACnC,KAAI,CAAC,OAAO,SAAS,UAAU,CAC7B,OAAM,IAAI,MAAM,GAAG,MAAM,wBAAwB;AAEnD,KAAI,aAAa,UACf,OAAM,IAAI,MAAM,GAAG,MAAM,+CAA+C;AAE1E,QAAO,IAAI,KAAK,UAAU,CAAC,aAAa;;AAG1C,SAAS,cAAc,OAA+D;AACpF,QAAO,UAAU,aACZ,UAAU,aACV,UAAU,qBACV,UAAU;;AAGjB,SAAS,SAAS,OAAkD;AAClE,QAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAC"}
@@ -1,13 +1,18 @@
1
- import type { HalalRuntimeContent } from "./types.js";
2
- export type RuntimeContentInspectionIssue = "max_depth" | "unreadable_object" | "unreadable_property";
3
- export interface PreparedRuntimeContent {
4
- canonical: string;
5
- localText: string;
6
- aiText: string;
7
- truncated: boolean;
8
- maxCharacters: number;
9
- inspectionIssues: RuntimeContentInspectionIssue[];
1
+ import { HalalRuntimeContent } from "./types.js";
2
+
3
+ //#region src/halal-core/runtime/serializeRuntimeContent.d.ts
4
+ type RuntimeContentInspectionIssue = "max_depth" | "unreadable_object" | "unreadable_property";
5
+ interface PreparedRuntimeContent {
6
+ canonical: string;
7
+ localText: string;
8
+ aiText: string;
9
+ truncated: boolean;
10
+ maxCharacters: number;
11
+ inspectionIssues: RuntimeContentInspectionIssue[];
10
12
  }
11
- export declare function serializeRuntimeContent(content: HalalRuntimeContent, maxCharacters?: number): string;
12
- export declare function prepareRuntimeContent(content: HalalRuntimeContent, maxCharacters?: number): PreparedRuntimeContent;
13
- export declare function serializeRuntimeContentCanonical(content: HalalRuntimeContent): string;
13
+ declare function serializeRuntimeContent(content: HalalRuntimeContent, maxCharacters?: number): string;
14
+ declare function prepareRuntimeContent(content: HalalRuntimeContent, maxCharacters?: number): PreparedRuntimeContent;
15
+ declare function serializeRuntimeContentCanonical(content: HalalRuntimeContent): string;
16
+ //#endregion
17
+ export { PreparedRuntimeContent, RuntimeContentInspectionIssue, prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical };
18
+ //# sourceMappingURL=serializeRuntimeContent.d.ts.map