resuxjs 0.3.11 → 0.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/bin.d.ts +1 -2
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +28 -0
- package/dist/build/index.js +51 -0
- package/dist/build/index.js.map +1 -0
- package/dist/cli.d.ts +15 -5
- package/dist/cli.js +2648 -3671
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +14 -11
- package/dist/compiler/adapter.js +68 -93
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +8 -5
- package/dist/compiler/dev-warnings.js +248 -321
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +3 -0
- package/dist/compiler/directives.js +124 -150
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +96 -93
- package/dist/compiler/implementation.js +2967 -3430
- package/dist/compiler/index.d.ts +14 -11
- package/dist/compiler/index.js +68 -93
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +12 -5
- package/dist/core/config.js +42 -25
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +127 -126
- package/dist/core/hooks.js +45 -55
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +5 -5
- package/dist/core/module-container.d.ts +76 -74
- package/dist/core/module-container.js +181 -186
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +15 -12
- package/dist/core/resux.js +17 -13
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -2
- package/dist/create-bin.js +4 -0
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +3 -0
- package/dist/create.js +499 -638
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +4 -1
- package/dist/deploy/cloudflare.js +30 -34
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +6 -4
- package/dist/deploy/common.js +118 -188
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +3 -0
- package/dist/deploy/framework-runtime.js +43 -48
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +4 -1
- package/dist/deploy/index.js +58 -80
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +4 -1
- package/dist/deploy/netlify.js +40 -41
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +4 -1
- package/dist/deploy/node.js +24 -19
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +3 -0
- package/dist/deploy/production-report.js +14 -14
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +3 -0
- package/dist/deploy/runtime-dependencies.js +158 -220
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +4 -1
- package/dist/deploy/static.js +16 -14
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +25 -22
- package/dist/deploy/types.js +0 -1
- package/dist/deploy/vercel.d.ts +4 -1
- package/dist/deploy/vercel.js +137 -188
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +15 -11
- package/dist/fonts/index.js +114 -134
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +79 -78
- package/dist/globals.js +0 -1
- package/dist/halal-core/ai/classifyProject.d.ts +4 -1
- package/dist/halal-core/ai/classifyProject.js +81 -95
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +5 -2
- package/dist/halal-core/ai/classifyRuntimeContent.js +77 -95
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +38 -35
- package/dist/halal-core/ai/createProjectSummary.js +38 -39
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +3 -0
- package/dist/halal-core/ai/halalClassifierPrompt.js +5 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js.map +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +3 -0
- package/dist/halal-core/ai/redactSensitiveData.js +82 -110
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +4 -1
- package/dist/halal-core/ai/validateAiResponse.js +58 -85
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +3 -0
- package/dist/halal-core/cli/check.js +28 -30
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +3 -0
- package/dist/halal-core/cli/explain.js +27 -31
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +3 -0
- package/dist/halal-core/cli/report.js +14 -10
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +3 -0
- package/dist/halal-core/cli/submitReview.js +13 -9
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +3 -0
- package/dist/halal-core/cli/verifyReview.js +18 -15
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +30 -27
- package/dist/halal-core/config.js +76 -118
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +6 -3
- package/dist/halal-core/crypto/integrity.js +64 -87
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +3 -0
- package/dist/halal-core/enforce.js +92 -105
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.d.ts +20 -16
- package/dist/halal-core/index.js +18 -19
- package/dist/halal-core/lifecycle.d.ts +3 -0
- package/dist/halal-core/lifecycle.js +15 -13
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +4 -1
- package/dist/halal-core/policy.js +6 -2
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +4 -1
- package/dist/halal-core/report/formatBrowserOverlay.js +10 -8
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +4 -1
- package/dist/halal-core/report/formatTerminalReport.js +27 -37
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +7 -4
- package/dist/halal-core/report/generateHalalReport.js +26 -26
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +4 -1
- package/dist/halal-core/report/signReport.js +16 -12
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +9 -6
- package/dist/halal-core/report/verifyReport.js +51 -41
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +4 -1
- package/dist/halal-core/review/createReviewRequest.js +21 -17
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +3 -0
- package/dist/halal-core/review/reviewPolicy.js +19 -17
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +11 -8
- package/dist/halal-core/review/signedReviewFile.js +24 -22
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +9 -6
- package/dist/halal-core/review/verifyReviewApproval.js +68 -62
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +3 -0
- package/dist/halal-core/rules/adultContentRules.js +23 -23
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -0
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +22 -22
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +3 -0
- package/dist/halal-core/rules/childSafetyRules.js +19 -19
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +7 -4
- package/dist/halal-core/rules/coreCategories.js +237 -110
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -0
- package/dist/halal-core/rules/cyberAbuseRules.js +27 -27
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +21 -18
- package/dist/halal-core/rules/defaultBlockedRules.js +158 -199
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +8 -5
- package/dist/halal-core/rules/dependencyRules.js +50 -56
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +6 -3
- package/dist/halal-core/rules/endpointRules.js +21 -23
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/environmentalHarmRules.js +17 -17
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +3 -0
- package/dist/halal-core/rules/financeRibaRules.js +20 -20
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +3 -0
- package/dist/halal-core/rules/gamblingRules.js +22 -22
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/generalHarmRules.js +15 -15
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/healthHarmRules.js +19 -19
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +11 -8
- package/dist/halal-core/rules/keywordRules.js +90 -39
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -0
- package/dist/halal-core/rules/privacyAbuseRules.js +21 -21
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +3 -0
- package/dist/halal-core/rules/scamFraudRules.js +29 -29
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +3 -0
- package/dist/halal-core/rules/selfHarmRules.js +17 -17
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -0
- package/dist/halal-core/rules/violenceExtremismRules.js +30 -30
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +17 -14
- package/dist/halal-core/runtime/guard.js +162 -183
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.d.ts +5 -4
- package/dist/halal-core/runtime/index.js +4 -5
- package/dist/halal-core/runtime/reviewedMemory.d.ts +4 -1
- package/dist/halal-core/runtime/reviewedMemory.js +74 -110
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +10 -7
- package/dist/halal-core/runtime/serializeRuntimeContent.js +132 -156
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +44 -41
- package/dist/halal-core/runtime/types.js +0 -1
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +3 -0
- package/dist/halal-core/scanner/scanApiRoutes.js +32 -36
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +3 -0
- package/dist/halal-core/scanner/scanComponents.js +12 -13
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +5 -2
- package/dist/halal-core/scanner/scanContent.js +193 -263
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +3 -0
- package/dist/halal-core/scanner/scanDependencies.js +16 -15
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +5 -2
- package/dist/halal-core/scanner/scanDomains.js +12 -12
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +3 -0
- package/dist/halal-core/scanner/scanEnvNames.js +23 -26
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +6 -3
- package/dist/halal-core/scanner/scanMetadata.js +20 -29
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +3 -0
- package/dist/halal-core/scanner/scanPages.js +12 -15
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +15 -10
- package/dist/halal-core/scanner/scanProject.js +43 -49
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +3 -0
- package/dist/halal-core/scanner/scanRoutes.js +32 -39
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +3 -0
- package/dist/halal-core/scanner/scanTranslations.js +21 -29
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +14 -11
- package/dist/halal-core/status.js +0 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +3 -0
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +26 -24
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +3 -0
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +13 -12
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +6 -3
- package/dist/halal-core/tamper/verifyReportSignature.js +20 -14
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.d.ts +20 -1
- package/dist/halal.js +18 -2
- package/dist/i18n/index.d.ts +34 -31
- package/dist/i18n/index.js +219 -288
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +18 -15
- package/dist/i18n/shared.js +204 -266
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +143 -139
- package/dist/icons/index.js +322 -273
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -2
- package/dist/kit/index.d.ts +9 -6
- package/dist/kit/index.js +45 -43
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +7 -4
- package/dist/nitro-server/index.js +6 -2
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +6 -3
- package/dist/node.js +88 -116
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +6 -3
- package/dist/reactivity/computed.js +46 -53
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +8 -5
- package/dist/reactivity/effect.js +105 -146
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.d.ts +8 -8
- package/dist/reactivity/index.js +7 -8
- package/dist/reactivity/reactive.d.ts +3 -0
- package/dist/reactivity/reactive.js +93 -133
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.d.ts +2 -1
- package/dist/reactivity/readonly.js +2 -2
- package/dist/reactivity/ref.d.ts +15 -15
- package/dist/reactivity/ref.js +73 -81
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +3 -1
- package/dist/reactivity/scheduler.js +67 -69
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +17 -14
- package/dist/reactivity/types.js +0 -1
- package/dist/reactivity/utils.d.ts +7 -4
- package/dist/reactivity/utils.js +25 -24
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +4 -2
- package/dist/reactivity/watch.js +75 -103
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +31 -0
- package/dist/runtime/core.js +156 -0
- package/dist/runtime/core.js.map +1 -0
- package/dist/runtime/index.d.ts +487 -461
- package/dist/runtime/index.js +4129 -5254
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.d.ts +7 -0
- package/dist/runtime/reactivity.js +6 -0
- package/dist/runtime/resume.d.ts +79 -0
- package/dist/runtime/resume.js +482 -0
- package/dist/runtime/resume.js.map +1 -0
- package/dist/runtime/router.d.ts +20 -0
- package/dist/runtime/router.js +60 -0
- package/dist/runtime/router.js.map +1 -0
- package/dist/runtime/streaming.d.ts +24 -0
- package/dist/runtime/streaming.js +200 -0
- package/dist/runtime/streaming.js.map +1 -0
- package/dist/security/media-fetch.d.ts +32 -0
- package/dist/security/media-fetch.js +301 -0
- package/dist/security/media-fetch.js.map +1 -0
- package/dist/security/path-boundary.d.ts +7 -0
- package/dist/security/path-boundary.js +70 -0
- package/dist/security/path-boundary.js.map +1 -0
- package/dist/ui/index.d.ts +1580 -1576
- package/dist/ui/index.js +975 -674
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +6 -3
- package/dist/vite-builder/index.js +6 -2
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +46 -86
- package/dist/compiler/implementation.js.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/deploy/types.js.map +0 -1
- package/dist/globals.js.map +0 -1
- package/dist/halal-core/index.js.map +0 -1
- package/dist/halal-core/runtime/index.js.map +0 -1
- package/dist/halal-core/runtime/types.js.map +0 -1
- package/dist/halal-core/status.js.map +0 -1
- package/dist/halal.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactivity/index.js.map +0 -1
- package/dist/reactivity/readonly.js.map +0 -1
- package/dist/reactivity/types.js.map +0 -1
|
@@ -1,101 +1,78 @@
|
|
|
1
1
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
const digest = createHash("sha256").update(payload).digest("hex");
|
|
10
|
-
return `sha256:${digest}`;
|
|
2
|
+
//#region src/halal-core/crypto/integrity.ts
|
|
3
|
+
function createIntegritySignature(value, options) {
|
|
4
|
+
const payload = stableSerialize(value);
|
|
5
|
+
const secret = resolveIntegritySecret(options);
|
|
6
|
+
if (secret) return `hmac-sha256:${createHmac("sha256", secret).update(payload).digest("hex")}`;
|
|
7
|
+
return `sha256:${createHash("sha256").update(payload).digest("hex")}`;
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return constantTimeEqual(expected, signature);
|
|
9
|
+
function verifyIntegritySignature(value, signature, options) {
|
|
10
|
+
if (typeof signature !== "string") return false;
|
|
11
|
+
const separator = signature.indexOf(":");
|
|
12
|
+
if (separator <= 0) return false;
|
|
13
|
+
const algorithm = signature.slice(0, separator);
|
|
14
|
+
if (algorithm !== "hmac-sha256" && algorithm !== "sha256") return false;
|
|
15
|
+
if (options.requireSecret === true && algorithm !== "hmac-sha256") return false;
|
|
16
|
+
let expected;
|
|
17
|
+
try {
|
|
18
|
+
if (algorithm === "hmac-sha256") expected = createIntegritySignature(value, {
|
|
19
|
+
...options,
|
|
20
|
+
requireSecret: true
|
|
21
|
+
});
|
|
22
|
+
else expected = createIntegritySignature(value, {
|
|
23
|
+
...options,
|
|
24
|
+
secret: "",
|
|
25
|
+
requireSecret: false
|
|
26
|
+
});
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return constantTimeEqual(expected, signature);
|
|
40
31
|
}
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
function isAuthenticatedIntegritySignature(signature) {
|
|
33
|
+
return typeof signature === "string" && signature.startsWith("hmac-sha256:");
|
|
43
34
|
}
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
function stableSerialize(value) {
|
|
36
|
+
return JSON.stringify(normalizeJsonValue(value));
|
|
46
37
|
}
|
|
47
38
|
function resolveIntegritySecret(options) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (secret.length < 32) {
|
|
56
|
-
throw new Error(`${options.envName} must contain at least 32 characters.`);
|
|
57
|
-
}
|
|
58
|
-
return secret;
|
|
39
|
+
const secret = options.secret ?? process.env[options.envName];
|
|
40
|
+
if (secret === void 0 || secret === "") {
|
|
41
|
+
if (options.requireSecret === true) throw new Error(`${options.envName} must be configured with at least 32 characters before creating authenticated signatures.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (secret.length < 32) throw new Error(`${options.envName} must contain at least 32 characters.`);
|
|
45
|
+
return secret;
|
|
59
46
|
}
|
|
60
47
|
function normalizeJsonValue(value) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const output = Object.create(null);
|
|
78
|
-
const keys = Object.keys(value).sort(compareCanonicalKeys);
|
|
79
|
-
for (const key of keys) {
|
|
80
|
-
const entry = value[key];
|
|
81
|
-
if (entry !== undefined) {
|
|
82
|
-
output[key] = normalizeJsonValue(entry);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return output;
|
|
86
|
-
}
|
|
87
|
-
throw new TypeError(`Integrity payloads must be JSON-serializable; received ${typeof value}.`);
|
|
48
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
49
|
+
if (typeof value === "number") {
|
|
50
|
+
if (!Number.isFinite(value)) throw new TypeError("Integrity payloads cannot contain non-finite numbers.");
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(value)) return value.map((entry) => entry === void 0 ? null : normalizeJsonValue(entry));
|
|
54
|
+
if (typeof value === "object") {
|
|
55
|
+
const output = Object.create(null);
|
|
56
|
+
const keys = Object.keys(value).sort(compareCanonicalKeys);
|
|
57
|
+
for (const key of keys) {
|
|
58
|
+
const entry = value[key];
|
|
59
|
+
if (entry !== void 0) output[key] = normalizeJsonValue(entry);
|
|
60
|
+
}
|
|
61
|
+
return output;
|
|
62
|
+
}
|
|
63
|
+
throw new TypeError(`Integrity payloads must be JSON-serializable; received ${typeof value}.`);
|
|
88
64
|
}
|
|
89
65
|
function compareCanonicalKeys(left, right) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return 1;
|
|
94
|
-
return 0;
|
|
66
|
+
if (left < right) return -1;
|
|
67
|
+
if (left > right) return 1;
|
|
68
|
+
return 0;
|
|
95
69
|
}
|
|
96
70
|
function constantTimeEqual(left, right) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
71
|
+
const leftBuffer = Buffer.from(left, "utf8");
|
|
72
|
+
const rightBuffer = Buffer.from(right, "utf8");
|
|
73
|
+
return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);
|
|
100
74
|
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { createIntegritySignature, isAuthenticatedIntegritySignature, stableSerialize, verifyIntegritySignature };
|
|
77
|
+
|
|
101
78
|
//# sourceMappingURL=integrity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrity.js","
|
|
1
|
+
{"version":3,"file":"integrity.js","names":[],"sources":["../../../src/halal-core/crypto/integrity.ts"],"sourcesContent":["import { createHash, createHmac, timingSafeEqual } from \"node:crypto\";\n\nexport interface IntegrityOptions {\n envName: string;\n secret?: string;\n requireSecret?: boolean;\n}\n\nexport function createIntegritySignature(value: unknown, options: IntegrityOptions): string {\n const payload = stableSerialize(value);\n const secret = resolveIntegritySecret(options);\n\n if (secret) {\n const digest = createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n return `hmac-sha256:${digest}`;\n }\n\n const digest = createHash(\"sha256\").update(payload).digest(\"hex\");\n return `sha256:${digest}`;\n}\n\nexport function verifyIntegritySignature(\n value: unknown,\n signature: unknown,\n options: IntegrityOptions,\n): boolean {\n if (typeof signature !== \"string\") {\n return false;\n }\n\n const separator = signature.indexOf(\":\");\n if (separator <= 0) {\n return false;\n }\n\n const algorithm = signature.slice(0, separator);\n if (algorithm !== \"hmac-sha256\" && algorithm !== \"sha256\") {\n return false;\n }\n if (options.requireSecret === true && algorithm !== \"hmac-sha256\") {\n return false;\n }\n\n let expected: string;\n try {\n if (algorithm === \"hmac-sha256\") {\n expected = createIntegritySignature(value, { ...options, requireSecret: true });\n } else {\n expected = createIntegritySignature(value, { ...options, secret: \"\", requireSecret: false });\n }\n } catch {\n return false;\n }\n\n return constantTimeEqual(expected, signature);\n}\n\nexport function isAuthenticatedIntegritySignature(signature: unknown): boolean {\n return typeof signature === \"string\" && signature.startsWith(\"hmac-sha256:\");\n}\n\nexport function stableSerialize(value: unknown): string {\n return JSON.stringify(normalizeJsonValue(value));\n}\n\nfunction resolveIntegritySecret(options: IntegrityOptions): string | undefined {\n const secret = options.secret ?? process.env[options.envName];\n if (secret === undefined || secret === \"\") {\n if (options.requireSecret === true) {\n throw new Error(\n `${options.envName} must be configured with at least 32 characters before creating authenticated signatures.`,\n );\n }\n return undefined;\n }\n\n if (secret.length < 32) {\n throw new Error(`${options.envName} must contain at least 32 characters.`);\n }\n return secret;\n}\n\nfunction normalizeJsonValue(value: unknown): unknown {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") {\n return value;\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new TypeError(\"Integrity payloads cannot contain non-finite numbers.\");\n }\n return value;\n }\n if (Array.isArray(value)) {\n return value.map((entry) => entry === undefined ? null : normalizeJsonValue(entry));\n }\n if (typeof value === \"object\") {\n // A null-prototype object preserves special JSON keys such as \"__proto__\"\n // instead of invoking the legacy Object.prototype setter and dropping them\n // from the canonical payload.\n const output: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n const keys = Object.keys(value as Record<string, unknown>).sort(compareCanonicalKeys);\n for (const key of keys) {\n const entry = (value as Record<string, unknown>)[key];\n if (entry !== undefined) {\n output[key] = normalizeJsonValue(entry);\n }\n }\n return output;\n }\n throw new TypeError(`Integrity payloads must be JSON-serializable; received ${typeof value}.`);\n}\n\nfunction compareCanonicalKeys(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n const leftBuffer = Buffer.from(left, \"utf8\");\n const rightBuffer = Buffer.from(right, \"utf8\");\n return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);\n}\n"],"mappings":";;AAQA,SAAgB,yBAAyB,OAAgB,SAAmC;CAC1F,MAAM,UAAU,gBAAgB,KAAK;CACrC,MAAM,SAAS,uBAAuB,OAAO;CAE7C,IAAI,QAEF,OAAO,eADQ,WAAW,UAAU,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KACxC;CAI7B,OAAO,UADQ,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KACrC;AACxB;AAEA,SAAgB,yBACd,OACA,WACA,SACS;CACT,IAAI,OAAO,cAAc,UACvB,OAAO;CAGT,MAAM,YAAY,UAAU,QAAQ,GAAG;CACvC,IAAI,aAAa,GACf,OAAO;CAGT,MAAM,YAAY,UAAU,MAAM,GAAG,SAAS;CAC9C,IAAI,cAAc,iBAAiB,cAAc,UAC/C,OAAO;CAET,IAAI,QAAQ,kBAAkB,QAAQ,cAAc,eAClD,OAAO;CAGT,IAAI;CACJ,IAAI;EACF,IAAI,cAAc,eAChB,WAAW,yBAAyB,OAAO;GAAE,GAAG;GAAS,eAAe;EAAK,CAAC;OAE9E,WAAW,yBAAyB,OAAO;GAAE,GAAG;GAAS,QAAQ;GAAI,eAAe;EAAM,CAAC;CAE/F,QAAQ;EACN,OAAO;CACT;CAEA,OAAO,kBAAkB,UAAU,SAAS;AAC9C;AAEA,SAAgB,kCAAkC,WAA6B;CAC7E,OAAO,OAAO,cAAc,YAAY,UAAU,WAAW,cAAc;AAC7E;AAEA,SAAgB,gBAAgB,OAAwB;CACtD,OAAO,KAAK,UAAU,mBAAmB,KAAK,CAAC;AACjD;AAEA,SAAS,uBAAuB,SAA+C;CAC7E,MAAM,SAAS,QAAQ,UAAU,QAAQ,IAAI,QAAQ;CACrD,IAAI,WAAW,KAAA,KAAa,WAAW,IAAI;EACzC,IAAI,QAAQ,kBAAkB,MAC5B,MAAM,IAAI,MACR,GAAG,QAAQ,QAAQ,0FACrB;EAEF;CACF;CAEA,IAAI,OAAO,SAAS,IAClB,MAAM,IAAI,MAAM,GAAG,QAAQ,QAAQ,sCAAsC;CAE3E,OAAO;AACT;AAEA,SAAS,mBAAmB,OAAyB;CACnD,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAO,UAAU,WAClE,OAAO;CAET,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,CAAC,OAAO,SAAS,KAAK,GACxB,MAAM,IAAI,UAAU,uDAAuD;EAE7E,OAAO;CACT;CACA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,UAAU,UAAU,KAAA,IAAY,OAAO,mBAAmB,KAAK,CAAC;CAEpF,IAAI,OAAO,UAAU,UAAU;EAI7B,MAAM,SAAkC,OAAO,OAAO,IAAI;EAC1D,MAAM,OAAO,OAAO,KAAK,KAAgC,CAAC,CAAC,KAAK,oBAAoB;EACpF,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,QAAS,MAAkC;GACjD,IAAI,UAAU,KAAA,GACZ,OAAO,OAAO,mBAAmB,KAAK;EAE1C;EACA,OAAO;CACT;CACA,MAAM,IAAI,UAAU,0DAA0D,OAAO,MAAM,EAAE;AAC/F;AAEA,SAAS,qBAAqB,MAAc,OAAuB;CACjE,IAAI,OAAO,OAAO,OAAO;CACzB,IAAI,OAAO,OAAO,OAAO;CACzB,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAc,OAAwB;CAC/D,MAAM,aAAa,OAAO,KAAK,MAAM,MAAM;CAC3C,MAAM,cAAc,OAAO,KAAK,OAAO,MAAM;CAC7C,OAAO,WAAW,WAAW,YAAY,UAAU,gBAAgB,YAAY,WAAW;AAC5F"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
//#region src/halal-core/enforce.d.ts
|
|
1
2
|
export declare function enforceDevGuard(appRoot: string, outDir: string): Promise<void>;
|
|
2
3
|
export declare function enforceBuildGuard(appRoot: string, outDir: string): Promise<void>;
|
|
3
4
|
export declare function enforcePreviewGuard(outDir: string): void;
|
|
4
5
|
export declare function enforceProductionServerGuard(outDir: string): void;
|
|
5
6
|
export declare function enforceDeploymentGuard(outDir: string): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
//# sourceMappingURL=enforce.d.ts.map
|
|
@@ -1,119 +1,106 @@
|
|
|
1
|
+
import { loadProjectPolicy } from "./config.js";
|
|
1
2
|
import { scanProject } from "./scanner/scanProject.js";
|
|
2
3
|
import { evaluateRules } from "./rules/defaultBlockedRules.js";
|
|
3
|
-
import { loadProjectPolicy } from "./config.js";
|
|
4
4
|
import { formatTerminalReport } from "./report/formatTerminalReport.js";
|
|
5
5
|
import { generateHalalReport } from "./report/generateHalalReport.js";
|
|
6
6
|
import { createReviewEvidenceHash } from "./review/signedReviewFile.js";
|
|
7
7
|
import { verifyReviewApproval } from "./review/verifyReviewApproval.js";
|
|
8
8
|
import { checkOnDiskReportSignature } from "./tamper/verifyReportSignature.js";
|
|
9
9
|
import { verifyCoreIntegrity } from "./tamper/verifyCoreIntegrity.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
10
|
+
//#region src/halal-core/enforce.ts
|
|
11
|
+
async function enforceDevGuard(appRoot, outDir) {
|
|
12
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return;
|
|
13
|
+
if (!verifyCoreIntegrity(appRoot)) {
|
|
14
|
+
console.error("[resux-halal-core] Framework integrity compromised.");
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const policy = await loadProjectPolicy(appRoot);
|
|
18
|
+
const scanned = scanProject(appRoot);
|
|
19
|
+
const report = evaluateRules(scanned, policy);
|
|
20
|
+
const isStrict = policy.halalAI?.strict === true;
|
|
21
|
+
if (report.status === "review_required") {
|
|
22
|
+
const checkReview = verifyReviewApproval(appRoot, report.status, {
|
|
23
|
+
projectName: policy.projectName,
|
|
24
|
+
evidenceHash: createReviewEvidenceHash(report)
|
|
25
|
+
});
|
|
26
|
+
if (!checkReview.approved) {
|
|
27
|
+
console.error(formatTerminalReport(report));
|
|
28
|
+
console.error(`\x1b[31m[resux-halal-core] Cannot start dev server: ${checkReview.reason}\x1b[0m`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
} else if (report.status === "blocked") {
|
|
32
|
+
console.error(formatTerminalReport(report));
|
|
33
|
+
console.error("\x1B[31m[resux-halal-core] Cannot start dev server: Project violates safety policy.\x1B[0m");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
} else if (report.status === "warning") {
|
|
36
|
+
console.warn(formatTerminalReport(report));
|
|
37
|
+
if (isStrict) {
|
|
38
|
+
console.error("\x1B[31m[resux-halal-core] Dev startup blocked: Strict mode enabled and warnings found.\x1B[0m");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else if (report.status === "warning" && isStrict) {
|
|
84
|
-
console.error(formatTerminalReport(report));
|
|
85
|
-
console.error("\x1b[31m[resux-halal-core] Build failed: Strict mode enabled and warnings found.\x1b[0m");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
43
|
+
async function enforceBuildGuard(appRoot, outDir) {
|
|
44
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return;
|
|
45
|
+
if (!verifyCoreIntegrity(appRoot)) {
|
|
46
|
+
console.error("[resux-halal-core] Framework integrity compromised.");
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const policy = await loadProjectPolicy(appRoot);
|
|
50
|
+
const scanned = scanProject(appRoot);
|
|
51
|
+
const report = generateHalalReport(scanned, policy, outDir, { requireAuthenticated: true });
|
|
52
|
+
const blockProductionBuild = policy.halalAI?.blockProductionBuild !== false;
|
|
53
|
+
const isStrict = policy.halalAI?.strict === true;
|
|
54
|
+
if (report.status === "review_required") {
|
|
55
|
+
const checkReview = verifyReviewApproval(appRoot, report.status, {
|
|
56
|
+
projectName: policy.projectName,
|
|
57
|
+
evidenceHash: createReviewEvidenceHash(report)
|
|
58
|
+
});
|
|
59
|
+
if (!checkReview.approved) {
|
|
60
|
+
console.error(formatTerminalReport(report));
|
|
61
|
+
console.error(`\x1b[31m[resux-halal-core] Build failed: ${checkReview.reason}\x1b[0m`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
} else if (report.status === "blocked") {
|
|
65
|
+
if (blockProductionBuild) {
|
|
66
|
+
console.error(formatTerminalReport(report));
|
|
67
|
+
console.error("\x1B[31m[resux-halal-core] Build failed: Project violates safety policy.\x1B[0m");
|
|
68
|
+
process.exit(1);
|
|
69
|
+
} else {
|
|
70
|
+
console.warn(formatTerminalReport(report));
|
|
71
|
+
console.warn("\x1B[33m[resux-halal-core] Warning: build-time safety violations found, proceeding due to blockProductionBuild = false.\x1B[0m");
|
|
72
|
+
}
|
|
73
|
+
} else if (report.status === "warning" && isStrict) {
|
|
74
|
+
console.error(formatTerminalReport(report));
|
|
75
|
+
console.error("\x1B[31m[resux-halal-core] Build failed: Strict mode enabled and warnings found.\x1B[0m");
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
88
78
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
79
|
+
function enforcePreviewGuard(outDir) {
|
|
80
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return;
|
|
81
|
+
const check = checkOnDiskReportSignature(outDir);
|
|
82
|
+
if (!check.valid) {
|
|
83
|
+
console.error(`\x1b[31m[resux-halal-core] Preview rejected: ${check.reason}\x1b[0m`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
98
86
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
87
|
+
function enforceProductionServerGuard(outDir) {
|
|
88
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return;
|
|
89
|
+
const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });
|
|
90
|
+
if (!check.valid) {
|
|
91
|
+
console.error(`\x1b[31m[resux-halal-core] Production server startup rejected: ${check.reason}\x1b[0m`);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
108
94
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
95
|
+
function enforceDeploymentGuard(outDir) {
|
|
96
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return;
|
|
97
|
+
const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });
|
|
98
|
+
if (!check.valid) {
|
|
99
|
+
console.error(`\x1b[31m[resux-halal-core] Deployment rejected: ${check.reason}\x1b[0m`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
118
102
|
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard };
|
|
105
|
+
|
|
119
106
|
//# sourceMappingURL=enforce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce.js","
|
|
1
|
+
{"version":3,"file":"enforce.js","names":[],"sources":["../../src/halal-core/enforce.ts"],"sourcesContent":["import { scanProject } from \"./scanner/scanProject.js\";\nimport { evaluateRules } from \"./rules/defaultBlockedRules.js\";\nimport { loadProjectPolicy } from \"./config.js\";\nimport { formatTerminalReport } from \"./report/formatTerminalReport.js\";\nimport { generateHalalReport } from \"./report/generateHalalReport.js\";\nimport { createReviewEvidenceHash } from \"./review/signedReviewFile.js\";\nimport { verifyReviewApproval } from \"./review/verifyReviewApproval.js\";\nimport { checkOnDiskReportSignature } from \"./tamper/verifyReportSignature.js\";\nimport { verifyCoreIntegrity } from \"./tamper/verifyCoreIntegrity.js\";\n\nexport async function enforceDevGuard(appRoot: string, outDir: string): Promise<void> {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n if (!verifyCoreIntegrity(appRoot)) {\n console.error(\"[resux-halal-core] Framework integrity compromised.\");\n process.exit(1);\n }\n\n const policy = await loadProjectPolicy(appRoot);\n const scanned = scanProject(appRoot);\n const report = evaluateRules(scanned, policy);\n\n const isStrict = policy.halalAI?.strict === true;\n\n if (report.status === \"review_required\") {\n const checkReview = verifyReviewApproval(appRoot, report.status, {\n projectName: policy.projectName,\n evidenceHash: createReviewEvidenceHash(report),\n });\n if (!checkReview.approved) {\n console.error(formatTerminalReport(report));\n console.error(`\\x1b[31m[resux-halal-core] Cannot start dev server: ${checkReview.reason}\\x1b[0m`);\n process.exit(1);\n }\n } else if (report.status === \"blocked\") {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Cannot start dev server: Project violates safety policy.\\x1b[0m\");\n process.exit(1);\n } else if (report.status === \"warning\") {\n console.warn(formatTerminalReport(report));\n if (isStrict) {\n console.error(\"\\x1b[31m[resux-halal-core] Dev startup blocked: Strict mode enabled and warnings found.\\x1b[0m\");\n process.exit(1);\n }\n }\n}\n\nexport async function enforceBuildGuard(appRoot: string, outDir: string): Promise<void> {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n if (!verifyCoreIntegrity(appRoot)) {\n console.error(\"[resux-halal-core] Framework integrity compromised.\");\n process.exit(1);\n }\n\n const policy = await loadProjectPolicy(appRoot);\n const scanned = scanProject(appRoot);\n const report = generateHalalReport(scanned, policy, outDir, {\n requireAuthenticated: true,\n });\n\n const blockProductionBuild = policy.halalAI?.blockProductionBuild !== false;\n const isStrict = policy.halalAI?.strict === true;\n\n if (report.status === \"review_required\") {\n const checkReview = verifyReviewApproval(appRoot, report.status, {\n projectName: policy.projectName,\n evidenceHash: createReviewEvidenceHash(report),\n });\n if (!checkReview.approved) {\n console.error(formatTerminalReport(report));\n console.error(`\\x1b[31m[resux-halal-core] Build failed: ${checkReview.reason}\\x1b[0m`);\n process.exit(1);\n }\n } else if (report.status === \"blocked\") {\n if (blockProductionBuild) {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Build failed: Project violates safety policy.\\x1b[0m\");\n process.exit(1);\n } else {\n console.warn(formatTerminalReport(report));\n console.warn(\"\\x1b[33m[resux-halal-core] Warning: build-time safety violations found, proceeding due to blockProductionBuild = false.\\x1b[0m\");\n }\n } else if (report.status === \"warning\" && isStrict) {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Build failed: Strict mode enabled and warnings found.\\x1b[0m\");\n process.exit(1);\n }\n}\n\nexport function enforcePreviewGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir);\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Preview rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n\nexport function enforceProductionServerGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Production server startup rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n\nexport function enforceDeploymentGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Deployment rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { HalalCheckResult, HalalGuardStatus } from "./status.js";
|
|
2
|
+
import { HalalAIConfig, ResuxHalalPolicy, ReviewContact, ReviewEvidence, StricterRules, loadMainResuxConfig, loadProjectPolicy, validatePolicyConfig } from "./config.js";
|
|
3
|
+
import { HalalRuntimeAiOptions, HalalRuntimeContent, HalalRuntimeContentKind, HalalRuntimeDecision, HalalRuntimeDecisionSource, HalalRuntimeGuardOptions, HalalRuntimeReviewDecision, HalalRuntimeReviewInput, SignedHalalRuntimeDecision } from "./runtime/types.js";
|
|
4
|
+
import { classifyRuntimeContentWithAi } from "./ai/classifyRuntimeContent.js";
|
|
5
|
+
import { runHalalCheck } from "./cli/check.js";
|
|
6
|
+
import { runHalalExplain } from "./cli/explain.js";
|
|
7
|
+
import { runHalalReport } from "./cli/report.js";
|
|
8
|
+
import { runHalalSubmitReview } from "./cli/submitReview.js";
|
|
9
|
+
import { runHalalVerifyReview } from "./cli/verifyReview.js";
|
|
10
|
+
import { enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard } from "./enforce.js";
|
|
11
|
+
import { defineResuxHalalPolicy } from "./policy.js";
|
|
12
|
+
import { registerHalalCoreHooks } from "./lifecycle.js";
|
|
13
|
+
import { PreparedRuntimeContent, RuntimeContentInspectionIssue, prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical } from "./runtime/serializeRuntimeContent.js";
|
|
14
|
+
import { createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, findReviewedRuntimeDecision, verifySignedHalalRuntimeDecision } from "./runtime/reviewedMemory.js";
|
|
15
|
+
import { HalalRuntimeBlockedError, createHalalRuntimeGuard, evaluateHalalRuntimeContent } from "./runtime/guard.js";
|
|
16
|
+
import { verifyCoreIntegrity } from "./tamper/verifyCoreIntegrity.js";
|
|
17
|
+
import { scanProject } from "./scanner/scanProject.js";
|
|
18
|
+
import { evaluateRules } from "./rules/defaultBlockedRules.js";
|
|
19
|
+
import { formatBrowserOverlayScript } from "./report/formatBrowserOverlay.js";
|
|
20
|
+
export { HalalAIConfig, HalalCheckResult, HalalGuardStatus, HalalRuntimeAiOptions, HalalRuntimeBlockedError, HalalRuntimeContent, HalalRuntimeContentKind, HalalRuntimeDecision, HalalRuntimeDecisionSource, HalalRuntimeGuardOptions, HalalRuntimeReviewDecision, HalalRuntimeReviewInput, PreparedRuntimeContent, ResuxHalalPolicy, ReviewContact, ReviewEvidence, RuntimeContentInspectionIssue, SignedHalalRuntimeDecision, StricterRules, classifyRuntimeContentWithAi, createHalalRuntimeGuard, createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, defineResuxHalalPolicy, enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard, evaluateHalalRuntimeContent, evaluateRules, findReviewedRuntimeDecision, formatBrowserOverlayScript, loadMainResuxConfig, loadProjectPolicy, prepareRuntimeContent, registerHalalCoreHooks, runHalalCheck, runHalalExplain, runHalalReport, runHalalSubmitReview, runHalalVerifyReview, scanProject, serializeRuntimeContent, serializeRuntimeContentCanonical, validatePolicyConfig, verifyCoreIntegrity, verifySignedHalalRuntimeDecision };
|
package/dist/halal-core/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export { formatBrowserOverlayScript
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { loadMainResuxConfig, loadProjectPolicy, validatePolicyConfig } from "./config.js";
|
|
2
|
+
import { defineResuxHalalPolicy } from "./policy.js";
|
|
3
|
+
import { scanProject } from "./scanner/scanProject.js";
|
|
4
|
+
import { evaluateRules } from "./rules/defaultBlockedRules.js";
|
|
5
|
+
import { verifyCoreIntegrity } from "./tamper/verifyCoreIntegrity.js";
|
|
6
|
+
import { enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard } from "./enforce.js";
|
|
7
|
+
import { registerHalalCoreHooks } from "./lifecycle.js";
|
|
8
|
+
import { prepareRuntimeContent, serializeRuntimeContent, serializeRuntimeContentCanonical } from "./runtime/serializeRuntimeContent.js";
|
|
9
|
+
import { createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, findReviewedRuntimeDecision, verifySignedHalalRuntimeDecision } from "./runtime/reviewedMemory.js";
|
|
10
|
+
import { classifyRuntimeContentWithAi } from "./ai/classifyRuntimeContent.js";
|
|
11
|
+
import { HalalRuntimeBlockedError, createHalalRuntimeGuard, evaluateHalalRuntimeContent } from "./runtime/guard.js";
|
|
12
|
+
import { runHalalCheck } from "./cli/check.js";
|
|
13
|
+
import { runHalalReport } from "./cli/report.js";
|
|
14
|
+
import { runHalalExplain } from "./cli/explain.js";
|
|
15
|
+
import { runHalalSubmitReview } from "./cli/submitReview.js";
|
|
16
|
+
import { runHalalVerifyReview } from "./cli/verifyReview.js";
|
|
17
|
+
import { formatBrowserOverlayScript } from "./report/formatBrowserOverlay.js";
|
|
18
|
+
export { HalalRuntimeBlockedError, classifyRuntimeContentWithAi, createHalalRuntimeGuard, createRuntimeContentFingerprint, createSignedHalalRuntimeDecision, defineResuxHalalPolicy, enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard, evaluateHalalRuntimeContent, evaluateRules, findReviewedRuntimeDecision, formatBrowserOverlayScript, loadMainResuxConfig, loadProjectPolicy, prepareRuntimeContent, registerHalalCoreHooks, runHalalCheck, runHalalExplain, runHalalReport, runHalalSubmitReview, runHalalVerifyReview, scanProject, serializeRuntimeContent, serializeRuntimeContentCanonical, validatePolicyConfig, verifyCoreIntegrity, verifySignedHalalRuntimeDecision };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
import { enforceBuildGuard, enforceDevGuard } from "./enforce.js";
|
|
2
|
+
//#region src/halal-core/lifecycle.ts
|
|
3
|
+
function registerHalalCoreHooks(hooks, appRoot, outDir) {
|
|
4
|
+
if (!hooks) return;
|
|
5
|
+
if (typeof hooks.hook === "function") {
|
|
6
|
+
hooks.hook("build:before", async () => {
|
|
7
|
+
await enforceBuildGuard(appRoot, outDir);
|
|
8
|
+
});
|
|
9
|
+
hooks.hook("dev:before", async () => {
|
|
10
|
+
await enforceDevGuard(appRoot, outDir);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
14
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { registerHalalCoreHooks };
|
|
16
|
+
|
|
15
17
|
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","
|
|
1
|
+
{"version":3,"file":"lifecycle.js","names":[],"sources":["../../src/halal-core/lifecycle.ts"],"sourcesContent":["import { enforceDevGuard, enforceBuildGuard } from \"./enforce.js\";\n\nexport function registerHalalCoreHooks(hooks: any, appRoot: string, outDir: string) {\n if (!hooks) return;\n\n // Hook into build:before or compile:before lifecycle\n if (typeof hooks.hook === \"function\") {\n hooks.hook(\"build:before\", async () => {\n await enforceBuildGuard(appRoot, outDir);\n });\n hooks.hook(\"dev:before\", async () => {\n await enforceDevGuard(appRoot, outDir);\n });\n }\n}\n"],"mappings":";;AAEA,SAAgB,uBAAuB,OAAY,SAAiB,QAAgB;CAClF,IAAI,CAAC,OAAO;CAGZ,IAAI,OAAO,MAAM,SAAS,YAAY;EACpC,MAAM,KAAK,gBAAgB,YAAY;GACrC,MAAM,kBAAkB,SAAS,MAAM;EACzC,CAAC;EACD,MAAM,KAAK,cAAc,YAAY;GACnC,MAAM,gBAAgB,SAAS,MAAM;EACvC,CAAC;CACH;AACF"}
|