resuxjs 0.4.0-beta.2 → 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.
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +3 -2
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +9 -8
- package/dist/build/index.js +2 -2
- package/dist/build/index.js.map +1 -1
- package/dist/cli.d.ts +5 -4
- package/dist/cli.js +115 -127
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +6 -5
- package/dist/compiler/adapter.js +2 -1
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +6 -5
- package/dist/compiler/dev-warnings.js +7 -6
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +4 -3
- package/dist/compiler/directives.js +2 -1
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +21 -19
- package/dist/compiler/implementation.js +124 -133
- package/dist/compiler/index.d.ts +6 -5
- package/dist/compiler/index.js +2 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +7 -5
- package/dist/core/config.js +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +7 -6
- package/dist/core/hooks.js +1 -1
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/module-container.d.ts +22 -20
- package/dist/core/module-container.js +3 -3
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +5 -3
- package/dist/core/resux.js +2 -1
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -1
- package/dist/create-bin.js +3 -2
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +3 -2
- package/dist/create.js +7 -10
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +3 -1
- package/dist/deploy/cloudflare.js +2 -1
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +13 -11
- package/dist/deploy/common.js +2 -1
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +2 -1
- package/dist/deploy/framework-runtime.js +2 -1
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +4 -2
- package/dist/deploy/index.js +4 -6
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +3 -1
- package/dist/deploy/netlify.js +2 -1
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +3 -1
- package/dist/deploy/node.js +3 -3
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +2 -1
- package/dist/deploy/production-report.js +2 -1
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +5 -4
- package/dist/deploy/runtime-dependencies.js +3 -3
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +3 -1
- package/dist/deploy/static.js +2 -1
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +8 -7
- package/dist/deploy/types.js +1 -1
- package/dist/deploy/vercel.d.ts +4 -2
- package/dist/deploy/vercel.js +2 -1
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +5 -4
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +2 -2
- package/dist/globals.js +1 -1
- package/dist/halal-core/ai/classifyProject.d.ts +5 -3
- package/dist/halal-core/ai/classifyProject.js +2 -1
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +3 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js +2 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +2 -1
- package/dist/halal-core/ai/createProjectSummary.js +2 -1
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +2 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +2 -1
- package/dist/halal-core/ai/redactSensitiveData.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +3 -1
- package/dist/halal-core/ai/validateAiResponse.js +3 -3
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +2 -1
- package/dist/halal-core/cli/check.js +3 -3
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +2 -1
- package/dist/halal-core/cli/explain.js +3 -3
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +2 -1
- package/dist/halal-core/cli/report.js +3 -3
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +2 -1
- package/dist/halal-core/cli/submitReview.js +3 -3
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +2 -1
- package/dist/halal-core/cli/verifyReview.js +3 -4
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +9 -8
- package/dist/halal-core/config.js +2 -1
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +6 -5
- package/dist/halal-core/crypto/integrity.js +2 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +6 -5
- package/dist/halal-core/enforce.js +13 -15
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.js +2 -1
- package/dist/halal-core/lifecycle.d.ts +2 -1
- package/dist/halal-core/lifecycle.js +2 -1
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +3 -1
- package/dist/halal-core/policy.js +2 -1
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +3 -1
- package/dist/halal-core/report/formatBrowserOverlay.js +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +3 -1
- package/dist/halal-core/report/formatTerminalReport.js +1 -1
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +4 -2
- package/dist/halal-core/report/generateHalalReport.js +5 -7
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +4 -2
- package/dist/halal-core/report/signReport.js +2 -1
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +5 -3
- package/dist/halal-core/report/verifyReport.js +4 -3
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +3 -1
- package/dist/halal-core/review/createReviewRequest.js +3 -3
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +4 -3
- package/dist/halal-core/review/reviewPolicy.js +1 -1
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +6 -4
- package/dist/halal-core/review/signedReviewFile.js +2 -1
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +3 -2
- package/dist/halal-core/review/verifyReviewApproval.js +2 -1
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +3 -2
- package/dist/halal-core/rules/adultContentRules.js +1 -1
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +3 -2
- package/dist/halal-core/rules/childSafetyRules.js +1 -1
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +3 -2
- package/dist/halal-core/rules/coreCategories.js +1 -1
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/cyberAbuseRules.js +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +3 -1
- package/dist/halal-core/rules/defaultBlockedRules.js +9 -11
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +3 -2
- package/dist/halal-core/rules/dependencyRules.js +1 -1
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +3 -2
- package/dist/halal-core/rules/endpointRules.js +1 -1
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/environmentalHarmRules.js +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +3 -2
- package/dist/halal-core/rules/financeRibaRules.js +1 -1
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +3 -2
- package/dist/halal-core/rules/gamblingRules.js +1 -1
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/generalHarmRules.js +1 -1
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/healthHarmRules.js +1 -1
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +2 -1
- package/dist/halal-core/rules/keywordRules.js +1 -1
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/privacyAbuseRules.js +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +3 -2
- package/dist/halal-core/rules/scamFraudRules.js +1 -1
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/selfHarmRules.js +1 -1
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -2
- package/dist/halal-core/rules/violenceExtremismRules.js +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +5 -3
- package/dist/halal-core/runtime/guard.js +2 -1
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.js +2 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +6 -4
- package/dist/halal-core/runtime/reviewedMemory.js +3 -2
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +7 -5
- package/dist/halal-core/runtime/serializeRuntimeContent.js +4 -3
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +11 -9
- package/dist/halal-core/runtime/types.js +1 -1
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +2 -1
- package/dist/halal-core/scanner/scanComponents.js +2 -1
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +3 -2
- package/dist/halal-core/scanner/scanContent.js +4 -3
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +2 -1
- package/dist/halal-core/scanner/scanDependencies.js +2 -1
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +2 -1
- package/dist/halal-core/scanner/scanDomains.js +1 -1
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +3 -2
- package/dist/halal-core/scanner/scanMetadata.js +2 -1
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +2 -1
- package/dist/halal-core/scanner/scanPages.js +2 -1
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +4 -2
- package/dist/halal-core/scanner/scanProject.js +2 -1
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanRoutes.js +2 -1
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +2 -1
- package/dist/halal-core/scanner/scanTranslations.js +2 -1
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +3 -2
- package/dist/halal-core/status.js +1 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +2 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +3 -1
- package/dist/halal-core/tamper/verifyReportSignature.js +3 -3
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.js +2 -1
- package/dist/i18n/index.d.ts +12 -11
- package/dist/i18n/index.js +5 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +15 -14
- package/dist/i18n/shared.js +4 -4
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +20 -18
- package/dist/icons/index.js +5 -4
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/kit/index.d.ts +23 -21
- package/dist/kit/index.js +2 -1
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +3 -2
- package/dist/nitro-server/index.js +1 -1
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +4 -2
- package/dist/node.js +7 -6
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +5 -3
- package/dist/reactivity/computed.js +3 -3
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +15 -13
- package/dist/reactivity/effect.js +9 -10
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.js +2 -1
- package/dist/reactivity/reactive.d.ts +6 -5
- package/dist/reactivity/reactive.js +5 -4
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.js +2 -1
- package/dist/reactivity/ref.d.ts +9 -7
- package/dist/reactivity/ref.js +2 -4
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +5 -4
- package/dist/reactivity/scheduler.js +1 -1
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +12 -11
- package/dist/reactivity/types.js +1 -1
- package/dist/reactivity/utils.d.ts +10 -9
- package/dist/reactivity/utils.js +1 -1
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +4 -2
- package/dist/reactivity/watch.js +4 -5
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +5 -4
- package/dist/runtime/core.js +9 -10
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +123 -122
- package/dist/runtime/index.js +45 -58
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.js +2 -1
- package/dist/runtime/resume.d.ts +15 -14
- package/dist/runtime/resume.js +3 -3
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +5 -4
- package/dist/runtime/router.js +1 -1
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +7 -6
- package/dist/runtime/streaming.js +3 -3
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/security/media-fetch.d.ts +11 -10
- package/dist/security/media-fetch.js +5 -4
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +5 -4
- package/dist/security/path-boundary.js +2 -1
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +195 -193
- package/dist/ui/index.js +7 -8
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +3 -2
- package/dist/vite-builder/index.js +1 -1
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
//#region src/halal-core/config.d.ts
|
|
2
|
-
|
|
2
|
+
interface ReviewContact {
|
|
3
3
|
name: string;
|
|
4
4
|
email: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
interface ReviewEvidence {
|
|
7
7
|
type: string;
|
|
8
8
|
path: string;
|
|
9
9
|
description: string;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
interface StricterRules {
|
|
12
12
|
blockAiChatWithoutModeration?: boolean;
|
|
13
13
|
blockUnmoderatedUserUploads?: boolean;
|
|
14
14
|
[key: string]: boolean | undefined;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
interface HalalAIConfig {
|
|
17
17
|
enabled?: boolean;
|
|
18
18
|
strict?: boolean;
|
|
19
19
|
blockProductionBuild?: boolean;
|
|
@@ -25,7 +25,7 @@ export interface HalalAIConfig {
|
|
|
25
25
|
scanDependencies?: boolean;
|
|
26
26
|
categories?: Record<string, "block" | "warn" | "review" | "allow">;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
interface ResuxHalalPolicy {
|
|
29
29
|
projectName?: string;
|
|
30
30
|
projectType?: string;
|
|
31
31
|
description?: string;
|
|
@@ -36,8 +36,9 @@ export interface ResuxHalalPolicy {
|
|
|
36
36
|
internalTeamNotes?: string;
|
|
37
37
|
halalAI?: HalalAIConfig;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
declare function validatePolicyConfig(config: Record<string, any>): ResuxHalalPolicy;
|
|
40
|
+
declare function loadMainResuxConfig(appRoot: string): Promise<Record<string, any>>;
|
|
41
|
+
declare function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy>;
|
|
42
42
|
//#endregion
|
|
43
|
+
export { HalalAIConfig, ResuxHalalPolicy, ReviewContact, ReviewEvidence, StricterRules, loadMainResuxConfig, loadProjectPolicy, validatePolicyConfig };
|
|
43
44
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
+
|
|
5
6
|
//#region src/halal-core/config.ts
|
|
6
7
|
const FORBIDDEN_FIELDS = [
|
|
7
8
|
"enabled",
|
|
@@ -80,7 +81,7 @@ async function loadProjectPolicy(appRoot) {
|
|
|
80
81
|
}
|
|
81
82
|
return validatePolicyConfig(policy);
|
|
82
83
|
}
|
|
84
|
+
|
|
83
85
|
//#endregion
|
|
84
86
|
export { loadMainResuxConfig, loadProjectPolicy, validatePolicyConfig };
|
|
85
|
-
|
|
86
87
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../../src/halal-core/config.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport ts from \"typescript\";\n\nexport interface ReviewContact {\n name: string;\n email: string;\n}\n\nexport interface ReviewEvidence {\n type: string;\n path: string;\n description: string;\n}\n\nexport interface StricterRules {\n blockAiChatWithoutModeration?: boolean;\n blockUnmoderatedUserUploads?: boolean;\n [key: string]: boolean | undefined;\n}\n\nexport interface HalalAIConfig {\n enabled?: boolean;\n strict?: boolean;\n blockProductionBuild?: boolean;\n scanRoutes?: boolean;\n scanMeta?: boolean;\n scanContent?: boolean;\n scanExternalLinks?: boolean;\n scanRuntimeConfig?: boolean;\n scanDependencies?: boolean;\n categories?: Record<string, \"block\" | \"warn\" | \"review\" | \"allow\">;\n}\n\nexport interface ResuxHalalPolicy {\n projectName?: string;\n projectType?: string;\n description?: string;\n reviewContact?: ReviewContact;\n stricterRules?: StricterRules;\n additionalBlockedCategories?: string[];\n evidence?: ReviewEvidence[];\n internalTeamNotes?: string;\n halalAI?: HalalAIConfig;\n}\n\nconst FORBIDDEN_FIELDS = [\n \"enabled\",\n \"mode\",\n \"ignoreCoreRules\",\n \"allowBlockedCategories\",\n \"disableHarmDetection\",\n \"removeDefaultRules\",\n \"halalGuard\",\n];\n\nexport function validatePolicyConfig(config: Record<string, any>): ResuxHalalPolicy {\n if (!config) {\n return {};\n }\n\n for (const field of FORBIDDEN_FIELDS) {\n if (field in config) {\n throw new Error(\n `[resux-halal-core] Invalid configuration field \"${field}\". You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n if (config.halalAI) {\n if (config.halalAI.enabled === false) {\n throw new Error(\n `[resux-halal-core] Invalid configuration: \"halalAI.enabled\" cannot be set to false. You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n // Basic validation of types\n if (config.projectName && typeof config.projectName !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectName' must be a string.\");\n }\n if (config.projectType && typeof config.projectType !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectType' must be a string.\");\n }\n if (config.description && typeof config.description !== \"string\") {\n throw new Error(\"[resux-halal-core] 'description' must be a string.\");\n }\n\n return config as ResuxHalalPolicy;\n}\n\nexport async function loadMainResuxConfig(appRoot: string): Promise<Record<string, any>> {\n const possiblePaths = [\n path.join(appRoot, \"resux.config.ts\"),\n path.join(appRoot, \"resux.config.js\"),\n path.join(appRoot, \"resux.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n let compiledSource: string;\n if (configPath.endsWith(\".ts\")) {\n const source = readFileSync(configPath, \"utf8\");\n const normalized = source.replace(/\\bdefineResuxConfig\\s*\\(/g, \"(\");\n compiledSource = ts.transpileModule(normalized, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.ES2022\n }\n }).outputText;\n } else {\n compiledSource = readFileSync(configPath, \"utf8\");\n }\n\n const tempDir = path.join(appRoot, \".resux\", \"server\");\n const fs = await import(\"node:fs\");\n if (!fs.existsSync(tempDir)) {\n fs.mkdirSync(tempDir, { recursive: true });\n }\n const tempPath = path.join(tempDir, `halal-temp-config-${Date.now()}.mjs`);\n fs.writeFileSync(tempPath, compiledSource, \"utf8\");\n\n try {\n const fileUrl = pathToFileURL(tempPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n return config;\n } finally {\n try {\n fs.unlinkSync(tempPath);\n } catch {}\n }\n } catch (err: any) {\n console.warn(`[resux-halal-core] Warning: failed to load resux.config.ts for Halal AI check: ${err.message}`);\n }\n }\n }\n return {};\n}\n\nexport async function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy> {\n const policy: ResuxHalalPolicy = {};\n\n try {\n const mainConfig = await loadMainResuxConfig(appRoot);\n if (mainConfig.halalAI) {\n policy.halalAI = mainConfig.halalAI;\n }\n if (mainConfig.projectType) {\n policy.projectType = mainConfig.projectType;\n }\n } catch (err: any) {\n if (err.message.includes(\"not permitted to disable\")) {\n throw err;\n }\n }\n\n const possiblePaths = [\n path.join(appRoot, \"resux.halal.config.ts\"),\n path.join(appRoot, \"resux.halal.config.js\"),\n path.join(appRoot, \"resux.halal.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n const fileUrl = pathToFileURL(configPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n const validated = validatePolicyConfig(config);\n Object.assign(policy, validated);\n break;\n } catch (err: any) {\n throw new Error(`[resux-halal-core] Failed to load halal configuration at ${configPath}: ${err.message}`);\n }\n }\n }\n\n return validatePolicyConfig(policy);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../src/halal-core/config.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport ts from \"typescript\";\n\nexport interface ReviewContact {\n name: string;\n email: string;\n}\n\nexport interface ReviewEvidence {\n type: string;\n path: string;\n description: string;\n}\n\nexport interface StricterRules {\n blockAiChatWithoutModeration?: boolean;\n blockUnmoderatedUserUploads?: boolean;\n [key: string]: boolean | undefined;\n}\n\nexport interface HalalAIConfig {\n enabled?: boolean;\n strict?: boolean;\n blockProductionBuild?: boolean;\n scanRoutes?: boolean;\n scanMeta?: boolean;\n scanContent?: boolean;\n scanExternalLinks?: boolean;\n scanRuntimeConfig?: boolean;\n scanDependencies?: boolean;\n categories?: Record<string, \"block\" | \"warn\" | \"review\" | \"allow\">;\n}\n\nexport interface ResuxHalalPolicy {\n projectName?: string;\n projectType?: string;\n description?: string;\n reviewContact?: ReviewContact;\n stricterRules?: StricterRules;\n additionalBlockedCategories?: string[];\n evidence?: ReviewEvidence[];\n internalTeamNotes?: string;\n halalAI?: HalalAIConfig;\n}\n\nconst FORBIDDEN_FIELDS = [\n \"enabled\",\n \"mode\",\n \"ignoreCoreRules\",\n \"allowBlockedCategories\",\n \"disableHarmDetection\",\n \"removeDefaultRules\",\n \"halalGuard\",\n];\n\nexport function validatePolicyConfig(config: Record<string, any>): ResuxHalalPolicy {\n if (!config) {\n return {};\n }\n\n for (const field of FORBIDDEN_FIELDS) {\n if (field in config) {\n throw new Error(\n `[resux-halal-core] Invalid configuration field \"${field}\". You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n if (config.halalAI) {\n if (config.halalAI.enabled === false) {\n throw new Error(\n `[resux-halal-core] Invalid configuration: \"halalAI.enabled\" cannot be set to false. You are not permitted to disable, bypass, or weaken the core safety and halal guidelines of ResuxJS.`\n );\n }\n }\n\n // Basic validation of types\n if (config.projectName && typeof config.projectName !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectName' must be a string.\");\n }\n if (config.projectType && typeof config.projectType !== \"string\") {\n throw new Error(\"[resux-halal-core] 'projectType' must be a string.\");\n }\n if (config.description && typeof config.description !== \"string\") {\n throw new Error(\"[resux-halal-core] 'description' must be a string.\");\n }\n\n return config as ResuxHalalPolicy;\n}\n\nexport async function loadMainResuxConfig(appRoot: string): Promise<Record<string, any>> {\n const possiblePaths = [\n path.join(appRoot, \"resux.config.ts\"),\n path.join(appRoot, \"resux.config.js\"),\n path.join(appRoot, \"resux.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n let compiledSource: string;\n if (configPath.endsWith(\".ts\")) {\n const source = readFileSync(configPath, \"utf8\");\n const normalized = source.replace(/\\bdefineResuxConfig\\s*\\(/g, \"(\");\n compiledSource = ts.transpileModule(normalized, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.ES2022\n }\n }).outputText;\n } else {\n compiledSource = readFileSync(configPath, \"utf8\");\n }\n\n const tempDir = path.join(appRoot, \".resux\", \"server\");\n const fs = await import(\"node:fs\");\n if (!fs.existsSync(tempDir)) {\n fs.mkdirSync(tempDir, { recursive: true });\n }\n const tempPath = path.join(tempDir, `halal-temp-config-${Date.now()}.mjs`);\n fs.writeFileSync(tempPath, compiledSource, \"utf8\");\n\n try {\n const fileUrl = pathToFileURL(tempPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n return config;\n } finally {\n try {\n fs.unlinkSync(tempPath);\n } catch {}\n }\n } catch (err: any) {\n console.warn(`[resux-halal-core] Warning: failed to load resux.config.ts for Halal AI check: ${err.message}`);\n }\n }\n }\n return {};\n}\n\nexport async function loadProjectPolicy(appRoot: string): Promise<ResuxHalalPolicy> {\n const policy: ResuxHalalPolicy = {};\n\n try {\n const mainConfig = await loadMainResuxConfig(appRoot);\n if (mainConfig.halalAI) {\n policy.halalAI = mainConfig.halalAI;\n }\n if (mainConfig.projectType) {\n policy.projectType = mainConfig.projectType;\n }\n } catch (err: any) {\n if (err.message.includes(\"not permitted to disable\")) {\n throw err;\n }\n }\n\n const possiblePaths = [\n path.join(appRoot, \"resux.halal.config.ts\"),\n path.join(appRoot, \"resux.halal.config.js\"),\n path.join(appRoot, \"resux.halal.config.mjs\"),\n ];\n\n for (const configPath of possiblePaths) {\n if (existsSync(configPath)) {\n try {\n const fileUrl = pathToFileURL(configPath).href;\n const module = await import(fileUrl);\n const config = module.default || module;\n const validated = validatePolicyConfig(config);\n Object.assign(policy, validated);\n break;\n } catch (err: any) {\n throw new Error(`[resux-halal-core] Failed to load halal configuration at ${configPath}: ${err.message}`);\n }\n }\n }\n\n return validatePolicyConfig(policy);\n}\n"],"mappings":";;;;;;AA+CA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,qBAAqB,QAA+C;AAClF,KAAI,CAAC,OACH,QAAO,EAAE;AAGX,MAAK,MAAM,SAAS,iBAClB,KAAI,SAAS,OACX,OAAM,IAAI,MACR,mDAAmD,MAAM,yGAC1D;AAIL,KAAI,OAAO,SACT;MAAI,OAAO,QAAQ,YAAY,MAC7B,OAAM,IAAI,MACR,2LACD;;AAKL,KAAI,OAAO,eAAe,OAAO,OAAO,gBAAgB,SACtD,OAAM,IAAI,MAAM,qDAAqD;AAEvE,KAAI,OAAO,eAAe,OAAO,OAAO,gBAAgB,SACtD,OAAM,IAAI,MAAM,qDAAqD;AAEvE,KAAI,OAAO,eAAe,OAAO,OAAO,gBAAgB,SACtD,OAAM,IAAI,MAAM,qDAAqD;AAGvE,QAAO;;AAGT,eAAsB,oBAAoB,SAA+C;CACvF,MAAM,gBAAgB;EACpB,KAAK,KAAK,SAAS,kBAAkB;EACrC,KAAK,KAAK,SAAS,kBAAkB;EACrC,KAAK,KAAK,SAAS,mBAAmB;EACvC;AAED,MAAK,MAAM,cAAc,cACvB,KAAI,WAAW,WAAW,CACxB,KAAI;EACF,IAAI;AACJ,MAAI,WAAW,SAAS,MAAM,EAAE;GAE9B,MAAM,aADS,aAAa,YAAY,OAAO,CACrB,QAAQ,6BAA6B,IAAI;AACnE,oBAAiB,GAAG,gBAAgB,YAAY,EAC9C,iBAAiB;IACf,QAAQ,GAAG,aAAa;IACxB,QAAQ,GAAG,WAAW;IACvB,EACF,CAAC,CAAC;QAEH,kBAAiB,aAAa,YAAY,OAAO;EAGnD,MAAM,UAAU,KAAK,KAAK,SAAS,UAAU,SAAS;EACtD,MAAM,KAAK,MAAM,OAAO;AACxB,MAAI,CAAC,GAAG,WAAW,QAAQ,CACzB,IAAG,UAAU,SAAS,EAAE,WAAW,MAAM,CAAC;EAE5C,MAAM,WAAW,KAAK,KAAK,SAAS,qBAAqB,KAAK,KAAK,CAAC,MAAM;AAC1E,KAAG,cAAc,UAAU,gBAAgB,OAAO;AAElD,MAAI;GAEF,MAAM,SAAS,MAAM,OADL,cAAc,SAAS,CAAC;AAGxC,UADe,OAAO,WAAW;YAEzB;AACR,OAAI;AACF,OAAG,WAAW,SAAS;WACjB;;UAEH,KAAU;AACjB,UAAQ,KAAK,kFAAkF,IAAI,UAAU;;AAInH,QAAO,EAAE;;AAGX,eAAsB,kBAAkB,SAA4C;CAClF,MAAM,SAA2B,EAAE;AAEnC,KAAI;EACF,MAAM,aAAa,MAAM,oBAAoB,QAAQ;AACrD,MAAI,WAAW,QACb,QAAO,UAAU,WAAW;AAE9B,MAAI,WAAW,YACb,QAAO,cAAc,WAAW;UAE3B,KAAU;AACjB,MAAI,IAAI,QAAQ,SAAS,2BAA2B,CAClD,OAAM;;CAIV,MAAM,gBAAgB;EACpB,KAAK,KAAK,SAAS,wBAAwB;EAC3C,KAAK,KAAK,SAAS,wBAAwB;EAC3C,KAAK,KAAK,SAAS,yBAAyB;EAC7C;AAED,MAAK,MAAM,cAAc,cACvB,KAAI,WAAW,WAAW,CACxB,KAAI;EAEF,MAAM,SAAS,MAAM,OADL,cAAc,WAAW,CAAC;EAG1C,MAAM,YAAY,qBADH,OAAO,WAAW,OACa;AAC9C,SAAO,OAAO,QAAQ,UAAU;AAChC;UACO,KAAU;AACjB,QAAM,IAAI,MAAM,4DAA4D,WAAW,IAAI,IAAI,UAAU;;AAK/G,QAAO,qBAAqB,OAAO"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
//#region src/halal-core/crypto/integrity.d.ts
|
|
2
|
-
|
|
2
|
+
interface IntegrityOptions {
|
|
3
3
|
envName: string;
|
|
4
4
|
secret?: string;
|
|
5
5
|
requireSecret?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
declare function createIntegritySignature(value: unknown, options: IntegrityOptions): string;
|
|
8
|
+
declare function verifyIntegritySignature(value: unknown, signature: unknown, options: IntegrityOptions): boolean;
|
|
9
|
+
declare function isAuthenticatedIntegritySignature(signature: unknown): boolean;
|
|
10
|
+
declare function stableSerialize(value: unknown): string;
|
|
11
11
|
//#endregion
|
|
12
|
+
export { IntegrityOptions, createIntegritySignature, isAuthenticatedIntegritySignature, stableSerialize, verifyIntegritySignature };
|
|
12
13
|
//# sourceMappingURL=integrity.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/crypto/integrity.ts
|
|
3
4
|
function createIntegritySignature(value, options) {
|
|
4
5
|
const payload = stableSerialize(value);
|
|
@@ -72,7 +73,7 @@ function constantTimeEqual(left, right) {
|
|
|
72
73
|
const rightBuffer = Buffer.from(right, "utf8");
|
|
73
74
|
return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);
|
|
74
75
|
}
|
|
76
|
+
|
|
75
77
|
//#endregion
|
|
76
78
|
export { createIntegritySignature, isAuthenticatedIntegritySignature, stableSerialize, verifyIntegritySignature };
|
|
77
|
-
|
|
78
79
|
//# sourceMappingURL=integrity.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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,MAAM;CACtC,MAAM,SAAS,uBAAuB,QAAQ;AAE9C,KAAI,OAEF,QAAO,eADQ,WAAW,UAAU,OAAO,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM;AAK3E,QAAO,UADQ,WAAW,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM;;AAInE,SAAgB,yBACd,OACA,WACA,SACS;AACT,KAAI,OAAO,cAAc,SACvB,QAAO;CAGT,MAAM,YAAY,UAAU,QAAQ,IAAI;AACxC,KAAI,aAAa,EACf,QAAO;CAGT,MAAM,YAAY,UAAU,MAAM,GAAG,UAAU;AAC/C,KAAI,cAAc,iBAAiB,cAAc,SAC/C,QAAO;AAET,KAAI,QAAQ,kBAAkB,QAAQ,cAAc,cAClD,QAAO;CAGT,IAAI;AACJ,KAAI;AACF,MAAI,cAAc,cAChB,YAAW,yBAAyB,OAAO;GAAE,GAAG;GAAS,eAAe;GAAM,CAAC;MAE/E,YAAW,yBAAyB,OAAO;GAAE,GAAG;GAAS,QAAQ;GAAI,eAAe;GAAO,CAAC;SAExF;AACN,SAAO;;AAGT,QAAO,kBAAkB,UAAU,UAAU;;AAG/C,SAAgB,kCAAkC,WAA6B;AAC7E,QAAO,OAAO,cAAc,YAAY,UAAU,WAAW,eAAe;;AAG9E,SAAgB,gBAAgB,OAAwB;AACtD,QAAO,KAAK,UAAU,mBAAmB,MAAM,CAAC;;AAGlD,SAAS,uBAAuB,SAA+C;CAC7E,MAAM,SAAS,QAAQ,UAAU,QAAQ,IAAI,QAAQ;AACrD,KAAI,WAAW,UAAa,WAAW,IAAI;AACzC,MAAI,QAAQ,kBAAkB,KAC5B,OAAM,IAAI,MACR,GAAG,QAAQ,QAAQ,2FACpB;AAEH;;AAGF,KAAI,OAAO,SAAS,GAClB,OAAM,IAAI,MAAM,GAAG,QAAQ,QAAQ,uCAAuC;AAE5E,QAAO;;AAGT,SAAS,mBAAmB,OAAyB;AACnD,KAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAO,UAAU,UAClE,QAAO;AAET,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,CAAC,OAAO,SAAS,MAAM,CACzB,OAAM,IAAI,UAAU,wDAAwD;AAE9E,SAAO;;AAET,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,KAAK,UAAU,UAAU,SAAY,OAAO,mBAAmB,MAAM,CAAC;AAErF,KAAI,OAAO,UAAU,UAAU;EAI7B,MAAM,SAAkC,OAAO,OAAO,KAAK;EAC3D,MAAM,OAAO,OAAO,KAAK,MAAiC,CAAC,KAAK,qBAAqB;AACrF,OAAK,MAAM,OAAO,MAAM;GACtB,MAAM,QAAS,MAAkC;AACjD,OAAI,UAAU,OACZ,QAAO,OAAO,mBAAmB,MAAM;;AAG3C,SAAO;;AAET,OAAM,IAAI,UAAU,0DAA0D,OAAO,MAAM,GAAG;;AAGhG,SAAS,qBAAqB,MAAc,OAAuB;AACjE,KAAI,OAAO,MAAO,QAAO;AACzB,KAAI,OAAO,MAAO,QAAO;AACzB,QAAO;;AAGT,SAAS,kBAAkB,MAAc,OAAwB;CAC/D,MAAM,aAAa,OAAO,KAAK,MAAM,OAAO;CAC5C,MAAM,cAAc,OAAO,KAAK,OAAO,OAAO;AAC9C,QAAO,WAAW,WAAW,YAAY,UAAU,gBAAgB,YAAY,YAAY"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
//#region src/halal-core/enforce.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
declare function enforceDevGuard(appRoot: string, outDir: string): Promise<void>;
|
|
3
|
+
declare function enforceBuildGuard(appRoot: string, outDir: string): Promise<void>;
|
|
4
|
+
declare function enforcePreviewGuard(outDir: string): void;
|
|
5
|
+
declare function enforceProductionServerGuard(outDir: string): void;
|
|
6
|
+
declare function enforceDeploymentGuard(outDir: string): void;
|
|
7
7
|
//#endregion
|
|
8
|
+
export { enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard };
|
|
8
9
|
//# sourceMappingURL=enforce.d.ts.map
|
|
@@ -7,6 +7,7 @@ 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
|
+
|
|
10
11
|
//#region src/halal-core/enforce.ts
|
|
11
12
|
async function enforceDevGuard(appRoot, outDir) {
|
|
12
13
|
if (process.env.VITEST || process.env.NODE_ENV === "test") return;
|
|
@@ -15,8 +16,7 @@ async function enforceDevGuard(appRoot, outDir) {
|
|
|
15
16
|
process.exit(1);
|
|
16
17
|
}
|
|
17
18
|
const policy = await loadProjectPolicy(appRoot);
|
|
18
|
-
const
|
|
19
|
-
const report = evaluateRules(scanned, policy);
|
|
19
|
+
const report = evaluateRules(scanProject(appRoot), policy);
|
|
20
20
|
const isStrict = policy.halalAI?.strict === true;
|
|
21
21
|
if (report.status === "review_required") {
|
|
22
22
|
const checkReview = verifyReviewApproval(appRoot, report.status, {
|
|
@@ -47,8 +47,7 @@ async function enforceBuildGuard(appRoot, outDir) {
|
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
const policy = await loadProjectPolicy(appRoot);
|
|
50
|
-
const
|
|
51
|
-
const report = generateHalalReport(scanned, policy, outDir, { requireAuthenticated: true });
|
|
50
|
+
const report = generateHalalReport(scanProject(appRoot), policy, outDir, { requireAuthenticated: true });
|
|
52
51
|
const blockProductionBuild = policy.halalAI?.blockProductionBuild !== false;
|
|
53
52
|
const isStrict = policy.halalAI?.strict === true;
|
|
54
53
|
if (report.status === "review_required") {
|
|
@@ -61,16 +60,15 @@ async function enforceBuildGuard(appRoot, outDir) {
|
|
|
61
60
|
console.error(`\x1b[31m[resux-halal-core] Build failed: ${checkReview.reason}\x1b[0m`);
|
|
62
61
|
process.exit(1);
|
|
63
62
|
}
|
|
64
|
-
} else if (report.status === "blocked") {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else if (report.status === "warning" && isStrict) {
|
|
63
|
+
} else if (report.status === "blocked") if (blockProductionBuild) {
|
|
64
|
+
console.error(formatTerminalReport(report));
|
|
65
|
+
console.error("\x1B[31m[resux-halal-core] Build failed: Project violates safety policy.\x1B[0m");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
} else {
|
|
68
|
+
console.warn(formatTerminalReport(report));
|
|
69
|
+
console.warn("\x1B[33m[resux-halal-core] Warning: build-time safety violations found, proceeding due to blockProductionBuild = false.\x1B[0m");
|
|
70
|
+
}
|
|
71
|
+
else if (report.status === "warning" && isStrict) {
|
|
74
72
|
console.error(formatTerminalReport(report));
|
|
75
73
|
console.error("\x1B[31m[resux-halal-core] Build failed: Strict mode enabled and warnings found.\x1B[0m");
|
|
76
74
|
process.exit(1);
|
|
@@ -100,7 +98,7 @@ function enforceDeploymentGuard(outDir) {
|
|
|
100
98
|
process.exit(1);
|
|
101
99
|
}
|
|
102
100
|
}
|
|
101
|
+
|
|
103
102
|
//#endregion
|
|
104
103
|
export { enforceBuildGuard, enforceDeploymentGuard, enforceDevGuard, enforcePreviewGuard, enforceProductionServerGuard };
|
|
105
|
-
|
|
106
104
|
//# sourceMappingURL=enforce.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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":";;;;;;;;;;;AAUA,eAAsB,gBAAgB,SAAiB,QAA+B;AACpF,KAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,OACjD;AAGF,KAAI,CAAC,oBAAoB,QAAQ,EAAE;AACjC,UAAQ,MAAM,sDAAsD;AACpE,UAAQ,KAAK,EAAE;;CAGjB,MAAM,SAAS,MAAM,kBAAkB,QAAQ;CAE/C,MAAM,SAAS,cADC,YAAY,QAAQ,EACE,OAAO;CAE7C,MAAM,WAAW,OAAO,SAAS,WAAW;AAE5C,KAAI,OAAO,WAAW,mBAAmB;EACvC,MAAM,cAAc,qBAAqB,SAAS,OAAO,QAAQ;GAC/D,aAAa,OAAO;GACpB,cAAc,yBAAyB,OAAO;GAC/C,CAAC;AACF,MAAI,CAAC,YAAY,UAAU;AACzB,WAAQ,MAAM,qBAAqB,OAAO,CAAC;AAC3C,WAAQ,MAAM,uDAAuD,YAAY,OAAO,SAAS;AACjG,WAAQ,KAAK,EAAE;;YAER,OAAO,WAAW,WAAW;AACtC,UAAQ,MAAM,qBAAqB,OAAO,CAAC;AAC3C,UAAQ,MAAM,6FAA6F;AAC3G,UAAQ,KAAK,EAAE;YACN,OAAO,WAAW,WAAW;AACtC,UAAQ,KAAK,qBAAqB,OAAO,CAAC;AAC1C,MAAI,UAAU;AACZ,WAAQ,MAAM,iGAAiG;AAC/G,WAAQ,KAAK,EAAE;;;;AAKrB,eAAsB,kBAAkB,SAAiB,QAA+B;AACtF,KAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,OACjD;AAGF,KAAI,CAAC,oBAAoB,QAAQ,EAAE;AACjC,UAAQ,MAAM,sDAAsD;AACpE,UAAQ,KAAK,EAAE;;CAGjB,MAAM,SAAS,MAAM,kBAAkB,QAAQ;CAE/C,MAAM,SAAS,oBADC,YAAY,QAAQ,EACQ,QAAQ,QAAQ,EAC1D,sBAAsB,MACvB,CAAC;CAEF,MAAM,uBAAuB,OAAO,SAAS,yBAAyB;CACtE,MAAM,WAAW,OAAO,SAAS,WAAW;AAE5C,KAAI,OAAO,WAAW,mBAAmB;EACvC,MAAM,cAAc,qBAAqB,SAAS,OAAO,QAAQ;GAC/D,aAAa,OAAO;GACpB,cAAc,yBAAyB,OAAO;GAC/C,CAAC;AACF,MAAI,CAAC,YAAY,UAAU;AACzB,WAAQ,MAAM,qBAAqB,OAAO,CAAC;AAC3C,WAAQ,MAAM,4CAA4C,YAAY,OAAO,SAAS;AACtF,WAAQ,KAAK,EAAE;;YAER,OAAO,WAAW,UAC3B,KAAI,sBAAsB;AACxB,UAAQ,MAAM,qBAAqB,OAAO,CAAC;AAC3C,UAAQ,MAAM,kFAAkF;AAChG,UAAQ,KAAK,EAAE;QACV;AACL,UAAQ,KAAK,qBAAqB,OAAO,CAAC;AAC1C,UAAQ,KAAK,iIAAiI;;UAEvI,OAAO,WAAW,aAAa,UAAU;AAClD,UAAQ,MAAM,qBAAqB,OAAO,CAAC;AAC3C,UAAQ,MAAM,0FAA0F;AACxG,UAAQ,KAAK,EAAE;;;AAInB,SAAgB,oBAAoB,QAAsB;AACxD,KAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,OACjD;CAGF,MAAM,QAAQ,2BAA2B,OAAO;AAChD,KAAI,CAAC,MAAM,OAAO;AAChB,UAAQ,MAAM,gDAAgD,MAAM,OAAO,SAAS;AACpF,UAAQ,KAAK,EAAE;;;AAInB,SAAgB,6BAA6B,QAAsB;AACjE,KAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,OACjD;CAGF,MAAM,QAAQ,2BAA2B,QAAQ,EAAE,sBAAsB,MAAM,CAAC;AAChF,KAAI,CAAC,MAAM,OAAO;AAChB,UAAQ,MAAM,kEAAkE,MAAM,OAAO,SAAS;AACtG,UAAQ,KAAK,EAAE;;;AAInB,SAAgB,uBAAuB,QAAsB;AAC3D,KAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,OACjD;CAGF,MAAM,QAAQ,2BAA2B,QAAQ,EAAE,sBAAsB,MAAM,CAAC;AAChF,KAAI,CAAC,MAAM,OAAO;AAChB,UAAQ,MAAM,mDAAmD,MAAM,OAAO,SAAS;AACvF,UAAQ,KAAK,EAAE"}
|
package/dist/halal-core/index.js
CHANGED
|
@@ -15,4 +15,5 @@ import { runHalalExplain } from "./cli/explain.js";
|
|
|
15
15
|
import { runHalalSubmitReview } from "./cli/submitReview.js";
|
|
16
16
|
import { runHalalVerifyReview } from "./cli/verifyReview.js";
|
|
17
17
|
import { formatBrowserOverlayScript } from "./report/formatBrowserOverlay.js";
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
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,4 +1,5 @@
|
|
|
1
1
|
//#region src/halal-core/lifecycle.d.ts
|
|
2
|
-
|
|
2
|
+
declare function registerHalalCoreHooks(hooks: any, appRoot: string, outDir: string): void;
|
|
3
3
|
//#endregion
|
|
4
|
+
export { registerHalalCoreHooks };
|
|
4
5
|
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { enforceBuildGuard, enforceDevGuard } from "./enforce.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/lifecycle.ts
|
|
3
4
|
function registerHalalCoreHooks(hooks, appRoot, outDir) {
|
|
4
5
|
if (!hooks) return;
|
|
@@ -11,7 +12,7 @@ function registerHalalCoreHooks(hooks, appRoot, outDir) {
|
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
|
|
14
16
|
//#endregion
|
|
15
17
|
export { registerHalalCoreHooks };
|
|
16
|
-
|
|
17
18
|
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;AAClF,KAAI,CAAC,MAAO;AAGZ,KAAI,OAAO,MAAM,SAAS,YAAY;AACpC,QAAM,KAAK,gBAAgB,YAAY;AACrC,SAAM,kBAAkB,SAAS,OAAO;IACxC;AACF,QAAM,KAAK,cAAc,YAAY;AACnC,SAAM,gBAAgB,SAAS,OAAO;IACtC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ResuxHalalPolicy } from "./config.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/policy.d.ts
|
|
3
|
-
|
|
4
|
+
declare function defineResuxHalalPolicy(config: ResuxHalalPolicy): ResuxHalalPolicy;
|
|
4
5
|
//#endregion
|
|
6
|
+
export { defineResuxHalalPolicy };
|
|
5
7
|
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { validatePolicyConfig } from "./config.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/policy.ts
|
|
3
4
|
function defineResuxHalalPolicy(config) {
|
|
4
5
|
return validatePolicyConfig(config);
|
|
5
6
|
}
|
|
7
|
+
|
|
6
8
|
//#endregion
|
|
7
9
|
export { defineResuxHalalPolicy };
|
|
8
|
-
|
|
9
10
|
//# sourceMappingURL=policy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","names":[],"sources":["../../src/halal-core/policy.ts"],"sourcesContent":["import { validatePolicyConfig, type ResuxHalalPolicy } from \"./config.js\";\n\nexport function defineResuxHalalPolicy(config: ResuxHalalPolicy): ResuxHalalPolicy {\n return validatePolicyConfig(config);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy.js","names":[],"sources":["../../src/halal-core/policy.ts"],"sourcesContent":["import { validatePolicyConfig, type ResuxHalalPolicy } from \"./config.js\";\n\nexport function defineResuxHalalPolicy(config: ResuxHalalPolicy): ResuxHalalPolicy {\n return validatePolicyConfig(config);\n}\n"],"mappings":";;;AAEA,SAAgB,uBAAuB,QAA4C;AACjF,QAAO,qBAAqB,OAAO"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/report/formatBrowserOverlay.d.ts
|
|
3
|
-
|
|
4
|
+
declare function formatBrowserOverlayScript(report: HalalCheckResult): string;
|
|
4
5
|
//#endregion
|
|
6
|
+
export { formatBrowserOverlayScript };
|
|
5
7
|
//# sourceMappingURL=formatBrowserOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatBrowserOverlay.js","names":[],"sources":["../../../src/halal-core/report/formatBrowserOverlay.ts"],"sourcesContent":["import type { HalalCheckResult } from \"../status.js\";\n\nexport function formatBrowserOverlayScript(report: HalalCheckResult): string {\n if (report.status === \"allowed\") {\n return \"\";\n }\n\n const title = report.status === \"blocked\" ? \"Resux Core Safety Block\" : \"Resux Core Review Required\";\n const message = report.reasons.join(\"<br/>- \");\n const color = report.status === \"blocked\" ? \"#EF4444\" : \"#F59E0B\";\n\n return `\n(function() {\n if (typeof window === 'undefined') return;\n const overlay = document.createElement('div');\n overlay.id = 'resux-halal-overlay';\n overlay.style.position = 'fixed';\n overlay.style.bottom = '20px';\n overlay.style.right = '20px';\n overlay.style.zIndex = '999999';\n overlay.style.backgroundColor = '#1E293B';\n overlay.style.color = '#F8FAFC';\n overlay.style.borderLeft = '6px solid ${color}';\n overlay.style.borderRadius = '8px';\n overlay.style.padding = '16px';\n overlay.style.boxShadow = '0 10px 15px -3px rgba(0, 0, 0, 0.5)';\n overlay.style.fontFamily = 'system-ui, sans-serif';\n overlay.style.fontSize = '14px';\n overlay.style.maxWidth = '380px';\n \n overlay.innerHTML = \\`\n <div style=\"font-weight: bold; margin-bottom: 8px; font-size: 16px; color: ${color};\">${title}</div>\n <div style=\"margin-bottom: 12px; opacity: 0.9;\">\n This project has triggered framework-level safety alerts:<br/>\n <div style=\"margin-top: 6px; padding: 6px; background: #0F172A; border-radius: 4px; font-size: 12px; font-family: monospace; max-height: 120px; overflow-y: auto;\">\n - ${message}\n </div>\n </div>\n <div style=\"font-size: 12px; opacity: 0.7;\">Recommended Action: ${report.recommendedAction}</div>\n \\`;\n document.body.appendChild(overlay);\n})();\n `.trim();\n}\n"],"mappings":";AAEA,SAAgB,2BAA2B,QAAkC;
|
|
1
|
+
{"version":3,"file":"formatBrowserOverlay.js","names":[],"sources":["../../../src/halal-core/report/formatBrowserOverlay.ts"],"sourcesContent":["import type { HalalCheckResult } from \"../status.js\";\n\nexport function formatBrowserOverlayScript(report: HalalCheckResult): string {\n if (report.status === \"allowed\") {\n return \"\";\n }\n\n const title = report.status === \"blocked\" ? \"Resux Core Safety Block\" : \"Resux Core Review Required\";\n const message = report.reasons.join(\"<br/>- \");\n const color = report.status === \"blocked\" ? \"#EF4444\" : \"#F59E0B\";\n\n return `\n(function() {\n if (typeof window === 'undefined') return;\n const overlay = document.createElement('div');\n overlay.id = 'resux-halal-overlay';\n overlay.style.position = 'fixed';\n overlay.style.bottom = '20px';\n overlay.style.right = '20px';\n overlay.style.zIndex = '999999';\n overlay.style.backgroundColor = '#1E293B';\n overlay.style.color = '#F8FAFC';\n overlay.style.borderLeft = '6px solid ${color}';\n overlay.style.borderRadius = '8px';\n overlay.style.padding = '16px';\n overlay.style.boxShadow = '0 10px 15px -3px rgba(0, 0, 0, 0.5)';\n overlay.style.fontFamily = 'system-ui, sans-serif';\n overlay.style.fontSize = '14px';\n overlay.style.maxWidth = '380px';\n \n overlay.innerHTML = \\`\n <div style=\"font-weight: bold; margin-bottom: 8px; font-size: 16px; color: ${color};\">${title}</div>\n <div style=\"margin-bottom: 12px; opacity: 0.9;\">\n This project has triggered framework-level safety alerts:<br/>\n <div style=\"margin-top: 6px; padding: 6px; background: #0F172A; border-radius: 4px; font-size: 12px; font-family: monospace; max-height: 120px; overflow-y: auto;\">\n - ${message}\n </div>\n </div>\n <div style=\"font-size: 12px; opacity: 0.7;\">Recommended Action: ${report.recommendedAction}</div>\n \\`;\n document.body.appendChild(overlay);\n})();\n `.trim();\n}\n"],"mappings":";AAEA,SAAgB,2BAA2B,QAAkC;AAC3E,KAAI,OAAO,WAAW,UACpB,QAAO;CAGT,MAAM,QAAQ,OAAO,WAAW,YAAY,4BAA4B;CACxE,MAAM,UAAU,OAAO,QAAQ,KAAK,UAAU;CAC9C,MAAM,QAAQ,OAAO,WAAW,YAAY,YAAY;AAExD,QAAO;;;;;;;;;;;0CAWiC,MAAM;;;;;;;;;iFASiC,MAAM,KAAK,MAAM;;;;YAItF,QAAQ;;;sEAGkD,OAAO,kBAAkB;;;;IAI3F,MAAM"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/report/formatTerminalReport.d.ts
|
|
3
|
-
|
|
4
|
+
declare function formatTerminalReport(report: HalalCheckResult): string;
|
|
4
5
|
//#endregion
|
|
6
|
+
export { formatTerminalReport };
|
|
5
7
|
//# sourceMappingURL=formatTerminalReport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatTerminalReport.js","names":[],"sources":["../../../src/halal-core/report/formatTerminalReport.ts"],"sourcesContent":["import type { HalalCheckResult } from \"../status.js\";\n\nexport function formatTerminalReport(report: HalalCheckResult): string {\n const lines: string[] = [];\n\n if (report.status === \"blocked\") {\n lines.push(\"\\x1b[31m\\x1b[1mResux Halal Core blocked this project.\\x1b[0m\\n\");\n } else if (report.status === \"review_required\") {\n lines.push(\"\\x1b[33m\\x1b[1mResux Halal Core review required for this project.\\x1b[0m\\n\");\n } else if (report.status === \"warning\") {\n lines.push(\"\\x1b[33mResux Halal Core warning issue.\\x1b[0m\\n\");\n } else {\n lines.push(\"\\x1b[32mResux Halal Core checks passed successfully.\\x1b[0m\\n\");\n }\n\n lines.push(`Status: ${report.status}`);\n lines.push(`Risk Level: ${report.riskLevel}`);\n lines.push(`Category: ${report.categories.join(\", \") || \"none\"}`);\n lines.push(`Confidence: ${(report.confidence * 100).toFixed(0)}%`);\n \n if (report.matchedFiles.length > 0) {\n lines.push(\"\\nDetected:\");\n report.matchedFiles.slice(0, 10).forEach(file => {\n lines.push(`- ${file}`);\n });\n if (report.matchedFiles.length > 10) {\n lines.push(`- ...and ${report.matchedFiles.length - 10} more files`);\n }\n }\n\n lines.push(\"\\nReason:\");\n if (report.reasons.length > 0) {\n report.reasons.forEach(r => lines.push(`- ${r}`));\n } else {\n lines.push(\"No policy infractions triggered.\");\n }\n\n lines.push(\"\\nAction:\");\n lines.push(report.recommendedAction);\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAEA,SAAgB,qBAAqB,QAAkC;CACrE,MAAM,QAAkB,
|
|
1
|
+
{"version":3,"file":"formatTerminalReport.js","names":[],"sources":["../../../src/halal-core/report/formatTerminalReport.ts"],"sourcesContent":["import type { HalalCheckResult } from \"../status.js\";\n\nexport function formatTerminalReport(report: HalalCheckResult): string {\n const lines: string[] = [];\n\n if (report.status === \"blocked\") {\n lines.push(\"\\x1b[31m\\x1b[1mResux Halal Core blocked this project.\\x1b[0m\\n\");\n } else if (report.status === \"review_required\") {\n lines.push(\"\\x1b[33m\\x1b[1mResux Halal Core review required for this project.\\x1b[0m\\n\");\n } else if (report.status === \"warning\") {\n lines.push(\"\\x1b[33mResux Halal Core warning issue.\\x1b[0m\\n\");\n } else {\n lines.push(\"\\x1b[32mResux Halal Core checks passed successfully.\\x1b[0m\\n\");\n }\n\n lines.push(`Status: ${report.status}`);\n lines.push(`Risk Level: ${report.riskLevel}`);\n lines.push(`Category: ${report.categories.join(\", \") || \"none\"}`);\n lines.push(`Confidence: ${(report.confidence * 100).toFixed(0)}%`);\n \n if (report.matchedFiles.length > 0) {\n lines.push(\"\\nDetected:\");\n report.matchedFiles.slice(0, 10).forEach(file => {\n lines.push(`- ${file}`);\n });\n if (report.matchedFiles.length > 10) {\n lines.push(`- ...and ${report.matchedFiles.length - 10} more files`);\n }\n }\n\n lines.push(\"\\nReason:\");\n if (report.reasons.length > 0) {\n report.reasons.forEach(r => lines.push(`- ${r}`));\n } else {\n lines.push(\"No policy infractions triggered.\");\n }\n\n lines.push(\"\\nAction:\");\n lines.push(report.recommendedAction);\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAEA,SAAgB,qBAAqB,QAAkC;CACrE,MAAM,QAAkB,EAAE;AAE1B,KAAI,OAAO,WAAW,UACpB,OAAM,KAAK,iEAAiE;UACnE,OAAO,WAAW,kBAC3B,OAAM,KAAK,6EAA6E;UAC/E,OAAO,WAAW,UAC3B,OAAM,KAAK,mDAAmD;KAE9D,OAAM,KAAK,gEAAgE;AAG7E,OAAM,KAAK,WAAW,OAAO,SAAS;AACtC,OAAM,KAAK,eAAe,OAAO,YAAY;AAC7C,OAAM,KAAK,aAAa,OAAO,WAAW,KAAK,KAAK,IAAI,SAAS;AACjE,OAAM,KAAK,gBAAgB,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC,GAAG;AAElE,KAAI,OAAO,aAAa,SAAS,GAAG;AAClC,QAAM,KAAK,cAAc;AACzB,SAAO,aAAa,MAAM,GAAG,GAAG,CAAC,SAAQ,SAAQ;AAC/C,SAAM,KAAK,KAAK,OAAO;IACvB;AACF,MAAI,OAAO,aAAa,SAAS,GAC/B,OAAM,KAAK,YAAY,OAAO,aAAa,SAAS,GAAG,aAAa;;AAIxE,OAAM,KAAK,YAAY;AACvB,KAAI,OAAO,QAAQ,SAAS,EAC1B,QAAO,QAAQ,SAAQ,MAAK,MAAM,KAAK,KAAK,IAAI,CAAC;KAEjD,OAAM,KAAK,mCAAmC;AAGhD,OAAM,KAAK,YAAY;AACvB,OAAM,KAAK,OAAO,kBAAkB;AAEpC,QAAO,MAAM,KAAK,KAAK"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
2
|
import { ResuxHalalPolicy } from "../config.js";
|
|
3
|
+
|
|
3
4
|
//#region src/halal-core/report/generateHalalReport.d.ts
|
|
4
|
-
|
|
5
|
+
interface GenerateHalalReportOptions {
|
|
5
6
|
requireAuthenticated?: boolean;
|
|
6
7
|
signingSecret?: string;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
declare function generateHalalReport(scannedData: any, policy: ResuxHalalPolicy, outDir: string, options?: GenerateHalalReportOptions): HalalCheckResult;
|
|
9
10
|
//#endregion
|
|
11
|
+
export { GenerateHalalReportOptions, generateHalalReport };
|
|
10
12
|
//# sourceMappingURL=generateHalalReport.d.ts.map
|
|
@@ -2,6 +2,7 @@ import { evaluateRules } from "../rules/defaultBlockedRules.js";
|
|
|
2
2
|
import { generateReportChecksum, generateReportSignature } from "./signReport.js";
|
|
3
3
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
|
|
5
6
|
//#region src/halal-core/report/generateHalalReport.ts
|
|
6
7
|
function generateHalalReport(scannedData, policy, outDir, options = {}) {
|
|
7
8
|
const baseReport = evaluateRules(scannedData, policy);
|
|
@@ -16,10 +17,8 @@ function generateHalalReport(scannedData, policy, outDir, options = {}) {
|
|
|
16
17
|
signature
|
|
17
18
|
};
|
|
18
19
|
if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
|
|
19
|
-
|
|
20
|
-
writeFileSync(
|
|
21
|
-
const mdPath = path.join(outDir, "halal-report.md");
|
|
22
|
-
const mdContent = `
|
|
20
|
+
writeFileSync(path.join(outDir, "halal-report.json"), JSON.stringify(finalReport, null, 2), "utf8");
|
|
21
|
+
writeFileSync(path.join(outDir, "halal-report.md"), `
|
|
23
22
|
# ResuxJS Halal Core Security Report
|
|
24
23
|
|
|
25
24
|
- **Generated At**: ${createdDate}
|
|
@@ -36,11 +35,10 @@ ${finalReport.reasons.map((reason) => `- ${reason}`).join("\n") || "No warning e
|
|
|
36
35
|
|
|
37
36
|
## Action Required
|
|
38
37
|
${finalReport.recommendedAction}
|
|
39
|
-
`.trim();
|
|
40
|
-
writeFileSync(mdPath, mdContent, "utf8");
|
|
38
|
+
`.trim(), "utf8");
|
|
41
39
|
return finalReport;
|
|
42
40
|
}
|
|
41
|
+
|
|
43
42
|
//#endregion
|
|
44
43
|
export { generateHalalReport };
|
|
45
|
-
|
|
46
44
|
//# sourceMappingURL=generateHalalReport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateHalalReport.js","names":[],"sources":["../../../src/halal-core/report/generateHalalReport.ts"],"sourcesContent":["import { existsSync, writeFileSync, mkdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { evaluateRules } from \"../rules/defaultBlockedRules.js\";\nimport {\n generateReportChecksum,\n generateReportSignature,\n} from \"./signReport.js\";\nimport type { HalalCheckResult } from \"../status.js\";\nimport type { ResuxHalalPolicy } from \"../config.js\";\n\nexport interface GenerateHalalReportOptions {\n requireAuthenticated?: boolean;\n signingSecret?: string;\n}\n\nexport function generateHalalReport(\n scannedData: any,\n policy: ResuxHalalPolicy,\n outDir: string,\n options: GenerateHalalReportOptions = {},\n): HalalCheckResult {\n const baseReport = evaluateRules(scannedData, policy);\n\n const createdDate = new Date().toISOString();\n const reportToSign: Omit<HalalCheckResult, \"signature\"> = {\n ...baseReport,\n createdDate,\n };\n\n const signature = options.requireAuthenticated === true\n ? generateReportSignature(reportToSign, options.signingSecret)\n : generateReportChecksum(reportToSign);\n const finalReport: HalalCheckResult = {\n ...reportToSign,\n signature,\n };\n\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n\n const reportPath = path.join(outDir, \"halal-report.json\");\n writeFileSync(reportPath, JSON.stringify(finalReport, null, 2), \"utf8\");\n\n const mdPath = path.join(outDir, \"halal-report.md\");\n const mdContent = `\n# ResuxJS Halal Core Security Report\n\n- **Generated At**: ${createdDate}\n- **Framework Status**: **${finalReport.status.toUpperCase()}**\n- **Risk Level**: **${finalReport.riskLevel.toUpperCase()}**\n- **Confidence**: ${(finalReport.confidence * 100).toFixed(0)}%\n- **Signature**: \\`${signature}\\`\n\n## Categories Detected\n${finalReport.categories.map((category) => `- ${category}`).join(\"\\n\") || \"No policy categories violated.\"}\n\n## Reasons\n${finalReport.reasons.map((reason) => `- ${reason}`).join(\"\\n\") || \"No warning elements flagged.\"}\n\n## Action Required\n${finalReport.recommendedAction}\n `.trim();\n\n writeFileSync(mdPath, mdContent, \"utf8\");\n\n return finalReport;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateHalalReport.js","names":[],"sources":["../../../src/halal-core/report/generateHalalReport.ts"],"sourcesContent":["import { existsSync, writeFileSync, mkdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { evaluateRules } from \"../rules/defaultBlockedRules.js\";\nimport {\n generateReportChecksum,\n generateReportSignature,\n} from \"./signReport.js\";\nimport type { HalalCheckResult } from \"../status.js\";\nimport type { ResuxHalalPolicy } from \"../config.js\";\n\nexport interface GenerateHalalReportOptions {\n requireAuthenticated?: boolean;\n signingSecret?: string;\n}\n\nexport function generateHalalReport(\n scannedData: any,\n policy: ResuxHalalPolicy,\n outDir: string,\n options: GenerateHalalReportOptions = {},\n): HalalCheckResult {\n const baseReport = evaluateRules(scannedData, policy);\n\n const createdDate = new Date().toISOString();\n const reportToSign: Omit<HalalCheckResult, \"signature\"> = {\n ...baseReport,\n createdDate,\n };\n\n const signature = options.requireAuthenticated === true\n ? generateReportSignature(reportToSign, options.signingSecret)\n : generateReportChecksum(reportToSign);\n const finalReport: HalalCheckResult = {\n ...reportToSign,\n signature,\n };\n\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n\n const reportPath = path.join(outDir, \"halal-report.json\");\n writeFileSync(reportPath, JSON.stringify(finalReport, null, 2), \"utf8\");\n\n const mdPath = path.join(outDir, \"halal-report.md\");\n const mdContent = `\n# ResuxJS Halal Core Security Report\n\n- **Generated At**: ${createdDate}\n- **Framework Status**: **${finalReport.status.toUpperCase()}**\n- **Risk Level**: **${finalReport.riskLevel.toUpperCase()}**\n- **Confidence**: ${(finalReport.confidence * 100).toFixed(0)}%\n- **Signature**: \\`${signature}\\`\n\n## Categories Detected\n${finalReport.categories.map((category) => `- ${category}`).join(\"\\n\") || \"No policy categories violated.\"}\n\n## Reasons\n${finalReport.reasons.map((reason) => `- ${reason}`).join(\"\\n\") || \"No warning elements flagged.\"}\n\n## Action Required\n${finalReport.recommendedAction}\n `.trim();\n\n writeFileSync(mdPath, mdContent, \"utf8\");\n\n return finalReport;\n}\n"],"mappings":";;;;;;AAeA,SAAgB,oBACd,aACA,QACA,QACA,UAAsC,EAAE,EACtB;CAClB,MAAM,aAAa,cAAc,aAAa,OAAO;CAErD,MAAM,+BAAc,IAAI,MAAM,EAAC,aAAa;CAC5C,MAAM,eAAoD;EACxD,GAAG;EACH;EACD;CAED,MAAM,YAAY,QAAQ,yBAAyB,OAC/C,wBAAwB,cAAc,QAAQ,cAAc,GAC5D,uBAAuB,aAAa;CACxC,MAAM,cAAgC;EACpC,GAAG;EACH;EACD;AAED,KAAI,CAAC,WAAW,OAAO,CACrB,WAAU,QAAQ,EAAE,WAAW,MAAM,CAAC;AAIxC,eADmB,KAAK,KAAK,QAAQ,oBAAoB,EAC/B,KAAK,UAAU,aAAa,MAAM,EAAE,EAAE,OAAO;AAsBvE,eApBe,KAAK,KAAK,QAAQ,kBAAkB,EACjC;;;sBAGE,YAAY;4BACN,YAAY,OAAO,aAAa,CAAC;sBACvC,YAAY,UAAU,aAAa,CAAC;qBACrC,YAAY,aAAa,KAAK,QAAQ,EAAE,CAAC;qBACzC,UAAU;;;EAG7B,YAAY,WAAW,KAAK,aAAa,KAAK,WAAW,CAAC,KAAK,KAAK,IAAI,iCAAiC;;;EAGzG,YAAY,QAAQ,KAAK,WAAW,KAAK,SAAS,CAAC,KAAK,KAAK,IAAI,+BAA+B;;;EAGhG,YAAY,kBAAkB;IAC5B,MAAM,EAEyB,OAAO;AAExC,QAAO"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/report/signReport.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
declare function generateReportSignature(report: Omit<HalalCheckResult, "signature">, secret?: string): string;
|
|
5
|
+
declare function generateReportChecksum(report: Omit<HalalCheckResult, "signature">): string;
|
|
5
6
|
//#endregion
|
|
7
|
+
export { generateReportChecksum, generateReportSignature };
|
|
6
8
|
//# sourceMappingURL=signReport.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createIntegritySignature } from "../crypto/integrity.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/report/signReport.ts
|
|
3
4
|
const REPORT_SIGNING_ENV = "RESUX_HALAL_REPORT_SIGNING_SECRET";
|
|
4
5
|
function generateReportSignature(report, secret) {
|
|
@@ -15,7 +16,7 @@ function generateReportChecksum(report) {
|
|
|
15
16
|
requireSecret: false
|
|
16
17
|
});
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
//#endregion
|
|
19
21
|
export { generateReportChecksum, generateReportSignature };
|
|
20
|
-
|
|
21
22
|
//# sourceMappingURL=signReport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signReport.js","names":[],"sources":["../../../src/halal-core/report/signReport.ts"],"sourcesContent":["import type { HalalCheckResult } from \"../status.js\";\nimport { createIntegritySignature } from \"../crypto/integrity.js\";\n\nconst REPORT_SIGNING_ENV = \"RESUX_HALAL_REPORT_SIGNING_SECRET\";\n\nexport function generateReportSignature(\n report: Omit<HalalCheckResult, \"signature\">,\n secret?: string,\n): string {\n return createIntegritySignature(report, {\n envName: REPORT_SIGNING_ENV,\n secret,\n requireSecret: true,\n });\n}\n\nexport function generateReportChecksum(\n report: Omit<HalalCheckResult, \"signature\">,\n): string {\n return createIntegritySignature(report, {\n envName: REPORT_SIGNING_ENV,\n secret: \"\",\n requireSecret: false,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"signReport.js","names":[],"sources":["../../../src/halal-core/report/signReport.ts"],"sourcesContent":["import type { HalalCheckResult } from \"../status.js\";\nimport { createIntegritySignature } from \"../crypto/integrity.js\";\n\nconst REPORT_SIGNING_ENV = \"RESUX_HALAL_REPORT_SIGNING_SECRET\";\n\nexport function generateReportSignature(\n report: Omit<HalalCheckResult, \"signature\">,\n secret?: string,\n): string {\n return createIntegritySignature(report, {\n envName: REPORT_SIGNING_ENV,\n secret,\n requireSecret: true,\n });\n}\n\nexport function generateReportChecksum(\n report: Omit<HalalCheckResult, \"signature\">,\n): string {\n return createIntegritySignature(report, {\n envName: REPORT_SIGNING_ENV,\n secret: \"\",\n requireSecret: false,\n });\n}\n"],"mappings":";;;AAGA,MAAM,qBAAqB;AAE3B,SAAgB,wBACd,QACA,QACQ;AACR,QAAO,yBAAyB,QAAQ;EACtC,SAAS;EACT;EACA,eAAe;EAChB,CAAC;;AAGJ,SAAgB,uBACd,QACQ;AACR,QAAO,yBAAyB,QAAQ;EACtC,SAAS;EACT,QAAQ;EACR,eAAe;EAChB,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/report/verifyReport.d.ts
|
|
3
|
-
|
|
4
|
+
interface ReportVerificationOptions {
|
|
4
5
|
secret?: string;
|
|
5
6
|
requireAuthenticated?: boolean;
|
|
6
7
|
now?: number;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
declare function verifyReportSignature(report: HalalCheckResult, options?: ReportVerificationOptions): boolean;
|
|
10
|
+
declare function isReportValid(report: HalalCheckResult, options?: ReportVerificationOptions): {
|
|
10
11
|
valid: boolean;
|
|
11
12
|
reason?: string;
|
|
12
13
|
};
|
|
13
14
|
//#endregion
|
|
15
|
+
export { ReportVerificationOptions, isReportValid, verifyReportSignature };
|
|
14
16
|
//# sourceMappingURL=verifyReport.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isAuthenticatedIntegritySignature, verifyIntegritySignature } from "../crypto/integrity.js";
|
|
2
|
+
|
|
2
3
|
//#region src/halal-core/report/verifyReport.ts
|
|
3
4
|
const REPORT_SIGNING_ENV = "RESUX_HALAL_REPORT_SIGNING_SECRET";
|
|
4
|
-
const REPORT_MAX_AGE_MS =
|
|
5
|
-
const MAX_CLOCK_SKEW_MS =
|
|
5
|
+
const REPORT_MAX_AGE_MS = 720 * 60 * 60 * 1e3;
|
|
6
|
+
const MAX_CLOCK_SKEW_MS = 300 * 1e3;
|
|
6
7
|
function verifyReportSignature(report, options = {}) {
|
|
7
8
|
if (!report || typeof report !== "object" || !report.signature) return false;
|
|
8
9
|
const { signature, ...rest } = report;
|
|
@@ -49,7 +50,7 @@ function isReportValid(report, options = {}) {
|
|
|
49
50
|
};
|
|
50
51
|
return { valid: true };
|
|
51
52
|
}
|
|
53
|
+
|
|
52
54
|
//#endregion
|
|
53
55
|
export { isReportValid, verifyReportSignature };
|
|
54
|
-
|
|
55
56
|
//# sourceMappingURL=verifyReport.js.map
|